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

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

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

Powered by Google App Engine
This is Rietveld 408576698