| 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 builder->Add("createAccount", IDS_CREATE_ACCOUNT_HTML); | 260 builder->Add("createAccount", IDS_CREATE_ACCOUNT_HTML); |
| 261 builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML); | 261 builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML); |
| 262 builder->Add("createSupervisedUser", | 262 builder->Add("createSupervisedUser", |
| 263 IDS_CREATE_SUPERVISED_USER_HTML); | 263 IDS_CREATE_SUPERVISED_USER_HTML); |
| 264 builder->Add("createSupervisedUserFeatureName", | 264 builder->Add("createSupervisedUserFeatureName", |
| 265 IDS_CREATE_SUPERVISED_USER_FEATURE_NAME); | 265 IDS_CREATE_SUPERVISED_USER_FEATURE_NAME); |
| 266 builder->Add("consumerManagementEnrollmentSigninMessage", | 266 builder->Add("consumerManagementEnrollmentSigninMessage", |
| 267 IDS_LOGIN_CONSUMER_MANAGEMENT_ENROLLMENT); | 267 IDS_LOGIN_CONSUMER_MANAGEMENT_ENROLLMENT); |
| 268 | 268 |
| 269 // Strings used by the SAML fatal error dialog. | 269 // Strings used by the SAML fatal error dialog. |
| 270 builder->Add("fatalErrorMessageNoEmail", IDS_LOGIN_FATAL_ERROR_NO_EMAIL); | 270 builder->Add("fatalErrorMessageNoAccountDetails", |
| 271 IDS_LOGIN_FATAL_ERROR_NO_ACCOUNT_DETAILS); |
| 271 builder->Add("fatalErrorMessageNoPassword", | 272 builder->Add("fatalErrorMessageNoPassword", |
| 272 IDS_LOGIN_FATAL_ERROR_NO_PASSWORD); | 273 IDS_LOGIN_FATAL_ERROR_NO_PASSWORD); |
| 273 builder->Add("fatalErrorMessageVerificationFailed", | 274 builder->Add("fatalErrorMessageVerificationFailed", |
| 274 IDS_LOGIN_FATAL_ERROR_PASSWORD_VERIFICATION); | 275 IDS_LOGIN_FATAL_ERROR_PASSWORD_VERIFICATION); |
| 275 builder->Add("fatalErrorMessageInsecureURL", | 276 builder->Add("fatalErrorMessageInsecureURL", |
| 276 IDS_LOGIN_FATAL_ERROR_TEXT_INSECURE_URL); | 277 IDS_LOGIN_FATAL_ERROR_TEXT_INSECURE_URL); |
| 277 builder->Add("fatalErrorInstructions", IDS_LOGIN_FATAL_ERROR_INSTRUCTIONS); | 278 builder->Add("fatalErrorInstructions", IDS_LOGIN_FATAL_ERROR_INSTRUCTIONS); |
| 278 builder->Add("fatalErrorDismissButton", IDS_OK); | 279 builder->Add("fatalErrorDismissButton", IDS_OK); |
| 279 } | 280 } |
| 280 | 281 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 | 313 |
| 313 if (network_state_informer_->state() != NetworkStateInformer::ONLINE) | 314 if (network_state_informer_->state() != NetworkStateInformer::ONLINE) |
| 314 return; | 315 return; |
| 315 if (frame_state_ == FRAME_STATE_LOADED) | 316 if (frame_state_ == FRAME_STATE_LOADED) |
| 316 UpdateState(ErrorScreenActor::ERROR_REASON_UPDATE); | 317 UpdateState(ErrorScreenActor::ERROR_REASON_UPDATE); |
| 317 else if (frame_state_ == FRAME_STATE_ERROR) | 318 else if (frame_state_ == FRAME_STATE_ERROR) |
| 318 UpdateState(ErrorScreenActor::ERROR_REASON_FRAME_ERROR); | 319 UpdateState(ErrorScreenActor::ERROR_REASON_FRAME_ERROR); |
| 319 } | 320 } |
| 320 | 321 |
| 321 void GaiaScreenHandler::HandleCompleteAuthentication( | 322 void GaiaScreenHandler::HandleCompleteAuthentication( |
| 323 const std::string& gaia_id, |
| 322 const std::string& email, | 324 const std::string& email, |
| 323 const std::string& password, | 325 const std::string& password, |
| 324 const std::string& auth_code) { | 326 const std::string& auth_code) { |
| 325 if (!Delegate()) | 327 if (!Delegate()) |
| 326 return; | 328 return; |
| 329 |
| 330 DCHECK(!email.empty()); |
| 331 DCHECK(!gaia_id.empty()); |
| 327 Delegate()->SetDisplayEmail(gaia::SanitizeEmail(email)); | 332 Delegate()->SetDisplayEmail(gaia::SanitizeEmail(email)); |
| 328 UserContext user_context(email); | 333 UserContext user_context(email); |
| 334 user_context.SetGaiaID(gaia_id); |
| 329 user_context.SetKey(Key(password)); | 335 user_context.SetKey(Key(password)); |
| 330 user_context.SetAuthCode(auth_code); | 336 user_context.SetAuthCode(auth_code); |
| 331 Delegate()->CompleteLogin(user_context); | 337 Delegate()->CompleteLogin(user_context); |
| 332 } | 338 } |
| 333 | 339 |
| 334 void GaiaScreenHandler::HandleCompleteLogin(const std::string& typed_email, | 340 void GaiaScreenHandler::HandleCompleteLogin(const std::string& gaia_id, |
| 341 const std::string& typed_email, |
| 335 const std::string& password, | 342 const std::string& password, |
| 336 bool using_saml) { | 343 bool using_saml) { |
| 337 if (!is_enrolling_consumer_management_) { | 344 if (!is_enrolling_consumer_management_) { |
| 338 DoCompleteLogin(typed_email, password, using_saml); | 345 DoCompleteLogin(gaia_id, typed_email, password, using_saml); |
| 339 return; | 346 return; |
| 340 } | 347 } |
| 341 | 348 |
| 342 // Consumer management enrollment is in progress. | 349 // Consumer management enrollment is in progress. |
| 343 const std::string owner_email = | 350 const std::string owner_email = |
| 344 user_manager::UserManager::Get()->GetOwnerEmail(); | 351 user_manager::UserManager::Get()->GetOwnerEmail(); |
| 345 if (typed_email != owner_email) { | 352 if (typed_email != owner_email) { |
| 346 // Show Gaia sign-in screen again, since we only allow the owner to sign | 353 // Show Gaia sign-in screen again, since we only allow the owner to sign |
| 347 // in. | 354 // in. |
| 348 populated_email_ = owner_email; | 355 populated_email_ = owner_email; |
| 349 ShowGaia(is_enrolling_consumer_management_); | 356 ShowGaia(is_enrolling_consumer_management_); |
| 350 return; | 357 return; |
| 351 } | 358 } |
| 352 | 359 |
| 353 CHECK(consumer_management_); | 360 CHECK(consumer_management_); |
| 354 consumer_management_->SetOwner(owner_email, | 361 consumer_management_->SetOwner(owner_email, |
| 355 base::Bind(&GaiaScreenHandler::OnSetOwnerDone, | 362 base::Bind(&GaiaScreenHandler::OnSetOwnerDone, |
| 356 weak_factory_.GetWeakPtr(), | 363 weak_factory_.GetWeakPtr(), |
| 364 gaia_id, |
| 357 typed_email, | 365 typed_email, |
| 358 password, | 366 password, |
| 359 using_saml)); | 367 using_saml)); |
| 360 } | 368 } |
| 361 | 369 |
| 362 void GaiaScreenHandler::HandleUsingSAMLAPI() { | 370 void GaiaScreenHandler::HandleUsingSAMLAPI() { |
| 363 SetSAMLPrincipalsAPIUsed(true); | 371 SetSAMLPrincipalsAPIUsed(true); |
| 364 } | 372 } |
| 365 | 373 |
| 366 void GaiaScreenHandler::HandleScrapedPasswordCount(int password_count) { | 374 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). | 418 // focus to current pod (see crbug/175243). |
| 411 DCHECK(signin_screen_handler_); | 419 DCHECK(signin_screen_handler_); |
| 412 signin_screen_handler_->RefocusCurrentPod(); | 420 signin_screen_handler_->RefocusCurrentPod(); |
| 413 } | 421 } |
| 414 HandleFrameLoadingCompleted(0); | 422 HandleFrameLoadingCompleted(0); |
| 415 | 423 |
| 416 if (test_expects_complete_login_) | 424 if (test_expects_complete_login_) |
| 417 SubmitLoginFormForTest(); | 425 SubmitLoginFormForTest(); |
| 418 } | 426 } |
| 419 | 427 |
| 420 void GaiaScreenHandler::OnSetOwnerDone(const std::string& typed_email, | 428 void GaiaScreenHandler::OnSetOwnerDone(const std::string& gaia_id, |
| 429 const std::string& typed_email, |
| 421 const std::string& password, | 430 const std::string& password, |
| 422 bool using_saml, | 431 bool using_saml, |
| 423 bool success) { | 432 bool success) { |
| 424 CHECK(consumer_management_); | 433 CHECK(consumer_management_); |
| 425 if (success) { | 434 if (success) { |
| 426 consumer_management_->SetEnrollmentStage( | 435 consumer_management_->SetEnrollmentStage( |
| 427 policy::ConsumerManagementService::ENROLLMENT_STAGE_OWNER_STORED); | 436 policy::ConsumerManagementService::ENROLLMENT_STAGE_OWNER_STORED); |
| 428 } else { | 437 } else { |
| 429 LOG(ERROR) << "Failed to write owner e-mail to boot lockbox."; | 438 LOG(ERROR) << "Failed to write owner e-mail to boot lockbox."; |
| 430 consumer_management_->SetEnrollmentStage( | 439 consumer_management_->SetEnrollmentStage( |
| 431 policy::ConsumerManagementService:: | 440 policy::ConsumerManagementService:: |
| 432 ENROLLMENT_STAGE_BOOT_LOCKBOX_FAILED); | 441 ENROLLMENT_STAGE_BOOT_LOCKBOX_FAILED); |
| 433 // We should continue logging in the user, as there's not much we can do | 442 // We should continue logging in the user, as there's not much we can do |
| 434 // here. | 443 // here. |
| 435 } | 444 } |
| 436 DoCompleteLogin(typed_email, password, using_saml); | 445 DoCompleteLogin(gaia_id, typed_email, password, using_saml); |
| 437 } | 446 } |
| 438 | 447 |
| 439 void GaiaScreenHandler::DoCompleteLogin(const std::string& typed_email, | 448 void GaiaScreenHandler::DoCompleteLogin(const std::string& gaia_id, |
| 449 const std::string& typed_email, |
| 440 const std::string& password, | 450 const std::string& password, |
| 441 bool using_saml) { | 451 bool using_saml) { |
| 442 if (!Delegate()) | 452 if (!Delegate()) |
| 443 return; | 453 return; |
| 444 | 454 |
| 445 if (using_saml && !using_saml_api_) | 455 if (using_saml && !using_saml_api_) |
| 446 RecordSAMLScrapingVerificationResultInHistogram(true); | 456 RecordSAMLScrapingVerificationResultInHistogram(true); |
| 447 | 457 |
| 458 DCHECK(!typed_email.empty()); |
| 459 DCHECK(!gaia_id.empty()); |
| 448 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); | 460 const std::string sanitized_email = gaia::SanitizeEmail(typed_email); |
| 449 Delegate()->SetDisplayEmail(sanitized_email); | 461 Delegate()->SetDisplayEmail(sanitized_email); |
| 450 UserContext user_context(sanitized_email); | 462 UserContext user_context(sanitized_email); |
| 463 user_context.SetGaiaID(gaia_id); |
| 451 user_context.SetKey(Key(password)); | 464 user_context.SetKey(Key(password)); |
| 452 user_context.SetAuthFlow(using_saml | 465 user_context.SetAuthFlow(using_saml |
| 453 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML | 466 ? UserContext::AUTH_FLOW_GAIA_WITH_SAML |
| 454 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); | 467 : UserContext::AUTH_FLOW_GAIA_WITHOUT_SAML); |
| 455 Delegate()->CompleteLogin(user_context); | 468 Delegate()->CompleteLogin(user_context); |
| 456 | 469 |
| 457 if (test_expects_complete_login_) { | 470 if (test_expects_complete_login_) { |
| 458 VLOG(2) << "Complete test login for " << typed_email | 471 VLOG(2) << "Complete test login for " << typed_email |
| 459 << ", requested=" << test_user_; | 472 << ", requested=" << test_user_; |
| 460 | 473 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 | 702 |
| 690 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 703 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
| 691 DCHECK(signin_screen_handler_); | 704 DCHECK(signin_screen_handler_); |
| 692 return signin_screen_handler_->delegate_; | 705 return signin_screen_handler_->delegate_; |
| 693 } | 706 } |
| 694 | 707 |
| 695 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { | 708 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { |
| 696 signin_screen_handler_ = handler; | 709 signin_screen_handler_ = handler; |
| 697 } | 710 } |
| 698 } // namespace chromeos | 711 } // namespace chromeos |
| OLD | NEW |