Index: chrome/browser/signin/fake_profile_oauth2_token_service.cc |
diff --git a/chrome/browser/signin/fake_profile_oauth2_token_service.cc b/chrome/browser/signin/fake_profile_oauth2_token_service.cc |
index 04d4fb9ef36f9162cae32cee2ed186b73c64a525..7a0d2bc58a752e34970c234cf7f69f41f378d74e 100644 |
--- a/chrome/browser/signin/fake_profile_oauth2_token_service.cc |
+++ b/chrome/browser/signin/fake_profile_oauth2_token_service.cc |
@@ -4,6 +4,8 @@ |
#include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
+#include "chrome/browser/profiles/profile.h" |
+ |
FakeProfileOAuth2TokenService::PendingRequest::PendingRequest() { |
} |
@@ -12,19 +14,32 @@ FakeProfileOAuth2TokenService::PendingRequest::~PendingRequest() { |
// static |
BrowserContextKeyedService* FakeProfileOAuth2TokenService::Build( |
- content::BrowserContext* profile) { |
- return new FakeProfileOAuth2TokenService(); |
+ content::BrowserContext* context) { |
+ // Initialize called explicitly here, instead of by passing a Profile to the |
+ // constructor, as not all of the consuming tests need an initialized service. |
+ ProfileOAuth2TokenService* token_service = |
+ new FakeProfileOAuth2TokenService(); |
+ token_service->Initialize(static_cast<Profile*>(context)); |
+ return token_service; |
} |
-FakeProfileOAuth2TokenService::FakeProfileOAuth2TokenService() { |
+FakeProfileOAuth2TokenService::FakeProfileOAuth2TokenService() |
+ : is_initialized_(false) { |
} |
FakeProfileOAuth2TokenService::~FakeProfileOAuth2TokenService() { |
} |
+void FakeProfileOAuth2TokenService::Initialize(Profile* profile) { |
+ ProfileOAuth2TokenService::Initialize(profile); |
+ is_initialized_ = true; |
+} |
+ |
void FakeProfileOAuth2TokenService::Shutdown() { |
- // Do not call the base class handler because it assumes that Initialize() |
- // is always called before Shutdown() and that's not the case for this mock. |
+ if (is_initialized_) { |
+ ProfileOAuth2TokenService::Shutdown(); |
+ is_initialized_ = false; |
+ } |
} |
void FakeProfileOAuth2TokenService::IssueRefreshToken( |
@@ -85,7 +100,8 @@ void FakeProfileOAuth2TokenService::CompleteRequests( |
} |
} |
-std::string FakeProfileOAuth2TokenService::GetRefreshToken() { |
+std::string FakeProfileOAuth2TokenService::GetRefreshToken( |
+ const std::string& account_id) { |
return refresh_token_; |
} |
@@ -107,11 +123,13 @@ FakeProfileOAuth2TokenService::GetPendingRequests() { |
void FakeProfileOAuth2TokenService::FetchOAuth2Token( |
RequestImpl* request, |
+ const std::string& account_id, |
net::URLRequestContextGetter* getter, |
const std::string& client_id, |
const std::string& client_secret, |
const ScopeSet& scopes) { |
PendingRequest pending_request; |
+ pending_request.account_id = account_id; |
pending_request.client_id = client_id; |
pending_request.client_secret = client_secret; |
pending_request.scopes = scopes; |