Chromium Code Reviews| 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 e1842eb558981452422fe797fd4ba7ee01348204..9b12e34d89e51871c0045d0e8ada807187ffa5af 100644 |
| --- a/chrome/browser/signin/fake_profile_oauth2_token_service.cc |
| +++ b/chrome/browser/signin/fake_profile_oauth2_token_service.cc |
| @@ -5,7 +5,33 @@ |
| #include "chrome/browser/signin/fake_profile_oauth2_token_service.h" |
| #include "base/message_loop/message_loop.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| #include "chrome/browser/signin/signin_account_id_helper.h" |
| +#include "content/public/browser/browser_context.h" |
| + |
| +namespace { |
| + |
| +class FakeProfileOAuth2TokenServiceWrapper |
|
blundell
2014/02/10 16:19:16
This class will eventually have to be split into i
Roger Tawa OOO till Jul 10th
2014/02/10 19:49:13
Probably makes sense to do it as part of this CL,
blundell
2014/02/13 16:07:06
Done.
|
| + : public ProfileOAuth2TokenServiceWrapper { |
| + public: |
| + FakeProfileOAuth2TokenServiceWrapper(Profile* profile, |
| + bool auto_issue_tokens) { |
| + if (auto_issue_tokens) |
| + service_.set_auto_post_fetch_response_on_message_loop(true); |
| + service_.Initialize(reinterpret_cast<Profile*>(profile)); |
| + } |
| + virtual ~FakeProfileOAuth2TokenServiceWrapper() { service_.Shutdown(); } |
| + |
| + virtual ProfileOAuth2TokenService* GetProfileOAuth2TokenService() OVERRIDE { |
| + return &service_; |
| + } |
| + |
| + private: |
| + FakeProfileOAuth2TokenService service_; |
| +}; |
|
Roger Tawa OOO till Jul 10th
2014/02/10 19:49:13
Crazy idea, but if you make this class a template
blundell
2014/02/13 16:07:06
It's actually only needed for the fake. Additional
|
| + |
| +} // namespace |
| FakeProfileOAuth2TokenService::PendingRequest::PendingRequest() { |
| } |
| @@ -15,19 +41,16 @@ FakeProfileOAuth2TokenService::PendingRequest::~PendingRequest() { |
| // static |
| BrowserContextKeyedService* FakeProfileOAuth2TokenService::Build( |
| - content::BrowserContext* profile) { |
| - FakeProfileOAuth2TokenService* service = new FakeProfileOAuth2TokenService(); |
| - service->Initialize(reinterpret_cast<Profile*>(profile)); |
| - return service; |
| + content::BrowserContext* context) { |
| + Profile* profile = static_cast<Profile*>(context); |
| + return new FakeProfileOAuth2TokenServiceWrapper(profile, false); |
| } |
| BrowserContextKeyedService* |
| FakeProfileOAuth2TokenService::BuildAutoIssuingTokenService( |
| - content::BrowserContext* profile) { |
| - FakeProfileOAuth2TokenService* service = new FakeProfileOAuth2TokenService(); |
| - service->set_auto_post_fetch_response_on_message_loop(true); |
| - service->Initialize(reinterpret_cast<Profile*>(profile)); |
| - return service; |
| + content::BrowserContext* context) { |
| + Profile* profile = static_cast<Profile*>(context); |
| + return new FakeProfileOAuth2TokenServiceWrapper(profile, true); |
| } |
| FakeProfileOAuth2TokenService::FakeProfileOAuth2TokenService() |