Chromium Code Reviews| 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 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" | 5 #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 | 9 |
| 10 FakeProfileOAuth2TokenService::PendingRequest::PendingRequest() { | 10 FakeProfileOAuth2TokenService::PendingRequest::PendingRequest() { |
| 11 } | 11 } |
| 12 | 12 |
| 13 FakeProfileOAuth2TokenService::PendingRequest::~PendingRequest() { | 13 FakeProfileOAuth2TokenService::PendingRequest::~PendingRequest() { |
| 14 } | 14 } |
| 15 | 15 |
| 16 FakeProfileOAuth2TokenService::FakeProfileOAuth2TokenService() | 16 FakeProfileOAuth2TokenService::FakeProfileOAuth2TokenService() |
| 17 : auto_post_fetch_response_on_message_loop_(false), | 17 : ProfileOAuth2TokenService(NULL), |
| 18 auto_post_fetch_response_on_message_loop_(false), | |
| 18 weak_ptr_factory_(this) { | 19 weak_ptr_factory_(this) { |
| 19 } | 20 } |
| 20 | 21 |
| 21 FakeProfileOAuth2TokenService::~FakeProfileOAuth2TokenService() { | 22 FakeProfileOAuth2TokenService::~FakeProfileOAuth2TokenService() { |
| 22 } | 23 } |
| 23 | 24 |
| 24 bool FakeProfileOAuth2TokenService::RefreshTokenIsAvailable( | 25 bool FakeProfileOAuth2TokenService::RefreshTokenIsAvailable( |
| 25 const std::string& account_id) const { | 26 const std::string& account_id) const { |
| 26 return !GetRefreshToken(account_id).empty(); | 27 return !GetRefreshToken(account_id).empty(); |
| 27 } | 28 } |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 48 } | 49 } |
| 49 | 50 |
| 50 void FakeProfileOAuth2TokenService::IssueRefreshToken( | 51 void FakeProfileOAuth2TokenService::IssueRefreshToken( |
| 51 const std::string& token) { | 52 const std::string& token) { |
| 52 IssueRefreshTokenForUser("account_id", token); | 53 IssueRefreshTokenForUser("account_id", token); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void FakeProfileOAuth2TokenService::IssueRefreshTokenForUser( | 56 void FakeProfileOAuth2TokenService::IssueRefreshTokenForUser( |
| 56 const std::string& account_id, | 57 const std::string& account_id, |
| 57 const std::string& token) { | 58 const std::string& token) { |
| 58 ScopedBatchChange batch(this); | 59 // ScopedBatchChange batch(this); |
| 59 if (token.empty()) { | 60 if (token.empty()) { |
| 60 refresh_tokens_.erase(account_id); | 61 refresh_tokens_.erase(account_id); |
| 61 FireRefreshTokenRevoked(account_id); | 62 // FireRefreshTokenRevoked(account_id); |
| 62 } else { | 63 } else { |
| 63 refresh_tokens_[account_id] = token; | 64 refresh_tokens_[account_id] = token; |
| 64 FireRefreshTokenAvailable(account_id); | 65 // FireRefreshTokenAvailable(account_id); |
| 65 // TODO(atwilson): Maybe we should also call FireRefreshTokensLoaded() here? | 66 // TODO(atwilson): Maybe we should also call FireRefreshTokensLoaded() here? |
| 66 } | 67 } |
| 67 } | 68 } |
| 68 | 69 |
| 69 void FakeProfileOAuth2TokenService::IssueAllRefreshTokensLoaded() { | 70 void FakeProfileOAuth2TokenService::IssueAllRefreshTokensLoaded() { |
| 70 FireRefreshTokensLoaded(); | 71 // FireRefreshTokensLoaded(); |
|
Roger Tawa OOO till Jul 10th
2015/05/24 21:13:18
Probably don't need this class anymore, once we ha
gogerald1
2015/05/25 21:10:57
Probably, need more investigation after we lock do
| |
| 71 } | 72 } |
| 72 | 73 |
| 73 void FakeProfileOAuth2TokenService::IssueAllTokensForAccount( | 74 void FakeProfileOAuth2TokenService::IssueAllTokensForAccount( |
| 74 const std::string& account_id, | 75 const std::string& account_id, |
| 75 const std::string& access_token, | 76 const std::string& access_token, |
| 76 const base::Time& expiration) { | 77 const base::Time& expiration) { |
| 77 CompleteRequests(account_id, | 78 CompleteRequests(account_id, |
| 78 true, | 79 true, |
| 79 ScopeSet(), | 80 ScopeSet(), |
| 80 GoogleServiceAuthError::AuthErrorNone(), | 81 GoogleServiceAuthError::AuthErrorNone(), |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 208 return NULL; | 209 return NULL; |
| 209 } | 210 } |
| 210 | 211 |
| 211 void FakeProfileOAuth2TokenService::InvalidateOAuth2Token( | 212 void FakeProfileOAuth2TokenService::InvalidateOAuth2Token( |
| 212 const std::string& account_id, | 213 const std::string& account_id, |
| 213 const std::string& client_id, | 214 const std::string& client_id, |
| 214 const ScopeSet& scopes, | 215 const ScopeSet& scopes, |
| 215 const std::string& access_token) { | 216 const std::string& access_token) { |
| 216 // Do nothing, as we don't have a cache from which to remove the token. | 217 // Do nothing, as we don't have a cache from which to remove the token. |
| 217 } | 218 } |
| OLD | NEW |