| 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("ProfilePolicyConnector", |
| 56 ProfileDependencyManager::GetInstance()) { | 56 BrowserContextDependencyManager::GetInstance()) { |
| 57 #if defined(ENABLE_CONFIGURATION_POLICY) | 57 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 58 #if defined(OS_CHROMEOS) | 58 #if defined(OS_CHROMEOS) |
| 59 DependsOn(UserCloudPolicyManagerFactoryChromeOS::GetInstance()); | 59 DependsOn(UserCloudPolicyManagerFactoryChromeOS::GetInstance()); |
| 60 #else | 60 #else |
| 61 DependsOn(UserCloudPolicyManagerFactory::GetInstance()); | 61 DependsOn(UserCloudPolicyManagerFactory::GetInstance()); |
| 62 #endif | 62 #endif |
| 63 #endif | 63 #endif |
| 64 } | 64 } |
| 65 | 65 |
| 66 ProfilePolicyConnectorFactory::~ProfilePolicyConnectorFactory() { | 66 ProfilePolicyConnectorFactory::~ProfilePolicyConnectorFactory() { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 82 Profile* profile, | 82 Profile* profile, |
| 83 bool force_immediate_load, | 83 bool force_immediate_load, |
| 84 base::SequencedTaskRunner* sequenced_task_runner) { | 84 base::SequencedTaskRunner* sequenced_task_runner) { |
| 85 DCHECK(connectors_.find(profile) == connectors_.end()); | 85 DCHECK(connectors_.find(profile) == connectors_.end()); |
| 86 ProfilePolicyConnector* connector = new ProfilePolicyConnector(profile); | 86 ProfilePolicyConnector* connector = new ProfilePolicyConnector(profile); |
| 87 connector->Init(force_immediate_load, sequenced_task_runner); | 87 connector->Init(force_immediate_load, sequenced_task_runner); |
| 88 connectors_[profile] = connector; | 88 connectors_[profile] = connector; |
| 89 return scoped_ptr<ProfilePolicyConnector>(connector); | 89 return scoped_ptr<ProfilePolicyConnector>(connector); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void ProfilePolicyConnectorFactory::ProfileShutdown( | 92 void ProfilePolicyConnectorFactory::BrowserContextShutdown( |
| 93 content::BrowserContext* context) { | 93 content::BrowserContext* context) { |
| 94 Profile* profile = static_cast<Profile*>(context); | 94 Profile* profile = static_cast<Profile*>(context); |
| 95 if (profile->IsOffTheRecord()) | 95 if (profile->IsOffTheRecord()) |
| 96 return; | 96 return; |
| 97 ConnectorMap::iterator it = connectors_.find(profile); | 97 ConnectorMap::iterator it = connectors_.find(profile); |
| 98 if (it != connectors_.end()) | 98 if (it != connectors_.end()) |
| 99 it->second->Shutdown(); | 99 it->second->Shutdown(); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void ProfilePolicyConnectorFactory::ProfileDestroyed( | 102 void ProfilePolicyConnectorFactory::BrowserContextDestroyed( |
| 103 content::BrowserContext* context) { | 103 content::BrowserContext* context) { |
| 104 ConnectorMap::iterator it = connectors_.find(static_cast<Profile*>(context)); | 104 ConnectorMap::iterator it = connectors_.find(static_cast<Profile*>(context)); |
| 105 if (it != connectors_.end()) | 105 if (it != connectors_.end()) |
| 106 connectors_.erase(it); | 106 connectors_.erase(it); |
| 107 ProfileKeyedBaseFactory::ProfileDestroyed(context); | 107 BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void ProfilePolicyConnectorFactory::RegisterUserPrefs( | 110 void ProfilePolicyConnectorFactory::RegisterUserPrefs( |
| 111 user_prefs::PrefRegistrySyncable* registry) { | 111 user_prefs::PrefRegistrySyncable* registry) { |
| 112 #if defined(OS_CHROMEOS) | 112 #if defined(OS_CHROMEOS) |
| 113 registry->RegisterBooleanPref( | 113 registry->RegisterBooleanPref( |
| 114 prefs::kUsedPolicyCertificatesOnce, | 114 prefs::kUsedPolicyCertificatesOnce, |
| 115 false, | 115 false, |
| 116 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 116 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 117 #endif | 117 #endif |
| 118 } | 118 } |
| 119 | 119 |
| 120 void ProfilePolicyConnectorFactory::SetEmptyTestingFactory( | 120 void ProfilePolicyConnectorFactory::SetEmptyTestingFactory( |
| 121 content::BrowserContext* context) {} | 121 content::BrowserContext* context) {} |
| 122 | 122 |
| 123 void ProfilePolicyConnectorFactory::CreateServiceNow( | 123 void ProfilePolicyConnectorFactory::CreateServiceNow( |
| 124 content::BrowserContext* context) {} | 124 content::BrowserContext* context) {} |
| 125 | 125 |
| 126 } // namespace policy | 126 } // namespace policy |
| OLD | NEW |