summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorachuith@chromium.org <achuith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-18 09:09:13 +0000
committerachuith@chromium.org <achuith@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-18 09:09:13 +0000
commite519c435d39e453f532b1ba352ad2944c75895d8 (patch)
tree212e7ec56c2277b43946724ead049adfc8470c8e
parent6b9aa60aca15ddf94387b208c2a91380cca4ca55 (diff)
downloadchromium_src-e519c435d39e453f532b1ba352ad2944c75895d8.zip
chromium_src-e519c435d39e453f532b1ba352ad2944c75895d8.tar.gz
chromium_src-e519c435d39e453f532b1ba352ad2944c75895d8.tar.bz2
Deprecate switches gaia-host and gaia-url-path in favor of gaia-url
* Deprecate lso-host to replace with lso-url, which is the complete origin (not just the host). * Allow for http access of gaia-urls, not just https. * Add data member gaia_url_ and accessor to GaiaUrls, replacing gaia_origin_url_ * Replace javascript params gaiaOrigin and gaiaUrlPath with gaiaUrl. * Replace SetGaiaOriginForTesting with SetGaiaUrlForTesting. BUG=239151 TEST=manual with telemetry auth server. on linux and on the device with GAIA_FLAGS="--gaia-url=https://gaiastaging.corp.google.com --lso-url=https://test-sandbox.auth.corp.google.com --google-apis-host=www.googleapis-test.sandbox.google.com --oauth2-client-id=236834563817.apps.googleusercontent.com --oauth2-client-secret=RsKv5AwFKSzNgE0yjnurkPVI" Review URL: https://chromiumcodereview.appspot.com/14786022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200977 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/chromeos/login/oobe_browsertest.cc9
-rw-r--r--chrome/browser/chromeos/login/webui_login_display.cc4
-rw-r--r--chrome/browser/chromeos/login/webui_login_display.h3
-rw-r--r--chrome/browser/policy/url_blacklist_manager.cc2
-rw-r--r--chrome/browser/resources/chromeos/login/oobe_screen_oauth_enrollment.js4
-rw-r--r--chrome/browser/resources/gaia_auth/main.js20
-rw-r--r--chrome/browser/resources/gaia_auth_host/gaia_auth_host.js3
-rw-r--r--chrome/browser/service/service_process_control.cc2
-rw-r--r--chrome/browser/signin/signin_manager_cookie_helper.cc2
-rw-r--r--chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc9
-rw-r--r--chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc18
-rw-r--r--chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h7
-rw-r--r--chrome/browser/ui/webui/inline_login_ui.cc9
-rw-r--r--cloud_print/service/win/service_utils.cc2
-rw-r--r--google_apis/gaia/gaia_auth_util.cc2
-rw-r--r--google_apis/gaia/gaia_switches.cc5
-rw-r--r--google_apis/gaia/gaia_switches.h17
-rw-r--r--google_apis/gaia/gaia_urls.cc117
-rw-r--r--google_apis/gaia/gaia_urls.h61
19 files changed, 127 insertions, 169 deletions
diff --git a/chrome/browser/chromeos/login/oobe_browsertest.cc b/chrome/browser/chromeos/login/oobe_browsertest.cc
index 3c7bdc5..37063ca 100644
--- a/chrome/browser/chromeos/login/oobe_browsertest.cc
+++ b/chrome/browser/chromeos/login/oobe_browsertest.cc
@@ -56,7 +56,7 @@ class TestBrowserMainExtraParts
}
void set_quit_task(const base::Closure& quit_task) { quit_task_ = quit_task; }
- void set_gaia_url(const std::string& url) { gaia_url_ = url; }
+ void set_gaia_url(const GURL& url) { gaia_url_ = url; }
private:
// Overridden from content::NotificationObserver:
@@ -93,7 +93,7 @@ class TestBrowserMainExtraParts
static_cast<chromeos::WebUILoginDisplay*>(
controller->login_display());
CHECK(webui_login_display);
- webui_login_display->SetGaiaOriginForTesting(gaia_url_);
+ webui_login_display->SetGaiaUrlForTesting(gaia_url_);
webui_login_display->ShowSigninScreenForCreds("username", "password");
// TODO(glotov): mock GAIA server (test_server_) should support
// username/password configuration.
@@ -102,7 +102,7 @@ class TestBrowserMainExtraParts
bool webui_visible_, browsing_data_removed_, signin_screen_shown_;
content::NotificationRegistrar registrar_;
base::Closure quit_task_;
- std::string gaia_url_;
+ GURL gaia_url_;
DISALLOW_COPY_AND_ASSIGN(TestBrowserMainExtraParts);
};
@@ -164,8 +164,7 @@ class OobeTest : public chromeos::CrosInProcessBrowserTest {
<< "Current manifest_test.json for gaia_login restrictions "
<< "does not allow this port";
- const std::string gaia_url =
- "http://localhost:" + test_server_->base_url().port();
+ const GURL gaia_url("http://localhost:" + test_server_->base_url().port());
content_browser_client_->browser_main_extra_parts_->set_gaia_url(gaia_url);
}
diff --git a/chrome/browser/chromeos/login/webui_login_display.cc b/chrome/browser/chromeos/login/webui_login_display.cc
index 4c65744..e72d467 100644
--- a/chrome/browser/chromeos/login/webui_login_display.cc
+++ b/chrome/browser/chromeos/login/webui_login_display.cc
@@ -312,9 +312,9 @@ void WebUILoginDisplay::ShowSigninScreenForCreds(
webui_handler_->ShowSigninScreenForCreds(username, password);
}
-void WebUILoginDisplay::SetGaiaOriginForTesting(const std::string& arg) {
+void WebUILoginDisplay::SetGaiaUrlForTesting(const GURL& gaia_url) {
if (webui_handler_)
- webui_handler_->SetGaiaOriginForTesting(arg);
+ webui_handler_->SetGaiaUrlForTesting(gaia_url);
}
const UserList& WebUILoginDisplay::GetUsers() const {
diff --git a/chrome/browser/chromeos/login/webui_login_display.h b/chrome/browser/chromeos/login/webui_login_display.h
index 044a967..27e8390 100644
--- a/chrome/browser/chromeos/login/webui_login_display.h
+++ b/chrome/browser/chromeos/login/webui_login_display.h
@@ -73,7 +73,6 @@ class WebUILoginDisplay : public LoginDisplay,
LoginDisplayWebUIHandler* webui_handler) OVERRIDE;
virtual void ShowSigninScreenForCreds(const std::string& username,
const std::string& password);
- virtual void SetGaiaOriginForTesting(const std::string& arg);
virtual const UserList& GetUsers() const OVERRIDE;
virtual bool IsShowGuest() const OVERRIDE;
virtual bool IsShowUsers() const OVERRIDE;
@@ -86,6 +85,8 @@ class WebUILoginDisplay : public LoginDisplay,
// UserActivityDetector implementation:
virtual void OnUserActivity() OVERRIDE;
+ void SetGaiaUrlForTesting(const GURL& gaia_url);
+
private:
void StartPasswordClearTimer();
void OnPasswordClearTimerExpired();
diff --git a/chrome/browser/policy/url_blacklist_manager.cc b/chrome/browser/policy/url_blacklist_manager.cc
index d7d768f..a4525ed 100644
--- a/chrome/browser/policy/url_blacklist_manager.cc
+++ b/chrome/browser/policy/url_blacklist_manager.cc
@@ -69,7 +69,7 @@ bool IsSigninFlowURL(const GURL& url) {
return true;
// Additionally whitelist /ServiceLoginAuth.
- if (url.GetOrigin() != GURL(GaiaUrls::GetInstance()->gaia_origin_url()))
+ if (url.GetOrigin() != GaiaUrls::GetInstance()->gaia_url().GetOrigin())
return false;
return url.path() == kServiceLoginAuth;
}
diff --git a/chrome/browser/resources/chromeos/login/oobe_screen_oauth_enrollment.js b/chrome/browser/resources/chromeos/login/oobe_screen_oauth_enrollment.js
index 26686c1..be76d57 100644
--- a/chrome/browser/resources/chromeos/login/oobe_screen_oauth_enrollment.js
+++ b/chrome/browser/resources/chromeos/login/oobe_screen_oauth_enrollment.js
@@ -167,9 +167,7 @@ login.createScreen('OAuthEnrollmentScreen', 'oauth-enrollment', function() {
*/
onBeforeShow: function(data) {
var url = data.signin_url;
- url += '?gaiaOrigin=' + encodeURIComponent(data.gaiaOrigin);
- if (data.gaiaUrlBase)
- url += '&gaiaUrlPath=' + encodeURIComponent(data.gaiaUrlPath);
+ url += '?gaiaUrl=' + encodeURIComponent(data.gaiaUrl);
if (data.test_email) {
url += '&test_email=' + encodeURIComponent(data.test_email);
url += '&test_password=' + encodeURIComponent(data.test_password);
diff --git a/chrome/browser/resources/gaia_auth/main.js b/chrome/browser/resources/gaia_auth/main.js
index 0839b40..eaeec8b 100644
--- a/chrome/browser/resources/gaia_auth/main.js
+++ b/chrome/browser/resources/gaia_auth/main.js
@@ -25,8 +25,8 @@ Authenticator.prototype = {
inputLang_: undefined,
intputEmail_: undefined,
- GAIA_PAGE_ORIGIN: 'https://accounts.google.com',
- GAIA_PAGE_PATH: '/ServiceLogin?service=chromeoslogin' +
+ GAIA_URL: 'https://accounts.google.com/',
+ GAIA_PAGE_PATH: 'ServiceLogin?service=chromeoslogin' +
'&skipvpage=true&sarp=1&rm=hide' +
'&continue=chrome-extension://mfffpogegjflfpflabcdkioaeobkgjik/' +
'success.html',
@@ -36,8 +36,7 @@ Authenticator.prototype = {
initialize: function() {
var params = getUrlSearchParams(location.search);
this.parentPage_ = params['parentPage'] || this.PARENT_PAGE;
- this.gaiaOrigin_ = params['gaiaOrigin'] || this.GAIA_PAGE_ORIGIN;
- this.gaiaUrlPath_ = params['gaiaUrlPath'] || '';
+ this.gaiaUrl_ = params['gaiaUrl'] || this.GAIA_URL;
this.inputLang_ = params['hl'];
this.inputEmail_ = params['email'];
this.testEmail_ = params['test_email'];
@@ -47,8 +46,9 @@ Authenticator.prototype = {
},
isGaiaMessage_: function(msg) {
- return msg.origin == this.gaiaOrigin_ ||
- msg.origin == this.GAIA_PAGE_ORIGIN;
+ // Not quite right, but good enough.
+ return this.gaiaUrl_.indexOf(msg.origin) == 0 ||
+ this.GAIA_URL.indexOf(msg.origin) == 0;
},
isInternalMessage_: function(msg) {
@@ -56,13 +56,7 @@ Authenticator.prototype = {
},
getFrameUrl_: function() {
- var url = this.gaiaOrigin_;
-
- if (this.gaiaOrigin_ == 'https://www.google.com')
- url += '/accounts';
-
- if (this.gaiaUrlPath_ && this.gaiaUrlPath_ != '')
- url += this.gaiaUrlPath_;
+ var url = this.gaiaUrl_;
url += this.GAIA_PAGE_PATH;
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 8929b52..642d5b4 100644
--- a/chrome/browser/resources/gaia_auth_host/gaia_auth_host.js
+++ b/chrome/browser/resources/gaia_auth_host/gaia_auth_host.js
@@ -41,8 +41,7 @@ cr.define('cr.login', function() {
* @const
*/
var SUPPORTED_PARAMS = [
- 'gaiaOrigin', // Gaia origin to use;
- 'gaiaUrlPath', // Url path to gaia sign-in servlet on gaiaOrigin;
+ 'gaiaUrl', // Gaia url to use;
'hl', // Language code for the user interface;
'email', // Pre-fill the email field in Gaia UI;
'test_email', // Used for test;
diff --git a/chrome/browser/service/service_process_control.cc b/chrome/browser/service/service_process_control.cc
index 650beef..72f61cd 100644
--- a/chrome/browser/service/service_process_control.cc
+++ b/chrome/browser/service/service_process_control.cc
@@ -133,7 +133,7 @@ void ServiceProcessControl::Launch(const base::Closure& success_task,
switches::kIgnoreUrlFetcherCertRequests,
switches::kLang,
switches::kLoggingLevel,
- switches::kLsoHost,
+ switches::kLsoUrl,
switches::kNoServiceAutorun,
switches::kUserDataDir,
switches::kV,
diff --git a/chrome/browser/signin/signin_manager_cookie_helper.cc b/chrome/browser/signin/signin_manager_cookie_helper.cc
index 0ea6f9a..8c3fe2c 100644
--- a/chrome/browser/signin/signin_manager_cookie_helper.cc
+++ b/chrome/browser/signin/signin_manager_cookie_helper.cc
@@ -42,7 +42,7 @@ void SigninManagerCookieHelper::FetchGaiaCookiesOnIOThread() {
cookie_store()->GetCookieMonster();
if (cookie_monster) {
cookie_monster->GetAllCookiesForURLAsync(
- GURL(GaiaUrls::GetInstance()->gaia_origin_url()),
+ GaiaUrls::GetInstance()->gaia_url(),
base::Bind(&SigninManagerCookieHelper::OnGaiaCookiesFetched, this));
} else {
OnGaiaCookiesFetched(net::CookieList());
diff --git a/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc
index 99ce0d1..847a807 100644
--- a/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/enrollment_screen_handler.cc
@@ -6,7 +6,6 @@
#include <algorithm>
-#include "base/command_line.h"
#include "base/values.h"
#include "chrome/browser/browsing_data/browsing_data_helper.h"
#include "chrome/browser/browsing_data/browsing_data_remover.h"
@@ -463,13 +462,7 @@ void EnrollmentScreenHandler::OnTokenRevokerDone(
void EnrollmentScreenHandler::DoShow() {
DictionaryValue screen_data;
screen_data.SetString("signin_url", kGaiaExtStartPage);
- screen_data.SetString("gaiaOrigin",
- GaiaUrls::GetInstance()->gaia_origin_url());
- if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGaiaUrlPath)) {
- screen_data.SetString("gaiaUrlPath",
- CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
- switches::kGaiaUrlPath));
- }
+ screen_data.SetString("gaiaUrl", GaiaUrls::GetInstance()->gaia_url().spec());
screen_data.SetBoolean("is_auto_enrollment", is_auto_enrollment_);
screen_data.SetBoolean("prevent_cancellation", !can_exit_enrollment_);
if (!test_email_.empty()) {
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
index a7d525d..ff36192 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.cc
@@ -899,8 +899,8 @@ void SigninScreenHandler::ShowSigninScreenForCreds(
HandleShowAddUser(NULL);
}
-void SigninScreenHandler::SetGaiaOriginForTesting(const std::string& arg) {
- gaia_origin_for_test_ = arg;
+void SigninScreenHandler::SetGaiaUrlForTesting(const GURL& gaia_url) {
+ gaia_url_for_test_ = gaia_url;
}
void SigninScreenHandler::OnCookiesCleared(base::Closure on_clear_callback) {
@@ -1029,17 +1029,13 @@ void SigninScreenHandler::LoadAuthExtension(
params.Set("localizedStrings", localized_strings);
}
- std::string gaia_origin = GaiaUrls::GetInstance()->gaia_origin_url();
- if (!gaia_origin_for_test_.empty())
- gaia_origin = gaia_origin_for_test_;
- params.SetString("gaiaOrigin", gaia_origin);
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(::switches::kGaiaUrlPath)) {
- params.SetString("gaiaUrlPath",
- command_line->GetSwitchValueASCII(::switches::kGaiaUrlPath));
- }
+ const GURL gaia_url = gaia_url_for_test_.is_empty() ?
+ GaiaUrls::GetInstance()->gaia_url() :
+ gaia_url_for_test_;
+ params.SetString("gaiaUrl", gaia_url.spec());
// Test automation data:
+ const CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kAuthExtensionPath)) {
if (!test_user_.empty()) {
params.SetString("test_email", test_user_);
diff --git a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
index b12d2a5..4ccfc5b 100644
--- a/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
+++ b/chrome/browser/ui/webui/chromeos/login/signin_screen_handler.h
@@ -60,7 +60,8 @@ class LoginDisplayWebUIHandler {
// Show sign-in screen for the given credentials.
virtual void ShowSigninScreenForCreds(const std::string& username,
const std::string& password) = 0;
- virtual void SetGaiaOriginForTesting(const std::string& arg) = 0;
+ // TODO(achuith): Get rid of this in favor of --gaia-url. crbug.com/240502
+ virtual void SetGaiaUrlForTesting(const GURL& gaia_url) = 0;
protected:
virtual ~LoginDisplayWebUIHandler() {}
};
@@ -247,7 +248,7 @@ class SigninScreenHandler
virtual void ShowErrorScreen(LoginDisplay::SigninError error_id) OVERRIDE;
virtual void ShowSigninScreenForCreds(const std::string& username,
const std::string& password) OVERRIDE;
- virtual void SetGaiaOriginForTesting(const std::string& arg) OVERRIDE;
+ virtual void SetGaiaUrlForTesting(const GURL& gaia_url) OVERRIDE;
// SystemKeyEventListener::CapsLockObserver overrides.
virtual void OnCapsLockChange(bool enabled) OVERRIDE;
@@ -443,7 +444,7 @@ class SigninScreenHandler
bool has_pending_auth_ui_;
// Testing helper, specifies new value for gaia url.
- std::string gaia_origin_for_test_;
+ GURL gaia_url_for_test_;
DISALLOW_COPY_AND_ASSIGN(SigninScreenHandler);
};
diff --git a/chrome/browser/ui/webui/inline_login_ui.cc b/chrome/browser/ui/webui/inline_login_ui.cc
index dbfe5cd..637d629 100644
--- a/chrome/browser/ui/webui/inline_login_ui.cc
+++ b/chrome/browser/ui/webui/inline_login_ui.cc
@@ -93,14 +93,7 @@ class InlineLoginUIHandler : public content::WebUIMessageHandler {
const std::string& app_locale = g_browser_process->GetApplicationLocale();
params.SetString("hl", app_locale);
-
- params.SetString("gaiaOrigin", GaiaUrls::GetInstance()->gaia_origin_url());
- const CommandLine* command_line = CommandLine::ForCurrentProcess();
- if (command_line->HasSwitch(::switches::kGaiaUrlPath)) {
- params.SetString(
- "gaiaUrlPath",
- command_line->GetSwitchValueASCII(::switches::kGaiaUrlPath));
- }
+ params.SetString("gaiaUrl", GaiaUrls::GetInstance()->gaia_url().spec());
web_ui()->CallJavascriptFunction("inline.login.loadAuthExtension", params);
}
diff --git a/cloud_print/service/win/service_utils.cc b/cloud_print/service/win/service_utils.cc
index 14076fe..5635e6f 100644
--- a/cloud_print/service/win/service_utils.cc
+++ b/cloud_print/service/win/service_utils.cc
@@ -52,7 +52,7 @@ void CopyChromeSwitchesFromCurrentProcess(CommandLine* destination) {
switches::kCloudPrintServiceURL,
switches::kEnableLogging,
switches::kIgnoreUrlFetcherCertRequests,
- switches::kLsoHost,
+ switches::kLsoUrl,
switches::kV,
};
destination->CopySwitchesFrom(*CommandLine::ForCurrentProcess(),
diff --git a/google_apis/gaia/gaia_auth_util.cc b/google_apis/gaia/gaia_auth_util.cc
index 7f6e9c8..6122589 100644
--- a/google_apis/gaia/gaia_auth_util.cc
+++ b/google_apis/gaia/gaia_auth_util.cc
@@ -69,7 +69,7 @@ bool IsGaiaSignonRealm(const GURL& url) {
if (!url.SchemeIsSecure())
return false;
- return url == GURL(GaiaUrls::GetInstance()->gaia_origin_url());
+ return url == GaiaUrls::GetInstance()->gaia_url();
}
} // namespace gaia
diff --git a/google_apis/gaia/gaia_switches.cc b/google_apis/gaia/gaia_switches.cc
index eb3f85e..c2430b0 100644
--- a/google_apis/gaia/gaia_switches.cc
+++ b/google_apis/gaia/gaia_switches.cc
@@ -7,10 +7,9 @@
namespace switches {
const char kClientLoginToOAuth2Url[] = "client-login-to-oauth2-url";
-const char kGaiaHost[] = "gaia-host";
-const char kGaiaUrlPath[] = "gaia-url-path";
+const char kGaiaUrl[] = "gaia-url";
const char kGoogleApisHost[] = "google-apis-host";
-const char kLsoHost[] = "lso-host";
+const char kLsoUrl[] = "lso-url";
const char kOAuth1LoginScope[] = "oauth1-login-scope";
const char kOAuth2IssueTokenUrl[] = "oauth2-issue-token-url";
const char kOAuth2TokenUrl[] = "oauth2-token-url";
diff --git a/google_apis/gaia/gaia_switches.h b/google_apis/gaia/gaia_switches.h
index 52680dd..727a355 100644
--- a/google_apis/gaia/gaia_switches.h
+++ b/google_apis/gaia/gaia_switches.h
@@ -10,15 +10,9 @@ namespace switches {
// Supplies custom client login to OAuth2 URL for testing purposes.
extern const char kClientLoginToOAuth2Url[];
-// Specifies the backend server used for gaia authentications, like sync or
-// policies for example. The https:// prefix and the trailing slash should be
-// omitted. The default value is "accounts.google.com".
-extern const char kGaiaHost[];
-
-// Specifies the path prefix for GAIA authentication URL. It should be used
-// for testing in cases where authentication path prefix differs from the one
-// used in production.
-extern const char kGaiaUrlPath[];
+// Specifies the path for GAIA authentication URL. The default value is
+// "https://accounts.google.com".
+extern const char kGaiaUrl[];
// Specifies the backend server used for Google API calls. The https:// prefix
// and the trailing slash should be omitted.
@@ -26,9 +20,8 @@ extern const char kGaiaUrlPath[];
extern const char kGoogleApisHost[];
// Specifies the backend server used for lso authentication calls.
-// The https:// prefix and the trailing slash should be
-// omitted. The default value is "accounts.google.com".
-extern const char kLsoHost[];
+// "https://accounts.google.com".
+extern const char kLsoUrl[];
// TODO(zelidrag): Get rid of all following since all URLs should be
// controlled only with --gaia-host, --lso-host and --google-apis-host.
diff --git a/google_apis/gaia/gaia_urls.cc b/google_apis/gaia/gaia_urls.cc
index 2135c31..4cd0be8a 100644
--- a/google_apis/gaia/gaia_urls.cc
+++ b/google_apis/gaia/gaia_urls.cc
@@ -5,13 +5,14 @@
#include "google_apis/gaia/gaia_urls.h"
#include "base/command_line.h"
+#include "base/logging.h"
#include "google_apis/gaia/gaia_switches.h"
#include "google_apis/google_api_keys.h"
namespace {
// Gaia service constants
-const char kDefaultGaiaBaseUrl[] = "accounts.google.com";
+const char kDefaultGaiaUrl[] = "https://accounts.google.com";
const char kDefaultGoogleApisBaseUrl[] = "www.googleapis.com";
const char kCaptchaUrlPrefixSuffix[] = "/";
@@ -62,36 +63,27 @@ GaiaUrls* GaiaUrls::GetInstance() {
}
GaiaUrls::GaiaUrls() {
- CommandLine* command_line = CommandLine::ForCurrentProcess();
- std::string host_base;
- GetSwitchValueWithDefault(switches::kGaiaHost, kDefaultGaiaBaseUrl,
- &host_base);
+ std::string gaia_url_str;
+ GetSwitchValueWithDefault(switches::kGaiaUrl,
+ kDefaultGaiaUrl,
+ &gaia_url_str);
+ gaia_url_ = GURL(gaia_url_str);
+ DCHECK(gaia_url_.is_valid());
- std::string lso_base;
- GetSwitchValueWithDefault(switches::kLsoHost, kDefaultGaiaBaseUrl,
- &lso_base);
+ GetSwitchValueWithDefault(switches::kLsoUrl,
+ kDefaultGaiaUrl,
+ &lso_origin_url_);
std::string google_apis_base;
GetSwitchValueWithDefault(switches::kGoogleApisHost,
kDefaultGoogleApisBaseUrl,
&google_apis_base);
- captcha_url_prefix_ = "http://" + host_base + kCaptchaUrlPrefixSuffix;
- gaia_origin_url_ = "https://" + host_base;
- lso_origin_url_ = "https://" + lso_base;
- google_apis_origin_url_ = "https://" + google_apis_base;
- std::string gaia_url_base = gaia_origin_url_;
- if (command_line->HasSwitch(switches::kGaiaUrlPath)) {
- std::string path =
- command_line->GetSwitchValueASCII(switches::kGaiaUrlPath);
- if (!path.empty()) {
- if (path[0] != '/')
- gaia_url_base.append("/");
-
- gaia_url_base.append(path);
- }
- }
+ captcha_url_prefix_ = "http://" + gaia_url_.host() +
+ (gaia_url_.has_port() ? ":" + gaia_url_.port() : "") +
+ kCaptchaUrlPrefixSuffix;
+ google_apis_origin_url_ = "https://" + google_apis_base;
oauth2_chrome_client_id_ =
google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN);
@@ -99,19 +91,18 @@ GaiaUrls::GaiaUrls() {
google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN);
// URLs from accounts.google.com.
- gaia_login_form_realm_ = gaia_url_base + "/";
- client_login_url_ = gaia_url_base + kClientLoginUrlSuffix;
- service_login_url_ = gaia_url_base + kServiceLoginUrlSuffix;
- service_logout_url_ = gaia_url_base + kServiceLogoutUrlSuffix;
- issue_auth_token_url_ = gaia_url_base + kIssueAuthTokenUrlSuffix;
- get_user_info_url_ = gaia_url_base + kGetUserInfoUrlSuffix;
- token_auth_url_ = gaia_url_base + kTokenAuthUrlSuffix;
- merge_session_url_ = gaia_url_base + kMergeSessionUrlSuffix;
- oauth_get_access_token_url_ = gaia_url_base +
- kOAuthGetAccessTokenUrlSuffix;
- oauth_wrap_bridge_url_ = gaia_url_base + kOAuthWrapBridgeUrlSuffix;
- oauth_revoke_token_url_ = gaia_url_base + kOAuthRevokeTokenUrlSuffix;
- oauth1_login_url_ = gaia_url_base + kOAuth1LoginUrlSuffix;
+ gaia_login_form_realm_ = gaia_url_str + "/";
+ client_login_url_ = gaia_url_str + kClientLoginUrlSuffix;
+ service_login_url_ = gaia_url_str + kServiceLoginUrlSuffix;
+ service_logout_url_ = gaia_url_str + kServiceLogoutUrlSuffix;
+ issue_auth_token_url_ = gaia_url_str + kIssueAuthTokenUrlSuffix;
+ get_user_info_url_ = gaia_url_str + kGetUserInfoUrlSuffix;
+ token_auth_url_ = gaia_url_str + kTokenAuthUrlSuffix;
+ merge_session_url_ = gaia_url_str + kMergeSessionUrlSuffix;
+ oauth_get_access_token_url_ = gaia_url_str + kOAuthGetAccessTokenUrlSuffix;
+ oauth_wrap_bridge_url_ = gaia_url_str + kOAuthWrapBridgeUrlSuffix;
+ oauth_revoke_token_url_ = gaia_url_str + kOAuthRevokeTokenUrlSuffix;
+ oauth1_login_url_ = gaia_url_str + kOAuth1LoginUrlSuffix;
// URLs from accounts.google.com (LSO).
get_oauth_token_url_ = lso_origin_url_ + kGetOAuthTokenUrlSuffix;
@@ -130,7 +121,7 @@ GaiaUrls::GaiaUrls() {
kOAuthUserInfoUrlSuffix;
// TODO(zelidrag): Get rid of all these switches since all URLs should be
- // controlled only with --gaia-host, --lso-host and --google-apis-host.
+ // controlled only with --gaia-url, --lso-url and --google-apis-host.
GetSwitchValueWithDefault(switches::kOAuth1LoginScope,
kOAuth1LoginScope,
&oauth1_login_scope_);
@@ -151,102 +142,102 @@ GaiaUrls::GaiaUrls() {
GaiaUrls::~GaiaUrls() {
}
-const std::string& GaiaUrls::captcha_url_prefix() {
+const std::string& GaiaUrls::captcha_url_prefix() const {
return captcha_url_prefix_;
}
-const std::string& GaiaUrls::gaia_origin_url() {
- return gaia_origin_url_;
+const GURL& GaiaUrls::gaia_url() const {
+ return gaia_url_;
}
-const std::string& GaiaUrls::client_login_url() {
+const std::string& GaiaUrls::client_login_url() const {
return client_login_url_;
}
-const std::string& GaiaUrls::service_login_url() {
+const std::string& GaiaUrls::service_login_url() const {
return service_login_url_;
}
-const std::string& GaiaUrls::service_logout_url() {
+const std::string& GaiaUrls::service_logout_url() const {
return service_logout_url_;
}
-const std::string& GaiaUrls::issue_auth_token_url() {
+const std::string& GaiaUrls::issue_auth_token_url() const {
return issue_auth_token_url_;
}
-const std::string& GaiaUrls::get_user_info_url() {
+const std::string& GaiaUrls::get_user_info_url() const {
return get_user_info_url_;
}
-const std::string& GaiaUrls::token_auth_url() {
+const std::string& GaiaUrls::token_auth_url() const {
return token_auth_url_;
}
-const std::string& GaiaUrls::merge_session_url() {
+const std::string& GaiaUrls::merge_session_url() const {
return merge_session_url_;
}
-const std::string& GaiaUrls::get_oauth_token_url() {
+const std::string& GaiaUrls::get_oauth_token_url() const {
return get_oauth_token_url_;
}
-const std::string& GaiaUrls::oauth_get_access_token_url() {
+const std::string& GaiaUrls::oauth_get_access_token_url() const {
return oauth_get_access_token_url_;
}
-const std::string& GaiaUrls::oauth_wrap_bridge_url() {
+const std::string& GaiaUrls::oauth_wrap_bridge_url() const {
return oauth_wrap_bridge_url_;
}
-const std::string& GaiaUrls::oauth_user_info_url() {
+const std::string& GaiaUrls::oauth_user_info_url() const {
return oauth_user_info_url_;
}
-const std::string& GaiaUrls::oauth_revoke_token_url() {
+const std::string& GaiaUrls::oauth_revoke_token_url() const {
return oauth_revoke_token_url_;
}
-const std::string& GaiaUrls::oauth1_login_url() {
+const std::string& GaiaUrls::oauth1_login_url() const {
return oauth1_login_url_;
}
-const std::string& GaiaUrls::oauth1_login_scope() {
+const std::string& GaiaUrls::oauth1_login_scope() const {
return oauth1_login_scope_;
}
-const std::string& GaiaUrls::oauth_wrap_bridge_user_info_scope() {
+const std::string& GaiaUrls::oauth_wrap_bridge_user_info_scope() const {
return oauth_wrap_bridge_user_info_scope_;
}
-const std::string& GaiaUrls::oauth2_chrome_client_id() {
+const std::string& GaiaUrls::oauth2_chrome_client_id() const {
return oauth2_chrome_client_id_;
}
-const std::string& GaiaUrls::oauth2_chrome_client_secret() {
+const std::string& GaiaUrls::oauth2_chrome_client_secret() const {
return oauth2_chrome_client_secret_;
}
-const std::string& GaiaUrls::client_login_to_oauth2_url() {
+const std::string& GaiaUrls::client_login_to_oauth2_url() const {
return client_login_to_oauth2_url_;
}
-const std::string& GaiaUrls::oauth2_auth_url() {
+const std::string& GaiaUrls::oauth2_auth_url() const {
return oauth2_auth_url_;
}
-const std::string& GaiaUrls::oauth2_token_url() {
+const std::string& GaiaUrls::oauth2_token_url() const {
return oauth2_token_url_;
}
-const std::string& GaiaUrls::oauth2_issue_token_url() {
+const std::string& GaiaUrls::oauth2_issue_token_url() const {
return oauth2_issue_token_url_;
}
-const std::string& GaiaUrls::oauth2_revoke_url() {
+const std::string& GaiaUrls::oauth2_revoke_url() const {
return oauth2_revoke_url_;
}
-const std::string& GaiaUrls::gaia_login_form_realm() {
+const std::string& GaiaUrls::gaia_login_form_realm() const {
return gaia_login_form_realm_;
}
diff --git a/google_apis/gaia/gaia_urls.h b/google_apis/gaia/gaia_urls.h
index 3b434e4b..605aa64 100644
--- a/google_apis/gaia/gaia_urls.h
+++ b/google_apis/gaia/gaia_urls.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/memory/singleton.h"
+#include "googleurl/src/gurl.h"
// A signleton that provides all the URLs that are used for connecting to GAIA.
class GaiaUrls {
@@ -15,35 +16,35 @@ class GaiaUrls {
static GaiaUrls* GetInstance();
// The URLs for different calls in the Google Accounts programmatic login API.
- const std::string& captcha_url_prefix();
-
- const std::string& gaia_origin_url();
- const std::string& client_login_url();
- const std::string& service_login_url();
- const std::string& service_logout_url();
- const std::string& issue_auth_token_url();
- const std::string& get_user_info_url();
- const std::string& token_auth_url();
- const std::string& merge_session_url();
- const std::string& get_oauth_token_url();
- const std::string& oauth_get_access_token_url();
- const std::string& oauth_wrap_bridge_url();
- const std::string& oauth_user_info_url();
- const std::string& oauth_revoke_token_url();
- const std::string& oauth1_login_url();
-
- const std::string& oauth1_login_scope();
- const std::string& oauth_wrap_bridge_user_info_scope();
-
- const std::string& oauth2_chrome_client_id();
- const std::string& oauth2_chrome_client_secret();
- const std::string& client_login_to_oauth2_url();
- const std::string& oauth2_auth_url();
- const std::string& oauth2_token_url();
- const std::string& oauth2_issue_token_url();
- const std::string& oauth2_revoke_url();
-
- const std::string& gaia_login_form_realm();
+ const std::string& captcha_url_prefix() const;
+
+ const GURL& gaia_url() const;
+ const std::string& client_login_url() const;
+ const std::string& service_login_url() const;
+ const std::string& service_logout_url() const;
+ const std::string& issue_auth_token_url() const;
+ const std::string& get_user_info_url() const;
+ const std::string& token_auth_url() const;
+ const std::string& merge_session_url() const;
+ const std::string& get_oauth_token_url() const;
+ const std::string& oauth_get_access_token_url() const;
+ const std::string& oauth_wrap_bridge_url() const;
+ const std::string& oauth_user_info_url() const;
+ const std::string& oauth_revoke_token_url() const;
+ const std::string& oauth1_login_url() const;
+
+ const std::string& oauth1_login_scope() const;
+ const std::string& oauth_wrap_bridge_user_info_scope() const;
+
+ const std::string& oauth2_chrome_client_id() const;
+ const std::string& oauth2_chrome_client_secret() const;
+ const std::string& client_login_to_oauth2_url() const;
+ const std::string& oauth2_auth_url() const;
+ const std::string& oauth2_token_url() const;
+ const std::string& oauth2_issue_token_url() const;
+ const std::string& oauth2_revoke_url() const;
+
+ const std::string& gaia_login_form_realm() const;
private:
GaiaUrls();
@@ -53,7 +54,7 @@ class GaiaUrls {
std::string captcha_url_prefix_;
- std::string gaia_origin_url_;
+ GURL gaia_url_;
std::string lso_origin_url_;
std::string google_apis_origin_url_;
std::string client_login_url_;