| 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/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "chrome/browser/signin/signin_account_id_helper.h" | 8 #include "chrome/browser/signin/signin_account_id_helper.h" |
| 9 | 9 |
| 10 FakeProfileOAuth2TokenService::PendingRequest::PendingRequest() { | 10 FakeProfileOAuth2TokenService::PendingRequest::PendingRequest() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 FakeProfileOAuth2TokenService::~FakeProfileOAuth2TokenService() { | 38 FakeProfileOAuth2TokenService::~FakeProfileOAuth2TokenService() { |
| 39 SigninAccountIdHelper::SetDisableForTest(false); | 39 SigninAccountIdHelper::SetDisableForTest(false); |
| 40 } | 40 } |
| 41 | 41 |
| 42 bool FakeProfileOAuth2TokenService::RefreshTokenIsAvailable( | 42 bool FakeProfileOAuth2TokenService::RefreshTokenIsAvailable( |
| 43 const std::string& account_id) { | 43 const std::string& account_id) { |
| 44 return !GetRefreshToken(account_id).empty(); | 44 return !GetRefreshToken(account_id).empty(); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void FakeProfileOAuth2TokenService::LoadCredentials( |
| 48 const std::string& primary_account_id) { |
| 49 // Empty implementation as FakeProfileOAuth2TokenService does not have any |
| 50 // credentials to load. |
| 51 } |
| 52 |
| 47 std::vector<std::string> FakeProfileOAuth2TokenService::GetAccounts() { | 53 std::vector<std::string> FakeProfileOAuth2TokenService::GetAccounts() { |
| 48 std::vector<std::string> account_ids; | 54 std::vector<std::string> account_ids; |
| 49 for (std::map<std::string, std::string>::const_iterator iter = | 55 for (std::map<std::string, std::string>::const_iterator iter = |
| 50 refresh_tokens_.begin(); iter != refresh_tokens_.end(); ++iter) { | 56 refresh_tokens_.begin(); iter != refresh_tokens_.end(); ++iter) { |
| 51 account_ids.push_back(iter->first); | 57 account_ids.push_back(iter->first); |
| 52 } | 58 } |
| 53 return account_ids; | 59 return account_ids; |
| 54 } | 60 } |
| 55 | 61 |
| 56 void FakeProfileOAuth2TokenService::UpdateCredentials( | 62 void FakeProfileOAuth2TokenService::UpdateCredentials( |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 it->request->InformConsumer(error, access_token, expiration); | 151 it->request->InformConsumer(error, access_token, expiration); |
| 146 } | 152 } |
| 147 } | 153 } |
| 148 | 154 |
| 149 std::string FakeProfileOAuth2TokenService::GetRefreshToken( | 155 std::string FakeProfileOAuth2TokenService::GetRefreshToken( |
| 150 const std::string& account_id) { | 156 const std::string& account_id) { |
| 151 return refresh_tokens_.count(account_id) > 0 ? refresh_tokens_[account_id] : | 157 return refresh_tokens_.count(account_id) > 0 ? refresh_tokens_[account_id] : |
| 152 std::string(); | 158 std::string(); |
| 153 } | 159 } |
| 154 | 160 |
| 161 net::URLRequestContextGetter* |
| 162 FakeProfileOAuth2TokenService::GetRequestContext() { |
| 163 return NULL; |
| 164 } |
| 165 |
| 155 std::vector<FakeProfileOAuth2TokenService::PendingRequest> | 166 std::vector<FakeProfileOAuth2TokenService::PendingRequest> |
| 156 FakeProfileOAuth2TokenService::GetPendingRequests() { | 167 FakeProfileOAuth2TokenService::GetPendingRequests() { |
| 157 std::vector<PendingRequest> valid_requests; | 168 std::vector<PendingRequest> valid_requests; |
| 158 for (std::vector<PendingRequest>::iterator it = pending_requests_.begin(); | 169 for (std::vector<PendingRequest>::iterator it = pending_requests_.begin(); |
| 159 it != pending_requests_.end(); ++it) { | 170 it != pending_requests_.end(); ++it) { |
| 160 if (it->request) | 171 if (it->request) |
| 161 valid_requests.push_back(*it); | 172 valid_requests.push_back(*it); |
| 162 } | 173 } |
| 163 return valid_requests; | 174 return valid_requests; |
| 164 } | 175 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 188 } | 199 } |
| 189 } | 200 } |
| 190 | 201 |
| 191 void FakeProfileOAuth2TokenService::InvalidateOAuth2Token( | 202 void FakeProfileOAuth2TokenService::InvalidateOAuth2Token( |
| 192 const std::string& account_id, | 203 const std::string& account_id, |
| 193 const std::string& client_id, | 204 const std::string& client_id, |
| 194 const ScopeSet& scopes, | 205 const ScopeSet& scopes, |
| 195 const std::string& access_token) { | 206 const std::string& access_token) { |
| 196 // Do nothing, as we don't have a cache from which to remove the token. | 207 // Do nothing, as we don't have a cache from which to remove the token. |
| 197 } | 208 } |
| OLD | NEW |