| 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 #import <Carbon/Carbon.h> | 5 #import <Carbon/Carbon.h> |
| 6 | 6 |
| 7 #include "content/browser/renderer_host/popup_menu_helper_mac.h" | 7 #include "content/browser/renderer_host/popup_menu_helper_mac.h" |
| 8 | 8 |
| 9 #import "base/mac/scoped_sending_event.h" | 9 #import "base/mac/scoped_sending_event.h" |
| 10 #include "base/memory/scoped_nsobject.h" | 10 #include "base/memory/scoped_nsobject.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "content/browser/renderer_host/render_view_host_impl.h" | 12 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 13 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 13 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 14 #include "content/public/browser/notification_source.h" | 14 #include "content/public/browser/notification_source.h" |
| 15 #include "content/public/browser/notification_types.h" | 15 #include "content/public/browser/notification_types.h" |
| 16 #import "ui/base/cocoa/base_view.h" | 16 #import "ui/base/cocoa/base_view.h" |
| 17 #include "webkit/glue/webmenurunner_mac.h" | 17 #include "webkit/glue/webmenurunner_mac.h" |
| 18 | 18 |
| 19 using content::RenderViewHost; | 19 namespace content { |
| 20 using content::RenderViewHostImpl; | |
| 21 using content::RenderWidgetHost; | |
| 22 | 20 |
| 23 PopupMenuHelper::PopupMenuHelper(RenderViewHost* render_view_host) | 21 PopupMenuHelper::PopupMenuHelper(RenderViewHost* render_view_host) |
| 24 : render_view_host_(static_cast<RenderViewHostImpl*>(render_view_host)) { | 22 : render_view_host_(static_cast<RenderViewHostImpl*>(render_view_host)) { |
| 25 notification_registrar_.Add( | 23 notification_registrar_.Add( |
| 26 this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 24 this, NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 27 content::Source<RenderWidgetHost>(render_view_host)); | 25 Source<RenderWidgetHost>(render_view_host)); |
| 28 } | 26 } |
| 29 | 27 |
| 30 void PopupMenuHelper::ShowPopupMenu( | 28 void PopupMenuHelper::ShowPopupMenu( |
| 31 const gfx::Rect& bounds, | 29 const gfx::Rect& bounds, |
| 32 int item_height, | 30 int item_height, |
| 33 double item_font_size, | 31 double item_font_size, |
| 34 int selected_item, | 32 int selected_item, |
| 35 const std::vector<WebMenuItem>& items, | 33 const std::vector<WebMenuItem>& items, |
| 36 bool right_aligned, | 34 bool right_aligned, |
| 37 bool allow_multiple_selection) { | 35 bool allow_multiple_selection) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 75 } |
| 78 | 76 |
| 79 if ([menu_runner menuItemWasChosen]) { | 77 if ([menu_runner menuItemWasChosen]) { |
| 80 render_view_host_->DidSelectPopupMenuItem( | 78 render_view_host_->DidSelectPopupMenuItem( |
| 81 [menu_runner indexOfSelectedItem]); | 79 [menu_runner indexOfSelectedItem]); |
| 82 } else { | 80 } else { |
| 83 render_view_host_->DidCancelPopupMenu(); | 81 render_view_host_->DidCancelPopupMenu(); |
| 84 } | 82 } |
| 85 } | 83 } |
| 86 | 84 |
| 87 void PopupMenuHelper::Observe( | 85 void PopupMenuHelper::Observe(int type, |
| 88 int type, | 86 const NotificationSource& source, |
| 89 const content::NotificationSource& source, | 87 const NotificationDetails& details) { |
| 90 const content::NotificationDetails& details) { | 88 DCHECK(type == NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED); |
| 91 DCHECK(type == content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED); | 89 DCHECK(Source<RenderWidgetHost>(source).ptr() == render_view_host_); |
| 92 DCHECK(content::Source<RenderWidgetHost>(source).ptr() == render_view_host_); | |
| 93 render_view_host_ = NULL; | 90 render_view_host_ = NULL; |
| 94 } | 91 } |
| 95 | 92 |
| 93 } // namespace content |
| OLD | NEW |