diff options
Diffstat (limited to 'chrome/browser/app_controller_mac.mm')
-rw-r--r-- | chrome/browser/app_controller_mac.mm | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm index e1f5a42..137a060 100644 --- a/chrome/browser/app_controller_mac.mm +++ b/chrome/browser/app_controller_mac.mm @@ -44,6 +44,7 @@ #include "chrome/browser/sessions/tab_restore_service_factory.h" #include "chrome/browser/signin/signin_manager_factory.h" #include "chrome/browser/signin/signin_promo.h" +#include "chrome/browser/signin/signin_ui_util.h" #include "chrome/browser/sync/profile_sync_service.h" #include "chrome/browser/sync/sync_ui_util.h" #include "chrome/browser/ui/browser.h" @@ -302,6 +303,33 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver { @synthesize startupComplete = startupComplete_; ++ (void)updateSigninItem:(id)signinItem + shouldShow:(BOOL)showSigninMenuItem + currentProfile:(Profile*)profile { + DCHECK([signinItem isKindOfClass:[NSMenuItem class]]); + NSMenuItem* signinMenuItem = static_cast<NSMenuItem*>(signinItem); + + // Look for a separator immediately after the menu item so it can be hidden + // or shown appropriately along with the signin menu item. + NSMenuItem* followingSeparator = nil; + NSMenu* menu = [signinItem menu]; + if (menu) { + NSInteger signinItemIndex = [menu indexOfItem:signinMenuItem]; + DCHECK_NE(signinItemIndex, -1); + if ((signinItemIndex + 1) < [menu numberOfItems]) { + NSMenuItem* menuItem = [menu itemAtIndex:(signinItemIndex + 1)]; + if ([menuItem isSeparatorItem]) { + followingSeparator = menuItem; + } + } + } + + base::string16 label = signin_ui_util::GetSigninMenuLabel(profile); + [signinMenuItem setTitle:l10n_util::FixUpWindowsStyleLabel(label)]; + [signinMenuItem setHidden:!showSigninMenuItem]; + [followingSeparator setHidden:!showSigninMenuItem]; +} + - (void)dealloc { [[closeTabMenuItem_ menu] setDelegate:nil]; [super dealloc]; @@ -929,6 +957,27 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver { // dialog. enable = ![self keyWindowIsModal]; break; + case IDC_SHOW_SYNC_SETUP: { + Profile* lastProfile = [self lastProfile]; + // The profile may be NULL during shutdown -- see + // http://code.google.com/p/chromium/issues/detail?id=43048 . + // + // TODO(akalin,viettrungluu): Figure out whether this method + // can be prevented from being called if lastProfile is + // NULL. + if (!lastProfile) { + LOG(WARNING) + << "NULL lastProfile detected -- not doing anything"; + break; + } + SigninManager* signin = SigninManagerFactory::GetForProfile( + lastProfile->GetOriginalProfile()); + enable = signin->IsSigninAllowed() && ![self keyWindowIsModal]; + [AppController updateSigninItem:item + shouldShow:enable + currentProfile:lastProfile]; + break; + } #if defined(GOOGLE_CHROME_BUILD) case IDC_FEEDBACK: enable = NO; @@ -1080,6 +1129,14 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver { else chrome::OpenHelpWindow(lastProfile, chrome::HELP_SOURCE_MENU); break; + case IDC_SHOW_SYNC_SETUP: + if (Browser* browser = ActivateBrowser(lastProfile)) { + chrome::ShowBrowserSigninOrSettings(browser, + signin_metrics::SOURCE_MENU); + } else { + chrome::OpenSyncSetupWindow(lastProfile, signin_metrics::SOURCE_MENU); + } + break; case IDC_TASK_MANAGER: chrome::OpenTaskManager(NULL); break; @@ -1233,6 +1290,7 @@ class AppControllerProfileObserver : public ProfileInfoCacheObserver { #if defined(GOOGLE_CHROME_BUILD) menuState_->UpdateCommandEnabled(IDC_FEEDBACK, true); #endif + menuState_->UpdateCommandEnabled(IDC_SHOW_SYNC_SETUP, true); menuState_->UpdateCommandEnabled(IDC_TASK_MANAGER, true); } |