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

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: Extract managed user specific stuff into another changelist. 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 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,
sail 2013/02/08 20:18:57 Move the code to update this state into a single f
Adrian Kuegel 2013/02/11 16:47:30 Done. Note that I had to pass show_main_ui as a pa
+ 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.

Powered by Google App Engine
This is Rietveld 408576698