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

Side by Side Diff: chrome/browser/ui/sync/one_click_signin_helper.cc

Issue 12395019: Merge 185407 (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1410/src/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 if (!web_contents) 889 if (!web_contents)
836 return; 890 return;
837 891
838 // TODO(mathp): The appearance of this infobar should be tested using a 892 // TODO(mathp): The appearance of this infobar should be tested using a
839 // browser_test. 893 // browser_test.
840 OneClickSigninHelper* helper = 894 OneClickSigninHelper* helper =
841 OneClickSigninHelper::FromWebContents(web_contents); 895 OneClickSigninHelper::FromWebContents(web_contents);
842 if (!helper) 896 if (!helper)
843 return; 897 return;
844 898
845 // Save the email in the one-click signin manager. The manager may
846 // not exist if the contents is incognito or if the profile is already
847 // connected to a Google account.
848 if (!session_index.empty())
849 helper->session_index_ = session_index;
850
851 if (!email.empty())
852 helper->email_ = email;
853
854 if (auto_accept != AUTO_ACCEPT_NONE) { 899 if (auto_accept != AUTO_ACCEPT_NONE) {
855 helper->auto_accept_ = auto_accept; 900 helper->auto_accept_ = auto_accept;
856 helper->source_ = source; 901 helper->source_ = source;
857 } 902 }
858 903
859 CanOfferFor can_offer_for = 904 CanOfferFor can_offer_for =
860 (auto_accept != AUTO_ACCEPT_EXPLICIT && 905 (auto_accept != AUTO_ACCEPT_EXPLICIT &&
861 helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ? 906 helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ?
862 CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL; 907 CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL;
863 std::string error_message; 908 std::string error_message;
864 909
865 if (!web_contents || !CanOffer(web_contents, can_offer_for, email, 910 if (!web_contents || !CanOffer(web_contents, can_offer_for, email,
866 &error_message)) { 911 &error_message)) {
867 VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering"; 912 VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering";
868 if (helper && helper->error_message_.empty() && !error_message.empty()) 913 if (helper && helper->error_message_.empty() && !error_message.empty())
869 helper->error_message_ = error_message; 914 helper->error_message_ = error_message;
870 915
871 return; 916 return;
872 } 917 }
873 918
919 // Save the email in the one-click signin manager. The manager may
920 // not exist if the contents is incognito or if the profile is already
921 // connected to a Google account.
922 if (!session_index.empty())
923 helper->session_index_ = session_index;
924
925 if (!email.empty())
926 helper->email_ = email;
927
874 if (continue_url.is_valid()) 928 if (continue_url.is_valid())
875 helper->continue_url_ = continue_url; 929 helper->continue_url_ = continue_url;
876 } 930 }
877 931
878 void OneClickSigninHelper::RedirectToNTP(bool show_bubble) { 932 void OneClickSigninHelper::RedirectToNTP(bool show_bubble) {
879 VLOG(1) << "OneClickSigninHelper::RedirectToNTP"; 933 VLOG(1) << "OneClickSigninHelper::RedirectToNTP";
880 934
881 // Redirect to NTP with sign in bubble visible. 935 // Redirect to NTP with sign in bubble visible.
882 content::WebContents* contents = web_contents(); 936 content::WebContents* contents = web_contents();
883 Profile* profile = 937 Profile* profile =
(...skipping 24 matching lines...) Expand all
908 962
909 content::WebContents* contents = web_contents(); 963 content::WebContents* contents = web_contents();
910 contents->GetController().LoadURL(page, 964 contents->GetController().LoadURL(page,
911 content::Referrer(), 965 content::Referrer(),
912 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 966 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
913 std::string()); 967 std::string());
914 } 968 }
915 969
916 void OneClickSigninHelper::CleanTransientState() { 970 void OneClickSigninHelper::CleanTransientState() {
917 VLOG(1) << "OneClickSigninHelper::CleanTransientState"; 971 VLOG(1) << "OneClickSigninHelper::CleanTransientState";
972 showing_signin_ = false;
918 email_.clear(); 973 email_.clear();
919 password_.clear(); 974 password_.clear();
920 auto_accept_ = AUTO_ACCEPT_NONE; 975 auto_accept_ = AUTO_ACCEPT_NONE;
921 source_ = SyncPromoUI::SOURCE_UNKNOWN; 976 source_ = SyncPromoUI::SOURCE_UNKNOWN;
977 switched_to_advanced_ = false;
978 original_source_ = SyncPromoUI::SOURCE_UNKNOWN;
922 continue_url_ = GURL(); 979 continue_url_ = GURL();
923 980
924 // Post to IO thread to clear pending email. 981 // Post to IO thread to clear pending email.
925 Profile* profile = 982 Profile* profile =
926 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); 983 Profile::FromBrowserContext(web_contents()->GetBrowserContext());
927 content::BrowserThread::PostTask( 984 content::BrowserThread::PostTask(
928 content::BrowserThread::IO, FROM_HERE, 985 content::BrowserThread::IO, FROM_HERE,
929 base::Bind(&ClearPendingEmailOnIOThread, 986 base::Bind(&ClearPendingEmailOnIOThread,
930 base::Unretained(profile->GetResourceContext()))); 987 base::Unretained(profile->GetResourceContext())));
931 } 988 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 1022
966 // 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
967 // 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
968 // explicit sign ins. 1025 // explicit sign ins.
969 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) { 1026 if (!error_message_.empty() && auto_accept_ == AUTO_ACCEPT_EXPLICIT) {
970 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_; 1027 VLOG(1) << "OneClickSigninHelper::DidStopLoading: error=" << error_message_;
971 RedirectToNTP(true); 1028 RedirectToNTP(true);
972 return; 1029 return;
973 } 1030 }
974 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
975 // 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
976 // extra query parameters. So ignore the parameters when checking to see 1043 // extra query parameters. So ignore the parameters when checking to see
977 // if the user has continued. 1044 // if the user has continued.
978 GURL::Replacements replacements; 1045 GURL::Replacements replacements;
979 replacements.ClearQuery(); 1046 replacements.ClearQuery();
980 const bool continue_url_match_accept = ( 1047 const bool continue_url_match_accept = (
981 auto_accept_ == AUTO_ACCEPT_EXPLICIT && 1048 auto_accept_ == AUTO_ACCEPT_EXPLICIT &&
982 continue_url_.is_valid() && 1049 continue_url_.is_valid() &&
983 url.ReplaceComponents(replacements) == 1050 url.ReplaceComponents(replacements) ==
984 continue_url_.ReplaceComponents(replacements)); 1051 continue_url_.ReplaceComponents(replacements));
985 1052
986 // 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.
987 if (email_.empty() || password_.empty()) { 1054 if (email_.empty() || password_.empty()) {
1055 VLOG(1) << "OneClickSigninHelper::DidStopLoading: nothing to do";
988 if (continue_url_match_accept) 1056 if (continue_url_match_accept)
989 RedirectToSignin(); 1057 RedirectToSignin();
990 std::string unused_value; 1058 std::string unused_value;
991 if (net::GetValueForKeyInQuery(url, "ntp", &unused_value)) 1059 if (net::GetValueForKeyInQuery(url, "ntp", &unused_value))
992 RedirectToNTP(false); 1060 RedirectToNTP(false);
993 return; 1061 return;
994 } 1062 }
995 1063
996 // 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
997 // 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
1031 // 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
1032 // 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
1033 // current source. 1101 // current source.
1034 // 1102 //
1035 // If the source was changed to SOURCE_SETTINGS, we want 1103 // If the source was changed to SOURCE_SETTINGS, we want
1036 // OneClickSigninSyncStarter to reuse the current tab to display the 1104 // OneClickSigninSyncStarter to reuse the current tab to display the
1037 // advanced configuration. 1105 // advanced configuration.
1038 SyncPromoUI::Source source = 1106 SyncPromoUI::Source source =
1039 SyncPromoUI::GetSourceForSyncPromoURL(url); 1107 SyncPromoUI::GetSourceForSyncPromoURL(url);
1040 if (source != source_) { 1108 if (source != source_) {
1109 original_source_ = source_;
1041 source_ = source; 1110 source_ = source;
1042 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;
1043 } 1113 }
1044 } 1114 }
1045 } 1115 }
1046 1116
1047 Browser* browser = chrome::FindBrowserWithWebContents(contents); 1117 Browser* browser = chrome::FindBrowserWithWebContents(contents);
1048 Profile* profile = 1118 Profile* profile =
1049 Profile::FromBrowserContext(contents->GetBrowserContext()); 1119 Profile::FromBrowserContext(contents->GetBrowserContext());
1050 1120
1051 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go." 1121 VLOG(1) << "OneClickSigninHelper::DidStopLoading: signin is go."
1052 << " auto_accept=" << auto_accept_ 1122 << " auto_accept=" << auto_accept_
1053 << " source=" << source_; 1123 << " source=" << source_;
1054 1124
1055 BrowserWindow::OneClickSigninBubbleType bubble_type; 1125 BrowserWindow::OneClickSigninBubbleType bubble_type;
1056 if (base::FieldTrialList::FindFullName(kSignInToChromeDialogFieldTrialName) == 1126 if (base::FieldTrialList::FindFullName(kSignInToChromeDialogFieldTrialName) ==
1057 kSignInConfirmBubbleGroupName) 1127 kSignInConfirmBubbleGroupName)
1058 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE; 1128 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE;
1059 else 1129 else
1060 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG; 1130 bubble_type = BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_MODAL_DIALOG;
1061 1131
1062 switch (auto_accept_) { 1132 switch (auto_accept_) {
1063 case AUTO_ACCEPT_NONE: 1133 case AUTO_ACCEPT_NONE:
1064 if (SyncPromoUI::UseWebBasedSigninFlow()) { 1134 if (SyncPromoUI::UseWebBasedSigninFlow()) {
1065 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", 1135 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_DISMISSED);
1066 one_click_signin::HISTOGRAM_DISMISSED,
1067 one_click_signin::HISTOGRAM_MAX);
1068 } else { 1136 } else {
1069 OneClickInfoBarDelegateImpl::Create( 1137 OneClickInfoBarDelegateImpl::Create(
1070 InfoBarService::FromWebContents(contents), session_index_, email_, 1138 InfoBarService::FromWebContents(contents), session_index_, email_,
1071 password_); 1139 password_);
1072 } 1140 }
1073 break; 1141 break;
1074 case AUTO_ACCEPT_ACCEPTED: 1142 case AUTO_ACCEPT_ACCEPTED:
1143 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED);
1144 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS);
1075 SigninManager::DisableOneClickSignIn(profile); 1145 SigninManager::DisableOneClickSignIn(profile);
1076 browser->window()->ShowOneClickSigninBubble( 1146 browser->window()->ShowOneClickSigninBubble(
1077 bubble_type, 1147 bubble_type,
1078 base::Bind(&StartSync, 1148 base::Bind(&StartSync,
1079 StartSyncArgs(profile, browser, auto_accept_, 1149 StartSyncArgs(profile, browser, auto_accept_,
1080 session_index_, email_, password_, 1150 session_index_, email_, password_,
1081 false /* force_same_tab_navigation */))); 1151 false /* force_same_tab_navigation */)));
1082 break; 1152 break;
1083 case AUTO_ACCEPT_CONFIGURE: 1153 case AUTO_ACCEPT_CONFIGURE:
1154 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED);
1155 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED);
1084 SigninManager::DisableOneClickSignIn(profile); 1156 SigninManager::DisableOneClickSignIn(profile);
1085 StartSync( 1157 StartSync(
1086 StartSyncArgs(profile, browser, auto_accept_, session_index_, email_, 1158 StartSyncArgs(profile, browser, auto_accept_, session_index_, email_,
1087 password_, false /* force_same_tab_navigation */), 1159 password_, false /* force_same_tab_navigation */),
1088 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); 1160 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST);
1089 break; 1161 break;
1090 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 }
1091 OneClickSigninSyncStarter::StartSyncMode start_mode = 1172 OneClickSigninSyncStarter::StartSyncMode start_mode =
1092 source_ == SyncPromoUI::SOURCE_SETTINGS ? 1173 source_ == SyncPromoUI::SOURCE_SETTINGS ?
1093 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : 1174 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST :
1094 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; 1175 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS;
1095 1176
1096 // 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
1097 // just signed in, show a confirmation dialog. 1178 // just signed in, show a confirmation dialog.
1098 std::string last_email = 1179 std::string last_email =
1099 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); 1180 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername);
1100 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
1134 // redirect back to webstore. 1215 // redirect back to webstore.
1135 if (source_ != SyncPromoUI::SOURCE_SETTINGS && 1216 if (source_ != SyncPromoUI::SOURCE_SETTINGS &&
1136 source_ != SyncPromoUI::SOURCE_WEBSTORE_INSTALL) { 1217 source_ != SyncPromoUI::SOURCE_WEBSTORE_INSTALL) {
1137 signin_tracker_.reset(new SigninTracker(profile, this)); 1218 signin_tracker_.reset(new SigninTracker(profile, this));
1138 RedirectToNTP(true); 1219 RedirectToNTP(true);
1139 } 1220 }
1140 break; 1221 break;
1141 } 1222 }
1142 case AUTO_ACCEPT_REJECTED_FOR_PROFILE: 1223 case AUTO_ACCEPT_REJECTED_FOR_PROFILE:
1143 AddEmailToOneClickRejectedList(profile, email_); 1224 AddEmailToOneClickRejectedList(profile, email_);
1144 UMA_HISTOGRAM_ENUMERATION("AutoLogin.Reverse", 1225 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_REJECTED);
1145 one_click_signin::HISTOGRAM_REJECTED,
1146 one_click_signin::HISTOGRAM_MAX);
1147 break; 1226 break;
1148 default: 1227 default:
1149 NOTREACHED() << "Invalid auto_accept=" << auto_accept_; 1228 NOTREACHED() << "Invalid auto_accept=" << auto_accept_;
1150 break; 1229 break;
1151 } 1230 }
1152 1231
1153 CleanTransientState(); 1232 CleanTransientState();
1154 } 1233 }
1155 1234
1156 void OneClickSigninHelper::GaiaCredentialsValid() { 1235 void OneClickSigninHelper::GaiaCredentialsValid() {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 } 1281 }
1203 } 1282 }
1204 1283
1205 RedirectToNTP(true); 1284 RedirectToNTP(true);
1206 signin_tracker_.reset(); 1285 signin_tracker_.reset();
1207 } 1286 }
1208 1287
1209 void OneClickSigninHelper::SigninSuccess() { 1288 void OneClickSigninHelper::SigninSuccess() {
1210 signin_tracker_.reset(); 1289 signin_tracker_.reset();
1211 } 1290 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698