| 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" |
| 11 #include "ui/views/controls/button/menu_button.h" | 11 #include "ui/views/controls/button/menu_button.h" |
| 12 #include "ui/views/controls/menu/menu_controller.h" | 12 #include "ui/views/controls/menu/menu_controller.h" |
| 13 #include "ui/views/controls/menu/menu_controller_delegate.h" | 13 #include "ui/views/controls/menu/menu_controller_delegate.h" |
| 14 #include "ui/views/controls/menu/menu_delegate.h" | 14 #include "ui/views/controls/menu/menu_delegate.h" |
| 15 #include "ui/views/controls/menu/menu_model_adapter.h" | 15 #include "ui/views/controls/menu/menu_model_adapter.h" |
| 16 #include "ui/views/controls/menu/menu_runner_handler.h" |
| 16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
| 17 | 18 |
| 18 #if defined(OS_WIN) | 19 #if defined(OS_WIN) |
| 19 #include "base/win/win_util.h" | 20 #include "base/win/win_util.h" |
| 20 #endif | 21 #endif |
| 21 | 22 |
| 22 namespace views { | 23 namespace views { |
| 23 | 24 |
| 24 namespace internal { | 25 namespace internal { |
| 25 | 26 |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 MenuItemView* MenuRunner::GetMenu() { | 306 MenuItemView* MenuRunner::GetMenu() { |
| 306 return holder_->menu(); | 307 return holder_->menu(); |
| 307 } | 308 } |
| 308 | 309 |
| 309 MenuRunner::RunResult MenuRunner::RunMenuAt(Widget* parent, | 310 MenuRunner::RunResult MenuRunner::RunMenuAt(Widget* parent, |
| 310 MenuButton* button, | 311 MenuButton* button, |
| 311 const gfx::Rect& bounds, | 312 const gfx::Rect& bounds, |
| 312 MenuItemView::AnchorPosition anchor, | 313 MenuItemView::AnchorPosition anchor, |
| 313 ui::MenuSourceType source_type, | 314 ui::MenuSourceType source_type, |
| 314 int32 types) { | 315 int32 types) { |
| 316 if (runner_handler_.get()) { |
| 317 return runner_handler_->RunMenuAt(parent, button, bounds, anchor, |
| 318 source_type, types); |
| 319 } |
| 320 |
| 315 // The parent of the nested menu will have created a DisplayChangeListener, so | 321 // The parent of the nested menu will have created a DisplayChangeListener, so |
| 316 // we avoid creating a DisplayChangeListener if nested. Drop menus are | 322 // we avoid creating a DisplayChangeListener if nested. Drop menus are |
| 317 // transient, so we don't cancel in that case. | 323 // transient, so we don't cancel in that case. |
| 318 if ((types & (IS_NESTED | FOR_DROP)) == 0 && parent) { | 324 if ((types & (IS_NESTED | FOR_DROP)) == 0 && parent) { |
| 319 display_change_listener_.reset( | 325 display_change_listener_.reset( |
| 320 internal::DisplayChangeListener::Create(parent, this)); | 326 internal::DisplayChangeListener::Create(parent, this)); |
| 321 } | 327 } |
| 322 | 328 |
| 323 if (types & CONTEXT_MENU) { | 329 if (types & CONTEXT_MENU) { |
| 324 switch (source_type) { | 330 switch (source_type) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 344 } | 350 } |
| 345 | 351 |
| 346 void MenuRunner::Cancel() { | 352 void MenuRunner::Cancel() { |
| 347 holder_->Cancel(); | 353 holder_->Cancel(); |
| 348 } | 354 } |
| 349 | 355 |
| 350 base::TimeDelta MenuRunner::closing_event_time() const { | 356 base::TimeDelta MenuRunner::closing_event_time() const { |
| 351 return holder_->closing_event_time(); | 357 return holder_->closing_event_time(); |
| 352 } | 358 } |
| 353 | 359 |
| 360 void MenuRunner::SetRunnerHandler( |
| 361 scoped_ptr<MenuRunnerHandler> runner_handler) { |
| 362 runner_handler_ = runner_handler.Pass(); |
| 363 } |
| 364 |
| 354 } // namespace views | 365 } // namespace views |
| OLD | NEW |