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

Side by Side Diff: chrome/browser/ui/webui/signin/inline_login_handler_impl.cc

Issue 2255413002: [Signin Error Dialog] (3/3) Added the triggering code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Broke down the CL Created 4 years, 4 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/signin/inline_login_handler_impl.h" 5 #include "chrome/browser/ui/webui/signin/inline_login_handler_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 break; 448 break;
449 default: 449 default:
450 DCHECK(false) << "Invalid action"; 450 DCHECK(false) << "Invalid action";
451 } 451 }
452 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 452 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
453 } 453 }
454 454
455 void InlineSigninHelper::OnClientOAuthFailure( 455 void InlineSigninHelper::OnClientOAuthFailure(
456 const GoogleServiceAuthError& error) { 456 const GoogleServiceAuthError& error) {
457 if (handler_) 457 if (handler_)
458 handler_->HandleLoginError(error.ToString()); 458 handler_->HandleLoginError(error.ToString(), base::string16());
459 459
460 AboutSigninInternals* about_signin_internals = 460 AboutSigninInternals* about_signin_internals =
461 AboutSigninInternalsFactory::GetForProfile(profile_); 461 AboutSigninInternalsFactory::GetForProfile(profile_);
462 about_signin_internals->OnRefreshTokenReceived("Failure"); 462 about_signin_internals->OnRefreshTokenReceived("Failure");
463 463
464 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); 464 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this);
465 } 465 }
466 466
467 InlineLoginHandlerImpl::InlineLoginHandlerImpl() 467 InlineLoginHandlerImpl::InlineLoginHandlerImpl()
468 : confirm_untrusted_signin_(false), 468 : confirm_untrusted_signin_(false),
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 std::string default_email; 775 std::string default_email;
776 std::string validate_email; 776 std::string validate_email;
777 if (net::GetValueForKeyInQuery(params.url, "email", &default_email) && 777 if (net::GetValueForKeyInQuery(params.url, "email", &default_email) &&
778 net::GetValueForKeyInQuery(params.url, "validateEmail", 778 net::GetValueForKeyInQuery(params.url, "validateEmail",
779 &validate_email) && 779 &validate_email) &&
780 validate_email == "1") { 780 validate_email == "1") {
781 if (!gaia::AreEmailsSame(params.email, default_email)) { 781 if (!gaia::AreEmailsSame(params.email, default_email)) {
782 if (params.handler) { 782 if (params.handler) {
783 params.handler->HandleLoginError( 783 params.handler->HandleLoginError(
784 l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL, 784 l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL,
785 base::UTF8ToUTF16(default_email))); 785 base::UTF8ToUTF16(default_email)),
786 base::UTF8ToUTF16(params.email));
786 } 787 }
787 return; 788 return;
788 } 789 }
789 } 790 }
790 791
791 signin_metrics::AccessPoint access_point = 792 signin_metrics::AccessPoint access_point =
792 signin::GetAccessPointForPromoURL(params.url); 793 signin::GetAccessPointForPromoURL(params.url);
793 signin_metrics::Reason reason = 794 signin_metrics::Reason reason =
794 signin::GetSigninReasonForPromoURL(params.url); 795 signin::GetSigninReasonForPromoURL(params.url);
795 LogHistogramValue(signin_metrics::HISTOGRAM_ACCEPTED); 796 LogHistogramValue(signin_metrics::HISTOGRAM_ACCEPTED);
(...skipping 21 matching lines...) Expand all
817 } 818 }
818 default: 819 default:
819 // No need to change |can_offer_for|. 820 // No need to change |can_offer_for|.
820 break; 821 break;
821 } 822 }
822 823
823 std::string error_msg; 824 std::string error_msg;
824 bool can_offer = CanOffer(profile, can_offer_for, params.gaia_id, 825 bool can_offer = CanOffer(profile, can_offer_for, params.gaia_id,
825 params.email, &error_msg); 826 params.email, &error_msg);
826 if (!can_offer) { 827 if (!can_offer) {
827 if (params.handler) 828 if (params.handler) {
828 params.handler->HandleLoginError(error_msg); 829 params.handler->HandleLoginError(error_msg,
830 base::UTF8ToUTF16(params.email));
831 }
829 return; 832 return;
830 } 833 }
831 834
832 AboutSigninInternals* about_signin_internals = 835 AboutSigninInternals* about_signin_internals =
833 AboutSigninInternalsFactory::GetForProfile(profile); 836 AboutSigninInternalsFactory::GetForProfile(profile);
834 about_signin_internals->OnAuthenticationResultReceived("Successful"); 837 about_signin_internals->OnAuthenticationResultReceived("Successful");
835 838
836 SigninClient* signin_client = 839 SigninClient* signin_client =
837 ChromeSigninClientFactory::GetForProfile(profile); 840 ChromeSigninClientFactory::GetForProfile(profile);
838 std::string signin_scoped_device_id = 841 std::string signin_scoped_device_id =
(...skipping 24 matching lines...) Expand all
863 entry->SetIsSigninRequired(false); 866 entry->SetIsSigninRequired(false);
864 } 867 }
865 } 868 }
866 } 869 }
867 870
868 if (params.handler) 871 if (params.handler)
869 params.handler->web_ui()->CallJavascriptFunctionUnsafe( 872 params.handler->web_ui()->CallJavascriptFunctionUnsafe(
870 "inline.login.closeDialog"); 873 "inline.login.closeDialog");
871 } 874 }
872 875
873 void InlineLoginHandlerImpl::HandleLoginError(const std::string& error_msg) { 876 void InlineLoginHandlerImpl::HandleLoginError(const std::string& error_msg,
877 const base::string16& email) {
874 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); 878 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE);
875 Browser* browser = GetDesktopBrowser(); 879 Browser* browser = GetDesktopBrowser();
876 Profile* profile = Profile::FromWebUI(web_ui()); 880 Profile* profile = Profile::FromWebUI(web_ui());
877 881
878 CloseModalSigninIfNeeded(this); 882 CloseModalSigninIfNeeded(this);
879 if (browser && !error_msg.empty()) { 883 if (browser && !error_msg.empty()) {
880 LoginUIServiceFactory::GetForProfile(profile)-> 884 LoginUIServiceFactory::GetForProfile(profile)->DisplayLoginResult(
881 DisplayLoginResult(browser, base::UTF8ToUTF16(error_msg)); 885 browser, base::UTF8ToUTF16(error_msg), email);
882 } 886 }
883 } 887 }
884 888
885 Browser* InlineLoginHandlerImpl::GetDesktopBrowser() { 889 Browser* InlineLoginHandlerImpl::GetDesktopBrowser() {
886 Browser* browser = chrome::FindBrowserWithWebContents( 890 Browser* browser = chrome::FindBrowserWithWebContents(
887 web_ui()->GetWebContents()); 891 web_ui()->GetWebContents());
888 if (!browser) 892 if (!browser)
889 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); 893 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui()));
890 return browser; 894 return browser;
891 } 895 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 } 937 }
934 938
935 if (show_account_management) { 939 if (show_account_management) {
936 browser->window()->ShowAvatarBubbleFromAvatarButton( 940 browser->window()->ShowAvatarBubbleFromAvatarButton(
937 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, 941 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT,
938 signin::ManageAccountsParams(), 942 signin::ManageAccountsParams(),
939 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); 943 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN);
940 } 944 }
941 } 945 }
942 } 946 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/signin/inline_login_handler_impl.h ('k') | chrome/browser/ui/webui/signin/login_ui_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698