| 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/signin_manager_factory.h" | 5 #include "chrome/browser/signin/signin_manager_factory.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_registry_simple.h" | 7 #include "base/prefs/pref_registry_simple.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/signin/chrome_signin_client_factory.h" | 10 #include "chrome/browser/signin/chrome_signin_client_factory.h" |
| 11 #include "chrome/browser/signin/local_auth.h" | 11 #include "chrome/browser/signin/local_auth.h" |
| 12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 12 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 13 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 14 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 14 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 15 #include "components/pref_registry/pref_registry_syncable.h" | 15 #include "components/pref_registry/pref_registry_syncable.h" |
| 16 #include "components/signin/core/browser/signin_manager.h" | 16 #include "components/signin/core/browser/signin_manager.h" |
| 17 | 17 |
| 18 SigninManagerFactory::SigninManagerFactory() | 18 SigninManagerFactory::SigninManagerFactory() |
| 19 : BrowserContextKeyedServiceFactory( | 19 : BrowserContextKeyedServiceFactory( |
| 20 "SigninManager", | 20 "SigninManager", |
| 21 BrowserContextDependencyManager::GetInstance()) { | 21 BrowserContextDependencyManager::GetInstance()) { |
| 22 DependsOn(ChromeSigninClientFactory::GetInstance()); | 22 DependsOn(ChromeSigninClientFactory::GetInstance()); |
| 23 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); | 23 DependsOn(ProfileOAuth2TokenServiceFactory::GetInstance()); |
| 24 } | 24 } |
| 25 | 25 |
| 26 SigninManagerFactory::~SigninManagerFactory() { | 26 SigninManagerFactory::~SigninManagerFactory() { |
| 27 #if defined(OS_MACOSX) | |
| 28 // Check that the number of remaining observers is as expected. Mac has a | |
| 29 // known issue wherein there might be a remaining observer | |
| 30 // (UIAppListViewDelegate). | |
| 31 int num_observers = 0; | |
| 32 if (observer_list_.might_have_observers()) { | |
| 33 ObserverListBase<SigninManagerFactory::Observer>::Iterator it( | |
| 34 observer_list_); | |
| 35 while (it.GetNext()) { | |
| 36 num_observers++; | |
| 37 } | |
| 38 } | |
| 39 DCHECK_LE(num_observers, 1); | |
| 40 #endif // defined(OS_MACOSX) | |
| 41 } | 27 } |
| 42 | 28 |
| 43 #if defined(OS_CHROMEOS) | 29 #if defined(OS_CHROMEOS) |
| 44 // static | 30 // static |
| 45 SigninManagerBase* SigninManagerFactory::GetForProfileIfExists( | 31 SigninManagerBase* SigninManagerFactory::GetForProfileIfExists( |
| 46 Profile* profile) { | 32 Profile* profile) { |
| 47 return static_cast<SigninManagerBase*>( | 33 return static_cast<SigninManagerBase*>( |
| 48 GetInstance()->GetServiceForBrowserContext(profile, false)); | 34 GetInstance()->GetServiceForBrowserContext(profile, false)); |
| 49 } | 35 } |
| 50 | 36 |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 } | 133 } |
| 148 | 134 |
| 149 void SigninManagerFactory::BrowserContextShutdown( | 135 void SigninManagerFactory::BrowserContextShutdown( |
| 150 content::BrowserContext* context) { | 136 content::BrowserContext* context) { |
| 151 SigninManagerBase* manager = static_cast<SigninManagerBase*>( | 137 SigninManagerBase* manager = static_cast<SigninManagerBase*>( |
| 152 GetServiceForBrowserContext(context, false)); | 138 GetServiceForBrowserContext(context, false)); |
| 153 if (manager) | 139 if (manager) |
| 154 FOR_EACH_OBSERVER(Observer, observer_list_, SigninManagerShutdown(manager)); | 140 FOR_EACH_OBSERVER(Observer, observer_list_, SigninManagerShutdown(manager)); |
| 155 BrowserContextKeyedServiceFactory::BrowserContextShutdown(context); | 141 BrowserContextKeyedServiceFactory::BrowserContextShutdown(context); |
| 156 } | 142 } |
| OLD | NEW |