| 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> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
| 14 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
| 15 #include "base/command_line.h" |
| 15 #include "base/compiler_specific.h" | 16 #include "base/compiler_specific.h" |
| 16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/message_loop/message_loop_proxy.h" | 18 #include "base/message_loop/message_loop_proxy.h" |
| 18 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
| 19 #include "base/metrics/histogram.h" | 20 #include "base/metrics/histogram.h" |
| 20 #include "base/prefs/pref_service.h" | 21 #include "base/prefs/pref_service.h" |
| 21 #include "base/prefs/scoped_user_pref_update.h" | 22 #include "base/prefs/scoped_user_pref_update.h" |
| 22 #include "base/strings/string_split.h" | 23 #include "base/strings/string_split.h" |
| 23 #include "base/strings/string_util.h" | 24 #include "base/strings/string_util.h" |
| 24 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 90 |
| 90 // Arguments used with StartSync function. base::Bind() cannot support too | 91 // Arguments used with StartSync function. base::Bind() cannot support too |
| 91 // many args for performance reasons, so they are packaged up into a struct. | 92 // many args for performance reasons, so they are packaged up into a struct. |
| 92 struct StartSyncArgs { | 93 struct StartSyncArgs { |
| 93 StartSyncArgs(Profile* profile, | 94 StartSyncArgs(Profile* profile, |
| 94 Browser* browser, | 95 Browser* browser, |
| 95 OneClickSigninHelper::AutoAccept auto_accept, | 96 OneClickSigninHelper::AutoAccept auto_accept, |
| 96 const std::string& session_index, | 97 const std::string& session_index, |
| 97 const std::string& email, | 98 const std::string& email, |
| 98 const std::string& password, | 99 const std::string& password, |
| 100 const std::string& oauth_code, |
| 99 content::WebContents* web_contents, | 101 content::WebContents* web_contents, |
| 100 bool untrusted_confirmation_required, | 102 bool untrusted_confirmation_required, |
| 101 signin::Source source, | 103 signin::Source source, |
| 102 OneClickSigninSyncStarter::Callback callback); | 104 OneClickSigninSyncStarter::Callback callback); |
| 103 | 105 |
| 104 Profile* profile; | 106 Profile* profile; |
| 105 Browser* browser; | 107 Browser* browser; |
| 106 OneClickSigninHelper::AutoAccept auto_accept; | 108 OneClickSigninHelper::AutoAccept auto_accept; |
| 107 std::string session_index; | 109 std::string session_index; |
| 108 std::string email; | 110 std::string email; |
| 109 std::string password; | 111 std::string password; |
| 112 std::string oauth_code; |
| 110 | 113 |
| 111 // Web contents in which the sync setup page should be displayed, | 114 // Web contents in which the sync setup page should be displayed, |
| 112 // if necessary. Can be NULL. | 115 // if necessary. Can be NULL. |
| 113 content::WebContents* web_contents; | 116 content::WebContents* web_contents; |
| 114 | 117 |
| 115 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required; | 118 OneClickSigninSyncStarter::ConfirmationRequired confirmation_required; |
| 116 signin::Source source; | 119 signin::Source source; |
| 117 OneClickSigninSyncStarter::Callback callback; | 120 OneClickSigninSyncStarter::Callback callback; |
| 118 }; | 121 }; |
| 119 | 122 |
| 120 StartSyncArgs::StartSyncArgs(Profile* profile, | 123 StartSyncArgs::StartSyncArgs(Profile* profile, |
| 121 Browser* browser, | 124 Browser* browser, |
| 122 OneClickSigninHelper::AutoAccept auto_accept, | 125 OneClickSigninHelper::AutoAccept auto_accept, |
| 123 const std::string& session_index, | 126 const std::string& session_index, |
| 124 const std::string& email, | 127 const std::string& email, |
| 125 const std::string& password, | 128 const std::string& password, |
| 129 const std::string& oauth_code, |
| 126 content::WebContents* web_contents, | 130 content::WebContents* web_contents, |
| 127 bool untrusted_confirmation_required, | 131 bool untrusted_confirmation_required, |
| 128 signin::Source source, | 132 signin::Source source, |
| 129 OneClickSigninSyncStarter::Callback callback) | 133 OneClickSigninSyncStarter::Callback callback) |
| 130 : profile(profile), | 134 : profile(profile), |
| 131 browser(browser), | 135 browser(browser), |
| 132 auto_accept(auto_accept), | 136 auto_accept(auto_accept), |
| 133 session_index(session_index), | 137 session_index(session_index), |
| 134 email(email), | 138 email(email), |
| 135 password(password), | 139 password(password), |
| 140 oauth_code(oauth_code), |
| 136 web_contents(web_contents), | 141 web_contents(web_contents), |
| 137 source(source), | 142 source(source), |
| 138 callback(callback) { | 143 callback(callback) { |
| 139 if (untrusted_confirmation_required) { | 144 if (untrusted_confirmation_required) { |
| 140 confirmation_required = OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN; | 145 confirmation_required = OneClickSigninSyncStarter::CONFIRM_UNTRUSTED_SIGNIN; |
| 141 } else if (source == signin::SOURCE_SETTINGS || | 146 } else if (source == signin::SOURCE_SETTINGS || |
| 142 source == signin::SOURCE_WEBSTORE_INSTALL) { | 147 source == signin::SOURCE_WEBSTORE_INSTALL) { |
| 143 // Do not display a status confirmation for webstore installs or re-auth. | 148 // Do not display a status confirmation for webstore installs or re-auth. |
| 144 confirmation_required = OneClickSigninSyncStarter::NO_CONFIRMATION; | 149 confirmation_required = OneClickSigninSyncStarter::NO_CONFIRMATION; |
| 145 } else { | 150 } else { |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 void StartSync(const StartSyncArgs& args, | 374 void StartSync(const StartSyncArgs& args, |
| 370 OneClickSigninSyncStarter::StartSyncMode start_mode) { | 375 OneClickSigninSyncStarter::StartSyncMode start_mode) { |
| 371 if (start_mode == OneClickSigninSyncStarter::UNDO_SYNC) { | 376 if (start_mode == OneClickSigninSyncStarter::UNDO_SYNC) { |
| 372 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_UNDO); | 377 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_UNDO); |
| 373 return; | 378 return; |
| 374 } | 379 } |
| 375 | 380 |
| 376 // The starter deletes itself once its done. | 381 // The starter deletes itself once its done. |
| 377 new OneClickSigninSyncStarter(args.profile, args.browser, args.session_index, | 382 new OneClickSigninSyncStarter(args.profile, args.browser, args.session_index, |
| 378 args.email, args.password, | 383 args.email, args.password, |
| 379 "" /* oauth_code */, start_mode, | 384 args.oauth_code, start_mode, |
| 380 args.web_contents, | 385 args.web_contents, |
| 381 args.confirmation_required, | 386 args.confirmation_required, |
| 382 args.callback); | 387 args.callback); |
| 383 | 388 |
| 384 int action = one_click_signin::HISTOGRAM_MAX; | 389 int action = one_click_signin::HISTOGRAM_MAX; |
| 385 switch (args.auto_accept) { | 390 switch (args.auto_accept) { |
| 386 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: | 391 case OneClickSigninHelper::AUTO_ACCEPT_EXPLICIT: |
| 387 break; | 392 break; |
| 388 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: | 393 case OneClickSigninHelper::AUTO_ACCEPT_ACCEPTED: |
| 389 action = | 394 action = |
| (...skipping 10 matching lines...) Expand all Loading... |
| 400 break; | 405 break; |
| 401 } | 406 } |
| 402 if (action != one_click_signin::HISTOGRAM_MAX) | 407 if (action != one_click_signin::HISTOGRAM_MAX) |
| 403 LogOneClickHistogramValue(action); | 408 LogOneClickHistogramValue(action); |
| 404 } | 409 } |
| 405 | 410 |
| 406 void StartExplicitSync(const StartSyncArgs& args, | 411 void StartExplicitSync(const StartSyncArgs& args, |
| 407 content::WebContents* contents, | 412 content::WebContents* contents, |
| 408 OneClickSigninSyncStarter::StartSyncMode start_mode, | 413 OneClickSigninSyncStarter::StartSyncMode start_mode, |
| 409 ConfirmEmailDialogDelegate::Action action) { | 414 ConfirmEmailDialogDelegate::Action action) { |
| 415 bool enable_inline = CommandLine::ForCurrentProcess()->HasSwitch( |
| 416 switches::kEnableInlineSignin); |
| 410 if (action == ConfirmEmailDialogDelegate::START_SYNC) { | 417 if (action == ConfirmEmailDialogDelegate::START_SYNC) { |
| 411 StartSync(args, start_mode); | 418 StartSync(args, start_mode); |
| 412 OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary( | 419 if (!enable_inline) { |
| 413 contents, args.source); | 420 // Redirect/tab closing for inline flow is handled by the sync callback. |
| 421 OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary( |
| 422 contents, args.source); |
| 423 } |
| 414 } else { | 424 } else { |
| 415 // Perform a redirection to the NTP/Apps page to hide the blank page when | 425 // 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 | 426 // 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 | 427 // 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. | 428 // be opened in a different tab that is already showing settings. |
| 419 // | 429 if (enable_inline) { |
| 420 // Don't redirect when the visible URL is not a blank page: if the | 430 // Redirect/tab closing for inline flow is handled by the sync callback. |
| 421 // source is SOURCE_WEBSTORE_INSTALL, |contents| might be showing an app | 431 args.callback.Run(OneClickSigninSyncStarter::SYNC_SETUP_FAILURE); |
| 422 // page that shouldn't be hidden. | 432 } else { |
| 423 // | 433 // 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 | 434 // source is SOURCE_WEBSTORE_INSTALL, |contents| might be showing an app |
| 425 // navigations and a crash would occur (crbug.com/293261). Post the task | 435 // page that shouldn't be hidden. |
| 426 // to the current thread instead. | 436 // |
| 427 if (signin::IsContinueUrlForWebBasedSigninFlow( | 437 // If redirecting, don't do so immediately, otherwise there may be 2 |
| 428 contents->GetVisibleURL())) { | 438 // nested navigations and a crash would occur (crbug.com/293261). Post |
| 429 base::MessageLoopProxy::current()->PostNonNestableTask( | 439 // the task to the current thread instead. |
| 430 FROM_HERE, | 440 if (signin::IsContinueUrlForWebBasedSigninFlow( |
| 431 base::Bind(RedirectToNtpOrAppsPageWithIds, | 441 contents->GetVisibleURL())) { |
| 432 contents->GetRenderProcessHost()->GetID(), | 442 base::MessageLoopProxy::current()->PostNonNestableTask( |
| 433 contents->GetRoutingID(), | 443 FROM_HERE, |
| 434 args.source)); | 444 base::Bind(RedirectToNtpOrAppsPageWithIds, |
| 445 contents->GetRenderProcessHost()->GetID(), |
| 446 contents->GetRoutingID(), |
| 447 args.source)); |
| 448 } |
| 435 } | 449 } |
| 436 if (action == ConfirmEmailDialogDelegate::CREATE_NEW_USER) { | 450 if (action == ConfirmEmailDialogDelegate::CREATE_NEW_USER) { |
| 437 chrome::ShowSettingsSubPage(args.browser, | 451 chrome::ShowSettingsSubPage(args.browser, |
| 438 std::string(chrome::kSearchUsersSubPage)); | 452 std::string(chrome::kSearchUsersSubPage)); |
| 439 } | 453 } |
| 440 } | 454 } |
| 441 } | 455 } |
| 442 | 456 |
| 443 void ClearPendingEmailOnIOThread(content::ResourceContext* context) { | 457 void ClearPendingEmailOnIOThread(content::ResourceContext* context) { |
| 444 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); | 458 ProfileIOData* io_data = ProfileIOData::FromResourceContext(context); |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1030 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, | 1044 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, |
| 1031 base::string16(), /* no SAML email */ | 1045 base::string16(), /* no SAML email */ |
| 1032 UTF8ToUTF16(error), | 1046 UTF8ToUTF16(error), |
| 1033 // This callback is never invoked. | 1047 // This callback is never invoked. |
| 1034 // TODO(rogerta): Separate out the bubble API so we don't have to pass | 1048 // TODO(rogerta): Separate out the bubble API so we don't have to pass |
| 1035 // ignored |email| and |callback| params. | 1049 // ignored |email| and |callback| params. |
| 1036 BrowserWindow::StartSyncCallback()); | 1050 BrowserWindow::StartSyncCallback()); |
| 1037 } | 1051 } |
| 1038 | 1052 |
| 1039 // static | 1053 // static |
| 1054 bool OneClickSigninHelper::HandleCrossAccountError( |
| 1055 content::WebContents* contents, |
| 1056 const std::string& session_index, |
| 1057 const std::string& email, |
| 1058 const std::string& password, |
| 1059 const std::string& oauth_code, |
| 1060 OneClickSigninHelper::AutoAccept auto_accept, |
| 1061 signin::Source source, |
| 1062 OneClickSigninSyncStarter::StartSyncMode start_mode, |
| 1063 OneClickSigninSyncStarter::Callback sync_callback) { |
| 1064 Profile* profile = |
| 1065 Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 1066 std::string last_email = |
| 1067 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); |
| 1068 |
| 1069 if (!last_email.empty() && !gaia::AreEmailsSame(last_email, email)) { |
| 1070 // If the new email address is different from the email address that |
| 1071 // just signed in, show a confirmation dialog. |
| 1072 |
| 1073 // No need to display a second confirmation so pass false below. |
| 1074 // TODO(atwilson): Move this into OneClickSigninSyncStarter. |
| 1075 // The tab modal dialog always executes its callback before |contents| |
| 1076 // is deleted. |
| 1077 Browser* browser = chrome::FindBrowserWithWebContents(contents); |
| 1078 ConfirmEmailDialogDelegate::AskForConfirmation( |
| 1079 contents, |
| 1080 last_email, |
| 1081 email, |
| 1082 base::Bind( |
| 1083 &StartExplicitSync, |
| 1084 StartSyncArgs(profile, browser, auto_accept, |
| 1085 session_index, email, password, oauth_code, contents, |
| 1086 false /* confirmation_required */, source, |
| 1087 sync_callback), |
| 1088 contents, |
| 1089 start_mode)); |
| 1090 return true; |
| 1091 } |
| 1092 |
| 1093 return false; |
| 1094 } |
| 1095 |
| 1096 // static |
| 1040 void OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary( | 1097 void OneClickSigninHelper::RedirectToNtpOrAppsPageIfNecessary( |
| 1041 content::WebContents* contents, signin::Source source) { | 1098 content::WebContents* contents, signin::Source source) { |
| 1042 if (source != signin::SOURCE_SETTINGS && | 1099 if (source != signin::SOURCE_SETTINGS && |
| 1043 source != signin::SOURCE_WEBSTORE_INSTALL) { | 1100 source != signin::SOURCE_WEBSTORE_INSTALL) { |
| 1044 RedirectToNtpOrAppsPage(contents, source); | 1101 RedirectToNtpOrAppsPage(contents, source); |
| 1045 } | 1102 } |
| 1046 } | 1103 } |
| 1047 | 1104 |
| 1048 void OneClickSigninHelper::RedirectToSignin() { | 1105 void OneClickSigninHelper::RedirectToSignin() { |
| 1049 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; | 1106 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1286 case AUTO_ACCEPT_ACCEPTED: | 1343 case AUTO_ACCEPT_ACCEPTED: |
| 1287 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | 1344 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); |
| 1288 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); | 1345 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); |
| 1289 SigninManager::DisableOneClickSignIn(profile); | 1346 SigninManager::DisableOneClickSignIn(profile); |
| 1290 // Start syncing with the default settings - prompt the user to sign in | 1347 // Start syncing with the default settings - prompt the user to sign in |
| 1291 // first. | 1348 // first. |
| 1292 if (!do_not_start_sync_for_testing_) { | 1349 if (!do_not_start_sync_for_testing_) { |
| 1293 StartSync( | 1350 StartSync( |
| 1294 StartSyncArgs(profile, browser, auto_accept_, | 1351 StartSyncArgs(profile, browser, auto_accept_, |
| 1295 session_index_, email_, password_, | 1352 session_index_, email_, password_, |
| 1353 "" /* oauth_code */, |
| 1296 NULL /* don't force to show sync setup in same tab */, | 1354 NULL /* don't force to show sync setup in same tab */, |
| 1297 true /* confirmation_required */, source_, | 1355 true /* confirmation_required */, source_, |
| 1298 CreateSyncStarterCallback()), | 1356 CreateSyncStarterCallback()), |
| 1299 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); | 1357 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
| 1300 } | 1358 } |
| 1301 break; | 1359 break; |
| 1302 case AUTO_ACCEPT_CONFIGURE: | 1360 case AUTO_ACCEPT_CONFIGURE: |
| 1303 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | 1361 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); |
| 1304 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); | 1362 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); |
| 1305 SigninManager::DisableOneClickSignIn(profile); | 1363 SigninManager::DisableOneClickSignIn(profile); |
| 1306 // Display the extra confirmation (even in the SAML case) in case this | 1364 // Display the extra confirmation (even in the SAML case) in case this |
| 1307 // was an untrusted renderer. | 1365 // was an untrusted renderer. |
| 1308 if (!do_not_start_sync_for_testing_) { | 1366 if (!do_not_start_sync_for_testing_) { |
| 1309 StartSync( | 1367 StartSync( |
| 1310 StartSyncArgs(profile, browser, auto_accept_, | 1368 StartSyncArgs(profile, browser, auto_accept_, |
| 1311 session_index_, email_, password_, | 1369 session_index_, email_, password_, |
| 1370 "" /* oauth_code */, |
| 1312 NULL /* don't force sync setup in same tab */, | 1371 NULL /* don't force sync setup in same tab */, |
| 1313 true /* confirmation_required */, source_, | 1372 true /* confirmation_required */, source_, |
| 1314 CreateSyncStarterCallback()), | 1373 CreateSyncStarterCallback()), |
| 1315 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 1374 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
| 1316 } | 1375 } |
| 1317 break; | 1376 break; |
| 1318 case AUTO_ACCEPT_EXPLICIT: { | 1377 case AUTO_ACCEPT_EXPLICIT: { |
| 1319 signin::Source original_source = | 1378 signin::Source original_source = |
| 1320 signin::GetSourceForPromoURL(original_continue_url_); | 1379 signin::GetSourceForPromoURL(original_continue_url_); |
| 1321 if (switched_to_advanced_) { | 1380 if (switched_to_advanced_) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1337 ProfileSyncService* sync_service = | 1396 ProfileSyncService* sync_service = |
| 1338 ProfileSyncServiceFactory::GetForProfile(profile); | 1397 ProfileSyncServiceFactory::GetForProfile(profile); |
| 1339 OneClickSigninSyncStarter::StartSyncMode start_mode = | 1398 OneClickSigninSyncStarter::StartSyncMode start_mode = |
| 1340 source_ == signin::SOURCE_SETTINGS ? | 1399 source_ == signin::SOURCE_SETTINGS ? |
| 1341 (SigninGlobalError::GetForProfile(profile)->HasMenuItem() && | 1400 (SigninGlobalError::GetForProfile(profile)->HasMenuItem() && |
| 1342 sync_service && sync_service->HasSyncSetupCompleted()) ? | 1401 sync_service && sync_service->HasSyncSetupCompleted()) ? |
| 1343 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : | 1402 OneClickSigninSyncStarter::SHOW_SETTINGS_WITHOUT_CONFIGURE : |
| 1344 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : | 1403 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST : |
| 1345 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; | 1404 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS; |
| 1346 | 1405 |
| 1347 std::string last_email = | 1406 if (!HandleCrossAccountError(contents, session_index_, email_, password_, |
| 1348 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); | 1407 "" /* oauth_code */, auto_accept_, source_, start_mode, |
| 1349 | 1408 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_) { | 1409 if (!do_not_start_sync_for_testing_) { |
| 1372 StartSync( | 1410 StartSync( |
| 1373 StartSyncArgs(profile, browser, auto_accept_, | 1411 StartSyncArgs(profile, browser, auto_accept_, |
| 1374 session_index_, email_, password_, contents, | 1412 session_index_, email_, password_, |
| 1413 "" /* oauth_code */, contents, |
| 1375 untrusted_confirmation_required_, source_, | 1414 untrusted_confirmation_required_, source_, |
| 1376 CreateSyncStarterCallback()), | 1415 CreateSyncStarterCallback()), |
| 1377 start_mode); | 1416 start_mode); |
| 1378 } | 1417 } |
| 1379 | 1418 |
| 1380 // If this explicit sign in is not from settings page/webstore, show | 1419 // 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 | 1420 // 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 | 1421 // settings page, it will get auto-closed after sync setup. In the case |
| 1383 // of webstore, it will redirect back to webstore. | 1422 // of webstore, it will redirect back to webstore. |
| 1384 RedirectToNtpOrAppsPageIfNecessary(web_contents(), source_); | 1423 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, | 1521 // If the web contents is showing a blank page and not about to be closed, |
| 1483 // redirect to the NTP or apps page. | 1522 // redirect to the NTP or apps page. |
| 1484 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && | 1523 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && |
| 1485 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { | 1524 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { |
| 1486 RedirectToNtpOrAppsPage( | 1525 RedirectToNtpOrAppsPage( |
| 1487 web_contents(), | 1526 web_contents(), |
| 1488 signin::GetSourceForPromoURL(original_continue_url_)); | 1527 signin::GetSourceForPromoURL(original_continue_url_)); |
| 1489 } | 1528 } |
| 1490 } | 1529 } |
| 1491 } | 1530 } |
| OLD | NEW |