OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ | 5 #ifndef GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ |
6 #define GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ | 6 #define GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ |
7 | 7 |
8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
9 #include "google_apis/gaia/gaia_auth_util.h" | 9 #include "google_apis/gaia/gaia_auth_util.h" |
10 #include "google_apis/gaia/oauth2_token_service.h" | 10 #include "google_apis/gaia/oauth2_token_service.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 public: | 22 public: |
23 OAuth2TokenServiceDelegate(); | 23 OAuth2TokenServiceDelegate(); |
24 virtual ~OAuth2TokenServiceDelegate(); | 24 virtual ~OAuth2TokenServiceDelegate(); |
25 | 25 |
26 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( | 26 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( |
27 const std::string& account_id, | 27 const std::string& account_id, |
28 net::URLRequestContextGetter* getter, | 28 net::URLRequestContextGetter* getter, |
29 OAuth2AccessTokenConsumer* consumer) = 0; | 29 OAuth2AccessTokenConsumer* consumer) = 0; |
30 | 30 |
31 virtual bool RefreshTokenIsAvailable(const std::string& account_id) const = 0; | 31 virtual bool RefreshTokenIsAvailable(const std::string& account_id) const = 0; |
| 32 virtual bool RefreshTokenHasError(const std::string& account_id) const; |
32 virtual void UpdateAuthError(const std::string& account_id, | 33 virtual void UpdateAuthError(const std::string& account_id, |
33 const GoogleServiceAuthError& error){}; | 34 const GoogleServiceAuthError& error) {} |
34 | 35 |
35 virtual std::vector<std::string> GetAccounts(); | 36 virtual std::vector<std::string> GetAccounts(); |
36 virtual void RevokeAllCredentials(){}; | 37 virtual void RevokeAllCredentials(){}; |
37 | 38 |
38 virtual void InvalidateAccessToken(const std::string& account_id, | 39 virtual void InvalidateAccessToken(const std::string& account_id, |
39 const std::string& client_id, | 40 const std::string& client_id, |
40 const std::set<std::string>& scopes, | 41 const std::set<std::string>& scopes, |
41 const std::string& access_token) {} | 42 const std::string& access_token) {} |
42 | 43 |
43 virtual void Shutdown() {} | 44 virtual void Shutdown() {} |
(...skipping 19 matching lines...) Expand all Loading... |
63 class ScopedBatchChange { | 64 class ScopedBatchChange { |
64 public: | 65 public: |
65 explicit ScopedBatchChange(OAuth2TokenServiceDelegate* delegate); | 66 explicit ScopedBatchChange(OAuth2TokenServiceDelegate* delegate); |
66 ~ScopedBatchChange(); | 67 ~ScopedBatchChange(); |
67 | 68 |
68 private: | 69 private: |
69 OAuth2TokenServiceDelegate* delegate_; // Weak. | 70 OAuth2TokenServiceDelegate* delegate_; // Weak. |
70 DISALLOW_COPY_AND_ASSIGN(ScopedBatchChange); | 71 DISALLOW_COPY_AND_ASSIGN(ScopedBatchChange); |
71 }; | 72 }; |
72 | 73 |
| 74 // This function is called by derived classes to help implement |
| 75 // RefreshTokenHasError(). It centralizes the code for determining if |
| 76 // |error| is worthy of being reported as an error for purposes of |
| 77 // RefreshTokenHasError(). |
| 78 static bool IsError(const GoogleServiceAuthError& error); |
| 79 |
73 private: | 80 private: |
74 // List of observers to notify when refresh token availability changes. | 81 // List of observers to notify when refresh token availability changes. |
75 // Makes sure list is empty on destruction. | 82 // Makes sure list is empty on destruction. |
76 base::ObserverList<OAuth2TokenService::Observer, true> observer_list_; | 83 base::ObserverList<OAuth2TokenService::Observer, true> observer_list_; |
77 | 84 |
78 void StartBatchChanges(); | 85 void StartBatchChanges(); |
79 void EndBatchChanges(); | 86 void EndBatchChanges(); |
80 | 87 |
81 // The depth of batch changes. | 88 // The depth of batch changes. |
82 int batch_change_depth_; | 89 int batch_change_depth_; |
83 | 90 |
84 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceDelegate); | 91 DISALLOW_COPY_AND_ASSIGN(OAuth2TokenServiceDelegate); |
85 }; | 92 }; |
86 | 93 |
87 #endif // GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ | 94 #endif // GOOGLE_APIS_GAIA_OAUTH2_TOKEN_SERVICE_DELEGATE_H_ |
OLD | NEW |