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

Side by Side Diff: chrome/browser/signin/signin_manager_fake.cc

Issue 12502017: signin: pull basic SigninManager functionality into new SigninManagerBase class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix override Created 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/signin/signin_manager_fake.h" 5 #include "chrome/browser/signin/signin_manager_fake.h"
6 6
7 #include "base/callback_helpers.h" 7 #include "base/callback_helpers.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/signin_global_error.h" 10 #include "chrome/browser/signin/signin_global_error.h"
11 #include "chrome/browser/ui/global_error/global_error_service.h" 11 #include "chrome/browser/ui/global_error/global_error_service.h"
12 #include "chrome/browser/ui/global_error/global_error_service_factory.h" 12 #include "chrome/browser/ui/global_error/global_error_service_factory.h"
13 #include "chrome/common/chrome_notification_types.h" 13 #include "chrome/common/chrome_notification_types.h"
14 #include "chrome/common/pref_names.h" 14 #include "chrome/common/pref_names.h"
15 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
16 16
17 FakeSigninManager::FakeSigninManager(Profile* profile) 17 FakeSigninManagerBase::FakeSigninManagerBase(Profile* profile)
18 : auth_in_progress_(false) { 18 : auth_in_progress_(false) {
19 profile_ = profile; 19 profile_ = profile;
20 signin_global_error_.reset(new SigninGlobalError(this, profile)); 20 signin_global_error_.reset(new SigninGlobalError(this, profile));
21 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( 21 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(
22 signin_global_error_.get()); 22 signin_global_error_.get());
23 signin_allowed_.Init(prefs::kSigninAllowed, profile_->GetPrefs(), 23 signin_allowed_.Init(prefs::kSigninAllowed, profile_->GetPrefs(),
24 base::Bind(&SigninManager::OnSigninAllowedPrefChanged, 24 base::Bind(&SigninManagerBase::OnSigninAllowedPrefChanged,
25 base::Unretained(this))); 25 base::Unretained(this)));
26 } 26 }
27 27
28 FakeSigninManager::~FakeSigninManager() { 28 FakeSigninManagerBase::~FakeSigninManagerBase() {
29 if (signin_global_error_.get()) { 29 if (signin_global_error_.get()) {
30 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( 30 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(
31 signin_global_error_.get()); 31 signin_global_error_.get());
32 signin_global_error_.reset(); 32 signin_global_error_.reset();
33 } 33 }
34 } 34 }
35 35
36 void FakeSigninManagerBase::SignOut() {
37 authenticated_username_.clear();
38 content::NotificationService::current()->Notify(
39 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
40 content::Source<Profile>(profile_),
41 content::NotificationService::NoDetails());
42 }
43
44 bool FakeSigninManagerBase::AuthInProgress() const {
45 return auth_in_progress_;
46 }
47
48 // static
49 ProfileKeyedService* FakeSigninManagerBase::Build(Profile* profile) {
50 return new FakeSigninManagerBase(profile);
51 }
52
53 #if !defined (OS_CHROMEOS)
54
55 FakeSigninManager::FakeSigninManager(Profile* profile) {
56 Initialize(profile);
57 }
58
59 FakeSigninManager::~FakeSigninManager() {
60 }
61
62 void FakeSigninManager::InitTokenService() {
63 }
64
36 void FakeSigninManager::StartSignIn(const std::string& username, 65 void FakeSigninManager::StartSignIn(const std::string& username,
37 const std::string& password, 66 const std::string& password,
38 const std::string& login_token, 67 const std::string& login_token,
39 const std::string& login_captcha) { 68 const std::string& login_captcha) {
40 SetAuthenticatedUsername(username); 69 SetAuthenticatedUsername(username);
41 } 70 }
42 71
43 void FakeSigninManager::StartSignInWithCredentials( 72 void FakeSigninManager::StartSignInWithCredentials(
44 const std::string& session_index, 73 const std::string& session_index,
45 const std::string& username, 74 const std::string& username,
46 const std::string& password) { 75 const std::string& password) {
47 SetAuthenticatedUsername(username); 76 SetAuthenticatedUsername(username);
48 } 77 }
49 78
50 void FakeSigninManager::StartSignInWithOAuth(const std::string& username, 79 void FakeSigninManager::StartSignInWithOAuth(const std::string& username,
51 const std::string& password) { 80 const std::string& password) {
52 SetAuthenticatedUsername(username); 81 SetAuthenticatedUsername(username);
53 } 82 }
54 83
55 void FakeSigninManager::SignOut() { 84 void FakeSigninManager::SignOut() {
56 if (IsSignoutProhibited()) 85 if (IsSignoutProhibited())
57 return; 86 return;
58 authenticated_username_.clear(); 87 authenticated_username_.clear();
59 content::NotificationService::current()->Notify( 88 content::NotificationService::current()->Notify(
60 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, 89 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT,
61 content::Source<Profile>(profile_), 90 content::Source<Profile>(profile_),
62 content::NotificationService::NoDetails()); 91 content::NotificationService::NoDetails());
63 } 92 }
64 93
65 void FakeSigninManager::ForceSignOut() {
66 // Allow signing out now.
67 prohibit_signout_ = false;
68 SignOut();
69 }
70
71 bool FakeSigninManager::AuthInProgress() const {
72 return auth_in_progress_;
73 }
74
75 // static 94 // static
76 ProfileKeyedService* FakeSigninManager::Build(Profile* profile) { 95 ProfileKeyedService* FakeSigninManager::Build(Profile* profile) {
77 return new FakeSigninManager(profile); 96 return new FakeSigninManager(profile);
78 } 97 }
98
99 #endif // !defined (OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698