| Index: chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc
|
| diff --git a/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc b/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc
|
| index c3203842f0a631b9a957214fe7df9bd4fb53a373..c583098c29700590399a52d08626cda3cc450f8e 100644
|
| --- a/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc
|
| +++ b/chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc
|
| @@ -147,6 +147,7 @@ BrowserPolicyConnectorChromeOS::~BrowserPolicyConnectorChromeOS() {}
|
| void BrowserPolicyConnectorChromeOS::Init(
|
| PrefService* local_state,
|
| scoped_refptr<net::URLRequestContextGetter> request_context) {
|
| + local_state_ = local_state;
|
| ChromeBrowserPolicyConnector::Init(local_state, request_context);
|
|
|
| const CommandLine* command_line = CommandLine::ForCurrentProcess();
|
| @@ -168,19 +169,7 @@ void BrowserPolicyConnectorChromeOS::Init(
|
|
|
| device_cloud_policy_manager_->Initialize(local_state);
|
| device_cloud_policy_manager_->AddObserver(this);
|
| -
|
| - device_cloud_policy_initializer_.reset(
|
| - new DeviceCloudPolicyInitializer(
|
| - local_state,
|
| - device_management_service(),
|
| - consumer_device_management_service_.get(),
|
| - GetBackgroundTaskRunner(),
|
| - install_attributes_.get(),
|
| - state_keys_broker_.get(),
|
| - device_cloud_policy_manager_->device_store(),
|
| - device_cloud_policy_manager_,
|
| - chromeos::DeviceSettingsService::Get()));
|
| - device_cloud_policy_initializer_->Init();
|
| + RestartDeviceCloudPolicyInitializer();
|
| }
|
|
|
| device_local_account_policy_service_.reset(
|
| @@ -319,13 +308,19 @@ void BrowserPolicyConnectorChromeOS::RegisterPrefs(
|
| }
|
|
|
| void BrowserPolicyConnectorChromeOS::OnDeviceCloudPolicyManagerConnected() {
|
| + CHECK(device_cloud_policy_initializer_);
|
| +
|
| // DeviceCloudPolicyInitializer might still be on the call stack, so we
|
| // should release the initializer after this function returns.
|
| - if (device_cloud_policy_initializer_) {
|
| - device_cloud_policy_initializer_->Shutdown();
|
| - base::MessageLoop::current()->DeleteSoon(
|
| - FROM_HERE, device_cloud_policy_initializer_.release());
|
| - }
|
| + device_cloud_policy_initializer_->Shutdown();
|
| + base::MessageLoop::current()->DeleteSoon(
|
| + FROM_HERE, device_cloud_policy_initializer_.release());
|
| +}
|
| +
|
| +void BrowserPolicyConnectorChromeOS::OnDeviceCloudPolicyManagerDisconnected() {
|
| + DCHECK(!device_cloud_policy_initializer_);
|
| +
|
| + RestartDeviceCloudPolicyInitializer();
|
| }
|
|
|
| void BrowserPolicyConnectorChromeOS::SetTimezoneIfPolicyAvailable() {
|
| @@ -347,4 +342,20 @@ void BrowserPolicyConnectorChromeOS::SetTimezoneIfPolicyAvailable() {
|
| }
|
| }
|
|
|
| +void BrowserPolicyConnectorChromeOS::RestartDeviceCloudPolicyInitializer() {
|
| + device_cloud_policy_initializer_.reset(
|
| + new DeviceCloudPolicyInitializer(
|
| + local_state_,
|
| + device_management_service(),
|
| + consumer_device_management_service_.get(),
|
| + GetBackgroundTaskRunner(),
|
| + install_attributes_.get(),
|
| + state_keys_broker_.get(),
|
| + device_cloud_policy_manager_->device_store(),
|
| + device_cloud_policy_manager_,
|
| + chromeos::DeviceSettingsService::Get(),
|
| + consumer_management_service_.get()));
|
| + device_cloud_policy_initializer_->Init();
|
| +}
|
| +
|
| } // namespace policy
|
|
|