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

Side by Side Diff: ui/views/controls/menu/menu_host.cc

Issue 2155243007: Turn Bookmark Menus Async (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge the pretarget handlers Created 4 years, 4 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 | « ui/views/controls/menu/menu_host.h ('k') | ui/views/controls/menu/menu_key_event_handler.h » ('j') | 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 #include "ui/views/controls/menu/menu_host.h" 5 #include "ui/views/controls/menu/menu_host.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/trace_event/trace_event.h" 9 #include "base/trace_event/trace_event.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 212 }
213 213
214 void MenuHost::OnDragWillStart() { 214 void MenuHost::OnDragWillStart() {
215 MenuController* menu_controller = 215 MenuController* menu_controller =
216 submenu_->GetMenuItem()->GetMenuController(); 216 submenu_->GetMenuItem()->GetMenuController();
217 DCHECK(menu_controller); 217 DCHECK(menu_controller);
218 menu_controller->OnDragWillStart(); 218 menu_controller->OnDragWillStart();
219 } 219 }
220 220
221 void MenuHost::OnDragComplete() { 221 void MenuHost::OnDragComplete() {
222 // If we are being destroyed there is no guarantee that the menu items are
223 // available.
224 if (destroying_)
225 return;
222 MenuController* menu_controller = 226 MenuController* menu_controller =
223 submenu_->GetMenuItem()->GetMenuController(); 227 submenu_->GetMenuItem()->GetMenuController();
224 if (destroying_ || !menu_controller) 228 if (!menu_controller)
225 return; 229 return;
226 230
227 bool should_close = true; 231 bool should_close = true;
228 // If the view came from outside menu code (i.e., not a MenuItemView), we 232 // If the view came from outside menu code (i.e., not a MenuItemView), we
229 // should consult the MenuDelegate to determine whether or not to close on 233 // should consult the MenuDelegate to determine whether or not to close on
230 // exit. 234 // exit.
231 if (!menu_controller->did_initiate_drag()) { 235 if (!menu_controller->did_initiate_drag()) {
232 MenuDelegate* menu_delegate = submenu_->GetMenuItem()->GetDelegate(); 236 MenuDelegate* menu_delegate = submenu_->GetMenuItem()->GetDelegate();
233 should_close = 237 should_close =
234 menu_delegate ? menu_delegate->ShouldCloseOnDragComplete() : should_close; 238 menu_delegate ? menu_delegate->ShouldCloseOnDragComplete() : should_close;
235 } 239 }
236 menu_controller->OnDragComplete(should_close); 240 menu_controller->OnDragComplete(should_close);
237 241
238 // We may have lost capture in the drag and drop, but are remaining open. 242 // We may have lost capture in the drag and drop, but are remaining open.
239 // Return capture so we get MouseCaptureLost events. 243 // Return capture so we get MouseCaptureLost events.
240 if (!should_close) 244 if (!should_close)
241 native_widget_private()->SetCapture(); 245 native_widget_private()->SetCapture();
242 } 246 }
243 247
244 } // namespace views 248 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/menu/menu_host.h ('k') | ui/views/controls/menu/menu_key_event_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698