OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/sync/one_click_signin_helper.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 #include "ui/base/resource/resource_bundle.h" | 75 #include "ui/base/resource/resource_bundle.h" |
76 | 76 |
77 | 77 |
78 namespace { | 78 namespace { |
79 | 79 |
80 // StartSyncArgs -------------------------------------------------------------- | 80 // StartSyncArgs -------------------------------------------------------------- |
81 | 81 |
82 // Arguments used with StartSync function. base::Bind() cannot support too | 82 // Arguments used with StartSync function. base::Bind() cannot support too |
83 // many args for performance reasons, so they are packaged up into a struct. | 83 // many args for performance reasons, so they are packaged up into a struct. |
84 struct StartSyncArgs { | 84 struct StartSyncArgs { |
85 StartSyncArgs(Profile* profile, | 85 StartSyncArgs( |
86 Browser* browser, | 86 Profile* profile, |
87 OneClickSigninHelper::AutoAccept auto_accept, | 87 Browser* browser, |
88 const std::string& session_index, | 88 OneClickSigninHelper::AutoAccept auto_accept, |
89 const std::string& email, | 89 const std::string& session_index, |
90 const std::string& password, | 90 const std::string& email, |
91 bool force_same_tab_navigation, | 91 const std::string& password, |
92 bool confirmation_required); | 92 bool force_same_tab_navigation, |
93 bool saml_confirmation_required, | |
Roger Tawa OOO till Jul 10th
2013/05/03 15:16:47
Is this really saml related? I think my suggestio
Andrew T Wilson (Slow)
2013/05/03 19:16:11
I only set this if confirmation_required_ is set,
Roger Tawa OOO till Jul 10th
2013/05/06 15:46:39
Thanks Drew. The non-saml "untrusted" flow is the
| |
94 SyncPromoUI::Source source); | |
93 | 95 |
94 Profile* profile; | 96 Profile* profile; |
95 Browser* browser; | 97 Browser* browser; |
96 OneClickSigninHelper::AutoAccept auto_accept; | 98 OneClickSigninHelper::AutoAccept auto_accept; |
97 std::string session_index; | 99 std::string session_index; |
98 std::string email; | 100 std::string email; |
99 std::string password; | 101 std::string password; |
100 bool force_same_tab_navigation; | 102 bool force_same_tab_navigation; |
101 bool confirmation_required; | 103 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required; |
102 }; | 104 }; |
103 | 105 |
104 StartSyncArgs::StartSyncArgs(Profile* profile, | 106 StartSyncArgs::StartSyncArgs( |
105 Browser* browser, | 107 Profile* profile, |
106 OneClickSigninHelper::AutoAccept auto_accept, | 108 Browser* browser, |
107 const std::string& session_index, | 109 OneClickSigninHelper::AutoAccept auto_accept, |
108 const std::string& email, | 110 const std::string& session_index, |
109 const std::string& password, | 111 const std::string& email, |
110 bool force_same_tab_navigation, | 112 const std::string& password, |
111 bool confirmation_required) | 113 bool force_same_tab_navigation, |
114 bool saml_confirmation_required, | |
115 SyncPromoUI::Source source) | |
112 : profile(profile), | 116 : profile(profile), |
113 browser(browser), | 117 browser(browser), |
114 auto_accept(auto_accept), | 118 auto_accept(auto_accept), |
115 session_index(session_index), | 119 session_index(session_index), |
116 email(email), | 120 email(email), |
117 password(password), | 121 password(password), |
118 force_same_tab_navigation(force_same_tab_navigation), | 122 force_same_tab_navigation(force_same_tab_navigation) { |
119 confirmation_required(confirmation_required) { | 123 if (saml_confirmation_required) { |
124 confirmation_required = OneClickSigninSyncStarter::CONFIRM_SAML_SIGNIN; | |
125 } else if (source == SyncPromoUI::SOURCE_SETTINGS || | |
126 source == SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { | |
127 // Do not display a status confirmation for webstore installs or re-auth. | |
128 confirmation_required = OneClickSigninSyncStarter::NO_CONFIRMATION; | |
129 } else { | |
130 confirmation_required = OneClickSigninSyncStarter::CONFIRM_AFTER_SIGNIN; | |
131 } | |
120 } | 132 } |
121 | 133 |
122 | 134 |
123 // Helpers -------------------------------------------------------------------- | 135 // Helpers -------------------------------------------------------------------- |
124 | 136 |
125 // Add a specific email to the list of emails rejected for one-click | 137 // Add a specific email to the list of emails rejected for one-click |
126 // sign-in, for this profile. | 138 // sign-in, for this profile. |
127 void AddEmailToOneClickRejectedList(Profile* profile, | 139 void AddEmailToOneClickRejectedList(Profile* profile, |
128 const std::string& email) { | 140 const std::string& email) { |
129 PrefService* pref_service = profile->GetPrefs(); | 141 PrefService* pref_service = profile->GetPrefs(); |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
464 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper); | 476 DEFINE_WEB_CONTENTS_USER_DATA_KEY(OneClickSigninHelper); |
465 | 477 |
466 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) | 478 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) |
467 : content::WebContentsObserver(web_contents), | 479 : content::WebContentsObserver(web_contents), |
468 showing_signin_(false), | 480 showing_signin_(false), |
469 auto_accept_(AUTO_ACCEPT_NONE), | 481 auto_accept_(AUTO_ACCEPT_NONE), |
470 source_(SyncPromoUI::SOURCE_UNKNOWN), | 482 source_(SyncPromoUI::SOURCE_UNKNOWN), |
471 switched_to_advanced_(false), | 483 switched_to_advanced_(false), |
472 original_source_(SyncPromoUI::SOURCE_UNKNOWN), | 484 original_source_(SyncPromoUI::SOURCE_UNKNOWN), |
473 untrusted_navigations_since_signin_visit_(0), | 485 untrusted_navigations_since_signin_visit_(0), |
474 confirmation_required_(false) { | 486 saml_confirmation_required_(false) { |
475 } | 487 } |
476 | 488 |
477 OneClickSigninHelper::~OneClickSigninHelper() { | 489 OneClickSigninHelper::~OneClickSigninHelper() { |
478 content::WebContents* contents = web_contents(); | 490 content::WebContents* contents = web_contents(); |
479 if (contents) { | 491 if (contents) { |
480 Profile* profile = | 492 Profile* profile = |
481 Profile::FromBrowserContext(contents->GetBrowserContext()); | 493 Profile::FromBrowserContext(contents->GetBrowserContext()); |
482 ProfileSyncService* sync_service = | 494 ProfileSyncService* sync_service = |
483 ProfileSyncServiceFactory::GetForProfile(profile); | 495 ProfileSyncServiceFactory::GetForProfile(profile); |
484 if (sync_service && sync_service->HasObserver(this)) | 496 if (sync_service && sync_service->HasObserver(this)) |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
817 CanOfferFor can_offer_for = | 829 CanOfferFor can_offer_for = |
818 (auto_accept != AUTO_ACCEPT_EXPLICIT && | 830 (auto_accept != AUTO_ACCEPT_EXPLICIT && |
819 helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ? | 831 helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ? |
820 CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL; | 832 CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL; |
821 | 833 |
822 std::string error_message; | 834 std::string error_message; |
823 | 835 |
824 if (!web_contents || !CanOffer(web_contents, can_offer_for, email, | 836 if (!web_contents || !CanOffer(web_contents, can_offer_for, email, |
825 &error_message)) { | 837 &error_message)) { |
826 VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering"; | 838 VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering"; |
839 // TODO(rogerta): Can we just display our error now instead of keeping it | |
840 // around and doing it later? | |
827 if (helper && helper->error_message_.empty() && !error_message.empty()) | 841 if (helper && helper->error_message_.empty() && !error_message.empty()) |
828 helper->error_message_ = error_message; | 842 helper->error_message_ = error_message; |
829 | 843 |
830 return; | 844 return; |
831 } | 845 } |
832 | 846 |
833 // Only allow the dedicated signin process to sign the user into | 847 // Only allow the dedicated signin process to sign the user into |
834 // Chrome without intervention, because it doesn't load any untrusted | 848 // Chrome without intervention, because it doesn't load any untrusted |
835 // pages. If at any point an untrusted page is detected, chrome will | 849 // pages. If at any point an untrusted page is detected, chrome will |
836 // show a modal dialog asking the user to confirm. | 850 // show a modal dialog asking the user to confirm. |
837 Profile* profile = | 851 Profile* profile = |
838 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 852 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
839 SigninManager* manager = profile ? | 853 SigninManager* manager = profile ? |
840 SigninManagerFactory::GetForProfile(profile) : NULL; | 854 SigninManagerFactory::GetForProfile(profile) : NULL; |
841 helper->confirmation_required_ |= (manager && | 855 helper->saml_confirmation_required_ |= (manager && |
842 !manager->IsSigninProcess(child_id)); | 856 !manager->IsSigninProcess(child_id)); |
843 | 857 |
844 // Save the email in the one-click signin manager. The manager may | 858 // Save the email in the one-click signin manager. The manager may |
845 // not exist if the contents is incognito or if the profile is already | 859 // not exist if the contents is incognito or if the profile is already |
846 // connected to a Google account. | 860 // connected to a Google account. |
847 if (!session_index.empty()) | 861 if (!session_index.empty()) |
848 helper->session_index_ = session_index; | 862 helper->session_index_ = session_index; |
849 | 863 |
850 if (!email.empty()) | 864 if (!email.empty()) |
851 helper->email_ = email; | 865 helper->email_ = email; |
852 | 866 |
853 if (continue_url.is_valid()) | 867 if (continue_url.is_valid()) |
854 helper->continue_url_ = continue_url; | 868 helper->continue_url_ = continue_url; |
855 } | 869 } |
856 | 870 |
857 // static | 871 // static |
858 void OneClickSigninHelper::RemoveCurrentHistoryItem( | 872 void OneClickSigninHelper::RemoveCurrentHistoryItem( |
859 content::WebContents* web_contents) { | 873 content::WebContents* web_contents) { |
860 new CurrentHistoryCleaner(web_contents); // will self-destruct when finished | 874 new CurrentHistoryCleaner(web_contents); // will self-destruct when finished |
861 } | 875 } |
862 | 876 |
863 void OneClickSigninHelper::ShowSyncConfirmationBubble(bool show_bubble) { | 877 void OneClickSigninHelper::ShowSigninErrorBubble(const std::string& error) { |
864 if (show_bubble) { | 878 DCHECK(!error.empty()); |
865 content::WebContents* contents = web_contents(); | 879 content::WebContents* contents = web_contents(); |
866 Profile* profile = | 880 Profile* profile = |
867 Profile::FromBrowserContext(contents->GetBrowserContext()); | 881 Profile::FromBrowserContext(contents->GetBrowserContext()); |
868 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 882 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
869 | 883 |
870 browser->window()->ShowOneClickSigninBubble( | 884 browser->window()->ShowOneClickSigninBubble( |
871 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, | 885 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, |
872 string16(), /* no SAML email */ | 886 string16(), /* no SAML email */ |
873 UTF8ToUTF16(error_message_), | 887 UTF8ToUTF16(error), |
874 base::Bind(&StartSync, | 888 // This callback is never invoked. |
875 StartSyncArgs(profile, browser, AUTO_ACCEPT_ACCEPTED, | 889 // TODO(rogerta): Separate out the bubble API so we don't have to pass |
876 session_index_, email_, password_, | 890 // ignored |email| and |callback| params. |
877 false, confirmation_required_))); | 891 base::Bind(&StartSync, |
878 } | 892 StartSyncArgs(profile, browser, AUTO_ACCEPT_ACCEPTED, |
879 error_message_.clear(); | 893 session_index_, email_, password_, |
894 false, saml_confirmation_required_, source_))); | |
880 } | 895 } |
881 | 896 |
882 void OneClickSigninHelper::RedirectToNtpOrAppsPage(bool show_bubble) { | 897 void OneClickSigninHelper::RedirectToNtpOrAppsPage() { |
883 VLOG(1) << "OneClickSigninHelper::RedirectToNtpOrAppsPage"; | 898 VLOG(1) << "OneClickSigninHelper::RedirectToNtpOrAppsPage"; |
884 | |
885 // Redirect to NTP/Apps page and display a confirmation bubble | 899 // Redirect to NTP/Apps page and display a confirmation bubble |
886 content::WebContents* contents = web_contents(); | 900 content::WebContents* contents = web_contents(); |
887 GURL url(chrome::IsInstantExtendedAPIEnabled() ? | 901 GURL url(chrome::IsInstantExtendedAPIEnabled() ? |
888 chrome::kChromeUIAppsURL : chrome::kChromeUINewTabURL); | 902 chrome::kChromeUIAppsURL : chrome::kChromeUINewTabURL); |
889 content::OpenURLParams params(url, | 903 content::OpenURLParams params(url, |
890 content::Referrer(), | 904 content::Referrer(), |
891 CURRENT_TAB, | 905 CURRENT_TAB, |
892 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 906 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
893 false); | 907 false); |
894 contents->OpenURL(params); | 908 contents->OpenURL(params); |
895 | |
896 ShowSyncConfirmationBubble(show_bubble); | |
897 } | 909 } |
898 | 910 |
899 void OneClickSigninHelper::RedirectToSignin() { | 911 void OneClickSigninHelper::RedirectToSignin() { |
900 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; | 912 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; |
901 | 913 |
902 // Extract the existing sounce=X value. Default to "2" if missing. | 914 // Extract the existing sounce=X value. Default to "2" if missing. |
903 SyncPromoUI::Source source = | 915 SyncPromoUI::Source source = |
904 SyncPromoUI::GetSourceForSyncPromoURL(continue_url_); | 916 SyncPromoUI::GetSourceForSyncPromoURL(continue_url_); |
905 if (source == SyncPromoUI::SOURCE_UNKNOWN) | 917 if (source == SyncPromoUI::SOURCE_UNKNOWN) |
906 source = SyncPromoUI::SOURCE_MENU; | 918 source = SyncPromoUI::SOURCE_MENU; |
(...skipping 10 matching lines...) Expand all Loading... | |
917 VLOG(1) << "OneClickSigninHelper::CleanTransientState"; | 929 VLOG(1) << "OneClickSigninHelper::CleanTransientState"; |
918 showing_signin_ = false; | 930 showing_signin_ = false; |
919 email_.clear(); | 931 email_.clear(); |
920 password_.clear(); | 932 password_.clear(); |
921 auto_accept_ = AUTO_ACCEPT_NONE; | 933 auto_accept_ = AUTO_ACCEPT_NONE; |
922 source_ = SyncPromoUI::SOURCE_UNKNOWN; | 934 source_ = SyncPromoUI::SOURCE_UNKNOWN; |
923 switched_to_advanced_ = false; | 935 switched_to_advanced_ = false; |
924 original_source_ = SyncPromoUI::SOURCE_UNKNOWN; | 936 original_source_ = SyncPromoUI::SOURCE_UNKNOWN; |
925 continue_url_ = GURL(); | 937 continue_url_ = GURL(); |
926 untrusted_navigations_since_signin_visit_ = 0; | 938 untrusted_navigations_since_signin_visit_ = 0; |
927 confirmation_required_ = false; | 939 saml_confirmation_required_ = false; |
940 error_message_.clear(); | |
928 | 941 |
929 // Post to IO thread to clear pending email. | 942 // Post to IO thread to clear pending email. |
930 Profile* profile = | 943 Profile* profile = |
931 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 944 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
932 content::BrowserThread::PostTask( | 945 content::BrowserThread::PostTask( |
933 content::BrowserThread::IO, FROM_HERE, | 946 content::BrowserThread::IO, FROM_HERE, |
934 base::Bind(&ClearPendingEmailOnIOThread, | 947 base::Bind(&ClearPendingEmailOnIOThread, |
935 base::Unretained(profile->GetResourceContext()))); | 948 base::Unretained(profile->GetResourceContext()))); |
936 } | 949 } |
937 | 950 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
992 // TODO(rogerta): might need to allow some youtube URLs. | 1005 // TODO(rogerta): might need to allow some youtube URLs. |
993 content::WebContents* contents = web_contents(); | 1006 content::WebContents* contents = web_contents(); |
994 const GURL url = contents->GetURL(); | 1007 const GURL url = contents->GetURL(); |
995 Profile* profile = | 1008 Profile* profile = |
996 Profile::FromBrowserContext(contents->GetBrowserContext()); | 1009 Profile::FromBrowserContext(contents->GetBrowserContext()); |
997 VLOG(1) << "OneClickSigninHelper::DidStopLoading: url=" << url.spec(); | 1010 VLOG(1) << "OneClickSigninHelper::DidStopLoading: url=" << url.spec(); |
998 | 1011 |
999 // If an error has already occured during the sign in flow, make sure to | 1012 // If an error has already occured during the sign in flow, make sure to |
1000 // display it to the user and abort the process. Do this only for | 1013 // display it to the user and abort the process. Do this only for |
1001 // explicit sign ins. | 1014 // explicit sign ins. |
1015 // TODO(rogerta): Could we move this code back up to ShowInfoBarUIThread()? | |
1002 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) { | 1016 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) { |
1003 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_; | 1017 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_; |
1004 RemoveCurrentHistoryItem(contents); | 1018 RemoveCurrentHistoryItem(contents); |
1005 RedirectToNtpOrAppsPage(true); | 1019 // Redirect to the landing page and display an error popup. |
1020 RedirectToNtpOrAppsPage(); | |
1021 ShowSigninErrorBubble(error_message_); | |
1022 CleanTransientState(); | |
1006 return; | 1023 return; |
1007 } | 1024 } |
1008 | 1025 |
1009 if (AreWeShowingSignin(url, source_, email_)) { | 1026 if (AreWeShowingSignin(url, source_, email_)) { |
1010 if (!showing_signin_) { | 1027 if (!showing_signin_) { |
1011 if (source_ == SyncPromoUI::SOURCE_UNKNOWN) | 1028 if (source_ == SyncPromoUI::SOURCE_UNKNOWN) |
1012 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_SHOWN); | 1029 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_SHOWN); |
1013 else | 1030 else |
1014 LogHistogramValue(source_, one_click_signin::HISTOGRAM_SHOWN); | 1031 LogHistogramValue(source_, one_click_signin::HISTOGRAM_SHOWN); |
1015 } | 1032 } |
(...skipping 14 matching lines...) Expand all Loading... | |
1030 // password is allowed to be empty, since its no longer required to setup | 1047 // password is allowed to be empty, since its no longer required to setup |
1031 // sync. | 1048 // sync. |
1032 if (email_.empty()) { | 1049 if (email_.empty()) { |
1033 VLOG(1) << "OneClickSigninHelper::DidStopLoading: nothing to do"; | 1050 VLOG(1) << "OneClickSigninHelper::DidStopLoading: nothing to do"; |
1034 if (continue_url_match && auto_accept_ == AUTO_ACCEPT_EXPLICIT) | 1051 if (continue_url_match && auto_accept_ == AUTO_ACCEPT_EXPLICIT) |
1035 RedirectToSignin(); | 1052 RedirectToSignin(); |
1036 std::string unused_value; | 1053 std::string unused_value; |
1037 if (net::GetValueForKeyInQuery(url, "ntp", &unused_value)) { | 1054 if (net::GetValueForKeyInQuery(url, "ntp", &unused_value)) { |
1038 SyncPromoUI::SetUserSkippedSyncPromo(profile); | 1055 SyncPromoUI::SetUserSkippedSyncPromo(profile); |
1039 RemoveCurrentHistoryItem(contents); | 1056 RemoveCurrentHistoryItem(contents); |
1040 RedirectToNtpOrAppsPage(false); | 1057 RedirectToNtpOrAppsPage(); |
1041 } | 1058 } |
1042 | 1059 |
1043 if (!continue_url_match && !IsValidGaiaSigninRedirectOrResponseURL(url) && | 1060 if (!continue_url_match && !IsValidGaiaSigninRedirectOrResponseURL(url) && |
1044 ++untrusted_navigations_since_signin_visit_ > kMaxNavigationsSince) { | 1061 ++untrusted_navigations_since_signin_visit_ > kMaxNavigationsSince) { |
1045 CleanTransientState(); | 1062 CleanTransientState(); |
1046 } | 1063 } |
1047 | 1064 |
1048 return; | 1065 return; |
1049 } | 1066 } |
1050 | 1067 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1127 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); | 1144 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); |
1128 SigninManager::DisableOneClickSignIn(profile); | 1145 SigninManager::DisableOneClickSignIn(profile); |
1129 browser->window()->ShowOneClickSigninBubble( | 1146 browser->window()->ShowOneClickSigninBubble( |
1130 bubble_type, | 1147 bubble_type, |
1131 UTF8ToUTF16(email_), | 1148 UTF8ToUTF16(email_), |
1132 string16(), /* no error message to display */ | 1149 string16(), /* no error message to display */ |
1133 base::Bind(&StartSync, | 1150 base::Bind(&StartSync, |
1134 StartSyncArgs(profile, browser, auto_accept_, | 1151 StartSyncArgs(profile, browser, auto_accept_, |
1135 session_index_, email_, password_, | 1152 session_index_, email_, password_, |
1136 false /* force_same_tab_navigation */, | 1153 false /* force_same_tab_navigation */, |
1137 confirmation_required_))); | 1154 saml_confirmation_required_, source_))); |
Roger Tawa OOO till Jul 10th
2013/05/03 15:16:47
Hmm, this is actually broken. Not your CL Drew, b
Andrew T Wilson (Slow)
2013/05/03 19:16:11
Do you mean that I should pass |false| as the conf
Roger Tawa OOO till Jul 10th
2013/05/06 15:46:39
I was actually suggesting passing |true| instead o
Andrew T Wilson (Slow)
2013/05/06 17:00:13
Done.
| |
1138 break; | 1155 break; |
1139 case AUTO_ACCEPT_CONFIGURE: | 1156 case AUTO_ACCEPT_CONFIGURE: |
1140 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | 1157 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); |
1141 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); | 1158 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); |
1142 SigninManager::DisableOneClickSignIn(profile); | 1159 SigninManager::DisableOneClickSignIn(profile); |
1143 StartSync( | 1160 StartSync( |
1144 StartSyncArgs(profile, browser, auto_accept_, session_index_, email_, | 1161 StartSyncArgs(profile, browser, auto_accept_, session_index_, email_, |
1145 password_, false /* force_same_tab_navigation */, | 1162 password_, false /* force_same_tab_navigation */, |
1146 confirmation_required_), | 1163 saml_confirmation_required_, source_), |
1147 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 1164 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
1148 break; | 1165 break; |
1149 case AUTO_ACCEPT_EXPLICIT: { | 1166 case AUTO_ACCEPT_EXPLICIT: { |
1150 if (switched_to_advanced_) { | 1167 if (switched_to_advanced_) { |
1151 LogHistogramValue(original_source_, | 1168 LogHistogramValue(original_source_, |
1152 one_click_signin::HISTOGRAM_WITH_ADVANCED); | 1169 one_click_signin::HISTOGRAM_WITH_ADVANCED); |
1153 LogHistogramValue(original_source_, | 1170 LogHistogramValue(original_source_, |
1154 one_click_signin::HISTOGRAM_ACCEPTED); | 1171 one_click_signin::HISTOGRAM_ACCEPTED); |
1155 } else { | 1172 } else { |
1156 LogHistogramValue(source_, one_click_signin::HISTOGRAM_ACCEPTED); | 1173 LogHistogramValue(source_, one_click_signin::HISTOGRAM_ACCEPTED); |
1157 LogHistogramValue(source_, one_click_signin::HISTOGRAM_WITH_DEFAULTS); | 1174 LogHistogramValue(source_, one_click_signin::HISTOGRAM_WITH_DEFAULTS); |
1158 } | 1175 } |
1159 OneClickSigninSyncStarter::StartSyncMode start_mode = | 1176 OneClickSigninSyncStarter::StartSyncMode start_mode = |
1160 source_ == SyncPromoUI::SOURCE_SETTINGS ? | 1177 source_ == SyncPromoUI::SOURCE_SETTINGS ? |
1161 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : | 1178 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : |
1162 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; | 1179 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; |
1163 | 1180 |
1164 std::string last_email = | 1181 std::string last_email = |
1165 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); | 1182 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); |
1166 | 1183 |
1167 if (!last_email.empty() && last_email != email_) { | 1184 if (!last_email.empty() && last_email != email_) { |
1168 // If the new email address is different from the email address that | 1185 // If the new email address is different from the email address that |
1169 // just signed in, show a confirmation dialog. | 1186 // just signed in, show a confirmation dialog. |
1170 | 1187 |
1171 // No need to display a second confirmation. | 1188 // No need to display a second confirmation. |
1172 confirmation_required_ = false; | 1189 saml_confirmation_required_ = false; |
1173 ConfirmEmailDialogDelegate::AskForConfirmation( | 1190 ConfirmEmailDialogDelegate::AskForConfirmation( |
1174 contents, | 1191 contents, |
1175 last_email, | 1192 last_email, |
1176 email_, | 1193 email_, |
1177 base::Bind( | 1194 base::Bind( |
1178 &StartExplicitSync, | 1195 &StartExplicitSync, |
1179 StartSyncArgs(profile, browser, auto_accept_, | 1196 StartSyncArgs(profile, browser, auto_accept_, |
1180 session_index_, email_, password_, | 1197 session_index_, email_, password_, |
1181 force_same_tab_navigation, | 1198 force_same_tab_navigation, |
1182 confirmation_required_), | 1199 saml_confirmation_required_, source_), |
1183 contents, | 1200 contents, |
1184 start_mode)); | 1201 start_mode)); |
Roger Tawa OOO till Jul 10th
2013/05/03 15:16:47
Can we move this confirmation dialog into the star
Andrew T Wilson (Slow)
2013/05/03 19:16:11
Maybe as a separate CL? I wasn't really doing this
Roger Tawa OOO till Jul 10th
2013/05/06 15:46:39
Sure.
Andrew T Wilson (Slow)
2013/05/06 17:00:13
Done.
| |
1185 } else { | 1202 } else { |
1186 StartExplicitSync( | 1203 StartExplicitSync( |
1187 StartSyncArgs(profile, browser, auto_accept_, session_index_, | 1204 StartSyncArgs(profile, browser, auto_accept_, session_index_, |
1188 email_, password_, force_same_tab_navigation, | 1205 email_, password_, force_same_tab_navigation, |
1189 confirmation_required_), | 1206 saml_confirmation_required_, source_), |
1190 contents, | 1207 contents, |
1191 start_mode, | 1208 start_mode, |
1192 IDS_ONE_CLICK_SIGNIN_CONFIRM_EMAIL_DIALOG_CANCEL_BUTTON); | 1209 IDS_ONE_CLICK_SIGNIN_CONFIRM_EMAIL_DIALOG_CANCEL_BUTTON); |
1193 } | 1210 } |
1194 | 1211 |
1195 if (source_ == SyncPromoUI::SOURCE_SETTINGS && | 1212 if (source_ == SyncPromoUI::SOURCE_SETTINGS && |
1196 SyncPromoUI::GetSourceForSyncPromoURL(continue_url_) == | 1213 SyncPromoUI::GetSourceForSyncPromoURL(continue_url_) == |
1197 SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { | 1214 SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { |
1198 redirect_url_ = continue_url_; | 1215 redirect_url_ = continue_url_; |
1199 ProfileSyncService* sync_service = | 1216 ProfileSyncService* sync_service = |
1200 ProfileSyncServiceFactory::GetForProfile(profile); | 1217 ProfileSyncServiceFactory::GetForProfile(profile); |
1201 if (sync_service) | 1218 if (sync_service) |
1202 sync_service->AddObserver(this); | 1219 sync_service->AddObserver(this); |
1203 } | 1220 } |
1204 | 1221 |
1205 // If this explicit sign in is not from settings page/webstore, show the | 1222 // If this explicit sign in is not from settings page/webstore, show the |
1206 // NTP/Apps page after sign in completes. In the case of the settings | 1223 // NTP/Apps page after sign in completes. In the case of the settings |
1207 // page, it will get closed by SyncSetupHandler. In the case of webstore, | 1224 // page, it will get closed by SyncSetupHandler. In the case of webstore, |
1208 // it will redirect back to webstore. | 1225 // it will redirect back to webstore. |
1209 if (source_ != SyncPromoUI::SOURCE_SETTINGS && | 1226 if (source_ != SyncPromoUI::SOURCE_SETTINGS && |
1210 source_ != SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { | 1227 source_ != SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { |
1211 signin_tracker_.reset(new SigninTracker(profile, this)); | |
1212 RemoveCurrentHistoryItem(contents); | 1228 RemoveCurrentHistoryItem(contents); |
1213 RedirectToNtpOrAppsPage(false); | 1229 RedirectToNtpOrAppsPage(); |
1214 } | 1230 } |
1215 break; | 1231 break; |
1216 } | 1232 } |
1217 case AUTO_ACCEPT_REJECTED_FOR_PROFILE: | 1233 case AUTO_ACCEPT_REJECTED_FOR_PROFILE: |
1218 AddEmailToOneClickRejectedList(profile, email_); | 1234 AddEmailToOneClickRejectedList(profile, email_); |
1219 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_REJECTED); | 1235 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_REJECTED); |
1220 break; | 1236 break; |
1221 default: | 1237 default: |
1222 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; | 1238 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; |
1223 break; | 1239 break; |
1224 } | 1240 } |
1225 | 1241 |
1226 CleanTransientState(); | 1242 CleanTransientState(); |
1227 } | 1243 } |
1228 | 1244 |
1229 void OneClickSigninHelper::GaiaCredentialsValid() { | |
1230 } | |
1231 | |
1232 void OneClickSigninHelper::OnStateChanged() { | 1245 void OneClickSigninHelper::OnStateChanged() { |
1233 // No redirect url after sync setup is set, thus no need to watch for sync | 1246 // No redirect url after sync setup is set, thus no need to watch for sync |
1234 // state changes. | 1247 // state changes. |
1235 if (redirect_url_.is_empty()) | 1248 if (redirect_url_.is_empty()) |
1236 return; | 1249 return; |
1237 | 1250 |
1238 content::WebContents* contents = web_contents(); | 1251 content::WebContents* contents = web_contents(); |
1239 Profile* profile = | 1252 Profile* profile = |
1240 Profile::FromBrowserContext(contents->GetBrowserContext()); | 1253 Profile::FromBrowserContext(contents->GetBrowserContext()); |
1241 ProfileSyncService* sync_service = | 1254 ProfileSyncService* sync_service = |
1242 ProfileSyncServiceFactory::GetForProfile(profile); | 1255 ProfileSyncServiceFactory::GetForProfile(profile); |
1243 | 1256 |
1244 // Sync setup not completed yet. | 1257 // Sync setup not completed yet. |
1245 if (sync_service->FirstSetupInProgress()) | 1258 if (sync_service->FirstSetupInProgress()) |
1246 return; | 1259 return; |
1247 | 1260 |
1248 if (sync_service->sync_initialized()) { | 1261 if (sync_service->sync_initialized()) { |
1249 contents->GetController().LoadURL(redirect_url_, | 1262 contents->GetController().LoadURL(redirect_url_, |
1250 content::Referrer(), | 1263 content::Referrer(), |
1251 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 1264 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
1252 std::string()); | 1265 std::string()); |
1253 } | 1266 } |
1254 | 1267 |
1255 // Clear the redirect URL. | 1268 // Clear the redirect URL. |
1256 redirect_url_ = GURL(); | 1269 redirect_url_ = GURL(); |
1257 sync_service->RemoveObserver(this); | 1270 sync_service->RemoveObserver(this); |
1258 } | 1271 } |
1259 | |
1260 void OneClickSigninHelper::SigninFailed(const GoogleServiceAuthError& error) { | |
1261 if (error_message_.empty() && !error.error_message().empty()) | |
1262 error_message_ = error.error_message(); | |
1263 | |
1264 bool display_bubble = true; | |
1265 if (error_message_.empty()) { | |
1266 switch (error.state()) { | |
1267 case GoogleServiceAuthError::NONE: | |
1268 error_message_.clear(); | |
1269 break; | |
1270 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: | |
1271 error_message_ = l10n_util::GetStringUTF8(IDS_SYNC_UNRECOVERABLE_ERROR); | |
1272 break; | |
1273 case GoogleServiceAuthError::REQUEST_CANCELED: | |
1274 // If the user cancelled signin, then no need to display any error | |
1275 // messages or anything - just go back to the NTP. | |
1276 error_message_.clear(); | |
1277 display_bubble = false; | |
1278 break; | |
1279 default: | |
1280 error_message_ = l10n_util::GetStringUTF8(IDS_SYNC_ERROR_SIGNING_IN); | |
1281 break; | |
1282 } | |
1283 } | |
1284 ShowSyncConfirmationBubble(display_bubble); | |
1285 signin_tracker_.reset(); | |
1286 } | |
1287 | |
1288 void OneClickSigninHelper::SigninSuccess() { | |
1289 ShowSyncConfirmationBubble(true); | |
1290 signin_tracker_.reset(); | |
1291 } | |
OLD | NEW |