| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 std::string client_secret; | 53 std::string client_secret; |
| 54 ScopeSet scopes; | 54 ScopeSet scopes; |
| 55 base::WeakPtr<RequestImpl> request; | 55 base::WeakPtr<RequestImpl> request; |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 FakeProfileOAuth2TokenService(); | 58 FakeProfileOAuth2TokenService(); |
| 59 virtual ~FakeProfileOAuth2TokenService(); | 59 virtual ~FakeProfileOAuth2TokenService(); |
| 60 | 60 |
| 61 // Overriden to make sure it works on Android. | 61 // Overriden to make sure it works on Android. |
| 62 virtual bool RefreshTokenIsAvailable( | 62 virtual bool RefreshTokenIsAvailable( |
| 63 const std::string& account_id) const OVERRIDE; | 63 const std::string& account_id) const override; |
| 64 | 64 |
| 65 // Overriden to make sure it works on iOS. | 65 // Overriden to make sure it works on iOS. |
| 66 virtual void LoadCredentials(const std::string& primary_account_id) OVERRIDE; | 66 virtual void LoadCredentials(const std::string& primary_account_id) override; |
| 67 | 67 |
| 68 virtual std::vector<std::string> GetAccounts() OVERRIDE; | 68 virtual std::vector<std::string> GetAccounts() override; |
| 69 | 69 |
| 70 // Overriden to make sure it works on Android. Simply calls | 70 // Overriden to make sure it works on Android. Simply calls |
| 71 // IssueRefreshToken(). | 71 // IssueRefreshToken(). |
| 72 virtual void UpdateCredentials(const std::string& account_id, | 72 virtual void UpdateCredentials(const std::string& account_id, |
| 73 const std::string& refresh_token) OVERRIDE; | 73 const std::string& refresh_token) override; |
| 74 | 74 |
| 75 // Sets the current refresh token. If |token| is non-empty, this will invoke | 75 // Sets the current refresh token. If |token| is non-empty, this will invoke |
| 76 // OnRefreshTokenAvailable() on all Observers, otherwise this will invoke | 76 // OnRefreshTokenAvailable() on all Observers, otherwise this will invoke |
| 77 // OnRefreshTokenRevoked(). | 77 // OnRefreshTokenRevoked(). |
| 78 void IssueRefreshToken(const std::string& token); | 78 void IssueRefreshToken(const std::string& token); |
| 79 | 79 |
| 80 // TODO(fgorski,rogerta): Merge with UpdateCredentials when this class fully | 80 // TODO(fgorski,rogerta): Merge with UpdateCredentials when this class fully |
| 81 // supports multiple accounts. | 81 // supports multiple accounts. |
| 82 void IssueRefreshTokenForUser(const std::string& account_id, | 82 void IssueRefreshTokenForUser(const std::string& account_id, |
| 83 const std::string& token); | 83 const std::string& token); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 114 auto_post_fetch_response_on_message_loop_ = auto_post_response; | 114 auto_post_fetch_response_on_message_loop_ = auto_post_response; |
| 115 } | 115 } |
| 116 | 116 |
| 117 protected: | 117 protected: |
| 118 // OAuth2TokenService overrides. | 118 // OAuth2TokenService overrides. |
| 119 virtual void FetchOAuth2Token(RequestImpl* request, | 119 virtual void FetchOAuth2Token(RequestImpl* request, |
| 120 const std::string& account_id, | 120 const std::string& account_id, |
| 121 net::URLRequestContextGetter* getter, | 121 net::URLRequestContextGetter* getter, |
| 122 const std::string& client_id, | 122 const std::string& client_id, |
| 123 const std::string& client_secret, | 123 const std::string& client_secret, |
| 124 const ScopeSet& scopes) OVERRIDE; | 124 const ScopeSet& scopes) override; |
| 125 | 125 |
| 126 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( | 126 virtual OAuth2AccessTokenFetcher* CreateAccessTokenFetcher( |
| 127 const std::string& account_id, | 127 const std::string& account_id, |
| 128 net::URLRequestContextGetter* getter, | 128 net::URLRequestContextGetter* getter, |
| 129 OAuth2AccessTokenConsumer* consumer) OVERRIDE; | 129 OAuth2AccessTokenConsumer* consumer) override; |
| 130 | 130 |
| 131 virtual void InvalidateOAuth2Token(const std::string& account_id, | 131 virtual void InvalidateOAuth2Token(const std::string& account_id, |
| 132 const std::string& client_id, | 132 const std::string& client_id, |
| 133 const ScopeSet& scopes, | 133 const ScopeSet& scopes, |
| 134 const std::string& access_token) OVERRIDE; | 134 const std::string& access_token) override; |
| 135 | 135 |
| 136 virtual net::URLRequestContextGetter* GetRequestContext() OVERRIDE; | 136 virtual net::URLRequestContextGetter* GetRequestContext() override; |
| 137 | 137 |
| 138 private: | 138 private: |
| 139 // Helper function to complete pending requests - if |all_scopes| is true, | 139 // Helper function to complete pending requests - if |all_scopes| is true, |
| 140 // then all pending requests are completed, otherwise, only those requests | 140 // then all pending requests are completed, otherwise, only those requests |
| 141 // matching |scopes| are completed. If |account_id| is empty, then pending | 141 // matching |scopes| are completed. If |account_id| is empty, then pending |
| 142 // requests for all accounts are completed, otherwise only requests for the | 142 // requests for all accounts are completed, otherwise only requests for the |
| 143 // given account. | 143 // given account. |
| 144 void CompleteRequests(const std::string& account_id, | 144 void CompleteRequests(const std::string& account_id, |
| 145 bool all_scopes, | 145 bool all_scopes, |
| 146 const ScopeSet& scopes, | 146 const ScopeSet& scopes, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 159 // |FetchOAuth2Token| on the current run loop. There is no need to call | 159 // |FetchOAuth2Token| on the current run loop. There is no need to call |
| 160 // |IssueTokenForScope| in this case. | 160 // |IssueTokenForScope| in this case. |
| 161 bool auto_post_fetch_response_on_message_loop_; | 161 bool auto_post_fetch_response_on_message_loop_; |
| 162 | 162 |
| 163 base::WeakPtrFactory<FakeProfileOAuth2TokenService> weak_ptr_factory_; | 163 base::WeakPtrFactory<FakeProfileOAuth2TokenService> weak_ptr_factory_; |
| 164 | 164 |
| 165 DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenService); | 165 DISALLOW_COPY_AND_ASSIGN(FakeProfileOAuth2TokenService); |
| 166 }; | 166 }; |
| 167 | 167 |
| 168 #endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ | 168 #endif // CHROME_BROWSER_SIGNIN_FAKE_PROFILE_OAUTH2_TOKEN_SERVICE_H_ |
| OLD | NEW |