| 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/policy/cloud/user_cloud_policy_manager_factory.h" | 5 #include "chrome/browser/policy/cloud/user_cloud_policy_manager_factory.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" |
| 12 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
| 13 #include "base/threading/thread_task_runner_handle.h" | 14 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "chrome/browser/policy/schema_registry_service.h" | 15 #include "chrome/browser/policy/schema_registry_service.h" |
| 15 #include "chrome/browser/policy/schema_registry_service_factory.h" | 16 #include "chrome/browser/policy/schema_registry_service_factory.h" |
| 16 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 17 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 17 #include "components/keyed_service/core/keyed_service.h" | 18 #include "components/keyed_service/core/keyed_service.h" |
| 18 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" | 19 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" |
| 19 #include "components/policy/core/common/cloud/cloud_policy_constants.h" | 20 #include "components/policy/core/common/cloud/cloud_policy_constants.h" |
| 20 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" | 21 #include "components/policy/core/common/cloud/user_cloud_policy_manager.h" |
| 21 #include "components/policy/core/common/cloud/user_cloud_policy_store.h" | 22 #include "components/policy/core/common/cloud/user_cloud_policy_store.h" |
| 22 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
| 23 | 24 |
| 25 #if defined(OS_ANDROID) |
| 26 #include "chrome/browser/android/chrome_feature_list.h" |
| 27 #endif |
| 28 |
| 24 namespace policy { | 29 namespace policy { |
| 25 | 30 |
| 26 namespace { | 31 namespace { |
| 27 | 32 |
| 28 // Directory inside the profile directory where policy-related resources are | 33 // Directory inside the profile directory where policy-related resources are |
| 29 // stored. | 34 // stored. |
| 30 const base::FilePath::CharType kPolicy[] = FILE_PATH_LITERAL("Policy"); | 35 const base::FilePath::CharType kPolicy[] = FILE_PATH_LITERAL("Policy"); |
| 31 | 36 |
| 32 // Directory under kPolicy, in the user's profile dir, where policy for | 37 // Directory under kPolicy, in the user's profile dir, where policy for |
| 33 // components is cached. | 38 // components is cached. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 DCHECK(!testing_factory_); | 149 DCHECK(!testing_factory_); |
| 145 | 150 |
| 146 std::unique_ptr<UserCloudPolicyStore> store( | 151 std::unique_ptr<UserCloudPolicyStore> store( |
| 147 UserCloudPolicyStore::Create(context->GetPath(), background_task_runner)); | 152 UserCloudPolicyStore::Create(context->GetPath(), background_task_runner)); |
| 148 if (force_immediate_load) | 153 if (force_immediate_load) |
| 149 store->LoadImmediately(); | 154 store->LoadImmediately(); |
| 150 | 155 |
| 151 const base::FilePath component_policy_cache_dir = | 156 const base::FilePath component_policy_cache_dir = |
| 152 context->GetPath().Append(kPolicy).Append(kComponentsDir); | 157 context->GetPath().Append(kPolicy).Append(kComponentsDir); |
| 153 | 158 |
| 154 std::unique_ptr<UserCloudPolicyManager> manager; | 159 auto manager = base::MakeUnique<UserCloudPolicyManager>( |
| 155 manager.reset(new UserCloudPolicyManager( | |
| 156 std::move(store), component_policy_cache_dir, | 160 std::move(store), component_policy_cache_dir, |
| 157 std::unique_ptr<CloudExternalDataManager>(), | 161 std::unique_ptr<CloudExternalDataManager>(), |
| 158 base::ThreadTaskRunnerHandle::Get(), file_task_runner, io_task_runner)); | 162 base::ThreadTaskRunnerHandle::Get(), file_task_runner, io_task_runner); |
| 163 |
| 164 #if defined(OS_ANDROID) |
| 165 // TODO(treib): Remove this again. crbug.com/708191 |
| 166 if (base::FeatureList::IsEnabled(chrome::android::kChromeHomeFeature)) |
| 167 manager->SetChromeHomeEnabled(); |
| 168 #endif |
| 159 manager->Init( | 169 manager->Init( |
| 160 SchemaRegistryServiceFactory::GetForContext(context)->registry()); | 170 SchemaRegistryServiceFactory::GetForContext(context)->registry()); |
| 161 manager_wrappers_[context] = new ManagerWrapper(manager.get()); | 171 manager_wrappers_[context] = new ManagerWrapper(manager.get()); |
| 162 return manager; | 172 return manager; |
| 163 } | 173 } |
| 164 | 174 |
| 165 UserCloudPolicyManager* | 175 UserCloudPolicyManager* |
| 166 UserCloudPolicyManagerFactory::RegisterManagerForOffTheRecordBrowserContext( | 176 UserCloudPolicyManagerFactory::RegisterManagerForOffTheRecordBrowserContext( |
| 167 content::BrowserContext* original_context, | 177 content::BrowserContext* original_context, |
| 168 content::BrowserContext* off_the_record_context) { | 178 content::BrowserContext* off_the_record_context) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 return testing_factory_ != NULL; | 218 return testing_factory_ != NULL; |
| 209 } | 219 } |
| 210 | 220 |
| 211 void UserCloudPolicyManagerFactory::CreateServiceNow( | 221 void UserCloudPolicyManagerFactory::CreateServiceNow( |
| 212 content::BrowserContext* context) { | 222 content::BrowserContext* context) { |
| 213 DCHECK(testing_factory_); | 223 DCHECK(testing_factory_); |
| 214 manager_wrappers_[context] = new ManagerWrapper(testing_factory_(context)); | 224 manager_wrappers_[context] = new ManagerWrapper(testing_factory_(context)); |
| 215 } | 225 } |
| 216 | 226 |
| 217 } // namespace policy | 227 } // namespace policy |
| OLD | NEW |