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

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: Lint + review fixes 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 507 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 base::Bind(&StartSync, 524 base::Bind(&StartSync,
525 StartSyncArgs(profile, browser, 525 StartSyncArgs(profile, browser,
526 OneClickSigninHelper::AUTO_ACCEPT_NONE, 526 OneClickSigninHelper::AUTO_ACCEPT_NONE,
527 session_index_, email_, password_, 527 session_index_, email_, password_,
528 false /* force_same_tab_navigation */))); 528 false /* force_same_tab_navigation */)),
529 std::string() /* no error message to display */);
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() {
534 AddEmailToOneClickRejectedList(Profile::FromBrowserContext( 535 AddEmailToOneClickRejectedList(Profile::FromBrowserContext(
535 owner()->GetWebContents()->GetBrowserContext()), email_); 536 owner()->GetWebContents()->GetBrowserContext()), email_);
536 RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED); 537 RecordHistogramAction(one_click_signin::HISTOGRAM_REJECTED);
537 button_pressed_ = true; 538 button_pressed_ = true;
538 return true; 539 return true;
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 helper->continue_url_ = continue_url; 972 helper->continue_url_ = continue_url;
972 } 973 }
973 974
974 void OneClickSigninHelper::RedirectToNtpOrAppsPage(bool show_bubble) { 975 void OneClickSigninHelper::RedirectToNtpOrAppsPage(bool show_bubble) {
975 VLOG(1) << "OneClickSigninHelper::RedirectToNtpOrAppsPage"; 976 VLOG(1) << "OneClickSigninHelper::RedirectToNtpOrAppsPage";
976 977
977 // Redirect to NTP/Apps page with sign in bubble visible. 978 // Redirect to NTP/Apps page with sign in bubble visible.
978 content::WebContents* contents = web_contents(); 979 content::WebContents* contents = web_contents();
979 Profile* profile = 980 Profile* profile =
980 Profile::FromBrowserContext(contents->GetBrowserContext()); 981 Profile::FromBrowserContext(contents->GetBrowserContext());
981 PrefService* pref_service = profile->GetPrefs(); 982 Browser* browser = chrome::FindBrowserWithWebContents(contents);
Roger Tawa OOO till Jul 10th 2013/04/17 17:53:25 Move the var declaration closer to where its used
noms (inactive) 2013/04/17 20:32:37 Done.
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->window()->ShowOneClickSigninBubble(
995 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_BUBBLE,
996 string16(), /* no SAML email */
997 base::Bind(&StartSync,
998 StartSyncArgs(profile, browser, AUTO_ACCEPT_ACCEPTED,
999 session_index_, email_, password_,
1000 false)),
1001 error_message_);
1002 }
1003
996 error_message_.clear(); 1004 error_message_.clear();
997 } 1005 }
998 1006
999 void OneClickSigninHelper::RedirectToSignin() { 1007 void OneClickSigninHelper::RedirectToSignin() {
1000 VLOG(1) << "OneClickSigninHelper::RedirectToSignin"; 1008 VLOG(1) << "OneClickSigninHelper::RedirectToSignin";
1001 1009
1002 // Extract the existing sounce=X value. Default to "2" if missing. 1010 // Extract the existing sounce=X value. Default to "2" if missing.
1003 SyncPromoUI::Source source = 1011 SyncPromoUI::Source source =
1004 SyncPromoUI::GetSourceForSyncPromoURL(continue_url_); 1012 SyncPromoUI::GetSourceForSyncPromoURL(continue_url_);
1005 if (source == SyncPromoUI::SOURCE_UNKNOWN) 1013 if (source == SyncPromoUI::SOURCE_UNKNOWN)
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 case AUTO_ACCEPT_ACCEPTED: 1234 case AUTO_ACCEPT_ACCEPTED:
1227 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); 1235 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED);
1228 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS); 1236 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_DEFAULTS);
1229 SigninManager::DisableOneClickSignIn(profile); 1237 SigninManager::DisableOneClickSignIn(profile);
1230 browser->window()->ShowOneClickSigninBubble( 1238 browser->window()->ShowOneClickSigninBubble(
1231 bubble_type, 1239 bubble_type,
1232 UTF8ToUTF16(email_), 1240 UTF8ToUTF16(email_),
1233 base::Bind(&StartSync, 1241 base::Bind(&StartSync,
1234 StartSyncArgs(profile, browser, auto_accept_, 1242 StartSyncArgs(profile, browser, auto_accept_,
1235 session_index_, email_, password_, 1243 session_index_, email_, password_,
1236 false /* force_same_tab_navigation */))); 1244 false /* force_same_tab_navigation */)),
1245 error_message_);
Roger Tawa OOO till Jul 10th 2013/04/17 17:53:25 why not std::string() like line 1284 below? Will
noms (inactive) 2013/04/17 20:32:37 Done.
1237 break; 1246 break;
1238 case AUTO_ACCEPT_CONFIGURE: 1247 case AUTO_ACCEPT_CONFIGURE:
1239 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED); 1248 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED);
1240 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED); 1249 LogOneClickHistogramValue(one_click_signin::HISTOGRAM_WITH_ADVANCED);
1241 SigninManager::DisableOneClickSignIn(profile); 1250 SigninManager::DisableOneClickSignIn(profile);
1242 StartSync( 1251 StartSync(
1243 StartSyncArgs(profile, browser, auto_accept_, session_index_, email_, 1252 StartSyncArgs(profile, browser, auto_accept_, session_index_, email_,
1244 password_, false /* force_same_tab_navigation */), 1253 password_, false /* force_same_tab_navigation */),
1245 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); 1254 OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST);
1246 break; 1255 break;
(...skipping 17 matching lines...) Expand all
1264 1273
1265 if (!is_trusted_) { 1274 if (!is_trusted_) {
1266 // The user has navigated away from valid Gaia URLs during sign in, 1275 // The user has navigated away from valid Gaia URLs during sign in,
1267 // verify this sign in is desired. 1276 // verify this sign in is desired.
1268 browser->window()->ShowOneClickSigninBubble( 1277 browser->window()->ShowOneClickSigninBubble(
1269 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_SAML_MODAL_DIALOG, 1278 BrowserWindow::ONE_CLICK_SIGNIN_BUBBLE_TYPE_SAML_MODAL_DIALOG,
1270 UTF8ToUTF16(email_), 1279 UTF8ToUTF16(email_),
1271 base::Bind(&StartSync, 1280 base::Bind(&StartSync,
1272 StartSyncArgs(profile, browser, auto_accept_, 1281 StartSyncArgs(profile, browser, auto_accept_,
1273 session_index_, email_, password_, 1282 session_index_, email_, password_,
1274 force_same_tab_navigation))); 1283 force_same_tab_navigation)),
1284 std::string() /* no error message to display */);
1275 } else if (!last_email.empty() && last_email != email_) { 1285 } else if (!last_email.empty() && last_email != email_) {
1276 // If the new email address is different from the email address that 1286 // If the new email address is different from the email address that
1277 // just signed in, show a confirmation dialog. 1287 // just signed in, show a confirmation dialog.
1278 ConfirmEmailDialogDelegate::AskForConfirmation( 1288 ConfirmEmailDialogDelegate::AskForConfirmation(
1279 contents, 1289 contents,
1280 last_email, 1290 last_email,
1281 email_, 1291 email_,
1282 base::Bind( 1292 base::Bind(
1283 &StartExplicitSync, 1293 &StartExplicitSync,
1284 StartSyncArgs(profile, browser, auto_accept_, 1294 StartSyncArgs(profile, browser, auto_accept_,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1388 1398
1389 void OneClickSigninHelper::SigninSuccess() { 1399 void OneClickSigninHelper::SigninSuccess() {
1390 RedirectOnSigninComplete(true); 1400 RedirectOnSigninComplete(true);
1391 } 1401 }
1392 1402
1393 void OneClickSigninHelper::RedirectOnSigninComplete(bool show_bubble) { 1403 void OneClickSigninHelper::RedirectOnSigninComplete(bool show_bubble) {
1394 // Show the result in the sign-in bubble if desired. 1404 // Show the result in the sign-in bubble if desired.
1395 RedirectToNtpOrAppsPage(show_bubble); 1405 RedirectToNtpOrAppsPage(show_bubble);
1396 signin_tracker_.reset(); 1406 signin_tracker_.reset();
1397 } 1407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698