Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: chrome/browser/app_controller_mac.mm

Issue 1301583004: Revert of Delete dead signin code (SigninGlobalError) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/app_controller_mac_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/app_controller_mac.mm
diff --git a/chrome/browser/app_controller_mac.mm b/chrome/browser/app_controller_mac.mm
index e1f5a42245b7e9a0dace2f011e63a06e94f4ac8f..137a0605b44a98a3251cb5844cc57e5e4fcc572e 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 @@
@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 @@
// 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 @@
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 @@
#if defined(GOOGLE_CHROME_BUILD)
menuState_->UpdateCommandEnabled(IDC_FEEDBACK, true);
#endif
+ menuState_->UpdateCommandEnabled(IDC_SHOW_SYNC_SETUP, true);
menuState_->UpdateCommandEnabled(IDC_TASK_MANAGER, true);
}
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/app_controller_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698