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 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
577 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents, | 577 OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents, |
578 PasswordManager* password_manager) | 578 PasswordManager* password_manager) |
579 : content::WebContentsObserver(web_contents), | 579 : content::WebContentsObserver(web_contents), |
580 showing_signin_(false), | 580 showing_signin_(false), |
581 auto_accept_(AUTO_ACCEPT_NONE), | 581 auto_accept_(AUTO_ACCEPT_NONE), |
582 source_(signin::SOURCE_UNKNOWN), | 582 source_(signin::SOURCE_UNKNOWN), |
583 switched_to_advanced_(false), | 583 switched_to_advanced_(false), |
584 untrusted_navigations_since_signin_visit_(0), | 584 untrusted_navigations_since_signin_visit_(0), |
585 untrusted_confirmation_required_(false), | 585 untrusted_confirmation_required_(false), |
586 do_not_clear_pending_email_(false), | 586 do_not_clear_pending_email_(false), |
| 587 do_not_start_sync_for_testing_(false), |
587 weak_pointer_factory_(this) { | 588 weak_pointer_factory_(this) { |
588 // May be NULL during testing. | 589 // May be NULL during testing. |
589 if (password_manager) { | 590 if (password_manager) { |
590 password_manager->AddSubmissionCallback( | 591 password_manager->AddSubmissionCallback( |
591 base::Bind(&OneClickSigninHelper::PasswordSubmitted, | 592 base::Bind(&OneClickSigninHelper::PasswordSubmitted, |
592 weak_pointer_factory_.GetWeakPtr())); | 593 weak_pointer_factory_.GetWeakPtr())); |
593 } | 594 } |
594 } | 595 } |
595 | 596 |
596 OneClickSigninHelper::~OneClickSigninHelper() { | 597 OneClickSigninHelper::~OneClickSigninHelper() { |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 if (gaia::IsGaiaSignonRealm(GURL(form.signon_realm))) { | 1031 if (gaia::IsGaiaSignonRealm(GURL(form.signon_realm))) { |
1031 VLOG(1) << "OneClickSigninHelper::DidNavigateAnyFrame: got password"; | 1032 VLOG(1) << "OneClickSigninHelper::DidNavigateAnyFrame: got password"; |
1032 password_ = UTF16ToUTF8(form.password_value); | 1033 password_ = UTF16ToUTF8(form.password_value); |
1033 } | 1034 } |
1034 } | 1035 } |
1035 | 1036 |
1036 void OneClickSigninHelper::SetDoNotClearPendingEmailForTesting() { | 1037 void OneClickSigninHelper::SetDoNotClearPendingEmailForTesting() { |
1037 do_not_clear_pending_email_ = true; | 1038 do_not_clear_pending_email_ = true; |
1038 } | 1039 } |
1039 | 1040 |
| 1041 void OneClickSigninHelper::set_do_not_start_sync_for_testing() { |
| 1042 do_not_start_sync_for_testing_ = true; |
| 1043 } |
| 1044 |
1040 void OneClickSigninHelper::NavigateToPendingEntry( | 1045 void OneClickSigninHelper::NavigateToPendingEntry( |
1041 const GURL& url, | 1046 const GURL& url, |
1042 content::NavigationController::ReloadType reload_type) { | 1047 content::NavigationController::ReloadType reload_type) { |
1043 VLOG(1) << "OneClickSigninHelper::NavigateToPendingEntry: url=" << url.spec(); | 1048 VLOG(1) << "OneClickSigninHelper::NavigateToPendingEntry: url=" << url.spec(); |
1044 // If the tab navigates to a new page, and this page is not a valid Gaia | 1049 // If the tab navigates to a new page, and this page is not a valid Gaia |
1045 // sign in redirect or reponse, or the expected continue URL, make sure to | 1050 // sign in redirect or reponse, or the expected continue URL, make sure to |
1046 // clear the internal state. This is needed to detect navigations in the | 1051 // clear the internal state. This is needed to detect navigations in the |
1047 // middle of the sign in process that may redirect back to the sign in | 1052 // middle of the sign in process that may redirect back to the sign in |
1048 // process (see crbug.com/181163 for details). | 1053 // process (see crbug.com/181163 for details). |
1049 const GURL continue_url = signin::GetNextPageURLForPromoURL( | 1054 const GURL continue_url = signin::GetNextPageURLForPromoURL( |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1205 case AUTO_ACCEPT_NONE: | 1210 case AUTO_ACCEPT_NONE: |
1206 if (showing_signin_) | 1211 if (showing_signin_) |
1207 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_DISMISSED); | 1212 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_DISMISSED); |
1208 break; | 1213 break; |
1209 case AUTO_ACCEPT_ACCEPTED: | 1214 case AUTO_ACCEPT_ACCEPTED: |
1210 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | 1215 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); |
1211 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); | 1216 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); |
1212 SigninManager::DisableOneClickSignIn(profile); | 1217 SigninManager::DisableOneClickSignIn(profile); |
1213 // Start syncing with the default settings - prompt the user to sign in | 1218 // Start syncing with the default settings - prompt the user to sign in |
1214 // first. | 1219 // first. |
1215 StartSync( | 1220 if (!do_not_start_sync_for_testing_) { |
1216 StartSyncArgs(profile, browser, auto_accept_, | 1221 StartSync( |
1217 session_index_, email_, password_, | 1222 StartSyncArgs(profile, browser, auto_accept_, |
1218 NULL /* don't force to show sync setup in same tab */, | 1223 session_index_, email_, password_, |
1219 true /* confirmation_required */, source_, | 1224 NULL /* don't force to show sync setup in same tab */, |
1220 CreateSyncStarterCallback()), | 1225 true /* confirmation_required */, source_, |
1221 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); | 1226 CreateSyncStarterCallback()), |
| 1227 OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
| 1228 } |
1222 break; | 1229 break; |
1223 case AUTO_ACCEPT_CONFIGURE: | 1230 case AUTO_ACCEPT_CONFIGURE: |
1224 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | 1231 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); |
1225 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); | 1232 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); |
1226 SigninManager::DisableOneClickSignIn(profile); | 1233 SigninManager::DisableOneClickSignIn(profile); |
1227 // Display the extra confirmation (even in the SAML case) in case this | 1234 // Display the extra confirmation (even in the SAML case) in case this |
1228 // was an untrusted renderer. | 1235 // was an untrusted renderer. |
1229 StartSync( | 1236 if (!do_not_start_sync_for_testing_) { |
1230 StartSyncArgs(profile, browser, auto_accept_, | 1237 StartSync( |
1231 session_index_, email_, password_, | 1238 StartSyncArgs(profile, browser, auto_accept_, |
1232 NULL /* don't force to show sync setup in same tab */, | 1239 session_index_, email_, password_, |
1233 true /* confirmation_required */, source_, | 1240 NULL /* don't force sync setup in same tab */, |
1234 CreateSyncStarterCallback()), | 1241 true /* confirmation_required */, source_, |
1235 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); | 1242 CreateSyncStarterCallback()), |
| 1243 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
| 1244 } |
1236 break; | 1245 break; |
1237 case AUTO_ACCEPT_EXPLICIT: { | 1246 case AUTO_ACCEPT_EXPLICIT: { |
1238 signin::Source original_source = | 1247 signin::Source original_source = |
1239 signin::GetSourceForPromoURL(original_continue_url_); | 1248 signin::GetSourceForPromoURL(original_continue_url_); |
1240 if (switched_to_advanced_) { | 1249 if (switched_to_advanced_) { |
1241 LogHistogramValue(original_source, | 1250 LogHistogramValue(original_source, |
1242 one_click_signin::HISTOGRAM_WITH_ADVANCED); | 1251 one_click_signin::HISTOGRAM_WITH_ADVANCED); |
1243 LogHistogramValue(original_source, | 1252 LogHistogramValue(original_source, |
1244 one_click_signin::HISTOGRAM_ACCEPTED); | 1253 one_click_signin::HISTOGRAM_ACCEPTED); |
1245 } else { | 1254 } else { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1280 email_, | 1289 email_, |
1281 base::Bind( | 1290 base::Bind( |
1282 &StartExplicitSync, | 1291 &StartExplicitSync, |
1283 StartSyncArgs(profile, browser, auto_accept_, | 1292 StartSyncArgs(profile, browser, auto_accept_, |
1284 session_index_, email_, password_, contents, | 1293 session_index_, email_, password_, contents, |
1285 false /* confirmation_required */, source_, | 1294 false /* confirmation_required */, source_, |
1286 CreateSyncStarterCallback()), | 1295 CreateSyncStarterCallback()), |
1287 contents, | 1296 contents, |
1288 start_mode)); | 1297 start_mode)); |
1289 } else { | 1298 } else { |
1290 StartSync( | 1299 if (!do_not_start_sync_for_testing_) { |
1291 StartSyncArgs(profile, browser, auto_accept_, | 1300 StartSync( |
1292 session_index_, email_, password_, contents, | 1301 StartSyncArgs(profile, browser, auto_accept_, |
1293 untrusted_confirmation_required_, source_, | 1302 session_index_, email_, password_, contents, |
1294 CreateSyncStarterCallback()), | 1303 untrusted_confirmation_required_, source_, |
1295 start_mode); | 1304 CreateSyncStarterCallback()), |
| 1305 start_mode); |
| 1306 } |
1296 | 1307 |
1297 // If this explicit sign in is not from settings page/webstore, show | 1308 // If this explicit sign in is not from settings page/webstore, show |
1298 // the NTP/Apps page after sign in completes. In the case of the | 1309 // the NTP/Apps page after sign in completes. In the case of the |
1299 // settings page, it will get auto-closed after sync setup. In the case | 1310 // settings page, it will get auto-closed after sync setup. In the case |
1300 // of webstore, it will redirect back to webstore. | 1311 // of webstore, it will redirect back to webstore. |
1301 RedirectToNtpOrAppsPageIfNecessary(web_contents(), source_); | 1312 RedirectToNtpOrAppsPageIfNecessary(web_contents(), source_); |
1302 } | 1313 } |
1303 | 1314 |
1304 // Observe the sync service if the Webstore tab or the settings tab | 1315 // Observe the sync service if the Webstore tab or the settings tab |
1305 // requested a gaia sign in, so that when sign in and sync setup are | 1316 // requested a gaia sign in, so that when sign in and sync setup are |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1397 // If the web contents is showing a blank page and not about to be closed, | 1408 // If the web contents is showing a blank page and not about to be closed, |
1398 // redirect to the NTP or apps page. | 1409 // redirect to the NTP or apps page. |
1399 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && | 1410 if (signin::IsContinueUrlForWebBasedSigninFlow(current_url) && |
1400 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { | 1411 !signin::IsAutoCloseEnabledInURL(original_continue_url_)) { |
1401 RedirectToNtpOrAppsPage( | 1412 RedirectToNtpOrAppsPage( |
1402 web_contents(), | 1413 web_contents(), |
1403 signin::GetSourceForPromoURL(original_continue_url_)); | 1414 signin::GetSourceForPromoURL(original_continue_url_)); |
1404 } | 1415 } |
1405 } | 1416 } |
1406 } | 1417 } |
OLD | NEW |