| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 core_oobe_actor_(core_oobe_actor), | 168 core_oobe_actor_(core_oobe_actor), |
| 169 dns_cleared_(false), | 169 dns_cleared_(false), |
| 170 dns_clear_task_running_(false), | 170 dns_clear_task_running_(false), |
| 171 cookies_cleared_(false), | 171 cookies_cleared_(false), |
| 172 show_when_dns_and_cookies_cleared_(false), | 172 show_when_dns_and_cookies_cleared_(false), |
| 173 focus_stolen_(false), | 173 focus_stolen_(false), |
| 174 gaia_silent_load_(false), | 174 gaia_silent_load_(false), |
| 175 using_saml_api_(false), | 175 using_saml_api_(false), |
| 176 is_enrolling_consumer_management_(false), | 176 is_enrolling_consumer_management_(false), |
| 177 test_expects_complete_login_(false), | 177 test_expects_complete_login_(false), |
| 178 embedded_signin_enabled_by_shortcut_(false), | |
| 179 use_easy_bootstrap_(false), | 178 use_easy_bootstrap_(false), |
| 180 signin_screen_handler_(NULL), | 179 signin_screen_handler_(NULL), |
| 181 weak_factory_(this) { | 180 weak_factory_(this) { |
| 182 DCHECK(network_state_informer_.get()); | 181 DCHECK(network_state_informer_.get()); |
| 183 } | 182 } |
| 184 | 183 |
| 185 GaiaScreenHandler::~GaiaScreenHandler() { | 184 GaiaScreenHandler::~GaiaScreenHandler() { |
| 186 } | 185 } |
| 187 | 186 |
| 188 void GaiaScreenHandler::LoadGaia(const GaiaContext& context) { | 187 void GaiaScreenHandler::LoadGaia(const GaiaContext& context) { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 command_line->HasSwitch(::switches::kGaiaUrl) | 270 command_line->HasSwitch(::switches::kGaiaUrl) |
| 272 ? GURL(command_line->GetSwitchValueASCII(::switches::kGaiaUrl)) | 271 ? GURL(command_line->GetSwitchValueASCII(::switches::kGaiaUrl)) |
| 273 : GaiaUrls::GetInstance()->gaia_url(); | 272 : GaiaUrls::GetInstance()->gaia_url(); |
| 274 params.SetString("gaiaUrl", gaia_url.spec()); | 273 params.SetString("gaiaUrl", gaia_url.spec()); |
| 275 } | 274 } |
| 276 | 275 |
| 277 if (command_line->HasSwitch(switches::kGaiaEndpointChromeOS)) { | 276 if (command_line->HasSwitch(switches::kGaiaEndpointChromeOS)) { |
| 278 params.SetString("gaiaEndpoint", command_line->GetSwitchValueASCII( | 277 params.SetString("gaiaEndpoint", command_line->GetSwitchValueASCII( |
| 279 switches::kGaiaEndpointChromeOS)); | 278 switches::kGaiaEndpointChromeOS)); |
| 280 } | 279 } |
| 281 if (context.embedded_signin_enabled) { | |
| 282 params.SetBoolean("useEmbedded", true); | |
| 283 // We set 'constrained' here to switch troubleshooting page on embedded | |
| 284 // signin to full tab. | |
| 285 params.SetInteger("constrained", 1); | |
| 286 } | |
| 287 | 280 |
| 288 if (use_easy_bootstrap_) { | 281 if (use_easy_bootstrap_) { |
| 289 params.SetBoolean("useEafe", true); | 282 params.SetBoolean("useEafe", true); |
| 290 // Easy login overrides. | 283 // Easy login overrides. |
| 291 std::string eafe_url = "https://easylogin.corp.google.com/"; | 284 std::string eafe_url = "https://easylogin.corp.google.com/"; |
| 292 if (command_line->HasSwitch(switches::kEafeUrl)) | 285 if (command_line->HasSwitch(switches::kEafeUrl)) |
| 293 eafe_url = command_line->GetSwitchValueASCII(switches::kEafeUrl); | 286 eafe_url = command_line->GetSwitchValueASCII(switches::kEafeUrl); |
| 294 std::string eafe_path = "planters/cbaudioChrome"; | 287 std::string eafe_path = "planters/cbaudioChrome"; |
| 295 if (command_line->HasSwitch(switches::kEafePath)) | 288 if (command_line->HasSwitch(switches::kEafePath)) |
| 296 eafe_path = command_line->GetSwitchValueASCII(switches::kEafePath); | 289 eafe_path = command_line->GetSwitchValueASCII(switches::kEafePath); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 321 if (state != NetworkStateInformer::ONLINE) { | 314 if (state != NetworkStateInformer::ONLINE) { |
| 322 VLOG(1) << "Skipping reloading of Gaia since network state=" | 315 VLOG(1) << "Skipping reloading of Gaia since network state=" |
| 323 << NetworkStateInformer::StatusString(state); | 316 << NetworkStateInformer::StatusString(state); |
| 324 return; | 317 return; |
| 325 } | 318 } |
| 326 VLOG(1) << "Reloading Gaia."; | 319 VLOG(1) << "Reloading Gaia."; |
| 327 frame_state_ = FRAME_STATE_LOADING; | 320 frame_state_ = FRAME_STATE_LOADING; |
| 328 CallJS("doReload"); | 321 CallJS("doReload"); |
| 329 } | 322 } |
| 330 | 323 |
| 331 void GaiaScreenHandler::SwitchToEmbeddedSignin() { | |
| 332 // This feature should not be working on Stable,Beta images. | |
| 333 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | |
| 334 if (channel == chrome::VersionInfo::CHANNEL_STABLE || | |
| 335 channel == chrome::VersionInfo::CHANNEL_BETA) { | |
| 336 return; | |
| 337 } | |
| 338 embedded_signin_enabled_by_shortcut_ = true; | |
| 339 LoadAuthExtension( | |
| 340 true /* force */, true /* silent_load */, false /* offline */); | |
| 341 } | |
| 342 | |
| 343 void GaiaScreenHandler::CancelEmbeddedSignin() { | |
| 344 embedded_signin_enabled_by_shortcut_ = false; | |
| 345 } | |
| 346 | |
| 347 void GaiaScreenHandler::DeclareLocalizedValues( | 324 void GaiaScreenHandler::DeclareLocalizedValues( |
| 348 ::login::LocalizedValuesBuilder* builder) { | 325 ::login::LocalizedValuesBuilder* builder) { |
| 349 builder->Add("signinScreenTitle", IDS_SIGNIN_SCREEN_TITLE); | 326 builder->Add("signinScreenTitle", IDS_SIGNIN_SCREEN_TITLE); |
| 350 builder->Add("signinScreenPasswordChanged", | 327 builder->Add("signinScreenPasswordChanged", |
| 351 IDS_SIGNIN_SCREEN_PASSWORD_CHANGED); | 328 IDS_SIGNIN_SCREEN_PASSWORD_CHANGED); |
| 352 builder->Add("createAccount", IDS_CREATE_ACCOUNT_HTML); | 329 builder->Add("createAccount", IDS_CREATE_ACCOUNT_HTML); |
| 353 builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML); | 330 builder->Add("guestSignin", IDS_BROWSE_WITHOUT_SIGNING_IN_HTML); |
| 354 builder->Add("createSupervisedUser", | 331 builder->Add("createSupervisedUser", |
| 355 IDS_CREATE_SUPERVISED_USER_HTML); | 332 IDS_CREATE_SUPERVISED_USER_HTML); |
| 356 builder->Add("createSupervisedUserFeatureName", | 333 builder->Add("createSupervisedUserFeatureName", |
| (...skipping 29 matching lines...) Expand all Loading... |
| 386 AddCallback("completeAuthentication", | 363 AddCallback("completeAuthentication", |
| 387 &GaiaScreenHandler::HandleCompleteAuthentication); | 364 &GaiaScreenHandler::HandleCompleteAuthentication); |
| 388 AddCallback("completeAuthenticationAuthCodeOnly", | 365 AddCallback("completeAuthenticationAuthCodeOnly", |
| 389 &GaiaScreenHandler::HandleCompleteAuthenticationAuthCodeOnly); | 366 &GaiaScreenHandler::HandleCompleteAuthenticationAuthCodeOnly); |
| 390 AddCallback("usingSAMLAPI", &GaiaScreenHandler::HandleUsingSAMLAPI); | 367 AddCallback("usingSAMLAPI", &GaiaScreenHandler::HandleUsingSAMLAPI); |
| 391 AddCallback("scrapedPasswordCount", | 368 AddCallback("scrapedPasswordCount", |
| 392 &GaiaScreenHandler::HandleScrapedPasswordCount); | 369 &GaiaScreenHandler::HandleScrapedPasswordCount); |
| 393 AddCallback("scrapedPasswordVerificationFailed", | 370 AddCallback("scrapedPasswordVerificationFailed", |
| 394 &GaiaScreenHandler::HandleScrapedPasswordVerificationFailed); | 371 &GaiaScreenHandler::HandleScrapedPasswordVerificationFailed); |
| 395 AddCallback("loginWebuiReady", &GaiaScreenHandler::HandleGaiaUIReady); | 372 AddCallback("loginWebuiReady", &GaiaScreenHandler::HandleGaiaUIReady); |
| 396 AddCallback("switchToFullTab", &GaiaScreenHandler::HandleSwitchToFullTab); | |
| 397 AddCallback("toggleWebviewSignin", | 373 AddCallback("toggleWebviewSignin", |
| 398 &GaiaScreenHandler::HandleToggleWebviewSignin); | 374 &GaiaScreenHandler::HandleToggleWebviewSignin); |
| 399 AddCallback("toggleEasyBootstrap", | 375 AddCallback("toggleEasyBootstrap", |
| 400 &GaiaScreenHandler::HandleToggleEasyBootstrap); | 376 &GaiaScreenHandler::HandleToggleEasyBootstrap); |
| 401 } | 377 } |
| 402 | 378 |
| 403 void GaiaScreenHandler::HandleFrameLoadingCompleted(int status) { | 379 void GaiaScreenHandler::HandleFrameLoadingCompleted(int status) { |
| 404 const net::Error frame_error = static_cast<net::Error>(-status); | 380 const net::Error frame_error = static_cast<net::Error>(-status); |
| 405 if (frame_error == net::ERR_ABORTED) { | 381 if (frame_error == net::ERR_ABORTED) { |
| 406 LOG(WARNING) << "Ignoring Gaia frame error: " << frame_error; | 382 LOG(WARNING) << "Ignoring Gaia frame error: " << frame_error; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 498 UMA_HISTOGRAM_ENUMERATION( | 474 UMA_HISTOGRAM_ENUMERATION( |
| 499 "ChromeOS.SAML.Scraping.PasswordCount", std::min(password_count, 10), 11); | 475 "ChromeOS.SAML.Scraping.PasswordCount", std::min(password_count, 10), 11); |
| 500 if (password_count == 0) | 476 if (password_count == 0) |
| 501 HandleScrapedPasswordVerificationFailed(); | 477 HandleScrapedPasswordVerificationFailed(); |
| 502 } | 478 } |
| 503 | 479 |
| 504 void GaiaScreenHandler::HandleScrapedPasswordVerificationFailed() { | 480 void GaiaScreenHandler::HandleScrapedPasswordVerificationFailed() { |
| 505 RecordSAMLScrapingVerificationResultInHistogram(false); | 481 RecordSAMLScrapingVerificationResultInHistogram(false); |
| 506 } | 482 } |
| 507 | 483 |
| 508 void GaiaScreenHandler::HandleSwitchToFullTab() { | |
| 509 CallJS("switchToFullTab"); | |
| 510 } | |
| 511 | |
| 512 void GaiaScreenHandler::HandleToggleWebviewSignin() { | 484 void GaiaScreenHandler::HandleToggleWebviewSignin() { |
| 513 if (StartupUtils::EnableWebviewSignin( | 485 if (StartupUtils::EnableWebviewSignin( |
| 514 !StartupUtils::IsWebviewSigninEnabled())) { | 486 !StartupUtils::IsWebviewSigninEnabled())) { |
| 515 chrome::AttemptRestart(); | 487 chrome::AttemptRestart(); |
| 516 } | 488 } |
| 517 } | 489 } |
| 518 | 490 |
| 519 void GaiaScreenHandler::HandleToggleEasyBootstrap() { | 491 void GaiaScreenHandler::HandleToggleEasyBootstrap() { |
| 520 use_easy_bootstrap_ = !use_easy_bootstrap_; | 492 use_easy_bootstrap_ = !use_easy_bootstrap_; |
| 521 const bool kForceReload = true; | 493 const bool kForceReload = true; |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 context.password_changed = !populated_email_.empty() && | 801 context.password_changed = !populated_email_.empty() && |
| 830 password_changed_for_.count(populated_email_); | 802 password_changed_for_.count(populated_email_); |
| 831 context.use_offline = offline; | 803 context.use_offline = offline; |
| 832 context.email = populated_email_; | 804 context.email = populated_email_; |
| 833 context.is_enrolling_consumer_management = is_enrolling_consumer_management_; | 805 context.is_enrolling_consumer_management = is_enrolling_consumer_management_; |
| 834 if (Delegate()) { | 806 if (Delegate()) { |
| 835 context.show_users = Delegate()->IsShowUsers(); | 807 context.show_users = Delegate()->IsShowUsers(); |
| 836 context.has_users = !Delegate()->GetUsers().empty(); | 808 context.has_users = !Delegate()->GetUsers().empty(); |
| 837 } | 809 } |
| 838 | 810 |
| 839 context.embedded_signin_enabled = | |
| 840 base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 841 chromeos::switches::kEnableEmbeddedSignin) || | |
| 842 embedded_signin_enabled_by_shortcut_; | |
| 843 | |
| 844 populated_email_.clear(); | 811 populated_email_.clear(); |
| 845 | 812 |
| 846 LoadGaia(context); | 813 LoadGaia(context); |
| 847 } | 814 } |
| 848 | 815 |
| 849 void GaiaScreenHandler::UpdateState(NetworkError::ErrorReason reason) { | 816 void GaiaScreenHandler::UpdateState(NetworkError::ErrorReason reason) { |
| 850 if (signin_screen_handler_) | 817 if (signin_screen_handler_) |
| 851 signin_screen_handler_->UpdateState(reason); | 818 signin_screen_handler_->UpdateState(reason); |
| 852 } | 819 } |
| 853 | 820 |
| 854 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 821 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
| 855 DCHECK(signin_screen_handler_); | 822 DCHECK(signin_screen_handler_); |
| 856 return signin_screen_handler_->delegate_; | 823 return signin_screen_handler_->delegate_; |
| 857 } | 824 } |
| 858 | 825 |
| 859 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { | 826 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { |
| 860 signin_screen_handler_ = handler; | 827 signin_screen_handler_ = handler; |
| 861 } | 828 } |
| 862 | 829 |
| 863 } // namespace chromeos | 830 } // namespace chromeos |
| OLD | NEW |