diff options
author | gfeher@chromium.org <gfeher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 19:14:24 +0000 |
---|---|---|
committer | gfeher@chromium.org <gfeher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-15 19:14:24 +0000 |
commit | 63411a0180c7eb6678ca3681578479a3ab003436 (patch) | |
tree | dffe8863c4b3646b3535d2631d0b8e52eb97bb86 /chrome/common/net/gaia | |
parent | f91ac539016dec3faca1c47f7a27bec56f6fdf79 (diff) | |
download | chromium_src-63411a0180c7eb6678ca3681578479a3ab003436.zip chromium_src-63411a0180c7eb6678ca3681578479a3ab003436.tar.gz chromium_src-63411a0180c7eb6678ca3681578479a3ab003436.tar.bz2 |
Flag for switching GAIA backend
This makes it possible to run Chrome with test gaia backends.
BUG=82120
TEST=sync, cloud policies and cloud print keeps working as before
Review URL: http://codereview.chromium.org/7134045
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@89228 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/net/gaia')
-rw-r--r-- | chrome/common/net/gaia/gaia_auth_fetcher.cc | 22 | ||||
-rw-r--r-- | chrome/common/net/gaia/gaia_auth_fetcher.h | 6 | ||||
-rw-r--r-- | chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc | 6 | ||||
-rw-r--r-- | chrome/common/net/gaia/gaia_authenticator.h | 5 | ||||
-rw-r--r-- | chrome/common/net/gaia/gaia_urls.cc | 65 | ||||
-rw-r--r-- | chrome/common/net/gaia/gaia_urls.h | 41 |
6 files changed, 117 insertions, 28 deletions
diff --git a/chrome/common/net/gaia/gaia_auth_fetcher.cc b/chrome/common/net/gaia/gaia_auth_fetcher.cc index 2f979f4..0e7b6f2 100644 --- a/chrome/common/net/gaia/gaia_auth_fetcher.cc +++ b/chrome/common/net/gaia/gaia_auth_fetcher.cc @@ -13,6 +13,7 @@ #include "base/string_util.h" #include "chrome/common/net/gaia/gaia_auth_consumer.h" #include "chrome/common/net/gaia/gaia_constants.h" +#include "chrome/common/net/gaia/gaia_urls.h" #include "chrome/common/net/gaia/google_service_auth_error.h" #include "chrome/common/net/http_return.h" #include "net/base/escape.h" @@ -68,9 +69,6 @@ const char GaiaAuthFetcher::kErrorUrlParam[] = "Url"; const char GaiaAuthFetcher::kCaptchaUrlParam[] = "CaptchaUrl"; // static const char GaiaAuthFetcher::kCaptchaTokenParam[] = "CaptchaToken"; -// static -const char GaiaAuthFetcher::kCaptchaUrlPrefix[] = - "http://www.google.com/accounts/"; // static const char GaiaAuthFetcher::kCookiePersistence[] = "true"; @@ -85,24 +83,15 @@ const char GaiaAuthFetcher::kAccountTypeGoogle[] = // static const char GaiaAuthFetcher::kSecondFactor[] = "Info=InvalidSecondFactor"; -// TODO(chron): These urls are also in auth_response_handler.h. -// The URLs for different calls in the Google Accounts programmatic login API. -const char GaiaAuthFetcher::kClientLoginUrl[] = - "https://www.google.com/accounts/ClientLogin"; -const char GaiaAuthFetcher::kIssueAuthTokenUrl[] = - "https://www.google.com/accounts/IssueAuthToken"; -const char GaiaAuthFetcher::kGetUserInfoUrl[] = - "https://www.google.com/accounts/GetUserInfo"; - GaiaAuthFetcher::GaiaAuthFetcher(GaiaAuthConsumer* consumer, const std::string& source, net::URLRequestContextGetter* getter) : consumer_(consumer), getter_(getter), source_(source), - client_login_gurl_(kClientLoginUrl), - issue_auth_token_gurl_(kIssueAuthTokenUrl), - get_user_info_gurl_(kGetUserInfoUrl), + client_login_gurl_(GaiaUrls::GetInstance()->client_login_url()), + issue_auth_token_gurl_(GaiaUrls::GetInstance()->issue_auth_token_url()), + get_user_info_gurl_(GaiaUrls::GetInstance()->get_user_info_url()), fetch_pending_(false) {} GaiaAuthFetcher::~GaiaAuthFetcher() {} @@ -335,7 +324,8 @@ GoogleServiceAuthError GaiaAuthFetcher::GenerateAuthError( LOG(WARNING) << "ClientLogin failed with " << error; if (error == kCaptchaError) { - GURL image_url(kCaptchaUrlPrefix + captcha_url); + GURL image_url( + GaiaUrls::GetInstance()->captcha_url_prefix() + captcha_url); GURL unlock_url(url); return GoogleServiceAuthError::FromCaptchaChallenge( captcha_token, image_url, unlock_url); diff --git a/chrome/common/net/gaia/gaia_auth_fetcher.h b/chrome/common/net/gaia/gaia_auth_fetcher.h index 9099986..ca72def 100644 --- a/chrome/common/net/gaia/gaia_auth_fetcher.h +++ b/chrome/common/net/gaia/gaia_auth_fetcher.h @@ -33,11 +33,6 @@ class GaiaAuthFetcher : public URLFetcher::Delegate { HostedAccountsNotAllowed }; - // The URLs for different calls in the Google Accounts programmatic login API. - static const char kClientLoginUrl[]; - static const char kIssueAuthTokenUrl[]; - static const char kGetUserInfoUrl[]; - // Magic string indicating that, while a second factor is still // needed to complete authentication, the user provided the right password. static const char kSecondFactor[]; @@ -112,7 +107,6 @@ class GaiaAuthFetcher : public URLFetcher::Delegate { static const char kErrorUrlParam[]; static const char kCaptchaUrlParam[]; static const char kCaptchaTokenParam[]; - static const char kCaptchaUrlPrefix[]; // Process the results of a ClientLogin fetch. void OnClientLoginFetched(const std::string& data, diff --git a/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc b/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc index af6491b..2479aac 100644 --- a/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc +++ b/chrome/common/net/gaia/gaia_auth_fetcher_unittest.cc @@ -12,6 +12,7 @@ #include "chrome/common/net/gaia/gaia_auth_consumer.h" #include "chrome/common/net/gaia/gaia_auth_fetcher.h" #include "chrome/common/net/gaia/gaia_auth_fetcher_unittest.h" +#include "chrome/common/net/gaia/gaia_urls.h" #include "chrome/common/net/gaia/google_service_auth_error.h" #include "chrome/common/net/http_return.h" #include "chrome/test/testing_profile.h" @@ -61,8 +62,9 @@ void MockFetcher::Start() { class GaiaAuthFetcherTest : public testing::Test { public: GaiaAuthFetcherTest() - : client_login_source_(GaiaAuthFetcher::kClientLoginUrl), - issue_auth_token_source_(GaiaAuthFetcher::kIssueAuthTokenUrl) {} + : client_login_source_(GaiaUrls::GetInstance()->client_login_url()), + issue_auth_token_source_( + GaiaUrls::GetInstance()->issue_auth_token_url()) {} void RunParsingTest(const std::string& data, const std::string& sid, diff --git a/chrome/common/net/gaia/gaia_authenticator.h b/chrome/common/net/gaia/gaia_authenticator.h index ce0500d9..b72b4b2 100644 --- a/chrome/common/net/gaia/gaia_authenticator.h +++ b/chrome/common/net/gaia/gaia_authenticator.h @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // @@ -39,9 +39,6 @@ namespace gaia { -static const char kGaiaUrl[] = - "https://www.google.com:443/accounts/ClientLogin"; - // Error codes from Gaia. These will be set correctly for both Gaia V1 // (/ClientAuth) and V2 (/ClientLogin) enum AuthenticationError { diff --git a/chrome/common/net/gaia/gaia_urls.cc b/chrome/common/net/gaia/gaia_urls.cc new file mode 100644 index 0000000..481a76f --- /dev/null +++ b/chrome/common/net/gaia/gaia_urls.cc @@ -0,0 +1,65 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/common/net/gaia/gaia_urls.h" + +#include "base/command_line.h" +#include "chrome/common/chrome_switches.h" + +namespace { + +const char kDefaultGaiaBaseUrl[] = "www.google.com"; +const char kCaptchaUrlPrefixSuffix[] = "/accounts/"; +const char kClientLoginUrlSuffix[] = "/accounts/ClientLogin"; +const char kIssueAuthTokenUrlSuffix[] = "/accounts/IssueAuthToken"; +const char kGetUserInfoUrlSuffix[] = "/accounts/GetUserInfo"; +// TODO(cmasone): make sure that using an http:// URL in the "continue" +// parameter here doesn't open the system up to attack long-term. +const char kTokenAuthUrlSuffix[] = + "accounts/TokenAuth?" + "continue=http://www.google.com/webhp&source=chromeos&auth="; + +} // namespacce + +GaiaUrls* GaiaUrls::GetInstance() { + return Singleton<GaiaUrls>::get(); +} + +GaiaUrls::GaiaUrls() { + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kGaiaHost)) { + host_base_ = command_line->GetSwitchValueASCII(switches::kGaiaHost); + } else { + host_base_ = kDefaultGaiaBaseUrl; + } + + captcha_url_prefix_ = "http://" + host_base_ + kCaptchaUrlPrefixSuffix; + client_login_url_ = "https://" + host_base_ + kClientLoginUrlSuffix; + issue_auth_token_url_ = "https://" + host_base_ + kIssueAuthTokenUrlSuffix; + get_user_info_url_ = "https://" + host_base_ + kGetUserInfoUrlSuffix; + token_auth_url_ = "https://" + host_base_ + kTokenAuthUrlSuffix; +} + +GaiaUrls::~GaiaUrls() { +} + +const std::string& GaiaUrls::captcha_url_prefix() { + return captcha_url_prefix_; +} + +const std::string& GaiaUrls::client_login_url() { + return client_login_url_; +} + +const std::string& GaiaUrls::issue_auth_token_url() { + return issue_auth_token_url_; +} + +const std::string& GaiaUrls::get_user_info_url() { + return get_user_info_url_; +} + +const std::string& GaiaUrls::token_auth_url() { + return token_auth_url_; +} diff --git a/chrome/common/net/gaia/gaia_urls.h b/chrome/common/net/gaia/gaia_urls.h new file mode 100644 index 0000000..327110d --- /dev/null +++ b/chrome/common/net/gaia/gaia_urls.h @@ -0,0 +1,41 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_COMMON_NET_GAIA_GAIA_URLS_H_ +#define CHROME_COMMON_NET_GAIA_GAIA_URLS_H_ +#pragma once + +#include <string> + +#include "base/memory/singleton.h" + +// A signleton that provides all the URLs that are used for connecting to GAIA. +class GaiaUrls { + public: + static GaiaUrls* GetInstance(); + + // The URLs for different calls in the Google Accounts programmatic login API. + const std::string& captcha_url_prefix(); + const std::string& client_login_url(); + const std::string& issue_auth_token_url(); + const std::string& get_user_info_url(); + const std::string& token_auth_url(); + + private: + GaiaUrls(); + ~GaiaUrls(); + + friend struct DefaultSingletonTraits<GaiaUrls>; + + std::string host_base_; + std::string captcha_url_prefix_; + std::string client_login_url_; + std::string issue_auth_token_url_; + std::string get_user_info_url_; + std::string token_auth_url_; + + DISALLOW_COPY_AND_ASSIGN(GaiaUrls); +}; + +#endif // CHROME_COMMON_NET_GAIA_GAIA_URLS_H_ |