OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_SIGNIN_FAKE_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_FAKE_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ |
| 7 |
| 8 #include "google_apis/gaia/oauth2_token_service_delegate.h" |
| 9 #include "net/url_request/url_request_context_getter.h" |
| 10 |
| 11 class FakeOAuth2TokenServiceDelegate : public OAuth2TokenServiceDelegate { |
| 12 public: |
| 13 FakeOAuth2TokenServiceDelegate(net::URLRequestContextGetter* request_context); |
| 14 ~FakeOAuth2TokenServiceDelegate() override; |
| 15 |
| 16 OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( |
| 17 const std::string& account_id, |
| 18 net::URLRequestContextGetter* getter, |
| 19 OAuth2AccessTokenConsumer* consumer) override; |
| 20 |
| 21 // Overriden to make sure it works on Android. |
| 22 bool RefreshTokenIsAvailable(const std::string& account_id) const override; |
| 23 void UpdateAuthError(const std::string& account_id, |
| 24 const GoogleServiceAuthError& error) override; |
| 25 |
| 26 std::vector<std::string> GetAccounts() override; |
| 27 void RevokeAllCredentials() override; |
| 28 |
| 29 void LoadCredentials(const std::string& primary_account_id) override; |
| 30 |
| 31 void UpdateCredentials(const std::string& account_id, |
| 32 const std::string& refresh_token) override; |
| 33 void RevokeCredentials(const std::string& account_id) override; |
| 34 |
| 35 net::URLRequestContextGetter* GetRequestContext() const override; |
| 36 |
| 37 void set_request_context(net::URLRequestContextGetter* request_context) { |
| 38 request_context_ = request_context; |
| 39 } |
| 40 |
| 41 private: |
| 42 void IssueRefreshTokenForUser(const std::string& account_id, |
| 43 const std::string& token); |
| 44 std::string GetRefreshToken(const std::string& account_id) const; |
| 45 |
| 46 // Maps account ids to their refresh token strings. |
| 47 std::map<std::string, std::string> refresh_tokens_; |
| 48 |
| 49 scoped_refptr<net::URLRequestContextGetter> request_context_; |
| 50 |
| 51 DISALLOW_COPY_AND_ASSIGN(FakeOAuth2TokenServiceDelegate); |
| 52 }; |
| 53 #endif |
OLD | NEW |