| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 device_mode_(DEVICE_MODE_NOT_SET), | 69 device_mode_(DEVICE_MODE_NOT_SET), |
| 70 enrollment_step_(STEP_PENDING), | 70 enrollment_step_(STEP_PENDING), |
| 71 lockbox_init_duration_(0), | 71 lockbox_init_duration_(0), |
| 72 weak_ptr_factory_(this) { | 72 weak_ptr_factory_(this) { |
| 73 CHECK(!client_->is_registered()); | 73 CHECK(!client_->is_registered()); |
| 74 CHECK_EQ(DM_STATUS_SUCCESS, client_->status()); | 74 CHECK_EQ(DM_STATUS_SUCCESS, client_->status()); |
| 75 CHECK(management_mode_ == em::PolicyData::ENTERPRISE_MANAGED || | 75 CHECK(management_mode_ == em::PolicyData::ENTERPRISE_MANAGED || |
| 76 management_mode_ == em::PolicyData::CONSUMER_MANAGED); | 76 management_mode_ == em::PolicyData::CONSUMER_MANAGED); |
| 77 store_->AddObserver(this); | 77 store_->AddObserver(this); |
| 78 client_->AddObserver(this); | 78 client_->AddObserver(this); |
| 79 client_->AddNamespaceToFetch(PolicyNamespaceKey( | 79 client_->AddPolicyTypeToFetch(dm_protocol::kChromeDevicePolicyType, ""); |
| 80 dm_protocol::kChromeDevicePolicyType, std::string())); | |
| 81 } | 80 } |
| 82 | 81 |
| 83 EnrollmentHandlerChromeOS::~EnrollmentHandlerChromeOS() { | 82 EnrollmentHandlerChromeOS::~EnrollmentHandlerChromeOS() { |
| 84 Stop(); | 83 Stop(); |
| 85 store_->RemoveObserver(this); | 84 store_->RemoveObserver(this); |
| 86 } | 85 } |
| 87 | 86 |
| 88 void EnrollmentHandlerChromeOS::StartEnrollment() { | 87 void EnrollmentHandlerChromeOS::StartEnrollment() { |
| 89 CHECK_EQ(STEP_PENDING, enrollment_step_); | 88 CHECK_EQ(STEP_PENDING, enrollment_step_); |
| 90 enrollment_step_ = STEP_STATE_KEYS; | 89 enrollment_step_ = STEP_STATE_KEYS; |
| 91 state_keys_broker_->RequestStateKeys( | 90 state_keys_broker_->RequestStateKeys( |
| 92 base::Bind(&EnrollmentHandlerChromeOS::HandleStateKeysResult, | 91 base::Bind(&EnrollmentHandlerChromeOS::HandleStateKeysResult, |
| 93 weak_ptr_factory_.GetWeakPtr())); | 92 weak_ptr_factory_.GetWeakPtr())); |
| 94 } | 93 } |
| 95 | 94 |
| 96 scoped_ptr<CloudPolicyClient> EnrollmentHandlerChromeOS::ReleaseClient() { | 95 scoped_ptr<CloudPolicyClient> EnrollmentHandlerChromeOS::ReleaseClient() { |
| 97 Stop(); | 96 Stop(); |
| 98 return client_.Pass(); | 97 return client_.Pass(); |
| 99 } | 98 } |
| 100 | 99 |
| 101 void EnrollmentHandlerChromeOS::OnPolicyFetched(CloudPolicyClient* client) { | 100 void EnrollmentHandlerChromeOS::OnPolicyFetched(CloudPolicyClient* client) { |
| 102 DCHECK_EQ(client_.get(), client); | 101 DCHECK_EQ(client_.get(), client); |
| 103 CHECK_EQ(STEP_POLICY_FETCH, enrollment_step_); | 102 CHECK_EQ(STEP_POLICY_FETCH, enrollment_step_); |
| 104 | 103 |
| 105 enrollment_step_ = STEP_VALIDATION; | 104 enrollment_step_ = STEP_VALIDATION; |
| 106 | 105 |
| 107 // Validate the policy. | 106 // Validate the policy. |
| 108 const em::PolicyFetchResponse* policy = client_->GetPolicyFor( | 107 const em::PolicyFetchResponse* policy = |
| 109 PolicyNamespaceKey(dm_protocol::kChromeDevicePolicyType, std::string())); | 108 client_->GetPolicyFor(dm_protocol::kChromeDevicePolicyType, ""); |
| 110 if (!policy) { | 109 if (!policy) { |
| 111 ReportResult(EnrollmentStatus::ForFetchError( | 110 ReportResult(EnrollmentStatus::ForFetchError( |
| 112 DM_STATUS_RESPONSE_DECODING_ERROR)); | 111 DM_STATUS_RESPONSE_DECODING_ERROR)); |
| 113 return; | 112 return; |
| 114 } | 113 } |
| 115 | 114 |
| 116 scoped_ptr<DeviceCloudPolicyValidator> validator( | 115 scoped_ptr<DeviceCloudPolicyValidator> validator( |
| 117 DeviceCloudPolicyValidator::Create( | 116 DeviceCloudPolicyValidator::Create( |
| 118 scoped_ptr<em::PolicyFetchResponse>( | 117 scoped_ptr<em::PolicyFetchResponse>( |
| 119 new em::PolicyFetchResponse(*policy)), | 118 new em::PolicyFetchResponse(*policy)), |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 << ", validation: " << status.validation_status() | 453 << ", validation: " << status.validation_status() |
| 455 << ", store: " << status.store_status() | 454 << ", store: " << status.store_status() |
| 456 << ", lock: " << status.lock_status(); | 455 << ", lock: " << status.lock_status(); |
| 457 } | 456 } |
| 458 | 457 |
| 459 if (!callback.is_null()) | 458 if (!callback.is_null()) |
| 460 callback.Run(status); | 459 callback.Run(status); |
| 461 } | 460 } |
| 462 | 461 |
| 463 } // namespace policy | 462 } // namespace policy |
| OLD | NEW |