diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-22 11:11:38 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-22 11:11:38 +0000 |
commit | 244c78b3f737f2cacab2d212801b0524cbcc3a7b (patch) | |
tree | 5e901cfc0981c11c2df7479653acb8c2aa41144f /chrome/browser | |
parent | 5f9c76e2aab9e06be691eb9e6f8bfb563c41dc77 (diff) | |
download | chromium_src-244c78b3f737f2cacab2d212801b0524cbcc3a7b.zip chromium_src-244c78b3f737f2cacab2d212801b0524cbcc3a7b.tar.gz chromium_src-244c78b3f737f2cacab2d212801b0524cbcc3a7b.tar.bz2 |
Reset the device policy machinery upon retrying enrollment.
BUG=chromium-os:18208
TEST=See bug description
Review URL: http://codereview.chromium.org/7676005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@97615 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/chromeos/login/enterprise_enrollment_screen.cc | 6 | ||||
-rw-r--r-- | chrome/browser/policy/browser_policy_connector.cc | 6 | ||||
-rw-r--r-- | chrome/browser/policy/browser_policy_connector.h | 18 | ||||
-rw-r--r-- | chrome/browser/policy/cloud_policy_cache_base.cc | 11 | ||||
-rw-r--r-- | chrome/browser/policy/cloud_policy_cache_base.h | 4 | ||||
-rw-r--r-- | chrome/browser/policy/cloud_policy_controller.cc | 8 | ||||
-rw-r--r-- | chrome/browser/policy/cloud_policy_controller.h | 5 | ||||
-rw-r--r-- | chrome/browser/policy/cloud_policy_subsystem.cc | 7 | ||||
-rw-r--r-- | chrome/browser/policy/cloud_policy_subsystem.h | 6 | ||||
-rw-r--r-- | chrome/browser/policy/device_token_fetcher.cc | 7 | ||||
-rw-r--r-- | chrome/browser/policy/device_token_fetcher.h | 4 |
11 files changed, 48 insertions, 34 deletions
diff --git a/chrome/browser/chromeos/login/enterprise_enrollment_screen.cc b/chrome/browser/chromeos/login/enterprise_enrollment_screen.cc index 48bc472..bcef7e9 100644 --- a/chrome/browser/chromeos/login/enterprise_enrollment_screen.cc +++ b/chrome/browser/chromeos/login/enterprise_enrollment_screen.cc @@ -98,7 +98,7 @@ void EnterpriseEnrollmentScreen::OnAuthCancelled() { policy::kMetricEnrollmentSize); auth_fetcher_.reset(); registrar_.reset(); - g_browser_process->browser_policy_connector()->DeviceStopAutoRetry(); + g_browser_process->browser_policy_connector()->ResetDevicePolicy(); get_screen_observer()->OnExit( ScreenObserver::ENTERPRISE_ENROLLMENT_CANCELLED); } @@ -222,7 +222,7 @@ void EnterpriseEnrollmentScreen::OnPolicyStateChanged( // Stop the policy infrastructure. registrar_.reset(); - g_browser_process->browser_policy_connector()->DeviceStopAutoRetry(); + g_browser_process->browser_policy_connector()->ResetDevicePolicy(); } void EnterpriseEnrollmentScreen::HandleAuthError( @@ -334,7 +334,7 @@ void EnterpriseEnrollmentScreen::RegisterForDevicePolicy( // Push the credentials to the policy infrastructure. It'll start enrollment // and notify us of progress through CloudPolicySubsystem::Observer. - connector->SetDeviceCredentials(user_, token, token_type); + connector->RegisterForDevicePolicy(user_, token, token_type); } } // namespace chromeos diff --git a/chrome/browser/policy/browser_policy_connector.cc b/chrome/browser/policy/browser_policy_connector.cc index 922a2ca..2886988 100644 --- a/chrome/browser/policy/browser_policy_connector.cc +++ b/chrome/browser/policy/browser_policy_connector.cc @@ -98,7 +98,7 @@ ConfigurationPolicyProvider* return recommended_cloud_provider_.get(); } -void BrowserPolicyConnector::SetDeviceCredentials( +void BrowserPolicyConnector::RegisterForDevicePolicy( const std::string& owner_email, const std::string& token, TokenType token_type) { @@ -146,10 +146,10 @@ std::string BrowserPolicyConnector::GetEnterpriseDomain() { return std::string(); } -void BrowserPolicyConnector::DeviceStopAutoRetry() { +void BrowserPolicyConnector::ResetDevicePolicy() { #if defined(OS_CHROMEOS) if (device_cloud_policy_subsystem_.get()) - device_cloud_policy_subsystem_->StopAutoRetry(); + device_cloud_policy_subsystem_->Reset(); #endif } diff --git a/chrome/browser/policy/browser_policy_connector.h b/chrome/browser/policy/browser_policy_connector.h index d919673..350dd77 100644 --- a/chrome/browser/policy/browser_policy_connector.h +++ b/chrome/browser/policy/browser_policy_connector.h @@ -67,11 +67,10 @@ class BrowserPolicyConnector : public NotificationObserver { return user_cloud_policy_subsystem_.get(); } - // Used to set the credentials stored in the data store associated - // with this policy connector. - void SetDeviceCredentials(const std::string& owner_email, - const std::string& token, - TokenType token_type); + // Triggers registration for device policy. + void RegisterForDevicePolicy(const std::string& owner_email, + const std::string& token, + TokenType token_type); // Returns true if this device is managed by an enterprise (as opposed to // a local owner). @@ -83,10 +82,9 @@ class BrowserPolicyConnector : public NotificationObserver { // Returns the enterprise domain if device is managed. std::string GetEnterpriseDomain(); - // Exposes the StopAutoRetry() method of the CloudPolicySubsystem managed - // by this connector, which can be used to disable automatic - // retrying behavior. - void DeviceStopAutoRetry(); + // Reset the device policy machinery. This stops any automatic retry behavior + // and clears the error flags, so potential retries have a chance to succeed. + void ResetDevicePolicy(); // Initiates a policy fetch after a successful device registration. void FetchDevicePolicy(); @@ -95,7 +93,7 @@ class BrowserPolicyConnector : public NotificationObserver { // services are already constructed. void ScheduleServiceInitialization(int64 delay_milliseconds); - // Initializes the user cloud policy infrasturcture. + // Initializes the user cloud policy infrastructure. // TODO(sfeuz): Listen to log-out or going-away messages of TokenService and // reset the backend at that point. void InitializeUserPolicy(const std::string& user_name, diff --git a/chrome/browser/policy/cloud_policy_cache_base.cc b/chrome/browser/policy/cloud_policy_cache_base.cc index 8d23415..4dc0270 100644 --- a/chrome/browser/policy/cloud_policy_cache_base.cc +++ b/chrome/browser/policy/cloud_policy_cache_base.cc @@ -34,6 +34,17 @@ void CloudPolicyCacheBase::RemoveObserver(Observer* observer) { observer_list_.RemoveObserver(observer); } +void CloudPolicyCacheBase::Reset() { + last_policy_refresh_time_ = base::Time(); + is_unmanaged_ = false; + mandatory_policy_.Clear(); + recommended_policy_.Clear(); + public_key_version_.version = 0; + public_key_version_.valid = false; + InformNotifier(CloudPolicySubsystem::UNENROLLED, + CloudPolicySubsystem::NO_DETAILS); +} + const PolicyMap* CloudPolicyCacheBase::policy(PolicyLevel level) { switch (level) { case POLICY_LEVEL_MANDATORY: diff --git a/chrome/browser/policy/cloud_policy_cache_base.h b/chrome/browser/policy/cloud_policy_cache_base.h index 3a57ec2..64f8497 100644 --- a/chrome/browser/policy/cloud_policy_cache_base.h +++ b/chrome/browser/policy/cloud_policy_cache_base.h @@ -73,6 +73,10 @@ class CloudPolicyCacheBase : public base::NonThreadSafe { // Accessor for the underlying PolicyMaps. const PolicyMap* policy(PolicyLevel level); + // Resets the cache, clearing the policy currently stored in memory and the + // last refresh time. + void Reset(); + // true if the cache contains data that is ready to be served as policies. // This should mean that this method turns true as soon as a round-trip to // the local policy storage is complete. The creation of the Profile is diff --git a/chrome/browser/policy/cloud_policy_controller.cc b/chrome/browser/policy/cloud_policy_controller.cc index 7527b76..996d3d1 100644 --- a/chrome/browser/policy/cloud_policy_controller.cc +++ b/chrome/browser/policy/cloud_policy_controller.cc @@ -98,9 +98,8 @@ void CloudPolicyController::Retry() { DoWork(); } -void CloudPolicyController::StopAutoRetry() { - scheduler_->CancelDelayedWork(); - backend_.reset(); +void CloudPolicyController::Reset() { + SetState(STATE_TOKEN_UNAVAILABLE); } void CloudPolicyController::HandlePolicyResponse( @@ -283,7 +282,8 @@ void CloudPolicyController::DoWork() { void CloudPolicyController::SetState( CloudPolicyController::ControllerState new_state) { state_ = new_state; - backend_.reset(); // Discard any pending requests. + + backend_.reset(); // Stop any pending requests. base::Time now(base::Time::NowFromSystemTime()); base::Time refresh_at; diff --git a/chrome/browser/policy/cloud_policy_controller.h b/chrome/browser/policy/cloud_policy_controller.h index 04e5e29..3ce708a 100644 --- a/chrome/browser/policy/cloud_policy_controller.h +++ b/chrome/browser/policy/cloud_policy_controller.h @@ -41,9 +41,8 @@ class CloudPolicyController // Triggers an immediate retry of of the current operation. void Retry(); - // Stops all auto-retrying error handling behavior inside the policy - // subsystem. - void StopAutoRetry(); + // Stops any pending activity and resets the controller to unenrolled state. + void Reset(); // DevicePolicyResponseDelegate implementation: virtual void HandlePolicyResponse( diff --git a/chrome/browser/policy/cloud_policy_subsystem.cc b/chrome/browser/policy/cloud_policy_subsystem.cc index 35da26e..9c43a5e 100644 --- a/chrome/browser/policy/cloud_policy_subsystem.cc +++ b/chrome/browser/policy/cloud_policy_subsystem.cc @@ -129,10 +129,11 @@ CloudPolicySubsystem::ErrorDetails CloudPolicySubsystem::error_details() { return notifier_->error_details(); } -void CloudPolicySubsystem::StopAutoRetry() { - cloud_policy_controller_->StopAutoRetry(); - device_token_fetcher_->StopAutoRetry(); +void CloudPolicySubsystem::Reset() { data_store_->Reset(); + cloud_policy_cache_->Reset(); + cloud_policy_controller_->Reset(); + device_token_fetcher_->Reset(); } // static diff --git a/chrome/browser/policy/cloud_policy_subsystem.h b/chrome/browser/policy/cloud_policy_subsystem.h index f96a12d..41da01e 100644 --- a/chrome/browser/policy/cloud_policy_subsystem.h +++ b/chrome/browser/policy/cloud_policy_subsystem.h @@ -88,9 +88,9 @@ class CloudPolicySubsystem PolicySubsystemState state(); ErrorDetails error_details(); - // Stops all auto-retrying error handling behavior inside the policy - // subsystem. - void StopAutoRetry(); + // Resets the subsystem back to unenrolled state and cancels any pending + // retry operations. + void Reset(); // Registers cloud policy related prefs. static void RegisterPrefs(PrefService* pref_service); diff --git a/chrome/browser/policy/device_token_fetcher.cc b/chrome/browser/policy/device_token_fetcher.cc index e6cef4f..db928cb 100644 --- a/chrome/browser/policy/device_token_fetcher.cc +++ b/chrome/browser/policy/device_token_fetcher.cc @@ -90,9 +90,8 @@ void DeviceTokenFetcher::SetUnmanagedState() { SetState(STATE_UNMANAGED); } -void DeviceTokenFetcher::StopAutoRetry() { - scheduler_->CancelDelayedWork(); - backend_.reset(); +void DeviceTokenFetcher::Reset() { + SetState(STATE_INACTIVE); } void DeviceTokenFetcher::HandleRegisterResponse( @@ -153,6 +152,8 @@ void DeviceTokenFetcher::SetState(FetcherState state) { if (state_ != STATE_TEMPORARY_ERROR) effective_token_fetch_error_delay_ms_ = kTokenFetchErrorDelayMilliseconds; + backend_.reset(); // Stop any pending requests. + base::Time delayed_work_at; switch (state_) { case STATE_INACTIVE: diff --git a/chrome/browser/policy/device_token_fetcher.h b/chrome/browser/policy/device_token_fetcher.h index cec1b93..59e322a 100644 --- a/chrome/browser/policy/device_token_fetcher.h +++ b/chrome/browser/policy/device_token_fetcher.h @@ -49,8 +49,8 @@ class DeviceTokenFetcher virtual void SetUnmanagedState(); - // Disables the auto-retry-on-error behavior of this token fetcher. - void StopAutoRetry(); + // Cancels any pending work on this fetcher and resets it to inactive state. + void Reset(); // DeviceManagementBackend::DeviceRegisterResponseDelegate method overrides: virtual void HandleRegisterResponse( |