Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/sync/one_click_signin_helper.h" | 5 #include "chrome/browser/ui/sync/one_click_signin_helper.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 514 web_contents->GetBrowserContext()); | 514 web_contents->GetBrowserContext()); |
| 515 | 515 |
| 516 // User has accepted one-click sign-in for this account. Never ask again for | 516 // User has accepted one-click sign-in for this account. Never ask again for |
| 517 // this profile. | 517 // this profile. |
| 518 SigninManager::DisableOneClickSignIn(profile); | 518 SigninManager::DisableOneClickSignIn(profile); |
| 519 RecordHistogramAction(one_click_signin::HISTOGRAM_ACCEPTED); | 519 RecordHistogramAction(one_click_signin::HISTOGRAM_ACCEPTED); |
| 520 chrome::FindBrowserWithWebContents(web_contents)->window()-> | 520 chrome::FindBrowserWithWebContents(web_contents)->window()-> |
| 521 ShowOneClickSigninBubble( | 521 ShowOneClickSigninBubble( |
| 522 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, | 522 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, |
| 523 UTF8ToUTF16(email_), | 523 UTF8ToUTF16(email_), |
| 524 string16() /* no error message to display */, | |
| 524 base::Bind(&StartSync, | 525 base::Bind(&StartSync, |
| 525 StartSyncArgs(profile, browser, | 526 StartSyncArgs(profile, browser, |
| 526 OneClickSigninHelper::AUTO_ACCEPT_NONE, | 527 OneClickSigninHelper::AUTO_ACCEPT_NONE, |
| 527 session_index_, email_, password_, | 528 session_index_, email_, password_, |
| 528 false /* force_same_tab_navigation */))); | 529 false /* force_same_tab_navigation */))); |
| 529 button_pressed_ = true; | 530 button_pressed_ = true; |
| 530 return true; | 531 return true; |
| 531 } | 532 } |
| 532 | 533 |
| 533 bool OneClickInfoBarDelegateImpl::Cancel() { | 534 bool OneClickInfoBarDelegateImpl::Cancel() { |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 930 | 931 |
| 931 if (source != SyncPromoUI::SOURCE_UNKNOWN && | 932 if (source != SyncPromoUI::SOURCE_UNKNOWN && |
| 932 helper->source_ == SyncPromoUI::SOURCE_UNKNOWN) { | 933 helper->source_ == SyncPromoUI::SOURCE_UNKNOWN) { |
| 933 helper->source_ = source; | 934 helper->source_ = source; |
| 934 } | 935 } |
| 935 | 936 |
| 936 CanOfferFor can_offer_for = | 937 CanOfferFor can_offer_for = |
| 937 (auto_accept != AUTO_ACCEPT_EXPLICIT && | 938 (auto_accept != AUTO_ACCEPT_EXPLICIT && |
| 938 helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ? | 939 helper->auto_accept_ != AUTO_ACCEPT_EXPLICIT) ? |
| 939 CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL; | 940 CAN_OFFER_FOR_INTERSTITAL_ONLY : CAN_OFFER_FOR_ALL; |
| 941 | |
| 940 std::string error_message; | 942 std::string error_message; |
| 941 | 943 |
| 942 if (!web_contents || !CanOffer(web_contents, can_offer_for, email, | 944 if (!web_contents || !CanOffer(web_contents, can_offer_for, email, |
| 943 &error_message)) { | 945 &error_message)) { |
| 944 VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering"; | 946 VLOG(1) << "OneClickSigninHelper::ShowInfoBarUIThread: not offering"; |
| 945 if (helper && helper->error_message_.empty() && !error_message.empty()) | 947 if (helper && helper->error_message_.empty() && !error_message.empty()) |
| 946 helper->error_message_ = error_message; | 948 helper->error_message_ = error_message; |
| 947 | 949 |
| 948 return; | 950 return; |
| 949 } | 951 } |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 971 helper->continue_url_ = continue_url; | 973 helper->continue_url_ = continue_url; |
| 972 } | 974 } |
| 973 | 975 |
| 974 void OneClickSigninHelper::RedirectToNtpOrAppsPage(bool show_bubble) { | 976 void OneClickSigninHelper::RedirectToNtpOrAppsPage(bool show_bubble) { |
| 975 VLOG(1) << "OneClickSigninHelper::RedirectToNtpOrAppsPage"; | 977 VLOG(1) << "OneClickSigninHelper::RedirectToNtpOrAppsPage"; |
| 976 | 978 |
| 977 // Redirect to NTP/Apps page with sign in bubble visible. | 979 // Redirect to NTP/Apps page with sign in bubble visible. |
| 978 content::WebContents* contents = web_contents(); | 980 content::WebContents* contents = web_contents(); |
| 979 Profile* profile = | 981 Profile* profile = |
| 980 Profile::FromBrowserContext(contents->GetBrowserContext()); | 982 Profile::FromBrowserContext(contents->GetBrowserContext()); |
| 981 PrefService* pref_service = profile->GetPrefs(); | |
| 982 if (show_bubble) { | |
| 983 pref_service->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); | |
| 984 pref_service->SetString(prefs::kSyncPromoErrorMessage, error_message_); | |
| 985 } | |
| 986 | 983 |
| 987 GURL url(chrome::IsInstantExtendedAPIEnabled() ? | 984 GURL url(chrome::IsInstantExtendedAPIEnabled() ? |
| 988 chrome::kChromeUIAppsURL : chrome::kChromeUINewTabURL); | 985 chrome::kChromeUIAppsURL : chrome::kChromeUINewTabURL); |
| 989 content::OpenURLParams params(url, | 986 content::OpenURLParams params(url, |
| 990 content::Referrer(), | 987 content::Referrer(), |
| 991 CURRENT_TAB, | 988 CURRENT_TAB, |
| 992 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 989 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
| 993 false); | 990 false); |
| 994 contents->OpenURL(params); | 991 contents->OpenURL(params); |
| 995 | 992 |
| 993 if (show_bubble) { | |
| 994 Browser* browser = chrome::FindBrowserWithWebContents(contents); | |
| 995 browser->window()->ShowOneClickSigninBubble( | |
| 996 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE, | |
| 997 string16(), /* no SAML email */ | |
| 998 UTF8ToUTF16(error_message_), | |
| 999 base::Bind(&StartSync, | |
| 1000 StartSyncArgs(profile, browser, AUTO_ACCEPT_ACCEPTED, | |
| 1001 session_index_, email_, password_, | |
| 1002 false))); | |
| 1003 } | |
| 1004 | |
| 996 error_message_.clear(); | 1005 error_message_.clear(); |
| 997 } | 1006 } |
| 998 | 1007 |
| 999 void OneClickSigninHelper::RedirectToSignin() { | 1008 void OneClickSigninHelper::RedirectToSignin() { |
| 1000 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; | 1009 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; |
| 1001 | 1010 |
| 1002 // Extract the existing sounce=X value. Default to "2" if missing. | 1011 // Extract the existing sounce=X value. Default to "2" if missing. |
| 1003 SyncPromoUI::Source source = | 1012 SyncPromoUI::Source source = |
| 1004 SyncPromoUI::GetSourceForSyncPromoURL(continue_url_); | 1013 SyncPromoUI::GetSourceForSyncPromoURL(continue_url_); |
| 1005 if (source == SyncPromoUI::SOURCE_UNKNOWN) | 1014 if (source == SyncPromoUI::SOURCE_UNKNOWN) |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1223 password_); | 1232 password_); |
| 1224 } | 1233 } |
| 1225 break; | 1234 break; |
| 1226 case AUTO_ACCEPT_ACCEPTED: | 1235 case AUTO_ACCEPT_ACCEPTED: |
| 1227 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | 1236 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); |
| 1228 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); | 1237 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); |
| 1229 SigninManager::DisableOneClickSignIn(profile); | 1238 SigninManager::DisableOneClickSignIn(profile); |
| 1230 browser->window()->ShowOneClickSigninBubble( | 1239 browser->window()->ShowOneClickSigninBubble( |
| 1231 bubble_type, | 1240 bubble_type, |
| 1232 UTF8ToUTF16(email_), | 1241 UTF8ToUTF16(email_), |
| 1242 string16(), /* no error message to display */ | |
| 1233 base::Bind(&StartSync, | 1243 base::Bind(&StartSync, |
| 1234 StartSyncArgs(profile, browser, auto_accept_, | 1244 StartSyncArgs(profile, browser, auto_accept_, |
| 1235 session_index_, email_, password_, | 1245 session_index_, email_, password_, |
| 1236 false /* force_same_tab_navigation */))); | 1246 false /* force_same_tab_navigation */))); |
| 1237 break; | 1247 break; |
| 1238 case AUTO_ACCEPT_CONFIGURE: | 1248 case AUTO_ACCEPT_CONFIGURE: |
| 1239 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); | 1249 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); |
| 1240 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); | 1250 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); |
| 1241 SigninManager::DisableOneClickSignIn(profile); | 1251 SigninManager::DisableOneClickSignIn(profile); |
| 1242 StartSync( | 1252 StartSync( |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1261 | 1271 |
| 1262 std::string last_email = | 1272 std::string last_email = |
| 1263 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); | 1273 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); |
| 1264 | 1274 |
| 1265 if (!is_trusted_) { | 1275 if (!is_trusted_) { |
| 1266 // The user has navigated away from valid Gaia URLs during sign in, | 1276 // The user has navigated away from valid Gaia URLs during sign in, |
| 1267 // verify this sign in is desired. | 1277 // verify this sign in is desired. |
| 1268 browser->window()->ShowOneClickSigninBubble( | 1278 browser->window()->ShowOneClickSigninBubble( |
| 1269 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_SAML_MODAL_DIALOG, | 1279 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_SAML_MODAL_DIALOG, |
| 1270 UTF8ToUTF16(email_), | 1280 UTF8ToUTF16(email_), |
| 1281 string16(), /* no error message to display */ | |
| 1271 base::Bind(&StartSync, | 1282 base::Bind(&StartSync, |
| 1272 StartSyncArgs(profile, browser, auto_accept_, | 1283 StartSyncArgs(profile, browser, auto_accept_, |
| 1273 session_index_, email_, password_, | 1284 session_index_, email_, password_, |
| 1274 force_same_tab_navigation))); | 1285 force_same_tab_navigation))); |
| 1275 } else if (!last_email.empty() && last_email != email_) { | 1286 } else if (!last_email.empty() && last_email != email_) { |
| 1276 // If the new email address is different from the email address that | 1287 // If the new email address is different from the email address that |
| 1277 // just signed in, show a confirmation dialog. | 1288 // just signed in, show a confirmation dialog. |
| 1278 ConfirmEmailDialogDelegate::AskForConfirmation( | 1289 ConfirmEmailDialogDelegate::AskForConfirmation( |
| 1279 contents, | 1290 contents, |
| 1280 last_email, | 1291 last_email, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1385 } | 1396 } |
| 1386 RedirectOnSigninComplete(display_bubble); | 1397 RedirectOnSigninComplete(display_bubble); |
| 1387 } | 1398 } |
| 1388 | 1399 |
| 1389 void OneClickSigninHelper::SigninSuccess() { | 1400 void OneClickSigninHelper::SigninSuccess() { |
| 1390 RedirectOnSigninComplete(true); | 1401 RedirectOnSigninComplete(true); |
| 1391 } | 1402 } |
| 1392 | 1403 |
| 1393 void OneClickSigninHelper::RedirectOnSigninComplete(bool show_bubble) { | 1404 void OneClickSigninHelper::RedirectOnSigninComplete(bool show_bubble) { |
| 1394 // Show the result in the sign-in bubble if desired. | 1405 // Show the result in the sign-in bubble if desired. |
| 1395 RedirectToNtpOrAppsPage(show_bubble); | 1406 RedirectToNtpOrAppsPage(show_bubble); |
|
Roger Tawa OOO till Jul 10th
2013/04/22 20:49:05
The sign in code does two redirects to the NTP: on
noms (inactive)
2013/04/23 19:21:23
Done. (I hope!)
On 2013/04/22 20:49:05, Roger Ta
| |
| 1396 signin_tracker_.reset(); | 1407 signin_tracker_.reset(); |
| 1397 } | 1408 } |
| OLD | NEW |