diff options
author | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-19 09:41:02 +0000 |
---|---|---|
committer | mnissler@chromium.org <mnissler@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-09-19 09:41:02 +0000 |
commit | bd7026033fc1d0729b3b36819b7b6ec4b95674e9 (patch) | |
tree | 1450d1617722ea637e21d244ceeb491d7f4d8f41 /google_apis | |
parent | bb40c930f3fddbe433b2273e541da9645d128024 (diff) | |
download | chromium_src-bd7026033fc1d0729b3b36819b7b6ec4b95674e9.zip chromium_src-bd7026033fc1d0729b3b36819b7b6ec4b95674e9.tar.gz chromium_src-bd7026033fc1d0729b3b36819b7b6ec4b95674e9.tar.bz2 |
Clean up GaiaUrls to actually return GURLs.
It turns out that most consuming code can actually handle a GURL
return value better. Other consumers can use GURL::Resolve() which
provides nicer semantics for construction URLs that string
concatenation, which had been used before.
BUG=chromium:243889
R=akalin@chromium.org, bauerb@chromium.org, brettw@chromium.org, courage@chromium.org, isherman@chromium.org, rogerta@chromium.org, sail@chromium.org, sky@chromium.org, zelidrag@chromium.org
Review URL: https://codereview.chromium.org/23691043
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@224092 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r-- | google_apis/gaia/gaia_auth_fetcher.cc | 23 | ||||
-rw-r--r-- | google_apis/gaia/gaia_auth_fetcher_unittest.cc | 8 | ||||
-rw-r--r-- | google_apis/gaia/gaia_switches.cc | 7 | ||||
-rw-r--r-- | google_apis/gaia/gaia_switches.h | 19 | ||||
-rw-r--r-- | google_apis/gaia/gaia_urls.cc | 211 | ||||
-rw-r--r-- | google_apis/gaia/gaia_urls.h | 95 | ||||
-rw-r--r-- | google_apis/gaia/oauth2_access_token_fetcher.cc | 2 | ||||
-rw-r--r-- | google_apis/gaia/oauth2_mint_token_flow.cc | 2 |
8 files changed, 174 insertions, 193 deletions
diff --git a/google_apis/gaia/gaia_auth_fetcher.cc b/google_apis/gaia/gaia_auth_fetcher.cc index 67756de..f0e2644 100644 --- a/google_apis/gaia/gaia_auth_fetcher.cc +++ b/google_apis/gaia/gaia_auth_fetcher.cc @@ -103,7 +103,7 @@ const char GaiaAuthFetcher::kMergeSessionFormat[] = "source=%s"; // static const char GaiaAuthFetcher::kUberAuthTokenURLFormat[] = - "%s?source=%s&" + "?source=%s&" "issueuberauth=1"; const char GaiaAuthFetcher::kOAuthLoginFormat[] = "service=%s&source=%s"; @@ -179,8 +179,8 @@ GaiaAuthFetcher::GaiaAuthFetcher(GaiaAuthConsumer* consumer, oauth2_revoke_gurl_(GaiaUrls::GetInstance()->oauth2_revoke_url()), get_user_info_gurl_(GaiaUrls::GetInstance()->get_user_info_url()), merge_session_gurl_(GaiaUrls::GetInstance()->merge_session_url()), - uberauth_token_gurl_(base::StringPrintf(kUberAuthTokenURLFormat, - GaiaUrls::GetInstance()->oauth1_login_url().c_str(), source.c_str())), + uberauth_token_gurl_(GaiaUrls::GetInstance()->oauth1_login_url().Resolve( + base::StringPrintf(kUberAuthTokenURLFormat, source.c_str()))), oauth_login_gurl_(GaiaUrls::GetInstance()->oauth1_login_url()), client_login_to_oauth2_gurl_( GaiaUrls::GetInstance()->client_login_to_oauth2_url()), @@ -517,7 +517,7 @@ void GaiaAuthFetcher::StartLsoForOAuthLoginTokenExchange( DVLOG(1) << "Starting OAuth login token exchange with auth_token"; request_body_ = MakeGetAuthCodeBody(); client_login_to_oauth2_gurl_ = - GURL(GaiaUrls::GetInstance()->client_login_to_oauth2_url()); + GaiaUrls::GetInstance()->client_login_to_oauth2_url(); fetcher_.reset(CreateGaiaFetcher(getter_, request_body_, @@ -551,11 +551,12 @@ void GaiaAuthFetcher::StartCookieForOAuthLoginTokenExchange( DVLOG(1) << "Starting OAuth login token fetch with cookie jar"; request_body_ = MakeGetAuthCodeBody(); - std::string url = GaiaUrls::GetInstance()->client_login_to_oauth2_url(); - if (!session_index.empty()) - url += "?authuser=" + session_index; - - client_login_to_oauth2_gurl_ = GURL(url); + client_login_to_oauth2_gurl_ = + GaiaUrls::GetInstance()->client_login_to_oauth2_url(); + if (!session_index.empty()) { + client_login_to_oauth2_gurl_ = + client_login_to_oauth2_gurl_.Resolve("?authuser=" + session_index); + } fetcher_.reset(CreateGaiaFetcher(getter_, request_body_, @@ -684,7 +685,7 @@ GoogleServiceAuthError GaiaAuthFetcher::GenerateAuthError( if (error == kCaptchaError) { GURL image_url( - GaiaUrls::GetInstance()->captcha_url_prefix() + captcha_url); + GaiaUrls::GetInstance()->captcha_base_url().Resolve(captcha_url)); GURL unlock_url(url); return GoogleServiceAuthError::FromClientLoginCaptchaChallenge( captcha_token, image_url, unlock_url); @@ -737,7 +738,7 @@ GoogleServiceAuthError GaiaAuthFetcher::GenerateOAuthLoginError( if (error == kCaptchaErrorCode) { GURL image_url( - GaiaUrls::GetInstance()->captcha_url_prefix() + captcha_url); + GaiaUrls::GetInstance()->captcha_base_url().Resolve(captcha_url)); GURL unlock_url(url); return GoogleServiceAuthError::FromClientLoginCaptchaChallenge( captcha_token, image_url, unlock_url); diff --git a/google_apis/gaia/gaia_auth_fetcher_unittest.cc b/google_apis/gaia/gaia_auth_fetcher_unittest.cc index 74fed98..f554b5e 100644 --- a/google_apis/gaia/gaia_auth_fetcher_unittest.cc +++ b/google_apis/gaia/gaia_auth_fetcher_unittest.cc @@ -27,8 +27,8 @@ #include "testing/gtest/include/gtest/gtest.h" #include "url/gurl.h" -using ::testing::_; using ::testing::Invoke; +using ::testing::_; namespace { static const char kGetAuthCodeValidCookie[] = @@ -111,9 +111,9 @@ class GaiaAuthFetcherTest : public testing::Test { oauth2_token_source_(GaiaUrls::GetInstance()->oauth2_token_url()), token_auth_source_(GaiaUrls::GetInstance()->token_auth_url()), merge_session_source_(GaiaUrls::GetInstance()->merge_session_url()), - uberauth_token_source_(base::StringPrintf( - "%s?source=&issueuberauth=1", - GaiaUrls::GetInstance()->oauth1_login_url().c_str())), + uberauth_token_source_( + GaiaUrls::GetInstance()->oauth1_login_url().Resolve( + "?source=&issueuberauth=1")), oauth_login_gurl_(GaiaUrls::GetInstance()->oauth1_login_url()) {} void RunParsingTest(const std::string& data, diff --git a/google_apis/gaia/gaia_switches.cc b/google_apis/gaia/gaia_switches.cc index c2430b0..16228c3 100644 --- a/google_apis/gaia/gaia_switches.cc +++ b/google_apis/gaia/gaia_switches.cc @@ -8,11 +8,10 @@ namespace switches { const char kClientLoginToOAuth2Url[] = "client-login-to-oauth2-url"; const char kGaiaUrl[] = "gaia-url"; -const char kGoogleApisHost[] = "google-apis-host"; +const char kGoogleApisUrl[] = "google-apis-url"; const char kLsoUrl[] = "lso-url"; const char kOAuth1LoginScope[] = "oauth1-login-scope"; -const char kOAuth2IssueTokenUrl[] = "oauth2-issue-token-url"; -const char kOAuth2TokenUrl[] = "oauth2-token-url"; -const char kOAuthUserInfoUrl[] = "oauth-user-info-url"; +const char kOAuthWrapBridgeUserInfoScope[] = + "oauth-wrap-bridge-user-info-scope"; } // namespace switches diff --git a/google_apis/gaia/gaia_switches.h b/google_apis/gaia/gaia_switches.h index 727a355..0700f36 100644 --- a/google_apis/gaia/gaia_switches.h +++ b/google_apis/gaia/gaia_switches.h @@ -14,29 +14,20 @@ extern const char kClientLoginToOAuth2Url[]; // "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. -// The default value is "www.googleapis.com". -extern const char kGoogleApisHost[]; +// Specifies the backend server used for Google API calls. +// The default value is "https://www.googleapis.com". +extern const char kGoogleApisUrl[]; // Specifies the backend server used for lso authentication calls. // "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. - // Specifies custom OAuth1 login scope for testing purposes. extern const char kOAuth1LoginScope[]; -// Specifies custom OAuth2 issue token URL for testing purposes. -extern const char kOAuth2IssueTokenUrl[]; - -// Specifies custom OAuth2 token URL for testing purposes. -extern const char kOAuth2TokenUrl[]; +// Overrides OAuth wrap bridge user info scope. +extern const char kOAuthWrapBridgeUserInfoScope[]; -// Specifies custom OAuth user info URL for testing purposes. -extern const char kOAuthUserInfoUrl[]; } // namespace switches #endif // GOOGLE_APIS_GAIA_GAIA_SWITCHES_H_ diff --git a/google_apis/gaia/gaia_urls.cc b/google_apis/gaia/gaia_urls.cc index 578205c..f976f6c 100644 --- a/google_apis/gaia/gaia_urls.cc +++ b/google_apis/gaia/gaia_urls.cc @@ -13,38 +13,38 @@ namespace { // Gaia service constants const char kDefaultGaiaUrl[] = "https://accounts.google.com"; -const char kDefaultGoogleApisBaseUrl[] = "www.googleapis.com"; -const char kCaptchaUrlPrefixSuffix[] = "/"; +const char kDefaultGoogleApisBaseUrl[] = "https://www.googleapis.com"; // API calls from accounts.google.com -const char kClientLoginUrlSuffix[] = "/ClientLogin"; -const char kServiceLoginUrlSuffix[] = "/ServiceLogin"; -const char kServiceLogoutUrlSuffix[] = "/Logout"; -const char kIssueAuthTokenUrlSuffix[] = "/IssueAuthToken"; -const char kGetUserInfoUrlSuffix[] = "/GetUserInfo"; -const char kTokenAuthUrlSuffix[] = "/TokenAuth"; -const char kMergeSessionUrlSuffix[] = "/MergeSession"; -const char kOAuthGetAccessTokenUrlSuffix[] = "/OAuthGetAccessToken"; -const char kOAuthWrapBridgeUrlSuffix[] = "/OAuthWrapBridge"; -const char kOAuth1LoginUrlSuffix[] = "/OAuthLogin"; -const char kOAuthRevokeTokenUrlSuffix[] = "/AuthSubRevokeToken"; +const char kClientLoginUrlSuffix[] = "ClientLogin"; +const char kServiceLoginUrlSuffix[] = "ServiceLogin"; +const char kServiceLogoutUrlSuffix[] = "Logout"; +const char kIssueAuthTokenUrlSuffix[] = "IssueAuthToken"; +const char kGetUserInfoUrlSuffix[] = "GetUserInfo"; +const char kTokenAuthUrlSuffix[] = "TokenAuth"; +const char kMergeSessionUrlSuffix[] = "MergeSession"; +const char kOAuthGetAccessTokenUrlSuffix[] = "OAuthGetAccessToken"; +const char kOAuthWrapBridgeUrlSuffix[] = "OAuthWrapBridge"; +const char kOAuth1LoginUrlSuffix[] = "OAuthLogin"; +const char kOAuthRevokeTokenUrlSuffix[] = "AuthSubRevokeToken"; + +// OAuth scopes +const char kOAuth1LoginScope[] = "https://www.google.com/accounts/OAuthLogin"; +const char kOAuthWrapBridgeUserInfoScope[] = + "https://www.googleapis.com/auth/userinfo.email"; // API calls from accounts.google.com (LSO) -const char kGetOAuthTokenUrlSuffix[] = "/o/oauth/GetOAuthToken/"; -const char kClientLoginToOAuth2UrlSuffix[] = "/o/oauth2/programmatic_auth"; -const char kOAuth2AuthUrlSuffix[] = "/o/oauth2/auth"; -const char kOAuth2RevokeUrlSuffix[] = "/o/oauth2/revoke"; -const char kOAuth2TokenUrlSuffix[] = "/o/oauth2/token"; -const char kClientOAuthUrlSuffix[] = "/ClientOAuth"; +const char kGetOAuthTokenUrlSuffix[] = "o/oauth/GetOAuthToken/"; +const char kClientLoginToOAuth2UrlSuffix[] = "o/oauth2/programmatic_auth"; +const char kOAuth2AuthUrlSuffix[] = "o/oauth2/auth"; +const char kOAuth2RevokeUrlSuffix[] = "o/oauth2/revoke"; +const char kOAuth2TokenUrlSuffix[] = "o/oauth2/token"; +const char kClientOAuthUrlSuffix[] = "ClientOAuth"; // API calls from www.googleapis.com -const char kOAuth2IssueTokenUrlSuffix[] = "/oauth2/v2/IssueToken"; -const char kOAuth2TokenInfoUrlSuffix[] = "/oauth2/v2/tokeninfo"; -const char kOAuthUserInfoUrlSuffix[] = "/oauth2/v1/userinfo"; -const char kOAuthWrapBridgeUserInfoScopeUrlSuffix[] = "/auth/userinfo.email"; - -const char kOAuth1LoginScope[] = - "https://www.google.com/accounts/OAuthLogin"; +const char kOAuth2IssueTokenUrlSuffix[] = "oauth2/v2/IssueToken"; +const char kOAuth2TokenInfoUrlSuffix[] = "oauth2/v2/tokeninfo"; +const char kOAuthUserInfoUrlSuffix[] = "oauth2/v1/userinfo"; void GetSwitchValueWithDefault(const char* switch_value, const char* default_value, @@ -57,6 +57,16 @@ void GetSwitchValueWithDefault(const char* switch_value, } } +GURL GetURLSwitchValueWithDefault(const char* switch_value, + const char* default_value) { + std::string string_value; + GetSwitchValueWithDefault(switch_value, default_value, &string_value); + const GURL result(string_value); + DCHECK(result.is_valid()); + return result; +} + + } // namespace GaiaUrls* GaiaUrls::GetInstance() { @@ -64,27 +74,15 @@ GaiaUrls* GaiaUrls::GetInstance() { } GaiaUrls::GaiaUrls() { - std::string gaia_url_str; - GetSwitchValueWithDefault(switches::kGaiaUrl, - kDefaultGaiaUrl, - &gaia_url_str); - gaia_url_ = GURL(gaia_url_str); - DCHECK(gaia_url_.is_valid()); - - GetSwitchValueWithDefault(switches::kLsoUrl, - kDefaultGaiaUrl, - &lso_origin_url_); - - std::string google_apis_base; - GetSwitchValueWithDefault(switches::kGoogleApisHost, - kDefaultGoogleApisBaseUrl, - &google_apis_base); + gaia_url_ = GetURLSwitchValueWithDefault(switches::kGaiaUrl, kDefaultGaiaUrl); + lso_origin_url_ = + GetURLSwitchValueWithDefault(switches::kLsoUrl, kDefaultGaiaUrl); + google_apis_origin_url_ = GetURLSwitchValueWithDefault( + switches::kGoogleApisUrl, kDefaultGoogleApisBaseUrl); - captcha_url_prefix_ = "http://" + gaia_url_.host() + - (gaia_url_.has_port() ? ":" + gaia_url_.port() : "") + - kCaptchaUrlPrefixSuffix; - - google_apis_origin_url_ = "https://" + google_apis_base; + captcha_base_url_ = + GURL("http://" + gaia_url_.host() + + (gaia_url_.has_port() ? ":" + gaia_url_.port() : "")); oauth2_chrome_client_id_ = google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN); @@ -92,115 +90,106 @@ GaiaUrls::GaiaUrls() { google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN); // URLs from accounts.google.com. - 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; + client_login_url_ = gaia_url_.Resolve(kClientLoginUrlSuffix); + service_login_url_ = gaia_url_.Resolve(kServiceLoginUrlSuffix); + service_logout_url_ = gaia_url_.Resolve(kServiceLogoutUrlSuffix); + issue_auth_token_url_ = gaia_url_.Resolve(kIssueAuthTokenUrlSuffix); + get_user_info_url_ = gaia_url_.Resolve(kGetUserInfoUrlSuffix); + token_auth_url_ = gaia_url_.Resolve(kTokenAuthUrlSuffix); + merge_session_url_ = gaia_url_.Resolve(kMergeSessionUrlSuffix); + oauth_get_access_token_url_ = + gaia_url_.Resolve(kOAuthGetAccessTokenUrlSuffix); + oauth_wrap_bridge_url_ = gaia_url_.Resolve(kOAuthWrapBridgeUrlSuffix); + oauth_revoke_token_url_ = gaia_url_.Resolve(kOAuthRevokeTokenUrlSuffix); + oauth1_login_url_ = gaia_url_.Resolve(kOAuth1LoginUrlSuffix); // URLs from accounts.google.com (LSO). - get_oauth_token_url_ = lso_origin_url_ + kGetOAuthTokenUrlSuffix; - std::string client_login_to_oauth2_url = lso_origin_url_ + - kClientLoginToOAuth2UrlSuffix; - oauth2_auth_url_ = lso_origin_url_ + kOAuth2AuthUrlSuffix; - std::string oauth2_token_url = lso_origin_url_ + kOAuth2TokenUrlSuffix; - oauth2_revoke_url_ = lso_origin_url_ + kOAuth2RevokeUrlSuffix; + get_oauth_token_url_ = lso_origin_url_.Resolve(kGetOAuthTokenUrlSuffix); + client_login_to_oauth2_url_ = + lso_origin_url_.Resolve(kClientLoginToOAuth2UrlSuffix); + oauth2_auth_url_ = lso_origin_url_.Resolve(kOAuth2AuthUrlSuffix); + oauth2_token_url_ = lso_origin_url_.Resolve(kOAuth2TokenUrlSuffix); + oauth2_revoke_url_ = lso_origin_url_.Resolve(kOAuth2RevokeUrlSuffix); // URLs from www.googleapis.com. - oauth_wrap_bridge_user_info_scope_ = google_apis_origin_url_ + - kOAuthWrapBridgeUserInfoScopeUrlSuffix; - std::string oauth2_issue_token_url = google_apis_origin_url_ + - kOAuth2IssueTokenUrlSuffix; - oauth2_token_info_url_ = google_apis_origin_url_ + kOAuth2TokenInfoUrlSuffix; - std::string oauth_user_info_url = google_apis_origin_url_ + - kOAuthUserInfoUrlSuffix; - - // TODO(zelidrag): Get rid of all these switches since all URLs should be - // controlled only with --gaia-url, --lso-url and --google-apis-host. + oauth2_issue_token_url_ = + google_apis_origin_url_.Resolve(kOAuth2IssueTokenUrlSuffix); + oauth2_token_info_url_ = + google_apis_origin_url_.Resolve(kOAuth2TokenInfoUrlSuffix); + oauth_user_info_url_ = + google_apis_origin_url_.Resolve(kOAuthUserInfoUrlSuffix); + + gaia_login_form_realm_ = gaia_url_; + + // OAuth scopes. + GetSwitchValueWithDefault(switches::kOAuthWrapBridgeUserInfoScope, + kOAuthWrapBridgeUserInfoScope, + &oauth_wrap_bridge_user_info_scope_); GetSwitchValueWithDefault(switches::kOAuth1LoginScope, kOAuth1LoginScope, &oauth1_login_scope_); - GetSwitchValueWithDefault(switches::kClientLoginToOAuth2Url, - client_login_to_oauth2_url.c_str(), - &client_login_to_oauth2_url_); - GetSwitchValueWithDefault(switches::kOAuth2TokenUrl, - oauth2_token_url.c_str(), - &oauth2_token_url_); - GetSwitchValueWithDefault(switches::kOAuth2IssueTokenUrl, - oauth2_issue_token_url.c_str(), - &oauth2_issue_token_url_); - GetSwitchValueWithDefault(switches::kOAuthUserInfoUrl, - oauth_user_info_url.c_str(), - &oauth_user_info_url_); } GaiaUrls::~GaiaUrls() { } -const std::string& GaiaUrls::captcha_url_prefix() const { - return captcha_url_prefix_; -} - const GURL& GaiaUrls::gaia_url() const { return gaia_url_; } -const std::string& GaiaUrls::client_login_url() const { +const GURL& GaiaUrls::captcha_base_url() const { + return captcha_base_url_; +} + +const GURL& GaiaUrls::client_login_url() const { return client_login_url_; } -const std::string& GaiaUrls::service_login_url() const { +const GURL& GaiaUrls::service_login_url() const { return service_login_url_; } -const std::string& GaiaUrls::service_logout_url() const { +const GURL& GaiaUrls::service_logout_url() const { return service_logout_url_; } -const std::string& GaiaUrls::issue_auth_token_url() const { +const GURL& GaiaUrls::issue_auth_token_url() const { return issue_auth_token_url_; } -const std::string& GaiaUrls::get_user_info_url() const { +const GURL& GaiaUrls::get_user_info_url() const { return get_user_info_url_; } -const std::string& GaiaUrls::token_auth_url() const { +const GURL& GaiaUrls::token_auth_url() const { return token_auth_url_; } -const std::string& GaiaUrls::merge_session_url() const { +const GURL& GaiaUrls::merge_session_url() const { return merge_session_url_; } -const std::string& GaiaUrls::get_oauth_token_url() const { +const GURL& GaiaUrls::get_oauth_token_url() const { return get_oauth_token_url_; } -const std::string& GaiaUrls::oauth_get_access_token_url() const { +const GURL& GaiaUrls::oauth_get_access_token_url() const { return oauth_get_access_token_url_; } -const std::string& GaiaUrls::oauth_wrap_bridge_url() const { +const GURL& GaiaUrls::oauth_wrap_bridge_url() const { return oauth_wrap_bridge_url_; } -const std::string& GaiaUrls::oauth_user_info_url() const { +const GURL& GaiaUrls::oauth_user_info_url() const { return oauth_user_info_url_; } -const std::string& GaiaUrls::oauth_revoke_token_url() const { +const GURL& GaiaUrls::oauth_revoke_token_url() const { return oauth_revoke_token_url_; } -const std::string& GaiaUrls::oauth1_login_url() const { +const GURL& GaiaUrls::oauth1_login_url() const { return oauth1_login_url_; } @@ -220,30 +209,30 @@ const std::string& GaiaUrls::oauth2_chrome_client_secret() const { return oauth2_chrome_client_secret_; } -const std::string& GaiaUrls::client_login_to_oauth2_url() const { +const GURL& GaiaUrls::client_login_to_oauth2_url() const { return client_login_to_oauth2_url_; } -const std::string& GaiaUrls::oauth2_auth_url() const { +const GURL& GaiaUrls::oauth2_auth_url() const { return oauth2_auth_url_; } -const std::string& GaiaUrls::oauth2_token_url() const { +const GURL& GaiaUrls::oauth2_token_url() const { return oauth2_token_url_; } -const std::string& GaiaUrls::oauth2_issue_token_url() const { +const GURL& GaiaUrls::oauth2_issue_token_url() const { return oauth2_issue_token_url_; } -const std::string& GaiaUrls::oauth2_token_info_url() const { +const GURL& GaiaUrls::oauth2_token_info_url() const { return oauth2_token_info_url_; } -const std::string& GaiaUrls::oauth2_revoke_url() const { +const GURL& GaiaUrls::oauth2_revoke_url() const { return oauth2_revoke_url_; } -const std::string& GaiaUrls::gaia_login_form_realm() const { - return gaia_login_form_realm_; +const GURL& GaiaUrls::gaia_login_form_realm() const { + return gaia_url_; } diff --git a/google_apis/gaia/gaia_urls.h b/google_apis/gaia/gaia_urls.h index 28c7279..06014d2 100644 --- a/google_apis/gaia/gaia_urls.h +++ b/google_apis/gaia/gaia_urls.h @@ -16,36 +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; - 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 GURL& captcha_base_url() const; + const GURL& client_login_url() const; + const GURL& service_login_url() const; + const GURL& service_logout_url() const; + const GURL& issue_auth_token_url() const; + const GURL& get_user_info_url() const; + const GURL& token_auth_url() const; + const GURL& merge_session_url() const; + const GURL& get_oauth_token_url() const; + const GURL& oauth_get_access_token_url() const; + const GURL& oauth_wrap_bridge_url() const; + const GURL& oauth_user_info_url() const; + const GURL& oauth_revoke_token_url() const; + const GURL& 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_token_info_url() const; - const std::string& oauth2_revoke_url() const; + const GURL& client_login_to_oauth2_url() const; + const GURL& oauth2_auth_url() const; + const GURL& oauth2_token_url() const; + const GURL& oauth2_issue_token_url() const; + const GURL& oauth2_token_info_url() const; + const GURL& oauth2_revoke_url() const; - const std::string& gaia_login_form_realm() const; + const GURL& gaia_login_form_realm() const; private: GaiaUrls(); @@ -53,38 +52,40 @@ class GaiaUrls { friend struct DefaultSingletonTraits<GaiaUrls>; - std::string captcha_url_prefix_; - GURL gaia_url_; - std::string lso_origin_url_; - std::string google_apis_origin_url_; - std::string client_login_url_; - std::string service_login_url_; - std::string service_logout_url_; - std::string issue_auth_token_url_; - std::string get_user_info_url_; - std::string token_auth_url_; - std::string merge_session_url_; - std::string get_oauth_token_url_; - std::string oauth_get_access_token_url_; - std::string oauth_wrap_bridge_url_; - std::string oauth_user_info_url_; - std::string oauth_revoke_token_url_; - std::string oauth1_login_url_; + GURL captcha_base_url_; + + GURL lso_origin_url_; + GURL google_apis_origin_url_; + + GURL client_login_url_; + GURL service_login_url_; + GURL service_logout_url_; + GURL issue_auth_token_url_; + GURL get_user_info_url_; + GURL token_auth_url_; + GURL merge_session_url_; + GURL get_oauth_token_url_; + GURL oauth_get_access_token_url_; + GURL oauth_wrap_bridge_url_; + GURL oauth_user_info_url_; + GURL oauth_revoke_token_url_; + GURL oauth1_login_url_; std::string oauth1_login_scope_; std::string oauth_wrap_bridge_user_info_scope_; std::string oauth2_chrome_client_id_; std::string oauth2_chrome_client_secret_; - std::string client_login_to_oauth2_url_; - std::string oauth2_auth_url_; - std::string oauth2_token_url_; - std::string oauth2_issue_token_url_; - std::string oauth2_token_info_url_; - std::string oauth2_revoke_url_; - - std::string gaia_login_form_realm_; + + GURL client_login_to_oauth2_url_; + GURL oauth2_auth_url_; + GURL oauth2_token_url_; + GURL oauth2_issue_token_url_; + GURL oauth2_token_info_url_; + GURL oauth2_revoke_url_; + + GURL gaia_login_form_realm_; DISALLOW_COPY_AND_ASSIGN(GaiaUrls); }; diff --git a/google_apis/gaia/oauth2_access_token_fetcher.cc b/google_apis/gaia/oauth2_access_token_fetcher.cc index 456251f..44f2d4a 100644 --- a/google_apis/gaia/oauth2_access_token_fetcher.cc +++ b/google_apis/gaia/oauth2_access_token_fetcher.cc @@ -182,7 +182,7 @@ void OAuth2AccessTokenFetcher::OnURLFetchComplete( // static GURL OAuth2AccessTokenFetcher::MakeGetAccessTokenUrl() { - return GURL(GaiaUrls::GetInstance()->oauth2_token_url()); + return GaiaUrls::GetInstance()->oauth2_token_url(); } // static diff --git a/google_apis/gaia/oauth2_mint_token_flow.cc b/google_apis/gaia/oauth2_mint_token_flow.cc index f66e0fb..b705ab8 100644 --- a/google_apis/gaia/oauth2_mint_token_flow.cc +++ b/google_apis/gaia/oauth2_mint_token_flow.cc @@ -151,7 +151,7 @@ void OAuth2MintTokenFlow::ReportFailure( } GURL OAuth2MintTokenFlow::CreateApiCallUrl() { - return GURL(GaiaUrls::GetInstance()->oauth2_issue_token_url()); + return GaiaUrls::GetInstance()->oauth2_issue_token_url(); } std::string OAuth2MintTokenFlow::CreateApiCallBody() { |