| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 5 #ifndef CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| 6 #define CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 6 #define CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 base::WeakPtr<RequestImpl> request; | 59 base::WeakPtr<RequestImpl> request; |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 FakeProfileOAuth2TokenService(); | 62 FakeProfileOAuth2TokenService(); |
| 63 virtual ~FakeProfileOAuth2TokenService(); | 63 virtual ~FakeProfileOAuth2TokenService(); |
| 64 | 64 |
| 65 // Overriden to make sure it works on Android. | 65 // Overriden to make sure it works on Android. |
| 66 virtual bool RefreshTokenIsAvailable( | 66 virtual bool RefreshTokenIsAvailable( |
| 67 const std::string& account_id) OVERRIDE; | 67 const std::string& account_id) OVERRIDE; |
| 68 | 68 |
| 69 // Overriden to make sure it works on iOS. |
| 70 virtual void LoadCredentials(const std::string& primary_account_id) OVERRIDE; |
| 71 |
| 69 virtual std::vector<std::string> GetAccounts() OVERRIDE; | 72 virtual std::vector<std::string> GetAccounts() OVERRIDE; |
| 70 | 73 |
| 71 // Overriden to make sure it works on Android. Simply calls | 74 // Overriden to make sure it works on Android. Simply calls |
| 72 // IssueRefreshToken(). | 75 // IssueRefreshToken(). |
| 73 virtual void UpdateCredentials(const std::string& account_id, | 76 virtual void UpdateCredentials(const std::string& account_id, |
| 74 const std::string& refresh_token) OVERRIDE; | 77 const std::string& refresh_token) OVERRIDE; |
| 75 | 78 |
| 76 // Sets the current refresh token. If |token| is non-empty, this will invoke | 79 // Sets the current refresh token. If |token| is non-empty, this will invoke |
| 77 // OnRefreshTokenAvailable() on all Observers, otherwise this will invoke | 80 // OnRefreshTokenAvailable() on all Observers, otherwise this will invoke |
| 78 // OnRefreshTokenRevoked(). | 81 // OnRefreshTokenRevoked(). |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 const std::string& client_secret, | 131 const std::string& client_secret, |
| 129 const ScopeSet& scopes) OVERRIDE; | 132 const ScopeSet& scopes) OVERRIDE; |
| 130 | 133 |
| 131 virtual void InvalidateOAuth2Token(const std::string& account_id, | 134 virtual void InvalidateOAuth2Token(const std::string& account_id, |
| 132 const std::string& client_id, | 135 const std::string& client_id, |
| 133 const ScopeSet& scopes, | 136 const ScopeSet& scopes, |
| 134 const std::string& access_token) OVERRIDE; | 137 const std::string& access_token) OVERRIDE; |
| 135 | 138 |
| 136 virtual std::string GetRefreshToken(const std::string& account_id) OVERRIDE; | 139 virtual std::string GetRefreshToken(const std::string& account_id) OVERRIDE; |
| 137 | 140 |
| 141 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; |
| 142 |
| 138 private: | 143 private: |
| 139 // Helper function to complete pending requests - if |all_scopes| is true, | 144 // Helper function to complete pending requests - if |all_scopes| is true, |
| 140 // then all pending requests are completed, otherwise, only those requests | 145 // then all pending requests are completed, otherwise, only those requests |
| 141 // matching |scopes| are completed. If |account_id| is empty, then pending | 146 // matching |scopes| are completed. If |account_id| is empty, then pending |
| 142 // requests for all accounts are completed, otherwise only requests for the | 147 // requests for all accounts are completed, otherwise only requests for the |
| 143 // given account. | 148 // given account. |
| 144 void CompleteRequests(const std::string& account_id, | 149 void CompleteRequests(const std::string& account_id, |
| 145 bool all_scopes, | 150 bool all_scopes, |
| 146 const ScopeSet& scopes, | 151 const ScopeSet& scopes, |
| 147 const GoogleServiceAuthError& error, | 152 const GoogleServiceAuthError& error, |
| 148 const std::string& access_token, | 153 const std::string& access_token, |
| 149 const base::Time& expiration); | 154 const base::Time& expiration); |
| 150 | 155 |
| 151 std::vector<PendingRequest> pending_requests_; | 156 std::vector<PendingRequest> pending_requests_; |
| 152 | 157 |
| 153 // Maps account ids to their refresh token strings. | 158 // Maps account ids to their refresh token strings. |
| 154 std::map<std::string, std::string> refresh_tokens_; | 159 std::map<std::string, std::string> refresh_tokens_; |
| 155 | 160 |
| 156 // If true, then this fake service will post responses to | 161 // If true, then this fake service will post responses to |
| 157 // |FetchOAuth2Token| on the current run loop. There is no need to call | 162 // |FetchOAuth2Token| on the current run loop. There is no need to call |
| 158 // |IssueTokenForScope| in this case. | 163 // |IssueTokenForScope| in this case. |
| 159 bool auto_post_fetch_response_on_message_loop_; | 164 bool auto_post_fetch_response_on_message_loop_; |
| 160 | 165 |
| 161 DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenService); | 166 DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenService); |
| 162 }; | 167 }; |
| 163 | 168 |
| 164 #endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 169 #endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| OLD | NEW |