ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chrome / browser / services / gcm / fake_signin_manager.cc
blob28ea3fdf43214076a13c3d09ae11931151f936c5
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 "components/keyed_service/core/keyed_service.h"
13 #include "components/signin/core/common/signin_pref_names.h"
14 #include "content/public/browser/browser_context.h"
16 #if !defined(OS_CHROMEOS)
17 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
18 #endif
20 namespace gcm {
22 FakeSigninManager::FakeSigninManager(Profile* profile)
23 #if defined(OS_CHROMEOS)
24 : SigninManagerBase(
25 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile)),
26 #else
27 : SigninManager(
28 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
29 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
30 AccountTrackerServiceFactory::GetForProfile(profile)),
31 #endif
32 profile_(profile) {
33 Initialize(NULL);
36 FakeSigninManager::~FakeSigninManager() {
39 void FakeSigninManager::SignIn(const std::string& username) {
40 SetAuthenticatedUsername(username);
41 FOR_EACH_OBSERVER(SigninManagerBase::Observer,
42 observer_list_,
43 GoogleSigninSucceeded(username, username, std::string()));
46 void FakeSigninManager::SignOut(
47 signin_metrics::ProfileSignout signout_source_metric) {
48 const std::string account_id = GetAuthenticatedAccountId();
49 const std::string username = GetAuthenticatedUsername();
50 ClearAuthenticatedUsername();
51 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername);
52 FOR_EACH_OBSERVER(SigninManagerBase::Observer,
53 observer_list_,
54 GoogleSignedOut(account_id, username));
57 // static
58 KeyedService* FakeSigninManager::Build(content::BrowserContext* context) {
59 return new FakeSigninManager(Profile::FromBrowserContext(context));
62 } // namespace gcm