| 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 // Called when a command is selected. |
| 211 // Logs UMA metrics about which command was chosen and how long the user |
| 212 // took to select the command. |
| 213 void LogMenuMetrics(int command_id); |
| 214 |
| 215 // Helper function to record the menu action in a UMA histogram. |
| 216 void LogMenuAction(int action_id); |
| 217 |
| 218 // Time menu has been open. Used by LogMenuMetrics() to record the time |
| 219 // to action when the user selects a menu item. |
| 220 base::ElapsedTimer timer_; |
| 221 |
| 222 // Whether a UMA menu action has been recorded since the menu is open. |
| 223 // Only the first time to action is recorded since some commands |
| 224 // (zoom controls) don't dimiss the menu. |
| 225 bool uma_action_recorded_; |
| 226 |
| 160 // Models for the special menu items with buttons. | 227 // Models for the special menu items with buttons. |
| 161 scoped_ptr<ui::ButtonMenuItemModel> edit_menu_item_model_; | 228 scoped_ptr<ui::ButtonMenuItemModel> edit_menu_item_model_; |
| 162 scoped_ptr<ui::ButtonMenuItemModel> zoom_menu_item_model_; | 229 scoped_ptr<ui::ButtonMenuItemModel> zoom_menu_item_model_; |
| 163 | 230 |
| 164 // Label of the zoom label in the zoom menu item. | 231 // Label of the zoom label in the zoom menu item. |
| 165 base::string16 zoom_label_; | 232 base::string16 zoom_label_; |
| 166 | 233 |
| 167 #if defined(GOOGLE_CHROME_BUILD) | 234 #if defined(GOOGLE_CHROME_BUILD) |
| 168 // Help menu. | 235 // Help menu. |
| 169 scoped_ptr<HelpMenuModel> help_menu_model_; | 236 scoped_ptr<HelpMenuModel> help_menu_model_; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 184 TabStripModel* tab_strip_model_; // weak | 251 TabStripModel* tab_strip_model_; // weak |
| 185 | 252 |
| 186 scoped_ptr<content::HostZoomMap::Subscription> content_zoom_subscription_; | 253 scoped_ptr<content::HostZoomMap::Subscription> content_zoom_subscription_; |
| 187 scoped_ptr<content::HostZoomMap::Subscription> browser_zoom_subscription_; | 254 scoped_ptr<content::HostZoomMap::Subscription> browser_zoom_subscription_; |
| 188 content::NotificationRegistrar registrar_; | 255 content::NotificationRegistrar registrar_; |
| 189 | 256 |
| 190 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel); | 257 DISALLOW_COPY_AND_ASSIGN(WrenchMenuModel); |
| 191 }; | 258 }; |
| 192 | 259 |
| 193 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ | 260 #endif // CHROME_BROWSER_UI_TOOLBAR_WRENCH_MENU_MODEL_H_ |
| OLD | NEW |