Index: chrome/browser/ui/browser_command_controller.cc |
diff --git a/chrome/browser/ui/browser_command_controller.cc b/chrome/browser/ui/browser_command_controller.cc |
index 546d80dc43c5cfe40bd5e513c92bbf90cee04e1f..1aa3bac716f422c07d26d49dc43e432191a1ce15 100644 |
--- a/chrome/browser/ui/browser_command_controller.cc |
+++ b/chrome/browser/ui/browser_command_controller.cc |
@@ -16,6 +16,8 @@ |
#include "chrome/browser/sessions/tab_restore_service.h" |
#include "chrome/browser/sessions/tab_restore_service_factory.h" |
#include "chrome/browser/shell_integration.h" |
+#include "chrome/browser/signin/signin_manager.h" |
+#include "chrome/browser/signin/signin_manager_factory.h" |
#include "chrome/browser/sync/profile_sync_service.h" |
#include "chrome/browser/sync/profile_sync_service_factory.h" |
#include "chrome/browser/ui/bookmarks/bookmark_tab_helper.h" |
@@ -210,9 +212,20 @@ BrowserCommandController::BrowserCommandController( |
tab_restore_service->AddObserver(this); |
TabRestoreServiceChanged(tab_restore_service); |
} |
+ |
+ SigninManager* signin = |
+ SigninManagerFactory::GetInstance()->GetForProfile( |
+ profile()->GetOriginalProfile()); |
+ if (signin) |
+ signin->AddSigninPrefObserver(this); |
Andrew T Wilson (Slow)
2013/02/04 15:41:48
I don't think we want to define a new SigninPrefOb
Adrian Kuegel
2013/02/05 10:55:15
I removed the SigninPrefObserver now. You are righ
|
} |
BrowserCommandController::~BrowserCommandController() { |
+ SigninManager* signin = SigninManagerFactory::GetInstance()->GetForProfile( |
+ profile()->GetOriginalProfile()); |
+ if (signin) |
+ signin->RemoveSigninPrefObserver(this); |
+ |
// TabRestoreService may have been shutdown by the time we get here. Don't |
// trigger creating it. |
TabRestoreService* tab_restore_service = |
@@ -742,6 +755,17 @@ void BrowserCommandController::OnProfileAvatarChanged( |
} |
//////////////////////////////////////////////////////////////////////////////// |
+// BrowserCommandController, SigninPrefObserver implementation: |
+ |
+void BrowserCommandController::OnSigninAllowedPrefChange(bool signin_allowed) { |
+ // For unit tests, we don't have a window. |
+ if (!window()) |
+ return; |
+ const bool show_main_ui = IsShowingMainUI(window()->IsFullscreen()); |
+ command_updater_.UpdateCommandEnabled(IDC_SHOW_SYNC_SETUP, |
+ show_main_ui && signin_allowed); |
+} |
+ |
// BrowserCommandController, TabStripModelObserver implementation: |
void BrowserCommandController::TabInsertedAt(WebContents* contents, |
@@ -881,7 +905,9 @@ void BrowserCommandController::InitCommandState() { |
!profile()->IsGuestSession() && |
!profile()->IsOffTheRecord()); |
- command_updater_.UpdateCommandEnabled(IDC_SHOW_SIGNIN, true); |
+ command_updater_.UpdateCommandEnabled( |
+ IDC_SHOW_SYNC_SETUP, |
+ profile()->GetOriginalProfile()->IsSigninAllowed()); |
// Initialize other commands based on the window type. |
bool normal_window = browser_->is_type_tabbed(); |
@@ -1116,6 +1142,8 @@ void BrowserCommandController::UpdateCommandsForFullscreenMode( |
// Show various bits of UI |
command_updater_.UpdateCommandEnabled(IDC_DEVELOPER_MENU, show_main_ui); |
command_updater_.UpdateCommandEnabled(IDC_FEEDBACK, show_main_ui); |
+ command_updater_.UpdateCommandEnabled(IDC_SHOW_SYNC_SETUP, |
+ show_main_ui && profile()->GetOriginalProfile()->IsSigninAllowed()); |
// Settings page/subpages are forced to open in normal mode. We disable these |
// commands when incognito is forced. |