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

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

Issue 2700303002: cros: Unify oobe View/Actor naming to just View. (Closed)
Patch Set: Rebase Created 3 years, 10 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 namespace chromeos { 68 namespace chromeos {
69 69
70 // static 70 // static
71 EnrollmentScreen* EnrollmentScreen::Get(ScreenManager* manager) { 71 EnrollmentScreen* EnrollmentScreen::Get(ScreenManager* manager) {
72 return static_cast<EnrollmentScreen*>( 72 return static_cast<EnrollmentScreen*>(
73 manager->GetScreen(OobeScreen::SCREEN_OOBE_ENROLLMENT)); 73 manager->GetScreen(OobeScreen::SCREEN_OOBE_ENROLLMENT));
74 } 74 }
75 75
76 EnrollmentScreen::EnrollmentScreen(BaseScreenDelegate* base_screen_delegate, 76 EnrollmentScreen::EnrollmentScreen(BaseScreenDelegate* base_screen_delegate,
77 EnrollmentScreenActor* actor) 77 EnrollmentScreenView* view)
78 : BaseScreen(base_screen_delegate, OobeScreen::SCREEN_OOBE_ENROLLMENT), 78 : BaseScreen(base_screen_delegate, OobeScreen::SCREEN_OOBE_ENROLLMENT),
79 actor_(actor), 79 view_(view),
80 weak_ptr_factory_(this) { 80 weak_ptr_factory_(this) {
81 retry_policy_.num_errors_to_ignore = 0; 81 retry_policy_.num_errors_to_ignore = 0;
82 retry_policy_.initial_delay_ms = kInitialDelayMS; 82 retry_policy_.initial_delay_ms = kInitialDelayMS;
83 retry_policy_.multiply_factor = kMultiplyFactor; 83 retry_policy_.multiply_factor = kMultiplyFactor;
84 retry_policy_.jitter_factor = kJitterFactor; 84 retry_policy_.jitter_factor = kJitterFactor;
85 retry_policy_.maximum_backoff_ms = kMaxDelayMS; 85 retry_policy_.maximum_backoff_ms = kMaxDelayMS;
86 retry_policy_.entry_lifetime_ms = -1; 86 retry_policy_.entry_lifetime_ms = -1;
87 retry_policy_.always_use_initial_delay = true; 87 retry_policy_.always_use_initial_delay = true;
88 retry_backoff_.reset(new net::BackoffEntry(&retry_policy_)); 88 retry_backoff_.reset(new net::BackoffEntry(&retry_policy_));
89 } 89 }
(...skipping 29 matching lines...) Expand all
119 SetConfig(); 119 SetConfig();
120 } 120 }
121 121
122 void EnrollmentScreen::SetConfig() { 122 void EnrollmentScreen::SetConfig() {
123 config_ = enrollment_config_; 123 config_ = enrollment_config_;
124 if (current_auth_ == AUTH_ATTESTATION) { 124 if (current_auth_ == AUTH_ATTESTATION) {
125 config_.mode = enrollment_config_.is_attestation_forced() 125 config_.mode = enrollment_config_.is_attestation_forced()
126 ? policy::EnrollmentConfig::MODE_ATTESTATION_FORCED 126 ? policy::EnrollmentConfig::MODE_ATTESTATION_FORCED
127 : policy::EnrollmentConfig::MODE_ATTESTATION; 127 : policy::EnrollmentConfig::MODE_ATTESTATION;
128 } 128 }
129 actor_->SetParameters(this, config_); 129 view_->SetParameters(this, config_);
130 enrollment_helper_ = nullptr; 130 enrollment_helper_ = nullptr;
131 } 131 }
132 132
133 bool EnrollmentScreen::AdvanceToNextAuth() { 133 bool EnrollmentScreen::AdvanceToNextAuth() {
134 if (current_auth_ != last_auth_ && current_auth_ == AUTH_ATTESTATION) { 134 if (current_auth_ != last_auth_ && current_auth_ == AUTH_ATTESTATION) {
135 current_auth_ = AUTH_OAUTH; 135 current_auth_ = AUTH_OAUTH;
136 SetConfig(); 136 SetConfig();
137 return true; 137 return true;
138 } 138 }
139 return false; 139 return false;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 break; 175 break;
176 } 176 }
177 } 177 }
178 178
179 void EnrollmentScreen::ShowInteractiveScreen() { 179 void EnrollmentScreen::ShowInteractiveScreen() {
180 ClearAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen, 180 ClearAuth(base::Bind(&EnrollmentScreen::ShowSigninScreen,
181 weak_ptr_factory_.GetWeakPtr())); 181 weak_ptr_factory_.GetWeakPtr()));
182 } 182 }
183 183
184 void EnrollmentScreen::Hide() { 184 void EnrollmentScreen::Hide() {
185 actor_->Hide(); 185 view_->Hide();
186 weak_ptr_factory_.InvalidateWeakPtrs(); 186 weak_ptr_factory_.InvalidateWeakPtrs();
187 } 187 }
188 188
189 void EnrollmentScreen::AuthenticateUsingAttestation() { 189 void EnrollmentScreen::AuthenticateUsingAttestation() {
190 VLOG(1) << "Authenticating using attestation."; 190 VLOG(1) << "Authenticating using attestation.";
191 elapsed_timer_.reset(new base::ElapsedTimer()); 191 elapsed_timer_.reset(new base::ElapsedTimer());
192 actor_->Show(); 192 view_->Show();
193 CreateEnrollmentHelper(); 193 CreateEnrollmentHelper();
194 enrollment_helper_->EnrollUsingAttestation(); 194 enrollment_helper_->EnrollUsingAttestation();
195 } 195 }
196 196
197 void EnrollmentScreen::OnLoginDone(const std::string& user, 197 void EnrollmentScreen::OnLoginDone(const std::string& user,
198 const std::string& auth_code) { 198 const std::string& auth_code) {
199 LOG_IF(ERROR, auth_code.empty()) << "Auth code is empty."; 199 LOG_IF(ERROR, auth_code.empty()) << "Auth code is empty.";
200 elapsed_timer_.reset(new base::ElapsedTimer()); 200 elapsed_timer_.reset(new base::ElapsedTimer());
201 enrolling_user_domain_ = gaia::ExtractDomainName(user); 201 enrolling_user_domain_ = gaia::ExtractDomainName(user);
202 UMA(enrollment_failed_once_ ? policy::kMetricEnrollmentRestarted 202 UMA(enrollment_failed_once_ ? policy::kMetricEnrollmentRestarted
203 : policy::kMetricEnrollmentStarted); 203 : policy::kMetricEnrollmentStarted);
204 204
205 actor_->ShowEnrollmentSpinnerScreen(); 205 view_->ShowEnrollmentSpinnerScreen();
206 CreateEnrollmentHelper(); 206 CreateEnrollmentHelper();
207 enrollment_helper_->EnrollUsingAuthCode( 207 enrollment_helper_->EnrollUsingAuthCode(
208 auth_code, shark_controller_ != nullptr /* fetch_additional_token */); 208 auth_code, shark_controller_ != nullptr /* fetch_additional_token */);
209 } 209 }
210 210
211 void EnrollmentScreen::OnRetry() { 211 void EnrollmentScreen::OnRetry() {
212 retry_task_.Cancel(); 212 retry_task_.Cancel();
213 ProcessRetry(); 213 ProcessRetry();
214 } 214 }
215 215
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 ClearAuth(base::Bind(&EnrollmentScreen::Finish, base::Unretained(this), 249 ClearAuth(base::Bind(&EnrollmentScreen::Finish, base::Unretained(this),
250 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED)); 250 BaseScreenDelegate::ENTERPRISE_ENROLLMENT_COMPLETED));
251 } 251 }
252 252
253 void EnrollmentScreen::OnAdJoined(const std::string& realm) { 253 void EnrollmentScreen::OnAdJoined(const std::string& realm) {
254 std::move(on_joined_callback_).Run(realm); 254 std::move(on_joined_callback_).Run(realm);
255 } 255 }
256 256
257 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) { 257 void EnrollmentScreen::OnAuthError(const GoogleServiceAuthError& error) {
258 RecordEnrollmentErrorMetrics(); 258 RecordEnrollmentErrorMetrics();
259 actor_->ShowAuthError(error); 259 view_->ShowAuthError(error);
260 } 260 }
261 261
262 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) { 262 void EnrollmentScreen::OnEnrollmentError(policy::EnrollmentStatus status) {
263 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. 263 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed.
264 LOG(WARNING) << "Enrollment error occured: status=" << status.status() 264 LOG(WARNING) << "Enrollment error occured: status=" << status.status()
265 << " http status=" << status.http_status() 265 << " http status=" << status.http_status()
266 << " DM status=" << status.client_status(); 266 << " DM status=" << status.client_status();
267 RecordEnrollmentErrorMetrics(); 267 RecordEnrollmentErrorMetrics();
268 // If the DM server does not have a device pre-provisioned for attestation- 268 // If the DM server does not have a device pre-provisioned for attestation-
269 // based enrollment and we have a fallback authentication, show it. 269 // based enrollment and we have a fallback authentication, show it.
270 if (status.status() == policy::EnrollmentStatus::REGISTRATION_FAILED && 270 if (status.status() == policy::EnrollmentStatus::REGISTRATION_FAILED &&
271 status.client_status() == policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND && 271 status.client_status() == policy::DM_STATUS_SERVICE_DEVICE_NOT_FOUND &&
272 current_auth_ == AUTH_ATTESTATION && AdvanceToNextAuth()) { 272 current_auth_ == AUTH_ATTESTATION && AdvanceToNextAuth()) {
273 Show(); 273 Show();
274 } else { 274 } else {
275 actor_->ShowEnrollmentStatus(status); 275 view_->ShowEnrollmentStatus(status);
276 if (UsingHandsOffEnrollment()) 276 if (UsingHandsOffEnrollment())
277 AutomaticRetry(); 277 AutomaticRetry();
278 } 278 }
279 } 279 }
280 280
281 void EnrollmentScreen::OnOtherError( 281 void EnrollmentScreen::OnOtherError(
282 EnterpriseEnrollmentHelper::OtherError error) { 282 EnterpriseEnrollmentHelper::OtherError error) {
283 RecordEnrollmentErrorMetrics(); 283 RecordEnrollmentErrorMetrics();
284 actor_->ShowOtherError(error); 284 view_->ShowOtherError(error);
285 if (UsingHandsOffEnrollment()) 285 if (UsingHandsOffEnrollment())
286 AutomaticRetry(); 286 AutomaticRetry();
287 } 287 }
288 288
289 void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) { 289 void EnrollmentScreen::OnDeviceEnrolled(const std::string& additional_token) {
290 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed. 290 // TODO(pbond): remove this LOG once http://crbug.com/586961 is fixed.
291 LOG(WARNING) << "Device is successfully enrolled."; 291 LOG(WARNING) << "Device is successfully enrolled.";
292 if (!additional_token.empty()) 292 if (!additional_token.empty())
293 SendEnrollmentAuthToken(additional_token); 293 SendEnrollmentAuthToken(additional_token);
294 294
(...skipping 23 matching lines...) Expand all
318 } 318 }
319 319
320 } 320 }
321 321
322 void EnrollmentScreen::OnDeviceAttributeUploadCompleted(bool success) { 322 void EnrollmentScreen::OnDeviceAttributeUploadCompleted(bool success) {
323 if (success) { 323 if (success) {
324 // If the device attributes have been successfully uploaded, fetch policy. 324 // If the device attributes have been successfully uploaded, fetch policy.
325 policy::BrowserPolicyConnectorChromeOS* connector = 325 policy::BrowserPolicyConnectorChromeOS* connector =
326 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 326 g_browser_process->platform_part()->browser_policy_connector_chromeos();
327 connector->GetDeviceCloudPolicyManager()->core()->RefreshSoon(); 327 connector->GetDeviceCloudPolicyManager()->core()->RefreshSoon();
328 actor_->ShowEnrollmentStatus( 328 view_->ShowEnrollmentStatus(
329 policy::EnrollmentStatus::ForStatus(policy::EnrollmentStatus::SUCCESS)); 329 policy::EnrollmentStatus::ForStatus(policy::EnrollmentStatus::SUCCESS));
330 } else { 330 } else {
331 actor_->ShowEnrollmentStatus(policy::EnrollmentStatus::ForStatus( 331 view_->ShowEnrollmentStatus(policy::EnrollmentStatus::ForStatus(
332 policy::EnrollmentStatus::ATTRIBUTE_UPDATE_FAILED)); 332 policy::EnrollmentStatus::ATTRIBUTE_UPDATE_FAILED));
333 } 333 }
334 } 334 }
335 335
336 void EnrollmentScreen::ShowAttributePromptScreen() { 336 void EnrollmentScreen::ShowAttributePromptScreen() {
337 policy::BrowserPolicyConnectorChromeOS* connector = 337 policy::BrowserPolicyConnectorChromeOS* connector =
338 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 338 g_browser_process->platform_part()->browser_policy_connector_chromeos();
339 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 339 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
340 connector->GetDeviceCloudPolicyManager(); 340 connector->GetDeviceCloudPolicyManager();
341 341
342 policy::CloudPolicyStore* store = policy_manager->core()->store(); 342 policy::CloudPolicyStore* store = policy_manager->core()->store();
343 343
344 const enterprise_management::PolicyData* policy = store->policy(); 344 const enterprise_management::PolicyData* policy = store->policy();
345 345
346 std::string asset_id = policy ? policy->annotated_asset_id() : std::string(); 346 std::string asset_id = policy ? policy->annotated_asset_id() : std::string();
347 std::string location = policy ? policy->annotated_location() : std::string(); 347 std::string location = policy ? policy->annotated_location() : std::string();
348 actor_->ShowAttributePromptScreen(asset_id, location); 348 view_->ShowAttributePromptScreen(asset_id, location);
349 } 349 }
350 350
351 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { 351 void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) {
352 DCHECK(shark_controller_); 352 DCHECK(shark_controller_);
353 shark_controller_->OnAuthenticationDone(enrolling_user_domain_, token); 353 shark_controller_->OnAuthenticationDone(enrolling_user_domain_, token);
354 } 354 }
355 355
356 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() { 356 void EnrollmentScreen::ShowEnrollmentStatusOnSuccess() {
357 retry_backoff_->InformOfRequest(true); 357 retry_backoff_->InformOfRequest(true);
358 if (elapsed_timer_) 358 if (elapsed_timer_)
359 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_); 359 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeSuccess, elapsed_timer_);
360 if (UsingHandsOffEnrollment()) { 360 if (UsingHandsOffEnrollment()) {
361 OnConfirmationClosed(); 361 OnConfirmationClosed();
362 } else { 362 } else {
363 actor_->ShowEnrollmentStatus( 363 view_->ShowEnrollmentStatus(
364 policy::EnrollmentStatus::ForStatus(policy::EnrollmentStatus::SUCCESS)); 364 policy::EnrollmentStatus::ForStatus(policy::EnrollmentStatus::SUCCESS));
365 } 365 }
366 } 366 }
367 367
368 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) { 368 void EnrollmentScreen::UMA(policy::MetricEnrollment sample) {
369 EnrollmentUMA(sample, config_.mode); 369 EnrollmentUMA(sample, config_.mode);
370 } 370 }
371 371
372 void EnrollmentScreen::ShowSigninScreen() { 372 void EnrollmentScreen::ShowSigninScreen() {
373 actor_->Show(); 373 view_->Show();
374 actor_->ShowSigninScreen(); 374 view_->ShowSigninScreen();
375 } 375 }
376 376
377 void EnrollmentScreen::RecordEnrollmentErrorMetrics() { 377 void EnrollmentScreen::RecordEnrollmentErrorMetrics() {
378 enrollment_failed_once_ = true; 378 enrollment_failed_once_ = true;
379 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)? 379 // TODO(drcrash): Maybe create multiple metrics (http://crbug.com/640313)?
380 if (elapsed_timer_) 380 if (elapsed_timer_)
381 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_); 381 UMA_ENROLLMENT_TIME(kMetricEnrollmentTimeFailure, elapsed_timer_);
382 } 382 }
383 383
384 void EnrollmentScreen::JoinDomain(OnDomainJoinedCallback on_joined_callback) { 384 void EnrollmentScreen::JoinDomain(OnDomainJoinedCallback on_joined_callback) {
385 on_joined_callback_ = std::move(on_joined_callback); 385 on_joined_callback_ = std::move(on_joined_callback);
386 actor_->ShowAdJoin(); 386 view_->ShowAdJoin();
387 } 387 }
388 388
389 } // namespace chromeos 389 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698