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_COCOA_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_COCOA_H_ |
6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_COCOA_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_COCOA_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "ui/views/controls/menu/menu_runner_impl_interface.h" | 14 #include "ui/views/controls/menu/menu_runner_impl_interface.h" |
15 | 15 |
16 @class MenuController; | 16 @class MenuController; |
17 | 17 |
18 namespace views { | 18 namespace views { |
19 namespace internal { | 19 namespace internal { |
20 | 20 |
21 // A menu runner implementation that uses NSMenu to show a context menu. | 21 // A menu runner implementation that uses NSMenu to show a context menu. |
22 class VIEWS_EXPORT MenuRunnerImplCocoa : public MenuRunnerImplInterface { | 22 class VIEWS_EXPORT MenuRunnerImplCocoa : public MenuRunnerImplInterface { |
23 public: | 23 public: |
24 MenuRunnerImplCocoa(ui::MenuModel* menu, | 24 MenuRunnerImplCocoa(ui::MenuModel* menu, |
25 const base::Closure& on_menu_closed_callback); | 25 const base::Closure& on_menu_closed_callback); |
26 | 26 |
27 bool IsRunning() const override; | 27 bool IsRunning() const override; |
28 void Release() override; | 28 void Release() override; |
29 MenuRunner::RunResult RunMenuAt(Widget* parent, | 29 void RunMenuAt(Widget* parent, |
30 MenuButton* button, | 30 MenuButton* button, |
31 const gfx::Rect& bounds, | 31 const gfx::Rect& bounds, |
32 MenuAnchorPosition anchor, | 32 MenuAnchorPosition anchor, |
33 int32_t run_types) override; | 33 int32_t run_types) override; |
34 void Cancel() override; | 34 void Cancel() override; |
35 base::TimeTicks GetClosingEventTime() const override; | 35 base::TimeTicks GetClosingEventTime() const override; |
36 | 36 |
37 private: | 37 private: |
38 ~MenuRunnerImplCocoa() override; | 38 ~MenuRunnerImplCocoa() override; |
39 | 39 |
40 // The Cocoa menu controller that this instance is bridging. | 40 // The Cocoa menu controller that this instance is bridging. |
41 base::scoped_nsobject<MenuController> menu_controller_; | 41 base::scoped_nsobject<MenuController> menu_controller_; |
42 | 42 |
43 // Are we in run waiting for it to return? | 43 // Are we in run waiting for it to return? |
44 bool running_; | 44 bool running_; |
45 | 45 |
46 // Set if |running_| and Release() has been invoked. | 46 // Set if |running_| and Release() has been invoked. |
47 bool delete_after_run_; | 47 bool delete_after_run_; |
48 | 48 |
49 // The timestamp of the event which closed the menu - or 0. | 49 // The timestamp of the event which closed the menu - or 0. |
50 base::TimeTicks closing_event_time_; | 50 base::TimeTicks closing_event_time_; |
51 | 51 |
52 // Invoked before RunMenuAt() returns, except upon a Release(). | 52 // Invoked before RunMenuAt() returns, except upon a Release(). |
53 base::Closure on_menu_closed_callback_; | 53 base::Closure on_menu_closed_callback_; |
54 | 54 |
55 DISALLOW_COPY_AND_ASSIGN(MenuRunnerImplCocoa); | 55 DISALLOW_COPY_AND_ASSIGN(MenuRunnerImplCocoa); |
56 }; | 56 }; |
57 | 57 |
58 } // namespace internal | 58 } // namespace internal |
59 } // namespace views | 59 } // namespace views |
60 | 60 |
61 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_COCOA_H_ | 61 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_IMPL_COCOA_H_ |
OLD | NEW |