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

Unified Diff: chrome/browser/ui/sync/one_click_signin_sync_starter.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
Index: chrome/browser/ui/sync/one_click_signin_sync_starter.cc
diff --git a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
index d037dabbf65c76610a2f32540f3db8f5be98db44..884c09d12deffb074b1cf4ee5f8764e94831e65f 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
+++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
@@ -48,12 +48,12 @@ OneClickSigninSyncStarter::OneClickSigninSyncStarter(
const std::string& email,
const std::string& password,
StartSyncMode start_mode,
- bool force_same_tab_navigation,
+ content::WebContents* web_contents,
ConfirmationRequired confirmation_required,
signin::Source source,
Callback sync_setup_completed_callback)
- : start_mode_(start_mode),
- force_same_tab_navigation_(force_same_tab_navigation),
+ : content::WebContentsObserver(web_contents),
+ start_mode_(start_mode),
confirmation_required_(confirmation_required),
source_(source),
sync_setup_completed_callback_(sync_setup_completed_callback),
@@ -424,8 +424,8 @@ void OneClickSigninSyncStarter::ShowSettingsPageInNewTab(bool configure_sync) {
EnsureBrowser();
if (profile_sync_service) {
// Need to navigate to the settings page and display the sync UI.
- if (force_same_tab_navigation_) {
- ShowSyncSettingsPageOnSameTab();
+ if (web_contents()) {
+ ShowSyncSettingsPageInWebContents(web_contents());
} else {
// If the user is setting up sync for the first time, let them configure
// advanced sync settings. However, in the case of re-authentication,
@@ -459,12 +459,21 @@ void OneClickSigninSyncStarter::FinishProfileSyncServiceSetup() {
service->SetSetupInProgress(false);
}
-void OneClickSigninSyncStarter::ShowSyncSettingsPageOnSameTab() {
+void OneClickSigninSyncStarter::ShowSyncSettingsPageInWebContents(
+ content::WebContents* contents) {
std::string url = std::string(chrome::kChromeUISettingsURL) +
chrome::kSyncSetupSubPage;
- chrome::NavigateParams params(
- browser_, GURL(url), content::PAGE_TRANSITION_AUTO_TOPLEVEL);
- params.disposition = CURRENT_TAB;
- params.window_action = chrome::NavigateParams::SHOW_WINDOW;
- chrome::Navigate(&params);
+ content::OpenURLParams params(GURL(url),
+ content::Referrer(),
+ CURRENT_TAB,
+ content::PAGE_TRANSITION_AUTO_TOPLEVEL,
+ false);
+ contents->OpenURL(params);
+
+ // Activate the tab.
+ Browser* browser = chrome::FindBrowserWithWebContents(contents);
+ int content_index =
+ browser->tab_strip_model()->GetIndexOfWebContents(contents);
+ browser->tab_strip_model()->ActivateTabAt(content_index,
+ false /* user_gesture */);
}

Powered by Google App Engine
This is Rietveld 408576698