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
This commit is contained in:
chrome/browser
resources
ui
google_apis/gaia
@ -48,6 +48,7 @@ Authenticator.prototype = {
|
|||||||
var params = getUrlSearchParams(location.search);
|
var params = getUrlSearchParams(location.search);
|
||||||
this.parentPage_ = params.parentPage || this.PARENT_PAGE;
|
this.parentPage_ = params.parentPage || this.PARENT_PAGE;
|
||||||
this.gaiaUrl_ = params.gaiaUrl || this.GAIA_URL;
|
this.gaiaUrl_ = params.gaiaUrl || this.GAIA_URL;
|
||||||
|
this.gaiaPath_ = params.gaiaPath || this.GAIA_PAGE_PATH;
|
||||||
this.inputLang_ = params.hl;
|
this.inputLang_ = params.hl;
|
||||||
this.inputEmail_ = params.email;
|
this.inputEmail_ = params.email;
|
||||||
this.service_ = params.service || this.SERVICE_ID;
|
this.service_ = params.service || this.SERVICE_ID;
|
||||||
@ -77,16 +78,15 @@ Authenticator.prototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
getFrameUrl_: function() {
|
getFrameUrl_: function() {
|
||||||
var url = this.gaiaUrl_;
|
var url = this.gaiaUrl_ + this.gaiaPath_;
|
||||||
|
|
||||||
url += this.GAIA_PAGE_PATH +
|
|
||||||
'&service=' + encodeURIComponent(this.service_) +
|
|
||||||
'&continue=' + encodeURIComponent(this.continueUrl_);
|
|
||||||
|
|
||||||
|
url = appendParam(url, 'service', this.service_);
|
||||||
|
url = appendParam(url, 'continue', this.continueUrl_);
|
||||||
if (this.inputLang_)
|
if (this.inputLang_)
|
||||||
url += '&hl=' + encodeURIComponent(this.inputLang_);
|
url = appendParam(url, 'hl', this.inputLang_);
|
||||||
if (this.inputEmail_)
|
if (this.inputEmail_)
|
||||||
url += '&Email=' + encodeURIComponent(this.inputEmail_);
|
url = appendParam(url, 'Email', this.inputEmail_);
|
||||||
|
|
||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ Authenticator.prototype = {
|
|||||||
window.parent.postMessage(msg, this.parentPage_);
|
window.parent.postMessage(msg, this.parentPage_);
|
||||||
|
|
||||||
if (gaiaFrame.src.lastIndexOf(
|
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() {
|
gaiaFrame.executeScript({file: 'inline_injected.js'}, function() {
|
||||||
// Send an initial message to gaia so that it has an JavaScript
|
// Send an initial message to gaia so that it has an JavaScript
|
||||||
// reference to the embedder.
|
// reference to the embedder.
|
||||||
|
@ -25,3 +25,20 @@ function getUrlSearchParams(search) {
|
|||||||
|
|
||||||
return params;
|
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;
|
||||||
|
}
|
||||||
|
@ -54,6 +54,7 @@ cr.define('cr.login', function() {
|
|||||||
*/
|
*/
|
||||||
var SUPPORTED_PARAMS = [
|
var SUPPORTED_PARAMS = [
|
||||||
'gaiaUrl', // Gaia url to use;
|
'gaiaUrl', // Gaia url to use;
|
||||||
|
'gaiaPath', // Gaia path to use without a leading slash;
|
||||||
'hl', // Language code for the user interface;
|
'hl', // Language code for the user interface;
|
||||||
'email', // Pre-fill the email field in Gaia UI;
|
'email', // Pre-fill the email field in Gaia UI;
|
||||||
'service', // Name of Gaia service;
|
'service', // Name of Gaia service;
|
||||||
|
@ -311,7 +311,7 @@ void ProfileChooserView::ShowView(BubbleViewMode view_to_display,
|
|||||||
view_to_display == GAIA_ADD_ACCOUNT_VIEW) {
|
view_to_display == GAIA_ADD_ACCOUNT_VIEW) {
|
||||||
// Minimum size for embedded sign in pages as defined in Gaia.
|
// Minimum size for embedded sign in pages as defined in Gaia.
|
||||||
const int kMinGaiaViewWidth = 320;
|
const int kMinGaiaViewWidth = 320;
|
||||||
const int kMinGaiaViewHeight = 500;
|
const int kMinGaiaViewHeight = 440;
|
||||||
Profile* profile = browser_->profile();
|
Profile* profile = browser_->profile();
|
||||||
views::WebView* web_view = new views::WebView(profile);
|
views::WebView* web_view = new views::WebView(profile);
|
||||||
signin::Source source = (view_to_display == GAIA_SIGNIN_VIEW) ?
|
signin::Source source = (view_to_display == GAIA_SIGNIN_VIEW) ?
|
||||||
|
@ -151,17 +151,19 @@ class InlineLoginUIHandler : public content::WebUIMessageHandler {
|
|||||||
|
|
||||||
const GURL& current_url = web_ui()->GetWebContents()->GetURL();
|
const GURL& current_url = web_ui()->GetWebContents()->GetURL();
|
||||||
signin::Source source = signin::GetSourceForPromoURL(current_url);
|
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);
|
DCHECK(source != signin::SOURCE_UNKNOWN);
|
||||||
if (source != signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT &&
|
if (source == signin::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT ||
|
||||||
source != signin::SOURCE_AVATAR_BUBBLE_SIGN_IN) {
|
source == signin::SOURCE_AVATAR_BUBBLE_SIGN_IN) {
|
||||||
params.SetString("service", "chromiumsync");
|
// Drop the leading slash in the path.
|
||||||
base::StringAppendF(
|
params.SetString("gaiaPath",
|
||||||
&encoded_continue_params, "&%s=%d", "source",
|
gaiaUrls->embedded_signin_url().path().substr(1));
|
||||||
static_cast<int>(source));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
params.SetString("service", "chromiumsync");
|
||||||
|
base::StringAppendF(
|
||||||
|
&encoded_continue_params, "&%s=%d", "source",
|
||||||
|
static_cast<int>(source));
|
||||||
|
|
||||||
params.SetString("continueUrl",
|
params.SetString("continueUrl",
|
||||||
gaiaUrls->client_login_to_oauth2_url().Resolve(
|
gaiaUrls->client_login_to_oauth2_url().Resolve(
|
||||||
encoded_continue_params).spec());
|
encoded_continue_params).spec());
|
||||||
|
@ -29,6 +29,7 @@ const char kOAuthWrapBridgeUrlSuffix[] = "OAuthWrapBridge";
|
|||||||
const char kOAuth1LoginUrlSuffix[] = "OAuthLogin";
|
const char kOAuth1LoginUrlSuffix[] = "OAuthLogin";
|
||||||
const char kOAuthRevokeTokenUrlSuffix[] = "AuthSubRevokeToken";
|
const char kOAuthRevokeTokenUrlSuffix[] = "AuthSubRevokeToken";
|
||||||
const char kListAccountsSuffix[] = "ListAccounts";
|
const char kListAccountsSuffix[] = "ListAccounts";
|
||||||
|
const char kEmbeddedSigninSuffix[] = "EmbeddedSignIn";
|
||||||
|
|
||||||
// OAuth scopes
|
// OAuth scopes
|
||||||
const char kOAuth1LoginScope[] = "https://www.google.com/accounts/OAuthLogin";
|
const char kOAuth1LoginScope[] = "https://www.google.com/accounts/OAuthLogin";
|
||||||
@ -105,6 +106,7 @@ GaiaUrls::GaiaUrls() {
|
|||||||
oauth_revoke_token_url_ = gaia_url_.Resolve(kOAuthRevokeTokenUrlSuffix);
|
oauth_revoke_token_url_ = gaia_url_.Resolve(kOAuthRevokeTokenUrlSuffix);
|
||||||
oauth1_login_url_ = gaia_url_.Resolve(kOAuth1LoginUrlSuffix);
|
oauth1_login_url_ = gaia_url_.Resolve(kOAuth1LoginUrlSuffix);
|
||||||
list_accounts_url_ = gaia_url_.Resolve(kListAccountsSuffix);
|
list_accounts_url_ = gaia_url_.Resolve(kListAccountsSuffix);
|
||||||
|
embedded_signin_url_ = gaia_url_.Resolve(kEmbeddedSigninSuffix);
|
||||||
|
|
||||||
// URLs from accounts.google.com (LSO).
|
// URLs from accounts.google.com (LSO).
|
||||||
get_oauth_token_url_ = lso_origin_url_.Resolve(kGetOAuthTokenUrlSuffix);
|
get_oauth_token_url_ = lso_origin_url_.Resolve(kGetOAuthTokenUrlSuffix);
|
||||||
@ -204,6 +206,10 @@ const GURL& GaiaUrls::list_accounts_url() const {
|
|||||||
return list_accounts_url_;
|
return list_accounts_url_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GURL& GaiaUrls::embedded_signin_url() const {
|
||||||
|
return embedded_signin_url_;
|
||||||
|
}
|
||||||
|
|
||||||
const std::string& GaiaUrls::oauth1_login_scope() const {
|
const std::string& GaiaUrls::oauth1_login_scope() const {
|
||||||
return oauth1_login_scope_;
|
return oauth1_login_scope_;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ class GaiaUrls {
|
|||||||
const GURL& oauth_revoke_token_url() const;
|
const GURL& oauth_revoke_token_url() const;
|
||||||
const GURL& oauth1_login_url() const;
|
const GURL& oauth1_login_url() const;
|
||||||
const GURL& list_accounts_url() const;
|
const GURL& list_accounts_url() const;
|
||||||
|
const GURL& embedded_signin_url() const;
|
||||||
|
|
||||||
const std::string& oauth1_login_scope() const;
|
const std::string& oauth1_login_scope() const;
|
||||||
const std::string& oauth_wrap_bridge_user_info_scope() const;
|
const std::string& oauth_wrap_bridge_user_info_scope() const;
|
||||||
@ -75,6 +76,7 @@ class GaiaUrls {
|
|||||||
GURL oauth_revoke_token_url_;
|
GURL oauth_revoke_token_url_;
|
||||||
GURL oauth1_login_url_;
|
GURL oauth1_login_url_;
|
||||||
GURL list_accounts_url_;
|
GURL list_accounts_url_;
|
||||||
|
GURL embedded_signin_url_;
|
||||||
|
|
||||||
std::string oauth1_login_scope_;
|
std::string oauth1_login_scope_;
|
||||||
std::string oauth_wrap_bridge_user_info_scope_;
|
std::string oauth_wrap_bridge_user_info_scope_;
|
||||||
|
Reference in New Issue
Block a user