| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_ |
| 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 11 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
| 12 #include "content/browser/web_contents/web_contents_view.h" | 12 #include "content/browser/web_contents/web_contents_view.h" |
| 13 #include "content/public/browser/web_contents_view_delegate.h" | 13 #include "content/public/browser/web_contents_view_delegate.h" |
| 14 #include "content/public/common/context_menu_params.h" | 14 #include "content/public/common/context_menu_params.h" |
| 15 #include "content/public/common/drop_data.h" | 15 #include "content/public/common/drop_data.h" |
| 16 #include "ui/android/overscroll_refresh.h" |
| 16 #include "ui/android/view_android.h" | 17 #include "ui/android/view_android.h" |
| 17 #include "ui/gfx/geometry/rect_f.h" | 18 #include "ui/gfx/geometry/rect_f.h" |
| 18 | 19 |
| 19 namespace content { | 20 namespace content { |
| 20 class ContentViewCoreImpl; | 21 class ContentViewCoreImpl; |
| 21 class SynchronousCompositorClient; | 22 class SynchronousCompositorClient; |
| 22 class WebContentsImpl; | 23 class WebContentsImpl; |
| 23 | 24 |
| 24 // Android-specific implementation of the WebContentsView. | 25 // Android-specific implementation of the WebContentsView. |
| 25 class WebContentsViewAndroid : public WebContentsView, | 26 class WebContentsViewAndroid : public WebContentsView, |
| 26 public RenderViewHostDelegateView { | 27 public RenderViewHostDelegateView { |
| 27 public: | 28 public: |
| 28 WebContentsViewAndroid(WebContentsImpl* web_contents, | 29 WebContentsViewAndroid(WebContentsImpl* web_contents, |
| 29 WebContentsViewDelegate* delegate); | 30 WebContentsViewDelegate* delegate); |
| 30 ~WebContentsViewAndroid() override; | 31 ~WebContentsViewAndroid() override; |
| 31 | 32 |
| 32 // Sets the interface to the view system. ContentViewCoreImpl is owned | 33 // Sets the interface to the view system. ContentViewCoreImpl is owned |
| 33 // by its Java ContentViewCore counterpart, whose lifetime is managed | 34 // by its Java ContentViewCore counterpart, whose lifetime is managed |
| 34 // by the UI frontend. | 35 // by the UI frontend. |
| 35 void SetContentViewCore(ContentViewCoreImpl* content_view_core); | 36 void SetContentViewCore(ContentViewCoreImpl* content_view_core); |
| 36 | 37 |
| 37 void set_synchronous_compositor_client(SynchronousCompositorClient* client) { | 38 void set_synchronous_compositor_client(SynchronousCompositorClient* client) { |
| 38 synchronous_compositor_client_ = client; | 39 synchronous_compositor_client_ = client; |
| 39 } | 40 } |
| 40 | 41 |
| 41 SynchronousCompositorClient* synchronous_compositor_client() const { | 42 SynchronousCompositorClient* synchronous_compositor_client() const { |
| 42 return synchronous_compositor_client_; | 43 return synchronous_compositor_client_; |
| 43 } | 44 } |
| 44 | 45 |
| 46 void SetOverscrollRefreshHandler( |
| 47 std::unique_ptr<ui::OverscrollRefreshHandler> overscroll_refresh_handler); |
| 48 |
| 45 // WebContentsView implementation -------------------------------------------- | 49 // WebContentsView implementation -------------------------------------------- |
| 46 gfx::NativeView GetNativeView() const override; | 50 gfx::NativeView GetNativeView() const override; |
| 47 gfx::NativeView GetContentNativeView() const override; | 51 gfx::NativeView GetContentNativeView() const override; |
| 48 gfx::NativeWindow GetTopLevelNativeWindow() const override; | 52 gfx::NativeWindow GetTopLevelNativeWindow() const override; |
| 49 void GetScreenInfo(ScreenInfo* screen_info) const override; | 53 void GetScreenInfo(ScreenInfo* screen_info) const override; |
| 50 void GetContainerBounds(gfx::Rect* out) const override; | 54 void GetContainerBounds(gfx::Rect* out) const override; |
| 51 void SizeContents(const gfx::Size& size) override; | 55 void SizeContents(const gfx::Size& size) override; |
| 52 void Focus() override; | 56 void Focus() override; |
| 53 void SetInitialFocus() override; | 57 void SetInitialFocus() override; |
| 54 void StoreFocus() override; | 58 void StoreFocus() override; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 72 const ContextMenuParams& params) override; | 76 const ContextMenuParams& params) override; |
| 73 void ShowPopupMenu(RenderFrameHost* render_frame_host, | 77 void ShowPopupMenu(RenderFrameHost* render_frame_host, |
| 74 const gfx::Rect& bounds, | 78 const gfx::Rect& bounds, |
| 75 int item_height, | 79 int item_height, |
| 76 double item_font_size, | 80 double item_font_size, |
| 77 int selected_item, | 81 int selected_item, |
| 78 const std::vector<MenuItem>& items, | 82 const std::vector<MenuItem>& items, |
| 79 bool right_aligned, | 83 bool right_aligned, |
| 80 bool allow_multiple_selection) override; | 84 bool allow_multiple_selection) override; |
| 81 void HidePopupMenu() override; | 85 void HidePopupMenu() override; |
| 86 ui::OverscrollRefreshHandler* GetOverscrollRefreshHandler() const override; |
| 82 void StartDragging(const DropData& drop_data, | 87 void StartDragging(const DropData& drop_data, |
| 83 blink::WebDragOperationsMask allowed_ops, | 88 blink::WebDragOperationsMask allowed_ops, |
| 84 const gfx::ImageSkia& image, | 89 const gfx::ImageSkia& image, |
| 85 const gfx::Vector2d& image_offset, | 90 const gfx::Vector2d& image_offset, |
| 86 const DragEventSourceInfo& event_info, | 91 const DragEventSourceInfo& event_info, |
| 87 RenderWidgetHostImpl* source_rwh) override; | 92 RenderWidgetHostImpl* source_rwh) override; |
| 88 void UpdateDragCursor(blink::WebDragOperation operation) override; | 93 void UpdateDragCursor(blink::WebDragOperation operation) override; |
| 89 void GotFocus() override; | 94 void GotFocus() override; |
| 90 void TakeFocus(bool reverse) override; | 95 void TakeFocus(bool reverse) override; |
| 91 | 96 |
| 92 void OnDragEntered(const std::vector<DropData::Metadata>& metadata, | 97 void OnDragEntered(const std::vector<DropData::Metadata>& metadata, |
| 93 const gfx::Point& location, | 98 const gfx::Point& location, |
| 94 const gfx::Point& screen_location); | 99 const gfx::Point& screen_location); |
| 95 void OnDragUpdated(const gfx::Point& location, | 100 void OnDragUpdated(const gfx::Point& location, |
| 96 const gfx::Point& screen_location); | 101 const gfx::Point& screen_location); |
| 97 void OnDragExited(); | 102 void OnDragExited(); |
| 98 void OnPerformDrop(DropData* drop_data, | 103 void OnPerformDrop(DropData* drop_data, |
| 99 const gfx::Point& location, | 104 const gfx::Point& location, |
| 100 const gfx::Point& screen_location); | 105 const gfx::Point& screen_location); |
| 101 void OnDragEnded(); | 106 void OnDragEnded(); |
| 102 | 107 |
| 103 private: | 108 private: |
| 104 // The WebContents whose contents we display. | 109 // The WebContents whose contents we display. |
| 105 WebContentsImpl* web_contents_; | 110 WebContentsImpl* web_contents_; |
| 106 | 111 |
| 107 // ContentViewCoreImpl is our interface to the view system. | 112 // ContentViewCoreImpl is our interface to the view system. |
| 108 ContentViewCoreImpl* content_view_core_; | 113 ContentViewCoreImpl* content_view_core_; |
| 109 | 114 |
| 115 // Handles "overscroll to refresh" events |
| 116 std::unique_ptr<ui::OverscrollRefreshHandler> overscroll_refresh_handler_; |
| 117 |
| 110 // Interface for extensions to WebContentsView. Used to show the context menu. | 118 // Interface for extensions to WebContentsView. Used to show the context menu. |
| 111 std::unique_ptr<WebContentsViewDelegate> delegate_; | 119 std::unique_ptr<WebContentsViewDelegate> delegate_; |
| 112 | 120 |
| 113 // The native view associated with the contents of the web. | 121 // The native view associated with the contents of the web. |
| 114 ui::ViewAndroid view_; | 122 ui::ViewAndroid view_; |
| 115 | 123 |
| 116 // Interface used to get notified of events from the synchronous compositor. | 124 // Interface used to get notified of events from the synchronous compositor. |
| 117 SynchronousCompositorClient* synchronous_compositor_client_; | 125 SynchronousCompositorClient* synchronous_compositor_client_; |
| 118 | 126 |
| 119 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAndroid); | 127 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAndroid); |
| 120 }; | 128 }; |
| 121 | 129 |
| 122 } // namespace content | 130 } // namespace content |
| 123 | 131 |
| 124 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_ | 132 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_ANDROID_H_ |
| OLD | NEW |