1 // Copyright 2014 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.
5 #include "chrome/browser/sync/fake_oauth2_token_service_for_sync.h"
7 #include "base/message_loop/message_loop.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "content/public/browser/browser_context.h"
11 void FakeOAuth2TokenServiceForSync::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
,
22 GoogleServiceAuthError(GoogleServiceAuthError::NONE
),
27 void FakeOAuth2TokenServiceForSync::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
);
35 bool FakeOAuth2TokenServiceForSync::RefreshTokenIsAvailable(
36 const std::string
& account_id
) {
37 return account_id_
== account_id
&& !refresh_token_
.empty();
40 BrowserContextKeyedService
* FakeOAuth2TokenServiceForSync::BuildTokenService(
41 content::BrowserContext
* context
) {
42 Profile
* profile
= static_cast<Profile
*>(context
);
44 FakeOAuth2TokenServiceForSync
* service
= new FakeOAuth2TokenServiceForSync();
45 service
->Initialize(profile
);