diff options
author | guohui@chromium.org <guohui@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-09 04:41:34 +0000 |
---|---|---|
committer | guohui@chromium.org <guohui@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-09 04:41:34 +0000 |
commit | e3d89ffff503cef678788fb547f2c2ab07f8527c (patch) | |
tree | 5945c6d895584de7c578fa933f44dce0a0365389 | |
parent | ed3668b12a4a4048024f65fcbffd8a1e2aeb7676 (diff) | |
download | chromium_src-e3d89ffff503cef678788fb547f2c2ab07f8527c.zip chromium_src-e3d89ffff503cef678788fb547f2c2ab07f8527c.tar.gz chromium_src-e3d89ffff503cef678788fb547f2c2ab07f8527c.tar.bz2 |
Use embedded sign in UI for inline sign in flow
BUG=315259
Review URL: https://codereview.chromium.org/66403006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@234093 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/resources/gaia_auth/main.js | 16 | ||||
-rw-r--r-- | chrome/browser/resources/gaia_auth/util.js | 17 | ||||
-rw-r--r-- | chrome/browser/resources/gaia_auth_host/gaia_auth_host.js | 1 | ||||
-rw-r--r-- | chrome/browser/ui/views/profile_chooser_view.cc | 2 | ||||
-rw-r--r-- | chrome/browser/ui/webui/inline_login_ui.cc | 18 | ||||
-rw-r--r-- | google_apis/gaia/gaia_urls.cc | 6 | ||||
-rw-r--r-- | google_apis/gaia/gaia_urls.h | 2 |
7 files changed, 45 insertions, 17 deletions
diff --git a/chrome/browser/resources/gaia_auth/main.js b/chrome/browser/resources/gaia_auth/main.js index 6b413e6..ced0c3d 100644 --- a/chrome/browser/resources/gaia_auth/main.js +++ b/chrome/browser/resources/gaia_auth/main.js @@ -48,6 +48,7 @@ Authenticator.prototype = { var params = getUrlSearchParams(location.search); this.parentPage_ = params.parentPage || this.PARENT_PAGE; this.gaiaUrl_ = params.gaiaUrl || this.GAIA_URL; + this.gaiaPath_ = params.gaiaPath || this.GAIA_PAGE_PATH; this.inputLang_ = params.hl; this.inputEmail_ = params.email; this.service_ = params.service || this.SERVICE_ID; @@ -77,16 +78,15 @@ Authenticator.prototype = { }, getFrameUrl_: function() { - var url = this.gaiaUrl_; - - url += this.GAIA_PAGE_PATH + - '&service=' + encodeURIComponent(this.service_) + - '&continue=' + encodeURIComponent(this.continueUrl_); + var url = this.gaiaUrl_ + this.gaiaPath_; + url = appendParam(url, 'service', this.service_); + url = appendParam(url, 'continue', this.continueUrl_); if (this.inputLang_) - url += '&hl=' + encodeURIComponent(this.inputLang_); + url = appendParam(url, 'hl', this.inputLang_); if (this.inputEmail_) - url += '&Email=' + encodeURIComponent(this.inputEmail_); + url = appendParam(url, 'Email', this.inputEmail_); + return url; }, @@ -101,7 +101,7 @@ Authenticator.prototype = { window.parent.postMessage(msg, this.parentPage_); if (gaiaFrame.src.lastIndexOf( - this.gaiaUrl_ + this.GAIA_PAGE_PATH, 0) == 0) { + this.gaiaUrl_ + this.gaiaPath_, 0) == 0) { gaiaFrame.executeScript({file: 'inline_injected.js'}, function() { // Send an initial message to gaia so that it has an JavaScript // reference to the embedder. diff --git a/chrome/browser/resources/gaia_auth/util.js b/chrome/browser/resources/gaia_auth/util.js index 33d344c..3735ae7 100644 --- a/chrome/browser/resources/gaia_auth/util.js +++ b/chrome/browser/resources/gaia_auth/util.js @@ -25,3 +25,20 @@ function getUrlSearchParams(search) { return params; } + +/** + * Creates a new URL which is the old URL with a GET param of key=value. + * Copied from ui/webui/resources/js/util.js. + * @param {string} url The base URL. There is not sanity checking on the URL so + * it must be passed in a proper format. + * @param {string} key The key of the param. + * @param {string} value The value of the param. + * @return {string} The new URL. + */ +function appendParam(url, key, value) { + var param = encodeURIComponent(key) + '=' + encodeURIComponent(value); + + if (url.indexOf('?') == -1) + return url + '?' + param; + return url + '&' + param; +} diff --git a/chrome/browser/resources/gaia_auth_host/gaia_auth_host.js b/chrome/browser/resources/gaia_auth_host/gaia_auth_host.js index bffe34fb..67f2083 100644 --- a/chrome/browser/resources/gaia_auth_host/gaia_auth_host.js +++ b/chrome/browser/resources/gaia_auth_host/gaia_auth_host.js @@ -54,6 +54,7 @@ cr.define('cr.login', function() { */ var SUPPORTED_PARAMS = [ 'gaiaUrl', // Gaia url to use; + 'gaiaPath', // Gaia path to use without a leading slash; 'hl', // Language code for the user interface; 'email', // Pre-fill the email field in Gaia UI; 'service', // Name of Gaia service; diff --git a/chrome/browser/ui/views/profile_chooser_view.cc b/chrome/browser/ui/views/profile_chooser_view.cc index 4e2c40f..f7ebccd 100644 --- a/chrome/browser/ui/views/profile_chooser_view.cc +++ b/chrome/browser/ui/views/profile_chooser_view.cc @@ -311,7 +311,7 @@ void ProfileChooserView::ShowView(BubbleViewMode view_to_display, view_to_display == GAIA_ADD_ACCOUNT_VIEW) { // Minimum size for embedded sign in pages as defined in Gaia. const int kMinGaiaViewWidth = 320; - const int kMinGaiaViewHeight = 500; + const int kMinGaiaViewHeight = 440; Profile* profile = browser_->profile(); views::WebView* web_view = new views::WebView(profile); signin::Source source = (view_to_display == GAIA_SIGNIN_VIEW) ? diff --git a/chrome/browser/ui/webui/inline_login_ui.cc b/chrome/browser/ui/webui/inline_login_ui.cc index cc7be52..12e04ea 100644 --- a/chrome/browser/ui/webui/inline_login_ui.cc +++ b/chrome/browser/ui/webui/inline_login_ui.cc @@ -151,17 +151,19 @@ class InlineLoginUIHandler : public content::WebUIMessageHandler { const GURL& current_url = web_ui()->GetWebContents()->GetURL(); signin::Source source = signin::GetSourceForPromoURL(current_url); - // TODO(guohui): switch to the embedded gaia endpoint for avatar flows - // when available. DCHECK(source != signin::SOURCE_UNKNOWN); - if (source != signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT && - source != signin::SOURCE_AVATAR_BUBBLE_SIGN_IN) { - params.SetString("service", "chromiumsync"); - base::StringAppendF( - &encoded_continue_params, "&%s=%d", "source", - static_cast<int>(source)); + if (source == signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT || + source == signin::SOURCE_AVATAR_BUBBLE_SIGN_IN) { + // Drop the leading slash in the path. + params.SetString("gaiaPath", + gaiaUrls->embedded_signin_url().path().substr(1)); } + params.SetString("service", "chromiumsync"); + base::StringAppendF( + &encoded_continue_params, "&%s=%d", "source", + static_cast<int>(source)); + params.SetString("continueUrl", gaiaUrls->client_login_to_oauth2_url().Resolve( encoded_continue_params).spec()); diff --git a/google_apis/gaia/gaia_urls.cc b/google_apis/gaia/gaia_urls.cc index 16bd9d6..97020f0 100644 --- a/google_apis/gaia/gaia_urls.cc +++ b/google_apis/gaia/gaia_urls.cc @@ -29,6 +29,7 @@ const char kOAuthWrapBridgeUrlSuffix[] = "OAuthWrapBridge"; const char kOAuth1LoginUrlSuffix[] = "OAuthLogin"; const char kOAuthRevokeTokenUrlSuffix[] = "AuthSubRevokeToken"; const char kListAccountsSuffix[] = "ListAccounts"; +const char kEmbeddedSigninSuffix[] = "EmbeddedSignIn"; // OAuth scopes const char kOAuth1LoginScope[] = "https://www.google.com/accounts/OAuthLogin"; @@ -105,6 +106,7 @@ GaiaUrls::GaiaUrls() { oauth_revoke_token_url_ = gaia_url_.Resolve(kOAuthRevokeTokenUrlSuffix); oauth1_login_url_ = gaia_url_.Resolve(kOAuth1LoginUrlSuffix); list_accounts_url_ = gaia_url_.Resolve(kListAccountsSuffix); + embedded_signin_url_ = gaia_url_.Resolve(kEmbeddedSigninSuffix); // URLs from accounts.google.com (LSO). get_oauth_token_url_ = lso_origin_url_.Resolve(kGetOAuthTokenUrlSuffix); @@ -204,6 +206,10 @@ const GURL& GaiaUrls::list_accounts_url() const { return list_accounts_url_; } +const GURL& GaiaUrls::embedded_signin_url() const { + return embedded_signin_url_; +} + const std::string& GaiaUrls::oauth1_login_scope() const { return oauth1_login_scope_; } diff --git a/google_apis/gaia/gaia_urls.h b/google_apis/gaia/gaia_urls.h index 51addeb..a1bec87a 100644 --- a/google_apis/gaia/gaia_urls.h +++ b/google_apis/gaia/gaia_urls.h @@ -33,6 +33,7 @@ class GaiaUrls { const GURL& oauth_revoke_token_url() const; const GURL& oauth1_login_url() const; const GURL& list_accounts_url() const; + const GURL& embedded_signin_url() const; const std::string& oauth1_login_scope() const; const std::string& oauth_wrap_bridge_user_info_scope() const; @@ -75,6 +76,7 @@ class GaiaUrls { GURL oauth_revoke_token_url_; GURL oauth1_login_url_; GURL list_accounts_url_; + GURL embedded_signin_url_; std::string oauth1_login_scope_; std::string oauth_wrap_bridge_user_info_scope_; |