Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: chrome/browser/services/gcm/fake_signin_manager.cc

Issue 964563002: Replace SetAuthenticatedUsername with SetAuthenticatedAccountId. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@priv
Patch Set: rebased Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/services/gcm/fake_signin_manager.h" 5 #include "chrome/browser/services/gcm/fake_signin_manager.h"
6 6
7 #include "base/observer_list.h" 7 #include "base/observer_list.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/signin/account_tracker_service_factory.h" 10 #include "chrome/browser/signin/account_tracker_service_factory.h"
11 #include "chrome/browser/signin/chrome_signin_client_factory.h" 11 #include "chrome/browser/signin/chrome_signin_client_factory.h"
12 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h" 12 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
13 #include "components/keyed_service/core/keyed_service.h" 13 #include "components/keyed_service/core/keyed_service.h"
14 #include "components/signin/core/browser/account_tracker_service.h"
14 #include "components/signin/core/common/signin_pref_names.h" 15 #include "components/signin/core/common/signin_pref_names.h"
15 #include "content/public/browser/browser_context.h" 16 #include "content/public/browser/browser_context.h"
16 17
17 #if !defined(OS_CHROMEOS) 18 #if !defined(OS_CHROMEOS)
18 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
19 #endif 20 #endif
20 21
21 namespace gcm { 22 namespace gcm {
22 23
23 FakeSigninManager::FakeSigninManager(Profile* profile) 24 FakeSigninManager::FakeSigninManager(Profile* profile)
24 #if defined(OS_CHROMEOS) 25 #if defined(OS_CHROMEOS)
25 : SigninManagerBase( 26 : SigninManagerBase(
26 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile)), 27 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
28 AccountTrackerServiceFactory::GetForProfile(profile)),
27 #else 29 #else
28 : SigninManager( 30 : SigninManager(
29 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile), 31 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile),
30 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), 32 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
31 AccountTrackerServiceFactory::GetForProfile(profile), 33 AccountTrackerServiceFactory::GetForProfile(profile),
32 GaiaCookieManagerServiceFactory::GetForProfile(profile)), 34 GaiaCookieManagerServiceFactory::GetForProfile(profile)),
33 #endif 35 #endif
34 profile_(profile) { 36 profile_(profile) {
35 Initialize(NULL); 37 Initialize(NULL);
36 } 38 }
37 39
38 FakeSigninManager::~FakeSigninManager() { 40 FakeSigninManager::~FakeSigninManager() {
39 } 41 }
40 42
41 void FakeSigninManager::SignIn(const std::string& username) { 43 void FakeSigninManager::SignIn(const std::string& account_id) {
42 SetAuthenticatedUsername(username); 44 SetAuthenticatedAccountId(account_id);
43 FOR_EACH_OBSERVER(SigninManagerBase::Observer, 45 FOR_EACH_OBSERVER(SigninManagerBase::Observer,
44 observer_list_, 46 observer_list_,
45 GoogleSigninSucceeded(username, username, std::string())); 47 GoogleSigninSucceeded(account_id, account_id,
48 std::string()));
46 } 49 }
47 50
48 void FakeSigninManager::SignOut( 51 void FakeSigninManager::SignOut(
49 signin_metrics::ProfileSignout signout_source_metric) { 52 signin_metrics::ProfileSignout signout_source_metric) {
50 const std::string account_id = GetAuthenticatedAccountId(); 53 const std::string account_id = GetAuthenticatedAccountId();
51 const std::string username = GetAuthenticatedUsername(); 54 const std::string username = GetAuthenticatedUsername();
52 ClearAuthenticatedUsername(); 55 clear_authenticated_user();
53 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesUsername); 56 profile_->GetPrefs()->ClearPref(prefs::kGoogleServicesAccountId);
54 FOR_EACH_OBSERVER(SigninManagerBase::Observer, 57 FOR_EACH_OBSERVER(SigninManagerBase::Observer,
55 observer_list_, 58 observer_list_,
56 GoogleSignedOut(account_id, username)); 59 GoogleSignedOut(account_id, username));
57 } 60 }
58 61
59 // static 62 // static
60 KeyedService* FakeSigninManager::Build(content::BrowserContext* context) { 63 KeyedService* FakeSigninManager::Build(content::BrowserContext* context) {
61 return new FakeSigninManager(Profile::FromBrowserContext(context)); 64 return new FakeSigninManager(Profile::FromBrowserContext(context));
62 } 65 }
63 66
64 } // namespace gcm 67 } // namespace gcm
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698