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 "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "ui/base/models/menu_model.h" | 10 #include "ui/base/models/menu_model.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 for_drop_ = (types & MenuRunner::FOR_DROP) != 0; | 179 for_drop_ = (types & MenuRunner::FOR_DROP) != 0; |
180 bool has_mnemonics = (types & MenuRunner::HAS_MNEMONICS) != 0 && !for_drop_; | 180 bool has_mnemonics = (types & MenuRunner::HAS_MNEMONICS) != 0 && !for_drop_; |
181 owns_controller_ = false; | 181 owns_controller_ = false; |
182 if (!controller) { | 182 if (!controller) { |
183 // No menus are showing, show one. | 183 // No menus are showing, show one. |
184 ui::NativeTheme* theme = parent ? parent->GetNativeTheme() : | 184 ui::NativeTheme* theme = parent ? parent->GetNativeTheme() : |
185 ui::NativeTheme::instance(); | 185 ui::NativeTheme::instance(); |
186 controller = new MenuController(theme, !for_drop_, this); | 186 controller = new MenuController(theme, !for_drop_, this); |
187 owns_controller_ = true; | 187 owns_controller_ = true; |
188 } | 188 } |
189 controller->set_accept_on_f4((types & MenuRunner::COMBOBOX) != 0); | 189 controller->set_is_combobox((types & MenuRunner::COMBOBOX) != 0); |
190 controller_ = controller; | 190 controller_ = controller; |
191 menu_->set_controller(controller_); | 191 menu_->set_controller(controller_); |
192 menu_->PrepareForRun(owns_controller_, | 192 menu_->PrepareForRun(owns_controller_, |
193 has_mnemonics, | 193 has_mnemonics, |
194 !for_drop_ && ShouldShowMnemonics(button)); | 194 !for_drop_ && ShouldShowMnemonics(button)); |
195 | 195 |
196 // Run the loop. | 196 // Run the loop. |
197 int mouse_event_flags = 0; | 197 int mouse_event_flags = 0; |
198 MenuItemView* result = controller->Run(parent, button, menu_, bounds, anchor, | 198 MenuItemView* result = controller->Run(parent, button, menu_, bounds, anchor, |
199 (types & MenuRunner::CONTEXT_MENU) != 0, | 199 (types & MenuRunner::CONTEXT_MENU) != 0, |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 base::TimeDelta MenuRunner::closing_event_time() const { | 356 base::TimeDelta MenuRunner::closing_event_time() const { |
357 return holder_->closing_event_time(); | 357 return holder_->closing_event_time(); |
358 } | 358 } |
359 | 359 |
360 void MenuRunner::SetRunnerHandler( | 360 void MenuRunner::SetRunnerHandler( |
361 scoped_ptr<MenuRunnerHandler> runner_handler) { | 361 scoped_ptr<MenuRunnerHandler> runner_handler) { |
362 runner_handler_ = runner_handler.Pass(); | 362 runner_handler_ = runner_handler.Pass(); |
363 } | 363 } |
364 | 364 |
365 } // namespace views | 365 } // namespace views |
OLD | NEW |