OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/popup_menu_helper_mac.h" | 7 #include "chrome/browser/tab_contents/popup_menu_helper_mac.h" |
8 | 8 |
9 #include "base/memory/scoped_nsobject.h" | 9 #include "base/memory/scoped_nsobject.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" | 11 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" |
12 #import "chrome/browser/ui/cocoa/base_view.h" | 12 #import "chrome/browser/ui/cocoa/base_view.h" |
13 #include "content/browser/renderer_host/render_view_host.h" | 13 #include "content/browser/renderer_host/render_view_host.h" |
14 #import "content/common/chrome_application_mac.h" | 14 #import "content/common/chrome_application_mac.h" |
15 #include "content/common/notification_source.h" | 15 #include "content/common/notification_source.h" |
16 #include "webkit/glue/webmenurunner_mac.h" | 16 #include "webkit/glue/webmenurunner_mac.h" |
17 | 17 |
18 PopupMenuHelper::PopupMenuHelper(RenderViewHost* render_view_host) | 18 PopupMenuHelper::PopupMenuHelper(RenderViewHost* render_view_host) |
19 : render_view_host_(render_view_host) { | 19 : render_view_host_(render_view_host) { |
20 notification_registrar_.Add( | 20 notification_registrar_.Add( |
21 this, NotificationType::RENDER_WIDGET_HOST_DESTROYED, | 21 this, content::RENDER_WIDGET_HOST_DESTROYED, |
22 Source<RenderWidgetHost>(render_view_host)); | 22 Source<RenderWidgetHost>(render_view_host)); |
23 } | 23 } |
24 | 24 |
25 void PopupMenuHelper::ShowPopupMenu( | 25 void PopupMenuHelper::ShowPopupMenu( |
26 const gfx::Rect& bounds, | 26 const gfx::Rect& bounds, |
27 int item_height, | 27 int item_height, |
28 double item_font_size, | 28 double item_font_size, |
29 int selected_item, | 29 int selected_item, |
30 const std::vector<WebMenuItem>& items, | 30 const std::vector<WebMenuItem>& items, |
31 bool right_aligned) { | 31 bool right_aligned) { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 | 69 |
70 if ([menu_runner menuItemWasChosen]) { | 70 if ([menu_runner menuItemWasChosen]) { |
71 render_view_host_->DidSelectPopupMenuItem( | 71 render_view_host_->DidSelectPopupMenuItem( |
72 [menu_runner indexOfSelectedItem]); | 72 [menu_runner indexOfSelectedItem]); |
73 } else { | 73 } else { |
74 render_view_host_->DidCancelPopupMenu(); | 74 render_view_host_->DidCancelPopupMenu(); |
75 } | 75 } |
76 } | 76 } |
77 | 77 |
78 void PopupMenuHelper::Observe( | 78 void PopupMenuHelper::Observe( |
79 NotificationType type, | 79 int type, |
80 const NotificationSource& source, | 80 const NotificationSource& source, |
81 const NotificationDetails& details) { | 81 const NotificationDetails& details) { |
82 DCHECK(type == NotificationType::RENDER_WIDGET_HOST_DESTROYED); | 82 DCHECK(type == content::RENDER_WIDGET_HOST_DESTROYED); |
83 RenderViewHost* rvh = Source<RenderViewHost>(source).ptr(); | 83 RenderViewHost* rvh = Source<RenderViewHost>(source).ptr(); |
84 DCHECK_EQ(render_view_host_, rvh); | 84 DCHECK_EQ(render_view_host_, rvh); |
85 render_view_host_ = NULL; | 85 render_view_host_ = NULL; |
86 } | 86 } |
87 | 87 |
OLD | NEW |