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/app_menu_model.h" | 5 #include "chrome/browser/ui/toolbar/app_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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 // state. | 99 // state. |
100 base::string16 GetUpgradeDialogMenuItemName() { | 100 base::string16 GetUpgradeDialogMenuItemName() { |
101 if (UpgradeDetector::GetInstance()->is_outdated_install() || | 101 if (UpgradeDetector::GetInstance()->is_outdated_install() || |
102 UpgradeDetector::GetInstance()->is_outdated_install_no_au()) { | 102 UpgradeDetector::GetInstance()->is_outdated_install_no_au()) { |
103 return l10n_util::GetStringUTF16(IDS_UPGRADE_BUBBLE_MENU_ITEM); | 103 return l10n_util::GetStringUTF16(IDS_UPGRADE_BUBBLE_MENU_ITEM); |
104 } else { | 104 } else { |
105 return l10n_util::GetStringUTF16(IDS_UPDATE_NOW); | 105 return l10n_util::GetStringUTF16(IDS_UPDATE_NOW); |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 #if defined(OS_WIN) | |
110 bool GetRestartMenuItemIfRequired(const chrome::HostDesktopType& desktop_type, | |
111 int* command_id, | |
112 int* string_id) { | |
113 if (base::win::GetVersion() == base::win::VERSION_WIN8 || | |
114 base::win::GetVersion() == base::win::VERSION_WIN8_1) { | |
115 if (desktop_type != chrome::HOST_DESKTOP_TYPE_ASH) { | |
116 *command_id = IDC_WIN8_METRO_RESTART; | |
117 *string_id = IDS_WIN8_METRO_RESTART; | |
118 } else { | |
119 *command_id = IDC_WIN_DESKTOP_RESTART; | |
120 *string_id = IDS_WIN_DESKTOP_RESTART; | |
121 } | |
122 return true; | |
123 } | |
124 | |
125 // Windows 7 ASH mode is only supported in DEBUG for now. | |
126 #if !defined(NDEBUG) | |
127 // Windows 8 can support ASH mode using WARP, but Windows 7 requires a working | |
128 // GPU compositor. | |
129 if (base::win::GetVersion() == base::win::VERSION_WIN7 && | |
130 content::GpuDataManager::GetInstance()->CanUseGpuBrowserCompositor()) { | |
131 if (desktop_type != chrome::HOST_DESKTOP_TYPE_ASH) { | |
132 *command_id = IDC_WIN_CHROMEOS_RESTART; | |
133 *string_id = IDS_WIN_CHROMEOS_RESTART; | |
134 } else { | |
135 *command_id = IDC_WIN_DESKTOP_RESTART; | |
136 *string_id = IDS_WIN_DESKTOP_RESTART; | |
137 } | |
138 return true; | |
139 } | |
140 #endif | |
141 return false; | |
142 } | |
143 #endif | |
144 | |
145 } // namespace | 109 } // namespace |
146 | 110 |
147 //////////////////////////////////////////////////////////////////////////////// | 111 //////////////////////////////////////////////////////////////////////////////// |
148 // EncodingMenuModel | 112 // EncodingMenuModel |
149 | 113 |
150 EncodingMenuModel::EncodingMenuModel(Browser* browser) | 114 EncodingMenuModel::EncodingMenuModel(Browser* browser) |
151 : ui::SimpleMenuModel(this), | 115 : ui::SimpleMenuModel(this), |
152 browser_(browser) { | 116 browser_(browser) { |
153 Build(); | 117 Build(); |
154 } | 118 } |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 LogMenuAction(MENU_ACTION_PIN_TO_START_SCREEN); | 453 LogMenuAction(MENU_ACTION_PIN_TO_START_SCREEN); |
490 break; | 454 break; |
491 | 455 |
492 // Recent tabs menu. | 456 // Recent tabs menu. |
493 case IDC_RESTORE_TAB: | 457 case IDC_RESTORE_TAB: |
494 if (!uma_action_recorded_) | 458 if (!uma_action_recorded_) |
495 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.RestoreTab", delta); | 459 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.RestoreTab", delta); |
496 LogMenuAction(MENU_ACTION_RESTORE_TAB); | 460 LogMenuAction(MENU_ACTION_RESTORE_TAB); |
497 break; | 461 break; |
498 | 462 |
499 // Windows. | |
500 case IDC_WIN_DESKTOP_RESTART: | |
501 if (!uma_action_recorded_) { | |
502 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.WinDesktopRestart", | |
503 delta); | |
504 } | |
505 LogMenuAction(MENU_ACTION_WIN_DESKTOP_RESTART); | |
506 break; | |
507 case IDC_WIN8_METRO_RESTART: | |
508 if (!uma_action_recorded_) { | |
509 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.Win8MetroRestart", | |
510 delta); | |
511 } | |
512 LogMenuAction(MENU_ACTION_WIN8_METRO_RESTART); | |
513 break; | |
514 | |
515 case IDC_WIN_CHROMEOS_RESTART: | |
516 if (!uma_action_recorded_) { | |
517 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.ChromeOSRestart", | |
518 delta); | |
519 } | |
520 LogMenuAction(MENU_ACTION_WIN_CHROMEOS_RESTART); | |
521 break; | |
522 case IDC_DISTILL_PAGE: | 463 case IDC_DISTILL_PAGE: |
523 if (!uma_action_recorded_) { | 464 if (!uma_action_recorded_) { |
524 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.DistillPage", | 465 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.DistillPage", |
525 delta); | 466 delta); |
526 } | 467 } |
527 LogMenuAction(MENU_ACTION_DISTILL_PAGE); | 468 LogMenuAction(MENU_ACTION_DISTILL_PAGE); |
528 break; | 469 break; |
529 case IDC_SAVE_PAGE: | 470 case IDC_SAVE_PAGE: |
530 if (!uma_action_recorded_) | 471 if (!uma_action_recorded_) |
531 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.SavePage", delta); | 472 UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.SavePage", delta); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
899 #else | 840 #else |
900 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); | 841 AddItem(IDC_ABOUT, l10n_util::GetStringUTF16(IDS_ABOUT)); |
901 #endif | 842 #endif |
902 #if defined(OS_CHROMEOS) | 843 #if defined(OS_CHROMEOS) |
903 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 844 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
904 chromeos::switches::kEnableRequestTabletSite)) | 845 chromeos::switches::kEnableRequestTabletSite)) |
905 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, | 846 AddCheckItemWithStringId(IDC_TOGGLE_REQUEST_TABLET_SITE, |
906 IDS_TOGGLE_REQUEST_TABLET_SITE); | 847 IDS_TOGGLE_REQUEST_TABLET_SITE); |
907 #endif | 848 #endif |
908 | 849 |
909 #if defined(OS_WIN) | 850 if (browser_defaults::kShowExitMenuItem) { |
910 int command_id = IDC_WIN_DESKTOP_RESTART; | |
911 int string_id = IDS_WIN_DESKTOP_RESTART; | |
912 if (GetRestartMenuItemIfRequired(browser_->host_desktop_type(), | |
913 &command_id, | |
914 &string_id)) { | |
915 AddSeparator(ui::NORMAL_SEPARATOR); | |
916 AddItemWithStringId(command_id, string_id); | |
917 } | |
918 #endif | |
919 bool show_exit_menu = browser_defaults::kShowExitMenuItem; | |
920 #if defined(OS_WIN) | |
921 if (browser_->host_desktop_type() == chrome::HOST_DESKTOP_TYPE_ASH) | |
922 show_exit_menu = false; | |
923 #endif | |
924 if (show_exit_menu) { | |
925 AddSeparator(ui::NORMAL_SEPARATOR); | 851 AddSeparator(ui::NORMAL_SEPARATOR); |
926 AddItemWithStringId(IDC_EXIT, IDS_EXIT); | 852 AddItemWithStringId(IDC_EXIT, IDS_EXIT); |
927 } | 853 } |
928 uma_action_recorded_ = false; | 854 uma_action_recorded_ = false; |
929 } | 855 } |
930 | 856 |
931 bool AppMenuModel::AddGlobalErrorMenuItems() { | 857 bool AppMenuModel::AddGlobalErrorMenuItems() { |
932 // TODO(sail): Currently we only build the app menu once per browser | 858 // TODO(sail): Currently we only build the app menu once per browser |
933 // window. This means that if a new error is added after the menu is built | 859 // window. This means that if a new error is added after the menu is built |
934 // it won't show in the existing app menu. To fix this we need to some | 860 // it won't show in the existing app menu. To fix this we need to some |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 ->GetZoomPercent(); | 941 ->GetZoomPercent(); |
1016 } | 942 } |
1017 zoom_label_ = l10n_util::GetStringFUTF16( | 943 zoom_label_ = l10n_util::GetStringFUTF16( |
1018 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); | 944 IDS_ZOOM_PERCENT, base::IntToString16(zoom_percent)); |
1019 } | 945 } |
1020 | 946 |
1021 void AppMenuModel::OnZoomLevelChanged( | 947 void AppMenuModel::OnZoomLevelChanged( |
1022 const content::HostZoomMap::ZoomLevelChange& change) { | 948 const content::HostZoomMap::ZoomLevelChange& change) { |
1023 UpdateZoomControls(); | 949 UpdateZoomControls(); |
1024 } | 950 } |
OLD | NEW |