thin_webview.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // Copyright 2019 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_THIN_WEBVIEW_INTERNAL_THIN_WEBVIEW_H_
  5. #define COMPONENTS_THIN_WEBVIEW_INTERNAL_THIN_WEBVIEW_H_
  6. #include <jni.h>
  7. #include "base/android/jni_android.h"
  8. #include "base/android/scoped_java_ref.h"
  9. #include "base/memory/raw_ptr.h"
  10. #include "components/thin_webview/internal/compositor_view_impl.h"
  11. #include "content/public/browser/web_contents.h"
  12. #include "content/public/browser/web_contents_observer.h"
  13. #include "ui/android/window_android.h"
  14. namespace web_contents_delegate_android {
  15. class WebContentsDelegateAndroid;
  16. } // namespace web_contents_delegate_android
  17. namespace thin_webview {
  18. namespace android {
  19. // Native counterpart of ThinWebViewImpl.java.
  20. class ThinWebView : public content::WebContentsObserver {
  21. public:
  22. ThinWebView(JNIEnv* env,
  23. jobject obj,
  24. CompositorView* compositor_view,
  25. ui::WindowAndroid* window_android);
  26. ThinWebView(const ThinWebView&) = delete;
  27. ThinWebView& operator=(const ThinWebView&) = delete;
  28. ~ThinWebView() override;
  29. void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& object);
  30. void SetWebContents(
  31. JNIEnv* env,
  32. const base::android::JavaParamRef<jobject>& object,
  33. const base::android::JavaParamRef<jobject>& jweb_contents,
  34. const base::android::JavaParamRef<jobject>& jweb_contents_delegate);
  35. void SizeChanged(JNIEnv* env,
  36. const base::android::JavaParamRef<jobject>& object,
  37. jint width,
  38. jint height);
  39. private:
  40. // content::WebContentsObserver overrides:
  41. void PrimaryPageChanged(content::Page& page) override;
  42. void SetWebContents(
  43. content::WebContents* web_contents,
  44. web_contents_delegate_android::WebContentsDelegateAndroid* delegate);
  45. void ResizeWebContents(const gfx::Size& size);
  46. base::android::ScopedJavaGlobalRef<jobject> obj_;
  47. raw_ptr<CompositorView> compositor_view_;
  48. raw_ptr<ui::WindowAndroid> window_android_;
  49. raw_ptr<content::WebContents> web_contents_;
  50. std::unique_ptr<web_contents_delegate_android::WebContentsDelegateAndroid>
  51. web_contents_delegate_;
  52. gfx::Size view_size_;
  53. };
  54. } // namespace android
  55. } // namespace thin_webview
  56. #endif // COMPONENTS_THIN_WEBVIEW_INTERNAL_THIN_WEBVIEW_H_