Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: content/browser/web_contents/web_contents_view_mac.mm

Issue 501583003: Move external popup menus from WebViewClient to WebFrameClient, part 3/3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nicer ipc Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #import <Carbon/Carbon.h> 5 #import <Carbon/Carbon.h>
6 6
7 #import "content/browser/web_contents/web_contents_view_mac.h" 7 #import "content/browser/web_contents/web_contents_view_mac.h"
8 8
9 #include <string> 9 #include <string>
10 10
11 #import "base/mac/scoped_sending_event.h" 11 #import "base/mac/scoped_sending_event.h"
12 #include "base/message_loop/message_loop.h" 12 #include "base/message_loop/message_loop.h"
13 #import "base/message_loop/message_pump_mac.h" 13 #import "base/message_loop/message_pump_mac.h"
14 #include "content/browser/renderer_host/popup_menu_helper_mac.h" 14 #include "content/browser/frame_host/popup_menu_helper_mac.h"
15 #include "content/browser/renderer_host/render_view_host_factory.h" 15 #include "content/browser/renderer_host/render_view_host_factory.h"
16 #include "content/browser/renderer_host/render_view_host_impl.h" 16 #include "content/browser/renderer_host/render_view_host_impl.h"
17 #include "content/browser/renderer_host/render_widget_host_view_mac.h" 17 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
18 #include "content/browser/web_contents/web_contents_impl.h" 18 #include "content/browser/web_contents/web_contents_impl.h"
19 #import "content/browser/web_contents/web_drag_dest_mac.h" 19 #import "content/browser/web_contents/web_drag_dest_mac.h"
20 #import "content/browser/web_contents/web_drag_source_mac.h" 20 #import "content/browser/web_contents/web_drag_source_mac.h"
21 #include "content/common/view_messages.h" 21 #include "content/common/view_messages.h"
22 #include "content/public/browser/web_contents_delegate.h" 22 #include "content/public/browser/web_contents_delegate.h"
23 #include "content/public/browser/web_contents_view_delegate.h" 23 #include "content/public/browser/web_contents_view_delegate.h"
24 #include "skia/ext/skia_utils_mac.h" 24 #include "skia/ext/skia_utils_mac.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 dragOperationMask:(NSDragOperation)operationMask 61 dragOperationMask:(NSDragOperation)operationMask
62 image:(NSImage*)image 62 image:(NSImage*)image
63 offset:(NSPoint)offset; 63 offset:(NSPoint)offset;
64 - (void)cancelDeferredClose; 64 - (void)cancelDeferredClose;
65 - (void)clearWebContentsView; 65 - (void)clearWebContentsView;
66 - (void)closeTabAfterEvent; 66 - (void)closeTabAfterEvent;
67 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification; 67 - (void)viewDidBecomeFirstResponder:(NSNotification*)notification;
68 @end 68 @end
69 69
70 namespace content { 70 namespace content {
71
71 WebContentsView* CreateWebContentsView( 72 WebContentsView* CreateWebContentsView(
72 WebContentsImpl* web_contents, 73 WebContentsImpl* web_contents,
73 WebContentsViewDelegate* delegate, 74 WebContentsViewDelegate* delegate,
74 RenderViewHostDelegateView** render_view_host_delegate_view) { 75 RenderViewHostDelegateView** render_view_host_delegate_view) {
75 WebContentsViewMac* rv = new WebContentsViewMac(web_contents, delegate); 76 WebContentsViewMac* rv = new WebContentsViewMac(web_contents, delegate);
76 *render_view_host_delegate_view = rv; 77 *render_view_host_delegate_view = rv;
77 return rv; 78 return rv;
78 } 79 }
79 80
80 WebContentsViewMac::WebContentsViewMac(WebContentsImpl* web_contents, 81 WebContentsViewMac::WebContentsViewMac(WebContentsImpl* web_contents,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 // iterated past the last focusable element on the page). 213 // iterated past the last focusable element on the page).
213 void WebContentsViewMac::TakeFocus(bool reverse) { 214 void WebContentsViewMac::TakeFocus(bool reverse) {
214 if (reverse) { 215 if (reverse) {
215 [[cocoa_view_ window] selectPreviousKeyView:cocoa_view_.get()]; 216 [[cocoa_view_ window] selectPreviousKeyView:cocoa_view_.get()];
216 } else { 217 } else {
217 [[cocoa_view_ window] selectNextKeyView:cocoa_view_.get()]; 218 [[cocoa_view_ window] selectNextKeyView:cocoa_view_.get()];
218 } 219 }
219 } 220 }
220 221
221 void WebContentsViewMac::ShowContextMenu( 222 void WebContentsViewMac::ShowContextMenu(
222 content::RenderFrameHost* render_frame_host, 223 RenderFrameHost* render_frame_host,
223 const ContextMenuParams& params) { 224 const ContextMenuParams& params) {
224 // Allow delegates to handle the context menu operation first. 225 // Allow delegates to handle the context menu operation first.
225 if (web_contents_->GetDelegate() && 226 if (web_contents_->GetDelegate() &&
226 web_contents_->GetDelegate()->HandleContextMenu(params)) { 227 web_contents_->GetDelegate()->HandleContextMenu(params)) {
227 return; 228 return;
228 } 229 }
229 230
230 if (delegate()) 231 if (delegate())
231 delegate()->ShowContextMenu(render_frame_host, params); 232 delegate()->ShowContextMenu(render_frame_host, params);
232 else 233 else
233 DLOG(ERROR) << "Cannot show context menus without a delegate."; 234 DLOG(ERROR) << "Cannot show context menus without a delegate.";
234 } 235 }
235 236
236 // Display a popup menu for WebKit using Cocoa widgets.
237 void WebContentsViewMac::ShowPopupMenu( 237 void WebContentsViewMac::ShowPopupMenu(
238 RenderFrameHost* render_frame_host,
238 const gfx::Rect& bounds, 239 const gfx::Rect& bounds,
239 int item_height, 240 int item_height,
240 double item_font_size, 241 double item_font_size,
241 int selected_item, 242 int selected_item,
242 const std::vector<MenuItem>& items, 243 const std::vector<MenuItem>& items,
243 bool right_aligned, 244 bool right_aligned,
244 bool allow_multiple_selection) { 245 bool allow_multiple_selection) {
245 popup_menu_helper_.reset( 246 popup_menu_helper_.reset(new PopupMenuHelper(render_frame_host));
246 new PopupMenuHelper(web_contents_->GetRenderViewHost()));
247 popup_menu_helper_->ShowPopupMenu(bounds, item_height, item_font_size, 247 popup_menu_helper_->ShowPopupMenu(bounds, item_height, item_font_size,
248 selected_item, items, right_aligned, 248 selected_item, items, right_aligned,
249 allow_multiple_selection); 249 allow_multiple_selection);
250 popup_menu_helper_.reset(); 250 popup_menu_helper_.reset();
251 } 251 }
252 252
253 void WebContentsViewMac::HidePopupMenu() { 253 void WebContentsViewMac::HidePopupMenu() {
254 if (popup_menu_helper_) 254 if (popup_menu_helper_)
255 popup_menu_helper_->Hide(); 255 popup_menu_helper_->Hide();
256 } 256 }
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // When the subviews require a layout, their size should be reset to the size 577 // When the subviews require a layout, their size should be reset to the size
578 // of this view. (It is possible for the size to get out of sync as an 578 // of this view. (It is possible for the size to get out of sync as an
579 // optimization in preparation for an upcoming WebContentsView resize. 579 // optimization in preparation for an upcoming WebContentsView resize.
580 // http://crbug.com/264207) 580 // http://crbug.com/264207)
581 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { 581 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize {
582 for (NSView* subview in self.subviews) 582 for (NSView* subview in self.subviews)
583 [subview setFrame:self.bounds]; 583 [subview setFrame:self.bounds];
584 } 584 }
585 585
586 @end 586 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698