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/sync/fake_oauth2_token_service.h" | 5 #include "chrome/browser/sync/fake_oauth2_token_service_for_sync.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" | 8 #include "chrome/browser/profiles/profile.h" |
9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
10 | 10 |
11 void FakeOAuth2TokenService::FetchOAuth2Token( | 11 void FakeOAuth2TokenServiceForSync::FetchOAuth2Token( |
12 OAuth2TokenService::RequestImpl* request, | 12 OAuth2TokenService::RequestImpl* request, |
13 const std::string& account_id, | 13 const std::string& account_id, |
14 net::URLRequestContextGetter* getter, | 14 net::URLRequestContextGetter* getter, |
15 const std::string& client_id, | 15 const std::string& client_id, |
16 const std::string& client_secret, | 16 const std::string& client_secret, |
17 const OAuth2TokenService::ScopeSet& scopes) { | 17 const OAuth2TokenService::ScopeSet& scopes) { |
18 // Request will succeed without network IO. | 18 // Request will succeed without network IO. |
19 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 19 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
20 &RequestImpl::InformConsumer, | 20 &RequestImpl::InformConsumer, |
21 request->AsWeakPtr(), | 21 request->AsWeakPtr(), |
22 GoogleServiceAuthError(GoogleServiceAuthError::NONE), | 22 GoogleServiceAuthError(GoogleServiceAuthError::NONE), |
23 "access_token", | 23 "access_token", |
24 base::Time::Max())); | 24 base::Time::Max())); |
25 } | 25 } |
26 | 26 |
27 void FakeOAuth2TokenService::UpdateCredentials( | 27 void FakeOAuth2TokenServiceForSync::UpdateCredentials( |
28 const std::string& account_id, | 28 const std::string& account_id, |
29 const std::string& refresh_token) { | 29 const std::string& refresh_token) { |
30 account_id_ = account_id; | 30 account_id_ = account_id; |
31 refresh_token_ = refresh_token; | 31 refresh_token_ = refresh_token; |
32 FireRefreshTokenAvailable(account_id); | 32 FireRefreshTokenAvailable(account_id); |
33 } | 33 } |
34 | 34 |
35 bool FakeOAuth2TokenService::RefreshTokenIsAvailable( | 35 bool FakeOAuth2TokenServiceForSync::RefreshTokenIsAvailable( |
36 const std::string& account_id) { | 36 const std::string& account_id) { |
37 return account_id_ == account_id && !refresh_token_.empty(); | 37 return account_id_ == account_id && !refresh_token_.empty(); |
38 } | 38 } |
39 | 39 |
40 BrowserContextKeyedService* FakeOAuth2TokenService::BuildTokenService( | 40 BrowserContextKeyedService* FakeOAuth2TokenServiceForSync::BuildTokenService( |
41 content::BrowserContext* context) { | 41 content::BrowserContext* context) { |
42 Profile* profile = static_cast<Profile*>(context); | 42 Profile* profile = static_cast<Profile*>(context); |
43 | 43 |
44 FakeOAuth2TokenService* service = new FakeOAuth2TokenService(); | 44 FakeOAuth2TokenServiceForSync* service = new FakeOAuth2TokenServiceForSync(); |
45 service->Initialize(profile); | 45 service->Initialize(profile); |
46 return service; | 46 return service; |
47 } | 47 } |
OLD | NEW |