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 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/wrench_menu_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
232 | 232 |
233 void ToolsMenuModel::Build(Browser* browser) { | 233 void ToolsMenuModel::Build(Browser* browser) { |
234 bool show_create_shortcuts = true; | 234 bool show_create_shortcuts = true; |
235 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) | 235 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) |
236 show_create_shortcuts = false; | 236 show_create_shortcuts = false; |
237 #elif defined(USE_ASH) | 237 #elif defined(USE_ASH) |
238 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | 238 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) |
239 show_create_shortcuts = false; | 239 show_create_shortcuts = false; |
240 #endif | 240 #endif |
241 | 241 |
242 AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA); | |
243 AddItemWithStringId(IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS); | |
244 | |
245 if (chrome::CanOpenTaskManager()) | |
246 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); | |
247 | |
242 if (extensions::util::IsNewBookmarkAppsEnabled()) { | 248 if (extensions::util::IsNewBookmarkAppsEnabled()) { |
243 #if defined(OS_MACOSX) | 249 #if defined(OS_MACOSX) |
244 int string_id = IDS_ADD_TO_APPLICATIONS; | 250 int string_id = IDS_ADD_TO_APPLICATIONS; |
245 #elif defined(OS_WIN) | 251 #elif defined(OS_WIN) |
246 int string_id = IDS_ADD_TO_TASKBAR; | 252 int string_id = IDS_ADD_TO_TASKBAR; |
247 #else | 253 #else |
248 int string_id = IDS_ADD_TO_DESKTOP; | 254 int string_id = IDS_ADD_TO_DESKTOP; |
249 #endif | 255 #endif |
250 #if defined(USE_ASH) | 256 #if defined(USE_ASH) |
251 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | 257 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) |
252 string_id = IDS_ADD_TO_SHELF; | 258 string_id = IDS_ADD_TO_SHELF; |
253 #endif | 259 #endif |
254 AddItemWithStringId(IDC_CREATE_HOSTED_APP, string_id); | 260 AddItemWithStringId(IDC_CREATE_HOSTED_APP, string_id); |
255 AddSeparator(ui::NORMAL_SEPARATOR); | |
256 } else if (show_create_shortcuts) { | 261 } else if (show_create_shortcuts) { |
257 AddItemWithStringId(IDC_CREATE_SHORTCUTS, IDS_CREATE_SHORTCUTS); | 262 AddItemWithStringId(IDC_CREATE_SHORTCUTS, IDS_CREATE_SHORTCUTS); |
258 AddSeparator(ui::NORMAL_SEPARATOR); | |
259 } | 263 } |
260 | 264 |
261 AddItemWithStringId(IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS); | |
262 | |
263 if (chrome::CanOpenTaskManager()) | |
264 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); | |
265 | |
266 AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA); | |
267 | |
268 #if defined(OS_CHROMEOS) | 265 #if defined(OS_CHROMEOS) |
269 AddItemWithStringId(IDC_TAKE_SCREENSHOT, IDS_TAKE_SCREENSHOT); | 266 AddItemWithStringId(IDC_TAKE_SCREENSHOT, IDS_TAKE_SCREENSHOT); |
270 #endif | 267 #endif |
271 | 268 |
272 AddSeparator(ui::NORMAL_SEPARATOR); | |
273 | |
274 encoding_menu_model_.reset(new EncodingMenuModel(browser)); | 269 encoding_menu_model_.reset(new EncodingMenuModel(browser)); |
275 AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU, | 270 AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU, |
276 encoding_menu_model_.get()); | 271 encoding_menu_model_.get()); |
272 AddSeparator(ui::NORMAL_SEPARATOR); | |
273 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS); | |
277 AddItemWithStringId(IDC_VIEW_SOURCE, IDS_VIEW_SOURCE); | 274 AddItemWithStringId(IDC_VIEW_SOURCE, IDS_VIEW_SOURCE); |
278 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS); | |
279 AddItemWithStringId(IDC_DEV_TOOLS_CONSOLE, IDS_DEV_TOOLS_CONSOLE); | 275 AddItemWithStringId(IDC_DEV_TOOLS_CONSOLE, IDS_DEV_TOOLS_CONSOLE); |
280 AddItemWithStringId(IDC_DEV_TOOLS_DEVICES, IDS_DEV_TOOLS_DEVICES); | 276 AddItemWithStringId(IDC_DEV_TOOLS_DEVICES, IDS_DEV_TOOLS_DEVICES); |
281 | 277 |
282 #if defined(ENABLE_PROFILING) && !defined(NO_TCMALLOC) | 278 #if defined(ENABLE_PROFILING) && !defined(NO_TCMALLOC) |
283 AddSeparator(ui::NORMAL_SEPARATOR); | 279 AddSeparator(ui::NORMAL_SEPARATOR); |
284 AddCheckItemWithStringId(IDC_PROFILING_ENABLED, IDS_PROFILING_ENABLED); | 280 AddCheckItemWithStringId(IDC_PROFILING_ENABLED, IDS_PROFILING_ENABLED); |
285 #endif | 281 #endif |
286 } | 282 } |
287 | 283 |
288 //////////////////////////////////////////////////////////////////////////////// | 284 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
818 } | 814 } |
819 | 815 |
820 bool WrenchMenuModel::ShouldShowNewIncognitoWindowMenuItem() { | 816 bool WrenchMenuModel::ShouldShowNewIncognitoWindowMenuItem() { |
821 if (browser_->profile()->IsGuestSession()) | 817 if (browser_->profile()->IsGuestSession()) |
822 return false; | 818 return false; |
823 | 819 |
824 return IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 820 return IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
825 IncognitoModePrefs::DISABLED; | 821 IncognitoModePrefs::DISABLED; |
826 } | 822 } |
827 | 823 |
824 // Note: When adding new menu items please place under an appropriate section. | |
825 // Menu is organised as follows: | |
826 // - Global browser errors and warnings. | |
Peter Kasting
2015/04/01 21:06:28
Nit: Should probably add "- Extension toolbar over
| |
827 // - Tabs and windows. | |
828 // - Places previously been e.g. History, bookmarks, recent tabs. | |
829 // - Page actions e.g. zoom, edit, find, print. | |
830 // - Learn about the browser and global customisation e.g. settings, help. | |
831 // - Browser relaunch, quit. | |
828 void WrenchMenuModel::Build() { | 832 void WrenchMenuModel::Build() { |
833 bool add_separator = false; | |
Peter Kasting
2015/04/01 21:06:29
Nit: This can be eliminated; see further notes bel
| |
834 | |
835 if (extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) | |
836 CreateExtensionToolbarOverflowMenu(); | |
837 | |
829 #if defined(OS_WIN) | 838 #if defined(OS_WIN) |
830 AddItem(IDC_VIEW_INCOMPATIBILITIES, | 839 AddItem(IDC_VIEW_INCOMPATIBILITIES, |
831 l10n_util::GetStringUTF16(IDS_VIEW_INCOMPATIBILITIES)); | 840 l10n_util::GetStringUTF16(IDS_VIEW_INCOMPATIBILITIES)); |
841 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES), | |
842 ui::ResourceBundle::GetSharedInstance(). | |
843 GetNativeImageNamed(IDR_INPUT_ALERT_MENU)); | |
844 | |
832 EnumerateModulesModel* model = | 845 EnumerateModulesModel* model = |
833 EnumerateModulesModel::GetInstance(); | 846 EnumerateModulesModel::GetInstance(); |
834 if (model->modules_to_notify_about() > 0 || | 847 if (model->modules_to_notify_about() > 0 || |
835 model->confirmed_bad_modules_detected() > 0) | 848 model->confirmed_bad_modules_detected() > 0) |
836 AddSeparator(ui::NORMAL_SEPARATOR); | 849 add_separator = true; |
Peter Kasting
2015/04/01 21:06:28
Instead of checking the EnumerateModulesModel dire
edwardjung
2015/04/02 13:13:28
Nice, I like simplicity. Done.
As IDS_VIEW_INCOMP
| |
837 #endif | 850 #endif |
838 | 851 |
839 if (extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) | 852 if (browser_defaults::kShowUpgradeMenuItem) { |
Peter Kasting
2015/04/01 21:06:28
Nit: Move the check of this variable into IsComman
edwardjung
2015/04/02 13:13:28
Done.
| |
840 CreateExtensionToolbarOverflowMenu(); | 853 AddItem(IDC_UPGRADE_DIALOG, GetUpgradeDialogMenuItemName()); |
854 if (UpgradeDetector::GetInstance()->notify_upgrade()) | |
Peter Kasting
2015/04/01 21:06:28
Similarly to above, this should call IsCommandIdVi
edwardjung
2015/04/02 13:13:28
Done.
| |
855 add_separator = true; | |
856 } | |
857 | |
858 if (AddGlobalErrorMenuItems()) | |
Peter Kasting
2015/04/01 21:06:28
You can eliminate |add_separator| entirely and sho
edwardjung
2015/04/02 13:13:28
Done.
| |
859 add_separator = true; | |
860 | |
861 if (add_separator) | |
862 AddSeparator(ui::NORMAL_SEPARATOR); | |
841 | 863 |
842 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); | 864 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); |
843 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); | 865 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); |
844 | 866 |
845 if (ShouldShowNewIncognitoWindowMenuItem()) | 867 if (ShouldShowNewIncognitoWindowMenuItem()) |
846 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); | 868 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); |
Peter Kasting
2015/04/01 21:06:28
Nit: I'd probably remove the blank line above this
edwardjung
2015/04/02 13:13:28
Done.
| |
869 AddSeparator(ui::NORMAL_SEPARATOR); | |
847 | 870 |
848 if (!browser_->profile()->IsGuestSession()) { | 871 AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); |
849 bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_)); | 872 AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS); |
850 AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU, | |
851 bookmark_sub_menu_model_.get()); | |
852 } | |
853 | 873 |
854 if (!browser_->profile()->IsOffTheRecord()) { | 874 if (!browser_->profile()->IsOffTheRecord()) { |
855 recent_tabs_sub_menu_model_.reset(new RecentTabsSubMenuModel(provider_, | 875 recent_tabs_sub_menu_model_.reset(new RecentTabsSubMenuModel(provider_, |
856 browser_, | 876 browser_, |
857 NULL)); | 877 NULL)); |
858 AddSubMenuWithStringId(IDC_RECENT_TABS_MENU, IDS_RECENT_TABS_MENU, | 878 AddSubMenuWithStringId(IDC_RECENT_TABS_MENU, IDS_RECENT_TABS_MENU, |
859 recent_tabs_sub_menu_model_.get()); | 879 recent_tabs_sub_menu_model_.get()); |
860 } | 880 } |
861 | 881 |
862 #if defined(OS_WIN) | 882 if (!browser_->profile()->IsGuestSession()) { |
863 base::win::Version min_version_for_ash_mode = base::win::VERSION_WIN8; | 883 bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_)); |
864 // Windows 7 ASH mode is only supported in DEBUG for now. | 884 AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU, |
865 #if !defined(NDEBUG) | 885 bookmark_sub_menu_model_.get()); |
866 min_version_for_ash_mode = base::win::VERSION_WIN7; | |
867 #endif | |
868 // Windows 8 can support ASH mode using WARP, but Windows 7 requires a working | |
869 // GPU compositor. | |
870 if ((base::win::GetVersion() >= min_version_for_ash_mode && | |
871 content::GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor()) || | |
872 (base::win::GetVersion() >= base::win::VERSION_WIN8)) { | |
873 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) { | |
874 // ASH/Metro mode, add the 'Relaunch Chrome in desktop mode'. | |
875 AddSeparator(ui::NORMAL_SEPARATOR); | |
876 AddItemWithStringId(IDC_WIN_DESKTOP_RESTART, IDS_WIN_DESKTOP_RESTART); | |
877 } else { | |
878 // In Windows 8 desktop, add the 'Relaunch Chrome in Windows 8 mode'. | |
879 // In Windows 7 desktop, add the 'Relaunch Chrome in Windows ASH mode' | |
880 AddSeparator(ui::NORMAL_SEPARATOR); | |
881 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | |
882 AddItemWithStringId(IDC_WIN8_METRO_RESTART, IDS_WIN8_METRO_RESTART); | |
883 } else { | |
884 AddItemWithStringId(IDC_WIN_CHROMEOS_RESTART, IDS_WIN_CHROMEOS_RESTART); | |
885 } | |
886 } | |
887 } | 886 } |
888 #endif | 887 |
888 CreateZoomMenu(); | |
889 | |
890 AddItemWithStringId(IDC_PRINT, IDS_PRINT); | |
891 AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE); | |
892 AddItemWithStringId(IDC_FIND, IDS_FIND); | |
893 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
894 switches::kEnableDomDistiller)) | |
895 AddItemWithStringId(IDC_DISTILL_PAGE, IDS_DISTILL_PAGE); | |
896 tools_menu_model_.reset(new ToolsMenuModel(this, browser_)); | |
897 AddSubMenuWithStringId( | |
898 IDC_MORE_TOOLS_MENU, IDS_MORE_TOOLS_MENU, tools_menu_model_.get()); | |
889 | 899 |
890 // Append the full menu including separators. The final separator only gets | 900 // Append the full menu including separators. The final separator only gets |
891 // appended when this is a touch menu - otherwise it would get added twice. | 901 // appended when this is a touch menu - otherwise it would get added twice. |
892 CreateCutCopyPasteMenu(); | 902 CreateCutCopyPasteMenu(); |
893 | 903 |
894 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 904 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); |
895 switches::kEnableDomDistiller)) { | |
896 AddItemWithStringId(IDC_DISTILL_PAGE, IDS_DISTILL_PAGE); | |
897 } | |
898 | |
899 AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE); | |
900 AddItemWithStringId(IDC_FIND, IDS_FIND); | |
901 AddItemWithStringId(IDC_PRINT, IDS_PRINT); | |
902 | |
903 tools_menu_model_.reset(new ToolsMenuModel(this, browser_)); | |
904 CreateZoomMenu(); | |
905 | |
906 AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); | |
907 AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS); | |
908 AddSeparator(ui::NORMAL_SEPARATOR); | |
909 | 905 |
910 #if !defined(OS_CHROMEOS) | 906 #if !defined(OS_CHROMEOS) |
911 if (!switches::IsNewAvatarMenu()) { | 907 if (!switches::IsNewAvatarMenu()) { |
912 // No "Sign in to Chromium..." menu item on ChromeOS. | 908 // No "Sign in to Chromium..." menu item on ChromeOS. |
913 SigninManager* signin = SigninManagerFactory::GetForProfile( | 909 SigninManager* signin = SigninManagerFactory::GetForProfile( |
914 browser_->profile()->GetOriginalProfile()); | 910 browser_->profile()->GetOriginalProfile()); |
915 if (signin && signin->IsSigninAllowed()) { | 911 if (signin && signin->IsSigninAllowed()) { |
916 const base::string16 short_product_name = | 912 // Check for sign in errors. |
917 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | 913 std::vector<GlobalError*> signin_errors; |
Peter Kasting
2015/04/01 21:06:28
This temp is unused and can be removed.
edwardjung
2015/04/02 13:13:28
Done.
| |
918 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( | 914 |
919 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); | 915 if (signin_ui_util::GetSignedInServiceErrors( |
920 AddSeparator(ui::NORMAL_SEPARATOR); | 916 browser_->profile()->GetOriginalProfile()).empty()) { |
917 const base::string16 short_product_name = | |
Peter Kasting
2015/04/01 21:06:28
This temp is unused and can be removed.
edwardjung
2015/04/02 13:13:28
Done.
| |
918 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | |
919 AddItem(IDC_SHOW_SYNC_SETUP, | |
920 l10n_util::GetStringFUTF16( | |
921 IDS_SYNC_MENU_PRE_SYNCED_LABEL, | |
922 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | |
923 } | |
921 } | 924 } |
922 } | 925 } |
923 #endif | 926 #endif |
924 | 927 |
925 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); | |
926 | |
927 // On ChromeOS we don't want the about menu option. | 928 // On ChromeOS we don't want the about menu option. |
928 #if !defined(OS_CHROMEOS) | 929 #if !defined(OS_CHROMEOS) |
929 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); | 930 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); |
930 #endif | 931 #endif |
931 | 932 |
932 #if defined(GOOGLE_CHROME_BUILD) | 933 #if defined(GOOGLE_CHROME_BUILD) |
933 help_menu_model_.reset(new HelpMenuModel(this, browser_)); | 934 help_menu_model_.reset(new HelpMenuModel(this, browser_)); |
934 AddSubMenuWithStringId(IDC_HELP_MENU, IDS_HELP_MENU, | 935 AddSubMenuWithStringId(IDC_HELP_MENU, IDS_HELP_MENU, |
935 help_menu_model_.get()); | 936 help_menu_model_.get()); |
936 #endif | 937 #endif |
937 | 938 |
938 #if defined(OS_CHROMEOS) | 939 #if defined(OS_CHROMEOS) |
939 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 940 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
940 chromeos::switches::kEnableRequestTabletSite)) | 941 chromeos::switches::kEnableRequestTabletSite)) |
941 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, | 942 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, |
942 IDS_TOGGLE_REQUEST_TABLET_SITE); | 943 IDS_TOGGLE_REQUEST_TABLET_SITE); |
943 #endif | 944 #endif |
944 | 945 |
945 if (browser_defaults::kShowUpgradeMenuItem) | 946 AddSeparator(ui::NORMAL_SEPARATOR); |
Peter Kasting
2015/04/01 21:06:28
This line should be removed.
* If we try to add t
edwardjung
2015/04/02 13:13:28
Good point. Done.
| |
946 AddItem(IDC_UPGRADE_DIALOG, GetUpgradeDialogMenuItemName()); | |
947 | 947 |
948 #if defined(OS_WIN) | 948 #if defined(OS_WIN) |
949 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES), | 949 base::win::Version min_version_for_ash_mode = base::win::VERSION_WIN8; |
950 ui::ResourceBundle::GetSharedInstance(). | 950 // Windows 7 ASH mode is only supported in DEBUG for now. |
951 GetNativeImageNamed(IDR_INPUT_ALERT_MENU)); | 951 #if !defined(NDEBUG) |
952 min_version_for_ash_mode = base::win::VERSION_WIN7; | |
952 #endif | 953 #endif |
953 | 954 // Windows 8 can support ASH mode using WARP, but Windows 7 requires a working |
954 AddGlobalErrorMenuItems(); | 955 // GPU compositor. |
955 | 956 if ((base::win::GetVersion() >= min_version_for_ash_mode && |
956 AddSeparator(ui::NORMAL_SEPARATOR); | 957 content::GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor()) || |
957 AddSubMenuWithStringId( | 958 (base::win::GetVersion() >= base::win::VERSION_WIN8)) { |
958 IDC_MORE_TOOLS_MENU, IDS_MORE_TOOLS_MENU, tools_menu_model_.get()); | 959 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) { |
960 // ASH/Metro mode, add the 'Relaunch Chrome in desktop mode'. | |
961 AddSeparator(ui::NORMAL_SEPARATOR); | |
962 AddItemWithStringId(IDC_WIN_DESKTOP_RESTART, IDS_WIN_DESKTOP_RESTART); | |
963 } else { | |
964 // In Windows 8 desktop, add the 'Relaunch Chrome in Windows 8 mode'. | |
965 // In Windows 7 desktop, add the 'Relaunch Chrome in Windows ASH mode' | |
966 AddSeparator(ui::NORMAL_SEPARATOR); | |
967 if (base::win::GetVersion() >= base::win::VERSION_WIN8) | |
968 AddItemWithStringId(IDC_WIN8_METRO_RESTART, IDS_WIN8_METRO_RESTART); | |
969 else | |
970 AddItemWithStringId(IDC_WIN_CHROMEOS_RESTART, IDS_WIN_CHROMEOS_RESTART); | |
971 } | |
972 } | |
973 #endif | |
959 | 974 |
960 bool show_exit_menu = browser_defaults::kShowExitMenuItem; | 975 bool show_exit_menu = browser_defaults::kShowExitMenuItem; |
961 #if defined(OS_WIN) | 976 #if defined(OS_WIN) |
962 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | 977 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) |
963 show_exit_menu = false; | 978 show_exit_menu = false; |
964 #endif | 979 #endif |
965 | 980 |
966 if (show_exit_menu) { | 981 if (show_exit_menu) { |
967 AddSeparator(ui::NORMAL_SEPARATOR); | 982 AddSeparator(ui::NORMAL_SEPARATOR); |
968 AddItemWithStringId(IDC_EXIT, IDS_EXIT); | 983 AddItemWithStringId(IDC_EXIT, IDS_EXIT); |
969 } | 984 } |
970 | 985 |
971 RemoveTrailingSeparators(); | 986 RemoveTrailingSeparators(); |
Peter Kasting
2015/04/01 21:06:28
I think this call can be removed (and, since this
edwardjung
2015/04/02 13:13:28
Removed, but didn't remove the function, a search
Peter Kasting
2015/04/02 20:25:37
Can you remove that instance too so we can kill th
| |
972 uma_action_recorded_ = false; | 987 uma_action_recorded_ = false; |
973 } | 988 } |
974 | 989 |
975 void WrenchMenuModel::AddGlobalErrorMenuItems() { | 990 bool WrenchMenuModel::AddGlobalErrorMenuItems() { |
976 // TODO(sail): Currently we only build the wrench menu once per browser | 991 // TODO(sail): Currently we only build the wrench menu once per browser |
977 // window. This means that if a new error is added after the menu is built | 992 // window. This means that if a new error is added after the menu is built |
978 // it won't show in the existing wrench menu. To fix this we need to some | 993 // it won't show in the existing wrench menu. To fix this we need to some |
979 // how update the menu if new errors are added. | 994 // how update the menu if new errors are added. |
980 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 995 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
981 // GetSignedInServiceErrors() can modify the global error list, so call it | 996 // GetSignedInServiceErrors() can modify the global error list, so call it |
982 // before iterating through that list below. | 997 // before iterating through that list below. |
983 std::vector<GlobalError*> signin_errors; | 998 std::vector<GlobalError*> signin_errors; |
984 signin_errors = signin_ui_util::GetSignedInServiceErrors( | 999 signin_errors = signin_ui_util::GetSignedInServiceErrors( |
985 browser_->profile()->GetOriginalProfile()); | 1000 browser_->profile()->GetOriginalProfile()); |
986 const GlobalErrorService::GlobalErrorList& errors = | 1001 const GlobalErrorService::GlobalErrorList& errors = |
987 GlobalErrorServiceFactory::GetForProfile(browser_->profile())->errors(); | 1002 GlobalErrorServiceFactory::GetForProfile(browser_->profile())->errors(); |
1003 bool menu_items_added = false; | |
988 for (GlobalErrorService::GlobalErrorList::const_iterator | 1004 for (GlobalErrorService::GlobalErrorList::const_iterator |
989 it = errors.begin(); it != errors.end(); ++it) { | 1005 it = errors.begin(); it != errors.end(); ++it) { |
990 GlobalError* error = *it; | 1006 GlobalError* error = *it; |
991 DCHECK(error); | 1007 DCHECK(error); |
992 if (error->HasMenuItem()) { | 1008 if (error->HasMenuItem()) { |
993 #if !defined(OS_CHROMEOS) | 1009 #if !defined(OS_CHROMEOS) |
994 // Don't add a signin error if it's already being displayed elsewhere. | 1010 // Don't add a signin error if it's already being displayed elsewhere. |
995 if (std::find(signin_errors.begin(), signin_errors.end(), error) != | 1011 if (std::find(signin_errors.begin(), signin_errors.end(), error) != |
996 signin_errors.end()) { | 1012 signin_errors.end()) { |
997 MenuModel* model = this; | 1013 MenuModel* model = this; |
998 int index = 0; | 1014 int index = 0; |
999 if (MenuModel::GetModelAndIndexForCommandId( | 1015 if (MenuModel::GetModelAndIndexForCommandId( |
1000 IDC_SHOW_SIGNIN, &model, &index)) { | 1016 IDC_SHOW_SIGNIN, &model, &index)) { |
1001 continue; | 1017 continue; |
1002 } | 1018 } |
1003 } | 1019 } |
1004 #endif | 1020 #endif |
1005 | 1021 |
1006 AddItem(error->MenuItemCommandID(), error->MenuItemLabel()); | 1022 AddItem(error->MenuItemCommandID(), error->MenuItemLabel()); |
1007 int icon_id = error->MenuItemIconResourceID(); | 1023 int icon_id = error->MenuItemIconResourceID(); |
1008 if (icon_id) { | 1024 if (icon_id) { |
1009 const gfx::Image& image = rb.GetNativeImageNamed(icon_id); | 1025 const gfx::Image& image = rb.GetNativeImageNamed(icon_id); |
1010 SetIcon(GetIndexOfCommandId(error->MenuItemCommandID()), | 1026 SetIcon(GetIndexOfCommandId(error->MenuItemCommandID()), |
1011 image); | 1027 image); |
1012 } | 1028 } |
1029 menu_items_added = true; | |
1013 } | 1030 } |
1014 } | 1031 } |
1032 return menu_items_added; | |
1015 } | 1033 } |
1016 | 1034 |
1017 void WrenchMenuModel::CreateExtensionToolbarOverflowMenu() { | 1035 void WrenchMenuModel::CreateExtensionToolbarOverflowMenu() { |
1018 // We only add the extensions overflow container if there are any icons that | 1036 // We only add the extensions overflow container if there are any icons that |
1019 // aren't shown in the main container. | 1037 // aren't shown in the main container. |
1020 if (!extensions::ExtensionToolbarModel::Get(browser_->profile())-> | 1038 if (!extensions::ExtensionToolbarModel::Get(browser_->profile())-> |
1021 all_icons_visible()) { | 1039 all_icons_visible()) { |
1022 AddItem(IDC_EXTENSIONS_OVERFLOW_MENU, base::string16()); | 1040 AddItem(IDC_EXTENSIONS_OVERFLOW_MENU, base::string16()); |
1023 AddSeparator(ui::UPPER_SEPARATOR); | 1041 AddSeparator(ui::UPPER_SEPARATOR); |
1024 } | 1042 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1067 ->GetZoomPercent(); | 1085 ->GetZoomPercent(); |
1068 } | 1086 } |
1069 zoom_label_ = l10n_util::GetStringFUTF16( | 1087 zoom_label_ = l10n_util::GetStringFUTF16( |
1070 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 1088 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
1071 } | 1089 } |
1072 | 1090 |
1073 void WrenchMenuModel::OnZoomLevelChanged( | 1091 void WrenchMenuModel::OnZoomLevelChanged( |
1074 const content::HostZoomMap::ZoomLevelChange& change) { | 1092 const content::HostZoomMap::ZoomLevelChange& change) { |
1075 UpdateZoomControls(); | 1093 UpdateZoomControls(); |
1076 } | 1094 } |
OLD | NEW |