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