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

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

Issue 196783002: Export a private webstore API to call into the new inline sign-in flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Redirect to the continue URL when Sync is disabled Created 6 years, 9 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 84a44203d815e891ee489c4a3cded441856e0e7e..50367c9f8fcb6bcc18bbebf9c678924b24d4f4b1 100644
--- a/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
+++ b/chrome/browser/ui/sync/one_click_signin_sync_starter.cc
@@ -30,6 +30,7 @@
#include "chrome/browser/ui/browser_tabstrip.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
+#include "chrome/browser/ui/sync/one_click_signin_sync_observer.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/webui/signin/login_ui_service.h"
#include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
@@ -51,14 +52,17 @@ OneClickSigninSyncStarter::OneClickSigninSyncStarter(
StartSyncMode start_mode,
content::WebContents* web_contents,
ConfirmationRequired confirmation_required,
+ const GURL& continue_url,
Callback sync_setup_completed_callback)
: content::WebContentsObserver(web_contents),
start_mode_(start_mode),
desktop_type_(chrome::HOST_DESKTOP_TYPE_NATIVE),
confirmation_required_(confirmation_required),
+ continue_url_(continue_url),
sync_setup_completed_callback_(sync_setup_completed_callback),
weak_pointer_factory_(this) {
DCHECK(profile);
+ DCHECK(web_contents || continue_url.is_empty());
BrowserList::AddObserver(this);
Initialize(profile, browser);
@@ -398,9 +402,17 @@ void OneClickSigninSyncStarter::MergeSessionComplete(
case SHOW_SETTINGS_WITHOUT_CONFIGURE:
ShowSettingsPage(false); // Don't show sync config UI.
break;
- default:
+ case UNDO_SYNC:
NOTREACHED();
}
+
+ // Navigate to the |continue_url_| if one is set, unless the user first needs
+ // to configure Sync.
+ if (web_contents() && !continue_url_.is_empty() &&
+ start_mode_ != CONFIGURE_SYNC_FIRST) {
+ LoadContinueUrl();
+ }
+
delete this;
}
@@ -481,12 +493,15 @@ void OneClickSigninSyncStarter::ShowSettingsPage(bool configure_sync) {
}
}
} else {
- // Sync is disabled - just display the settings page.
+ // Sync is disabled - just display the settings page or redirect to the
+ // |continue_url_|.
FinishProfileSyncServiceSetup();
- if (use_same_tab)
- ShowSettingsPageInWebContents(web_contents(), std::string());
- else
+ if (!use_same_tab)
chrome::ShowSettings(browser_);
+ else if (!continue_url_.is_empty())
+ LoadContinueUrl();
+ else
+ ShowSettingsPageInWebContents(web_contents(), std::string());
}
}
}
@@ -508,6 +523,13 @@ void OneClickSigninSyncStarter::FinishProfileSyncServiceSetup() {
void OneClickSigninSyncStarter::ShowSettingsPageInWebContents(
content::WebContents* contents,
const std::string& sub_page) {
+ if (!continue_url_.is_empty()) {
+ // This case should only be reachable when configuring Sync.
+ // The observer deletes itself once it's done.
+ DCHECK_EQ(sub_page, chrome::kSyncSetupSubPage);
+ new OneClickSigninSyncObserver(contents, continue_url_);
+ }
+
GURL url = chrome::GetSettingsUrl(sub_page);
content::OpenURLParams params(url,
content::Referrer(),
@@ -523,3 +545,11 @@ void OneClickSigninSyncStarter::ShowSettingsPageInWebContents(
browser->tab_strip_model()->ActivateTabAt(content_index,
false /* user_gesture */);
}
+
+void OneClickSigninSyncObserver::LoadContinueUrl() {
+ web_contents()->GetController().LoadURL(
+ continue_url_,
+ content::Referrer(),
+ content::PAGE_TRANSITION_AUTO_TOPLEVEL,
+ std::string());
+}

Powered by Google App Engine
This is Rietveld 408576698