Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / services / gcm / fake_signin_manager.cc
blob64f7ccc34388a41a3f738f710b31bae335a17a79
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/services/gcm/fake_signin_manager.h"
7 #include "base/observer_list.h"
8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/signin/account_tracker_service_factory.h"
11 #include "chrome/browser/signin/chrome_signin_client_factory.h"
12 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
13 #include "components/keyed_service/core/keyed_service.h"
14 #include "components/signin/core/common/signin_pref_names.h"
15 #include "content/public/browser/browser_context.h"
17 #if !defined(OS_CHROMEOS)
18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
19 #endif
21 namespace gcm {
23 FakeSigninManager::FakeSigninManager(Profile* profile)
24 #if defined(OS_CHROMEOS)
25 : SigninManagerBase(
26 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile)),
27 #else
28 : SigninManager(
29 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
30 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
31 AccountTrackerServiceFactory::GetForProfile(profile),
32 GaiaCookieManagerServiceFactory::GetForProfile(profile)),
33 #endif
34 profile_(profile) {
35 Initialize(NULL);
38 FakeSigninManager::~FakeSigninManager() {
41 void FakeSigninManager::SignIn(const std::string& username) {
42 SetAuthenticatedUsername(username);
43 FOR_EACH_OBSERVER(SigninManagerBase::Observer,
44 observer_list_,
45 GoogleSigninSucceeded(username, username, std::string()));
48 void FakeSigninManager::SignOut(
49 signin_metrics::ProfileSignout signout_source_metric) {
50 const std::string account_id = GetAuthenticatedAccountId();
51 const std::string username = GetAuthenticatedUsername();
52 ClearAuthenticatedUsername();
53 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
54 FOR_EACH_OBSERVER(SigninManagerBase::Observer,
55 observer_list_,
56 GoogleSignedOut(account_id, username));
59 // static
60 KeyedService* FakeSigninManager::Build(content::BrowserContext* context) {
61 return new FakeSigninManager(Profile::FromBrowserContext(context));
64 } // namespace gcm