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

Side by Side Diff: content/browser/frame_host/popup_menu_helper_mac.mm

Issue 839573002: On Mac: Hide any popup menus on the active view before switching to another. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix moved to popup_menu_helper_mac.mm Created 5 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/browser/frame_host/popup_menu_helper_mac.h" 7 #include "content/browser/frame_host/popup_menu_helper_mac.h"
8 8
9 #include "base/mac/scoped_nsobject.h" 9 #include "base/mac/scoped_nsobject.h"
10 #import "base/mac/scoped_sending_event.h" 10 #import "base/mac/scoped_sending_event.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "content/browser/frame_host/render_frame_host_impl.h" 12 #include "content/browser/frame_host/render_frame_host_impl.h"
13 #include "content/browser/renderer_host/render_view_host_impl.h" 13 #include "content/browser/renderer_host/render_view_host_impl.h"
14 #include "content/browser/renderer_host/render_widget_host_view_mac.h" 14 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
15 #include "content/browser/renderer_host/webmenurunner_mac.h" 15 #include "content/browser/renderer_host/webmenurunner_mac.h"
16 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_source.h" 17 #include "content/public/browser/notification_source.h"
17 #include "content/public/browser/notification_types.h" 18 #include "content/public/browser/notification_types.h"
18 #import "ui/base/cocoa/base_view.h" 19 #import "ui/base/cocoa/base_view.h"
19 20
20 namespace content { 21 namespace content {
21 22
22 namespace { 23 namespace {
23 24
24 bool g_allow_showing_popup_menus = true; 25 bool g_allow_showing_popup_menus = true;
25 26
26 } // namespace 27 } // namespace
27 28
28 PopupMenuHelper::PopupMenuHelper(RenderFrameHost* render_frame_host) 29 PopupMenuHelper::PopupMenuHelper(RenderFrameHost* render_frame_host)
29 : render_frame_host_(static_cast<RenderFrameHostImpl*>(render_frame_host)), 30 : render_frame_host_(static_cast<RenderFrameHostImpl*>(render_frame_host)),
30 menu_runner_(nil), 31 menu_runner_(nil),
31 popup_was_hidden_(false) { 32 popup_was_hidden_(false) {
32 notification_registrar_.Add( 33 notification_registrar_.Add(
33 this, NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, 34 this, NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED,
34 Source<RenderWidgetHost>(render_frame_host->GetRenderViewHost())); 35 Source<RenderWidgetHost>(render_frame_host->GetRenderViewHost()));
36 notification_registrar_.Add(
37 this, NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED,
38 Source<RenderWidgetHost>(render_frame_host->GetRenderViewHost()));
35 } 39 }
36 40
37 void PopupMenuHelper::ShowPopupMenu( 41 void PopupMenuHelper::ShowPopupMenu(
38 const gfx::Rect& bounds, 42 const gfx::Rect& bounds,
39 int item_height, 43 int item_height,
40 double item_font_size, 44 double item_font_size,
41 int selected_item, 45 int selected_item,
42 const std::vector<MenuItem>& items, 46 const std::vector<MenuItem>& items,
43 bool right_aligned, 47 bool right_aligned,
44 bool allow_multiple_selection) { 48 bool allow_multiple_selection) {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 116 }
113 117
114 RenderWidgetHostViewMac* PopupMenuHelper::GetRenderWidgetHostView() const { 118 RenderWidgetHostViewMac* PopupMenuHelper::GetRenderWidgetHostView() const {
115 return static_cast<RenderWidgetHostViewMac*>( 119 return static_cast<RenderWidgetHostViewMac*>(
116 render_frame_host_->GetRenderViewHost()->GetView()); 120 render_frame_host_->GetRenderViewHost()->GetView());
117 } 121 }
118 122
119 void PopupMenuHelper::Observe(int type, 123 void PopupMenuHelper::Observe(int type,
120 const NotificationSource& source, 124 const NotificationSource& source,
121 const NotificationDetails& details) { 125 const NotificationDetails& details) {
122 DCHECK(type == NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED);
123 DCHECK_EQ(Source<RenderWidgetHost>(source).ptr(), 126 DCHECK_EQ(Source<RenderWidgetHost>(source).ptr(),
124 render_frame_host_->GetRenderViewHost()); 127 render_frame_host_->GetRenderViewHost());
125 render_frame_host_ = NULL; 128 switch (type) {
129 case NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED: {
130 render_frame_host_ = NULL;
131 break;
132 }
133 case NOTIFICATION_RENDER_WIDGET_VISIBILITY_CHANGED: {
134 bool is_visible = *Details<bool>(details).ptr();
135 if (!is_visible)
136 Hide();
137 break;
138 }
139 }
126 } 140 }
127 141
128 } // namespace content 142 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698