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 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_H_ |
6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
15 #include "base/time/time.h" | 15 #include "base/time/time.h" |
16 #include "ui/views/controls/menu/menu_controller_delegate.h" | 16 #include "ui/views/controls/menu/menu_controller_delegate.h" |
17 #include "ui/views/controls/menu/menu_runner_impl_interface.h" | 17 #include "ui/views/controls/menu/menu_runner_impl_interface.h" |
18 #include "ui/views/views_export.h" | 18 #include "ui/views/views_export.h" |
19 | 19 |
20 namespace views { | 20 namespace views { |
21 | 21 |
22 class MenuController; | 22 class MenuController; |
23 class MenuDelegate; | 23 class MenuDelegate; |
24 class MenuItemView; | 24 class MenuItemView; |
25 | 25 |
| 26 namespace test { |
| 27 |
| 28 class MenuRunnerDestructionTest; |
| 29 |
| 30 } // namespace test |
| 31 |
26 namespace internal { | 32 namespace internal { |
27 | 33 |
28 // A menu runner implementation that uses views::MenuItemView to show a menu. | 34 // A menu runner implementation that uses views::MenuItemView to show a menu. |
29 class VIEWS_EXPORT MenuRunnerImpl | 35 class VIEWS_EXPORT MenuRunnerImpl |
30 : NON_EXPORTED_BASE(public MenuRunnerImplInterface), | 36 : NON_EXPORTED_BASE(public MenuRunnerImplInterface), |
31 NON_EXPORTED_BASE(public MenuControllerDelegate) { | 37 NON_EXPORTED_BASE(public MenuControllerDelegate) { |
32 public: | 38 public: |
33 explicit MenuRunnerImpl(MenuItemView* menu); | 39 explicit MenuRunnerImpl(MenuItemView* menu); |
34 | 40 |
35 bool IsRunning() const override; | 41 bool IsRunning() const override; |
36 void Release() override; | 42 void Release() override; |
37 MenuRunner::RunResult RunMenuAt(Widget* parent, | 43 MenuRunner::RunResult RunMenuAt(Widget* parent, |
38 MenuButton* button, | 44 MenuButton* button, |
39 const gfx::Rect& bounds, | 45 const gfx::Rect& bounds, |
40 MenuAnchorPosition anchor, | 46 MenuAnchorPosition anchor, |
41 int32_t run_types) override; | 47 int32_t run_types) override; |
42 void Cancel() override; | 48 void Cancel() override; |
43 base::TimeTicks GetClosingEventTime() const override; | 49 base::TimeTicks GetClosingEventTime() const override; |
44 | 50 |
45 // MenuControllerDelegate: | 51 // MenuControllerDelegate: |
46 void OnMenuClosed(NotifyType type, | 52 void OnMenuClosed(NotifyType type, |
47 MenuItemView* menu, | 53 MenuItemView* menu, |
48 int mouse_event_flags) override; | 54 int mouse_event_flags) override; |
49 void SiblingMenuCreated(MenuItemView* menu) override; | 55 void SiblingMenuCreated(MenuItemView* menu) override; |
50 | 56 |
51 private: | 57 private: |
| 58 friend class ::views::test::MenuRunnerDestructionTest; |
| 59 |
52 ~MenuRunnerImpl() override; | 60 ~MenuRunnerImpl() override; |
53 | 61 |
54 // Cleans up after the menu is no longer showing. |result| is the menu that | 62 // Cleans up after the menu is no longer showing. |result| is the menu that |
55 // the user selected, or NULL if nothing was selected. | 63 // the user selected, or NULL if nothing was selected. |
56 MenuRunner::RunResult MenuDone(NotifyType type, | 64 MenuRunner::RunResult MenuDone(NotifyType type, |
57 MenuItemView* result, | 65 MenuItemView* result, |
58 int mouse_event_flags); | 66 int mouse_event_flags); |
59 | 67 |
60 // Returns true if mnemonics should be shown in the menu. | 68 // Returns true if mnemonics should be shown in the menu. |
61 bool ShouldShowMnemonics(MenuButton* button); | 69 bool ShouldShowMnemonics(MenuButton* button); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Used to detect deletion of |this| when notifying delegate of success. | 105 // Used to detect deletion of |this| when notifying delegate of success. |
98 base::WeakPtrFactory<MenuRunnerImpl> weak_factory_; | 106 base::WeakPtrFactory<MenuRunnerImpl> weak_factory_; |
99 | 107 |
100 DISALLOW_COPY_AND_ASSIGN(MenuRunnerImpl); | 108 DISALLOW_COPY_AND_ASSIGN(MenuRunnerImpl); |
101 }; | 109 }; |
102 | 110 |
103 } // namespace internal | 111 } // namespace internal |
104 } // namespace views | 112 } // namespace views |
105 | 113 |
106 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_H_ | 114 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_H_ |
OLD | NEW |