OLD | NEW |
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/fake_signin_manager.h" | 5 #include "chrome/browser/signin/fake_signin_manager.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/chrome_signin_manager_delegate.h" | 10 #include "chrome/browser/signin/chrome_signin_manager_delegate.h" |
11 #include "chrome/browser/signin/signin_global_error.h" | 11 #include "chrome/browser/signin/signin_global_error.h" |
12 #include "chrome/browser/ui/global_error/global_error_service.h" | 12 #include "chrome/browser/ui/global_error/global_error_service.h" |
13 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 13 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
14 #include "chrome/common/chrome_notification_types.h" | 14 #include "chrome/common/chrome_notification_types.h" |
15 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
16 #include "content/public/browser/notification_service.h" | 16 #include "content/public/browser/notification_service.h" |
17 | 17 |
18 FakeSigninManagerBase::FakeSigninManagerBase(Profile* profile) { | 18 FakeSigninManagerBase::FakeSigninManagerBase() { |
19 profile_ = profile; | |
20 signin_global_error_.reset(new SigninGlobalError(this, profile)); | |
21 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError( | |
22 signin_global_error_.get()); | |
23 signin_allowed_.Init(prefs::kSigninAllowed, profile_->GetPrefs(), | |
24 base::Bind(&SigninManagerBase::OnSigninAllowedPrefChanged, | |
25 base::Unretained(this))); | |
26 } | 19 } |
27 | 20 |
28 FakeSigninManagerBase::~FakeSigninManagerBase() { | 21 FakeSigninManagerBase::~FakeSigninManagerBase() { |
29 if (signin_global_error_.get()) { | |
30 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError( | |
31 signin_global_error_.get()); | |
32 signin_global_error_.reset(); | |
33 } | |
34 } | 22 } |
35 | 23 |
36 void FakeSigninManagerBase::SignOut() { | 24 void FakeSigninManagerBase::InitTokenService() { |
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 } | 25 } |
43 | 26 |
44 // static | 27 // static |
45 ProfileKeyedService* FakeSigninManagerBase::Build( | 28 ProfileKeyedService* FakeSigninManagerBase::Build( |
46 content::BrowserContext* profile) { | 29 content::BrowserContext* profile) { |
47 return new FakeSigninManagerBase(static_cast<Profile*>(profile)); | 30 return new FakeSigninManagerBase(); |
48 } | 31 } |
49 | 32 |
50 #if !defined (OS_CHROMEOS) | 33 #if !defined (OS_CHROMEOS) |
51 | 34 |
52 FakeSigninManager::FakeSigninManager(Profile* profile) | 35 FakeSigninManager::FakeSigninManager(Profile* profile) |
53 : SigninManager(scoped_ptr<SigninManagerDelegate>( | 36 : SigninManager(scoped_ptr<SigninManagerDelegate>( |
54 new ChromeSigninManagerDelegate(profile))) { | 37 new ChromeSigninManagerDelegate(profile))) { |
55 Initialize(profile); | |
56 } | 38 } |
57 | 39 |
58 FakeSigninManager::~FakeSigninManager() { | 40 FakeSigninManager::~FakeSigninManager() { |
59 } | 41 } |
60 | 42 |
61 void FakeSigninManager::InitTokenService() { | 43 void FakeSigninManager::InitTokenService() { |
62 } | 44 } |
63 | 45 |
64 void FakeSigninManager::StartSignIn(const std::string& username, | 46 void FakeSigninManager::StartSignIn(const std::string& username, |
65 const std::string& password, | 47 const std::string& password, |
(...skipping 28 matching lines...) Expand all Loading... |
94 content::NotificationService::NoDetails()); | 76 content::NotificationService::NoDetails()); |
95 } | 77 } |
96 | 78 |
97 // static | 79 // static |
98 ProfileKeyedService* FakeSigninManager::Build( | 80 ProfileKeyedService* FakeSigninManager::Build( |
99 content::BrowserContext* profile) { | 81 content::BrowserContext* profile) { |
100 return new FakeSigninManager(static_cast<Profile*>(profile)); | 82 return new FakeSigninManager(static_cast<Profile*>(profile)); |
101 } | 83 } |
102 | 84 |
103 #endif // !defined (OS_CHROMEOS) | 85 #endif // !defined (OS_CHROMEOS) |
OLD | NEW |