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

Unified Diff: chrome/browser/signin/signin_promo.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: Add API tests 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/signin/signin_promo.cc
diff --git a/chrome/browser/signin/signin_promo.cc b/chrome/browser/signin/signin_promo.cc
index be633aca22a9e59eab23075232c91d18422a8444..7bc7661f03673548e7888af0046dea67573bcac5 100644
--- a/chrome/browser/signin/signin_promo.cc
+++ b/chrome/browser/signin/signin_promo.cc
@@ -40,11 +40,13 @@
#include "ui/base/l10n/l10n_util.h"
using content::WebContents;
+using net::GetValueForKeyInQuery;
namespace {
const char kSignInPromoQueryKeyAutoClose[] = "auto_close";
const char kSignInPromoQueryKeyContinue[] = "continue";
+const char kSignInPromoQueryKeyContinueUrl[] = "continue_url";
const char kSignInPromoQueryKeySource[] = "source";
const char kSignInPromoQueryKeyConstrained[] = "constrained";
@@ -178,6 +180,13 @@ GURL GetPromoURL(Source source, bool auto_close) {
}
GURL GetPromoURL(Source source, bool auto_close, bool is_constrained) {
+ return GetPromoURLWithContinueURL(source, auto_close, is_constrained, GURL());
+}
+
+GURL GetPromoURLWithContinueURL(Source source,
+ bool auto_close,
+ bool is_constrained,
+ GURL continue_url) {
DCHECK_NE(SOURCE_UNKNOWN, source);
if (!switches::IsEnableWebBasedSignin()) {
@@ -187,6 +196,15 @@ GURL GetPromoURL(Source source, bool auto_close, bool is_constrained) {
base::StringAppendF(&url, "&%s=1", kSignInPromoQueryKeyAutoClose);
if (is_constrained)
base::StringAppendF(&url, "&%s=1", kSignInPromoQueryKeyConstrained);
+ if (!continue_url.is_empty()) {
+ DCHECK(continue_url.is_valid());
+ std::string escaped_continue_url =
+ net::EscapeQueryParamValue(continue_url.spec(), false);
+ base::StringAppendF(&url,
+ "&%s=%s",
+ kSignInPromoQueryKeyContinueUrl,
+ escaped_continue_url.c_str());
+ }
return GURL(url);
}
@@ -206,14 +224,19 @@ GURL GetPromoURL(Source source, bool auto_close, bool is_constrained) {
// See OneClickSigninHelper for details.
std::string query_string = "?service=chromiumsync&sarp=1";
- std::string continue_url = GetLandingURL(kSignInPromoQueryKeySource,
- static_cast<int>(source)).spec();
- if (auto_close)
- base::StringAppendF(&continue_url, "&%s=1", kSignInPromoQueryKeyAutoClose);
+ DCHECK(continue_url.is_empty());
+ std::string continue_url_str = GetLandingURL(kSignInPromoQueryKeySource,
+ static_cast<int>(source)).spec();
+ if (auto_close) {
+ base::StringAppendF(
+ &continue_url_str, "&%s=1", kSignInPromoQueryKeyAutoClose);
+ }
- base::StringAppendF(&query_string, "&%s=%s", kSignInPromoQueryKeyContinue,
- net::EscapeQueryParamValue(
- continue_url, false).c_str());
+ base::StringAppendF(
+ &query_string,
+ "&%s=%s",
+ kSignInPromoQueryKeyContinue,
+ net::EscapeQueryParamValue(continue_url_str, false).c_str());
return GaiaUrls::GetInstance()->service_login_url().Resolve(query_string);
}
@@ -240,15 +263,22 @@ GURL GetReauthURL(Profile* profile, const std::string& account_id) {
GURL GetNextPageURLForPromoURL(const GURL& url) {
std::string value;
- if (net::GetValueForKeyInQuery(url, kSignInPromoQueryKeyContinue, &value))
+ if (GetValueForKeyInQuery(url, kSignInPromoQueryKeyContinue, &value))
return GURL(value);
+ value = std::string();
+ if (GetValueForKeyInQuery(url, kSignInPromoQueryKeyContinueUrl, &value)) {
+ GURL continue_url = GURL(value);
+ if (continue_url.is_valid())
+ return continue_url;
+ }
+
return GURL();
}
Source GetSourceForPromoURL(const GURL& url) {
std::string value;
- if (net::GetValueForKeyInQuery(url, kSignInPromoQueryKeySource, &value)) {
+ if (GetValueForKeyInQuery(url, kSignInPromoQueryKeySource, &value)) {
int source = 0;
if (base::StringToInt(value, &source) && source >= SOURCE_START_PAGE &&
source < SOURCE_UNKNOWN) {
@@ -260,7 +290,7 @@ Source GetSourceForPromoURL(const GURL& url) {
bool IsAutoCloseEnabledInURL(const GURL& url) {
std::string value;
- if (net::GetValueForKeyInQuery(url, kSignInPromoQueryKeyAutoClose, &value)) {
+ if (GetValueForKeyInQuery(url, kSignInPromoQueryKeyAutoClose, &value)) {
int enabled = 0;
if (base::StringToInt(value, &enabled) && enabled == 1)
return true;

Powered by Google App Engine
This is Rietveld 408576698