Commit dffa06ff authored by rogerta@chromium.org's avatar rogerta@chromium.org

Remove unused code (gaia_oauth_fetcher).

The oauth2 apis are handled by google_apis\gaia\gaia_oauth_client.

BUG=None

Review URL: https://codereview.chromium.org/139153011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245632 0039d316-1c4b-4281-b951-d872f2087c98
parent 26a809b8
rickcam@chromium.org
sanjeevr@chromium.org
tim@chromium.org
zelidrag@chromium.org
// 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_BROWSER_NET_GAIA_GAIA_OAUTH_CONSUMER_H_
#define CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_CONSUMER_H_
#include <string>
class GoogleServiceAuthError;
// An interface that defines the callbacks for objects to which
// GaiaOAuthFetcher can return data.
class GaiaOAuthConsumer {
public:
virtual ~GaiaOAuthConsumer() {}
virtual void OnGetOAuthTokenSuccess(const std::string& oauth_token) {}
virtual void OnGetOAuthTokenFailure(const GoogleServiceAuthError& error) {}
virtual void OnOAuthGetAccessTokenSuccess(const std::string& token,
const std::string& secret) {}
virtual void OnOAuthGetAccessTokenFailure(
const GoogleServiceAuthError& error) {}
virtual void OnOAuthWrapBridgeSuccess(const std::string& service_scope,
const std::string& token,
const std::string& expires_in) {}
virtual void OnOAuthWrapBridgeFailure(const std::string& service_scope,
const GoogleServiceAuthError& error) {}
virtual void OnUserInfoSuccess(const std::string& email) {}
virtual void OnUserInfoFailure(const GoogleServiceAuthError& error) {}
virtual void OnOAuthLoginSuccess(const std::string& sid,
const std::string& lsid,
const std::string& auth) {}
virtual void OnOAuthLoginFailure(const GoogleServiceAuthError& error) {}
virtual void OnOAuthRevokeTokenSuccess() {}
virtual void OnOAuthRevokeTokenFailure(const GoogleServiceAuthError& error) {}
};
#endif // CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_CONSUMER_H_
This diff is collapsed.
// Copyright (c) 2012 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_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_
#define CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_
#include <string>
#include <vector>
#include "base/memory/scoped_ptr.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "net/url_request/url_fetcher_delegate.h"
#include "url/gurl.h"
class GaiaOAuthConsumer;
namespace net {
class URLFetcher;
class URLRequestContextGetter;
class URLRequestStatus;
typedef std::vector<std::string> ResponseCookies;
}
// Authenticate a user using Gaia's OAuth1 and OAuth2 support.
//
// Users of this class typically desire an OAuth2 Access token scoped for a
// specific service. This will typically start with either an interactive
// login, using StartOAuthLogin, or with a long-lived OAuth1 all-scope
// token obtained through a previous login or other means, using
// StartOAuthGetAccessToken. In fact, one can start with any of these
// routines:
// StartOAuthLogin()
// StartGetOAuthTokenRequest()
// StartOAuthGetAccessToken()
// StartOAuthWrapBridge()
// StartUserInfo()
// with the expectation that each of these calls the next Start* routine in
// the sequence, except for StartUserInfo as it's the last one.
//
// This class can handle one request at a time, and all calls through an
// instance should be serialized.
class GaiaOAuthFetcher : public net::URLFetcherDelegate {
public:
// Defines steps of OAuth process performed by this class.
typedef enum {
OAUTH1_LOGIN,
OAUTH1_REQUEST_TOKEN,
OAUTH1_ALL_ACCESS_TOKEN,
OAUTH2_SERVICE_ACCESS_TOKEN,
USER_INFO,
OAUTH2_REVOKE_TOKEN,
} RequestType;
GaiaOAuthFetcher(GaiaOAuthConsumer* consumer,
net::URLRequestContextGetter* getter,
const std::string& service_scope);
virtual ~GaiaOAuthFetcher();
// Sets the mask of which OAuth fetch steps should be automatically kicked
// of upon successful completition of the previous steps. By default,
// this class will chain all steps in OAuth proccess.
void SetAutoFetchLimit(RequestType limit) { auto_fetch_limit_ = limit; }
// Non-UI version of the method above. Initiates Gaia OAuth request token
// retrieval.
void StartGetOAuthTokenRequest();
// Performs account login based on OAuth1 access token and its secret.
void StartOAuthLogin(const char* source,
const char* service,
const std::string& oauth1_access_token,
const std::string& oauth1_access_token_secret);
// Obtains an OAuth1 access token and secret
//
// oauth1_request_token is from GetOAuthToken's result.
virtual void StartOAuthGetAccessToken(
const std::string& oauth1_request_token);
// Obtains an OAuth2 access token using Gaia's OAuth1-to-OAuth2 bridge.
//
// oauth1_access_token and oauth1_access_token_secret are from
// OAuthGetAccessToken's result.
//
// wrap_token_duration is typically one hour,
// which is also the max -- you can only decrease it.
//
// service_scope will be used as a service name. For example, Chromium Sync
// uses https://www.googleapis.com/auth/chromesync for its OAuth2 service
// scope.
virtual void StartOAuthWrapBridge(
const std::string& oauth1_access_token,
const std::string& oauth1_access_token_secret,
const std::string& wrap_token_duration,
const std::string& service_scope);
// Obtains user information related to an OAuth2 access token
//
// oauth2_access_token is from OAuthWrapBridge's result.
virtual void StartUserInfo(const std::string& oauth2_access_token);
// Starts a request for revoking the given OAuth access token (as requested by
// StartOAuthGetAccessToken).
virtual void StartOAuthRevokeAccessToken(const std::string& token,
const std::string& secret);
// Starts a request for revoking the given OAuth Bearer token (as requested by
// StartOAuthWrapBridge).
virtual void StartOAuthRevokeWrapToken(const std::string& token);
// Implementation of net::URLFetcherDelegate
virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
// StartGetOAuthToken (or other Start* routine) been called, but results
// are not back yet.
virtual bool HasPendingFetch() const;
// Stop any URL fetches in progress.
virtual void CancelRequest();
protected:
// Stores the type of the current request in flight.
RequestType request_type_;
private:
// Process the results of a GetOAuthToken fetch for non-UI driven path.
virtual void OnGetOAuthTokenUrlFetched(const net::ResponseCookies& cookies,
const net::URLRequestStatus& status,
int response_code);
// Process the results of a OAuthLogin fetch.
virtual void OnOAuthLoginFetched(const std::string& data,
const net::URLRequestStatus& status,
int response_code);
// Process the results of a OAuthGetAccessToken fetch.
virtual void OnOAuthGetAccessTokenFetched(const std::string& data,
const net::URLRequestStatus& status,
int response_code);
// Process the results of a OAuthWrapBridge fetch.
virtual void OnOAuthWrapBridgeFetched(const std::string& data,
const net::URLRequestStatus& status,
int response_code);
// Process the results of a token revocation fetch.
virtual void OnOAuthRevokeTokenFetched(const std::string& data,
const net::URLRequestStatus& status,
int response_code);
// Process the results of a userinfo fetch.
virtual void OnUserInfoFetched(const std::string& data,
const net::URLRequestStatus& status,
int response_code);
// Tokenize the results of a OAuthLogin fetch.
static void ParseOAuthLoginResponse(const std::string& data,
std::string* sid,
std::string* lsid,
std::string* auth);
// Tokenize the results of a OAuthGetAccessToken fetch.
static void ParseOAuthGetAccessTokenResponse(const std::string& data,
std::string* token,
std::string* secret);
// Tokenize the results of a OAuthWrapBridge fetch.
static void ParseOAuthWrapBridgeResponse(const std::string& data,
std::string* token,
std::string* expires_in);
// Tokenize the results of a userinfo fetch.
static void ParseUserInfoResponse(const std::string& data,
std::string* email);
// From a URLFetcher result, generate an appropriate error.
static GoogleServiceAuthError GenerateAuthError(
const std::string& data,
const net::URLRequestStatus& status,
int response_code);
// Given parameters, create a OAuth v1 request URL.
static GURL MakeGetOAuthTokenUrl(const std::string& oauth1_login_scope,
const std::string& product_name);
// Given parameters, create a OAuthGetAccessToken request body.
static std::string MakeOAuthGetAccessTokenBody(
const std::string& oauth1_request_token);
// Given parameters, create a OAuthLogin request body.
static std::string MakeOAuthLoginBody(
const char* source,
const char* service,
const std::string& oauth1_access_token,
const std::string& oauth1_access_token_secret);
// Given parameters, create a OAuthWrapBridge request body.
static std::string MakeOAuthWrapBridgeBody(
const std::string& oauth1_access_token,
const std::string& oauth1_access_token_secret,
const std::string& wrap_token_duration,
const std::string& oauth2_service_scope);
// Create a fetcher useable for making any Gaia OAuth request.
static net::URLFetcher* CreateGaiaFetcher(
net::URLRequestContextGetter* getter,
const GURL& gaia_gurl_,
const std::string& body,
const std::string& headers,
bool send_cookies,
net::URLFetcherDelegate* delegate);
bool ShouldAutoFetch(RequestType fetch_step);
// These fields are common to GaiaOAuthFetcher, same every request
GaiaOAuthConsumer* const consumer_;
net::URLRequestContextGetter* const getter_;
// While a fetch is going on:
scoped_ptr<net::URLFetcher> fetcher_;
std::string request_body_;
std::string request_headers_;
std::string service_scope_;
bool fetch_pending_;
RequestType auto_fetch_limit_;
DISALLOW_COPY_AND_ASSIGN(GaiaOAuthFetcher);
};
#endif // CHROME_BROWSER_NET_GAIA_GAIA_OAUTH_FETCHER_H_
This diff is collapsed.
...@@ -1253,9 +1253,6 @@ ...@@ -1253,9 +1253,6 @@
'browser/net/evicted_domain_cookie_counter.h', 'browser/net/evicted_domain_cookie_counter.h',
'browser/net/firefox_proxy_settings.cc', 'browser/net/firefox_proxy_settings.cc',
'browser/net/firefox_proxy_settings.h', 'browser/net/firefox_proxy_settings.h',
'browser/net/gaia/gaia_oauth_consumer.h',
'browser/net/gaia/gaia_oauth_fetcher.cc',
'browser/net/gaia/gaia_oauth_fetcher.h',
'browser/net/http_pipelining_compatibility_client.cc', 'browser/net/http_pipelining_compatibility_client.cc',
'browser/net/http_pipelining_compatibility_client.h', 'browser/net/http_pipelining_compatibility_client.h',
'browser/net/http_server_properties_manager.cc', 'browser/net/http_server_properties_manager.cc',
...@@ -2917,9 +2914,6 @@ ...@@ -2917,9 +2914,6 @@
'browser/extensions/api/terminal/terminal_extension_helper.h', 'browser/extensions/api/terminal/terminal_extension_helper.h',
'browser/extensions/api/terminal/terminal_private_api.cc', 'browser/extensions/api/terminal/terminal_private_api.cc',
'browser/extensions/api/terminal/terminal_private_api.h', 'browser/extensions/api/terminal/terminal_private_api.h',
'browser/net/gaia/gaia_oauth_consumer.h',
'browser/net/gaia/gaia_oauth_fetcher.cc',
'browser/net/gaia/gaia_oauth_fetcher.h',
'browser/renderer_host/offline_resource_throttle.cc', 'browser/renderer_host/offline_resource_throttle.cc',
'browser/renderer_host/offline_resource_throttle.h', 'browser/renderer_host/offline_resource_throttle.h',
'browser/renderer_host/pepper/pepper_platform_verification_message_filter.cc', 'browser/renderer_host/pepper/pepper_platform_verification_message_filter.cc',
...@@ -3193,7 +3187,6 @@ ...@@ -3193,7 +3187,6 @@
'browser/sync/sync_global_error.h', 'browser/sync/sync_global_error.h',
'browser/download/download_crx_util.cc', 'browser/download/download_crx_util.cc',
'browser/net/gaia/gaia_oauth_fetcher.cc',
'browser/policy/cloud/user_policy_signin_service.cc', 'browser/policy/cloud/user_policy_signin_service.cc',
'browser/policy/cloud/user_policy_signin_service.h', 'browser/policy/cloud/user_policy_signin_service.h',
'browser/sessions/persistent_tab_restore_service.cc', 'browser/sessions/persistent_tab_restore_service.cc',
......
...@@ -1052,7 +1052,6 @@ ...@@ -1052,7 +1052,6 @@
'browser/net/dns_probe_service_unittest.cc', 'browser/net/dns_probe_service_unittest.cc',
'browser/net/evicted_domain_cookie_counter_unittest.cc', 'browser/net/evicted_domain_cookie_counter_unittest.cc',
'browser/net/firefox_proxy_settings_unittest.cc', 'browser/net/firefox_proxy_settings_unittest.cc',
'browser/net/gaia/gaia_oauth_fetcher_unittest.cc',
'browser/net/http_pipelining_compatibility_client_unittest.cc', 'browser/net/http_pipelining_compatibility_client_unittest.cc',
'browser/net/http_server_properties_manager_unittest.cc', 'browser/net/http_server_properties_manager_unittest.cc',
'browser/net/net_error_tab_helper_unittest.cc', 'browser/net/net_error_tab_helper_unittest.cc',
...@@ -2313,7 +2312,6 @@ ...@@ -2313,7 +2312,6 @@
], ],
'sources!': [ 'sources!': [
'browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api_unittest.cc', 'browser/extensions/api/enterprise_platform_keys_private/enterprise_platform_keys_private_api_unittest.cc',
'browser/net/gaia/gaia_oauth_fetcher_unittest.cc',
'browser/notifications/login_state_notification_blocker_chromeos_unittest.cc', 'browser/notifications/login_state_notification_blocker_chromeos_unittest.cc',
'browser/extensions/api/log_private/syslog_parser_unittest.cc', 'browser/extensions/api/log_private/syslog_parser_unittest.cc',
], ],
...@@ -2542,7 +2540,6 @@ ...@@ -2542,7 +2540,6 @@
'browser/download/download_shelf_unittest.cc', 'browser/download/download_shelf_unittest.cc',
'browser/extensions/extension_message_bubble_controller_unittest.cc', 'browser/extensions/extension_message_bubble_controller_unittest.cc',
'browser/storage_monitor/media_storage_util_unittest.cc', 'browser/storage_monitor/media_storage_util_unittest.cc',
'browser/net/gaia/gaia_oauth_fetcher_unittest.cc',
'browser/policy/policy_path_parser_unittest.cc', 'browser/policy/policy_path_parser_unittest.cc',
'browser/profiles/off_the_record_profile_impl_unittest.cc', 'browser/profiles/off_the_record_profile_impl_unittest.cc',
'browser/profiles/profile_list_desktop_unittest.cc', 'browser/profiles/profile_list_desktop_unittest.cc',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment