| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chrome_browser_policy_connector.h" | 5 #include "chrome/browser/policy/chrome_browser_policy_connector.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
| 8 | 9 |
| 9 #include "base/callback.h" | 10 #include "base/callback.h" |
| 10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/path_service.h" | 15 #include "base/path_service.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
| 16 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 17 #include "chrome/browser/policy/configuration_policy_handler_list_factory.h" | 18 #include "chrome/browser/policy/configuration_policy_handler_list_factory.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 PrefService* local_state, | 77 PrefService* local_state, |
| 77 scoped_refptr<net::URLRequestContextGetter> request_context) { | 78 scoped_refptr<net::URLRequestContextGetter> request_context) { |
| 78 // Initialization of some of the providers requires the FILE thread; make | 79 // Initialization of some of the providers requires the FILE thread; make |
| 79 // sure that threading is ready at this point. | 80 // sure that threading is ready at this point. |
| 80 DCHECK(BrowserThread::IsThreadInitialized(BrowserThread::FILE)); | 81 DCHECK(BrowserThread::IsThreadInitialized(BrowserThread::FILE)); |
| 81 | 82 |
| 82 scoped_ptr<DeviceManagementService::Configuration> configuration( | 83 scoped_ptr<DeviceManagementService::Configuration> configuration( |
| 83 new DeviceManagementServiceConfiguration( | 84 new DeviceManagementServiceConfiguration( |
| 84 BrowserPolicyConnector::GetDeviceManagementUrl())); | 85 BrowserPolicyConnector::GetDeviceManagementUrl())); |
| 85 scoped_ptr<DeviceManagementService> device_management_service( | 86 scoped_ptr<DeviceManagementService> device_management_service( |
| 86 new DeviceManagementService(configuration.Pass())); | 87 new DeviceManagementService(std::move(configuration))); |
| 87 device_management_service->ScheduleInitialization( | 88 device_management_service->ScheduleInitialization( |
| 88 kServiceInitializationStartupDelay); | 89 kServiceInitializationStartupDelay); |
| 89 | 90 |
| 90 InitInternal(local_state, device_management_service.Pass()); | 91 InitInternal(local_state, std::move(device_management_service)); |
| 91 } | 92 } |
| 92 | 93 |
| 93 ConfigurationPolicyProvider* | 94 ConfigurationPolicyProvider* |
| 94 ChromeBrowserPolicyConnector::CreatePlatformProvider() { | 95 ChromeBrowserPolicyConnector::CreatePlatformProvider() { |
| 95 #if defined(OS_WIN) | 96 #if defined(OS_WIN) |
| 96 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( | 97 scoped_ptr<AsyncPolicyLoader> loader(PolicyLoaderWin::Create( |
| 97 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 98 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 98 kRegistryChromePolicyKey)); | 99 kRegistryChromePolicyKey)); |
| 99 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); | 100 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); |
| 100 #elif defined(OS_MACOSX) | 101 #elif defined(OS_MACOSX) |
| 101 scoped_ptr<AsyncPolicyLoader> loader(new PolicyLoaderMac( | 102 scoped_ptr<AsyncPolicyLoader> loader(new PolicyLoaderMac( |
| 102 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 103 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 103 GetManagedPolicyPath(), | 104 GetManagedPolicyPath(), |
| 104 new MacPreferences())); | 105 new MacPreferences())); |
| 105 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); | 106 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); |
| 106 #elif defined(OS_POSIX) && !defined(OS_ANDROID) | 107 #elif defined(OS_POSIX) && !defined(OS_ANDROID) |
| 107 base::FilePath config_dir_path; | 108 base::FilePath config_dir_path; |
| 108 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { | 109 if (PathService::Get(chrome::DIR_POLICY_FILES, &config_dir_path)) { |
| 109 scoped_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader( | 110 scoped_ptr<AsyncPolicyLoader> loader(new ConfigDirPolicyLoader( |
| 110 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 111 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
| 111 config_dir_path, | 112 config_dir_path, |
| 112 POLICY_SCOPE_MACHINE)); | 113 POLICY_SCOPE_MACHINE)); |
| 113 return new AsyncPolicyProvider(GetSchemaRegistry(), loader.Pass()); | 114 return new AsyncPolicyProvider(GetSchemaRegistry(), std::move(loader)); |
| 114 } else { | 115 } else { |
| 115 return NULL; | 116 return NULL; |
| 116 } | 117 } |
| 117 #elif defined(OS_ANDROID) | 118 #elif defined(OS_ANDROID) |
| 118 return new policy::android::AndroidCombinedPolicyProvider( | 119 return new policy::android::AndroidCombinedPolicyProvider( |
| 119 GetSchemaRegistry()); | 120 GetSchemaRegistry()); |
| 120 #else | 121 #else |
| 121 return NULL; | 122 return NULL; |
| 122 #endif | 123 #endif |
| 123 } | 124 } |
| 124 | 125 |
| 125 } // namespace policy | 126 } // namespace policy |
| OLD | NEW |