OLD | NEW |
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" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 | 64 |
65 NOTREACHED() << "Bad enrollment mode: " << mode; | 65 NOTREACHED() << "Bad enrollment mode: " << mode; |
66 return em::DeviceRegisterRequest::FLAVOR_ENROLLMENT_MANUAL; | 66 return em::DeviceRegisterRequest::FLAVOR_ENROLLMENT_MANUAL; |
67 } | 67 } |
68 | 68 |
69 } // namespace | 69 } // namespace |
70 | 70 |
71 EnrollmentHandlerChromeOS::EnrollmentHandlerChromeOS( | 71 EnrollmentHandlerChromeOS::EnrollmentHandlerChromeOS( |
72 DeviceCloudPolicyStoreChromeOS* store, | 72 DeviceCloudPolicyStoreChromeOS* store, |
73 EnterpriseInstallAttributes* install_attributes, | 73 chromeos::InstallAttributes* install_attributes, |
74 ServerBackedStateKeysBroker* state_keys_broker, | 74 ServerBackedStateKeysBroker* state_keys_broker, |
75 chromeos::attestation::AttestationFlow* attestation_flow, | 75 chromeos::attestation::AttestationFlow* attestation_flow, |
76 std::unique_ptr<CloudPolicyClient> client, | 76 std::unique_ptr<CloudPolicyClient> client, |
77 scoped_refptr<base::SequencedTaskRunner> background_task_runner, | 77 scoped_refptr<base::SequencedTaskRunner> background_task_runner, |
78 const EnrollmentConfig& enrollment_config, | 78 const EnrollmentConfig& enrollment_config, |
79 const std::string& auth_token, | 79 const std::string& auth_token, |
80 const std::string& client_id, | 80 const std::string& client_id, |
81 const std::string& requisition, | 81 const std::string& requisition, |
82 const EnrollmentCallback& completion_callback) | 82 const EnrollmentCallback& completion_callback) |
83 : store_(store), | 83 : store_(store), |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
401 if (!success) { | 401 if (!success) { |
402 ReportResult(EnrollmentStatus::ForStatus( | 402 ReportResult(EnrollmentStatus::ForStatus( |
403 EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED)); | 403 EnrollmentStatus::STATUS_STORE_TOKEN_AND_ID_FAILED)); |
404 return; | 404 return; |
405 } | 405 } |
406 | 406 |
407 StartStoreRobotAuth(); | 407 StartStoreRobotAuth(); |
408 } | 408 } |
409 | 409 |
410 void EnrollmentHandlerChromeOS::HandleLockDeviceResult( | 410 void EnrollmentHandlerChromeOS::HandleLockDeviceResult( |
411 EnterpriseInstallAttributes::LockResult lock_result) { | 411 chromeos::InstallAttributes::LockResult lock_result) { |
412 CHECK_EQ(STEP_LOCK_DEVICE, enrollment_step_); | 412 CHECK_EQ(STEP_LOCK_DEVICE, enrollment_step_); |
413 switch (lock_result) { | 413 switch (lock_result) { |
414 case EnterpriseInstallAttributes::LOCK_SUCCESS: | 414 case chromeos::InstallAttributes::LOCK_SUCCESS: |
415 StartStoreRobotAuth(); | 415 StartStoreRobotAuth(); |
416 break; | 416 break; |
417 case EnterpriseInstallAttributes::LOCK_NOT_READY: | 417 case chromeos::InstallAttributes::LOCK_NOT_READY: |
418 // We wait up to |kLockRetryTimeoutMs| milliseconds and if it hasn't | 418 // We wait up to |kLockRetryTimeoutMs| milliseconds and if it hasn't |
419 // succeeded by then show an error to the user and stop the enrollment. | 419 // succeeded by then show an error to the user and stop the enrollment. |
420 if (lockbox_init_duration_ < kLockRetryTimeoutMs) { | 420 if (lockbox_init_duration_ < kLockRetryTimeoutMs) { |
421 // InstallAttributes not ready yet, retry later. | 421 // InstallAttributes not ready yet, retry later. |
422 LOG(WARNING) << "Install Attributes not ready yet will retry in " | 422 LOG(WARNING) << "Install Attributes not ready yet will retry in " |
423 << kLockRetryIntervalMs << "ms."; | 423 << kLockRetryIntervalMs << "ms."; |
424 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 424 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
425 FROM_HERE, base::Bind(&EnrollmentHandlerChromeOS::StartLockDevice, | 425 FROM_HERE, base::Bind(&EnrollmentHandlerChromeOS::StartLockDevice, |
426 weak_ptr_factory_.GetWeakPtr()), | 426 weak_ptr_factory_.GetWeakPtr()), |
427 base::TimeDelta::FromMilliseconds(kLockRetryIntervalMs)); | 427 base::TimeDelta::FromMilliseconds(kLockRetryIntervalMs)); |
428 lockbox_init_duration_ += kLockRetryIntervalMs; | 428 lockbox_init_duration_ += kLockRetryIntervalMs; |
429 } else { | 429 } else { |
430 HandleLockDeviceResult(EnterpriseInstallAttributes::LOCK_TIMEOUT); | 430 HandleLockDeviceResult(chromeos::InstallAttributes::LOCK_TIMEOUT); |
431 } | 431 } |
432 break; | 432 break; |
433 case EnterpriseInstallAttributes::LOCK_TIMEOUT: | 433 case chromeos::InstallAttributes::LOCK_TIMEOUT: |
434 case EnterpriseInstallAttributes::LOCK_BACKEND_INVALID: | 434 case chromeos::InstallAttributes::LOCK_BACKEND_INVALID: |
435 case EnterpriseInstallAttributes::LOCK_ALREADY_LOCKED: | 435 case chromeos::InstallAttributes::LOCK_ALREADY_LOCKED: |
436 case EnterpriseInstallAttributes::LOCK_SET_ERROR: | 436 case chromeos::InstallAttributes::LOCK_SET_ERROR: |
437 case EnterpriseInstallAttributes::LOCK_FINALIZE_ERROR: | 437 case chromeos::InstallAttributes::LOCK_FINALIZE_ERROR: |
438 case EnterpriseInstallAttributes::LOCK_READBACK_ERROR: | 438 case chromeos::InstallAttributes::LOCK_READBACK_ERROR: |
439 case EnterpriseInstallAttributes::LOCK_WRONG_DOMAIN: | 439 case chromeos::InstallAttributes::LOCK_WRONG_DOMAIN: |
440 case EnterpriseInstallAttributes::LOCK_WRONG_MODE: | 440 case chromeos::InstallAttributes::LOCK_WRONG_MODE: |
441 ReportResult(EnrollmentStatus::ForLockError(lock_result)); | 441 ReportResult(EnrollmentStatus::ForLockError(lock_result)); |
442 break; | 442 break; |
443 } | 443 } |
444 } | 444 } |
445 | 445 |
446 void EnrollmentHandlerChromeOS::StartStoreRobotAuth() { | 446 void EnrollmentHandlerChromeOS::StartStoreRobotAuth() { |
447 enrollment_step_ = STEP_STORE_ROBOT_AUTH; | 447 enrollment_step_ = STEP_STORE_ROBOT_AUTH; |
448 | 448 |
449 // Don't store the token if robot auth was skipped. | 449 // Don't store the token if robot auth was skipped. |
450 if (skip_robot_auth_) { | 450 if (skip_robot_auth_) { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 << ", validation: " << status.validation_status() | 490 << ", validation: " << status.validation_status() |
491 << ", store: " << status.store_status() | 491 << ", store: " << status.store_status() |
492 << ", lock: " << status.lock_status(); | 492 << ", lock: " << status.lock_status(); |
493 } | 493 } |
494 | 494 |
495 if (!callback.is_null()) | 495 if (!callback.is_null()) |
496 callback.Run(status); | 496 callback.Run(status); |
497 } | 497 } |
498 | 498 |
499 } // namespace policy | 499 } // namespace policy |
OLD | NEW |