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

Unified Diff: chrome/browser/ui/sync/one_click_signin_helper.cc

Issue 22510004: Show sync setup in same tab as sign in instead of active tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add web_contents parameter to ShowSyncSettingsPageInWebContents Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/sync/one_click_signin_sync_starter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/sync/one_click_signin_helper.cc
diff --git a/chrome/browser/ui/sync/one_click_signin_helper.cc b/chrome/browser/ui/sync/one_click_signin_helper.cc
index eb26b2088fbdf4e2af60563c1df8781131507824..363aa209d8527f4943451260fc36a5033c185774 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper.cc
@@ -93,7 +93,7 @@ struct StartSyncArgs {
const std::string& session_index,
const std::string& email,
const std::string& password,
- bool force_same_tab_navigation,
+ content::WebContents* web_contents,
bool untrusted_confirmation_required,
signin::Source source,
OneClickSigninSyncStarter::Callback callback);
@@ -104,7 +104,11 @@ struct StartSyncArgs {
std::string session_index;
std::string email;
std::string password;
- bool force_same_tab_navigation;
+
+ // Web contents in which the sync setup page should be displayed,
+ // if necessary. Can be NULL.
+ content::WebContents* web_contents;
+
OneClickSigninSyncStarter::ConfirmationRequired confirmation_required;
signin::Source source;
OneClickSigninSyncStarter::Callback callback;
@@ -116,7 +120,7 @@ StartSyncArgs::StartSyncArgs(Profile* profile,
const std::string& session_index,
const std::string& email,
const std::string& password,
- bool force_same_tab_navigation,
+ content::WebContents* web_contents,
bool untrusted_confirmation_required,
signin::Source source,
OneClickSigninSyncStarter::Callback callback)
@@ -126,7 +130,7 @@ StartSyncArgs::StartSyncArgs(Profile* profile,
session_index(session_index),
email(email),
password(password),
- force_same_tab_navigation(force_same_tab_navigation),
+ web_contents(web_contents),
source(source),
callback(callback) {
if (untrusted_confirmation_required) {
@@ -243,7 +247,7 @@ void StartSync(const StartSyncArgs& args,
// The starter deletes itself once its done.
new OneClickSigninSyncStarter(args.profile, args.browser, args.session_index,
args.email, args.password, start_mode,
- args.force_same_tab_navigation,
+ args.web_contents,
args.confirmation_required,
args.source,
args.callback);
@@ -1143,8 +1147,9 @@ void OneClickSigninHelper::DidStopLoading(
// checked, the source parameter will indicate settings. This will only be
// communicated back to chrome when Gaia redirects to the continue URL, and
// this is considered here a last minute change to the source. See a little
- // further below for when this variable is set to true.
- bool force_same_tab_navigation = false;
+ // further below for when this variable is set to a web contents that must be
+ // used to show the sync setup page.
+ content::WebContents* sync_setup_contents = NULL;
if (!continue_url_match && IsValidGaiaSigninRedirectOrResponseURL(url))
return;
@@ -1180,8 +1185,10 @@ void OneClickSigninHelper::DidStopLoading(
signin::Source source = signin::GetSourceForPromoURL(url);
if (source != source_) {
source_ = source;
- force_same_tab_navigation = source == signin::SOURCE_SETTINGS;
- switched_to_advanced_ = source == signin::SOURCE_SETTINGS;
+ if (source == signin::SOURCE_SETTINGS) {
+ sync_setup_contents = web_contents();
+ switched_to_advanced_ = true;
+ }
}
}
@@ -1202,12 +1209,13 @@ void OneClickSigninHelper::DidStopLoading(
SigninManager::DisableOneClickSignIn(profile);
// Start syncing with the default settings - prompt the user to sign in
// first.
- StartSync(StartSyncArgs(profile, browser, auto_accept_,
- session_index_, email_, password_,
- false /* force_same_tab_navigation */,
- true /* confirmation_required */, source_,
- CreateSyncStarterCallback()),
- OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS);
+ StartSync(
+ StartSyncArgs(profile, browser, auto_accept_,
+ session_index_, email_, password_,
+ NULL /* don't force to show sync setup in same tab */,
+ true /* confirmation_required */, source_,
+ CreateSyncStarterCallback()),
+ OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS);
break;
case AUTO_ACCEPT_CONFIGURE:
LogOneClickHistogramValue(one_click_signin::HISTOGRAM_ACCEPTED);
@@ -1216,8 +1224,9 @@ void OneClickSigninHelper::DidStopLoading(
// Display the extra confirmation (even in the SAML case) in case this
// was an untrusted renderer.
StartSync(
- StartSyncArgs(profile, browser, auto_accept_, session_index_, email_,
- password_, false /* force_same_tab_navigation */,
+ StartSyncArgs(profile, browser, auto_accept_,
+ session_index_, email_, password_,
+ NULL /* don't force to show sync setup in same tab */,
true /* confirmation_required */, source_,
CreateSyncStarterCallback()),
OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST);
@@ -1257,6 +1266,8 @@ void OneClickSigninHelper::DidStopLoading(
// No need to display a second confirmation so pass false below.
// TODO(atwilson): Move this into OneClickSigninSyncStarter.
+ // If |sync_setup_contents| is deleted before the callback execution,
+ // the tab modal dialog is closed and the callback is never executed.
ConfirmEmailDialogDelegate::AskForConfirmation(
contents,
last_email,
@@ -1265,7 +1276,7 @@ void OneClickSigninHelper::DidStopLoading(
&StartExplicitSync,
StartSyncArgs(profile, browser, auto_accept_,
session_index_, email_, password_,
- force_same_tab_navigation,
+ sync_setup_contents,
false /* confirmation_required */, source_,
CreateSyncStarterCallback()),
contents,
@@ -1273,7 +1284,7 @@ void OneClickSigninHelper::DidStopLoading(
} else {
StartSync(
StartSyncArgs(profile, browser, auto_accept_, session_index_,
- email_, password_, force_same_tab_navigation,
+ email_, password_, sync_setup_contents,
untrusted_confirmation_required_, source_,
CreateSyncStarterCallback()),
start_mode);
« no previous file with comments | « no previous file | chrome/browser/ui/sync/one_click_signin_sync_starter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698