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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // Add a specific email to the list of emails rejected for one-click | 84 // Add a specific email to the list of emails rejected for one-click |
85 // sign-in, for this profile. | 85 // sign-in, for this profile. |
86 void AddEmailToOneClickRejectedList(Profile* profile, | 86 void AddEmailToOneClickRejectedList(Profile* profile, |
87 const std::string& email) { | 87 const std::string& email) { |
88 PrefService* pref_service = profile->GetPrefs(); | 88 PrefService* pref_service = profile->GetPrefs(); |
89 ListPrefUpdate updater(pref_service, | 89 ListPrefUpdate updater(pref_service, |
90 prefs::kReverseAutologinRejectedEmailList); | 90 prefs::kReverseAutologinRejectedEmailList); |
91 updater->AppendIfNotPresent(new base::StringValue(email)); | 91 updater->AppendIfNotPresent(new base::StringValue(email)); |
92 } | 92 } |
93 | 93 |
| 94 void LogHistogramValue(SyncPromoUI::Source source, int action) { |
| 95 switch (source) { |
| 96 case SyncPromoUI::SOURCE_START_PAGE: |
| 97 UMA_HISTOGRAM_ENUMERATION("Signin.StartPageActions", action, |
| 98 one_click_signin::HISTOGRAM_MAX); |
| 99 break; |
| 100 case SyncPromoUI::SOURCE_NTP_LINK: |
| 101 UMA_HISTOGRAM_ENUMERATION("Signin.NTPLinkActions", action, |
| 102 one_click_signin::HISTOGRAM_MAX); |
| 103 break; |
| 104 case SyncPromoUI::SOURCE_MENU: |
| 105 UMA_HISTOGRAM_ENUMERATION("Signin.MenuActions", action, |
| 106 one_click_signin::HISTOGRAM_MAX); |
| 107 break; |
| 108 case SyncPromoUI::SOURCE_SETTINGS: |
| 109 UMA_HISTOGRAM_ENUMERATION("Signin.SettingsActions", action, |
| 110 one_click_signin::HISTOGRAM_MAX); |
| 111 break; |
| 112 case SyncPromoUI::SOURCE_EXTENSION_INSTALL_BUBBLE: |
| 113 UMA_HISTOGRAM_ENUMERATION("Signin.ExtensionInstallBubbleActions", action, |
| 114 one_click_signin::HISTOGRAM_MAX); |
| 115 break; |
| 116 case SyncPromoUI::SOURCE_WEBSTORE_INSTALL: |
| 117 UMA_HISTOGRAM_ENUMERATION("Signin.WebstoreInstallActions", action, |
| 118 one_click_signin::HISTOGRAM_MAX); |
| 119 break; |
| 120 case SyncPromoUI::SOURCE_APP_LAUNCHER: |
| 121 UMA_HISTOGRAM_ENUMERATION("Signin.AppLauncherActions", action, |
| 122 one_click_signin::HISTOGRAM_MAX); |
| 123 break; |
| 124 default: |
| 125 NOTREACHED() << "Invalid Source"; |
| 126 return; |
| 127 } |
| 128 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, |
| 129 one_click_signin::HISTOGRAM_MAX); |
| 130 } |
| 131 |
| 132 void LogOneClickHistogramValue(int action) { |
| 133 UMA_HISTOGRAM_ENUMERATION("Signin.OneClickActions", action, |
| 134 one_click_signin::HISTOGRAM_MAX); |
| 135 UMA_HISTOGRAM_ENUMERATION("Signin.AllAccessPointActions", action, |
| 136 one_click_signin::HISTOGRAM_MAX); |
| 137 } |
| 138 |
94 // Arguments used with StartSync function. base::Bind() cannot support too | 139 // Arguments used with StartSync function. base::Bind() cannot support too |
95 // many args for performance reasons, so they are packaged up into a struct. | 140 // many args for performance reasons, so they are packaged up into a struct. |
96 struct StartSyncArgs { | 141 struct StartSyncArgs { |
97 StartSyncArgs(Profile* profile, | 142 StartSyncArgs(Profile* profile, |
98 Browser* browser, | 143 Browser* browser, |
99 OneClickSigninHelper::AutoAccept auto_accept, | 144 OneClickSigninHelper::AutoAccept auto_accept, |
100 const std::string& session_index, | 145 const std::string& session_index, |
101 const std::string& email, | 146 const std::string& email, |
102 const std::string& password, | 147 const std::string& password, |
103 bool force_same_tab_navigation) | 148 bool force_same_tab_navigation) |
(...skipping 12 matching lines...) Expand all Loading... |
116 std::string session_index; | 161 std::string session_index; |
117 std::string email; | 162 std::string email; |
118 std::string password; | 163 std::string password; |
119 bool force_same_tab_navigation; | 164 bool force_same_tab_navigation; |
120 }; | 165 }; |
121 | 166 |
122 // Start syncing with the given user information. | 167 // Start syncing with the given user information. |
123 void StartSync(const StartSyncArgs& args, | 168 void StartSync(const StartSyncArgs& args, |
124 OneClickSigninSyncStarter::StartSyncMode start_mode) { | 169 OneClickSigninSyncStarter::StartSyncMode start_mode) { |
125 if (start_mode == OneClickSigninSyncStarter::UNDO_SYNC) { | 170 if (start_mode == OneClickSigninSyncStarter::UNDO_SYNC) { |
126 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", | 171 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_UNDO); |
127 one_click_signin::HISTOGRAM_UNDO, | |
128 one_click_signin::HISTOGRAM_MAX); | |
129 return; | 172 return; |
130 } | 173 } |
131 // The starter deletes itself once its done. | 174 // The starter deletes itself once its done. |
132 new OneClickSigninSyncStarter(args.profile, args.browser, args.session_index, | 175 new OneClickSigninSyncStarter(args.profile, args.browser, args.session_index, |
133 args.email, args.password, start_mode, | 176 args.email, args.password, start_mode, |
134 args.force_same_tab_navigation); | 177 args.force_same_tab_navigation); |
135 | 178 |
136 int action = one_click_signin::HISTOGRAM_MAX; | 179 int action = one_click_signin::HISTOGRAM_MAX; |
137 switch (args.auto_accept) { | 180 switch (args.auto_accept) { |
138 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: | 181 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: |
| 182 break; |
| 183 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: |
139 action = | 184 action = |
140 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? | 185 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? |
141 one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS : | 186 one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS : |
142 one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; | 187 one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; |
143 break; | 188 break; |
144 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: | |
145 action = one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS; | 189 action = one_click_signin::HISTOGRAM_AUTO_WITH_DEFAULTS; |
146 break; | 190 break; |
147 case OneClickSigninHelper::AUTO_ACCEPT_NONE: | |
148 action = | |
149 start_mode == OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS ? | |
150 one_click_signin::HISTOGRAM_WITH_DEFAULTS : | |
151 one_click_signin::HISTOGRAM_WITH_ADVANCED; | |
152 break; | |
153 case OneClickSigninHelper::AUTO_ACCEPT_CONFIGURE: | 191 case OneClickSigninHelper::AUTO_ACCEPT_CONFIGURE: |
154 DCHECK(start_mode == OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 192 DCHECK(start_mode == OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
155 action = one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; | 193 action = one_click_signin::HISTOGRAM_AUTO_WITH_ADVANCED; |
156 break; | 194 break; |
157 default: | 195 default: |
158 NOTREACHED() << "Invalid auto_accept: " << args.auto_accept; | 196 NOTREACHED() << "Invalid auto_accept: " << args.auto_accept; |
159 break; | 197 break; |
160 } | 198 } |
161 | 199 if (action != one_click_signin::HISTOGRAM_MAX) |
162 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, | 200 LogOneClickHistogramValue(action); |
163 one_click_signin::HISTOGRAM_MAX); | |
164 } | 201 } |
165 | 202 |
166 void StartExplicitSync(const StartSyncArgs& args, | 203 void StartExplicitSync(const StartSyncArgs& args, |
167 content::WebContents* contents, | 204 content::WebContents* contents, |
168 OneClickSigninSyncStarter::StartSyncMode start_mode, | 205 OneClickSigninSyncStarter::StartSyncMode start_mode, |
169 int button) { | 206 int button) { |
170 if (button == IDS_ONE_CLICK_SIGNIN_CONFIRM_EMAIL_DIALOG_OK_BUTTON) { | 207 if (button == IDS_ONE_CLICK_SIGNIN_CONFIRM_EMAIL_DIALOG_OK_BUTTON) { |
171 contents->GetController().LoadURL( | 208 contents->GetController().LoadURL( |
172 GURL(chrome::kChromeUINewTabURL), content::Referrer(), | 209 GURL(chrome::kChromeUINewTabURL), content::Referrer(), |
173 content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); | 210 content::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string()); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 content::WebContents* contents, | 357 content::WebContents* contents, |
321 const std::string& last_email, | 358 const std::string& last_email, |
322 const std::string& email, | 359 const std::string& email, |
323 Callback callback) | 360 Callback callback) |
324 : TabModalConfirmDialogDelegate(contents), | 361 : TabModalConfirmDialogDelegate(contents), |
325 last_email_(last_email), | 362 last_email_(last_email), |
326 email_(email), | 363 email_(email), |
327 callback_(callback) { | 364 callback_(callback) { |
328 } | 365 } |
329 | 366 |
| 367 // Tells when we are in the process of showing either the signin to chrome page |
| 368 // or the one click sign in to chrome page. |
| 369 bool AreWeShowingSignin(GURL url, SyncPromoUI::Source source, |
| 370 std::string email) { |
| 371 GURL::Replacements replacements; |
| 372 replacements.ClearQuery(); |
| 373 GURL clean_login_url = |
| 374 GURL(GaiaUrls::GetInstance()->service_login_url()).ReplaceComponents( |
| 375 replacements); |
| 376 |
| 377 return (url.ReplaceComponents(replacements) == clean_login_url && |
| 378 source != SyncPromoUI::SOURCE_UNKNOWN) || !email.empty(); |
| 379 } |
| 380 |
330 } // namespace | 381 } // namespace |
331 | 382 |
332 // The infobar asking the user if they want to use one-click sign in. | 383 // The infobar asking the user if they want to use one-click sign in. |
333 // TODO(rogerta): once we move to a web-based sign in flow, we can get rid | 384 // TODO(rogerta): once we move to a web-based sign in flow, we can get rid |
334 // of this infobar. | 385 // of this infobar. |
335 class OneClickInfoBarDelegateImpl : public OneClickSigninInfoBarDelegate { | 386 class OneClickInfoBarDelegateImpl : public OneClickSigninInfoBarDelegate { |
336 public: | 387 public: |
337 // Creates a one click signin delegate and adds it to |infobar_service|. | 388 // Creates a one click signin delegate and adds it to |infobar_service|. |
338 static void Create(InfoBarService* infobar_service, | 389 static void Create(InfoBarService* infobar_service, |
339 const std::string& session_index, | 390 const std::string& session_index, |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 return OneClickSigninInfoBarDelegate::GetAlternateColors(alt_colors); | 546 return OneClickSigninInfoBarDelegate::GetAlternateColors(alt_colors); |
496 } | 547 } |
497 | 548 |
498 void OneClickInfoBarDelegateImpl::RecordHistogramAction(int action) { | 549 void OneClickInfoBarDelegateImpl::RecordHistogramAction(int action) { |
499 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, | 550 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, |
500 one_click_signin::HISTOGRAM_MAX); | 551 one_click_signin::HISTOGRAM_MAX); |
501 } | 552 } |
502 | 553 |
503 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) | 554 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents) |
504 : content::WebContentsObserver(web_contents), | 555 : content::WebContentsObserver(web_contents), |
| 556 showing_signin_(false), |
505 auto_accept_(AUTO_ACCEPT_NONE), | 557 auto_accept_(AUTO_ACCEPT_NONE), |
506 source_(SyncPromoUI::SOURCE_UNKNOWN) { | 558 source_(SyncPromoUI::SOURCE_UNKNOWN), |
| 559 switched_to_advanced_(false), |
| 560 original_source_(SyncPromoUI::SOURCE_UNKNOWN) { |
507 } | 561 } |
508 | 562 |
509 OneClickSigninHelper::~OneClickSigninHelper() { | 563 OneClickSigninHelper::~OneClickSigninHelper() { |
510 content::WebContents* contents = web_contents(); | 564 content::WebContents* contents = web_contents(); |
511 if (contents) { | 565 if (contents) { |
512 Profile* profile = | 566 Profile* profile = |
513 Profile::FromBrowserContext(contents->GetBrowserContext()); | 567 Profile::FromBrowserContext(contents->GetBrowserContext()); |
514 ProfileSyncService* sync_service = | 568 ProfileSyncService* sync_service = |
515 ProfileSyncServiceFactory::GetForProfile(profile); | 569 ProfileSyncServiceFactory::GetForProfile(profile); |
516 if (sync_service && sync_service->HasObserver(this)) | 570 if (sync_service && sync_service->HasObserver(this)) |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
833 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, | 887 content::WebContents* web_contents = tab_util::GetWebContentsByID(child_id, |
834 route_id); | 888 route_id); |
835 | 889 |
836 // TODO(mathp): The appearance of this infobar should be tested using a | 890 // TODO(mathp): The appearance of this infobar should be tested using a |
837 // browser_test. | 891 // browser_test. |
838 OneClickSigninHelper* helper = | 892 OneClickSigninHelper* helper = |
839 OneClickSigninHelper::FromWebContents(web_contents); | 893 OneClickSigninHelper::FromWebContents(web_contents); |
840 if (!helper) | 894 if (!helper) |
841 return; | 895 return; |
842 | 896 |
843 // Save the email in the one-click signin manager. The manager may | |
844 // not exist if the contents is incognito or if the profile is already | |
845 // connected to a Google account. | |
846 if (!session_index.empty()) | |
847 helper->session_index_ = session_index; | |
848 | |
849 if (!email.empty()) | |
850 helper->email_ = email; | |
851 | |
852 if (auto_accept != AUTO_ACCEPT_NONE) { | 897 if (auto_accept != AUTO_ACCEPT_NONE) { |
853 helper->auto_accept_ = auto_accept; | 898 helper->auto_accept_ = auto_accept; |
854 helper->source_ = source; | 899 helper->source_ = source; |
855 } | 900 } |
856 | 901 |
857 CanOfferFor can_offer_for = | 902 CanOfferFor can_offer_for = |
858 (auto_accept != AUTO_ACCEPT_EXPLICIT && | 903 (auto_accept != AUTO_ACCEPT_EXPLICIT && |
859 helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ? | 904 helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ? |
860 CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL; | 905 CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL; |
861 std::string error_message; | 906 std::string error_message; |
862 | 907 |
863 if (!web_contents || !CanOffer(web_contents, can_offer_for, email, | 908 if (!web_contents || !CanOffer(web_contents, can_offer_for, email, |
864 &error_message)) { | 909 &error_message)) { |
865 VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering"; | 910 VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering"; |
866 if (helper && helper->error_message_.empty() && !error_message.empty()) | 911 if (helper && helper->error_message_.empty() && !error_message.empty()) |
867 helper->error_message_ = error_message; | 912 helper->error_message_ = error_message; |
868 | 913 |
869 return; | 914 return; |
870 } | 915 } |
871 | 916 |
| 917 // Save the email in the one-click signin manager. The manager may |
| 918 // not exist if the contents is incognito or if the profile is already |
| 919 // connected to a Google account. |
| 920 if (!session_index.empty()) |
| 921 helper->session_index_ = session_index; |
| 922 |
| 923 if (!email.empty()) |
| 924 helper->email_ = email; |
| 925 |
872 if (continue_url.is_valid()) | 926 if (continue_url.is_valid()) |
873 helper->continue_url_ = continue_url; | 927 helper->continue_url_ = continue_url; |
874 } | 928 } |
875 | 929 |
876 void OneClickSigninHelper::RedirectToNTP(bool show_bubble) { | 930 void OneClickSigninHelper::RedirectToNTP(bool show_bubble) { |
877 VLOG(1) << "OneClickSigninHelper::RedirectToNTP"; | 931 VLOG(1) << "OneClickSigninHelper::RedirectToNTP"; |
878 | 932 |
879 // Redirect to NTP with sign in bubble visible. | 933 // Redirect to NTP with sign in bubble visible. |
880 content::WebContents* contents = web_contents(); | 934 content::WebContents* contents = web_contents(); |
881 Profile* profile = | 935 Profile* profile = |
(...skipping 27 matching lines...) Expand all Loading... |
909 | 963 |
910 content::WebContents* contents = web_contents(); | 964 content::WebContents* contents = web_contents(); |
911 contents->GetController().LoadURL(page, | 965 contents->GetController().LoadURL(page, |
912 content::Referrer(), | 966 content::Referrer(), |
913 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 967 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
914 std::string()); | 968 std::string()); |
915 } | 969 } |
916 | 970 |
917 void OneClickSigninHelper::CleanTransientState() { | 971 void OneClickSigninHelper::CleanTransientState() { |
918 VLOG(1) << "OneClickSigninHelper::CleanTransientState"; | 972 VLOG(1) << "OneClickSigninHelper::CleanTransientState"; |
| 973 showing_signin_ = false; |
919 email_.clear(); | 974 email_.clear(); |
920 password_.clear(); | 975 password_.clear(); |
921 auto_accept_ = AUTO_ACCEPT_NONE; | 976 auto_accept_ = AUTO_ACCEPT_NONE; |
922 source_ = SyncPromoUI::SOURCE_UNKNOWN; | 977 source_ = SyncPromoUI::SOURCE_UNKNOWN; |
| 978 switched_to_advanced_ = false; |
| 979 original_source_ = SyncPromoUI::SOURCE_UNKNOWN; |
923 continue_url_ = GURL(); | 980 continue_url_ = GURL(); |
924 | 981 |
925 // Post to IO thread to clear pending email. | 982 // Post to IO thread to clear pending email. |
926 Profile* profile = | 983 Profile* profile = |
927 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 984 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
928 content::BrowserThread::PostTask( | 985 content::BrowserThread::PostTask( |
929 content::BrowserThread::IO, FROM_HERE, | 986 content::BrowserThread::IO, FROM_HERE, |
930 base::Bind(&ClearPendingEmailOnIOThread, | 987 base::Bind(&ClearPendingEmailOnIOThread, |
931 base::Unretained(profile->GetResourceContext()))); | 988 base::Unretained(profile->GetResourceContext()))); |
932 } | 989 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 | 1023 |
967 // If an error has already occured during the sign in flow, make sure to | 1024 // If an error has already occured during the sign in flow, make sure to |
968 // display it to the user and abort the process. Do this only for | 1025 // display it to the user and abort the process. Do this only for |
969 // explicit sign ins. | 1026 // explicit sign ins. |
970 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) { | 1027 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) { |
971 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_; | 1028 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_; |
972 RedirectToNTP(true); | 1029 RedirectToNTP(true); |
973 return; | 1030 return; |
974 } | 1031 } |
975 | 1032 |
| 1033 if (AreWeShowingSignin(url, source_, email_)) { |
| 1034 if (!showing_signin_) { |
| 1035 if (source_ == SyncPromoUI::SOURCE_UNKNOWN) |
| 1036 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_SHOWN); |
| 1037 else |
| 1038 LogHistogramValue(source_, one_click_signin::HISTOGRAM_SHOWN); |
| 1039 } |
| 1040 showing_signin_ = true; |
| 1041 } |
| 1042 |
976 // When Gaia finally redirects to the continue URL, Gaia will add some | 1043 // When Gaia finally redirects to the continue URL, Gaia will add some |
977 // extra query parameters. So ignore the parameters when checking to see | 1044 // extra query parameters. So ignore the parameters when checking to see |
978 // if the user has continued. | 1045 // if the user has continued. |
979 GURL::Replacements replacements; | 1046 GURL::Replacements replacements; |
980 replacements.ClearQuery(); | 1047 replacements.ClearQuery(); |
981 const bool continue_url_match_accept = ( | 1048 const bool continue_url_match_accept = ( |
982 auto_accept_ == AUTO_ACCEPT_EXPLICIT && | 1049 auto_accept_ == AUTO_ACCEPT_EXPLICIT && |
983 continue_url_.is_valid() && | 1050 continue_url_.is_valid() && |
984 url.ReplaceComponents(replacements) == | 1051 url.ReplaceComponents(replacements) == |
985 continue_url_.ReplaceComponents(replacements)); | 1052 continue_url_.ReplaceComponents(replacements)); |
986 | 1053 |
987 // If there is no valid email or password yet, there is nothing to do. | 1054 // If there is no valid email or password yet, there is nothing to do. |
988 if (email_.empty() || password_.empty()) { | 1055 if (email_.empty() || password_.empty()) { |
| 1056 VLOG(1) << "OneClickSigninHelper::DidStopLoading: nothing to do"; |
989 if (continue_url_match_accept) | 1057 if (continue_url_match_accept) |
990 RedirectToSignin(); | 1058 RedirectToSignin(); |
991 std::string unused_value; | 1059 std::string unused_value; |
992 if (net::GetValueForKeyInQuery(url, "ntp", &unused_value)) | 1060 if (net::GetValueForKeyInQuery(url, "ntp", &unused_value)) |
993 RedirectToNTP(false); | 1061 RedirectToNTP(false); |
994 return; | 1062 return; |
995 } | 1063 } |
996 | 1064 |
997 // When the user uses the first-run, ntp, or hotdog menu to sign in, then have | 1065 // When the user uses the first-run, ntp, or hotdog menu to sign in, then have |
998 // the option of checking the the box "Let me choose what to sync". When the | 1066 // the option of checking the the box "Let me choose what to sync". When the |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1032 // source of the continue URL. Make one last check of the current URL | 1100 // source of the continue URL. Make one last check of the current URL |
1033 // to see if there is a valid source. If so, it overrides the | 1101 // to see if there is a valid source. If so, it overrides the |
1034 // current source. | 1102 // current source. |
1035 // | 1103 // |
1036 // If the source was changed to SOURCE_SETTINGS, we want | 1104 // If the source was changed to SOURCE_SETTINGS, we want |
1037 // OneClickSigninSyncStarter to reuse the current tab to display the | 1105 // OneClickSigninSyncStarter to reuse the current tab to display the |
1038 // advanced configuration. | 1106 // advanced configuration. |
1039 SyncPromoUI::Source source = | 1107 SyncPromoUI::Source source = |
1040 SyncPromoUI::GetSourceForSyncPromoURL(url); | 1108 SyncPromoUI::GetSourceForSyncPromoURL(url); |
1041 if (source != source_) { | 1109 if (source != source_) { |
| 1110 original_source_ = source_; |
1042 source_ = source; | 1111 source_ = source; |
1043 force_same_tab_navigation = source_ == SyncPromoUI::SOURCE_SETTINGS; | 1112 force_same_tab_navigation = source == SyncPromoUI::SOURCE_SETTINGS; |
| 1113 switched_to_advanced_ = source == SyncPromoUI::SOURCE_SETTINGS; |
1044 } | 1114 } |
1045 } | 1115 } |
1046 } | 1116 } |
1047 | 1117 |
1048 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 1118 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
1049 Profile* profile = | 1119 Profile* profile = |
1050 Profile::FromBrowserContext(contents->GetBrowserContext()); | 1120 Profile::FromBrowserContext(contents->GetBrowserContext()); |
1051 | 1121 |
1052 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." | 1122 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." |
1053 << " auto_accept=" << auto_accept_ | 1123 << " auto_accept=" << auto_accept_ |
1054 << " source=" << source_; | 1124 << " source=" << source_; |
1055 | 1125 |
1056 BrowserWindow::OneClickSigninBubbleType bubble_type; | 1126 BrowserWindow::OneClickSigninBubbleType bubble_type; |
1057 if (base::FieldTrialList::FindFullName(kSignInToChromeDialogFieldTrialName) == | 1127 if (base::FieldTrialList::FindFullName(kSignInToChromeDialogFieldTrialName) == |
1058 kSignInConfirmBubbleGroupName) | 1128 kSignInConfirmBubbleGroupName) |
1059 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE; | 1129 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE; |
1060 else | 1130 else |
1061 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG; | 1131 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG; |
1062 | 1132 |
1063 switch (auto_accept_) { | 1133 switch (auto_accept_) { |
1064 case AUTO_ACCEPT_NONE: | 1134 case AUTO_ACCEPT_NONE: |
1065 if (SyncPromoUI::UseWebBasedSigninFlow()) { | 1135 if (SyncPromoUI::UseWebBasedSigninFlow()) { |
1066 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", | 1136 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_DISMISSED); |
1067 one_click_signin::HISTOGRAM_DISMISSED, | |
1068 one_click_signin::HISTOGRAM_MAX); | |
1069 } else { | 1137 } else { |
1070 OneClickInfoBarDelegateImpl::Create( | 1138 OneClickInfoBarDelegateImpl::Create( |
1071 InfoBarService::FromWebContents(contents), session_index_, email_, | 1139 InfoBarService::FromWebContents(contents), session_index_, email_, |
1072 password_); | 1140 password_); |
1073 } | 1141 } |
1074 break; | 1142 break; |
1075 case AUTO_ACCEPT_ACCEPTED: | 1143 case AUTO_ACCEPT_ACCEPTED: |
| 1144 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); |
| 1145 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); |
1076 SigninManager::DisableOneClickSignIn(profile); | 1146 SigninManager::DisableOneClickSignIn(profile); |
1077 browser->window()->ShowOneClickSigninBubble( | 1147 browser->window()->ShowOneClickSigninBubble( |
1078 bubble_type, | 1148 bubble_type, |
1079 base::Bind(&StartSync, | 1149 base::Bind(&StartSync, |
1080 StartSyncArgs(profile, browser, auto_accept_, | 1150 StartSyncArgs(profile, browser, auto_accept_, |
1081 session_index_, email_, password_, | 1151 session_index_, email_, password_, |
1082 false /* force_same_tab_navigation */))); | 1152 false /* force_same_tab_navigation */))); |
1083 break; | 1153 break; |
1084 case AUTO_ACCEPT_CONFIGURE: | 1154 case AUTO_ACCEPT_CONFIGURE: |
| 1155 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); |
| 1156 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); |
1085 SigninManager::DisableOneClickSignIn(profile); | 1157 SigninManager::DisableOneClickSignIn(profile); |
1086 StartSync( | 1158 StartSync( |
1087 StartSyncArgs(profile, browser, auto_accept_, session_index_, email_, | 1159 StartSyncArgs(profile, browser, auto_accept_, session_index_, email_, |
1088 password_, false /* force_same_tab_navigation */), | 1160 password_, false /* force_same_tab_navigation */), |
1089 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 1161 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
1090 break; | 1162 break; |
1091 case AUTO_ACCEPT_EXPLICIT: { | 1163 case AUTO_ACCEPT_EXPLICIT: { |
| 1164 if (switched_to_advanced_) { |
| 1165 LogHistogramValue(original_source_, |
| 1166 one_click_signin::HISTOGRAM_WITH_ADVANCED); |
| 1167 LogHistogramValue(original_source_, |
| 1168 one_click_signin::HISTOGRAM_ACCEPTED); |
| 1169 } else { |
| 1170 LogHistogramValue(source_, one_click_signin::HISTOGRAM_ACCEPTED); |
| 1171 LogHistogramValue(source_, one_click_signin::HISTOGRAM_WITH_DEFAULTS); |
| 1172 } |
1092 OneClickSigninSyncStarter::StartSyncMode start_mode = | 1173 OneClickSigninSyncStarter::StartSyncMode start_mode = |
1093 source_ == SyncPromoUI::SOURCE_SETTINGS ? | 1174 source_ == SyncPromoUI::SOURCE_SETTINGS ? |
1094 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : | 1175 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : |
1095 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; | 1176 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; |
1096 | 1177 |
1097 // If the new email address is different from the email address that | 1178 // If the new email address is different from the email address that |
1098 // just signed in, show a confirmation dialog. | 1179 // just signed in, show a confirmation dialog. |
1099 std::string last_email = | 1180 std::string last_email = |
1100 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); | 1181 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); |
1101 if (!last_email.empty() && last_email != email_) { | 1182 if (!last_email.empty() && last_email != email_) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1135 // redirect back to webstore. | 1216 // redirect back to webstore. |
1136 if (source_ != SyncPromoUI::SOURCE_SETTINGS && | 1217 if (source_ != SyncPromoUI::SOURCE_SETTINGS && |
1137 source_ != SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { | 1218 source_ != SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { |
1138 signin_tracker_.reset(new SigninTracker(profile, this)); | 1219 signin_tracker_.reset(new SigninTracker(profile, this)); |
1139 RedirectToNTP(true); | 1220 RedirectToNTP(true); |
1140 } | 1221 } |
1141 break; | 1222 break; |
1142 } | 1223 } |
1143 case AUTO_ACCEPT_REJECTED_FOR_PROFILE: | 1224 case AUTO_ACCEPT_REJECTED_FOR_PROFILE: |
1144 AddEmailToOneClickRejectedList(profile, email_); | 1225 AddEmailToOneClickRejectedList(profile, email_); |
1145 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", | 1226 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_REJECTED); |
1146 one_click_signin::HISTOGRAM_REJECTED, | |
1147 one_click_signin::HISTOGRAM_MAX); | |
1148 break; | 1227 break; |
1149 default: | 1228 default: |
1150 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; | 1229 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; |
1151 break; | 1230 break; |
1152 } | 1231 } |
1153 | 1232 |
1154 CleanTransientState(); | 1233 CleanTransientState(); |
1155 } | 1234 } |
1156 | 1235 |
1157 void OneClickSigninHelper::GaiaCredentialsValid() { | 1236 void OneClickSigninHelper::GaiaCredentialsValid() { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 } | 1282 } |
1204 } | 1283 } |
1205 | 1284 |
1206 RedirectToNTP(true); | 1285 RedirectToNTP(true); |
1207 signin_tracker_.reset(); | 1286 signin_tracker_.reset(); |
1208 } | 1287 } |
1209 | 1288 |
1210 void OneClickSigninHelper::SigninSuccess() { | 1289 void OneClickSigninHelper::SigninSuccess() { |
1211 signin_tracker_.reset(); | 1290 signin_tracker_.reset(); |
1212 } | 1291 } |
OLD | NEW |