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 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ | 5 #ifndef UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ |
6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ | 6 #define UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
| 10 #include <memory> |
| 11 |
10 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "ui/base/ui_base_types.h" | 14 #include "ui/base/ui_base_types.h" |
14 #include "ui/views/controls/menu/menu_types.h" | 15 #include "ui/views/controls/menu/menu_types.h" |
15 #include "ui/views/views_export.h" | 16 #include "ui/views/views_export.h" |
16 | 17 |
17 namespace base { | 18 namespace base { |
18 class TimeDelta; | 19 class TimeDelta; |
19 } | 20 } |
20 | 21 |
21 namespace gfx { | 22 namespace gfx { |
22 class Rect; | 23 class Rect; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Hides and cancels the menu. This does nothing if the menu is not open. | 129 // Hides and cancels the menu. This does nothing if the menu is not open. |
129 void Cancel(); | 130 void Cancel(); |
130 | 131 |
131 // Returns the time from the event which closed the menu - or 0. | 132 // Returns the time from the event which closed the menu - or 0. |
132 base::TimeDelta closing_event_time() const; | 133 base::TimeDelta closing_event_time() const; |
133 | 134 |
134 private: | 135 private: |
135 friend class test::MenuRunnerTestAPI; | 136 friend class test::MenuRunnerTestAPI; |
136 | 137 |
137 // Sets an implementation of RunMenuAt. This is intended to be used at test. | 138 // Sets an implementation of RunMenuAt. This is intended to be used at test. |
138 void SetRunnerHandler(scoped_ptr<MenuRunnerHandler> runner_handler); | 139 void SetRunnerHandler(std::unique_ptr<MenuRunnerHandler> runner_handler); |
139 | 140 |
140 const int32_t run_types_; | 141 const int32_t run_types_; |
141 | 142 |
142 // We own this. No scoped_ptr because it is destroyed by calling Release(). | 143 // We own this. No scoped_ptr because it is destroyed by calling Release(). |
143 internal::MenuRunnerImplInterface* impl_; | 144 internal::MenuRunnerImplInterface* impl_; |
144 | 145 |
145 // An implementation of RunMenuAt. This is usually NULL and ignored. If this | 146 // An implementation of RunMenuAt. This is usually NULL and ignored. If this |
146 // is not NULL, this implementation will be used. | 147 // is not NULL, this implementation will be used. |
147 scoped_ptr<MenuRunnerHandler> runner_handler_; | 148 std::unique_ptr<MenuRunnerHandler> runner_handler_; |
148 | 149 |
149 scoped_ptr<internal::DisplayChangeListener> display_change_listener_; | 150 std::unique_ptr<internal::DisplayChangeListener> display_change_listener_; |
150 | 151 |
151 DISALLOW_COPY_AND_ASSIGN(MenuRunner); | 152 DISALLOW_COPY_AND_ASSIGN(MenuRunner); |
152 }; | 153 }; |
153 | 154 |
154 namespace internal { | 155 namespace internal { |
155 | 156 |
156 // DisplayChangeListener is intended to listen for changes in the display size | 157 // DisplayChangeListener is intended to listen for changes in the display size |
157 // and cancel the menu. DisplayChangeListener is created when the menu is | 158 // and cancel the menu. DisplayChangeListener is created when the menu is |
158 // shown. | 159 // shown. |
159 class DisplayChangeListener { | 160 class DisplayChangeListener { |
160 public: | 161 public: |
161 virtual ~DisplayChangeListener() {} | 162 virtual ~DisplayChangeListener() {} |
162 | 163 |
163 // Creates the platform specified DisplayChangeListener, or NULL if there | 164 // Creates the platform specified DisplayChangeListener, or NULL if there |
164 // isn't one. Caller owns the returned value. | 165 // isn't one. Caller owns the returned value. |
165 static DisplayChangeListener* Create(Widget* parent, | 166 static DisplayChangeListener* Create(Widget* parent, |
166 MenuRunner* runner); | 167 MenuRunner* runner); |
167 | 168 |
168 protected: | 169 protected: |
169 DisplayChangeListener() {} | 170 DisplayChangeListener() {} |
170 }; | 171 }; |
171 | 172 |
172 } // namespace internal | 173 } // namespace internal |
173 | 174 |
174 } // namespace views | 175 } // namespace views |
175 | 176 |
176 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ | 177 #endif // UI_VIEWS_CONTROLS_MENU_MENU_RUNNER_H_ |
OLD | NEW |