| OLD | NEW |
| 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/login/enrollment/auto_enrollment_controller.h" | 5 #include "chrome/browser/chromeos/login/enrollment/auto_enrollment_controller.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 } | 210 } |
| 211 | 211 |
| 212 std::unique_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription> | 212 std::unique_ptr<AutoEnrollmentController::ProgressCallbackList::Subscription> |
| 213 AutoEnrollmentController::RegisterProgressCallback( | 213 AutoEnrollmentController::RegisterProgressCallback( |
| 214 const ProgressCallbackList::CallbackType& callback) { | 214 const ProgressCallbackList::CallbackType& callback) { |
| 215 return progress_callbacks_.Add(callback); | 215 return progress_callbacks_.Add(callback); |
| 216 } | 216 } |
| 217 | 217 |
| 218 void AutoEnrollmentController::OnOwnershipStatusCheckDone( | 218 void AutoEnrollmentController::OnOwnershipStatusCheckDone( |
| 219 DeviceSettingsService::OwnershipStatus status) { | 219 DeviceSettingsService::OwnershipStatus status) { |
| 220 switch (status) { | 220 policy::ServerBackedStateKeysBroker* state_keys_broker = |
| 221 case DeviceSettingsService::OWNERSHIP_NONE: { | |
| 222 g_browser_process->platform_part() | 221 g_browser_process->platform_part() |
| 223 ->browser_policy_connector_chromeos() | 222 ->browser_policy_connector_chromeos() |
| 224 ->GetStateKeysBroker() | 223 ->GetStateKeysBroker(); |
| 225 ->RequestStateKeys( | 224 switch (status) { |
| 226 base::Bind(&AutoEnrollmentController::StartClient, | 225 case DeviceSettingsService::OWNERSHIP_NONE: |
| 227 client_start_weak_factory_.GetWeakPtr())); | 226 // TODO(tnagel): Prevent missing state keys broker in the first place. |
| 228 break; | 227 // https://crbug.com/703658 |
| 229 } | 228 if (!state_keys_broker) { |
| 230 case DeviceSettingsService::OWNERSHIP_TAKEN: { | 229 LOG(ERROR) << "State keys broker missing."; |
| 230 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); |
| 231 return; |
| 232 } |
| 233 state_keys_broker->RequestStateKeys( |
| 234 base::Bind(&AutoEnrollmentController::StartClient, |
| 235 client_start_weak_factory_.GetWeakPtr())); |
| 236 return; |
| 237 case DeviceSettingsService::OWNERSHIP_TAKEN: |
| 231 VLOG(1) << "Device already owned, skipping auto-enrollment check."; | 238 VLOG(1) << "Device already owned, skipping auto-enrollment check."; |
| 232 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); | 239 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); |
| 233 break; | 240 return; |
| 234 } | 241 case DeviceSettingsService::OWNERSHIP_UNKNOWN: |
| 235 case DeviceSettingsService::OWNERSHIP_UNKNOWN: { | |
| 236 LOG(ERROR) << "Ownership unknown, skipping auto-enrollment check."; | 242 LOG(ERROR) << "Ownership unknown, skipping auto-enrollment check."; |
| 237 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); | 243 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); |
| 238 break; | 244 return; |
| 239 } | |
| 240 } | 245 } |
| 241 } | 246 } |
| 242 | 247 |
| 243 void AutoEnrollmentController::StartClient( | 248 void AutoEnrollmentController::StartClient( |
| 244 const std::vector<std::string>& state_keys) { | 249 const std::vector<std::string>& state_keys) { |
| 245 if (state_keys.empty()) { | 250 if (state_keys.empty()) { |
| 246 LOG(ERROR) << "No state keys available!"; | 251 LOG(ERROR) << "No state keys available!"; |
| 247 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); | 252 UpdateState(policy::AUTO_ENROLLMENT_STATE_NO_ENROLLMENT); |
| 248 return; | 253 return; |
| 249 } | 254 } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 // keeps the connection open. | 319 // keeps the connection open. |
| 315 LOG(ERROR) << "AutoEnrollmentClient didn't complete within time limit."; | 320 LOG(ERROR) << "AutoEnrollmentClient didn't complete within time limit."; |
| 316 UpdateState(policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR); | 321 UpdateState(policy::AUTO_ENROLLMENT_STATE_CONNECTION_ERROR); |
| 317 } | 322 } |
| 318 | 323 |
| 319 // Reset state. | 324 // Reset state. |
| 320 Cancel(); | 325 Cancel(); |
| 321 } | 326 } |
| 322 | 327 |
| 323 } // namespace chromeos | 328 } // namespace chromeos |
| OLD | NEW |