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/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "chrome/browser/profiles/profile.h" | |
| 9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | |
| 8 #include "chrome/browser/signin/signin_account_id_helper.h" | 10 #include "chrome/browser/signin/signin_account_id_helper.h" |
| 11 #include "content/public/browser/browser_context.h" | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 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.
| |
| 16 : public ProfileOAuth2TokenServiceWrapper { | |
| 17 public: | |
| 18 FakeProfileOAuth2TokenServiceWrapper(Profile* profile, | |
| 19 bool auto_issue_tokens) { | |
| 20 if (auto_issue_tokens) | |
| 21 service_.set_auto_post_fetch_response_on_message_loop(true); | |
| 22 service_.Initialize(reinterpret_cast<Profile*>(profile)); | |
| 23 } | |
| 24 virtual ~FakeProfileOAuth2TokenServiceWrapper() { service_.Shutdown(); } | |
| 25 | |
| 26 virtual ProfileOAuth2TokenService* GetProfileOAuth2TokenService() OVERRIDE { | |
| 27 return &service_; | |
| 28 } | |
| 29 | |
| 30 private: | |
| 31 FakeProfileOAuth2TokenService service_; | |
| 32 }; | |
|
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
| |
| 33 | |
| 34 } // namespace | |
| 9 | 35 |
| 10 FakeProfileOAuth2TokenService::PendingRequest::PendingRequest() { | 36 FakeProfileOAuth2TokenService::PendingRequest::PendingRequest() { |
| 11 } | 37 } |
| 12 | 38 |
| 13 FakeProfileOAuth2TokenService::PendingRequest::~PendingRequest() { | 39 FakeProfileOAuth2TokenService::PendingRequest::~PendingRequest() { |
| 14 } | 40 } |
| 15 | 41 |
| 16 // static | 42 // static |
| 17 BrowserContextKeyedService* FakeProfileOAuth2TokenService::Build( | 43 BrowserContextKeyedService* FakeProfileOAuth2TokenService::Build( |
| 18 content::BrowserContext* profile) { | 44 content::BrowserContext* context) { |
| 19 FakeProfileOAuth2TokenService* service = new FakeProfileOAuth2TokenService(); | 45 Profile* profile = static_cast<Profile*>(context); |
| 20 service->Initialize(reinterpret_cast<Profile*>(profile)); | 46 return new FakeProfileOAuth2TokenServiceWrapper(profile, false); |
| 21 return service; | |
| 22 } | 47 } |
| 23 | 48 |
| 24 BrowserContextKeyedService* | 49 BrowserContextKeyedService* |
| 25 FakeProfileOAuth2TokenService::BuildAutoIssuingTokenService( | 50 FakeProfileOAuth2TokenService::BuildAutoIssuingTokenService( |
| 26 content::BrowserContext* profile) { | 51 content::BrowserContext* context) { |
| 27 FakeProfileOAuth2TokenService* service = new FakeProfileOAuth2TokenService(); | 52 Profile* profile = static_cast<Profile*>(context); |
| 28 service->set_auto_post_fetch_response_on_message_loop(true); | 53 return new FakeProfileOAuth2TokenServiceWrapper(profile, true); |
| 29 service->Initialize(reinterpret_cast<Profile*>(profile)); | |
| 30 return service; | |
| 31 } | 54 } |
| 32 | 55 |
| 33 FakeProfileOAuth2TokenService::FakeProfileOAuth2TokenService() | 56 FakeProfileOAuth2TokenService::FakeProfileOAuth2TokenService() |
| 34 : auto_post_fetch_response_on_message_loop_(false) { | 57 : auto_post_fetch_response_on_message_loop_(false) { |
| 35 SigninAccountIdHelper::SetDisableForTest(true); | 58 SigninAccountIdHelper::SetDisableForTest(true); |
| 36 } | 59 } |
| 37 | 60 |
| 38 FakeProfileOAuth2TokenService::~FakeProfileOAuth2TokenService() { | 61 FakeProfileOAuth2TokenService::~FakeProfileOAuth2TokenService() { |
| 39 SigninAccountIdHelper::SetDisableForTest(false); | 62 SigninAccountIdHelper::SetDisableForTest(false); |
| 40 } | 63 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 188 } | 211 } |
| 189 } | 212 } |
| 190 | 213 |
| 191 void FakeProfileOAuth2TokenService::InvalidateOAuth2Token( | 214 void FakeProfileOAuth2TokenService::InvalidateOAuth2Token( |
| 192 const std::string& account_id, | 215 const std::string& account_id, |
| 193 const std::string& client_id, | 216 const std::string& client_id, |
| 194 const ScopeSet& scopes, | 217 const ScopeSet& scopes, |
| 195 const std::string& access_token) { | 218 const std::string& access_token) { |
| 196 // Do nothing, as we don't have a cache from which to remove the token. | 219 // Do nothing, as we don't have a cache from which to remove the token. |
| 197 } | 220 } |
| OLD | NEW |