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 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 Build(browser); | 241 Build(browser); |
242 } | 242 } |
243 | 243 |
244 private: | 244 private: |
245 void Build(Browser* browser) { | 245 void Build(Browser* browser) { |
246 #if defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD) | 246 #if defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD) |
247 int help_string_id = IDS_GET_HELP; | 247 int help_string_id = IDS_GET_HELP; |
248 #else | 248 #else |
249 int help_string_id = IDS_HELP_PAGE; | 249 int help_string_id = IDS_HELP_PAGE; |
250 #endif | 250 #endif |
251 // Don't display the about menu item on Chrome OS. | |
Peter Kasting
2015/06/17 22:59:43
Nit: Say why not.
edwardjung
2015/06/18 16:52:05
Done. Although there doesn't seem to a logical rea
| |
252 #if !defined(OS_CHROMEOS) | |
253 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); | |
254 #endif | |
251 AddItemWithStringId(IDC_HELP_PAGE_VIA_MENU, help_string_id); | 255 AddItemWithStringId(IDC_HELP_PAGE_VIA_MENU, help_string_id); |
252 if (browser_defaults::kShowHelpMenuItemIcon) { | 256 if (browser_defaults::kShowHelpMenuItemIcon) { |
253 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 257 ui::ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
254 SetIcon(GetIndexOfCommandId(IDC_HELP_PAGE_VIA_MENU), | 258 SetIcon(GetIndexOfCommandId(IDC_HELP_PAGE_VIA_MENU), |
255 rb.GetNativeImageNamed(IDR_HELP_MENU)); | 259 rb.GetNativeImageNamed(IDR_HELP_MENU)); |
256 } | 260 } |
257 | 261 |
258 AddItemWithStringId(IDC_FEEDBACK, IDS_FEEDBACK); | 262 AddItemWithStringId(IDC_FEEDBACK, IDS_FEEDBACK); |
259 } | 263 } |
260 | 264 |
(...skipping 15 matching lines...) Expand all Loading... | |
276 | 280 |
277 void ToolsMenuModel::Build(Browser* browser) { | 281 void ToolsMenuModel::Build(Browser* browser) { |
278 bool show_create_shortcuts = true; | 282 bool show_create_shortcuts = true; |
279 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) | 283 #if defined(OS_CHROMEOS) || defined(OS_MACOSX) |
280 show_create_shortcuts = false; | 284 show_create_shortcuts = false; |
281 #elif defined(USE_ASH) | 285 #elif defined(USE_ASH) |
282 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | 286 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) |
283 show_create_shortcuts = false; | 287 show_create_shortcuts = false; |
284 #endif | 288 #endif |
285 | 289 |
286 AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA); | 290 AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE); |
287 AddItemWithStringId(IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS); | |
288 | |
289 if (chrome::CanOpenTaskManager()) | |
290 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); | |
291 | 291 |
292 if (extensions::util::IsNewBookmarkAppsEnabled()) { | 292 if (extensions::util::IsNewBookmarkAppsEnabled()) { |
293 #if defined(OS_MACOSX) | 293 #if defined(OS_MACOSX) |
294 int string_id = IDS_ADD_TO_APPLICATIONS; | 294 int string_id = IDS_ADD_TO_APPLICATIONS; |
295 #elif defined(OS_WIN) | 295 #elif defined(OS_WIN) |
296 int string_id = IDS_ADD_TO_TASKBAR; | 296 int string_id = IDS_ADD_TO_TASKBAR; |
297 #else | 297 #else |
298 int string_id = IDS_ADD_TO_DESKTOP; | 298 int string_id = IDS_ADD_TO_DESKTOP; |
299 #endif | 299 #endif |
300 #if defined(USE_ASH) | 300 #if defined(USE_ASH) |
301 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | 301 if (browser->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) |
302 string_id = IDS_ADD_TO_SHELF; | 302 string_id = IDS_ADD_TO_SHELF; |
303 #endif | 303 #endif |
304 AddItemWithStringId(IDC_CREATE_HOSTED_APP, string_id); | 304 AddItemWithStringId(IDC_CREATE_HOSTED_APP, string_id); |
305 } else if (show_create_shortcuts) { | 305 } else if (show_create_shortcuts) { |
306 AddItemWithStringId(IDC_CREATE_SHORTCUTS, IDS_CREATE_SHORTCUTS); | 306 AddItemWithStringId(IDC_CREATE_SHORTCUTS, IDS_CREATE_SHORTCUTS); |
307 } | 307 } |
308 AddSeparator(ui::NORMAL_SEPARATOR); | |
309 AddItemWithStringId(IDC_CLEAR_BROWSING_DATA, IDS_CLEAR_BROWSING_DATA); | |
310 AddItemWithStringId(IDC_MANAGE_EXTENSIONS, IDS_SHOW_EXTENSIONS); | |
311 | |
312 if (chrome::CanOpenTaskManager()) | |
313 AddItemWithStringId(IDC_TASK_MANAGER, IDS_TASK_MANAGER); | |
308 | 314 |
309 #if defined(OS_CHROMEOS) | 315 #if defined(OS_CHROMEOS) |
310 AddItemWithStringId(IDC_TAKE_SCREENSHOT, IDS_TAKE_SCREENSHOT); | 316 AddItemWithStringId(IDC_TAKE_SCREENSHOT, IDS_TAKE_SCREENSHOT); |
311 #endif | 317 #endif |
312 | 318 |
313 encoding_menu_model_.reset(new EncodingMenuModel(browser)); | 319 encoding_menu_model_.reset(new EncodingMenuModel(browser)); |
314 AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU, | 320 AddSubMenuWithStringId(IDC_ENCODING_MENU, IDS_ENCODING_MENU, |
315 encoding_menu_model_.get()); | 321 encoding_menu_model_.get()); |
316 AddSeparator(ui::NORMAL_SEPARATOR); | 322 AddSeparator(ui::NORMAL_SEPARATOR); |
323 | |
Peter Kasting
2015/06/17 22:59:43
Nit: I can't figure out the logic of when this fun
edwardjung
2015/06/18 16:52:05
Reformatted. Blank lines added for each section of
| |
317 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS); | 324 AddItemWithStringId(IDC_DEV_TOOLS, IDS_DEV_TOOLS); |
318 AddItemWithStringId(IDC_VIEW_SOURCE, IDS_VIEW_SOURCE); | |
Peter Kasting
2015/06/17 22:59:43
Why are we removing View Source? I don't think th
edwardjung
2015/06/18 16:52:05
There's a lot more detail reorganisation in the bu
Peter Kasting
2015/06/18 17:16:58
I'm still concerned about this.
* 3.5% of total V
edwardjung
2015/06/18 17:42:27
Copying comments here so that ainslie can see the
| |
319 AddItemWithStringId(IDC_DEV_TOOLS_CONSOLE, IDS_DEV_TOOLS_CONSOLE); | |
320 AddItemWithStringId(IDC_DEV_TOOLS_DEVICES, IDS_DEV_TOOLS_DEVICES); | |
321 | 325 |
322 #if defined(ENABLE_PROFILING) && !defined(NO_TCMALLOC) | 326 #if defined(ENABLE_PROFILING) && !defined(NO_TCMALLOC) |
323 AddSeparator(ui::NORMAL_SEPARATOR); | 327 AddSeparator(ui::NORMAL_SEPARATOR); |
324 AddCheckItemWithStringId(IDC_PROFILING_ENABLED, IDS_PROFILING_ENABLED); | 328 AddCheckItemWithStringId(IDC_PROFILING_ENABLED, IDS_PROFILING_ENABLED); |
325 #endif | 329 #endif |
326 } | 330 } |
327 | 331 |
328 //////////////////////////////////////////////////////////////////////////////// | 332 //////////////////////////////////////////////////////////////////////////////// |
329 // WrenchMenuModel | 333 // WrenchMenuModel |
330 | 334 |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
897 IsCommandIdVisible(IDC_UPGRADE_DIALOG)) | 901 IsCommandIdVisible(IDC_UPGRADE_DIALOG)) |
898 AddSeparator(ui::NORMAL_SEPARATOR); | 902 AddSeparator(ui::NORMAL_SEPARATOR); |
899 | 903 |
900 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); | 904 AddItemWithStringId(IDC_NEW_TAB, IDS_NEW_TAB); |
901 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); | 905 AddItemWithStringId(IDC_NEW_WINDOW, IDS_NEW_WINDOW); |
902 if (ShouldShowNewIncognitoWindowMenuItem()) | 906 if (ShouldShowNewIncognitoWindowMenuItem()) |
903 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); | 907 AddItemWithStringId(IDC_NEW_INCOGNITO_WINDOW, IDS_NEW_INCOGNITO_WINDOW); |
904 | 908 |
905 AddSeparator(ui::NORMAL_SEPARATOR); | 909 AddSeparator(ui::NORMAL_SEPARATOR); |
906 | 910 |
907 AddItemWithStringId(IDC_SHOW_HISTORY, IDS_SHOW_HISTORY); | |
908 AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS); | |
909 | |
910 if (!browser_->profile()->IsOffTheRecord()) { | 911 if (!browser_->profile()->IsOffTheRecord()) { |
911 recent_tabs_sub_menu_model_.reset(new RecentTabsSubMenuModel(provider_, | 912 recent_tabs_sub_menu_model_.reset(new RecentTabsSubMenuModel(provider_, |
912 browser_, | 913 browser_, |
913 NULL)); | 914 NULL)); |
914 AddSubMenuWithStringId(IDC_RECENT_TABS_MENU, IDS_RECENT_TABS_MENU, | 915 AddSubMenuWithStringId(IDC_RECENT_TABS_MENU, IDS_HISTORY_RECENT_TABS_MENU, |
915 recent_tabs_sub_menu_model_.get()); | 916 recent_tabs_sub_menu_model_.get()); |
916 } | 917 } |
918 AddItemWithStringId(IDC_SHOW_DOWNLOADS, IDS_SHOW_DOWNLOADS); | |
917 | 919 |
918 if (!browser_->profile()->IsGuestSession()) { | 920 if (!browser_->profile()->IsGuestSession()) { |
919 bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_)); | 921 bookmark_sub_menu_model_.reset(new BookmarkSubMenuModel(this, browser_)); |
920 AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU, | 922 AddSubMenuWithStringId(IDC_BOOKMARKS_MENU, IDS_BOOKMARKS_MENU, |
921 bookmark_sub_menu_model_.get()); | 923 bookmark_sub_menu_model_.get()); |
922 } | 924 } |
923 | 925 |
924 CreateZoomMenu(); | 926 CreateZoomMenu(); |
925 | 927 |
926 AddItemWithStringId(IDC_PRINT, IDS_PRINT); | 928 AddItemWithStringId(IDC_PRINT, IDS_PRINT); |
927 AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE); | 929 // AddItemWithStringId(IDC_SAVE_PAGE, IDS_SAVE_PAGE); |
Peter Kasting
2015/06/17 22:59:43
In or out, but not in-but-commented-out.
edwardjung
2015/06/18 16:52:05
Done.
| |
928 AddItemWithStringId(IDC_FIND, IDS_FIND); | 930 AddItemWithStringId(IDC_FIND, IDS_FIND); |
929 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 931 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
930 switches::kEnableDomDistiller)) | 932 switches::kEnableDomDistiller)) |
931 AddItemWithStringId(IDC_DISTILL_PAGE, IDS_DISTILL_PAGE); | 933 AddItemWithStringId(IDC_DISTILL_PAGE, IDS_DISTILL_PAGE); |
932 tools_menu_model_.reset(new ToolsMenuModel(this, browser_)); | 934 tools_menu_model_.reset(new ToolsMenuModel(this, browser_)); |
933 AddSubMenuWithStringId( | 935 AddSubMenuWithStringId( |
934 IDC_MORE_TOOLS_MENU, IDS_MORE_TOOLS_MENU, tools_menu_model_.get()); | 936 IDC_MORE_TOOLS_MENU, IDS_MORE_TOOLS_MENU, tools_menu_model_.get()); |
935 | 937 |
936 // Append the full menu including separators. The final separator only gets | 938 // Append the full menu including separators. The final separator only gets |
937 // appended when this is a touch menu - otherwise it would get added twice. | 939 // appended when this is a touch menu - otherwise it would get added twice. |
(...skipping 10 matching lines...) Expand all Loading... | |
948 signin_ui_util::GetSignedInServiceErrors( | 950 signin_ui_util::GetSignedInServiceErrors( |
949 browser_->profile()->GetOriginalProfile()).empty()) { | 951 browser_->profile()->GetOriginalProfile()).empty()) { |
950 AddItem(IDC_SHOW_SYNC_SETUP, | 952 AddItem(IDC_SHOW_SYNC_SETUP, |
951 l10n_util::GetStringFUTF16( | 953 l10n_util::GetStringFUTF16( |
952 IDS_SYNC_MENU_PRE_SYNCED_LABEL, | 954 IDS_SYNC_MENU_PRE_SYNCED_LABEL, |
953 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); | 955 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
954 } | 956 } |
955 } | 957 } |
956 #endif | 958 #endif |
957 | 959 |
958 // On ChromeOS we don't want the about menu option. | |
959 #if !defined(OS_CHROMEOS) | |
960 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); | |
961 #endif | |
962 | |
963 #if defined(GOOGLE_CHROME_BUILD) | 960 #if defined(GOOGLE_CHROME_BUILD) |
964 help_menu_model_.reset(new HelpMenuModel(this, browser_)); | 961 help_menu_model_.reset(new HelpMenuModel(this, browser_)); |
965 AddSubMenuWithStringId(IDC_HELP_MENU, IDS_HELP_MENU, | 962 AddSubMenuWithStringId(IDC_HELP_MENU, IDS_HELP_MENU, |
966 help_menu_model_.get()); | 963 help_menu_model_.get()); |
964 #elif !defined(OS_CHROMEOS) | |
965 // Display the about menu item for non Chrome OS and non Google builds. | |
Peter Kasting
2015/06/17 22:59:43
Why do we have two blocks in this file both dedica
edwardjung
2015/06/18 16:52:05
We moved the 'About' menu item under the help subm
| |
966 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); | |
967 #endif | 967 #endif |
968 | 968 |
969 #if defined(OS_CHROMEOS) | 969 #if defined(OS_CHROMEOS) |
970 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 970 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
971 chromeos::switches::kEnableRequestTabletSite)) | 971 chromeos::switches::kEnableRequestTabletSite)) |
972 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, | 972 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, |
973 IDS_TOGGLE_REQUEST_TABLET_SITE); | 973 IDS_TOGGLE_REQUEST_TABLET_SITE); |
974 #endif | 974 #endif |
975 | 975 |
976 #if defined(OS_WIN) | 976 #if defined(OS_WIN) |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1108 ->GetZoomPercent(); | 1108 ->GetZoomPercent(); |
1109 } | 1109 } |
1110 zoom_label_ = l10n_util::GetStringFUTF16( | 1110 zoom_label_ = l10n_util::GetStringFUTF16( |
1111 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 1111 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
1112 } | 1112 } |
1113 | 1113 |
1114 void WrenchMenuModel::OnZoomLevelChanged( | 1114 void WrenchMenuModel::OnZoomLevelChanged( |
1115 const content::HostZoomMap::ZoomLevelChange& change) { | 1115 const content::HostZoomMap::ZoomLevelChange& change) { |
1116 UpdateZoomControls(); | 1116 UpdateZoomControls(); |
1117 } | 1117 } |
OLD | NEW |