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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "chrome/browser/tab_contents/tab_util.h" | 48 #include "chrome/browser/tab_contents/tab_util.h" |
49 #include "chrome/browser/ui/browser_finder.h" | 49 #include "chrome/browser/ui/browser_finder.h" |
50 #include "chrome/browser/ui/browser_window.h" | 50 #include "chrome/browser/ui/browser_window.h" |
51 #include "chrome/browser/ui/chrome_pages.h" | 51 #include "chrome/browser/ui/chrome_pages.h" |
52 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" | 52 #include "chrome/browser/ui/sync/one_click_signin_histogram.h" |
53 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" | 53 #include "chrome/browser/ui/sync/one_click_signin_sync_starter.h" |
54 #include "chrome/browser/ui/sync/signin_histogram.h" | 54 #include "chrome/browser/ui/sync/signin_histogram.h" |
55 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" | 55 #include "chrome/browser/ui/tab_modal_confirm_dialog.h" |
56 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" | 56 #include "chrome/browser/ui/tab_modal_confirm_dialog_delegate.h" |
57 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 57 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
58 #include "chrome/common/chrome_switches.h" | |
59 #include "chrome/common/chrome_version_info.h" | 58 #include "chrome/common/chrome_version_info.h" |
60 #include "chrome/common/net/url_util.h" | 59 #include "chrome/common/net/url_util.h" |
61 #include "chrome/common/pref_names.h" | 60 #include "chrome/common/pref_names.h" |
| 61 #include "chrome/common/profile_management_switches.h" |
62 #include "chrome/common/url_constants.h" | 62 #include "chrome/common/url_constants.h" |
63 #include "components/autofill/core/common/password_form.h" | 63 #include "components/autofill/core/common/password_form.h" |
64 #include "content/public/browser/browser_thread.h" | 64 #include "content/public/browser/browser_thread.h" |
65 #include "content/public/browser/navigation_entry.h" | 65 #include "content/public/browser/navigation_entry.h" |
66 #include "content/public/browser/page_navigator.h" | 66 #include "content/public/browser/page_navigator.h" |
67 #include "content/public/browser/render_process_host.h" | 67 #include "content/public/browser/render_process_host.h" |
68 #include "content/public/browser/web_contents.h" | 68 #include "content/public/browser/web_contents.h" |
69 #include "content/public/browser/web_contents_view.h" | 69 #include "content/public/browser/web_contents_view.h" |
70 #include "content/public/common/frame_navigate_params.h" | 70 #include "content/public/common/frame_navigate_params.h" |
71 #include "content/public/common/page_transition_types.h" | 71 #include "content/public/common/page_transition_types.h" |
(...skipping 17 matching lines...) Expand all Loading... |
89 | 89 |
90 // Arguments used with StartSync function. base::Bind() cannot support too | 90 // Arguments used with StartSync function. base::Bind() cannot support too |
91 // many args for performance reasons, so they are packaged up into a struct. | 91 // many args for performance reasons, so they are packaged up into a struct. |
92 struct StartSyncArgs { | 92 struct StartSyncArgs { |
93 StartSyncArgs(Profile* profile, | 93 StartSyncArgs(Profile* profile, |
94 Browser* browser, | 94 Browser* browser, |
95 OneClickSigninHelper::AutoAccept auto_accept, | 95 OneClickSigninHelper::AutoAccept auto_accept, |
96 const std::string& session_index, | 96 const std::string& session_index, |
97 const std::string& email, | 97 const std::string& email, |
98 const std::string& password, | 98 const std::string& password, |
| 99 const std::string& oauth_code, |
99 content::WebContents* web_contents, | 100 content::WebContents* web_contents, |
100 bool untrusted_confirmation_required, | 101 bool untrusted_confirmation_required, |
101 signin::Source source, | 102 signin::Source source, |
102 OneClickSigninSyncStarter::Callback callback); | 103 OneClickSigninSyncStarter::Callback callback); |
103 | 104 |
104 Profile* profile; | 105 Profile* profile; |
105 Browser* browser; | 106 Browser* browser; |
106 OneClickSigninHelper::AutoAccept auto_accept; | 107 OneClickSigninHelper::AutoAccept auto_accept; |
107 std::string session_index; | 108 std::string session_index; |
108 std::string email; | 109 std::string email; |
109 std::string password; | 110 std::string password; |
| 111 std::string oauth_code; |
110 | 112 |
111 // Web contents in which the sync setup page should be displayed, | 113 // Web contents in which the sync setup page should be displayed, |
112 // if necessary. Can be NULL. | 114 // if necessary. Can be NULL. |
113 content::WebContents* web_contents; | 115 content::WebContents* web_contents; |
114 | 116 |
115 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required; | 117 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required; |
116 signin::Source source; | 118 signin::Source source; |
117 OneClickSigninSyncStarter::Callback callback; | 119 OneClickSigninSyncStarter::Callback callback; |
118 }; | 120 }; |
119 | 121 |
120 StartSyncArgs::StartSyncArgs(Profile* profile, | 122 StartSyncArgs::StartSyncArgs(Profile* profile, |
121 Browser* browser, | 123 Browser* browser, |
122 OneClickSigninHelper::AutoAccept auto_accept, | 124 OneClickSigninHelper::AutoAccept auto_accept, |
123 const std::string& session_index, | 125 const std::string& session_index, |
124 const std::string& email, | 126 const std::string& email, |
125 const std::string& password, | 127 const std::string& password, |
| 128 const std::string& oauth_code, |
126 content::WebContents* web_contents, | 129 content::WebContents* web_contents, |
127 bool untrusted_confirmation_required, | 130 bool untrusted_confirmation_required, |
128 signin::Source source, | 131 signin::Source source, |
129 OneClickSigninSyncStarter::Callback callback) | 132 OneClickSigninSyncStarter::Callback callback) |
130 : profile(profile), | 133 : profile(profile), |
131 browser(browser), | 134 browser(browser), |
132 auto_accept(auto_accept), | 135 auto_accept(auto_accept), |
133 session_index(session_index), | 136 session_index(session_index), |
134 email(email), | 137 email(email), |
135 password(password), | 138 password(password), |
| 139 oauth_code(oauth_code), |
136 web_contents(web_contents), | 140 web_contents(web_contents), |
137 source(source), | 141 source(source), |
138 callback(callback) { | 142 callback(callback) { |
139 if (untrusted_confirmation_required) { | 143 if (untrusted_confirmation_required) { |
140 confirmation_required = OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN; | 144 confirmation_required = OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN; |
141 } else if (source == signin::SOURCE_SETTINGS || | 145 } else if (source == signin::SOURCE_SETTINGS || |
142 source == signin::SOURCE_WEBSTORE_INSTALL) { | 146 source == signin::SOURCE_WEBSTORE_INSTALL) { |
143 // Do not display a status confirmation for webstore installs or re-auth. | 147 // Do not display a status confirmation for webstore installs or re-auth. |
144 confirmation_required = OneClickSigninSyncStarter::NO_CONFIRMATION; | 148 confirmation_required = OneClickSigninSyncStarter::NO_CONFIRMATION; |
145 } else { | 149 } else { |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 void StartSync(const StartSyncArgs& args, | 373 void StartSync(const StartSyncArgs& args, |
370 OneClickSigninSyncStarter::StartSyncMode start_mode) { | 374 OneClickSigninSyncStarter::StartSyncMode start_mode) { |
371 if (start_mode == OneClickSigninSyncStarter::UNDO_SYNC) { | 375 if (start_mode == OneClickSigninSyncStarter::UNDO_SYNC) { |
372 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_UNDO); | 376 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_UNDO); |
373 return; | 377 return; |
374 } | 378 } |
375 | 379 |
376 // The starter deletes itself once its done. | 380 // The starter deletes itself once its done. |
377 new OneClickSigninSyncStarter(args.profile, args.browser, args.session_index, | 381 new OneClickSigninSyncStarter(args.profile, args.browser, args.session_index, |
378 args.email, args.password, | 382 args.email, args.password, |
379 "" /* oauth_code */, start_mode, | 383 args.oauth_code, start_mode, |
380 args.web_contents, | 384 args.web_contents, |
381 args.confirmation_required, | 385 args.confirmation_required, |
382 args.callback); | 386 args.callback); |
383 | 387 |
384 int action = one_click_signin::HISTOGRAM_MAX; | 388 int action = one_click_signin::HISTOGRAM_MAX; |
385 switch (args.auto_accept) { | 389 switch (args.auto_accept) { |
386 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: | 390 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: |
387 break; | 391 break; |
388 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: | 392 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: |
389 action = | 393 action = |
(...skipping 10 matching lines...) Expand all Loading... |
400 break; | 404 break; |
401 } | 405 } |
402 if (action != one_click_signin::HISTOGRAM_MAX) | 406 if (action != one_click_signin::HISTOGRAM_MAX) |
403 LogOneClickHistogramValue(action); | 407 LogOneClickHistogramValue(action); |
404 } | 408 } |
405 | 409 |
406 void StartExplicitSync(const StartSyncArgs& args, | 410 void StartExplicitSync(const StartSyncArgs& args, |
407 content::WebContents* contents, | 411 content::WebContents* contents, |
408 OneClickSigninSyncStarter::StartSyncMode start_mode, | 412 OneClickSigninSyncStarter::StartSyncMode start_mode, |
409 ConfirmEmailDialogDelegate::Action action) { | 413 ConfirmEmailDialogDelegate::Action action) { |
| 414 bool enable_inline = switches::IsEnableInlineSignin(); |
410 if (action == ConfirmEmailDialogDelegate::START_SYNC) { | 415 if (action == ConfirmEmailDialogDelegate::START_SYNC) { |
411 StartSync(args, start_mode); | 416 StartSync(args, start_mode); |
412 OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary( | 417 if (!enable_inline) { |
413 contents, args.source); | 418 // Redirect/tab closing for inline flow is handled by the sync callback. |
| 419 OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary( |
| 420 contents, args.source); |
| 421 } |
414 } else { | 422 } else { |
415 // Perform a redirection to the NTP/Apps page to hide the blank page when | 423 // Perform a redirection to the NTP/Apps page to hide the blank page when |
416 // the action is CLOSE or CREATE_NEW_USER. The redirection is useful when | 424 // the action is CLOSE or CREATE_NEW_USER. The redirection is useful when |
417 // the action is CREATE_NEW_USER because the "Create new user" page might | 425 // the action is CREATE_NEW_USER because the "Create new user" page might |
418 // be opened in a different tab that is already showing settings. | 426 // be opened in a different tab that is already showing settings. |
419 // | 427 if (enable_inline) { |
420 // Don't redirect when the visible URL is not a blank page: if the | 428 // Redirect/tab closing for inline flow is handled by the sync callback. |
421 // source is SOURCE_WEBSTORE_INSTALL, |contents| might be showing an app | 429 args.callback.Run(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); |
422 // page that shouldn't be hidden. | 430 } else { |
423 // | 431 // Don't redirect when the visible URL is not a blank page: if the |
424 // If redirecting, don't do so immediately, otherwise there may be 2 nested | 432 // source is SOURCE_WEBSTORE_INSTALL, |contents| might be showing an app |
425 // navigations and a crash would occur (crbug.com/293261). Post the task | 433 // page that shouldn't be hidden. |
426 // to the current thread instead. | 434 // |
427 if (signin::IsContinueUrlForWebBasedSigninFlow( | 435 // If redirecting, don't do so immediately, otherwise there may be 2 |
428 contents->GetVisibleURL())) { | 436 // nested navigations and a crash would occur (crbug.com/293261). Post |
429 base::MessageLoopProxy::current()->PostNonNestableTask( | 437 // the task to the current thread instead. |
430 FROM_HERE, | 438 if (signin::IsContinueUrlForWebBasedSigninFlow( |
431 base::Bind(RedirectToNtpOrAppsPageWithIds, | 439 contents->GetVisibleURL())) { |
432 contents->GetRenderProcessHost()->GetID(), | 440 base::MessageLoopProxy::current()->PostNonNestableTask( |
433 contents->GetRoutingID(), | 441 FROM_HERE, |
434 args.source)); | 442 base::Bind(RedirectToNtpOrAppsPageWithIds, |
| 443 contents->GetRenderProcessHost()->GetID(), |
| 444 contents->GetRoutingID(), |
| 445 args.source)); |
| 446 } |
435 } | 447 } |
436 if (action == ConfirmEmailDialogDelegate::CREATE_NEW_USER) { | 448 if (action == ConfirmEmailDialogDelegate::CREATE_NEW_USER) { |
437 chrome::ShowSettingsSubPage(args.browser, | 449 chrome::ShowSettingsSubPage(args.browser, |
438 std::string(chrome::kSearchUsersSubPage)); | 450 std::string(chrome::kSearchUsersSubPage)); |
439 } | 451 } |
440 } | 452 } |
441 } | 453 } |
442 | 454 |
443 void ClearPendingEmailOnIOThread(content::ResourceContext* context) { | 455 void ClearPendingEmailOnIOThread(content::ResourceContext* context) { |
444 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 456 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 } | 770 } |
759 | 771 |
760 VLOG(1) << "OneClickSigninHelper::CanOffer: yes we can"; | 772 VLOG(1) << "OneClickSigninHelper::CanOffer: yes we can"; |
761 return true; | 773 return true; |
762 } | 774 } |
763 | 775 |
764 // static | 776 // static |
765 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThread( | 777 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThread( |
766 net::URLRequest* request, | 778 net::URLRequest* request, |
767 ProfileIOData* io_data) { | 779 ProfileIOData* io_data) { |
768 return CanOfferOnIOThreadImpl(request->url(), request->referrer(), | 780 return CanOfferOnIOThreadImpl(request->url(), request, io_data); |
769 request, io_data); | |
770 } | 781 } |
771 | 782 |
772 // static | 783 // static |
773 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThreadImpl( | 784 OneClickSigninHelper::Offer OneClickSigninHelper::CanOfferOnIOThreadImpl( |
774 const GURL& url, | 785 const GURL& url, |
775 const std::string& referrer, | |
776 base::SupportsUserData* request, | 786 base::SupportsUserData* request, |
777 ProfileIOData* io_data) { | 787 ProfileIOData* io_data) { |
778 if (!gaia::IsGaiaSignonRealm(url.GetOrigin())) | 788 if (!gaia::IsGaiaSignonRealm(url.GetOrigin())) |
779 return IGNORE_REQUEST; | 789 return IGNORE_REQUEST; |
780 | 790 |
781 if (!io_data) | 791 if (!io_data) |
782 return DONT_OFFER; | 792 return DONT_OFFER; |
783 | 793 |
784 // Check for incognito before other parts of the io_data, since those | 794 // Check for incognito before other parts of the io_data, since those |
785 // members may not be initalized. | 795 // members may not be initalized. |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, | 1040 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, |
1031 base::string16(), /* no SAML email */ | 1041 base::string16(), /* no SAML email */ |
1032 UTF8ToUTF16(error), | 1042 UTF8ToUTF16(error), |
1033 // This callback is never invoked. | 1043 // This callback is never invoked. |
1034 // TODO(rogerta): Separate out the bubble API so we don't have to pass | 1044 // TODO(rogerta): Separate out the bubble API so we don't have to pass |
1035 // ignored |email| and |callback| params. | 1045 // ignored |email| and |callback| params. |
1036 BrowserWindow::StartSyncCallback()); | 1046 BrowserWindow::StartSyncCallback()); |
1037 } | 1047 } |
1038 | 1048 |
1039 // static | 1049 // static |
| 1050 bool OneClickSigninHelper::HandleCrossAccountError( |
| 1051 content::WebContents* contents, |
| 1052 const std::string& session_index, |
| 1053 const std::string& email, |
| 1054 const std::string& password, |
| 1055 const std::string& oauth_code, |
| 1056 OneClickSigninHelper::AutoAccept auto_accept, |
| 1057 signin::Source source, |
| 1058 OneClickSigninSyncStarter::StartSyncMode start_mode, |
| 1059 OneClickSigninSyncStarter::Callback sync_callback) { |
| 1060 Profile* profile = |
| 1061 Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 1062 std::string last_email = |
| 1063 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); |
| 1064 |
| 1065 if (!last_email.empty() && !gaia::AreEmailsSame(last_email, email)) { |
| 1066 // If the new email address is different from the email address that |
| 1067 // just signed in, show a confirmation dialog. |
| 1068 |
| 1069 // No need to display a second confirmation so pass false below. |
| 1070 // TODO(atwilson): Move this into OneClickSigninSyncStarter. |
| 1071 // The tab modal dialog always executes its callback before |contents| |
| 1072 // is deleted. |
| 1073 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
| 1074 ConfirmEmailDialogDelegate::AskForConfirmation( |
| 1075 contents, |
| 1076 last_email, |
| 1077 email, |
| 1078 base::Bind( |
| 1079 &StartExplicitSync, |
| 1080 StartSyncArgs(profile, browser, auto_accept, |
| 1081 session_index, email, password, oauth_code, contents, |
| 1082 false /* confirmation_required */, source, |
| 1083 sync_callback), |
| 1084 contents, |
| 1085 start_mode)); |
| 1086 return true; |
| 1087 } |
| 1088 |
| 1089 return false; |
| 1090 } |
| 1091 |
| 1092 // static |
1040 void OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary( | 1093 void OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary( |
1041 content::WebContents* contents, signin::Source source) { | 1094 content::WebContents* contents, signin::Source source) { |
1042 if (source != signin::SOURCE_SETTINGS && | 1095 if (source != signin::SOURCE_SETTINGS && |
1043 source != signin::SOURCE_WEBSTORE_INSTALL) { | 1096 source != signin::SOURCE_WEBSTORE_INSTALL) { |
1044 RedirectToNtpOrAppsPage(contents, source); | 1097 RedirectToNtpOrAppsPage(contents, source); |
1045 } | 1098 } |
1046 } | 1099 } |
1047 | 1100 |
1048 void OneClickSigninHelper::RedirectToSignin() { | 1101 void OneClickSigninHelper::RedirectToSignin() { |
1049 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; | 1102 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1105 void OneClickSigninHelper::DidStartNavigationToPendingEntry( | 1158 void OneClickSigninHelper::DidStartNavigationToPendingEntry( |
1106 const GURL& url, | 1159 const GURL& url, |
1107 content::NavigationController::ReloadType reload_type) { | 1160 content::NavigationController::ReloadType reload_type) { |
1108 VLOG(1) << "OneClickSigninHelper::DidStartNavigationToPendingEntry: url=" << | 1161 VLOG(1) << "OneClickSigninHelper::DidStartNavigationToPendingEntry: url=" << |
1109 url.spec(); | 1162 url.spec(); |
1110 // If the tab navigates to a new page, and this page is not a valid Gaia | 1163 // If the tab navigates to a new page, and this page is not a valid Gaia |
1111 // sign in redirect or reponse, or the expected continue URL, make sure to | 1164 // sign in redirect or reponse, or the expected continue URL, make sure to |
1112 // clear the internal state. This is needed to detect navigations in the | 1165 // clear the internal state. This is needed to detect navigations in the |
1113 // middle of the sign in process that may redirect back to the sign in | 1166 // middle of the sign in process that may redirect back to the sign in |
1114 // process (see crbug.com/181163 for details). | 1167 // process (see crbug.com/181163 for details). |
1115 const GURL continue_url = signin::GetNextPageURLForPromoURL( | |
1116 signin::GetPromoURL(signin::SOURCE_START_PAGE, false)); | |
1117 GURL::Replacements replacements; | 1168 GURL::Replacements replacements; |
1118 replacements.ClearQuery(); | 1169 replacements.ClearQuery(); |
1119 | 1170 |
1120 if (!IsValidGaiaSigninRedirectOrResponseURL(url) && | 1171 if (!IsValidGaiaSigninRedirectOrResponseURL(url) && |
1121 continue_url_.is_valid() && | 1172 continue_url_.is_valid() && |
1122 url.ReplaceComponents(replacements) != | 1173 url.ReplaceComponents(replacements) != |
1123 continue_url_.ReplaceComponents(replacements)) { | 1174 continue_url_.ReplaceComponents(replacements)) { |
1124 if (++untrusted_navigations_since_signin_visit_ > kMaxNavigationsSince) | 1175 if (++untrusted_navigations_since_signin_visit_ > kMaxNavigationsSince) |
1125 CleanTransientState(); | 1176 CleanTransientState(); |
1126 } | 1177 } |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 case AUTO_ACCEPT_ACCEPTED: | 1337 case AUTO_ACCEPT_ACCEPTED: |
1287 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | 1338 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); |
1288 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); | 1339 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); |
1289 SigninManager::DisableOneClickSignIn(profile); | 1340 SigninManager::DisableOneClickSignIn(profile); |
1290 // Start syncing with the default settings - prompt the user to sign in | 1341 // Start syncing with the default settings - prompt the user to sign in |
1291 // first. | 1342 // first. |
1292 if (!do_not_start_sync_for_testing_) { | 1343 if (!do_not_start_sync_for_testing_) { |
1293 StartSync( | 1344 StartSync( |
1294 StartSyncArgs(profile, browser, auto_accept_, | 1345 StartSyncArgs(profile, browser, auto_accept_, |
1295 session_index_, email_, password_, | 1346 session_index_, email_, password_, |
| 1347 "" /* oauth_code */, |
1296 NULL /* don't force to show sync setup in same tab */, | 1348 NULL /* don't force to show sync setup in same tab */, |
1297 true /* confirmation_required */, source_, | 1349 true /* confirmation_required */, source_, |
1298 CreateSyncStarterCallback()), | 1350 CreateSyncStarterCallback()), |
1299 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); | 1351 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
1300 } | 1352 } |
1301 break; | 1353 break; |
1302 case AUTO_ACCEPT_CONFIGURE: | 1354 case AUTO_ACCEPT_CONFIGURE: |
1303 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | 1355 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); |
1304 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); | 1356 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); |
1305 SigninManager::DisableOneClickSignIn(profile); | 1357 SigninManager::DisableOneClickSignIn(profile); |
1306 // Display the extra confirmation (even in the SAML case) in case this | 1358 // Display the extra confirmation (even in the SAML case) in case this |
1307 // was an untrusted renderer. | 1359 // was an untrusted renderer. |
1308 if (!do_not_start_sync_for_testing_) { | 1360 if (!do_not_start_sync_for_testing_) { |
1309 StartSync( | 1361 StartSync( |
1310 StartSyncArgs(profile, browser, auto_accept_, | 1362 StartSyncArgs(profile, browser, auto_accept_, |
1311 session_index_, email_, password_, | 1363 session_index_, email_, password_, |
| 1364 "" /* oauth_code */, |
1312 NULL /* don't force sync setup in same tab */, | 1365 NULL /* don't force sync setup in same tab */, |
1313 true /* confirmation_required */, source_, | 1366 true /* confirmation_required */, source_, |
1314 CreateSyncStarterCallback()), | 1367 CreateSyncStarterCallback()), |
1315 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 1368 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
1316 } | 1369 } |
1317 break; | 1370 break; |
1318 case AUTO_ACCEPT_EXPLICIT: { | 1371 case AUTO_ACCEPT_EXPLICIT: { |
1319 signin::Source original_source = | 1372 signin::Source original_source = |
1320 signin::GetSourceForPromoURL(original_continue_url_); | 1373 signin::GetSourceForPromoURL(original_continue_url_); |
1321 if (switched_to_advanced_) { | 1374 if (switched_to_advanced_) { |
(...skipping 15 matching lines...) Expand all Loading... |
1337 ProfileSyncService* sync_service = | 1390 ProfileSyncService* sync_service = |
1338 ProfileSyncServiceFactory::GetForProfile(profile); | 1391 ProfileSyncServiceFactory::GetForProfile(profile); |
1339 OneClickSigninSyncStarter::StartSyncMode start_mode = | 1392 OneClickSigninSyncStarter::StartSyncMode start_mode = |
1340 source_ == signin::SOURCE_SETTINGS ? | 1393 source_ == signin::SOURCE_SETTINGS ? |
1341 (SigninGlobalError::GetForProfile(profile)->HasMenuItem() && | 1394 (SigninGlobalError::GetForProfile(profile)->HasMenuItem() && |
1342 sync_service && sync_service->HasSyncSetupCompleted()) ? | 1395 sync_service && sync_service->HasSyncSetupCompleted()) ? |
1343 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : | 1396 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : |
1344 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : | 1397 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : |
1345 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; | 1398 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; |
1346 | 1399 |
1347 std::string last_email = | 1400 if (!HandleCrossAccountError(contents, session_index_, email_, password_, |
1348 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); | 1401 "" /* oauth_code */, auto_accept_, source_, start_mode, |
1349 | 1402 CreateSyncStarterCallback())) { |
1350 if (!last_email.empty() && !gaia::AreEmailsSame(last_email, email_)) { | |
1351 // If the new email address is different from the email address that | |
1352 // just signed in, show a confirmation dialog. | |
1353 | |
1354 // No need to display a second confirmation so pass false below. | |
1355 // TODO(atwilson): Move this into OneClickSigninSyncStarter. | |
1356 // The tab modal dialog always executes its callback before |contents| | |
1357 // is deleted. | |
1358 ConfirmEmailDialogDelegate::AskForConfirmation( | |
1359 contents, | |
1360 last_email, | |
1361 email_, | |
1362 base::Bind( | |
1363 &StartExplicitSync, | |
1364 StartSyncArgs(profile, browser, auto_accept_, | |
1365 session_index_, email_, password_, contents, | |
1366 false /* confirmation_required */, source_, | |
1367 CreateSyncStarterCallback()), | |
1368 contents, | |
1369 start_mode)); | |
1370 } else { | |
1371 if (!do_not_start_sync_for_testing_) { | 1403 if (!do_not_start_sync_for_testing_) { |
1372 StartSync( | 1404 StartSync( |
1373 StartSyncArgs(profile, browser, auto_accept_, | 1405 StartSyncArgs(profile, browser, auto_accept_, |
1374 session_index_, email_, password_, contents, | 1406 session_index_, email_, password_, |
| 1407 "" /* oauth_code */, contents, |
1375 untrusted_confirmation_required_, source_, | 1408 untrusted_confirmation_required_, source_, |
1376 CreateSyncStarterCallback()), | 1409 CreateSyncStarterCallback()), |
1377 start_mode); | 1410 start_mode); |
1378 } | 1411 } |
1379 | 1412 |
1380 // If this explicit sign in is not from settings page/webstore, show | 1413 // If this explicit sign in is not from settings page/webstore, show |
1381 // the NTP/Apps page after sign in completes. In the case of the | 1414 // the NTP/Apps page after sign in completes. In the case of the |
1382 // settings page, it will get auto-closed after sync setup. In the case | 1415 // settings page, it will get auto-closed after sync setup. In the case |
1383 // of webstore, it will redirect back to webstore. | 1416 // of webstore, it will redirect back to webstore. |
1384 RedirectToNtpOrAppsPageIfNecessary(web_contents(), source_); | 1417 RedirectToNtpOrAppsPageIfNecessary(web_contents(), source_); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 // If the web contents is showing a blank page and not about to be closed, | 1515 // If the web contents is showing a blank page and not about to be closed, |
1483 // redirect to the NTP or apps page. | 1516 // redirect to the NTP or apps page. |
1484 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && | 1517 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && |
1485 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { | 1518 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { |
1486 RedirectToNtpOrAppsPage( | 1519 RedirectToNtpOrAppsPage( |
1487 web_contents(), | 1520 web_contents(), |
1488 signin::GetSourceForPromoURL(original_continue_url_)); | 1521 signin::GetSourceForPromoURL(original_continue_url_)); |
1489 } | 1522 } |
1490 } | 1523 } |
1491 } | 1524 } |
OLD | NEW |