Index: chrome/browser/ui/toolbar/wrench_menu_model.cc |
diff --git a/chrome/browser/ui/toolbar/wrench_menu_model.cc b/chrome/browser/ui/toolbar/wrench_menu_model.cc |
index b3ffec09a6b2efe95c7d5202b825030fa0ac97df..5f9ca12ae7d21024e8709f2d56fc691a8e654ba1 100644 |
--- a/chrome/browser/ui/toolbar/wrench_menu_model.cc |
+++ b/chrome/browser/ui/toolbar/wrench_menu_model.cc |
@@ -366,7 +366,8 @@ |
#elif defined(OS_WIN) |
command_id == IDC_PIN_TO_START_SCREEN || |
#endif |
- command_id == IDC_UPGRADE_DIALOG; |
+ command_id == IDC_UPGRADE_DIALOG || |
+ (!switches::IsNewAvatarMenu() && command_id == IDC_SHOW_SIGNIN); |
} |
base::string16 WrenchMenuModel::GetLabelForCommandId(int command_id) const { |
@@ -396,6 +397,10 @@ |
#endif |
case IDC_UPGRADE_DIALOG: |
return GetUpgradeDialogMenuItemName(); |
+ case IDC_SHOW_SIGNIN: |
+ DCHECK(!switches::IsNewAvatarMenu()); |
+ return signin_ui_util::GetSigninMenuLabel( |
+ browser_->profile()->GetOriginalProfile()); |
default: |
NOTREACHED(); |
return base::string16(); |
@@ -414,6 +419,19 @@ |
} |
return false; |
} |
+ case IDC_SHOW_SIGNIN: { |
+ DCHECK(!switches::IsNewAvatarMenu()); |
+ GlobalError* error = signin_ui_util::GetSignedInServiceError( |
+ browser_->profile()->GetOriginalProfile()); |
+ if (error) { |
+ int icon_id = error->MenuItemIconResourceID(); |
+ if (icon_id) { |
+ *icon = rb.GetNativeImageNamed(icon_id); |
+ return true; |
+ } |
+ } |
+ return false; |
+ } |
default: |
break; |
} |
@@ -428,6 +446,16 @@ |
return; |
} |
+ if (!switches::IsNewAvatarMenu() && command_id == IDC_SHOW_SIGNIN) { |
+ // If a custom error message is being shown, handle it. |
+ GlobalError* error = signin_ui_util::GetSignedInServiceError( |
+ browser_->profile()->GetOriginalProfile()); |
+ if (error) { |
+ error->ExecuteMenuItem(browser_); |
+ return; |
+ } |
+ } |
+ |
LogMenuMetrics(command_id); |
chrome::ExecuteCommand(browser_, command_id); |
} |
@@ -671,6 +699,13 @@ |
delta); |
} |
LogMenuAction(MENU_ACTION_SHOW_DOWNLOADS); |
+ break; |
+ case IDC_SHOW_SYNC_SETUP: |
+ if (!uma_action_recorded_) { |
+ UMA_HISTOGRAM_MEDIUM_TIMES("WrenchMenu.TimeToAction.ShowSyncSetup", |
+ delta); |
+ } |
+ LogMenuAction(MENU_ACTION_SHOW_SYNC_SETUP); |
break; |
case IDC_OPTIONS: |
if (!uma_action_recorded_) |
@@ -895,7 +930,21 @@ |
CreateCutCopyPasteMenu(); |
AddItemWithStringId(IDC_OPTIONS, IDS_SETTINGS); |
- |
+#if !defined(OS_CHROMEOS) |
+ if (!switches::IsNewAvatarMenu()) { |
+ // No "Sign in to Chromium..." menu item on ChromeOS. |
+ SigninManager* signin = SigninManagerFactory::GetForProfile( |
+ browser_->profile()->GetOriginalProfile()); |
+ if (signin && signin->IsSigninAllowed() && |
+ signin_ui_util::GetSignedInServiceErrors( |
+ browser_->profile()->GetOriginalProfile()).empty()) { |
+ AddItem(IDC_SHOW_SYNC_SETUP, |
+ l10n_util::GetStringFUTF16( |
+ IDS_SYNC_MENU_PRE_SYNCED_LABEL, |
+ l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
+ } |
+ } |
+#endif |
// The help submenu is only displayed on official Chrome builds. As the |
// 'About' item has been moved to this submenu, it's reinstated here for |
// Chromium builds. |
@@ -941,6 +990,11 @@ |
// it won't show in the existing wrench menu. To fix this we need to some |
// how update the menu if new errors are added. |
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
+ // GetSignedInServiceErrors() can modify the global error list, so call it |
+ // before iterating through that list below. |
+ std::vector<GlobalError*> signin_errors; |
+ signin_errors = signin_ui_util::GetSignedInServiceErrors( |
+ browser_->profile()->GetOriginalProfile()); |
const GlobalErrorService::GlobalErrorList& errors = |
GlobalErrorServiceFactory::GetForProfile(browser_->profile())->errors(); |
bool menu_items_added = false; |
@@ -949,6 +1003,19 @@ |
GlobalError* error = *it; |
DCHECK(error); |
if (error->HasMenuItem()) { |
+#if !defined(OS_CHROMEOS) |
+ // Don't add a signin error if it's already being displayed elsewhere. |
+ if (std::find(signin_errors.begin(), signin_errors.end(), error) != |
+ signin_errors.end()) { |
+ MenuModel* model = this; |
+ int index = 0; |
+ if (MenuModel::GetModelAndIndexForCommandId( |
+ IDC_SHOW_SIGNIN, &model, &index)) { |
+ continue; |
+ } |
+ } |
+#endif |
+ |
AddItem(error->MenuItemCommandID(), error->MenuItemLabel()); |
int icon_id = error->MenuItemIconResourceID(); |
if (icon_id) { |