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

Side by Side Diff: chrome/browser/tab_contents/tab_contents_view_mac.mm

Issue 4078003: Refactoring select popup on Mac.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 1 month 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" 7 #include "chrome/browser/tab_contents/tab_contents_view_mac.h"
8 8
9 #include <string> 9 #include <string>
10 10
11 #import "base/chrome_application_mac.h" 11 #import "base/chrome_application_mac.h"
12 #import "chrome/browser/cocoa/focus_tracker.h" 12 #import "chrome/browser/cocoa/focus_tracker.h"
13 #import "chrome/browser/cocoa/browser_window_controller.h" 13 #import "chrome/browser/cocoa/browser_window_controller.h"
14 #include "chrome/browser/global_keyboard_shortcuts_mac.h" 14 #include "chrome/browser/global_keyboard_shortcuts_mac.h"
15 #include "chrome/browser/cocoa/sad_tab_controller.h" 15 #include "chrome/browser/cocoa/sad_tab_controller.h"
16 #import "chrome/browser/cocoa/web_drag_source.h" 16 #import "chrome/browser/cocoa/web_drag_source.h"
17 #import "chrome/browser/cocoa/web_drop_target.h" 17 #import "chrome/browser/cocoa/web_drop_target.h"
18 #import "chrome/browser/cocoa/view_id_util.h" 18 #import "chrome/browser/cocoa/view_id_util.h"
19 #include "chrome/browser/renderer_host/render_view_host.h" 19 #include "chrome/browser/renderer_host/render_view_host.h"
20 #include "chrome/browser/renderer_host/render_view_host_factory.h" 20 #include "chrome/browser/renderer_host/render_view_host_factory.h"
21 #include "chrome/browser/renderer_host/render_widget_host.h" 21 #include "chrome/browser/renderer_host/render_widget_host.h"
22 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" 22 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
23 #include "chrome/browser/tab_contents/popup_menu_helper_mac.h"
23 #include "chrome/browser/tab_contents/render_view_context_menu_mac.h" 24 #include "chrome/browser/tab_contents/render_view_context_menu_mac.h"
24 #include "chrome/browser/tab_contents/tab_contents.h" 25 #include "chrome/browser/tab_contents/tab_contents.h"
25 #include "chrome/browser/tab_contents/tab_contents_delegate.h" 26 #include "chrome/browser/tab_contents/tab_contents_delegate.h"
26 #include "chrome/common/notification_type.h" 27 #include "chrome/common/notification_type.h"
27 #include "chrome/common/notification_service.h" 28 #include "chrome/common/notification_service.h"
28 #include "chrome/common/render_messages.h" 29 #include "chrome/common/render_messages.h"
29 #include "skia/ext/skia_utils_mac.h" 30 #include "skia/ext/skia_utils_mac.h"
30 #import "third_party/mozilla/NSPasteboard+Utils.h" 31 #import "third_party/mozilla/NSPasteboard+Utils.h"
31 32
32 using WebKit::WebDragOperation; 33 using WebKit::WebDragOperation;
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 } 246 }
246 } 247 }
247 248
248 void TabContentsViewMac::ShowContextMenu(const ContextMenuParams& params) { 249 void TabContentsViewMac::ShowContextMenu(const ContextMenuParams& params) {
249 RenderViewContextMenuMac menu(tab_contents(), 250 RenderViewContextMenuMac menu(tab_contents(),
250 params, 251 params,
251 GetContentNativeView()); 252 GetContentNativeView());
252 menu.Init(); 253 menu.Init();
253 } 254 }
254 255
256 // Display a popup menu for WebKit using Cocoa widgets.
257 void TabContentsViewMac::ShowPopupMenu(
258 const gfx::Rect& bounds,
259 int item_height,
260 double item_font_size,
261 int selected_item,
262 const std::vector<WebMenuItem>& items,
263 bool right_aligned) {
264 PopupMenuHelper popup_menu_helper(tab_contents()->render_view_host());
265 popup_menu_helper.ShowPopupMenu(bounds, item_height, item_font_size,
266 selected_item, items, right_aligned);
267 }
268
255 RenderWidgetHostView* TabContentsViewMac::CreateNewWidgetInternal( 269 RenderWidgetHostView* TabContentsViewMac::CreateNewWidgetInternal(
256 int route_id, 270 int route_id,
257 WebKit::WebPopupType popup_type) { 271 WebKit::WebPopupType popup_type) {
258 // A RenderWidgetHostViewMac has lifetime scoped to the view. We'll retain it 272 // A RenderWidgetHostViewMac has lifetime scoped to the view. We'll retain it
259 // to allow it to survive the trip without being hosted. 273 // to allow it to survive the trip without being hosted.
260 RenderWidgetHostView* widget_view = 274 RenderWidgetHostView* widget_view =
261 TabContentsView::CreateNewWidgetInternal(route_id, popup_type); 275 TabContentsView::CreateNewWidgetInternal(route_id, popup_type);
262 RenderWidgetHostViewMac* widget_view_mac = 276 RenderWidgetHostViewMac* widget_view_mac =
263 static_cast<RenderWidgetHostViewMac*>(widget_view); 277 static_cast<RenderWidgetHostViewMac*>(widget_view);
264 [widget_view_mac->native_view() retain]; 278 [widget_view_mac->native_view() retain];
265 279
266 // |widget_view_mac| needs to know how to position itself in our view.
267 widget_view_mac->set_parent_view(cocoa_view_);
268
269 return widget_view; 280 return widget_view;
270 } 281 }
271 282
272 void TabContentsViewMac::ShowCreatedWidgetInternal( 283 void TabContentsViewMac::ShowCreatedWidgetInternal(
273 RenderWidgetHostView* widget_host_view, 284 RenderWidgetHostView* widget_host_view,
274 const gfx::Rect& initial_pos) { 285 const gfx::Rect& initial_pos) {
275 TabContentsView::ShowCreatedWidgetInternal(widget_host_view, initial_pos); 286 TabContentsView::ShowCreatedWidgetInternal(widget_host_view, initial_pos);
276 287
277 // A RenderWidgetHostViewMac has lifetime scoped to the view. Now that it's 288 // A RenderWidgetHostViewMac has lifetime scoped to the view. Now that it's
278 // properly embedded (or purposefully ignored) we can release the retain we 289 // properly embedded (or purposefully ignored) we can release the retain we
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 [NSObject cancelPreviousPerformRequestsWithTarget:self 476 [NSObject cancelPreviousPerformRequestsWithTarget:self
466 selector:aSel 477 selector:aSel
467 object:nil]; 478 object:nil];
468 } 479 }
469 480
470 - (void)closeTabAfterEvent { 481 - (void)closeTabAfterEvent {
471 tabContentsView_->CloseTab(); 482 tabContentsView_->CloseTab();
472 } 483 }
473 484
474 @end 485 @end
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents_view_mac.h ('k') | chrome/browser/views/tab_contents/tab_contents_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698