| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "chrome/browser/services/gcm/fake_signin_manager.h" | |
| 6 | |
| 7 #include "base/observer_list.h" | |
| 8 #include "build/build_config.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/prefs/pref_service.h" | |
| 15 #include "components/signin/core/browser/account_tracker_service.h" | |
| 16 #include "components/signin/core/common/signin_pref_names.h" | |
| 17 #include "content/public/browser/browser_context.h" | |
| 18 | |
| 19 #if !defined(OS_CHROMEOS) | |
| 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | |
| 21 #endif | |
| 22 | |
| 23 namespace gcm { | |
| 24 | |
| 25 FakeSigninManager::FakeSigninManager(Profile* profile) | |
| 26 #if defined(OS_CHROMEOS) | |
| 27 : SigninManagerBase( | |
| 28 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile), | |
| 29 AccountTrackerServiceFactory::GetForProfile(profile)), | |
| 30 #else | |
| 31 : SigninManager( | |
| 32 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile), | |
| 33 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | |
| 34 AccountTrackerServiceFactory::GetForProfile(profile), | |
| 35 GaiaCookieManagerServiceFactory::GetForProfile(profile)), | |
| 36 #endif | |
| 37 profile_(profile) { | |
| 38 Initialize(NULL); | |
| 39 } | |
| 40 | |
| 41 FakeSigninManager::~FakeSigninManager() { | |
| 42 } | |
| 43 | |
| 44 void FakeSigninManager::SignIn(const std::string& account_id) { | |
| 45 SetAuthenticatedAccountId(account_id); | |
| 46 FOR_EACH_OBSERVER(SigninManagerBase::Observer, | |
| 47 observer_list_, | |
| 48 GoogleSigninSucceeded(account_id, account_id, | |
| 49 std::string())); | |
| 50 } | |
| 51 | |
| 52 void FakeSigninManager::SignOut( | |
| 53 signin_metrics::ProfileSignout signout_source_metric, | |
| 54 signin_metrics::SignoutDelete signout_delete_metric) { | |
| 55 const std::string account_id = GetAuthenticatedAccountId(); | |
| 56 const std::string username = GetAuthenticatedAccountInfo().email; | |
| 57 clear_authenticated_user(); | |
| 58 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesAccountId); | |
| 59 FOR_EACH_OBSERVER(SigninManagerBase::Observer, | |
| 60 observer_list_, | |
| 61 GoogleSignedOut(account_id, username)); | |
| 62 } | |
| 63 | |
| 64 // static | |
| 65 KeyedService* FakeSigninManager::Build(content::BrowserContext* context) { | |
| 66 return new FakeSigninManager(Profile::FromBrowserContext(context)); | |
| 67 } | |
| 68 | |
| 69 } // namespace gcm | |
| OLD | NEW |