OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/webui/chromeos/login/gaia_screen_handler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 | 312 |
313 if (network_state_informer_->state() != NetworkStateInformer::ONLINE) | 313 if (network_state_informer_->state() != NetworkStateInformer::ONLINE) |
314 return; | 314 return; |
315 if (frame_state_ == FRAME_STATE_LOADED) | 315 if (frame_state_ == FRAME_STATE_LOADED) |
316 UpdateState(ErrorScreenActor::ERROR_REASON_UPDATE); | 316 UpdateState(ErrorScreenActor::ERROR_REASON_UPDATE); |
317 else if (frame_state_ == FRAME_STATE_ERROR) | 317 else if (frame_state_ == FRAME_STATE_ERROR) |
318 UpdateState(ErrorScreenActor::ERROR_REASON_FRAME_ERROR); | 318 UpdateState(ErrorScreenActor::ERROR_REASON_FRAME_ERROR); |
319 } | 319 } |
320 | 320 |
321 void GaiaScreenHandler::HandleCompleteAuthentication( | 321 void GaiaScreenHandler::HandleCompleteAuthentication( |
| 322 const std::string& gaia_id, |
322 const std::string& email, | 323 const std::string& email, |
323 const std::string& password, | 324 const std::string& password, |
324 const std::string& auth_code) { | 325 const std::string& auth_code) { |
325 if (!Delegate()) | 326 if (!Delegate()) |
326 return; | 327 return; |
| 328 |
| 329 DCHECK(!email.empty()); |
| 330 DCHECK(!gaia_id.empty()); |
327 Delegate()->SetDisplayEmail(gaia::SanitizeEmail(email)); | 331 Delegate()->SetDisplayEmail(gaia::SanitizeEmail(email)); |
328 UserContext user_context(email); | 332 UserContext user_context(email); |
| 333 user_context.SetGaiaID(gaia_id); |
329 user_context.SetKey(Key(password)); | 334 user_context.SetKey(Key(password)); |
330 user_context.SetAuthCode(auth_code); | 335 user_context.SetAuthCode(auth_code); |
331 Delegate()->CompleteLogin(user_context); | 336 Delegate()->CompleteLogin(user_context); |
332 } | 337 } |
333 | 338 |
334 void GaiaScreenHandler::HandleCompleteLogin(const std::string& typed_email, | 339 void GaiaScreenHandler::HandleCompleteLogin(const std::string& gaia_id, |
| 340 const std::string& typed_email, |
335 const std::string& password, | 341 const std::string& password, |
336 bool using_saml) { | 342 bool using_saml) { |
337 if (!is_enrolling_consumer_management_) { | 343 if (!is_enrolling_consumer_management_) { |
338 DoCompleteLogin(typed_email, password, using_saml); | 344 DoCompleteLogin(gaia_id, typed_email, password, using_saml); |
339 return; | 345 return; |
340 } | 346 } |
341 | 347 |
342 // Consumer management enrollment is in progress. | 348 // Consumer management enrollment is in progress. |
343 const std::string owner_email = | 349 const std::string owner_email = |
344 user_manager::UserManager::Get()->GetOwnerEmail(); | 350 user_manager::UserManager::Get()->GetOwnerEmail(); |
345 if (typed_email != owner_email) { | 351 if (typed_email != owner_email) { |
346 // Show Gaia sign-in screen again, since we only allow the owner to sign | 352 // Show Gaia sign-in screen again, since we only allow the owner to sign |
347 // in. | 353 // in. |
348 populated_email_ = owner_email; | 354 populated_email_ = owner_email; |
349 ShowGaia(is_enrolling_consumer_management_); | 355 ShowGaia(is_enrolling_consumer_management_); |
350 return; | 356 return; |
351 } | 357 } |
352 | 358 |
353 CHECK(consumer_management_); | 359 CHECK(consumer_management_); |
354 consumer_management_->SetOwner(owner_email, | 360 consumer_management_->SetOwner(owner_email, |
355 base::Bind(&GaiaScreenHandler::OnSetOwnerDone, | 361 base::Bind(&GaiaScreenHandler::OnSetOwnerDone, |
356 weak_factory_.GetWeakPtr(), | 362 weak_factory_.GetWeakPtr(), |
| 363 gaia_id, |
357 typed_email, | 364 typed_email, |
358 password, | 365 password, |
359 using_saml)); | 366 using_saml)); |
360 } | 367 } |
361 | 368 |
362 void GaiaScreenHandler::HandleUsingSAMLAPI() { | 369 void GaiaScreenHandler::HandleUsingSAMLAPI() { |
363 SetSAMLPrincipalsAPIUsed(true); | 370 SetSAMLPrincipalsAPIUsed(true); |
364 } | 371 } |
365 | 372 |
366 void GaiaScreenHandler::HandleScrapedPasswordCount(int password_count) { | 373 void GaiaScreenHandler::HandleScrapedPasswordCount(int password_count) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 // focus to current pod (see crbug/175243). | 417 // focus to current pod (see crbug/175243). |
411 DCHECK(signin_screen_handler_); | 418 DCHECK(signin_screen_handler_); |
412 signin_screen_handler_->RefocusCurrentPod(); | 419 signin_screen_handler_->RefocusCurrentPod(); |
413 } | 420 } |
414 HandleFrameLoadingCompleted(0); | 421 HandleFrameLoadingCompleted(0); |
415 | 422 |
416 if (test_expects_complete_login_) | 423 if (test_expects_complete_login_) |
417 SubmitLoginFormForTest(); | 424 SubmitLoginFormForTest(); |
418 } | 425 } |
419 | 426 |
420 void GaiaScreenHandler::OnSetOwnerDone(const std::string& typed_email, | 427 void GaiaScreenHandler::OnSetOwnerDone(const std::string& gaia_id, |
| 428 const std::string& typed_email, |
421 const std::string& password, | 429 const std::string& password, |
422 bool using_saml, | 430 bool using_saml, |
423 bool success) { | 431 bool success) { |
424 CHECK(consumer_management_); | 432 CHECK(consumer_management_); |
425 if (success) { | 433 if (success) { |
426 consumer_management_->SetEnrollmentStage( | 434 consumer_management_->SetEnrollmentStage( |
427 policy::ConsumerManagementService::ENROLLMENT_STAGE_OWNER_STORED); | 435 policy::ConsumerManagementService::ENROLLMENT_STAGE_OWNER_STORED); |
428 } else { | 436 } else { |
429 LOG(ERROR) << "Failed to write owner e-mail to boot lockbox."; | 437 LOG(ERROR) << "Failed to write owner e-mail to boot lockbox."; |
430 consumer_management_->SetEnrollmentStage( | 438 consumer_management_->SetEnrollmentStage( |
431 policy::ConsumerManagementService:: | 439 policy::ConsumerManagementService:: |
432 ENROLLMENT_STAGE_BOOT_LOCKBOX_FAILED); | 440 ENROLLMENT_STAGE_BOOT_LOCKBOX_FAILED); |
433 // We should continue logging in the user, as there's not much we can do | 441 // We should continue logging in the user, as there's not much we can do |
434 // here. | 442 // here. |
435 } | 443 } |
436 DoCompleteLogin(typed_email, password, using_saml); | 444 DoCompleteLogin(gaia_id, typed_email, password, using_saml); |
437 } | 445 } |
438 | 446 |
439 void GaiaScreenHandler::DoCompleteLogin(const std::string& typed_email, | 447 void GaiaScreenHandler::DoCompleteLogin(const std::string& gaia_id, |
| 448 const std::string& typed_email, |
440 const std::string& password, | 449 const std::string& password, |
441 bool using_saml) { | 450 bool using_saml) { |
442 if (!Delegate()) | 451 if (!Delegate()) |
443 return; | 452 return; |
444 | 453 |
445 if (using_saml && !using_saml_api_) | 454 if (using_saml && !using_saml_api_) |
446 RecordSAMLScrapingVerificationResultInHistogram(true); | 455 RecordSAMLScrapingVerificationResultInHistogram(true); |
447 | 456 |
| 457 DCHECK(!typed_email.empty()); |
| 458 DCHECK(!gaia_id.empty()); |
448 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); | 459 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); |
449 Delegate()->SetDisplayEmail(sanitized_email); | 460 Delegate()->SetDisplayEmail(sanitized_email); |
450 UserContext user_context(sanitized_email); | 461 UserContext user_context(sanitized_email); |
| 462 user_context.SetGaiaID(gaia_id); |
451 user_context.SetKey(Key(password)); | 463 user_context.SetKey(Key(password)); |
452 user_context.SetAuthFlow(using_saml | 464 user_context.SetAuthFlow(using_saml |
453 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML | 465 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML |
454 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); | 466 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); |
455 Delegate()->CompleteLogin(user_context); | 467 Delegate()->CompleteLogin(user_context); |
456 | 468 |
457 if (test_expects_complete_login_) { | 469 if (test_expects_complete_login_) { |
458 VLOG(2) << "Complete test login for " << typed_email | 470 VLOG(2) << "Complete test login for " << typed_email |
459 << ", requested=" << test_user_; | 471 << ", requested=" << test_user_; |
460 | 472 |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 | 701 |
690 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 702 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
691 DCHECK(signin_screen_handler_); | 703 DCHECK(signin_screen_handler_); |
692 return signin_screen_handler_->delegate_; | 704 return signin_screen_handler_->delegate_; |
693 } | 705 } |
694 | 706 |
695 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { | 707 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { |
696 signin_screen_handler_ = handler; | 708 signin_screen_handler_ = handler; |
697 } | 709 } |
698 } // namespace chromeos | 710 } // namespace chromeos |
OLD | NEW |