Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: chrome/browser/chromeos/login/enrollment/enrollment_screen.cc

Issue 2977033002: Mixed Licenses Enrollment (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 =
emaxx 2017/07/21 12:57:29 nit: While you're here - please remove the space b
Denis Kuznetsov (DE-MUC) 2017/07/25 21:51:05 Done.
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 const std::string GetLicenseIdByType(::policy::LicenseType type) {
emaxx 2017/07/21 12:57:29 nit: s/const // (There's no benefit from making th
Denis Kuznetsov (DE-MUC) 2017/07/25 21:51:05 Done.
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
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 auto license = GetLicenseTypeById(license_type);
236 CHECK(license != ::policy::LicenseType::UNKNOWN);
237 enrollment_helper_->UseLicenseType(license);
238 }
206 239
207 void EnrollmentScreen::OnRetry() { 240 void EnrollmentScreen::OnRetry() {
208 retry_task_.Cancel(); 241 retry_task_.Cancel();
209 ProcessRetry(); 242 ProcessRetry();
210 } 243 }
211 244
212 void EnrollmentScreen::AutomaticRetry() { 245 void EnrollmentScreen::AutomaticRetry() {
213 retry_backoff_->InformOfRequest(false); 246 retry_backoff_->InformOfRequest(false);
214 retry_task_.Reset(base::Bind(&EnrollmentScreen::ProcessRetry, 247 retry_task_.Reset(base::Bind(&EnrollmentScreen::ProcessRetry,
215 weak_ptr_factory_.GetWeakPtr())); 248 weak_ptr_factory_.GetWeakPtr()));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 291
259 void EnrollmentScreen::OnAdJoined(const std::string& realm) { 292 void EnrollmentScreen::OnAdJoined(const std::string& realm) {
260 std::move(on_joined_callback_).Run(realm); 293 std::move(on_joined_callback_).Run(realm);
261 } 294 }
262 295
263 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { 296 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) {
264 RecordEnrollmentErrorMetrics(); 297 RecordEnrollmentErrorMetrics();
265 view_->ShowAuthError(error); 298 view_->ShowAuthError(error);
266 } 299 }
267 300
301 void EnrollmentScreen::OnMultipleLicensesAvailable(
302 const EnrollmentLicenseMap& licenses) {
303 base::DictionaryValue license_dict;
304 for (auto it = licenses.begin(); it != licenses.end(); it++) {
emaxx 2017/07/21 12:57:29 nit: Replace with range-based for?
Denis Kuznetsov (DE-MUC) 2017/07/25 21:51:05 Done.
305 license_dict.SetInteger(GetLicenseIdByType(it->first), it->second);
306 }
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698