| 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 FakeProfileOAuth2TokenService::PendingRequest::PendingRequest() { | 7 FakeProfileOAuth2TokenService::PendingRequest::PendingRequest() { |
| 8 } | 8 } |
| 9 | 9 |
| 10 FakeProfileOAuth2TokenService::PendingRequest::~PendingRequest() { | 10 FakeProfileOAuth2TokenService::PendingRequest::~PendingRequest() { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 std::vector<FakeProfileOAuth2TokenService::PendingRequest> requests = | 75 std::vector<FakeProfileOAuth2TokenService::PendingRequest> requests = |
| 76 GetPendingRequests(); | 76 GetPendingRequests(); |
| 77 // Walk the requests and notify the callbacks. | 77 // Walk the requests and notify the callbacks. |
| 78 for (std::vector<PendingRequest>::iterator it = pending_requests_.begin(); | 78 for (std::vector<PendingRequest>::iterator it = pending_requests_.begin(); |
| 79 it != pending_requests_.end(); ++it) { | 79 it != pending_requests_.end(); ++it) { |
| 80 if (it->request && (all_scopes || it->scopes == scope)) | 80 if (it->request && (all_scopes || it->scopes == scope)) |
| 81 it->request->InformConsumer(error, access_token, expiration); | 81 it->request->InformConsumer(error, access_token, expiration); |
| 82 } | 82 } |
| 83 } | 83 } |
| 84 | 84 |
| 85 std::string FakeProfileOAuth2TokenService::GetRefreshToken() { | 85 std::string FakeProfileOAuth2TokenService::GetRefreshToken( |
| 86 const std::string& account_id) { |
| 86 return refresh_token_; | 87 return refresh_token_; |
| 87 } | 88 } |
| 88 | 89 |
| 89 net::URLRequestContextGetter* | 90 net::URLRequestContextGetter* |
| 90 FakeProfileOAuth2TokenService::GetRequestContext() { | 91 FakeProfileOAuth2TokenService::GetRequestContext() { |
| 91 return NULL; | 92 return NULL; |
| 92 } | 93 } |
| 93 | 94 |
| 94 std::vector<FakeProfileOAuth2TokenService::PendingRequest> | 95 std::vector<FakeProfileOAuth2TokenService::PendingRequest> |
| 95 FakeProfileOAuth2TokenService::GetPendingRequests() { | 96 FakeProfileOAuth2TokenService::GetPendingRequests() { |
| 96 std::vector<PendingRequest> valid_requests; | 97 std::vector<PendingRequest> valid_requests; |
| 97 for (std::vector<PendingRequest>::iterator it = pending_requests_.begin(); | 98 for (std::vector<PendingRequest>::iterator it = pending_requests_.begin(); |
| 98 it != pending_requests_.end(); ++it) { | 99 it != pending_requests_.end(); ++it) { |
| 99 if (it->request) | 100 if (it->request) |
| 100 valid_requests.push_back(*it); | 101 valid_requests.push_back(*it); |
| 101 } | 102 } |
| 102 return valid_requests; | 103 return valid_requests; |
| 103 } | 104 } |
| 104 | 105 |
| 105 void FakeProfileOAuth2TokenService::FetchOAuth2Token( | 106 void FakeProfileOAuth2TokenService::FetchOAuth2Token( |
| 106 RequestImpl* request, | 107 RequestImpl* request, |
| 108 const std::string& account_id, |
| 107 net::URLRequestContextGetter* getter, | 109 net::URLRequestContextGetter* getter, |
| 108 const std::string& client_id, | 110 const std::string& client_id, |
| 109 const std::string& client_secret, | 111 const std::string& client_secret, |
| 110 const ScopeSet& scopes) { | 112 const ScopeSet& scopes) { |
| 111 PendingRequest pending_request; | 113 PendingRequest pending_request; |
| 114 pending_request.account_id = account_id; |
| 112 pending_request.client_id = client_id; | 115 pending_request.client_id = client_id; |
| 113 pending_request.client_secret = client_secret; | 116 pending_request.client_secret = client_secret; |
| 114 pending_request.scopes = scopes; | 117 pending_request.scopes = scopes; |
| 115 pending_request.request = request->AsWeakPtr(); | 118 pending_request.request = request->AsWeakPtr(); |
| 116 pending_requests_.push_back(pending_request); | 119 pending_requests_.push_back(pending_request); |
| 117 } | 120 } |
| OLD | NEW |