Index: chrome/browser/chromeos/settings/device_oauth2_token_service.h |
diff --git a/chrome/browser/chromeos/settings/device_oauth2_token_service.h b/chrome/browser/chromeos/settings/device_oauth2_token_service.h |
index 4941c0279dcdc79bfffde0d230cdb730ad1d42be..1e1735dca8049b4e1cb332aff6899fde4547c563 100644 |
--- a/chrome/browser/chromeos/settings/device_oauth2_token_service.h |
+++ b/chrome/browser/chromeos/settings/device_oauth2_token_service.h |
@@ -18,6 +18,7 @@ |
#include "chrome/browser/chromeos/settings/cros_settings.h" |
#include "google_apis/gaia/gaia_oauth_client.h" |
#include "google_apis/gaia/oauth2_token_service.h" |
+#include "google_apis/gaia/oauth2_token_service_delegate.h" |
#include "net/url_request/url_request_context_getter.h" |
namespace gaia { |
@@ -46,6 +47,30 @@ namespace chromeos { |
class DeviceOAuth2TokenService : public OAuth2TokenService, |
public gaia::GaiaOAuthClient::Delegate { |
public: |
+ class DeviceOAuth2TokenServiceDelegate : public OAuth2TokenServiceDelegate { |
xiyuan
2015/06/26 18:15:53
nit: We can probably move DeviceOAuth2TokenService
|
+ public: |
+ friend class DeviceOAuth2TokenService; |
xiyuan
2015/06/26 18:15:53
Do we need this? Think inner class is friend of ou
|
+ DeviceOAuth2TokenServiceDelegate( |
+ DeviceOAuth2TokenService* device_token_service); |
+ ~DeviceOAuth2TokenServiceDelegate() override; |
+ |
+ OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( |
xiyuan
2015/06/26 18:15:53
nit: // OAuth2TokenServiceDelegate
|
+ const std::string& account_id, |
+ net::URLRequestContextGetter* getter, |
+ OAuth2AccessTokenConsumer* consumer) override; |
+ |
+ bool RefreshTokenIsAvailable(const std::string& account_id) const override; |
+ void UpdateAuthError(const std::string& account_id, |
+ const GoogleServiceAuthError& error) override; |
+ |
+ std::vector<std::string> GetAccounts() override; |
+ void RevokeAllCredentials() override; |
+ net::URLRequestContextGetter* GetRequestContext() const override; |
+ |
+ private: |
+ DeviceOAuth2TokenService* device_token_service_; |
xiyuan
2015/06/26 18:15:53
nit: DISALLOW_COPY_AND_ASSIGN(...);
|
+ }; |
+ |
typedef base::Callback<void(bool)> StatusCallback; |
// Persist the given refresh token on the device. Overwrites any previous |
@@ -56,9 +81,6 @@ class DeviceOAuth2TokenService : public OAuth2TokenService, |
static void RegisterPrefs(PrefRegistrySimple* registry); |
- // Implementation of OAuth2TokenService. |
- bool RefreshTokenIsAvailable(const std::string& account_id) const override; |
- |
// Pull the robot account ID from device policy. |
virtual std::string GetRobotAccountId() const; |
@@ -71,18 +93,12 @@ class DeviceOAuth2TokenService : public OAuth2TokenService, |
void OnNetworkError(int response_code) override; |
protected: |
- // Implementation of OAuth2TokenService. |
- net::URLRequestContextGetter* GetRequestContext() override; |
void FetchOAuth2Token(RequestImpl* request, |
const std::string& account_id, |
net::URLRequestContextGetter* getter, |
const std::string& client_id, |
const std::string& client_secret, |
const ScopeSet& scopes) override; |
- OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( |
- const std::string& account_id, |
- net::URLRequestContextGetter* getter, |
- OAuth2AccessTokenConsumer* consumer) override; |
private: |
struct PendingRequest; |
@@ -105,6 +121,21 @@ class DeviceOAuth2TokenService : public OAuth2TokenService, |
STATE_TOKEN_VALID, |
}; |
+ // Concrete Implementation of GetRequestContext for |
+ // DeviceOAuth2TokenServiceDelegate. |
+ net::URLRequestContextGetter* GetRequestContextImpl(); |
+ |
+ // Concrete Implementation of RefreshTokenIsAvailableImpl for |
+ // DeviceOAuth2TokenServiceDelegate. |
+ bool RefreshTokenIsAvailableImpl(const std::string& account_id) const; |
+ |
+ // Concrete Implementation of CreateAccessTokenFetcher for |
+ // DeviceOAuth2TokenServiceDelegate. |
+ OAuth2AccessTokenFetcher* CreateAccessTokenFetcherImpl( |
+ const std::string& account_id, |
+ net::URLRequestContextGetter* getter, |
+ OAuth2AccessTokenConsumer* consumer); |
+ |
// Invoked by CrosSettings when the robot account ID becomes available. |
void OnServiceAccountIdentityChanged(); |
@@ -145,6 +176,8 @@ class DeviceOAuth2TokenService : public OAuth2TokenService, |
scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; |
PrefService* local_state_; |
+ DeviceOAuth2TokenServiceDelegate* device_oauth2_token_service_delegate_; |
+ |
// Current operational state. |
State state_; |