OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_runner_impl.h" | 5 #include "ui/views/controls/menu/menu_runner_impl.h" |
6 | 6 |
7 #include "ui/native_theme/native_theme.h" | 7 #include "ui/native_theme/native_theme.h" |
8 #include "ui/views/controls/button/menu_button.h" | 8 #include "ui/views/controls/button/menu_button.h" |
9 #include "ui/views/controls/menu/menu_controller.h" | 9 #include "ui/views/controls/menu/menu_controller.h" |
10 #include "ui/views/controls/menu/menu_delegate.h" | 10 #include "ui/views/controls/menu/menu_delegate.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 return MenuRunner::NORMAL_EXIT; | 98 return MenuRunner::NORMAL_EXIT; |
99 } | 99 } |
100 // Drop menus don't block the message loop, so it's ok to create a new | 100 // Drop menus don't block the message loop, so it's ok to create a new |
101 // MenuController. | 101 // MenuController. |
102 controller = NULL; | 102 controller = NULL; |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 running_ = true; | 106 running_ = true; |
107 for_drop_ = (run_types & MenuRunner::FOR_DROP) != 0; | 107 for_drop_ = (run_types & MenuRunner::FOR_DROP) != 0; |
108 bool has_mnemonics = (run_types & MenuRunner::HAS_MNEMONICS) != 0; | 108 bool has_mnemonics = |
| 109 (run_types & MenuRunner::HAS_MNEMONICS) != 0 && !for_drop_; |
109 owns_controller_ = false; | 110 owns_controller_ = false; |
110 if (!controller) { | 111 if (!controller) { |
111 // No menus are showing, show one. | 112 // No menus are showing, show one. |
112 ui::NativeTheme* theme = | 113 ui::NativeTheme* theme = |
113 parent ? parent->GetNativeTheme() : ui::NativeTheme::instance(); | 114 parent ? parent->GetNativeTheme() : ui::NativeTheme::instance(); |
114 controller = new MenuController(theme, !for_drop_, this); | 115 controller = new MenuController(theme, !for_drop_, this); |
115 owns_controller_ = true; | 116 owns_controller_ = true; |
116 } | 117 } |
117 controller->set_is_combobox((run_types & MenuRunner::COMBOBOX) != 0); | 118 controller->set_is_combobox((run_types & MenuRunner::COMBOBOX) != 0); |
118 controller_ = controller; | 119 controller_ = controller; |
119 menu_->set_controller(controller_); | 120 menu_->set_controller(controller_); |
120 menu_->PrepareForRun(owns_controller_, | 121 menu_->PrepareForRun(owns_controller_, |
121 has_mnemonics, | 122 has_mnemonics, |
122 !for_drop_ && ShouldShowMnemonics(button)); | 123 !for_drop_ && ShouldShowMnemonics(button)); |
123 | 124 |
124 // Run the loop. | 125 // Run the loop. |
125 int mouse_event_flags = 0; | 126 int mouse_event_flags = 0; |
126 MenuItemView* result = | 127 MenuItemView* result = |
127 controller->Run(parent, | 128 controller->Run(parent, |
128 button, | 129 button, |
129 menu_, | 130 menu_, |
130 bounds, | 131 bounds, |
131 anchor, | 132 anchor, |
132 (run_types & MenuRunner::CONTEXT_MENU) != 0, | 133 (run_types & MenuRunner::CONTEXT_MENU) != 0, |
133 (run_types & MenuRunner::NESTED_DRAG) != 0, | |
134 &mouse_event_flags); | 134 &mouse_event_flags); |
135 // Get the time of the event which closed this menu. | 135 // Get the time of the event which closed this menu. |
136 closing_event_time_ = controller->closing_event_time(); | 136 closing_event_time_ = controller->closing_event_time(); |
137 if (for_drop_) { | 137 if (for_drop_) { |
138 // Drop menus return immediately. We finish processing in DropMenuClosed. | 138 // Drop menus return immediately. We finish processing in DropMenuClosed. |
139 return MenuRunner::NORMAL_EXIT; | 139 return MenuRunner::NORMAL_EXIT; |
140 } | 140 } |
141 return MenuDone(result, mouse_event_flags); | 141 return MenuDone(result, mouse_event_flags); |
142 } | 142 } |
143 | 143 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 #if defined(OS_WIN) | 208 #if defined(OS_WIN) |
209 // This is only needed on Windows. | 209 // This is only needed on Windows. |
210 if (!show_mnemonics) | 210 if (!show_mnemonics) |
211 show_mnemonics = base::win::IsAltPressed(); | 211 show_mnemonics = base::win::IsAltPressed(); |
212 #endif | 212 #endif |
213 return show_mnemonics; | 213 return show_mnemonics; |
214 } | 214 } |
215 | 215 |
216 } // namespace internal | 216 } // namespace internal |
217 } // namespace views | 217 } // namespace views |
OLD | NEW |