Index: ui/views/controls/menu/menu_host.cc |
diff --git a/ui/views/controls/menu/menu_host.cc b/ui/views/controls/menu/menu_host.cc |
index 2716ec8bb782c1a46288c0ab449d80a2a96e2caf..40d874927d132779960df84136f8ae3d1ac7be32 100644 |
--- a/ui/views/controls/menu/menu_host.cc |
+++ b/ui/views/controls/menu/menu_host.cc |
@@ -135,4 +135,34 @@ void MenuHost::OnOwnerClosing() { |
menu_controller->CancelAll(); |
} |
+void MenuHost::OnDragWillStart() { |
+ MenuController* menu_controller = |
+ submenu_->GetMenuItem()->GetMenuController(); |
+ if (menu_controller) |
sky
2014/07/14 15:19:05
The if should be a DCHECK
Devlin
2014/07/16 16:00:45
Done. For my own edification, why should it be DC
sky
2014/07/16 19:19:00
MenuHost may outlive MenuController, hence the nec
|
+ menu_controller->OnDragWillStart(); |
+} |
+ |
+void MenuHost::OnDragComplete(View* dragged_view) { |
+ MenuController* menu_controller = |
+ submenu_->GetMenuItem()->GetMenuController(); |
+ if (destroying_ || !menu_controller) |
+ return; |
+ |
+ bool should_close = true; |
+ // If the view came from outside menu code (i.e., not a MenuItemView), we |
+ // should consult the MenuDelegate to determine whether or not to close on |
+ // exit. |
+ if (dragged_view && dragged_view->id() != MenuItemView::kMenuItemViewID) { |
Devlin
2014/07/11 20:28:15
I think this should work for ensuring the delegate
sky
2014/07/14 15:19:05
It would be safer to make MenuController know it i
Devlin
2014/07/16 16:00:45
Done.
|
+ MenuDelegate* menu_delegate = submenu_->GetMenuItem()->GetDelegate(); |
+ should_close = |
+ menu_delegate ? menu_delegate->ShouldCloseOnDragComplete() : should_close; |
+ } |
+ menu_controller->OnDragComplete(should_close); |
+ |
+ // We may have lost capture in the drag and drop, but are remaining open. |
+ // Return capture so we get MouseCaptureLost events. |
+ if (!should_close) |
+ native_widget_private()->SetCapture(); |
+} |
+ |
} // namespace views |