Chromium Code Reviews| 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 (args.auto_accept != OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT) |
| 162 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", action, | 200 LogOneClickHistogramValue(action); |
|
Roger Tawa OOO till Jul 10th
2013/02/28 20:54:27
Nit: would it be better to check:
action !=
jwd
2013/02/28 21:01:49
Ya, that's nicer.
Done.
| |
| 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; | |
|
Roger Tawa OOO till Jul 10th
2013/02/28 20:54:27
Set original_source_ back to unknown.
jwd
2013/02/28 21:01:49
Done.
| |
| 923 continue_url_ = GURL(); | 979 continue_url_ = GURL(); |
| 924 | 980 |
| 925 // Post to IO thread to clear pending email. | 981 // Post to IO thread to clear pending email. |
| 926 Profile* profile = | 982 Profile* profile = |
| 927 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 983 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 928 content::BrowserThread::PostTask( | 984 content::BrowserThread::PostTask( |
| 929 content::BrowserThread::IO, FROM_HERE, | 985 content::BrowserThread::IO, FROM_HERE, |
| 930 base::Bind(&ClearPendingEmailOnIOThread, | 986 base::Bind(&ClearPendingEmailOnIOThread, |
| 931 base::Unretained(profile->GetResourceContext()))); | 987 base::Unretained(profile->GetResourceContext()))); |
| 932 } | 988 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 966 | 1022 |
| 967 // If an error has already occured during the sign in flow, make sure to | 1023 // 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 | 1024 // display it to the user and abort the process. Do this only for |
| 969 // explicit sign ins. | 1025 // explicit sign ins. |
| 970 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) { | 1026 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) { |
| 971 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_; | 1027 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_; |
| 972 RedirectToNTP(true); | 1028 RedirectToNTP(true); |
| 973 return; | 1029 return; |
| 974 } | 1030 } |
| 975 | 1031 |
| 1032 if (AreWeShowingSignin(url, source_, email_)) { | |
| 1033 if (!showing_signin_) { | |
| 1034 if (source_ == SyncPromoUI::SOURCE_UNKNOWN) | |
| 1035 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_SHOWN); | |
| 1036 else | |
| 1037 LogHistogramValue(source_, one_click_signin::HISTOGRAM_SHOWN); | |
| 1038 } | |
| 1039 showing_signin_ = true; | |
| 1040 } | |
| 1041 | |
| 976 // When Gaia finally redirects to the continue URL, Gaia will add some | 1042 // When Gaia finally redirects to the continue URL, Gaia will add some |
| 977 // extra query parameters. So ignore the parameters when checking to see | 1043 // extra query parameters. So ignore the parameters when checking to see |
| 978 // if the user has continued. | 1044 // if the user has continued. |
| 979 GURL::Replacements replacements; | 1045 GURL::Replacements replacements; |
| 980 replacements.ClearQuery(); | 1046 replacements.ClearQuery(); |
| 981 const bool continue_url_match_accept = ( | 1047 const bool continue_url_match_accept = ( |
| 982 auto_accept_ == AUTO_ACCEPT_EXPLICIT && | 1048 auto_accept_ == AUTO_ACCEPT_EXPLICIT && |
| 983 continue_url_.is_valid() && | 1049 continue_url_.is_valid() && |
| 984 url.ReplaceComponents(replacements) == | 1050 url.ReplaceComponents(replacements) == |
| 985 continue_url_.ReplaceComponents(replacements)); | 1051 continue_url_.ReplaceComponents(replacements)); |
| 986 | 1052 |
| 987 // If there is no valid email or password yet, there is nothing to do. | 1053 // If there is no valid email or password yet, there is nothing to do. |
| 988 if (email_.empty() || password_.empty()) { | 1054 if (email_.empty() || password_.empty()) { |
| 1055 VLOG(1) << "OneClickSigninHelper::DidStopLoading: nothing to do"; | |
| 989 if (continue_url_match_accept) | 1056 if (continue_url_match_accept) |
| 990 RedirectToSignin(); | 1057 RedirectToSignin(); |
| 991 std::string unused_value; | 1058 std::string unused_value; |
| 992 if (net::GetValueForKeyInQuery(url, "ntp", &unused_value)) | 1059 if (net::GetValueForKeyInQuery(url, "ntp", &unused_value)) |
| 993 RedirectToNTP(false); | 1060 RedirectToNTP(false); |
| 994 return; | 1061 return; |
| 995 } | 1062 } |
| 996 | 1063 |
| 997 // When the user uses the first-run, ntp, or hotdog menu to sign in, then have | 1064 // 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 | 1065 // 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 | 1099 // 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 | 1100 // to see if there is a valid source. If so, it overrides the |
| 1034 // current source. | 1101 // current source. |
| 1035 // | 1102 // |
| 1036 // If the source was changed to SOURCE_SETTINGS, we want | 1103 // If the source was changed to SOURCE_SETTINGS, we want |
| 1037 // OneClickSigninSyncStarter to reuse the current tab to display the | 1104 // OneClickSigninSyncStarter to reuse the current tab to display the |
| 1038 // advanced configuration. | 1105 // advanced configuration. |
| 1039 SyncPromoUI::Source source = | 1106 SyncPromoUI::Source source = |
| 1040 SyncPromoUI::GetSourceForSyncPromoURL(url); | 1107 SyncPromoUI::GetSourceForSyncPromoURL(url); |
| 1041 if (source != source_) { | 1108 if (source != source_) { |
| 1109 original_source_ = source_; | |
| 1042 source_ = source; | 1110 source_ = source; |
| 1043 force_same_tab_navigation = source_ == SyncPromoUI::SOURCE_SETTINGS; | 1111 force_same_tab_navigation = source == SyncPromoUI::SOURCE_SETTINGS; |
| 1112 switched_to_advanced_ = source == SyncPromoUI::SOURCE_SETTINGS; | |
| 1044 } | 1113 } |
| 1045 } | 1114 } |
| 1046 } | 1115 } |
| 1047 | 1116 |
| 1048 Browser* browser = chrome::FindBrowserWithWebContents(contents); | 1117 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
| 1049 Profile* profile = | 1118 Profile* profile = |
| 1050 Profile::FromBrowserContext(contents->GetBrowserContext()); | 1119 Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 1051 | 1120 |
| 1052 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." | 1121 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." |
| 1053 << " auto_accept=" << auto_accept_ | 1122 << " auto_accept=" << auto_accept_ |
| 1054 << " source=" << source_; | 1123 << " source=" << source_; |
| 1055 | 1124 |
| 1056 BrowserWindow::OneClickSigninBubbleType bubble_type; | 1125 BrowserWindow::OneClickSigninBubbleType bubble_type; |
| 1057 if (base::FieldTrialList::FindFullName(kSignInToChromeDialogFieldTrialName) == | 1126 if (base::FieldTrialList::FindFullName(kSignInToChromeDialogFieldTrialName) == |
| 1058 kSignInConfirmBubbleGroupName) | 1127 kSignInConfirmBubbleGroupName) |
| 1059 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE; | 1128 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE; |
| 1060 else | 1129 else |
| 1061 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG; | 1130 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG; |
| 1062 | 1131 |
| 1063 switch (auto_accept_) { | 1132 switch (auto_accept_) { |
| 1064 case AUTO_ACCEPT_NONE: | 1133 case AUTO_ACCEPT_NONE: |
| 1065 if (SyncPromoUI::UseWebBasedSigninFlow()) { | 1134 if (SyncPromoUI::UseWebBasedSigninFlow()) { |
| 1066 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", | 1135 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_DISMISSED); |
| 1067 one_click_signin::HISTOGRAM_DISMISSED, | |
| 1068 one_click_signin::HISTOGRAM_MAX); | |
| 1069 } else { | 1136 } else { |
| 1070 OneClickInfoBarDelegateImpl::Create( | 1137 OneClickInfoBarDelegateImpl::Create( |
| 1071 InfoBarService::FromWebContents(contents), session_index_, email_, | 1138 InfoBarService::FromWebContents(contents), session_index_, email_, |
| 1072 password_); | 1139 password_); |
| 1073 } | 1140 } |
| 1074 break; | 1141 break; |
| 1075 case AUTO_ACCEPT_ACCEPTED: | 1142 case AUTO_ACCEPT_ACCEPTED: |
| 1143 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | |
| 1144 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); | |
| 1076 SigninManager::DisableOneClickSignIn(profile); | 1145 SigninManager::DisableOneClickSignIn(profile); |
| 1077 browser->window()->ShowOneClickSigninBubble( | 1146 browser->window()->ShowOneClickSigninBubble( |
| 1078 bubble_type, | 1147 bubble_type, |
| 1079 base::Bind(&StartSync, | 1148 base::Bind(&StartSync, |
| 1080 StartSyncArgs(profile, browser, auto_accept_, | 1149 StartSyncArgs(profile, browser, auto_accept_, |
| 1081 session_index_, email_, password_, | 1150 session_index_, email_, password_, |
| 1082 false /* force_same_tab_navigation */))); | 1151 false /* force_same_tab_navigation */))); |
| 1083 break; | 1152 break; |
| 1084 case AUTO_ACCEPT_CONFIGURE: | 1153 case AUTO_ACCEPT_CONFIGURE: |
| 1154 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | |
| 1155 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); | |
| 1085 SigninManager::DisableOneClickSignIn(profile); | 1156 SigninManager::DisableOneClickSignIn(profile); |
| 1086 StartSync( | 1157 StartSync( |
| 1087 StartSyncArgs(profile, browser, auto_accept_, session_index_, email_, | 1158 StartSyncArgs(profile, browser, auto_accept_, session_index_, email_, |
| 1088 password_, false /* force_same_tab_navigation */), | 1159 password_, false /* force_same_tab_navigation */), |
| 1089 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 1160 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
| 1090 break; | 1161 break; |
| 1091 case AUTO_ACCEPT_EXPLICIT: { | 1162 case AUTO_ACCEPT_EXPLICIT: { |
| 1163 if (switched_to_advanced_) { | |
| 1164 LogHistogramValue(original_source_, | |
| 1165 one_click_signin::HISTOGRAM_WITH_ADVANCED); | |
| 1166 LogHistogramValue(original_source_, | |
| 1167 one_click_signin::HISTOGRAM_ACCEPTED); | |
| 1168 } else { | |
| 1169 LogHistogramValue(source_, one_click_signin::HISTOGRAM_ACCEPTED); | |
| 1170 LogHistogramValue(source_, one_click_signin::HISTOGRAM_WITH_DEFAULTS); | |
| 1171 } | |
| 1092 OneClickSigninSyncStarter::StartSyncMode start_mode = | 1172 OneClickSigninSyncStarter::StartSyncMode start_mode = |
| 1093 source_ == SyncPromoUI::SOURCE_SETTINGS ? | 1173 source_ == SyncPromoUI::SOURCE_SETTINGS ? |
| 1094 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : | 1174 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : |
| 1095 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; | 1175 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; |
| 1096 | 1176 |
| 1097 // If the new email address is different from the email address that | 1177 // If the new email address is different from the email address that |
| 1098 // just signed in, show a confirmation dialog. | 1178 // just signed in, show a confirmation dialog. |
| 1099 std::string last_email = | 1179 std::string last_email = |
| 1100 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); | 1180 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); |
| 1101 if (!last_email.empty() && last_email != email_) { | 1181 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. | 1215 // redirect back to webstore. |
| 1136 if (source_ != SyncPromoUI::SOURCE_SETTINGS && | 1216 if (source_ != SyncPromoUI::SOURCE_SETTINGS && |
| 1137 source_ != SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { | 1217 source_ != SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { |
| 1138 signin_tracker_.reset(new SigninTracker(profile, this)); | 1218 signin_tracker_.reset(new SigninTracker(profile, this)); |
| 1139 RedirectToNTP(true); | 1219 RedirectToNTP(true); |
| 1140 } | 1220 } |
| 1141 break; | 1221 break; |
| 1142 } | 1222 } |
| 1143 case AUTO_ACCEPT_REJECTED_FOR_PROFILE: | 1223 case AUTO_ACCEPT_REJECTED_FOR_PROFILE: |
| 1144 AddEmailToOneClickRejectedList(profile, email_); | 1224 AddEmailToOneClickRejectedList(profile, email_); |
| 1145 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", | 1225 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_REJECTED); |
| 1146 one_click_signin::HISTOGRAM_REJECTED, | |
| 1147 one_click_signin::HISTOGRAM_MAX); | |
| 1148 break; | 1226 break; |
| 1149 default: | 1227 default: |
| 1150 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; | 1228 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; |
| 1151 break; | 1229 break; |
| 1152 } | 1230 } |
| 1153 | 1231 |
| 1154 CleanTransientState(); | 1232 CleanTransientState(); |
| 1155 } | 1233 } |
| 1156 | 1234 |
| 1157 void OneClickSigninHelper::GaiaCredentialsValid() { | 1235 void OneClickSigninHelper::GaiaCredentialsValid() { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1203 } | 1281 } |
| 1204 } | 1282 } |
| 1205 | 1283 |
| 1206 RedirectToNTP(true); | 1284 RedirectToNTP(true); |
| 1207 signin_tracker_.reset(); | 1285 signin_tracker_.reset(); |
| 1208 } | 1286 } |
| 1209 | 1287 |
| 1210 void OneClickSigninHelper::SigninSuccess() { | 1288 void OneClickSigninHelper::SigninSuccess() { |
| 1211 signin_tracker_.reset(); | 1289 signin_tracker_.reset(); |
| 1212 } | 1290 } |
| OLD | NEW |