OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
| 9 #include <memory> |
9 #include <utility> | 10 #include <utility> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "base/timer/elapsed_timer.h" | 15 #include "base/timer/elapsed_timer.h" |
16 #include "components/bookmarks/browser/base_bookmark_model_observer.h" | 16 #include "components/bookmarks/browser/base_bookmark_model_observer.h" |
17 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
19 #include "ui/base/models/menu_model.h" | 19 #include "ui/base/models/menu_model.h" |
20 #include "ui/views/controls/menu/menu_delegate.h" | 20 #include "ui/views/controls/menu/menu_delegate.h" |
21 | 21 |
22 class AppMenuObserver; | 22 class AppMenuObserver; |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 // the bookmark model isn't loaded. | 150 // the bookmark model isn't loaded. |
151 void CreateBookmarkMenu(); | 151 void CreateBookmarkMenu(); |
152 | 152 |
153 // Returns the index of the MenuModel/index pair representing the |command_id| | 153 // Returns the index of the MenuModel/index pair representing the |command_id| |
154 // in |command_id_to_entry_|. | 154 // in |command_id_to_entry_|. |
155 int ModelIndexFromCommandId(int command_id) const; | 155 int ModelIndexFromCommandId(int command_id) const; |
156 | 156 |
157 // The views menu. Owned by |menu_runner_|. | 157 // The views menu. Owned by |menu_runner_|. |
158 views::MenuItemView* root_; | 158 views::MenuItemView* root_; |
159 | 159 |
160 scoped_ptr<views::MenuRunner> menu_runner_; | 160 std::unique_ptr<views::MenuRunner> menu_runner_; |
161 | 161 |
162 // Maps from the command ID in model to the model/index pair the item came | 162 // Maps from the command ID in model to the model/index pair the item came |
163 // from. | 163 // from. |
164 CommandIDToEntry command_id_to_entry_; | 164 CommandIDToEntry command_id_to_entry_; |
165 | 165 |
166 // Browser the menu is being shown for. | 166 // Browser the menu is being shown for. |
167 Browser* browser_; | 167 Browser* browser_; |
168 | 168 |
169 // |CancelAndEvaluate| sets |selected_menu_model_| and |selected_index_|. | 169 // |CancelAndEvaluate| sets |selected_menu_model_| and |selected_index_|. |
170 // If |selected_menu_model_| is non-null after the menu completes | 170 // If |selected_menu_model_| is non-null after the menu completes |
171 // ActivatedAt is invoked. This is done so that ActivatedAt isn't invoked | 171 // ActivatedAt is invoked. This is done so that ActivatedAt isn't invoked |
172 // while the message loop is nested. | 172 // while the message loop is nested. |
173 ui::ButtonMenuItemModel* selected_menu_model_; | 173 ui::ButtonMenuItemModel* selected_menu_model_; |
174 int selected_index_; | 174 int selected_index_; |
175 | 175 |
176 // Used for managing the bookmark menu items. | 176 // Used for managing the bookmark menu items. |
177 scoped_ptr<BookmarkMenuDelegate> bookmark_menu_delegate_; | 177 std::unique_ptr<BookmarkMenuDelegate> bookmark_menu_delegate_; |
178 | 178 |
179 // Menu corresponding to IDC_BOOKMARKS_MENU. | 179 // Menu corresponding to IDC_BOOKMARKS_MENU. |
180 views::MenuItemView* bookmark_menu_; | 180 views::MenuItemView* bookmark_menu_; |
181 | 181 |
182 // Menu corresponding to IDC_FEEDBACK. | 182 // Menu corresponding to IDC_FEEDBACK. |
183 views::MenuItemView* feedback_menu_item_; | 183 views::MenuItemView* feedback_menu_item_; |
184 | 184 |
185 // Menu corresponding to IDC_TAKE_SCREENSHOT. | 185 // Menu corresponding to IDC_TAKE_SCREENSHOT. |
186 views::MenuItemView* screenshot_menu_item_; | 186 views::MenuItemView* screenshot_menu_item_; |
187 | 187 |
188 // The view within the IDC_EXTENSIONS_OVERFLOW_MENU item (only present with | 188 // The view within the IDC_EXTENSIONS_OVERFLOW_MENU item (only present with |
189 // the toolbar action redesign enabled). | 189 // the toolbar action redesign enabled). |
190 ExtensionToolbarMenuView* extension_toolbar_; | 190 ExtensionToolbarMenuView* extension_toolbar_; |
191 | 191 |
192 // Used for managing "Recent tabs" menu items. | 192 // Used for managing "Recent tabs" menu items. |
193 scoped_ptr<RecentTabsMenuModelDelegate> recent_tabs_menu_model_delegate_; | 193 std::unique_ptr<RecentTabsMenuModelDelegate> recent_tabs_menu_model_delegate_; |
194 | 194 |
195 content::NotificationRegistrar registrar_; | 195 content::NotificationRegistrar registrar_; |
196 | 196 |
197 // The bit mask of RunFlags. | 197 // The bit mask of RunFlags. |
198 const int run_flags_; | 198 const int run_flags_; |
199 | 199 |
200 base::ObserverList<AppMenuObserver> observer_list_; | 200 base::ObserverList<AppMenuObserver> observer_list_; |
201 | 201 |
202 // Records the time from when menu opens to when the user selects a menu item. | 202 // Records the time from when menu opens to when the user selects a menu item. |
203 base::ElapsedTimer menu_opened_timer_; | 203 base::ElapsedTimer menu_opened_timer_; |
204 | 204 |
205 DISALLOW_COPY_AND_ASSIGN(AppMenu); | 205 DISALLOW_COPY_AND_ASSIGN(AppMenu); |
206 }; | 206 }; |
207 | 207 |
208 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_H_ | 208 #endif // CHROME_BROWSER_UI_VIEWS_TOOLBAR_APP_MENU_H_ |
OLD | NEW |