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

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/gaia_screen_handler.cc

Issue 1054403002: Basic tests for new webview based signin flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove flaky back-button check Created 5 years, 8 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 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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 528
529 void GaiaScreenHandler::HandleGaiaUIReady() { 529 void GaiaScreenHandler::HandleGaiaUIReady() {
530 if (focus_stolen_) { 530 if (focus_stolen_) {
531 // Set focus to the Gaia page. 531 // Set focus to the Gaia page.
532 // TODO(altimofeev): temporary solution, until focus parameters are 532 // TODO(altimofeev): temporary solution, until focus parameters are
533 // implemented on the Gaia side. 533 // implemented on the Gaia side.
534 // Do this only once. Any subsequent call would relod GAIA frame. 534 // Do this only once. Any subsequent call would relod GAIA frame.
535 focus_stolen_ = false; 535 focus_stolen_ = false;
536 const char code[] = 536 const char code[] =
537 "if (typeof gWindowOnLoad != 'undefined') gWindowOnLoad();"; 537 "if (typeof gWindowOnLoad != 'undefined') gWindowOnLoad();";
538 content::RenderFrameHost* frame = InlineLoginUI::GetAuthIframe( 538 content::RenderFrameHost* frame = InlineLoginUI::GetAuthFrame(
539 web_ui()->GetWebContents(), 539 web_ui()->GetWebContents(),
540 GURL(kAuthIframeParentOrigin), 540 GURL(kAuthIframeParentOrigin),
541 kAuthIframeParentName); 541 kAuthIframeParentName);
542 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); 542 frame->ExecuteJavaScript(base::ASCIIToUTF16(code));
543 } 543 }
544 if (gaia_silent_load_) { 544 if (gaia_silent_load_) {
545 focus_stolen_ = true; 545 focus_stolen_ = true;
546 // Prevent focus stealing by the Gaia page. 546 // Prevent focus stealing by the Gaia page.
547 // TODO(altimofeev): temporary solution, until focus parameters are 547 // TODO(altimofeev): temporary solution, until focus parameters are
548 // implemented on the Gaia side. 548 // implemented on the Gaia side.
549 const char code[] = 549 const char code[] =
550 "var gWindowOnLoad = window.onload; " 550 "var gWindowOnLoad = window.onload; "
551 "window.onload=function() {};"; 551 "window.onload=function() {};";
552 content::RenderFrameHost* frame = InlineLoginUI::GetAuthIframe( 552 content::RenderFrameHost* frame = InlineLoginUI::GetAuthFrame(
553 web_ui()->GetWebContents(), 553 web_ui()->GetWebContents(),
554 GURL(kAuthIframeParentOrigin), 554 GURL(kAuthIframeParentOrigin),
555 kAuthIframeParentName); 555 kAuthIframeParentName);
556 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); 556 frame->ExecuteJavaScript(base::ASCIIToUTF16(code));
557 557
558 // As we could miss and window.onload could already be called, restore 558 // As we could miss and window.onload could already be called, restore
559 // focus to current pod (see crbug/175243). 559 // focus to current pod (see crbug/175243).
560 DCHECK(signin_screen_handler_); 560 DCHECK(signin_screen_handler_);
561 signin_screen_handler_->RefocusCurrentPod(); 561 signin_screen_handler_->RefocusCurrentPod();
562 } 562 }
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 SubmitLoginFormForTest(); 680 SubmitLoginFormForTest();
681 } else if (frame_state() != GaiaScreenHandler::FRAME_STATE_LOADING) { 681 } else if (frame_state() != GaiaScreenHandler::FRAME_STATE_LOADING) {
682 DCHECK(signin_screen_handler_); 682 DCHECK(signin_screen_handler_);
683 signin_screen_handler_->OnShowAddUser(); 683 signin_screen_handler_->OnShowAddUser();
684 } 684 }
685 } 685 }
686 686
687 void GaiaScreenHandler::SubmitLoginFormForTest() { 687 void GaiaScreenHandler::SubmitLoginFormForTest() {
688 VLOG(2) << "Submit login form for test, user=" << test_user_; 688 VLOG(2) << "Submit login form for test, user=" << test_user_;
689 689
690 std::string code; 690 content::RenderFrameHost* frame = InlineLoginUI::GetAuthFrame(
691 code += "document.getElementById('Email').value = '" + test_user_ + "';";
692 code += "document.getElementById('Passwd').value = '" + test_pass_ + "';";
693 code += "document.getElementById('signIn').click();";
694
695 content::RenderFrameHost* frame = InlineLoginUI::GetAuthIframe(
696 web_ui()->GetWebContents(), 691 web_ui()->GetWebContents(),
697 GURL(kAuthIframeParentOrigin), 692 GURL(kAuthIframeParentOrigin),
698 kAuthIframeParentName); 693 kAuthIframeParentName);
699 frame->ExecuteJavaScript(base::ASCIIToUTF16(code)); 694
695 if (!StartupUtils::IsWebviewSigninEnabled()) {
696 std::string code;
697 code += "document.getElementById('Email').value = '" + test_user_ + "';";
698 code += "document.getElementById('Passwd').value = '" + test_pass_ + "';";
699 code += "document.getElementById('signIn').click();";
700
701 frame->ExecuteJavaScript(base::ASCIIToUTF16(code));
702 } else {
703 std::string code;
704
705 code =
706 "document.getElementById('identifier').value = '" + test_user_ + "';";
707 code += "document.getElementById('nextButton').click();";
708 frame->ExecuteJavaScript(base::ASCIIToUTF16(code));
709
710 if (!test_pass_.empty()) {
711 code =
712 "document.getElementById('password').value = '" + test_pass_ + "';";
713 code += "document.getElementById('nextButton').click();";
714 frame->ExecuteJavaScript(base::ASCIIToUTF16(code));
715 }
716 }
700 717
701 // Test properties are cleared in HandleCompleteLogin because the form 718 // Test properties are cleared in HandleCompleteLogin because the form
702 // submission might fail and login will not be attempted after reloading 719 // submission might fail and login will not be attempted after reloading
703 // if they are cleared here. 720 // if they are cleared here.
704 } 721 }
705 722
706 void GaiaScreenHandler::SetSAMLPrincipalsAPIUsed(bool api_used) { 723 void GaiaScreenHandler::SetSAMLPrincipalsAPIUsed(bool api_used) {
707 using_saml_api_ = api_used; 724 using_saml_api_ = api_used;
708 UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.APIUsed", api_used); 725 UMA_HISTOGRAM_BOOLEAN("ChromeOS.SAML.APIUsed", api_used);
709 } 726 }
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() { 872 SigninScreenHandlerDelegate* GaiaScreenHandler::Delegate() {
856 DCHECK(signin_screen_handler_); 873 DCHECK(signin_screen_handler_);
857 return signin_screen_handler_->delegate_; 874 return signin_screen_handler_->delegate_;
858 } 875 }
859 876
860 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) { 877 void GaiaScreenHandler::SetSigninScreenHandler(SigninScreenHandler* handler) {
861 signin_screen_handler_ = handler; 878 signin_screen_handler_ = handler;
862 } 879 }
863 880
864 } // namespace chromeos 881 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698