Chromium Code Reviews| 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/login/enrollment/enrollment_screen.h" | 5 #include "chrome/browser/chromeos/login/enrollment/enrollment_screen.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/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 220 | 220 |
| 221 void EnrollmentScreen::OnOtherError( | 221 void EnrollmentScreen::OnOtherError( |
| 222 EnterpriseEnrollmentHelper::OtherError error) { | 222 EnterpriseEnrollmentHelper::OtherError error) { |
| 223 OnAnyEnrollmentError(); | 223 OnAnyEnrollmentError(); |
| 224 actor_->ShowOtherError(error); | 224 actor_->ShowOtherError(error); |
| 225 } | 225 } |
| 226 | 226 |
| 227 void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) { | 227 void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) { |
| 228 if (!additional_token.empty()) | 228 if (!additional_token.empty()) |
| 229 SendEnrollmentAuthToken(additional_token); | 229 SendEnrollmentAuthToken(additional_token); |
| 230 StartupUtils::MarkDeviceRegistered( | 230 |
| 231 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess, | 231 policy::BrowserPolicyConnectorChromeOS* connector = |
|
Mattias Nissler (ping if slow)
2015/04/10 12:22:28
This logic should probably all be moved to the enr
Polina Bondarenko
2015/04/14 14:15:47
Done.
| |
| 232 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
| 233 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | |
| 234 connector->GetDeviceCloudPolicyManager(); | |
| 235 | |
| 236 policy::CloudPolicyClient* client = policy_manager->core()->client(); | |
| 237 | |
| 238 client->GetDeviceAttributeUpdatePermission( | |
| 239 enrollment_helper_->GetOAuthToken(), | |
| 240 base::Bind(&EnrollmentScreen::OnDeviceNamingPermission, | |
| 232 weak_ptr_factory_.GetWeakPtr())); | 241 weak_ptr_factory_.GetWeakPtr())); |
| 242 | |
| 233 if (remora_controller_) { | 243 if (remora_controller_) { |
|
Mattias Nissler (ping if slow)
2015/04/10 12:22:28
This should not be run if there's still a Naming p
Polina Bondarenko
2015/04/14 14:15:47
Done.
| |
| 234 remora_controller_->OnEnrollmentStatusChanged( | 244 remora_controller_->OnEnrollmentStatusChanged( |
| 235 HostPairingController::ENROLLMENT_STATUS_SUCCESS); | 245 HostPairingController::ENROLLMENT_STATUS_SUCCESS); |
| 236 } | 246 } |
| 237 } | 247 } |
| 238 | 248 |
| 249 void EnrollmentScreen::OnDeviceNaming(const std::string& asset_id, | |
| 250 const std::string& location) { | |
| 251 policy::BrowserPolicyConnectorChromeOS* connector = | |
|
Mattias Nissler (ping if slow)
2015/04/10 12:22:28
This stuff should also move to the enrollment help
Polina Bondarenko
2015/04/14 14:15:47
Done.
| |
| 252 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | |
| 253 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = | |
| 254 connector->GetDeviceCloudPolicyManager(); | |
| 255 | |
| 256 policy::CloudPolicyClient* client = policy_manager->core()->client(); | |
| 257 | |
| 258 client->UpdateDeviceAttributes(enrollment_helper_->GetOAuthToken(), asset_id, | |
| 259 location, | |
| 260 base::Bind(&EnrollmentScreen::OnDeviceNamed, | |
| 261 weak_ptr_factory_.GetWeakPtr())); | |
| 262 } | |
| 263 | |
| 264 void EnrollmentScreen::OnDeviceNamingPermission(bool status) { | |
| 265 // If user is permitted to name a device | |
| 266 // Show device naming screen | |
| 267 if (status) { | |
| 268 StartupUtils::MarkDeviceRegistered( | |
| 269 base::Bind(&EnrollmentScreen::ShowDeviceNamingScreen, | |
| 270 weak_ptr_factory_.GetWeakPtr())); | |
| 271 } else { | |
| 272 StartupUtils::MarkDeviceRegistered( | |
| 273 base::Bind(&EnrollmentScreen::ShowEnrollmentStatusOnSuccess, | |
| 274 weak_ptr_factory_.GetWeakPtr())); | |
| 275 } | |
| 276 } | |
| 277 | |
| 278 void EnrollmentScreen::OnDeviceNamed(bool status) { | |
|
Mattias Nissler (ping if slow)
2015/04/10 12:22:28
This should probably be renamed to OnDeviceAttribu
Polina Bondarenko
2015/04/14 14:15:47
Done.
| |
| 279 if (status) { | |
| 280 actor_->ShowEnrollmentStatus(policy::EnrollmentStatus::ForStatus( | |
| 281 policy::EnrollmentStatus::STATUS_SUCCESS)); | |
| 282 } else { | |
| 283 actor_->ShowEnrollmentStatus(policy::EnrollmentStatus::ForStatus( | |
| 284 policy::EnrollmentStatus::STATUS_DEVICE_NAMING_FAILED)); | |
| 285 } | |
| 286 } | |
| 287 void EnrollmentScreen::ShowDeviceNamingScreen() { | |
|
Mattias Nissler (ping if slow)
2015/04/10 12:22:28
nit: Rename to ShowAttributePromptScreen?
Polina Bondarenko
2015/04/14 14:15:47
Done.
| |
| 288 actor_->ShowDeviceNamingScreen(); | |
| 289 } | |
| 290 | |
| 239 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { | 291 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { |
| 240 // TODO(achuith, zork): Extract and send domain. | 292 // TODO(achuith, zork): Extract and send domain. |
| 241 DCHECK(shark_controller_); | 293 DCHECK(shark_controller_); |
| 242 shark_controller_->OnAuthenticationDone("", token); | 294 shark_controller_->OnAuthenticationDone("", token); |
| 243 } | 295 } |
| 244 | 296 |
| 245 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() { | 297 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() { |
| 246 StartupUtils::MarkOobeCompleted(); | 298 StartupUtils::MarkOobeCompleted(); |
| 247 if (elapsed_timer_) | 299 if (elapsed_timer_) |
| 248 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_); | 300 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 263 enrollment_failed_once_ = true; | 315 enrollment_failed_once_ = true; |
| 264 if (elapsed_timer_) | 316 if (elapsed_timer_) |
| 265 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); | 317 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); |
| 266 if (remora_controller_) { | 318 if (remora_controller_) { |
| 267 remora_controller_->OnEnrollmentStatusChanged( | 319 remora_controller_->OnEnrollmentStatusChanged( |
| 268 HostPairingController::ENROLLMENT_STATUS_FAILURE); | 320 HostPairingController::ENROLLMENT_STATUS_FAILURE); |
| 269 } | 321 } |
| 270 } | 322 } |
| 271 | 323 |
| 272 } // namespace chromeos | 324 } // namespace chromeos |
| OLD | NEW |