Chromium Code Reviews| 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 CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ | 
| 6 #define CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ | 6 #define CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ | 
| 7 | 7 | 
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" | 
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" | 
| 10 #include "base/time/time.h" | |
| 11 #include "base/timer/elapsed_timer.h" | |
| 10 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 
| 11 #include "content/public/browser/host_zoom_map.h" | 13 #include "content/public/browser/host_zoom_map.h" | 
| 12 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" | 
| 13 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" | 
| 14 #include "ui/base/accelerators/accelerator.h" | 16 #include "ui/base/accelerators/accelerator.h" | 
| 15 #include "ui/base/models/button_menu_item_model.h" | 17 #include "ui/base/models/button_menu_item_model.h" | 
| 16 #include "ui/base/models/simple_menu_model.h" | 18 #include "ui/base/models/simple_menu_model.h" | 
| 17 | 19 | 
| 18 class BookmarkSubMenuModel; | 20 class BookmarkSubMenuModel; | 
| 19 class Browser; | 21 class Browser; | 
| 20 class RecentTabsSubMenuModel; | 22 class RecentTabsSubMenuModel; | 
| 21 class TabStripModel; | 23 class TabStripModel; | 
| 22 | 24 | 
| 23 namespace { | 25 namespace { | 
| 24 class MockWrenchMenuModel; | 26 class MockWrenchMenuModel; | 
| 25 } // namespace | 27 } // namespace | 
| 26 | 28 | 
| 29 enum WrenchMenuAction { | |
| 30 MENU_ACTION_NEW_TAB = 0, | |
| 31 MENU_ACTION_NEW_WINDOW, | |
| 32 MENU_ACTION_NEW_INCOGNITO_WINDOW, | |
| 33 MENU_ACTION_SHOW_BOOKMARK_BAR, | |
| 34 MENU_ACTION_SHOW_BOOKMARK_MANAGER, | |
| 35 MENU_ACTION_IMPORT_SETTINGS, | |
| 36 MENU_ACTION_BOOKMARK_PAGE, | |
| 37 MENU_ACTION_BOOKMARK_ALL_TABS, | |
| 38 MENU_ACTION_PIN_TO_START_SCREEN, | |
| 39 MENU_ACTION_RESTORE_TAB, | |
| 40 MENU_ACTION_WIN_DESKTOP_RESTART, | |
| 41 MENU_ACTION_WIN8_METRO_RESTART, | |
| 42 MENU_ACTION_WIN_CHROMEOS_RESTART, | |
| 43 MENU_ACTION_DISTILL_PAGE, | |
| 44 MENU_ACTION_SAVE_PAGE, | |
| 45 MENU_ACTION_FIND, | |
| 46 MENU_ACTION_PRINT, | |
| 47 MENU_ACTION_CUT, | |
| 48 MENU_ACTION_COPY, | |
| 49 MENU_ACTION_PASTE, | |
| 50 MENU_ACTION_CREATE_HOSTED_APP, | |
| 51 MENU_ACTION_CREATE_SHORTCUTS, | |
| 52 MENU_ACTION_MANAGE_EXTENSIONS, | |
| 53 MENU_ACTION_TASK_MANAGER, | |
| 54 MENU_ACTION_CLEAR_BROWSING_DATA, | |
| 55 MENU_ACTION_VIEW_SOURCE, | |
| 56 MENU_ACTION_DEV_TOOLS, | |
| 57 MENU_ACTION_DEV_TOOLS_CONSOLE, | |
| 58 MENU_ACTION_DEV_TOOLS_DEVICES, | |
| 59 MENU_ACTION_PROFILING_ENABLED, | |
| 60 MENU_ACTION_ZOOM_MINUS, | |
| 61 MENU_ACTION_ZOOM_PLUS, | |
| 62 MENU_ACTION_FULLSCREEN, | |
| 63 MENU_ACTION_SHOW_HISTORY, | |
| 64 MENU_ACTION_SHOW_DOWNLOADS, | |
| 65 MENU_ACTION_SHOW_SYNC_SETUP, | |
| 66 MENU_ACTION_OPTIONS, | |
| 67 MENU_ACTION_ABOUT, | |
| 68 MENU_ACTION_HELP_PAGE_VIA_MENU, | |
| 69 MENU_ACTION_FEEDBACK, | |
| 70 MENU_ACTION_TOGGLE_REQUEST_TABLET_SITE, | |
| 71 MENU_ACTION_EXIT, | |
| 72 MENU_ACTION_RECENT_TAB, | |
| 73 MENU_ACTION_BOOKMARK_OPEN, | |
| 74 LIMIT_MENU_ACTION | |
| 75 }; | |
| 76 | |
| 27 // A menu model that builds the contents of an encoding menu. | 77 // A menu model that builds the contents of an encoding menu. | 
| 28 class EncodingMenuModel : public ui::SimpleMenuModel, | 78 class EncodingMenuModel : public ui::SimpleMenuModel, | 
| 29 public ui::SimpleMenuModel::Delegate { | 79 public ui::SimpleMenuModel::Delegate { | 
| 30 public: | 80 public: | 
| 31 explicit EncodingMenuModel(Browser* browser); | 81 explicit EncodingMenuModel(Browser* browser); | 
| 32 ~EncodingMenuModel() override; | 82 ~EncodingMenuModel() override; | 
| 33 | 83 | 
| 34 // Overridden from ui::SimpleMenuModel::Delegate: | 84 // Overridden from ui::SimpleMenuModel::Delegate: | 
| 35 bool IsCommandIdChecked(int command_id) const override; | 85 bool IsCommandIdChecked(int command_id) const override; | 
| 36 bool IsCommandIdEnabled(int command_id) const override; | 86 bool IsCommandIdEnabled(int command_id) const override; | 
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 void CreateExtensionToolbarOverflowMenu(); | 200 void CreateExtensionToolbarOverflowMenu(); | 
| 151 | 201 | 
| 152 // Appends everything needed for the zoom menu: a menu break, then the zoom | 202 // Appends everything needed for the zoom menu: a menu break, then the zoom | 
| 153 // menu content and then another menu break. | 203 // menu content and then another menu break. | 
| 154 void CreateZoomMenu(); | 204 void CreateZoomMenu(); | 
| 155 | 205 | 
| 156 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); | 206 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); | 
| 157 | 207 | 
| 158 bool ShouldShowNewIncognitoWindowMenuItem(); | 208 bool ShouldShowNewIncognitoWindowMenuItem(); | 
| 159 | 209 | 
| 210 // Log UMA metrics for each command clicked on. | |
| 
 
Peter Kasting
2014/11/14 19:48:59
Nit: Grammar (and specificity).  How about: "Calle
 
edwardjung
2014/11/17 15:58:23
Done.
 
 | |
| 211 void LogMenuMetrics(int command_id); | |
| 212 | |
| 213 // Time menu wasopened for. | |
| 
 
Peter Kasting
2014/11/14 19:48:59
Nit: was opened for before what?  Be much more spe
 
edwardjung
2014/11/17 15:58:24
Done.
 
 | |
| 214 base::ElapsedTimer timer_; | |
| 215 | |
| 216 // Whether a UMA menu action has been recorded. | |
| 
 
Peter Kasting
2014/11/14 19:48:59
Nit: Has been recorded since when?  Menu open?  Ev
 
edwardjung
2014/11/17 15:58:24
Done.
 
 | |
| 217 bool uma_action_recorded_; | |
| 218 | |
| 160 // Models for the special menu items with buttons. | 219 // Models for the special menu items with buttons. | 
| 161 scoped_ptr<ui::ButtonMenuItemModel> edit_menu_item_model_; | 220 scoped_ptr<ui::ButtonMenuItemModel> edit_menu_item_model_; | 
| 162 scoped_ptr<ui::ButtonMenuItemModel> zoom_menu_item_model_; | 221 scoped_ptr<ui::ButtonMenuItemModel> zoom_menu_item_model_; | 
| 163 | 222 | 
| 164 // Label of the zoom label in the zoom menu item. | 223 // Label of the zoom label in the zoom menu item. | 
| 165 base::string16 zoom_label_; | 224 base::string16 zoom_label_; | 
| 166 | 225 | 
| 167 #if defined(GOOGLE_CHROME_BUILD) | 226 #if defined(GOOGLE_CHROME_BUILD) | 
| 168 // Help menu. | 227 // Help menu. | 
| 169 scoped_ptr<HelpMenuModel> help_menu_model_; | 228 scoped_ptr<HelpMenuModel> help_menu_model_; | 
| (...skipping 14 matching lines...) Expand all Loading... | |
| 184 TabStripModel* tab_strip_model_; // weak | 243 TabStripModel* tab_strip_model_; // weak | 
| 185 | 244 | 
| 186 scoped_ptr<content::HostZoomMap::Subscription> content_zoom_subscription_; | 245 scoped_ptr<content::HostZoomMap::Subscription> content_zoom_subscription_; | 
| 187 scoped_ptr<content::HostZoomMap::Subscription> browser_zoom_subscription_; | 246 scoped_ptr<content::HostZoomMap::Subscription> browser_zoom_subscription_; | 
| 188 content::NotificationRegistrar registrar_; | 247 content::NotificationRegistrar registrar_; | 
| 189 | 248 | 
| 190 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel); | 249 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel); | 
| 191 }; | 250 }; | 
| 192 | 251 | 
| 193 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ | 252 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ | 
| OLD | NEW |