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 #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/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
9 #include "ui/events/gestures/gesture_recognizer.h" | 9 #include "ui/events/gestures/gesture_recognizer.h" |
10 #include "ui/gfx/path.h" | 10 #include "ui/gfx/path.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 void MenuHost::OnOwnerClosing() { | 128 void MenuHost::OnOwnerClosing() { |
129 if (destroying_) | 129 if (destroying_) |
130 return; | 130 return; |
131 | 131 |
132 MenuController* menu_controller = | 132 MenuController* menu_controller = |
133 submenu_->GetMenuItem()->GetMenuController(); | 133 submenu_->GetMenuItem()->GetMenuController(); |
134 if (menu_controller && !menu_controller->drag_in_progress()) | 134 if (menu_controller && !menu_controller->drag_in_progress()) |
135 menu_controller->CancelAll(); | 135 menu_controller->CancelAll(); |
136 } | 136 } |
137 | 137 |
| 138 void MenuHost::OnDragWillStart() { |
| 139 MenuController* menu_controller = |
| 140 submenu_->GetMenuItem()->GetMenuController(); |
| 141 DCHECK(menu_controller); |
| 142 menu_controller->OnDragWillStart(); |
| 143 } |
| 144 |
| 145 void MenuHost::OnDragComplete() { |
| 146 MenuController* menu_controller = |
| 147 submenu_->GetMenuItem()->GetMenuController(); |
| 148 if (destroying_ || !menu_controller) |
| 149 return; |
| 150 |
| 151 bool should_close = true; |
| 152 // If the view came from outside menu code (i.e., not a MenuItemView), we |
| 153 // should consult the MenuDelegate to determine whether or not to close on |
| 154 // exit. |
| 155 if (!menu_controller->did_initiate_drag()) { |
| 156 MenuDelegate* menu_delegate = submenu_->GetMenuItem()->GetDelegate(); |
| 157 should_close = |
| 158 menu_delegate ? menu_delegate->ShouldCloseOnDragComplete() : should_close; |
| 159 } |
| 160 menu_controller->OnDragComplete(should_close); |
| 161 |
| 162 // We may have lost capture in the drag and drop, but are remaining open. |
| 163 // Return capture so we get MouseCaptureLost events. |
| 164 if (!should_close) |
| 165 native_widget_private()->SetCapture(); |
| 166 } |
| 167 |
138 } // namespace views | 168 } // namespace views |
OLD | NEW |