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 26 matching lines...) Expand all Loading... |
37 UMA_HISTOGRAM_CUSTOM_TIMES( \ | 37 UMA_HISTOGRAM_CUSTOM_TIMES( \ |
38 (histogram_name), \ | 38 (histogram_name), \ |
39 (elapsed_timer)->Elapsed(), \ | 39 (elapsed_timer)->Elapsed(), \ |
40 base::TimeDelta::FromMilliseconds(100) /* min */, \ | 40 base::TimeDelta::FromMilliseconds(100) /* min */, \ |
41 base::TimeDelta::FromMinutes(15) /* max */, \ | 41 base::TimeDelta::FromMinutes(15) /* max */, \ |
42 100 /* bucket_count */); \ | 42 100 /* bucket_count */); \ |
43 } while (0) | 43 } while (0) |
44 | 44 |
45 namespace { | 45 namespace { |
46 | 46 |
47 const char * const kMetricEnrollmentTimeCancel = | 47 const char* const kMetricEnrollmentTimeCancel = |
48 "Enterprise.EnrollmentTime.Cancel"; | 48 "Enterprise.EnrollmentTime.Cancel"; |
49 const char * const kMetricEnrollmentTimeFailure = | 49 const char* const kMetricEnrollmentTimeFailure = |
50 "Enterprise.EnrollmentTime.Failure"; | 50 "Enterprise.EnrollmentTime.Failure"; |
51 const char * const kMetricEnrollmentTimeSuccess = | 51 const char* const kMetricEnrollmentTimeSuccess = |
52 "Enterprise.EnrollmentTime.Success"; | 52 "Enterprise.EnrollmentTime.Success"; |
53 | 53 |
| 54 const char* const kLicenseTypePerpetual = "perpetual"; |
| 55 const char* const kLicenseTypeAnnual = "annual"; |
| 56 const char* const kLicenseTypeKiosk = "kiosk"; |
| 57 |
54 // Retry policy constants. | 58 // Retry policy constants. |
55 constexpr int kInitialDelayMS = 4 * 1000; // 4 seconds | 59 constexpr int kInitialDelayMS = 4 * 1000; // 4 seconds |
56 constexpr double kMultiplyFactor = 1.5; | 60 constexpr double kMultiplyFactor = 1.5; |
57 constexpr double kJitterFactor = 0.1; // +/- 10% jitter | 61 constexpr double kJitterFactor = 0.1; // +/- 10% jitter |
58 constexpr int64_t kMaxDelayMS = 8 * 60 * 1000; // 8 minutes | 62 constexpr int64_t kMaxDelayMS = 8 * 60 * 1000; // 8 minutes |
59 | 63 |
| 64 ::policy::LicenseType GetLicenseTypeById(const std::string& id) { |
| 65 if (id == kLicenseTypePerpetual) |
| 66 return ::policy::LicenseType::PERPETUAL; |
| 67 if (id == kLicenseTypeAnnual) |
| 68 return ::policy::LicenseType::ANNUAL; |
| 69 if (id == kLicenseTypeKiosk) |
| 70 return ::policy::LicenseType::KIOSK; |
| 71 return ::policy::LicenseType::UNKNOWN; |
| 72 } |
| 73 |
| 74 std::string GetLicenseIdByType(::policy::LicenseType type) { |
| 75 switch (type) { |
| 76 case ::policy::LicenseType::PERPETUAL: |
| 77 return kLicenseTypePerpetual; |
| 78 case ::policy::LicenseType::ANNUAL: |
| 79 return kLicenseTypeAnnual; |
| 80 case ::policy::LicenseType::KIOSK: |
| 81 return kLicenseTypeKiosk; |
| 82 default: |
| 83 NOTREACHED(); |
| 84 return std::string(); |
| 85 } |
| 86 } |
| 87 |
60 } // namespace | 88 } // namespace |
61 | 89 |
62 namespace chromeos { | 90 namespace chromeos { |
63 | 91 |
64 // static | 92 // static |
65 EnrollmentScreen* EnrollmentScreen::Get(ScreenManager* manager) { | 93 EnrollmentScreen* EnrollmentScreen::Get(ScreenManager* manager) { |
66 return static_cast<EnrollmentScreen*>( | 94 return static_cast<EnrollmentScreen*>( |
67 manager->GetScreen(OobeScreen::SCREEN_OOBE_ENROLLMENT)); | 95 manager->GetScreen(OobeScreen::SCREEN_OOBE_ENROLLMENT)); |
68 } | 96 } |
69 | 97 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 enrolling_user_domain_ = gaia::ExtractDomainName(user); | 223 enrolling_user_domain_ = gaia::ExtractDomainName(user); |
196 UMA(enrollment_failed_once_ ? policy::kMetricEnrollmentRestarted | 224 UMA(enrollment_failed_once_ ? policy::kMetricEnrollmentRestarted |
197 : policy::kMetricEnrollmentStarted); | 225 : policy::kMetricEnrollmentStarted); |
198 | 226 |
199 view_->ShowEnrollmentSpinnerScreen(); | 227 view_->ShowEnrollmentSpinnerScreen(); |
200 CreateEnrollmentHelper(); | 228 CreateEnrollmentHelper(); |
201 enrollment_helper_->EnrollUsingAuthCode( | 229 enrollment_helper_->EnrollUsingAuthCode( |
202 auth_code, shark_controller_ != nullptr /* fetch_additional_token */); | 230 auth_code, shark_controller_ != nullptr /* fetch_additional_token */); |
203 } | 231 } |
204 | 232 |
205 void EnrollmentScreen::OnLicenseTypeSelected(const std::string& license_type) {} | 233 void EnrollmentScreen::OnLicenseTypeSelected(const std::string& license_type) { |
| 234 view_->ShowEnrollmentSpinnerScreen(); |
| 235 const ::policy::LicenseType license = GetLicenseTypeById(license_type); |
| 236 CHECK(license != ::policy::LicenseType::UNKNOWN) |
| 237 << "license_type = " << license_type; |
| 238 enrollment_helper_->UseLicenseType(license); |
| 239 } |
206 | 240 |
207 void EnrollmentScreen::OnRetry() { | 241 void EnrollmentScreen::OnRetry() { |
208 retry_task_.Cancel(); | 242 retry_task_.Cancel(); |
209 ProcessRetry(); | 243 ProcessRetry(); |
210 } | 244 } |
211 | 245 |
212 void EnrollmentScreen::AutomaticRetry() { | 246 void EnrollmentScreen::AutomaticRetry() { |
213 retry_backoff_->InformOfRequest(false); | 247 retry_backoff_->InformOfRequest(false); |
214 retry_task_.Reset(base::Bind(&EnrollmentScreen::ProcessRetry, | 248 retry_task_.Reset(base::Bind(&EnrollmentScreen::ProcessRetry, |
215 weak_ptr_factory_.GetWeakPtr())); | 249 weak_ptr_factory_.GetWeakPtr())); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 | 292 |
259 void EnrollmentScreen::OnAdJoined(const std::string& realm) { | 293 void EnrollmentScreen::OnAdJoined(const std::string& realm) { |
260 std::move(on_joined_callback_).Run(realm); | 294 std::move(on_joined_callback_).Run(realm); |
261 } | 295 } |
262 | 296 |
263 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { | 297 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { |
264 RecordEnrollmentErrorMetrics(); | 298 RecordEnrollmentErrorMetrics(); |
265 view_->ShowAuthError(error); | 299 view_->ShowAuthError(error); |
266 } | 300 } |
267 | 301 |
| 302 void EnrollmentScreen::OnMultipleLicensesAvailable( |
| 303 const EnrollmentLicenseMap& licenses) { |
| 304 base::DictionaryValue license_dict; |
| 305 for (const auto& it : licenses) |
| 306 license_dict.SetInteger(GetLicenseIdByType(it.first), it.second); |
| 307 view_->ShowLicenseTypeSelectionScreen(license_dict); |
| 308 } |
| 309 |
268 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) { | 310 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) { |
269 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. | 311 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. |
270 LOG(WARNING) << "Enrollment error occured: status=" << status.status() | 312 LOG(WARNING) << "Enrollment error occured: status=" << status.status() |
271 << " http status=" << status.http_status() | 313 << " http status=" << status.http_status() |
272 << " DM status=" << status.client_status(); | 314 << " DM status=" << status.client_status(); |
273 RecordEnrollmentErrorMetrics(); | 315 RecordEnrollmentErrorMetrics(); |
274 // If the DM server does not have a device pre-provisioned for attestation- | 316 // If the DM server does not have a device pre-provisioned for attestation- |
275 // based enrollment and we have a fallback authentication, show it. | 317 // based enrollment and we have a fallback authentication, show it. |
276 if (status.status() == policy::EnrollmentStatus::REGISTRATION_FAILED && | 318 if (status.status() == policy::EnrollmentStatus::REGISTRATION_FAILED && |
277 status.client_status() == policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND && | 319 status.client_status() == policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND && |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 if (elapsed_timer_) | 428 if (elapsed_timer_) |
387 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); | 429 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); |
388 } | 430 } |
389 | 431 |
390 void EnrollmentScreen::JoinDomain(OnDomainJoinedCallback on_joined_callback) { | 432 void EnrollmentScreen::JoinDomain(OnDomainJoinedCallback on_joined_callback) { |
391 on_joined_callback_ = std::move(on_joined_callback); | 433 on_joined_callback_ = std::move(on_joined_callback); |
392 view_->ShowAdJoin(); | 434 view_->ShowAdJoin(); |
393 } | 435 } |
394 | 436 |
395 } // namespace chromeos | 437 } // namespace chromeos |
OLD | NEW |