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

Unified Diff: chrome/browser/ui/browser_command_controller.cc

Issue 12088040: Add a SigninAllowed policy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix indentation issues. Created 7 years, 10 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
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 811679ae57192a22c281ea0e42fc4196c5ca81bd..7d08cbd0028526a990b1e652d4e83cbd8314d8de 100644
--- a/chrome/browser/ui/browser_command_controller.cc
+++ b/chrome/browser/ui/browser_command_controller.cc
@@ -201,6 +201,11 @@ 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();
@@ -740,6 +745,15 @@ void BrowserCommandController::OnProfileAvatarChanged(
}
////////////////////////////////////////////////////////////////////////////////
+// BrowserCommandController, SigninPrefObserver implementation:
+
+void BrowserCommandController::OnSigninAllowedPrefChange() {
+ // For unit tests, we don't have a window.
+ if (!window())
+ return;
+ UpdateShowSyncState(IsShowingMainUI(window()->IsFullscreen()));
+}
+
// BrowserCommandController, TabStripModelObserver implementation:
void BrowserCommandController::TabInsertedAt(WebContents* contents,
@@ -880,7 +894,7 @@ void BrowserCommandController::InitCommandState() {
!profile()->IsGuestSession() &&
!profile()->IsOffTheRecord());
- command_updater_.UpdateCommandEnabled(IDC_SHOW_SIGNIN, true);
+ UpdateShowSyncState(true);
// Initialize other commands based on the window type.
bool normal_window = browser_->is_type_tabbed();
@@ -1115,6 +1129,7 @@ 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);
+ UpdateShowSyncState(show_main_ui);
// Settings page/subpages are forced to open in normal mode. We disable these
// commands when incognito is forced.
@@ -1187,6 +1202,11 @@ void BrowserCommandController::UpdateSaveAsState() {
command_updater_.UpdateCommandEnabled(IDC_SAVE_PAGE, CanSavePage(browser_));
}
+void BrowserCommandController::UpdateShowSyncState(bool show_main_ui) {
+ command_updater_.UpdateCommandEnabled(
+ IDC_SHOW_SYNC_SETUP, show_main_ui && pref_signin_allowed_.GetValue());
+}
+
// static
void BrowserCommandController::UpdateOpenFileState(
CommandUpdater* command_updater) {

Powered by Google App Engine
This is Rietveld 408576698