| Index: chrome/common/net/gaia/gaia_auth_fetcher.h
|
| diff --git a/chrome/common/net/gaia/gaia_auth_fetcher.h b/chrome/common/net/gaia/gaia_auth_fetcher.h
|
| index f6f092b173b220d30ba6d3fd8358145fb4c81b22..3d8a04c0592c26cc2059f86b421d2688ac45fccc 100644
|
| --- a/chrome/common/net/gaia/gaia_auth_fetcher.h
|
| +++ b/chrome/common/net/gaia/gaia_auth_fetcher.h
|
| @@ -11,7 +11,7 @@
|
| #include "base/gtest_prod_util.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "chrome/common/net/gaia/gaia_auth_consumer.h"
|
| -#include "chrome/common/net/url_fetcher.h"
|
| +#include "chrome/common/net/gaia/authentication_fetcher.h"
|
| #include "googleurl/src/gurl.h"
|
|
|
| // Authenticate a user against the Google Accounts ClientLogin API
|
| @@ -26,13 +26,8 @@
|
|
|
| class GaiaAuthFetcherTest;
|
|
|
| -class GaiaAuthFetcher : public URLFetcher::Delegate {
|
| +class GaiaAuthFetcher : public AuthenticationFetcher {
|
| public:
|
| - enum HostedAccountsSetting {
|
| - HostedAccountsAllowed,
|
| - HostedAccountsNotAllowed
|
| - };
|
| -
|
| // The URLs for different calls in the Google Accounts programmatic login API.
|
| static const char kClientLoginUrl[];
|
| static const char kIssueAuthTokenUrl[];
|
| @@ -49,6 +44,13 @@ class GaiaAuthFetcher : public URLFetcher::Delegate {
|
| net::URLRequestContextGetter* getter);
|
| virtual ~GaiaAuthFetcher();
|
|
|
| + virtual void StartAuthentication(const std::string& username,
|
| + const std::string& password,
|
| + const char* const service,
|
| + const std::string& login_token,
|
| + const std::string& login_captcha,
|
| + HostedAccountsSetting allow_hosted_accounts);
|
| +
|
| // GaiaAuthConsumer will be called on the original thread
|
| // after results come back. This class is thread agnostic.
|
| // You can't make more than request at a time.
|
| @@ -62,16 +64,16 @@ class GaiaAuthFetcher : public URLFetcher::Delegate {
|
| // GaiaAuthConsumer will be called on the original thread
|
| // after results come back. This class is thread agnostic.
|
| // You can't make more than one request at a time.
|
| - void StartIssueAuthToken(const std::string& sid,
|
| - const std::string& lsid,
|
| - const char* const service);
|
| + virtual void StartIssueAuthToken(
|
| + const AuthenticationConsumer::AuthenticationResult& credentials,
|
| + const char* const service);
|
|
|
| // Start a request to get a particular key from user info.
|
| // GaiaAuthConsumer will be called back on the same thread when
|
| // results come back.
|
| // You can't make more than one request at a time.
|
| - void StartGetUserInfo(const std::string& lsid,
|
| - const std::string& info_key);
|
| + virtual void StartGetUserInfo(const std::string& lsid,
|
| + const std::string& info_key);
|
|
|
| // Implementation of URLFetcher::Delegate
|
| virtual void OnURLFetchComplete(const URLFetcher* source,
|
| @@ -81,12 +83,6 @@ class GaiaAuthFetcher : public URLFetcher::Delegate {
|
| const ResponseCookies& cookies,
|
| const std::string& data);
|
|
|
| - // StartClientLogin been called && results not back yet?
|
| - bool HasPendingFetch();
|
| -
|
| - // Stop any URL fetches in progress.
|
| - void CancelRequest();
|
| -
|
| private:
|
| // ClientLogin body constants that don't change
|
| static const char kCookiePersistence[];
|
| @@ -114,6 +110,11 @@ class GaiaAuthFetcher : public URLFetcher::Delegate {
|
| static const char kCaptchaTokenParam[];
|
| static const char kCaptchaUrlPrefix[];
|
|
|
| + // Process the results of a Authentication fetch.
|
| + virtual void OnAuthenticationFetched(const std::string& data,
|
| + const net::URLRequestStatus& status,
|
| + int response_code);
|
| +
|
| // Process the results of a ClientLogin fetch.
|
| void OnClientLoginFetched(const std::string& data,
|
| const net::URLRequestStatus& status,
|
| @@ -123,6 +124,10 @@ class GaiaAuthFetcher : public URLFetcher::Delegate {
|
| const net::URLRequestStatus& status,
|
| int response_code);
|
|
|
| + void OnIssueTokenFetched(const std::string& data,
|
| + const net::URLRequestStatus& status,
|
| + int response_code);
|
| +
|
| void OnGetUserInfoFetched(const std::string& data,
|
| const net::URLRequestStatus& status,
|
| int response_code);
|
| @@ -160,9 +165,9 @@ class GaiaAuthFetcher : public URLFetcher::Delegate {
|
| HostedAccountsSetting allow_hosted_accounts);
|
| // Supply the sid / lsid returned from ClientLogin in order to
|
| // request a long lived auth token for a service.
|
| - static std::string MakeIssueAuthTokenBody(const std::string& sid,
|
| - const std::string& lsid,
|
| - const char* const service);
|
| + static std::string MakeIssueAuthTokenBody(
|
| + const AuthenticationConsumer::AuthenticationResult& credentials,
|
| + const char* const service);
|
| // Supply the lsid returned from ClientLogin in order to fetch
|
| // user information.
|
| static std::string MakeGetUserInfoBody(const std::string& lsid);
|
| @@ -172,12 +177,7 @@ class GaiaAuthFetcher : public URLFetcher::Delegate {
|
| const std::string& body,
|
| const GURL& gaia_gurl_,
|
| URLFetcher::Delegate* delegate);
|
| -
|
| -
|
| // These fields are common to GaiaAuthFetcher, same every request
|
| - GaiaAuthConsumer* const consumer_;
|
| - net::URLRequestContextGetter* const getter_;
|
| - std::string source_;
|
| const GURL client_login_gurl_;
|
| const GURL issue_auth_token_gurl_;
|
| const GURL get_user_info_gurl_;
|
| @@ -187,7 +187,6 @@ class GaiaAuthFetcher : public URLFetcher::Delegate {
|
| std::string request_body_;
|
| std::string requested_service_; // Currently tracked for IssueAuthToken only
|
| std::string requested_info_key_; // Currently tracked for GetUserInfo only
|
| - bool fetch_pending_;
|
|
|
| friend class GaiaAuthFetcherTest;
|
| FRIEND_TEST_ALL_PREFIXES(GaiaAuthFetcherTest, CaptchaParse);
|
|
|