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/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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 break; | 444 break; |
445 default: | 445 default: |
446 DCHECK(false) << "Invalid action"; | 446 DCHECK(false) << "Invalid action"; |
447 } | 447 } |
448 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 448 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
449 } | 449 } |
450 | 450 |
451 void InlineSigninHelper::OnClientOAuthFailure( | 451 void InlineSigninHelper::OnClientOAuthFailure( |
452 const GoogleServiceAuthError& error) { | 452 const GoogleServiceAuthError& error) { |
453 if (handler_) | 453 if (handler_) |
454 handler_->HandleLoginError(error.ToString()); | 454 handler_->HandleLoginError(error.ToString(), base::string16()); |
455 | 455 |
456 AboutSigninInternals* about_signin_internals = | 456 AboutSigninInternals* about_signin_internals = |
457 AboutSigninInternalsFactory::GetForProfile(profile_); | 457 AboutSigninInternalsFactory::GetForProfile(profile_); |
458 about_signin_internals->OnRefreshTokenReceived("Failure"); | 458 about_signin_internals->OnRefreshTokenReceived("Failure"); |
459 | 459 |
460 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 460 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
461 } | 461 } |
462 | 462 |
463 InlineLoginHandlerImpl::InlineLoginHandlerImpl() | 463 InlineLoginHandlerImpl::InlineLoginHandlerImpl() |
464 : confirm_untrusted_signin_(false), | 464 : confirm_untrusted_signin_(false), |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 std::string default_email; | 771 std::string default_email; |
772 std::string validate_email; | 772 std::string validate_email; |
773 if (net::GetValueForKeyInQuery(params.url, "email", &default_email) && | 773 if (net::GetValueForKeyInQuery(params.url, "email", &default_email) && |
774 net::GetValueForKeyInQuery(params.url, "validateEmail", | 774 net::GetValueForKeyInQuery(params.url, "validateEmail", |
775 &validate_email) && | 775 &validate_email) && |
776 validate_email == "1") { | 776 validate_email == "1") { |
777 if (!gaia::AreEmailsSame(params.email, default_email)) { | 777 if (!gaia::AreEmailsSame(params.email, default_email)) { |
778 if (params.handler) { | 778 if (params.handler) { |
779 params.handler->HandleLoginError( | 779 params.handler->HandleLoginError( |
780 l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL, | 780 l10n_util::GetStringFUTF8(IDS_SYNC_WRONG_EMAIL, |
781 base::UTF8ToUTF16(default_email))); | 781 base::UTF8ToUTF16(default_email)), |
| 782 base::UTF8ToUTF16(params.email)); |
782 } | 783 } |
783 return; | 784 return; |
784 } | 785 } |
785 } | 786 } |
786 | 787 |
787 signin_metrics::AccessPoint access_point = | 788 signin_metrics::AccessPoint access_point = |
788 signin::GetAccessPointForPromoURL(params.url); | 789 signin::GetAccessPointForPromoURL(params.url); |
789 signin_metrics::Reason reason = | 790 signin_metrics::Reason reason = |
790 signin::GetSigninReasonForPromoURL(params.url); | 791 signin::GetSigninReasonForPromoURL(params.url); |
791 LogHistogramValue(signin_metrics::HISTOGRAM_ACCEPTED); | 792 LogHistogramValue(signin_metrics::HISTOGRAM_ACCEPTED); |
(...skipping 21 matching lines...) Expand all Loading... |
813 } | 814 } |
814 default: | 815 default: |
815 // No need to change |can_offer_for|. | 816 // No need to change |can_offer_for|. |
816 break; | 817 break; |
817 } | 818 } |
818 | 819 |
819 std::string error_msg; | 820 std::string error_msg; |
820 bool can_offer = CanOffer(profile, can_offer_for, params.gaia_id, | 821 bool can_offer = CanOffer(profile, can_offer_for, params.gaia_id, |
821 params.email, &error_msg); | 822 params.email, &error_msg); |
822 if (!can_offer) { | 823 if (!can_offer) { |
823 if (params.handler) | 824 if (params.handler) { |
824 params.handler->HandleLoginError(error_msg); | 825 params.handler->HandleLoginError(error_msg, |
| 826 base::UTF8ToUTF16(params.email)); |
| 827 } |
825 return; | 828 return; |
826 } | 829 } |
827 | 830 |
828 AboutSigninInternals* about_signin_internals = | 831 AboutSigninInternals* about_signin_internals = |
829 AboutSigninInternalsFactory::GetForProfile(profile); | 832 AboutSigninInternalsFactory::GetForProfile(profile); |
830 about_signin_internals->OnAuthenticationResultReceived("Successful"); | 833 about_signin_internals->OnAuthenticationResultReceived("Successful"); |
831 | 834 |
832 SigninClient* signin_client = | 835 SigninClient* signin_client = |
833 ChromeSigninClientFactory::GetForProfile(profile); | 836 ChromeSigninClientFactory::GetForProfile(profile); |
834 std::string signin_scoped_device_id = | 837 std::string signin_scoped_device_id = |
(...skipping 24 matching lines...) Expand all Loading... |
859 entry->SetIsSigninRequired(false); | 862 entry->SetIsSigninRequired(false); |
860 } | 863 } |
861 } | 864 } |
862 } | 865 } |
863 | 866 |
864 if (params.handler) | 867 if (params.handler) |
865 params.handler->web_ui()->CallJavascriptFunctionUnsafe( | 868 params.handler->web_ui()->CallJavascriptFunctionUnsafe( |
866 "inline.login.closeDialog"); | 869 "inline.login.closeDialog"); |
867 } | 870 } |
868 | 871 |
869 void InlineLoginHandlerImpl::HandleLoginError(const std::string& error_msg) { | 872 void InlineLoginHandlerImpl::HandleLoginError(const std::string& error_msg, |
| 873 const base::string16& email) { |
870 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); | 874 SyncStarterCallback(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); |
871 Browser* browser = GetDesktopBrowser(); | 875 Browser* browser = GetDesktopBrowser(); |
872 Profile* profile = Profile::FromWebUI(web_ui()); | 876 Profile* profile = Profile::FromWebUI(web_ui()); |
873 | 877 |
874 CloseModalSigninIfNeeded(this); | 878 CloseModalSigninIfNeeded(this); |
875 if (browser && !error_msg.empty()) { | 879 if (browser && !error_msg.empty()) { |
876 LoginUIServiceFactory::GetForProfile(profile)-> | 880 LoginUIServiceFactory::GetForProfile(profile)->DisplayLoginResult( |
877 DisplayLoginResult(browser, base::UTF8ToUTF16(error_msg)); | 881 browser, base::UTF8ToUTF16(error_msg), email); |
878 } | 882 } |
879 } | 883 } |
880 | 884 |
881 Browser* InlineLoginHandlerImpl::GetDesktopBrowser() { | 885 Browser* InlineLoginHandlerImpl::GetDesktopBrowser() { |
882 Browser* browser = chrome::FindBrowserWithWebContents( | 886 Browser* browser = chrome::FindBrowserWithWebContents( |
883 web_ui()->GetWebContents()); | 887 web_ui()->GetWebContents()); |
884 if (!browser) | 888 if (!browser) |
885 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); | 889 browser = chrome::FindLastActiveWithProfile(Profile::FromWebUI(web_ui())); |
886 return browser; | 890 return browser; |
887 } | 891 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 } | 933 } |
930 | 934 |
931 if (show_account_management) { | 935 if (show_account_management) { |
932 browser->window()->ShowAvatarBubbleFromAvatarButton( | 936 browser->window()->ShowAvatarBubbleFromAvatarButton( |
933 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, | 937 BrowserWindow::AVATAR_BUBBLE_MODE_ACCOUNT_MANAGEMENT, |
934 signin::ManageAccountsParams(), | 938 signin::ManageAccountsParams(), |
935 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); | 939 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); |
936 } | 940 } |
937 } | 941 } |
938 } | 942 } |
OLD | NEW |