| 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" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 26 this, content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
| 27 content::Source<RenderWidgetHost>(render_view_host)); | 27 content::Source<RenderWidgetHost>(render_view_host)); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void PopupMenuHelper::ShowPopupMenu( | 30 void PopupMenuHelper::ShowPopupMenu( |
| 31 const gfx::Rect& bounds, | 31 const gfx::Rect& bounds, |
| 32 int item_height, | 32 int item_height, |
| 33 double item_font_size, | 33 double item_font_size, |
| 34 int selected_item, | 34 int selected_item, |
| 35 const std::vector<WebMenuItem>& items, | 35 const std::vector<WebMenuItem>& items, |
| 36 bool right_aligned) { | 36 bool right_aligned, |
| 37 bool allow_multiple_selection) { |
| 38 // Only single selection list boxes show a popup on Mac. |
| 39 DCHECK(!allow_multiple_selection); |
| 40 |
| 37 // Retain the Cocoa view for the duration of the pop-up so that it can't be | 41 // Retain the Cocoa view for the duration of the pop-up so that it can't be |
| 38 // dealloced if my Destroy() method is called while the pop-up's up (which | 42 // dealloced if my Destroy() method is called while the pop-up's up (which |
| 39 // would in turn delete me, causing a crash once the -runMenuInView | 43 // would in turn delete me, causing a crash once the -runMenuInView |
| 40 // call returns. That's what was happening in <http://crbug.com/33250>). | 44 // call returns. That's what was happening in <http://crbug.com/33250>). |
| 41 RenderWidgetHostViewMac* rwhvm = | 45 RenderWidgetHostViewMac* rwhvm = |
| 42 static_cast<RenderWidgetHostViewMac*>(render_view_host_->GetView()); | 46 static_cast<RenderWidgetHostViewMac*>(render_view_host_->GetView()); |
| 43 scoped_nsobject<RenderWidgetHostViewCocoa> cocoa_view | 47 scoped_nsobject<RenderWidgetHostViewCocoa> cocoa_view |
| 44 ([rwhvm->cocoa_view() retain]); | 48 ([rwhvm->cocoa_view() retain]); |
| 45 | 49 |
| 46 // Display the menu. | 50 // Display the menu. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 86 |
| 83 void PopupMenuHelper::Observe( | 87 void PopupMenuHelper::Observe( |
| 84 int type, | 88 int type, |
| 85 const content::NotificationSource& source, | 89 const content::NotificationSource& source, |
| 86 const content::NotificationDetails& details) { | 90 const content::NotificationDetails& details) { |
| 87 DCHECK(type == content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED); | 91 DCHECK(type == content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED); |
| 88 DCHECK(content::Source<RenderWidgetHost>(source).ptr() == render_view_host_); | 92 DCHECK(content::Source<RenderWidgetHost>(source).ptr() == render_view_host_); |
| 89 render_view_host_ = NULL; | 93 render_view_host_ = NULL; |
| 90 } | 94 } |
| 91 | 95 |
| OLD | NEW |