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_INTERFACE_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_INTERFACE_H_ |
6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_INTERFACE_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_INTERFACE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/callback_forward.h" | 10 #include "base/callback_forward.h" |
11 #include "ui/views/controls/menu/menu_runner.h" | 11 #include "ui/views/controls/menu/menu_runner.h" |
12 | 12 |
13 namespace views { | 13 namespace views { |
14 | 14 |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 // An abstract interface for menu runner implementations. | 17 // An abstract interface for menu runner implementations. |
18 // Invoke Release() to destroy. Release() deletes immediately if the menu isn't | 18 // Invoke Release() to destroy. Release() deletes immediately if the menu isn't |
19 // showing. If the menu is showing Release() cancels the menu and when the | 19 // showing. If the menu is showing Release() cancels the menu and when the |
20 // nested RunMenuAt() call returns deletes itself and the menu. | 20 // nested RunMenuAt() call returns deletes itself and the menu. |
21 class MenuRunnerImplInterface { | 21 class MenuRunnerImplInterface { |
22 public: | 22 public: |
23 // Creates a concrete instance for running |menu_model|. | 23 // Creates a concrete instance for running |menu_model|. |
24 // |run_types| is a bitmask of MenuRunner::RunTypes. | 24 // |run_types| is a bitmask of MenuRunner::RunTypes. |
25 static MenuRunnerImplInterface* Create( | 25 static MenuRunnerImplInterface* Create( |
26 ui::MenuModel* menu_model, | 26 ui::MenuModel* menu_model, |
27 int32_t run_types, | 27 int32_t run_types, |
28 const base::Closure& on_menu_closed_callback); | 28 const base::Closure& on_menu_closed_callback); |
29 | 29 |
30 // Returns true if we're in a nested message loop running the menu. | 30 // Returns true if we're in a nested run loop running the menu. |
31 virtual bool IsRunning() const = 0; | 31 virtual bool IsRunning() const = 0; |
32 | 32 |
33 // See description above class for details. | 33 // See description above class for details. |
34 virtual void Release() = 0; | 34 virtual void Release() = 0; |
35 | 35 |
36 // Runs the menu. See MenuRunner::RunMenuAt for more details. | 36 // Runs the menu. See MenuRunner::RunMenuAt for more details. |
37 virtual void RunMenuAt(Widget* parent, | 37 virtual void RunMenuAt(Widget* parent, |
38 MenuButton* button, | 38 MenuButton* button, |
39 const gfx::Rect& bounds, | 39 const gfx::Rect& bounds, |
40 MenuAnchorPosition anchor, | 40 MenuAnchorPosition anchor, |
41 int32_t run_types) = 0; | 41 int32_t run_types) = 0; |
42 | 42 |
43 // Hides and cancels the menu. | 43 // Hides and cancels the menu. |
44 virtual void Cancel() = 0; | 44 virtual void Cancel() = 0; |
45 | 45 |
46 // Returns the time from the event which closed the menu - or 0. | 46 // Returns the time from the event which closed the menu - or 0. |
47 virtual base::TimeTicks GetClosingEventTime() const = 0; | 47 virtual base::TimeTicks GetClosingEventTime() const = 0; |
48 | 48 |
49 protected: | 49 protected: |
50 // Call Release() to delete. | 50 // Call Release() to delete. |
51 virtual ~MenuRunnerImplInterface() {} | 51 virtual ~MenuRunnerImplInterface() {} |
52 }; | 52 }; |
53 | 53 |
54 } // namespace internal | 54 } // namespace internal |
55 } // namespace views | 55 } // namespace views |
56 | 56 |
57 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_INTERFACE_H_ | 57 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_INTERFACE_H_ |
OLD | NEW |