| 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/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/browser_process.h" | 12 #include "chrome/browser/browser_process.h" |
| 13 #include "chrome/browser/browser_shutdown.h" | 13 #include "chrome/browser/browser_shutdown.h" |
| 14 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | |
| 15 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" | 14 #include "chrome/browser/chromeos/login/ui/user_adding_screen.h" |
| 16 #include "chrome/browser/chromeos/login/users/user_manager.h" | 15 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 17 #include "chrome/browser/chromeos/policy/consumer_management_service.h" | 16 #include "chrome/browser/chromeos/policy/consumer_management_service.h" |
| 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 17 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 19 #include "chrome/browser/chromeos/settings/cros_settings.h" | 18 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 20 #include "chrome/browser/io_thread.h" | 19 #include "chrome/browser/io_thread.h" |
| 21 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" | 20 #include "chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h" |
| 21 #include "chrome/browser/ui/webui/signin/inline_login_ui.h" |
| 22 #include "chromeos/chromeos_switches.h" | 22 #include "chromeos/chromeos_switches.h" |
| 23 #include "chromeos/settings/cros_settings_names.h" | 23 #include "chromeos/settings/cros_settings_names.h" |
| 24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 25 #include "content/public/browser/render_frame_host.h" | 25 #include "content/public/browser/render_frame_host.h" |
| 26 #include "google_apis/gaia/gaia_auth_util.h" | 26 #include "google_apis/gaia/gaia_auth_util.h" |
| 27 #include "google_apis/gaia/gaia_switches.h" | 27 #include "google_apis/gaia/gaia_switches.h" |
| 28 #include "google_apis/gaia/gaia_urls.h" | 28 #include "google_apis/gaia/gaia_urls.h" |
| 29 #include "grit/chromium_strings.h" | 29 #include "grit/chromium_strings.h" |
| 30 #include "grit/generated_resources.h" | 30 #include "grit/generated_resources.h" |
| 31 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 32 | 32 |
| 33 using content::BrowserThread; | 33 using content::BrowserThread; |
| 34 | 34 |
| 35 namespace chromeos { | 35 namespace chromeos { |
| 36 | 36 |
| 37 namespace { | 37 namespace { |
| 38 | 38 |
| 39 const char kJsScreenPath[] = "login.GaiaSigninScreen"; | 39 const char kJsScreenPath[] = "login.GaiaSigninScreen"; |
| 40 const char kAuthIframeParentName[] = "signin-frame"; |
| 41 const char kAuthIframeParentOrigin[] = |
| 42 "chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/"; |
| 40 | 43 |
| 41 void UpdateAuthParams(base::DictionaryValue* params, | 44 void UpdateAuthParams(base::DictionaryValue* params, |
| 42 bool has_users, | 45 bool has_users, |
| 43 bool is_enrolling_consumer_management) { | 46 bool is_enrolling_consumer_management) { |
| 44 CrosSettings* cros_settings = CrosSettings::Get(); | 47 CrosSettings* cros_settings = CrosSettings::Get(); |
| 45 bool allow_new_user = true; | 48 bool allow_new_user = true; |
| 46 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); | 49 cros_settings->GetBoolean(kAccountsPrefAllowNewUser, &allow_new_user); |
| 47 bool allow_guest = true; | 50 bool allow_guest = true; |
| 48 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); | 51 cros_settings->GetBoolean(kAccountsPrefAllowGuest, &allow_guest); |
| 49 // Account creation depends on Guest sign-in (http://crosbug.com/24570). | 52 // Account creation depends on Guest sign-in (http://crosbug.com/24570). |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 | 344 |
| 342 void GaiaScreenHandler::HandleGaiaUIReady() { | 345 void GaiaScreenHandler::HandleGaiaUIReady() { |
| 343 if (focus_stolen_) { | 346 if (focus_stolen_) { |
| 344 // Set focus to the Gaia page. | 347 // Set focus to the Gaia page. |
| 345 // TODO(altimofeev): temporary solution, until focus parameters are | 348 // TODO(altimofeev): temporary solution, until focus parameters are |
| 346 // implemented on the Gaia side. | 349 // implemented on the Gaia side. |
| 347 // Do this only once. Any subsequent call would relod GAIA frame. | 350 // Do this only once. Any subsequent call would relod GAIA frame. |
| 348 focus_stolen_ = false; | 351 focus_stolen_ = false; |
| 349 const char code[] = | 352 const char code[] = |
| 350 "if (typeof gWindowOnLoad != 'undefined') gWindowOnLoad();"; | 353 "if (typeof gWindowOnLoad != 'undefined') gWindowOnLoad();"; |
| 351 content::RenderFrameHost* frame = | 354 content::RenderFrameHost* frame = InlineLoginUI::GetAuthIframe( |
| 352 LoginDisplayHostImpl::GetGaiaAuthIframe(web_ui()->GetWebContents()); | 355 web_ui()->GetWebContents(), |
| 356 GURL(kAuthIframeParentOrigin), |
| 357 kAuthIframeParentName); |
| 353 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); | 358 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); |
| 354 } | 359 } |
| 355 if (gaia_silent_load_) { | 360 if (gaia_silent_load_) { |
| 356 focus_stolen_ = true; | 361 focus_stolen_ = true; |
| 357 // Prevent focus stealing by the Gaia page. | 362 // Prevent focus stealing by the Gaia page. |
| 358 // TODO(altimofeev): temporary solution, until focus parameters are | 363 // TODO(altimofeev): temporary solution, until focus parameters are |
| 359 // implemented on the Gaia side. | 364 // implemented on the Gaia side. |
| 360 const char code[] = | 365 const char code[] = |
| 361 "var gWindowOnLoad = window.onload; " | 366 "var gWindowOnLoad = window.onload; " |
| 362 "window.onload=function() {};"; | 367 "window.onload=function() {};"; |
| 363 content::RenderFrameHost* frame = | 368 content::RenderFrameHost* frame = InlineLoginUI::GetAuthIframe( |
| 364 LoginDisplayHostImpl::GetGaiaAuthIframe(web_ui()->GetWebContents()); | 369 web_ui()->GetWebContents(), |
| 370 GURL(kAuthIframeParentOrigin), |
| 371 kAuthIframeParentName); |
| 365 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); | 372 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); |
| 366 | 373 |
| 367 // As we could miss and window.onload could already be called, restore | 374 // As we could miss and window.onload could already be called, restore |
| 368 // focus to current pod (see crbug/175243). | 375 // focus to current pod (see crbug/175243). |
| 369 DCHECK(signin_screen_handler_); | 376 DCHECK(signin_screen_handler_); |
| 370 signin_screen_handler_->RefocusCurrentPod(); | 377 signin_screen_handler_->RefocusCurrentPod(); |
| 371 } | 378 } |
| 372 HandleFrameLoadingCompleted(0); | 379 HandleFrameLoadingCompleted(0); |
| 373 | 380 |
| 374 if (test_expects_complete_login_) | 381 if (test_expects_complete_login_) |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 486 } | 493 } |
| 487 | 494 |
| 488 void GaiaScreenHandler::SubmitLoginFormForTest() { | 495 void GaiaScreenHandler::SubmitLoginFormForTest() { |
| 489 VLOG(2) << "Submit login form for test, user=" << test_user_; | 496 VLOG(2) << "Submit login form for test, user=" << test_user_; |
| 490 | 497 |
| 491 std::string code; | 498 std::string code; |
| 492 code += "document.getElementById('Email').value = '" + test_user_ + "';"; | 499 code += "document.getElementById('Email').value = '" + test_user_ + "';"; |
| 493 code += "document.getElementById('Passwd').value = '" + test_pass_ + "';"; | 500 code += "document.getElementById('Passwd').value = '" + test_pass_ + "';"; |
| 494 code += "document.getElementById('signIn').click();"; | 501 code += "document.getElementById('signIn').click();"; |
| 495 | 502 |
| 496 content::RenderFrameHost* frame = | 503 content::RenderFrameHost* frame = InlineLoginUI::GetAuthIframe( |
| 497 LoginDisplayHostImpl::GetGaiaAuthIframe(web_ui()->GetWebContents()); | 504 web_ui()->GetWebContents(), |
| 505 GURL(kAuthIframeParentOrigin), |
| 506 kAuthIframeParentName); |
| 498 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); | 507 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); |
| 499 | 508 |
| 500 // Test properties are cleared in HandleCompleteLogin because the form | 509 // Test properties are cleared in HandleCompleteLogin because the form |
| 501 // submission might fail and login will not be attempted after reloading | 510 // submission might fail and login will not be attempted after reloading |
| 502 // if they are cleared here. | 511 // if they are cleared here. |
| 503 } | 512 } |
| 504 | 513 |
| 505 void GaiaScreenHandler::SetSAMLPrincipalsAPIUsed(bool api_used) { | 514 void GaiaScreenHandler::SetSAMLPrincipalsAPIUsed(bool api_used) { |
| 506 using_saml_api_ = api_used; | 515 using_saml_api_ = api_used; |
| 507 UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.APIUsed", api_used); | 516 UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.APIUsed", api_used); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 | 612 |
| 604 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { | 613 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { |
| 605 DCHECK(signin_screen_handler_); | 614 DCHECK(signin_screen_handler_); |
| 606 return signin_screen_handler_->delegate_; | 615 return signin_screen_handler_->delegate_; |
| 607 } | 616 } |
| 608 | 617 |
| 609 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { | 618 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { |
| 610 signin_screen_handler_ = handler; | 619 signin_screen_handler_ = handler; |
| 611 } | 620 } |
| 612 } // namespace chromeos | 621 } // namespace chromeos |
| OLD | NEW |