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

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

Issue 13979003: Win: Display a native bubble (instead of the JS one) after the web signin flow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: NTP redirects: less is more Created 7 years, 8 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
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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 14 matching lines...) Expand all
964 if (!session_index.empty()) 966 if (!session_index.empty())
965 helper->session_index_ = session_index; 967 helper->session_index_ = session_index;
966 968
967 if (!email.empty()) 969 if (!email.empty())
968 helper->email_ = email; 970 helper->email_ = email;
969 971
970 if (continue_url.is_valid()) 972 if (continue_url.is_valid())
971 helper->continue_url_ = continue_url; 973 helper->continue_url_ = continue_url;
972 } 974 }
973 975
976 void OneClickSigninHelper::ShowSyncConfirmationBubble(bool show_bubble) {
977 content::WebContents* contents = web_contents();
978 Profile* profile =
979 Profile::FromBrowserContext(contents->GetBrowserContext());
Roger Tawa OOO till Jul 10th 2013/04/23 19:49:12 Can move these variables into the if block.
980
981 if (show_bubble) {
982 Browser* browser = chrome::FindBrowserWithWebContents(contents);
983 browser->window()->ShowOneClickSigninBubble(
984 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE,
985 string16(), /* no SAML email */
986 UTF8ToUTF16(error_message_),
987 base::Bind(&StartSync,
988 StartSyncArgs(profile, browser, AUTO_ACCEPT_ACCEPTED,
989 session_index_, email_, password_,
990 false)));
991 }
992 error_message_.clear();
993 }
994
974 void OneClickSigninHelper::RedirectToNtpOrAppsPage(bool show_bubble) { 995 void OneClickSigninHelper::RedirectToNtpOrAppsPage(bool show_bubble) {
975 VLOG(1) << "OneClickSigninHelper::RedirectToNtpOrAppsPage"; 996 VLOG(1) << "OneClickSigninHelper::RedirectToNtpOrAppsPage";
976 997
977 // Redirect to NTP/Apps page with sign in bubble visible. 998 // Redirect to NTP/Apps page and display a confirmation bubble
978 content::WebContents* contents = web_contents(); 999 content::WebContents* contents = web_contents();
979 Profile* profile =
980 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
987 GURL url(chrome::IsInstantExtendedAPIEnabled() ? 1000 GURL url(chrome::IsInstantExtendedAPIEnabled() ?
988 chrome::kChromeUIAppsURL : chrome::kChromeUINewTabURL); 1001 chrome::kChromeUIAppsURL : chrome::kChromeUINewTabURL);
989 content::OpenURLParams params(url, 1002 content::OpenURLParams params(url,
990 content::Referrer(), 1003 content::Referrer(),
991 CURRENT_TAB, 1004 CURRENT_TAB,
992 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 1005 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
993 false); 1006 false);
994 contents->OpenURL(params); 1007 contents->OpenURL(params);
995 1008
996 error_message_.clear(); 1009 ShowSyncConfirmationBubble(show_bubble);
997 } 1010 }
998 1011
999 void OneClickSigninHelper::RedirectToSignin() { 1012 void OneClickSigninHelper::RedirectToSignin() {
1000 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; 1013 VLOG(1) << "OneClickSigninHelper::RedirectToSignin";
1001 1014
1002 // Extract the existing sounce=X value. Default to "2" if missing. 1015 // Extract the existing sounce=X value. Default to "2" if missing.
1003 SyncPromoUI::Source source = 1016 SyncPromoUI::Source source =
1004 SyncPromoUI::GetSourceForSyncPromoURL(continue_url_); 1017 SyncPromoUI::GetSourceForSyncPromoURL(continue_url_);
1005 if (source == SyncPromoUI::SOURCE_UNKNOWN) 1018 if (source == SyncPromoUI::SOURCE_UNKNOWN)
1006 source = SyncPromoUI::SOURCE_MENU; 1019 source = SyncPromoUI::SOURCE_MENU;
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 password_); 1236 password_);
1224 } 1237 }
1225 break; 1238 break;
1226 case AUTO_ACCEPT_ACCEPTED: 1239 case AUTO_ACCEPT_ACCEPTED:
1227 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); 1240 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED);
1228 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); 1241 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS);
1229 SigninManager::DisableOneClickSignIn(profile); 1242 SigninManager::DisableOneClickSignIn(profile);
1230 browser->window()->ShowOneClickSigninBubble( 1243 browser->window()->ShowOneClickSigninBubble(
1231 bubble_type, 1244 bubble_type,
1232 UTF8ToUTF16(email_), 1245 UTF8ToUTF16(email_),
1246 string16(), /* no error message to display */
1233 base::Bind(&StartSync, 1247 base::Bind(&StartSync,
1234 StartSyncArgs(profile, browser, auto_accept_, 1248 StartSyncArgs(profile, browser, auto_accept_,
1235 session_index_, email_, password_, 1249 session_index_, email_, password_,
1236 false /* force_same_tab_navigation */))); 1250 false /* force_same_tab_navigation */)));
1237 break; 1251 break;
1238 case AUTO_ACCEPT_CONFIGURE: 1252 case AUTO_ACCEPT_CONFIGURE:
1239 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); 1253 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED);
1240 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); 1254 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED);
1241 SigninManager::DisableOneClickSignIn(profile); 1255 SigninManager::DisableOneClickSignIn(profile);
1242 StartSync( 1256 StartSync(
(...skipping 18 matching lines...) Expand all
1261 1275
1262 std::string last_email = 1276 std::string last_email =
1263 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername); 1277 profile->GetPrefs()->GetString(prefs::kGoogleServicesLastUsername);
1264 1278
1265 if (!is_trusted_) { 1279 if (!is_trusted_) {
1266 // The user has navigated away from valid Gaia URLs during sign in, 1280 // The user has navigated away from valid Gaia URLs during sign in,
1267 // verify this sign in is desired. 1281 // verify this sign in is desired.
1268 browser->window()->ShowOneClickSigninBubble( 1282 browser->window()->ShowOneClickSigninBubble(
1269 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_SAML_MODAL_DIALOG, 1283 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_SAML_MODAL_DIALOG,
1270 UTF8ToUTF16(email_), 1284 UTF8ToUTF16(email_),
1285 string16(), /* no error message to display */
1271 base::Bind(&StartSync, 1286 base::Bind(&StartSync,
1272 StartSyncArgs(profile, browser, auto_accept_, 1287 StartSyncArgs(profile, browser, auto_accept_,
1273 session_index_, email_, password_, 1288 session_index_, email_, password_,
1274 force_same_tab_navigation))); 1289 force_same_tab_navigation)));
1275 } else if (!last_email.empty() && last_email != email_) { 1290 } else if (!last_email.empty() && last_email != email_) {
1276 // If the new email address is different from the email address that 1291 // If the new email address is different from the email address that
1277 // just signed in, show a confirmation dialog. 1292 // just signed in, show a confirmation dialog.
1278 ConfirmEmailDialogDelegate::AskForConfirmation( 1293 ConfirmEmailDialogDelegate::AskForConfirmation(
1279 contents, 1294 contents,
1280 last_email, 1295 last_email,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1376 // If the user cancelled signin, then no need to display any error 1391 // If the user cancelled signin, then no need to display any error
1377 // messages or anything - just go back to the NTP. 1392 // messages or anything - just go back to the NTP.
1378 error_message_.clear(); 1393 error_message_.clear();
1379 display_bubble = false; 1394 display_bubble = false;
1380 break; 1395 break;
1381 default: 1396 default:
1382 error_message_ = l10n_util::GetStringUTF8(IDS_SYNC_ERROR_SIGNING_IN); 1397 error_message_ = l10n_util::GetStringUTF8(IDS_SYNC_ERROR_SIGNING_IN);
1383 break; 1398 break;
1384 } 1399 }
1385 } 1400 }
1386 RedirectOnSigninComplete(display_bubble); 1401 ShowSyncConfirmationBubble(display_bubble);
1402 signin_tracker_.reset();
1387 } 1403 }
1388 1404
1389 void OneClickSigninHelper::SigninSuccess() { 1405 void OneClickSigninHelper::SigninSuccess() {
1390 RedirectOnSigninComplete(true); 1406 ShowSyncConfirmationBubble(true);
1391 }
1392
1393 void OneClickSigninHelper::RedirectOnSigninComplete(bool show_bubble) {
1394 // Show the result in the sign-in bubble if desired.
1395 RedirectToNtpOrAppsPage(show_bubble);
1396 signin_tracker_.reset(); 1407 signin_tracker_.reset();
1397 } 1408 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.h ('k') | chrome/browser/ui/sync/one_click_signin_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698