| 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 f4cd3bb7305be0a405e1543c08d8e8beb6a603b4..175b474281e1eabcc9b40d319367592b21ffa88e 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"
|
| @@ -202,6 +204,10 @@ BrowserCommandController::BrowserCommandController(
|
| prefs::kPrintingEnabled,
|
| base::Bind(&BrowserCommandController::UpdatePrintingState,
|
| base::Unretained(this)));
|
| + pref_signin_allowed_.Init(prefs::kSigninAllowed,
|
| + profile()->GetOriginalProfile()->GetPrefs(),
|
| + base::Bind(&BrowserCommandController::OnSigninAllowedPrefChange,
|
| + base::Unretained(this)));
|
|
|
| InitCommandState();
|
|
|
| @@ -743,6 +749,17 @@ void BrowserCommandController::OnProfileAvatarChanged(
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| +// BrowserCommandController, SigninPrefObserver implementation:
|
| +
|
| +void BrowserCommandController::OnSigninAllowedPrefChange() {
|
| + // 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 && pref_signin_allowed_.GetValue());
|
| +}
|
| +
|
| // BrowserCommandController, TabStripModelObserver implementation:
|
|
|
| void BrowserCommandController::TabInsertedAt(WebContents* contents,
|
| @@ -883,7 +900,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();
|
| @@ -1118,6 +1137,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.
|
|
|