| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/policy/profile_policy_connector_factory.h" | 5 #include "chrome/browser/policy/profile_policy_connector_factory.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/policy/profile_policy_connector.h" | 8 #include "chrome/browser/policy/profile_policy_connector.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 10 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 void ProfilePolicyConnectorFactory::SetServiceForTesting( | 46 void ProfilePolicyConnectorFactory::SetServiceForTesting( |
| 47 Profile* profile, | 47 Profile* profile, |
| 48 ProfilePolicyConnector* connector) { | 48 ProfilePolicyConnector* connector) { |
| 49 ProfilePolicyConnector*& map_entry = connectors_[profile]; | 49 ProfilePolicyConnector*& map_entry = connectors_[profile]; |
| 50 CHECK(!map_entry); | 50 CHECK(!map_entry); |
| 51 map_entry = connector; | 51 map_entry = connector; |
| 52 } | 52 } |
| 53 | 53 |
| 54 ProfilePolicyConnectorFactory::ProfilePolicyConnectorFactory() | 54 ProfilePolicyConnectorFactory::ProfilePolicyConnectorFactory() |
| 55 : ProfileKeyedBaseFactory("ProfilePolicyConnector", | 55 : BrowserContextKeyedBaseFactory( |
| 56 ProfileDependencyManager::GetInstance()) { | 56 "ProfilePolicyConnector", |
| 57 BrowserContextDependencyManager::GetInstance()) { |
| 57 #if defined(ENABLE_CONFIGURATION_POLICY) | 58 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 58 #if defined(OS_CHROMEOS) | 59 #if defined(OS_CHROMEOS) |
| 59 DependsOn(UserCloudPolicyManagerFactoryChromeOS::GetInstance()); | 60 DependsOn(UserCloudPolicyManagerFactoryChromeOS::GetInstance()); |
| 60 #else | 61 #else |
| 61 DependsOn(UserCloudPolicyManagerFactory::GetInstance()); | 62 DependsOn(UserCloudPolicyManagerFactory::GetInstance()); |
| 62 #endif | 63 #endif |
| 63 #endif | 64 #endif |
| 64 } | 65 } |
| 65 | 66 |
| 66 ProfilePolicyConnectorFactory::~ProfilePolicyConnectorFactory() { | 67 ProfilePolicyConnectorFactory::~ProfilePolicyConnectorFactory() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 82 Profile* profile, | 83 Profile* profile, |
| 83 bool force_immediate_load, | 84 bool force_immediate_load, |
| 84 base::SequencedTaskRunner* sequenced_task_runner) { | 85 base::SequencedTaskRunner* sequenced_task_runner) { |
| 85 DCHECK(connectors_.find(profile) == connectors_.end()); | 86 DCHECK(connectors_.find(profile) == connectors_.end()); |
| 86 ProfilePolicyConnector* connector = new ProfilePolicyConnector(profile); | 87 ProfilePolicyConnector* connector = new ProfilePolicyConnector(profile); |
| 87 connector->Init(force_immediate_load, sequenced_task_runner); | 88 connector->Init(force_immediate_load, sequenced_task_runner); |
| 88 connectors_[profile] = connector; | 89 connectors_[profile] = connector; |
| 89 return scoped_ptr<ProfilePolicyConnector>(connector); | 90 return scoped_ptr<ProfilePolicyConnector>(connector); |
| 90 } | 91 } |
| 91 | 92 |
| 92 void ProfilePolicyConnectorFactory::ProfileShutdown( | 93 void ProfilePolicyConnectorFactory::BrowserContextShutdown( |
| 93 content::BrowserContext* context) { | 94 content::BrowserContext* context) { |
| 94 Profile* profile = static_cast<Profile*>(context); | 95 Profile* profile = static_cast<Profile*>(context); |
| 95 if (profile->IsOffTheRecord()) | 96 if (profile->IsOffTheRecord()) |
| 96 return; | 97 return; |
| 97 ConnectorMap::iterator it = connectors_.find(profile); | 98 ConnectorMap::iterator it = connectors_.find(profile); |
| 98 if (it != connectors_.end()) | 99 if (it != connectors_.end()) |
| 99 it->second->Shutdown(); | 100 it->second->Shutdown(); |
| 100 } | 101 } |
| 101 | 102 |
| 102 void ProfilePolicyConnectorFactory::ProfileDestroyed( | 103 void ProfilePolicyConnectorFactory::BrowserContextDestroyed( |
| 103 content::BrowserContext* context) { | 104 content::BrowserContext* context) { |
| 104 ConnectorMap::iterator it = connectors_.find(static_cast<Profile*>(context)); | 105 ConnectorMap::iterator it = connectors_.find(static_cast<Profile*>(context)); |
| 105 if (it != connectors_.end()) | 106 if (it != connectors_.end()) |
| 106 connectors_.erase(it); | 107 connectors_.erase(it); |
| 107 ProfileKeyedBaseFactory::ProfileDestroyed(context); | 108 BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); |
| 108 } | 109 } |
| 109 | 110 |
| 110 void ProfilePolicyConnectorFactory::RegisterUserPrefs( | 111 void ProfilePolicyConnectorFactory::RegisterUserPrefs( |
| 111 user_prefs::PrefRegistrySyncable* registry) { | 112 user_prefs::PrefRegistrySyncable* registry) { |
| 112 #if defined(OS_CHROMEOS) | 113 #if defined(OS_CHROMEOS) |
| 113 registry->RegisterBooleanPref( | 114 registry->RegisterBooleanPref( |
| 114 prefs::kUsedPolicyCertificatesOnce, | 115 prefs::kUsedPolicyCertificatesOnce, |
| 115 false, | 116 false, |
| 116 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 117 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 117 #endif | 118 #endif |
| 118 } | 119 } |
| 119 | 120 |
| 120 void ProfilePolicyConnectorFactory::SetEmptyTestingFactory( | 121 void ProfilePolicyConnectorFactory::SetEmptyTestingFactory( |
| 121 content::BrowserContext* context) {} | 122 content::BrowserContext* context) {} |
| 122 | 123 |
| 123 void ProfilePolicyConnectorFactory::CreateServiceNow( | 124 void ProfilePolicyConnectorFactory::CreateServiceNow( |
| 124 content::BrowserContext* context) {} | 125 content::BrowserContext* context) {} |
| 125 | 126 |
| 126 } // namespace policy | 127 } // namespace policy |
| OLD | NEW |