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

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

Issue 2403053003: Remove unused email from install attributes and add support for AD. (Closed)
Patch Set: Address Maksim's comments. Created 4 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/enrollment_handler_chromeos.h" 5 #include "chrome/browser/chromeos/policy/enrollment_handler_chromeos.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/threading/thread_task_runner_handle.h" 13 #include "base/threading/thread_task_runner_handle.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" 15 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h"
16 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" 16 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
17 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h" 17 #include "chrome/browser/chromeos/policy/device_cloud_policy_store_chromeos.h"
18 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h" 18 #include "chrome/browser/chromeos/policy/enrollment_status_chromeos.h"
19 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h" 19 #include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
20 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h" 20 #include "chrome/browser/chromeos/policy/server_backed_state_keys_broker.h"
21 #include "chrome/browser/chromeos/profiles/profile_helper.h" 21 #include "chrome/browser/chromeos/profiles/profile_helper.h"
22 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h" 22 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
23 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " 23 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h "
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chromeos/attestation/attestation_flow.h" 25 #include "chromeos/attestation/attestation_flow.h"
26 #include "google_apis/gaia/gaia_auth_util.h"
26 #include "google_apis/gaia/gaia_urls.h" 27 #include "google_apis/gaia/gaia_urls.h"
27 #include "net/http/http_status_code.h" 28 #include "net/http/http_status_code.h"
28 29
29 namespace em = enterprise_management; 30 namespace em = enterprise_management;
30 31
31 namespace policy { 32 namespace policy {
32 33
33 namespace { 34 namespace {
34 35
35 // Retry for InstallAttrs initialization every 500ms. 36 // Retry for InstallAttrs initialization every 500ms.
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 pem_certificate_chain, client_id_, requisition_, current_state_key_); 310 pem_certificate_chain, client_id_, requisition_, current_state_key_);
310 else 311 else
311 ReportResult(EnrollmentStatus::ForStatus( 312 ReportResult(EnrollmentStatus::ForStatus(
312 EnrollmentStatus::STATUS_REGISTRATION_CERTIFICATE_FETCH_FAILED)); 313 EnrollmentStatus::STATUS_REGISTRATION_CERTIFICATE_FETCH_FAILED));
313 } 314 }
314 315
315 void EnrollmentHandlerChromeOS::HandlePolicyValidationResult( 316 void EnrollmentHandlerChromeOS::HandlePolicyValidationResult(
316 DeviceCloudPolicyValidator* validator) { 317 DeviceCloudPolicyValidator* validator) {
317 CHECK_EQ(STEP_VALIDATION, enrollment_step_); 318 CHECK_EQ(STEP_VALIDATION, enrollment_step_);
318 if (validator->success()) { 319 if (validator->success()) {
320 std::string username = validator->policy_data()->username();
321 domain_ = gaia::ExtractDomainName(gaia::CanonicalizeEmail(username));
322 device_id_ = validator->policy_data()->device_id();
319 policy_ = std::move(validator->policy()); 323 policy_ = std::move(validator->policy());
320 username_ = validator->policy_data()->username();
321 device_id_ = validator->policy_data()->device_id();
322 request_token_ = validator->policy_data()->request_token(); 324 request_token_ = validator->policy_data()->request_token();
323 enrollment_step_ = STEP_ROBOT_AUTH_FETCH; 325 enrollment_step_ = STEP_ROBOT_AUTH_FETCH;
324 client_->FetchRobotAuthCodes(auth_token_); 326 client_->FetchRobotAuthCodes(auth_token_);
325 } else { 327 } else {
326 ReportResult(EnrollmentStatus::ForValidationError(validator->status())); 328 ReportResult(EnrollmentStatus::ForValidationError(validator->status()));
327 } 329 }
328 } 330 }
329 331
330 void EnrollmentHandlerChromeOS::OnRobotAuthCodesFetched( 332 void EnrollmentHandlerChromeOS::OnRobotAuthCodesFetched(
331 CloudPolicyClient* client) { 333 CloudPolicyClient* client) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 ReportResult( 400 ReportResult(
399 EnrollmentStatus::ForRobotRefreshFetchError(response_code)); 401 EnrollmentStatus::ForRobotRefreshFetchError(response_code));
400 } 402 }
401 403
402 void EnrollmentHandlerChromeOS::StartLockDevice() { 404 void EnrollmentHandlerChromeOS::StartLockDevice() {
403 CHECK_EQ(STEP_LOCK_DEVICE, enrollment_step_); 405 CHECK_EQ(STEP_LOCK_DEVICE, enrollment_step_);
404 // Since this method is also called directly. 406 // Since this method is also called directly.
405 weak_ptr_factory_.InvalidateWeakPtrs(); 407 weak_ptr_factory_.InvalidateWeakPtrs();
406 408
407 install_attributes_->LockDevice( 409 install_attributes_->LockDevice(
408 username_, device_mode_, device_id_, 410 device_mode_, domain_, std::string() /* realm */, device_id_,
409 base::Bind(&EnrollmentHandlerChromeOS::HandleLockDeviceResult, 411 base::Bind(&EnrollmentHandlerChromeOS::HandleLockDeviceResult,
410 weak_ptr_factory_.GetWeakPtr())); 412 weak_ptr_factory_.GetWeakPtr()));
411 } 413 }
412 414
413 void EnrollmentHandlerChromeOS::HandleSetManagementSettingsDone(bool success) { 415 void EnrollmentHandlerChromeOS::HandleSetManagementSettingsDone(bool success) {
414 CHECK_EQ(STEP_STORE_TOKEN_AND_ID, enrollment_step_); 416 CHECK_EQ(STEP_STORE_TOKEN_AND_ID, enrollment_step_);
415 if (!success) { 417 if (!success) {
416 ReportResult(EnrollmentStatus::ForStatus( 418 ReportResult(EnrollmentStatus::ForStatus(
417 EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED)); 419 EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED));
418 return; 420 return;
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 << ", validation: " << status.validation_status() 506 << ", validation: " << status.validation_status()
505 << ", store: " << status.store_status() 507 << ", store: " << status.store_status()
506 << ", lock: " << status.lock_status(); 508 << ", lock: " << status.lock_status();
507 } 509 }
508 510
509 if (!callback.is_null()) 511 if (!callback.is_null())
510 callback.Run(status); 512 callback.Run(status);
511 } 513 }
512 514
513 } // namespace policy 515 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/policy/enrollment_handler_chromeos.h ('k') | chrome/browser/chromeos/settings/install_attributes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698