Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / services / gcm / fake_signin_manager.cc
blob563ee4f9934180fd9dbf1477f61127915c596ac1
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/browser/account_tracker_service.h"
15 #include "components/signin/core/common/signin_pref_names.h"
16 #include "content/public/browser/browser_context.h"
18 #if !defined(OS_CHROMEOS)
19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
20 #endif
22 namespace gcm {
24 FakeSigninManager::FakeSigninManager(Profile* profile)
25 #if defined(OS_CHROMEOS)
26 : SigninManagerBase(
27 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
28 AccountTrackerServiceFactory::GetForProfile(profile)),
29 #else
30 : SigninManager(
31 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
32 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
33 AccountTrackerServiceFactory::GetForProfile(profile),
34 GaiaCookieManagerServiceFactory::GetForProfile(profile)),
35 #endif
36 profile_(profile) {
37 Initialize(NULL);
40 FakeSigninManager::~FakeSigninManager() {
43 void FakeSigninManager::SignIn(const std::string& account_id) {
44 SetAuthenticatedAccountId(account_id);
45 FOR_EACH_OBSERVER(SigninManagerBase::Observer,
46 observer_list_,
47 GoogleSigninSucceeded(account_id, account_id,
48 std::string()));
51 void FakeSigninManager::SignOut(
52 signin_metrics::ProfileSignout signout_source_metric) {
53 const std::string account_id = GetAuthenticatedAccountId();
54 const std::string username = GetAuthenticatedUsername();
55 clear_authenticated_user();
56 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesAccountId);
57 FOR_EACH_OBSERVER(SigninManagerBase::Observer,
58 observer_list_,
59 GoogleSignedOut(account_id, username));
62 // static
63 KeyedService* FakeSigninManager::Build(content::BrowserContext* context) {
64 return new FakeSigninManager(Profile::FromBrowserContext(context));
67 } // namespace gcm