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

Side by Side Diff: chrome/browser/chromeos/policy/browser_policy_connector_chromeos.cc

Issue 751703003: Implemented consumer management unenrollment. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dcpm
Patch Set: Created 6 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 5 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
6 6
7 #include <string> 7 #include <string>
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 global_user_cloud_policy_provider_ = new ProxyPolicyProvider(); 140 global_user_cloud_policy_provider_ = new ProxyPolicyProvider();
141 AddPolicyProvider(scoped_ptr<ConfigurationPolicyProvider>( 141 AddPolicyProvider(scoped_ptr<ConfigurationPolicyProvider>(
142 global_user_cloud_policy_provider_)); 142 global_user_cloud_policy_provider_));
143 } 143 }
144 144
145 BrowserPolicyConnectorChromeOS::~BrowserPolicyConnectorChromeOS() {} 145 BrowserPolicyConnectorChromeOS::~BrowserPolicyConnectorChromeOS() {}
146 146
147 void BrowserPolicyConnectorChromeOS::Init( 147 void BrowserPolicyConnectorChromeOS::Init(
148 PrefService* local_state, 148 PrefService* local_state,
149 scoped_refptr<net::URLRequestContextGetter> request_context) { 149 scoped_refptr<net::URLRequestContextGetter> request_context) {
150 local_state_ = local_state;
150 ChromeBrowserPolicyConnector::Init(local_state, request_context); 151 ChromeBrowserPolicyConnector::Init(local_state, request_context);
151 152
152 const CommandLine* command_line = CommandLine::ForCurrentProcess(); 153 const CommandLine* command_line = CommandLine::ForCurrentProcess();
153 if (command_line->HasSwitch(chromeos::switches::kEnableConsumerManagement)) { 154 if (command_line->HasSwitch(chromeos::switches::kEnableConsumerManagement)) {
154 scoped_ptr<DeviceManagementService::Configuration> configuration( 155 scoped_ptr<DeviceManagementService::Configuration> configuration(
155 new DeviceManagementServiceConfiguration( 156 new DeviceManagementServiceConfiguration(
156 GetDeviceManagementServerUrlForConsumer())); 157 GetDeviceManagementServerUrlForConsumer()));
157 consumer_device_management_service_.reset( 158 consumer_device_management_service_.reset(
158 new DeviceManagementService(configuration.Pass())); 159 new DeviceManagementService(configuration.Pass()));
159 consumer_device_management_service_->ScheduleInitialization( 160 consumer_device_management_service_->ScheduleInitialization(
160 kServiceInitializationStartupDelay); 161 kServiceInitializationStartupDelay);
161 } 162 }
162 163
163 if (device_cloud_policy_manager_) { 164 if (device_cloud_policy_manager_) {
164 // Note: for now the |device_cloud_policy_manager_| is using the global 165 // Note: for now the |device_cloud_policy_manager_| is using the global
165 // schema registry. Eventually it will have its own registry, once device 166 // schema registry. Eventually it will have its own registry, once device
166 // cloud policy for extensions is introduced. That means it'd have to be 167 // cloud policy for extensions is introduced. That means it'd have to be
167 // initialized from here instead of BrowserPolicyConnector::Init(). 168 // initialized from here instead of BrowserPolicyConnector::Init().
168 169
169 device_cloud_policy_manager_->Initialize(local_state); 170 device_cloud_policy_manager_->Initialize(local_state);
170 device_cloud_policy_manager_->AddObserver(this); 171 device_cloud_policy_manager_->AddObserver(this);
171 172 RestartDeviceCloudPolicyInitializer();
172 device_cloud_policy_initializer_.reset(
173 new DeviceCloudPolicyInitializer(
174 local_state,
175 device_management_service(),
176 consumer_device_management_service_.get(),
177 GetBackgroundTaskRunner(),
178 install_attributes_.get(),
179 state_keys_broker_.get(),
180 device_cloud_policy_manager_->device_store(),
181 device_cloud_policy_manager_,
182 chromeos::DeviceSettingsService::Get()));
183 device_cloud_policy_initializer_->Init();
184 } 173 }
185 174
186 device_local_account_policy_service_.reset( 175 device_local_account_policy_service_.reset(
187 new DeviceLocalAccountPolicyService( 176 new DeviceLocalAccountPolicyService(
188 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), 177 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(),
189 chromeos::DeviceSettingsService::Get(), 178 chromeos::DeviceSettingsService::Get(),
190 chromeos::CrosSettings::Get(), 179 chromeos::CrosSettings::Get(),
191 GetBackgroundTaskRunner(), 180 GetBackgroundTaskRunner(),
192 GetBackgroundTaskRunner(), 181 GetBackgroundTaskRunner(),
193 GetBackgroundTaskRunner(), 182 GetBackgroundTaskRunner(),
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 301
313 // static 302 // static
314 void BrowserPolicyConnectorChromeOS::RegisterPrefs( 303 void BrowserPolicyConnectorChromeOS::RegisterPrefs(
315 PrefRegistrySimple* registry) { 304 PrefRegistrySimple* registry) {
316 registry->RegisterIntegerPref( 305 registry->RegisterIntegerPref(
317 prefs::kDevicePolicyRefreshRate, 306 prefs::kDevicePolicyRefreshRate,
318 CloudPolicyRefreshScheduler::kDefaultRefreshDelayMs); 307 CloudPolicyRefreshScheduler::kDefaultRefreshDelayMs);
319 } 308 }
320 309
321 void BrowserPolicyConnectorChromeOS::OnDeviceCloudPolicyManagerConnected() { 310 void BrowserPolicyConnectorChromeOS::OnDeviceCloudPolicyManagerConnected() {
311 CHECK(device_cloud_policy_initializer_);
312
322 // DeviceCloudPolicyInitializer might still be on the call stack, so we 313 // DeviceCloudPolicyInitializer might still be on the call stack, so we
323 // should release the initializer after this function returns. 314 // should release the initializer after this function returns.
324 if (device_cloud_policy_initializer_) { 315 device_cloud_policy_initializer_->Shutdown();
325 device_cloud_policy_initializer_->Shutdown(); 316 base::MessageLoop::current()->DeleteSoon(
326 base::MessageLoop::current()->DeleteSoon( 317 FROM_HERE, device_cloud_policy_initializer_.release());
327 FROM_HERE, device_cloud_policy_initializer_.release()); 318 }
328 } 319
320 void BrowserPolicyConnectorChromeOS::OnDeviceCloudPolicyManagerDisconnected() {
321 DCHECK(!device_cloud_policy_initializer_);
322
323 RestartDeviceCloudPolicyInitializer();
329 } 324 }
330 325
331 void BrowserPolicyConnectorChromeOS::SetTimezoneIfPolicyAvailable() { 326 void BrowserPolicyConnectorChromeOS::SetTimezoneIfPolicyAvailable() {
332 typedef chromeos::CrosSettingsProvider Provider; 327 typedef chromeos::CrosSettingsProvider Provider;
333 Provider::TrustedStatus result = 328 Provider::TrustedStatus result =
334 chromeos::CrosSettings::Get()->PrepareTrustedValues(base::Bind( 329 chromeos::CrosSettings::Get()->PrepareTrustedValues(base::Bind(
335 &BrowserPolicyConnectorChromeOS::SetTimezoneIfPolicyAvailable, 330 &BrowserPolicyConnectorChromeOS::SetTimezoneIfPolicyAvailable,
336 weak_ptr_factory_.GetWeakPtr())); 331 weak_ptr_factory_.GetWeakPtr()));
337 332
338 if (result != Provider::TRUSTED) 333 if (result != Provider::TRUSTED)
339 return; 334 return;
340 335
341 std::string timezone; 336 std::string timezone;
342 if (chromeos::CrosSettings::Get()->GetString(chromeos::kSystemTimezonePolicy, 337 if (chromeos::CrosSettings::Get()->GetString(chromeos::kSystemTimezonePolicy,
343 &timezone) && 338 &timezone) &&
344 !timezone.empty()) { 339 !timezone.empty()) {
345 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID( 340 chromeos::system::TimezoneSettings::GetInstance()->SetTimezoneFromID(
346 base::UTF8ToUTF16(timezone)); 341 base::UTF8ToUTF16(timezone));
347 } 342 }
348 } 343 }
349 344
345 void BrowserPolicyConnectorChromeOS::RestartDeviceCloudPolicyInitializer() {
346 device_cloud_policy_initializer_.reset(
347 new DeviceCloudPolicyInitializer(
348 local_state_,
349 device_management_service(),
350 consumer_device_management_service_.get(),
351 GetBackgroundTaskRunner(),
352 install_attributes_.get(),
353 state_keys_broker_.get(),
354 device_cloud_policy_manager_->device_store(),
355 device_cloud_policy_manager_,
356 chromeos::DeviceSettingsService::Get(),
357 consumer_management_service_.get()));
358 device_cloud_policy_initializer_->Init();
359 }
360
350 } // namespace policy 361 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698