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_MAC_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_MAC_H_ |
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_MAC_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_MAC_H_ |
7 | 7 |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/mac/scoped_nsobject.h" | 14 #include "base/mac/scoped_nsobject.h" |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "content/browser/frame_host/popup_menu_helper_mac.h" |
16 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 17 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
17 #include "content/browser/web_contents/web_contents_view.h" | 18 #include "content/browser/web_contents/web_contents_view.h" |
18 #include "content/common/content_export.h" | 19 #include "content/common/content_export.h" |
19 #include "content/common/drag_event_source_info.h" | 20 #include "content/common/drag_event_source_info.h" |
20 #include "ui/base/cocoa/base_view.h" | 21 #include "ui/base/cocoa/base_view.h" |
21 #include "ui/gfx/geometry/size.h" | 22 #include "ui/gfx/geometry/size.h" |
22 | 23 |
23 @class FocusTracker; | 24 @class FocusTracker; |
24 @class WebDragDest; | 25 @class WebDragDest; |
25 @class WebDragSource; | 26 @class WebDragSource; |
26 | 27 |
27 namespace content { | 28 namespace content { |
28 class PopupMenuHelper; | |
29 class RenderWidgetHostViewMac; | 29 class RenderWidgetHostViewMac; |
30 class WebContentsImpl; | 30 class WebContentsImpl; |
31 class WebContentsViewDelegate; | 31 class WebContentsViewDelegate; |
32 class WebContentsViewMac; | 32 class WebContentsViewMac; |
33 } | 33 } |
34 | 34 |
35 namespace gfx { | 35 namespace gfx { |
36 class Vector2d; | 36 class Vector2d; |
37 } | 37 } |
38 | 38 |
(...skipping 16 matching lines...) Expand all Loading... |
55 // NSDraggingSource. It is supposedly deprecated, but the non-deprecated API | 55 // NSDraggingSource. It is supposedly deprecated, but the non-deprecated API |
56 // -[NSWindow dragImage:...] still relies on it. | 56 // -[NSWindow dragImage:...] still relies on it. |
57 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal; | 57 - (NSDragOperation)draggingSourceOperationMaskForLocal:(BOOL)isLocal; |
58 @end | 58 @end |
59 | 59 |
60 namespace content { | 60 namespace content { |
61 | 61 |
62 // Mac-specific implementation of the WebContentsView. It owns an NSView that | 62 // Mac-specific implementation of the WebContentsView. It owns an NSView that |
63 // contains all of the contents of the tab and associated child views. | 63 // contains all of the contents of the tab and associated child views. |
64 class WebContentsViewMac : public WebContentsView, | 64 class WebContentsViewMac : public WebContentsView, |
65 public RenderViewHostDelegateView { | 65 public RenderViewHostDelegateView, |
| 66 public PopupMenuHelper::Delegate { |
66 public: | 67 public: |
67 // The corresponding WebContentsImpl is passed in the constructor, and manages | 68 // The corresponding WebContentsImpl is passed in the constructor, and manages |
68 // our lifetime. This doesn't need to be the case, but is this way currently | 69 // our lifetime. This doesn't need to be the case, but is this way currently |
69 // because that's what was easiest when they were split. | 70 // because that's what was easiest when they were split. |
70 WebContentsViewMac(WebContentsImpl* web_contents, | 71 WebContentsViewMac(WebContentsImpl* web_contents, |
71 WebContentsViewDelegate* delegate); | 72 WebContentsViewDelegate* delegate); |
72 ~WebContentsViewMac() override; | 73 ~WebContentsViewMac() override; |
73 | 74 |
74 // WebContentsView implementation -------------------------------------------- | 75 // WebContentsView implementation -------------------------------------------- |
75 gfx::NativeView GetNativeView() const override; | 76 gfx::NativeView GetNativeView() const override; |
(...skipping 17 matching lines...) Expand all Loading... |
93 bool is_guest_view_hack) override; | 94 bool is_guest_view_hack) override; |
94 RenderWidgetHostViewBase* CreateViewForPopupWidget( | 95 RenderWidgetHostViewBase* CreateViewForPopupWidget( |
95 RenderWidgetHost* render_widget_host) override; | 96 RenderWidgetHost* render_widget_host) override; |
96 void SetPageTitle(const base::string16& title) override; | 97 void SetPageTitle(const base::string16& title) override; |
97 void RenderViewCreated(RenderViewHost* host) override; | 98 void RenderViewCreated(RenderViewHost* host) override; |
98 void RenderViewSwappedIn(RenderViewHost* host) override; | 99 void RenderViewSwappedIn(RenderViewHost* host) override; |
99 void SetOverscrollControllerEnabled(bool enabled) override; | 100 void SetOverscrollControllerEnabled(bool enabled) override; |
100 bool IsEventTracking() const override; | 101 bool IsEventTracking() const override; |
101 void CloseTabAfterEventTracking() override; | 102 void CloseTabAfterEventTracking() override; |
102 | 103 |
103 // Backend implementation of RenderViewHostDelegateView. | 104 // RenderViewHostDelegateView: |
| 105 void StartDragging(const DropData& drop_data, |
| 106 blink::WebDragOperationsMask allowed_operations, |
| 107 const gfx::ImageSkia& image, |
| 108 const gfx::Vector2d& image_offset, |
| 109 const DragEventSourceInfo& event_info, |
| 110 RenderWidgetHostImpl* source_rwh) override; |
| 111 void UpdateDragCursor(blink::WebDragOperation operation) override; |
| 112 void GotFocus() override; |
| 113 void TakeFocus(bool reverse) override; |
104 void ShowContextMenu(RenderFrameHost* render_frame_host, | 114 void ShowContextMenu(RenderFrameHost* render_frame_host, |
105 const ContextMenuParams& params) override; | 115 const ContextMenuParams& params) override; |
106 void ShowPopupMenu(RenderFrameHost* render_frame_host, | 116 void ShowPopupMenu(RenderFrameHost* render_frame_host, |
107 const gfx::Rect& bounds, | 117 const gfx::Rect& bounds, |
108 int item_height, | 118 int item_height, |
109 double item_font_size, | 119 double item_font_size, |
110 int selected_item, | 120 int selected_item, |
111 const std::vector<MenuItem>& items, | 121 const std::vector<MenuItem>& items, |
112 bool right_aligned, | 122 bool right_aligned, |
113 bool allow_multiple_selection) override; | 123 bool allow_multiple_selection) override; |
114 void HidePopupMenu() override; | 124 void HidePopupMenu() override; |
115 void StartDragging(const DropData& drop_data, | 125 |
116 blink::WebDragOperationsMask allowed_operations, | 126 // PopupMenuHelper::Delegate: |
117 const gfx::ImageSkia& image, | 127 void OnMenuClosed() override; |
118 const gfx::Vector2d& image_offset, | |
119 const DragEventSourceInfo& event_info, | |
120 RenderWidgetHostImpl* source_rwh) override; | |
121 void UpdateDragCursor(blink::WebDragOperation operation) override; | |
122 void GotFocus() override; | |
123 void TakeFocus(bool reverse) override; | |
124 | 128 |
125 // A helper method for closing the tab in the | 129 // A helper method for closing the tab in the |
126 // CloseTabAfterEventTracking() implementation. | 130 // CloseTabAfterEventTracking() implementation. |
127 void CloseTab(); | 131 void CloseTab(); |
128 | 132 |
129 WebContentsImpl* web_contents() { return web_contents_; } | 133 WebContentsImpl* web_contents() { return web_contents_; } |
130 WebContentsViewDelegate* delegate() { return delegate_.get(); } | 134 WebContentsViewDelegate* delegate() { return delegate_.get(); } |
131 | 135 |
132 using RenderWidgetHostViewCreateFunction = | 136 using RenderWidgetHostViewCreateFunction = |
133 RenderWidgetHostViewMac* (*)(RenderWidgetHost*, bool); | 137 RenderWidgetHostViewMac* (*)(RenderWidgetHost*, bool); |
(...skipping 25 matching lines...) Expand all Loading... |
159 bool allow_other_views_; | 163 bool allow_other_views_; |
160 | 164 |
161 std::unique_ptr<PopupMenuHelper> popup_menu_helper_; | 165 std::unique_ptr<PopupMenuHelper> popup_menu_helper_; |
162 | 166 |
163 DISALLOW_COPY_AND_ASSIGN(WebContentsViewMac); | 167 DISALLOW_COPY_AND_ASSIGN(WebContentsViewMac); |
164 }; | 168 }; |
165 | 169 |
166 } // namespace content | 170 } // namespace content |
167 | 171 |
168 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_MAC_H_ | 172 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_MAC_H_ |
OLD | NEW |