OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ |
6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ | 6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 class GinJavaBridgeDispatcherHost; | 42 class GinJavaBridgeDispatcherHost; |
43 class RenderFrameHost; | 43 class RenderFrameHost; |
44 class RenderWidgetHostViewAndroid; | 44 class RenderWidgetHostViewAndroid; |
45 struct MenuItem; | 45 struct MenuItem; |
46 | 46 |
47 class ContentViewCoreImpl : public ContentViewCore, | 47 class ContentViewCoreImpl : public ContentViewCore, |
48 public ui::OverscrollRefreshHandler, | 48 public ui::OverscrollRefreshHandler, |
49 public WebContentsObserver { | 49 public WebContentsObserver { |
50 public: | 50 public: |
51 static ContentViewCoreImpl* FromWebContents(WebContents* web_contents); | 51 static ContentViewCoreImpl* FromWebContents(WebContents* web_contents); |
52 ContentViewCoreImpl(JNIEnv* env, | 52 ContentViewCoreImpl( |
53 jobject obj, | 53 JNIEnv* env, |
54 WebContents* web_contents, | 54 jobject obj, |
55 jobject view_android, | 55 WebContents* web_contents, |
56 ui::WindowAndroid* window_android, | 56 const base::android::JavaRef<jobject>& view_android_delegate, |
57 jobject java_bridge_retained_object_set); | 57 ui::WindowAndroid* window_android, |
| 58 jobject java_bridge_retained_object_set); |
58 | 59 |
59 // ContentViewCore implementation. | 60 // ContentViewCore implementation. |
60 base::android::ScopedJavaLocalRef<jobject> GetJavaObject() override; | 61 base::android::ScopedJavaLocalRef<jobject> GetJavaObject() override; |
61 WebContents* GetWebContents() const override; | 62 WebContents* GetWebContents() const override; |
62 ui::WindowAndroid* GetWindowAndroid() const override; | 63 ui::WindowAndroid* GetWindowAndroid() const override; |
63 const scoped_refptr<cc::Layer>& GetLayer() const override; | 64 const base::android::JavaRef<jobject>& GetViewAndroidDelegate() |
| 65 const override; |
| 66 cc::Layer* GetLayer() const override; |
64 bool ShowPastePopup(int x, int y) override; | 67 bool ShowPastePopup(int x, int y) override; |
65 float GetDpiScale() const override; | 68 float GetDpiScale() const override; |
66 void PauseOrResumeGeolocation(bool should_pause) override; | 69 void PauseOrResumeGeolocation(bool should_pause) override; |
67 void RequestTextSurroundingSelection( | 70 void RequestTextSurroundingSelection( |
68 int max_length, | 71 int max_length, |
69 const base::Callback<void(const base::string16& content, | 72 const base::Callback<void(const base::string16& content, |
70 int start_offset, | 73 int start_offset, |
71 int end_offset)>& callback) override; | 74 int end_offset)>& callback) override; |
72 | 75 |
73 void AddObserver(ContentViewCoreImplObserver* observer); | 76 void AddObserver(ContentViewCoreImplObserver* observer); |
74 void RemoveObserver(ContentViewCoreImplObserver* observer); | 77 void RemoveObserver(ContentViewCoreImplObserver* observer); |
75 | 78 |
76 // ViewAndroid implementation | |
77 base::android::ScopedJavaLocalRef<jobject> GetViewAndroidDelegate() | |
78 const override; | |
79 | |
80 // -------------------------------------------------------------------------- | 79 // -------------------------------------------------------------------------- |
81 // Methods called from Java via JNI | 80 // Methods called from Java via JNI |
82 // -------------------------------------------------------------------------- | 81 // -------------------------------------------------------------------------- |
83 | 82 |
84 base::android::ScopedJavaLocalRef<jobject> GetWebContentsAndroid( | 83 base::android::ScopedJavaLocalRef<jobject> GetWebContentsAndroid( |
85 JNIEnv* env, | 84 JNIEnv* env, |
86 const base::android::JavaParamRef<jobject>& obj); | 85 const base::android::JavaParamRef<jobject>& obj); |
87 base::android::ScopedJavaLocalRef<jobject> GetJavaWindowAndroid( | 86 base::android::ScopedJavaLocalRef<jobject> GetJavaWindowAndroid( |
88 JNIEnv* env, | 87 JNIEnv* env, |
89 const base::android::JavaParamRef<jobject>& obj); | 88 const base::android::JavaParamRef<jobject>& obj); |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 void AttachLayer(scoped_refptr<cc::Layer> layer); | 393 void AttachLayer(scoped_refptr<cc::Layer> layer); |
395 void RemoveLayer(scoped_refptr<cc::Layer> layer); | 394 void RemoveLayer(scoped_refptr<cc::Layer> layer); |
396 | 395 |
397 void MoveRangeSelectionExtent(const gfx::PointF& extent); | 396 void MoveRangeSelectionExtent(const gfx::PointF& extent); |
398 | 397 |
399 void SelectBetweenCoordinates(const gfx::PointF& base, | 398 void SelectBetweenCoordinates(const gfx::PointF& base, |
400 const gfx::PointF& extent); | 399 const gfx::PointF& extent); |
401 | 400 |
402 void OnShowUnhandledTapUIIfNeeded(int x_dip, int y_dip); | 401 void OnShowUnhandledTapUIIfNeeded(int x_dip, int y_dip); |
403 | 402 |
| 403 ui::ViewAndroid* GetViewAndroid(); |
| 404 |
404 private: | 405 private: |
405 class ContentViewUserData; | 406 class ContentViewUserData; |
406 | 407 |
407 friend class ContentViewUserData; | 408 friend class ContentViewUserData; |
408 ~ContentViewCoreImpl() override; | 409 ~ContentViewCoreImpl() override; |
409 | 410 |
410 // WebContentsObserver implementation. | 411 // WebContentsObserver implementation. |
411 void RenderViewReady() override; | 412 void RenderViewReady() override; |
412 void RenderViewHostChanged(RenderViewHost* old_host, | 413 void RenderViewHostChanged(RenderViewHost* old_host, |
413 RenderViewHost* new_host) override; | 414 RenderViewHost* new_host) override; |
(...skipping 27 matching lines...) Expand all Loading... |
441 void SetFocusInternal(bool focused); | 442 void SetFocusInternal(bool focused); |
442 | 443 |
443 // Send device_orientation_ to renderer. | 444 // Send device_orientation_ to renderer. |
444 void SendOrientationChangeEventInternal(); | 445 void SendOrientationChangeEventInternal(); |
445 | 446 |
446 float dpi_scale() const { return dpi_scale_; } | 447 float dpi_scale() const { return dpi_scale_; } |
447 | 448 |
448 // A weak reference to the Java ContentViewCore object. | 449 // A weak reference to the Java ContentViewCore object. |
449 JavaObjectWeakGlobalRef java_ref_; | 450 JavaObjectWeakGlobalRef java_ref_; |
450 | 451 |
| 452 ui::ViewAndroid view_; |
| 453 |
451 // Reference to the current WebContents used to determine how and what to | 454 // Reference to the current WebContents used to determine how and what to |
452 // display in the ContentViewCore. | 455 // display in the ContentViewCore. |
453 WebContentsImpl* web_contents_; | 456 WebContentsImpl* web_contents_; |
454 | 457 |
455 // A compositor layer containing any layer that should be shown. | |
456 scoped_refptr<cc::Layer> root_layer_; | |
457 | |
458 // Page scale factor. | 458 // Page scale factor. |
459 float page_scale_; | 459 float page_scale_; |
460 | 460 |
461 // Java delegate to acquire and release anchor views from the NativeView | |
462 base::android::ScopedJavaGlobalRef<jobject> view_android_delegate_; | |
463 | |
464 // Device scale factor. | 461 // Device scale factor. |
465 const float dpi_scale_; | 462 const float dpi_scale_; |
466 | 463 |
467 // The owning window that has a hold of main application activity. | |
468 ui::WindowAndroid* window_android_; | |
469 | |
470 // Observer to notify of lifecyle changes. | 464 // Observer to notify of lifecyle changes. |
471 base::ObserverList<ContentViewCoreImplObserver> observer_list_; | 465 base::ObserverList<ContentViewCoreImplObserver> observer_list_; |
472 | 466 |
473 // The cache of device's current orientation set from Java side, this value | 467 // The cache of device's current orientation set from Java side, this value |
474 // will be sent to Renderer once it is ready. | 468 // will be sent to Renderer once it is ready. |
475 int device_orientation_; | 469 int device_orientation_; |
476 | 470 |
477 bool accessibility_enabled_; | 471 bool accessibility_enabled_; |
478 | 472 |
479 // Manages injecting Java objects. | 473 // Manages injecting Java objects. |
480 scoped_refptr<GinJavaBridgeDispatcherHost> java_bridge_dispatcher_host_; | 474 scoped_refptr<GinJavaBridgeDispatcherHost> java_bridge_dispatcher_host_; |
481 | 475 |
482 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); | 476 DISALLOW_COPY_AND_ASSIGN(ContentViewCoreImpl); |
483 }; | 477 }; |
484 | 478 |
485 bool RegisterContentViewCore(JNIEnv* env); | 479 bool RegisterContentViewCore(JNIEnv* env); |
486 | 480 |
487 } // namespace content | 481 } // namespace content |
488 | 482 |
489 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ | 483 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIEW_CORE_IMPL_H_ |
OLD | NEW |