diff options
author | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-15 14:14:41 +0000 |
---|---|---|
committer | atwilson@chromium.org <atwilson@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-15 14:14:41 +0000 |
commit | 1c500db34be8e8bf4770cb550d70a0a8b87a5d5d (patch) | |
tree | fabf157debd818eeff7c8dbffbeeeffa06796dfb /chrome/browser/policy | |
parent | 0e72c88665a9c1054e89fac3646be835c9d1c746 (diff) | |
download | chromium_src-1c500db34be8e8bf4770cb550d70a0a8b87a5d5d.zip chromium_src-1c500db34be8e8bf4770cb550d70a0a8b87a5d5d.tar.gz chromium_src-1c500db34be8e8bf4770cb550d70a0a8b87a5d5d.tar.bz2 |
Properly handle disabling sync via the google dashboard.
Add SigninManager::ProhibitSignout() that the policy code can use to disable
signout. This makes our previous ad-hoc signout prohibition more stable by
catching other places where we might sign out (such as cancelling sync during
re-auth).
Add SigninManager::IsSignoutProhibited() which UI code that wants to show/hide
signout UI can call.
Restores old behavior where stopping sync via the google dashboard will try to
sign out the user.
Fixed sync UI to properly display the "Sync is stopped via the google dashboard"
message when sync is stopped on desktop platforms.
Updated sync settings code to trigger a re-auth flow when the user clicks on "Advanced Sync Setup..." when sync is stopped via the dashboard.
BUG=174134
Review URL: https://codereview.chromium.org/12258036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182705 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/policy')
-rw-r--r-- | chrome/browser/policy/user_policy_signin_service.cc | 13 | ||||
-rw-r--r-- | chrome/browser/policy/user_policy_signin_service.h | 4 | ||||
-rw-r--r-- | chrome/browser/policy/user_policy_signin_service_unittest.cc | 10 |
3 files changed, 23 insertions, 4 deletions
diff --git a/chrome/browser/policy/user_policy_signin_service.cc b/chrome/browser/policy/user_policy_signin_service.cc index 19b70ae..96c7a2e 100644 --- a/chrome/browser/policy/user_policy_signin_service.cc +++ b/chrome/browser/policy/user_policy_signin_service.cc @@ -408,6 +408,7 @@ void UserPolicySigninService::InitializeUserCloudPolicyManager( manager->Connect(g_browser_process->local_state(), client.Pass()); DCHECK(manager->core()->service()); StartObserving(); + ProhibitSignoutIfNeeded(); } void UserPolicySigninService::InitializeForSignedInUser() { @@ -474,6 +475,8 @@ void UserPolicySigninService::OnInitializationCompleted( } RegisterCloudPolicyService(token); } + // If client is registered now, prohibit signout. + ProhibitSignoutIfNeeded(); } void UserPolicySigninService::RegisterCloudPolicyService( @@ -496,9 +499,19 @@ void UserPolicySigninService::RegisterCloudPolicyService( } void UserPolicySigninService::OnRegistrationComplete() { + ProhibitSignoutIfNeeded(); registration_helper_.reset(); } +void UserPolicySigninService::ProhibitSignoutIfNeeded() { + if (GetManager()->IsClientRegistered()) { + DVLOG(1) << "User is registered for policy - prohibiting signout"; + SigninManager* signin_manager = + SigninManagerFactory::GetForProfile(profile_); + signin_manager->ProhibitSignout(); + } +} + void UserPolicySigninService::Shutdown() { // Stop any pending registration helper activity. We do this here instead of // in the destructor because we want to shutdown the registration helper diff --git a/chrome/browser/policy/user_policy_signin_service.h b/chrome/browser/policy/user_policy_signin_service.h index 1dca276..1e0f4a2 100644 --- a/chrome/browser/policy/user_policy_signin_service.h +++ b/chrome/browser/policy/user_policy_signin_service.h @@ -104,6 +104,10 @@ class UserPolicySigninService // Callback invoked when policy registration has finished. void OnRegistrationComplete(); + // Helper routine which prohibits user signout if the user is registered for + // cloud policy. + void ProhibitSignoutIfNeeded(); + // Helper routines to (un)register for CloudPolicyService and // CloudPolicyClient notifications. void StartObserving(); diff --git a/chrome/browser/policy/user_policy_signin_service_unittest.cc b/chrome/browser/policy/user_policy_signin_service_unittest.cc index 5743889..64460c2 100644 --- a/chrome/browser/policy/user_policy_signin_service_unittest.cc +++ b/chrome/browser/policy/user_policy_signin_service_unittest.cc @@ -110,8 +110,9 @@ class UserPolicySigninServiceTest : public testing::Test { EXPECT_CALL(*mock_store_, Load()).Times(AnyNumber()); manager_.reset(new UserCloudPolicyManager( profile_.get(), scoped_ptr<UserCloudPolicyStore>(mock_store_))); - SigninManagerFactory::GetInstance()->SetTestingFactory( - profile_.get(), FakeSigninManager::Build); + signin_manager_ = static_cast<FakeSigninManager*>( + SigninManagerFactory::GetInstance()->SetTestingFactoryAndUse( + profile_.get(), FakeSigninManager::Build)); // Make sure the UserPolicySigninService is created. UserPolicySigninServiceFactory::GetForProfile(profile_.get()); @@ -247,6 +248,8 @@ class UserPolicySigninServiceTest : public testing::Test { net::TestURLFetcherFactory url_factory_; + FakeSigninManager* signin_manager_; + // Used in conjunction with OnRegisterCompleted() to test client registration // callbacks. scoped_ptr<CloudPolicyClient> created_client_; @@ -623,8 +626,7 @@ TEST_F(UserPolicySigninServiceTest, FetchPolicySuccess) { TEST_F(UserPolicySigninServiceTest, SignOutThenSignInAgain) { TestSuccessfulSignin(); - // Now sign out. - SigninManagerFactory::GetForProfile(profile_.get())->SignOut(); + signin_manager_->ForceSignOut(); ASSERT_FALSE(manager_->core()->service()); // Now sign in again. |