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_runner.h" | 5 #include "ui/views/controls/menu/menu_runner.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "ui/views/controls/button/menu_button.h" | 9 #include "ui/views/controls/button/menu_button.h" |
10 #include "ui/views/controls/menu/menu_controller.h" | 10 #include "ui/views/controls/menu/menu_controller.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 // expected. | 152 // expected. |
153 return MenuRunner::NORMAL_EXIT; | 153 return MenuRunner::NORMAL_EXIT; |
154 } | 154 } |
155 // Drop menus don't block the message loop, so it's ok to create a new | 155 // Drop menus don't block the message loop, so it's ok to create a new |
156 // MenuController. | 156 // MenuController. |
157 controller = NULL; | 157 controller = NULL; |
158 } | 158 } |
159 } | 159 } |
160 running_ = true; | 160 running_ = true; |
161 for_drop_ = (types & MenuRunner::FOR_DROP) != 0; | 161 for_drop_ = (types & MenuRunner::FOR_DROP) != 0; |
162 bool root_context_menu = (MenuRunner::CONTEXT_MENU == | |
163 (types & (MenuRunner::IS_NESTED | MenuRunner::CONTEXT_MENU))); | |
162 bool has_mnemonics = (types & MenuRunner::HAS_MNEMONICS) != 0 && !for_drop_; | 164 bool has_mnemonics = (types & MenuRunner::HAS_MNEMONICS) != 0 && !for_drop_; |
163 menu_->PrepareForRun(has_mnemonics, | 165 menu_->PrepareForRun(has_mnemonics, |
164 !for_drop_ && ShouldShowMnemonics(button)); | 166 !for_drop_ && ShouldShowMnemonics(button), |
167 root_context_menu); | |
165 int mouse_event_flags = 0; | 168 int mouse_event_flags = 0; |
166 owns_controller_ = false; | 169 owns_controller_ = false; |
167 if (!controller) { | 170 if (!controller) { |
168 // No menus are showing, show one. | 171 // No menus are showing, show one. |
169 controller = new MenuController(!for_drop_, this); | 172 controller = new MenuController(!for_drop_, this); |
170 owns_controller_ = true; | 173 owns_controller_ = true; |
171 } | 174 } |
172 controller_ = controller; | 175 controller_ = controller; |
173 menu_->set_controller(controller_); | 176 menu_->set_controller(controller_); |
174 | 177 |
175 // Run the loop. | 178 // Run the loop. |
176 MenuItemView* result = controller->Run(parent, button, menu_, bounds, anchor, | 179 MenuItemView* result = controller->Run(parent, button, menu_, bounds, anchor, |
sky
2012/08/20 21:13:48
Can root_context_menu be passed to Run instead? Me
Harry McCleave
2012/08/21 01:30:18
Done.
| |
177 &mouse_event_flags); | 180 &mouse_event_flags); |
178 | 181 |
179 if (for_drop_) { | 182 if (for_drop_) { |
180 // Drop menus return immediately. We finish processing in DropMenuClosed. | 183 // Drop menus return immediately. We finish processing in DropMenuClosed. |
181 return MenuRunner::NORMAL_EXIT; | 184 return MenuRunner::NORMAL_EXIT; |
182 } | 185 } |
183 | 186 |
184 return MenuDone(result, mouse_event_flags); | 187 return MenuDone(result, mouse_event_flags); |
185 } | 188 } |
186 | 189 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
288 | 291 |
289 bool MenuRunner::IsRunning() const { | 292 bool MenuRunner::IsRunning() const { |
290 return holder_->running(); | 293 return holder_->running(); |
291 } | 294 } |
292 | 295 |
293 void MenuRunner::Cancel() { | 296 void MenuRunner::Cancel() { |
294 holder_->Cancel(); | 297 holder_->Cancel(); |
295 } | 298 } |
296 | 299 |
297 } // namespace views | 300 } // namespace views |
OLD | NEW |