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 #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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 |
| 828 void WrenchMenuModel::Build() { | 824 void WrenchMenuModel::Build() { |
| 825 bool add_separator = false; | |
| 826 | |
| 827 if (extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) | |
| 828 CreateExtensionToolbarOverflowMenu(); | |
| 829 | |
| 830 // Errors and warnings. | |
| 829 #if defined(OS_WIN) | 831 #if defined(OS_WIN) |
| 830 AddItem(IDC_VIEW_INCOMPATIBILITIES, | 832 AddItem(IDC_VIEW_INCOMPATIBILITIES, |
| 831 l10n_util::GetStringUTF16(IDS_VIEW_INCOMPATIBILITIES)); | 833 l10n_util::GetStringUTF16(IDS_VIEW_INCOMPATIBILITIES)); |
| 832 EnumerateModulesModel* model = | 834 EnumerateModulesModel* model = |
| 833 EnumerateModulesModel::GetInstance(); | 835 EnumerateModulesModel::GetInstance(); |
| 834 if (model->modules_to_notify_about() > 0 || | 836 if (model->modules_to_notify_about() > 0 || |
| 835 model->confirmed_bad_modules_detected() > 0) | 837 model->confirmed_bad_modules_detected() > 0) |
| 836 AddSeparator(ui::NORMAL_SEPARATOR); | 838 add_separator = true; |
|
Peter Kasting
2015/03/30 19:37:02
This seems strange. Where is the UI for these enu
edwardjung
2015/03/31 11:44:04
I altered this from the previous code, which was u
| |
| 837 #endif | 839 #endif |
| 838 | 840 |
| 839 if (extensions::FeatureSwitch::extension_action_redesign()->IsEnabled()) | 841 if (browser_defaults::kShowUpgradeMenuItem) { |
|
Peter Kasting
2015/03/30 19:37:02
Nit: No {}
edwardjung
2015/03/31 11:44:05
Done.
| |
| 840 CreateExtensionToolbarOverflowMenu(); | 842 AddItem(IDC_UPGRADE_DIALOG, GetUpgradeDialogMenuItemName()); |
| 843 } | |
| 841 | 844 |
| 845 if (AddGlobalErrorMenuItems()) | |
| 846 add_separator = true; | |
| 847 | |
| 848 #if defined(OS_WIN) | |
| 849 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES), | |
|
Peter Kasting
2015/03/30 19:37:02
Why is this code here instead of being up with the
edwardjung
2015/03/31 11:44:05
Good point, didn't think since it was in a separat
| |
| 850 ui::ResourceBundle::GetSharedInstance(). | |
| 851 GetNativeImageNamed(IDR_INPUT_ALERT_MENU)); | |
| 852 #endif | |
| 853 | |
| 854 if (add_separator) | |
| 855 AddSeparator(ui::NORMAL_SEPARATOR); | |
| 856 | |
| 857 // Tabs and windows. | |
|
Peter Kasting
2015/03/30 19:37:02
If it really adds clarity to comment each section
edwardjung
2015/03/31 11:44:05
Point taken. I've added a comment at the top of th
| |
| 842 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); | 858 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); |
| 843 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); | 859 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); |
| 844 | 860 |
| 845 if (ShouldShowNewIncognitoWindowMenuItem()) | 861 if (ShouldShowNewIncognitoWindowMenuItem()) |
| 846 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); | 862 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); |
| 863 AddSeparator(ui::NORMAL_SEPARATOR); | |
| 847 | 864 |
| 848 if (!browser_->profile()->IsGuestSession()) { | 865 // Places previously been - History, bookmarks, recent tabs. |
|
Peter Kasting
2015/03/30 19:37:02
This description doesn't seem to apply to SHOW_DOW
edwardjung
2015/03/31 11:44:04
Removed.
| |
| 849 bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_)); | 866 AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); |
| 850 AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU, | 867 AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS); |
| 851 bookmark_sub_menu_model_.get()); | |
| 852 } | |
| 853 | 868 |
| 854 if (!browser_->profile()->IsOffTheRecord()) { | 869 if (!browser_->profile()->IsOffTheRecord()) { |
| 855 recent_tabs_sub_menu_model_.reset(new RecentTabsSubMenuModel(provider_, | 870 recent_tabs_sub_menu_model_.reset(new RecentTabsSubMenuModel(provider_, |
| 856 browser_, | 871 browser_, |
| 857 NULL)); | 872 NULL)); |
| 858 AddSubMenuWithStringId(IDC_RECENT_TABS_MENU, IDS_RECENT_TABS_MENU, | 873 AddSubMenuWithStringId(IDC_RECENT_TABS_MENU, IDS_RECENT_TABS_MENU, |
| 859 recent_tabs_sub_menu_model_.get()); | 874 recent_tabs_sub_menu_model_.get()); |
| 860 } | 875 } |
| 861 | 876 |
| 862 #if defined(OS_WIN) | 877 if (!browser_->profile()->IsGuestSession()) { |
| 863 base::win::Version min_version_for_ash_mode = base::win::VERSION_WIN8; | 878 bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_)); |
| 864 // Windows 7 ASH mode is only supported in DEBUG for now. | 879 AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU, |
| 865 #if !defined(NDEBUG) | 880 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 } | 881 } |
| 888 #endif | 882 |
| 883 // Page actions. | |
| 884 CreateZoomMenu(); | |
| 885 | |
| 886 AddItemWithStringId(IDC_PRINT, IDS_PRINT); | |
| 887 AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE); | |
| 888 AddItemWithStringId(IDC_FIND, IDS_FIND); | |
| 889 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 890 switches::kEnableDomDistiller)) { | |
|
Peter Kasting
2015/03/30 19:37:02
Nit: No {}
edwardjung
2015/03/31 11:44:05
Done.
| |
| 891 AddItemWithStringId(IDC_DISTILL_PAGE, IDS_DISTILL_PAGE); | |
| 892 } | |
| 893 tools_menu_model_.reset(new ToolsMenuModel(this, browser_)); | |
| 894 AddSubMenuWithStringId( | |
| 895 IDC_MORE_TOOLS_MENU, IDS_MORE_TOOLS_MENU, tools_menu_model_.get()); | |
| 889 | 896 |
| 890 // Append the full menu including separators. The final separator only gets | 897 // 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. | 898 // appended when this is a touch menu - otherwise it would get added twice. |
| 892 CreateCutCopyPasteMenu(); | 899 CreateCutCopyPasteMenu(); |
| 893 | 900 |
| 894 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 901 // Customisation and learn. |
|
Peter Kasting
2015/03/30 19:37:02
"Customization and learning"? Though I don't know
edwardjung
2015/03/31 11:44:05
Removed.
| |
| 895 switches::kEnableDomDistiller)) { | 902 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); |
| 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 | 903 |
| 910 #if !defined(OS_CHROMEOS) | 904 #if !defined(OS_CHROMEOS) |
| 911 if (!switches::IsNewAvatarMenu()) { | 905 if (!switches::IsNewAvatarMenu()) { |
| 912 // No "Sign in to Chromium..." menu item on ChromeOS. | 906 // No "Sign in to Chromium..." menu item on ChromeOS. |
| 913 SigninManager* signin = SigninManagerFactory::GetForProfile( | 907 SigninManager* signin = SigninManagerFactory::GetForProfile( |
| 914 browser_->profile()->GetOriginalProfile()); | 908 browser_->profile()->GetOriginalProfile()); |
| 915 if (signin && signin->IsSigninAllowed()) { | 909 if (signin && signin->IsSigninAllowed()) { |
| 916 const base::string16 short_product_name = | 910 // Check for sign in errors. |
| 917 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | 911 std::vector<GlobalError*> signin_errors; |
| 918 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( | 912 signin_errors = signin_ui_util::GetSignedInServiceErrors( |
| 919 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); | 913 browser_->profile()->GetOriginalProfile()); |
|
Peter Kasting
2015/03/30 19:37:02
Nit: Since you don't actually care about the error
edwardjung
2015/03/31 11:44:05
Done.
| |
| 920 AddSeparator(ui::NORMAL_SEPARATOR); | 914 |
| 915 if (signin_errors.size() == 0) { | |
|
Peter Kasting
2015/03/30 19:37:02
Nit: Use .empty()
edwardjung
2015/03/31 11:44:05
Done.
| |
| 916 const base::string16 short_product_name = | |
| 917 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME); | |
| 918 AddItem(IDC_SHOW_SYNC_SETUP, l10n_util::GetStringFUTF16( | |
| 919 IDS_SYNC_MENU_PRE_SYNCED_LABEL, short_product_name)); | |
|
Peter Kasting
2015/03/30 19:37:02
Nit: Existing wrapping isn't actually style-compli
edwardjung
2015/03/31 11:44:05
Done.
| |
| 920 } | |
| 921 } | 921 } |
| 922 } | 922 } |
| 923 #endif | 923 #endif |
| 924 | 924 |
| 925 AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); | |
| 926 | |
| 927 // On ChromeOS we don't want the about menu option. | 925 // On ChromeOS we don't want the about menu option. |
| 928 #if !defined(OS_CHROMEOS) | 926 #if !defined(OS_CHROMEOS) |
| 929 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); | 927 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); |
| 930 #endif | 928 #endif |
| 931 | 929 |
| 932 #if defined(GOOGLE_CHROME_BUILD) | 930 #if defined(GOOGLE_CHROME_BUILD) |
| 933 help_menu_model_.reset(new HelpMenuModel(this, browser_)); | 931 help_menu_model_.reset(new HelpMenuModel(this, browser_)); |
| 934 AddSubMenuWithStringId(IDC_HELP_MENU, IDS_HELP_MENU, | 932 AddSubMenuWithStringId(IDC_HELP_MENU, IDS_HELP_MENU, |
| 935 help_menu_model_.get()); | 933 help_menu_model_.get()); |
| 936 #endif | 934 #endif |
| 937 | 935 |
| 938 #if defined(OS_CHROMEOS) | 936 #if defined(OS_CHROMEOS) |
| 939 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 937 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 940 chromeos::switches::kEnableRequestTabletSite)) | 938 chromeos::switches::kEnableRequestTabletSite)) |
| 941 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, | 939 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, |
| 942 IDS_TOGGLE_REQUEST_TABLET_SITE); | 940 IDS_TOGGLE_REQUEST_TABLET_SITE); |
| 943 #endif | 941 #endif |
| 944 | 942 |
| 945 if (browser_defaults::kShowUpgradeMenuItem) | 943 AddSeparator(ui::NORMAL_SEPARATOR); |
| 946 AddItem(IDC_UPGRADE_DIALOG, GetUpgradeDialogMenuItemName()); | |
| 947 | 944 |
| 945 // Exit / relaunch. | |
| 948 #if defined(OS_WIN) | 946 #if defined(OS_WIN) |
| 949 SetIcon(GetIndexOfCommandId(IDC_VIEW_INCOMPATIBILITIES), | 947 base::win::Version min_version_for_ash_mode = base::win::VERSION_WIN8; |
| 950 ui::ResourceBundle::GetSharedInstance(). | 948 // Windows 7 ASH mode is only supported in DEBUG for now. |
| 951 GetNativeImageNamed(IDR_INPUT_ALERT_MENU)); | 949 #if !defined(NDEBUG) |
| 950 min_version_for_ash_mode = base::win::VERSION_WIN7; | |
| 952 #endif | 951 #endif |
| 953 | 952 // Windows 8 can support ASH mode using WARP, but Windows 7 requires a working |
| 954 AddGlobalErrorMenuItems(); | 953 // GPU compositor. |
| 955 | 954 if ((base::win::GetVersion() >= min_version_for_ash_mode && |
| 956 AddSeparator(ui::NORMAL_SEPARATOR); | 955 content::GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor()) || |
| 957 AddSubMenuWithStringId( | 956 (base::win::GetVersion() >= base::win::VERSION_WIN8)) { |
| 958 IDC_MORE_TOOLS_MENU, IDS_MORE_TOOLS_MENU, tools_menu_model_.get()); | 957 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) { |
| 958 // ASH/Metro mode, add the 'Relaunch Chrome in desktop mode'. | |
| 959 AddSeparator(ui::NORMAL_SEPARATOR); | |
| 960 AddItemWithStringId(IDC_WIN_DESKTOP_RESTART, IDS_WIN_DESKTOP_RESTART); | |
| 961 } else { | |
| 962 // In Windows 8 desktop, add the 'Relaunch Chrome in Windows 8 mode'. | |
| 963 // In Windows 7 desktop, add the 'Relaunch Chrome in Windows ASH mode' | |
| 964 AddSeparator(ui::NORMAL_SEPARATOR); | |
| 965 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | |
|
Peter Kasting
2015/03/30 19:37:02
Nit: No {}
edwardjung
2015/03/31 11:44:04
Done.
| |
| 966 AddItemWithStringId(IDC_WIN8_METRO_RESTART, IDS_WIN8_METRO_RESTART); | |
| 967 } else { | |
| 968 AddItemWithStringId(IDC_WIN_CHROMEOS_RESTART, IDS_WIN_CHROMEOS_RESTART); | |
| 969 } | |
| 970 } | |
| 971 } | |
| 972 #endif | |
| 959 | 973 |
| 960 bool show_exit_menu = browser_defaults::kShowExitMenuItem; | 974 bool show_exit_menu = browser_defaults::kShowExitMenuItem; |
| 961 #if defined(OS_WIN) | 975 #if defined(OS_WIN) |
| 962 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | 976 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) |
| 963 show_exit_menu = false; | 977 show_exit_menu = false; |
| 964 #endif | 978 #endif |
| 965 | 979 |
| 966 if (show_exit_menu) { | 980 if (show_exit_menu) { |
| 967 AddSeparator(ui::NORMAL_SEPARATOR); | 981 AddSeparator(ui::NORMAL_SEPARATOR); |
| 968 AddItemWithStringId(IDC_EXIT, IDS_EXIT); | 982 AddItemWithStringId(IDC_EXIT, IDS_EXIT); |
| 969 } | 983 } |
| 970 | 984 |
| 971 RemoveTrailingSeparators(); | 985 RemoveTrailingSeparators(); |
| 972 uma_action_recorded_ = false; | 986 uma_action_recorded_ = false; |
| 973 } | 987 } |
| 974 | 988 |
| 975 void WrenchMenuModel::AddGlobalErrorMenuItems() { | 989 bool WrenchMenuModel::AddGlobalErrorMenuItems() { |
| 976 // TODO(sail): Currently we only build the wrench menu once per browser | 990 // 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 | 991 // 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 | 992 // 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. | 993 // how update the menu if new errors are added. |
| 980 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 994 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 981 // GetSignedInServiceErrors() can modify the global error list, so call it | 995 // GetSignedInServiceErrors() can modify the global error list, so call it |
| 982 // before iterating through that list below. | 996 // before iterating through that list below. |
| 983 std::vector<GlobalError*> signin_errors; | 997 std::vector<GlobalError*> signin_errors; |
| 984 signin_errors = signin_ui_util::GetSignedInServiceErrors( | 998 signin_errors = signin_ui_util::GetSignedInServiceErrors( |
| 985 browser_->profile()->GetOriginalProfile()); | 999 browser_->profile()->GetOriginalProfile()); |
| 986 const GlobalErrorService::GlobalErrorList& errors = | 1000 const GlobalErrorService::GlobalErrorList& errors = |
| 987 GlobalErrorServiceFactory::GetForProfile(browser_->profile())->errors(); | 1001 GlobalErrorServiceFactory::GetForProfile(browser_->profile())->errors(); |
| 1002 bool menu_items_added = false; | |
| 988 for (GlobalErrorService::GlobalErrorList::const_iterator | 1003 for (GlobalErrorService::GlobalErrorList::const_iterator |
| 989 it = errors.begin(); it != errors.end(); ++it) { | 1004 it = errors.begin(); it != errors.end(); ++it) { |
| 990 GlobalError* error = *it; | 1005 GlobalError* error = *it; |
| 991 DCHECK(error); | 1006 DCHECK(error); |
| 992 if (error->HasMenuItem()) { | 1007 if (error->HasMenuItem()) { |
| 993 #if !defined(OS_CHROMEOS) | 1008 #if !defined(OS_CHROMEOS) |
| 994 // Don't add a signin error if it's already being displayed elsewhere. | 1009 // Don't add a signin error if it's already being displayed elsewhere. |
| 995 if (std::find(signin_errors.begin(), signin_errors.end(), error) != | 1010 if (std::find(signin_errors.begin(), signin_errors.end(), error) != |
| 996 signin_errors.end()) { | 1011 signin_errors.end()) { |
| 997 MenuModel* model = this; | 1012 MenuModel* model = this; |
| 998 int index = 0; | 1013 int index = 0; |
| 999 if (MenuModel::GetModelAndIndexForCommandId( | 1014 if (MenuModel::GetModelAndIndexForCommandId( |
| 1000 IDC_SHOW_SIGNIN, &model, &index)) { | 1015 IDC_SHOW_SIGNIN, &model, &index)) { |
| 1001 continue; | 1016 continue; |
| 1002 } | 1017 } |
| 1003 } | 1018 } |
| 1004 #endif | 1019 #endif |
| 1005 | 1020 |
| 1006 AddItem(error->MenuItemCommandID(), error->MenuItemLabel()); | 1021 AddItem(error->MenuItemCommandID(), error->MenuItemLabel()); |
| 1007 int icon_id = error->MenuItemIconResourceID(); | 1022 int icon_id = error->MenuItemIconResourceID(); |
| 1008 if (icon_id) { | 1023 if (icon_id) { |
| 1009 const gfx::Image& image = rb.GetNativeImageNamed(icon_id); | 1024 const gfx::Image& image = rb.GetNativeImageNamed(icon_id); |
| 1010 SetIcon(GetIndexOfCommandId(error->MenuItemCommandID()), | 1025 SetIcon(GetIndexOfCommandId(error->MenuItemCommandID()), |
| 1011 image); | 1026 image); |
| 1012 } | 1027 } |
| 1028 menu_items_added = true; | |
| 1013 } | 1029 } |
| 1014 } | 1030 } |
| 1031 return menu_items_added; | |
| 1015 } | 1032 } |
| 1016 | 1033 |
| 1017 void WrenchMenuModel::CreateExtensionToolbarOverflowMenu() { | 1034 void WrenchMenuModel::CreateExtensionToolbarOverflowMenu() { |
| 1018 // We only add the extensions overflow container if there are any icons that | 1035 // We only add the extensions overflow container if there are any icons that |
| 1019 // aren't shown in the main container. | 1036 // aren't shown in the main container. |
| 1020 if (!extensions::ExtensionToolbarModel::Get(browser_->profile())-> | 1037 if (!extensions::ExtensionToolbarModel::Get(browser_->profile())-> |
| 1021 all_icons_visible()) { | 1038 all_icons_visible()) { |
| 1022 AddItem(IDC_EXTENSIONS_OVERFLOW_MENU, base::string16()); | 1039 AddItem(IDC_EXTENSIONS_OVERFLOW_MENU, base::string16()); |
| 1023 AddSeparator(ui::UPPER_SEPARATOR); | 1040 AddSeparator(ui::UPPER_SEPARATOR); |
| 1024 } | 1041 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1067 ->GetZoomPercent(); | 1084 ->GetZoomPercent(); |
| 1068 } | 1085 } |
| 1069 zoom_label_ = l10n_util::GetStringFUTF16( | 1086 zoom_label_ = l10n_util::GetStringFUTF16( |
| 1070 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 1087 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
| 1071 } | 1088 } |
| 1072 | 1089 |
| 1073 void WrenchMenuModel::OnZoomLevelChanged( | 1090 void WrenchMenuModel::OnZoomLevelChanged( |
| 1074 const content::HostZoomMap::ZoomLevelChange& change) { | 1091 const content::HostZoomMap::ZoomLevelChange& change) { |
| 1075 UpdateZoomControls(); | 1092 UpdateZoomControls(); |
| 1076 } | 1093 } |
| OLD | NEW |