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

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

Issue 2642793002: Don't start device cloud policy connection after Chromad enrollment (Closed)
Patch Set: Check for enrollment type in EnrollmentCompleted() and TryToCreateClient() Created 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/device_cloud_policy_initializer.h" 5 #include "chrome/browser/chromeos/policy/device_cloud_policy_initializer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 // Do nothing. 237 // Do nothing.
238 } 238 }
239 239
240 void DeviceCloudPolicyInitializer::EnrollmentCompleted( 240 void DeviceCloudPolicyInitializer::EnrollmentCompleted(
241 const EnrollmentCallback& enrollment_callback, 241 const EnrollmentCallback& enrollment_callback,
242 EnrollmentStatus status) { 242 EnrollmentStatus status) {
243 std::unique_ptr<CloudPolicyClient> client = 243 std::unique_ptr<CloudPolicyClient> client =
244 enrollment_handler_->ReleaseClient(); 244 enrollment_handler_->ReleaseClient();
245 enrollment_handler_.reset(); 245 enrollment_handler_.reset();
246 246
247 if (status.status() == EnrollmentStatus::SUCCESS) { 247 if (status.status() == EnrollmentStatus::SUCCESS &&
248 !install_attributes_->IsActiveDirectoryManaged()) {
248 StartConnection(std::move(client)); 249 StartConnection(std::move(client));
249 } else { 250 } else {
250 // Some attempts to create a client may be blocked because the enrollment 251 // Some attempts to create a client may be blocked because the enrollment
251 // was in progress. We give it a try again. 252 // was in progress. We give it a try again.
252 TryToCreateClient(); 253 TryToCreateClient();
253 } 254 }
254 255
255 if (!enrollment_callback.is_null()) 256 if (!enrollment_callback.is_null())
256 enrollment_callback.Run(status); 257 enrollment_callback.Run(status);
257 } 258 }
258 259
259 std::unique_ptr<CloudPolicyClient> DeviceCloudPolicyInitializer::CreateClient( 260 std::unique_ptr<CloudPolicyClient> DeviceCloudPolicyInitializer::CreateClient(
260 DeviceManagementService* device_management_service) { 261 DeviceManagementService* device_management_service) {
261 std::string machine_model; 262 std::string machine_model;
262 statistics_provider_->GetMachineStatistic(chromeos::system::kHardwareClassKey, 263 statistics_provider_->GetMachineStatistic(chromeos::system::kHardwareClassKey,
263 &machine_model); 264 &machine_model);
264 return base::MakeUnique<CloudPolicyClient>( 265 return base::MakeUnique<CloudPolicyClient>(
265 statistics_provider_->GetEnterpriseMachineID(), machine_model, 266 statistics_provider_->GetEnterpriseMachineID(), machine_model,
266 device_management_service, g_browser_process->system_request_context(), 267 device_management_service, g_browser_process->system_request_context(),
267 signing_service_.get()); 268 signing_service_.get());
268 } 269 }
269 270
270 void DeviceCloudPolicyInitializer::TryToCreateClient() { 271 void DeviceCloudPolicyInitializer::TryToCreateClient() {
271 if (!device_store_->is_initialized() || 272 if (!device_store_->is_initialized() ||
272 !device_store_->has_policy() || 273 !device_store_->has_policy() ||
273 state_keys_broker_->pending() || 274 state_keys_broker_->pending() ||
274 enrollment_handler_) { 275 enrollment_handler_ ||
276 install_attributes_->IsActiveDirectoryManaged()) {
275 return; 277 return;
276 } 278 }
277 StartConnection(CreateClient(enterprise_service_)); 279 StartConnection(CreateClient(enterprise_service_));
278 } 280 }
279 281
280 void DeviceCloudPolicyInitializer::StartConnection( 282 void DeviceCloudPolicyInitializer::StartConnection(
281 std::unique_ptr<CloudPolicyClient> client) { 283 std::unique_ptr<CloudPolicyClient> client) {
282 if (!manager_->core()->service()) 284 if (!manager_->core()->service())
283 manager_->StartConnection(std::move(client), install_attributes_); 285 manager_->StartConnection(std::move(client), install_attributes_);
284 } 286 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 if (success && (success = att_signed_data.ParseFromString(signed_data))) { 329 if (success && (success = att_signed_data.ParseFromString(signed_data))) {
328 em_signed_data.set_data(att_signed_data.data()); 330 em_signed_data.set_data(att_signed_data.data());
329 em_signed_data.set_signature(att_signed_data.signature()); 331 em_signed_data.set_signature(att_signed_data.signature());
330 em_signed_data.set_extra_data_bytes(att_signed_data.data().size() - 332 em_signed_data.set_extra_data_bytes(att_signed_data.data().size() -
331 data.size()); 333 data.size());
332 } 334 }
333 callback.Run(success, em_signed_data); 335 callback.Run(success, em_signed_data);
334 } 336 }
335 337
336 } // namespace policy 338 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698