diff options
author | dzhioev <dzhioev@chromium.org> | 2015-10-26 19:43:15 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-27 02:43:54 +0000 |
commit | 5f0b811546f719dfd53d46ca97c99593ef6124b0 (patch) | |
tree | 00f9901bca4c3c8113406fa81e90ef2468bc551e | |
parent | 25e7fa5c27096e1f4d664de9f13d904ac2571910 (diff) | |
download | chromium_src-5f0b811546f719dfd53d46ca97c99593ef6124b0.zip chromium_src-5f0b811546f719dfd53d46ca97c99593ef6124b0.tar.gz chromium_src-5f0b811546f719dfd53d46ca97c99593ef6124b0.tar.bz2 |
Fixed GAIA email prefill on Chrome OS.
The reason of regression is that newly added 'readOnlyEmail' was not added to Authenticator's SUPPORTED_PARAMETERS list, so the value of the parameter was filtered in screen_gaia_signin.js.
BUG=545597
TEST=WebviewLoginTest.EmailPrefill browsertest
Review URL: https://codereview.chromium.org/1415883003
Cr-Commit-Position: refs/heads/master@{#356218}
-rw-r--r-- | chrome/browser/chromeos/login/webview_login_browsertest.cc | 7 | ||||
-rw-r--r-- | chrome/browser/resources/gaia_auth_host/authenticator.js | 33 | ||||
-rw-r--r-- | google_apis/gaia/fake_gaia.cc | 3 | ||||
-rw-r--r-- | google_apis/gaia/fake_gaia.h | 4 |
4 files changed, 32 insertions, 15 deletions
diff --git a/chrome/browser/chromeos/login/webview_login_browsertest.cc b/chrome/browser/chromeos/login/webview_login_browsertest.cc index fdd66a8..c509a804 100644 --- a/chrome/browser/chromeos/login/webview_login_browsertest.cc +++ b/chrome/browser/chromeos/login/webview_login_browsertest.cc @@ -104,4 +104,11 @@ IN_PROC_BROWSER_TEST_F(WebviewLoginTest, AllowNewUser) { JsExpect(frame_url + ".search('flow=nosignup') != -1"); } +IN_PROC_BROWSER_TEST_F(WebviewLoginTest, EmailPrefill) { + WaitForGaiaPageLoad(); + JS().ExecuteAsync("Oobe.showSigninUI('user@example.com')"); + WaitForGaiaPageReload(); + EXPECT_EQ(fake_gaia_->prefilled_email(), "user@example.com"); +} + } // namespace chromeos diff --git a/chrome/browser/resources/gaia_auth_host/authenticator.js b/chrome/browser/resources/gaia_auth_host/authenticator.js index 6f7be92..14f4529 100644 --- a/chrome/browser/resources/gaia_auth_host/authenticator.js +++ b/chrome/browser/resources/gaia_auth_host/authenticator.js @@ -68,7 +68,6 @@ cr.define('cr.login', function() { '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. 'continueUrl', // Continue url to use. 'frameUrl', // Initial frame URL to use. If empty defaults to @@ -90,6 +89,24 @@ cr.define('cr.login', function() { 'releaseChannel', // Installation channel. 'endpointGen', // Current endpoint generation. 'gapsCookie', // GAPS cookie + + // The email fields allow for the following possibilities: + // + // 1/ If 'email' is not supplied, then the email text field is blank and the + // user must type an email to proceed. + // + // 2/ If 'email' is supplied, and 'readOnlyEmail' is truthy, then the email + // is hardcoded and the user cannot change it. The user is asked for + // password. This is useful for re-auth scenarios, where chrome needs the + // user to authenticate for a specific account and only that account. + // + // 3/ If 'email' is supplied, and 'readOnlyEmail' is falsy, gaia will + // prefill the email text field using the given email address, but the user + // can still change it and then proceed. This is used on desktop when the + // user disconnects their profile then reconnects, to encourage them to use + // the same account. + 'email', + 'readOnlyEmail', ]; /** @@ -277,20 +294,6 @@ cr.define('cr.login', function() { if (data.gaiaId) url = appendParam(url, 'user_id', data.gaiaId); if (data.email) { - // The email fields allow for the following possibilities: - // - // 1/ If neither Email nor email_hint is supplied, then the email text - // field is blank and the user must type an email to proceed. - // - // 2/ If Email is supplied, then the email is hardcoded and the user - // cannot change it. The user is asked for password. This is useful for - // re-auth scenarios, where chrome needs the user to authenticate for a - // specific account and only that account. - // - // 3/ If email_hint is supplied, gaia will prefill the email text field - // using the given email address, but the user can still change it and - // then proceed. This is used on desktop when the user disconnects their - // profile then reconnects, to encourage them to use the same account. if (data.readOnlyEmail) { url = appendParam(url, 'Email', data.email); } else { diff --git a/google_apis/gaia/fake_gaia.cc b/google_apis/gaia/fake_gaia.cc index 94f8b42..a4a7d1d 100644 --- a/google_apis/gaia/fake_gaia.cc +++ b/google_apis/gaia/fake_gaia.cc @@ -486,6 +486,7 @@ void FakeGaia::HandleServiceLogin(const HttpRequest& request, void FakeGaia::HandleEmbeddedSetupChromeos(const HttpRequest& request, BasicHttpResponse* http_response) { GURL request_url = GURL("http://localhost").Resolve(request.relative_url); + std::string client_id; if (!GetQueryParameter(request_url.query(), "client_id", &client_id) || GaiaUrls::GetInstance()->oauth2_chrome_client_id() != client_id) { @@ -494,6 +495,8 @@ void FakeGaia::HandleEmbeddedSetupChromeos(const HttpRequest& request, return; } + GetQueryParameter(request_url.query(), "Email", &prefilled_email_); + http_response->set_code(net::HTTP_OK); http_response->set_content(embedded_setup_chromeos_response_); http_response->set_content_type("text/html"); diff --git a/google_apis/gaia/fake_gaia.h b/google_apis/gaia/fake_gaia.h index 05c44d5..ef955de 100644 --- a/google_apis/gaia/fake_gaia.h +++ b/google_apis/gaia/fake_gaia.h @@ -140,6 +140,9 @@ class FakeGaia { return refresh_token_to_device_id_map_; } + // Returns an email that is filled into the the Email field (if any). + const std::string& prefilled_email() { return prefilled_email_; } + protected: // HTTP handler for /MergeSession. virtual void HandleMergeSession( @@ -232,6 +235,7 @@ class FakeGaia { SamlAccountIdpMap saml_account_idp_map_; bool issue_oauth_code_cookie_; RefreshTokenToDeviceIdMap refresh_token_to_device_id_map_; + std::string prefilled_email_; DISALLOW_COPY_AND_ASSIGN(FakeGaia); }; |