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/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include "net/url_request/url_request_context_getter.h" | 35 #include "net/url_request/url_request_context_getter.h" |
36 #include "policy/policy_constants.h" | 36 #include "policy/policy_constants.h" |
37 | 37 |
38 namespace policy { | 38 namespace policy { |
39 | 39 |
40 namespace { | 40 namespace { |
41 | 41 |
42 // Subdirectory in the user's profile for storing legacy user policies. | 42 // Subdirectory in the user's profile for storing legacy user policies. |
43 const base::FilePath::CharType kDeviceManagementDir[] = | 43 const base::FilePath::CharType kDeviceManagementDir[] = |
44 FILE_PATH_LITERAL("Device Management"); | 44 FILE_PATH_LITERAL("Device Management"); |
| 45 |
45 // File in the above directory for storing legacy user policy dmtokens. | 46 // File in the above directory for storing legacy user policy dmtokens. |
46 const base::FilePath::CharType kToken[] = FILE_PATH_LITERAL("Token"); | 47 const base::FilePath::CharType kToken[] = FILE_PATH_LITERAL("Token"); |
| 48 |
47 // This constant is used to build two different paths. It can be a file inside | 49 // This constant is used to build two different paths. It can be a file inside |
48 // kDeviceManagementDir where legacy user policy data is stored, and it can be | 50 // kDeviceManagementDir where legacy user policy data is stored, and it can be |
49 // a directory inside the profile directory where other resources are stored. | 51 // a directory inside the profile directory where other resources are stored. |
50 const base::FilePath::CharType kPolicy[] = FILE_PATH_LITERAL("Policy"); | 52 const base::FilePath::CharType kPolicy[] = FILE_PATH_LITERAL("Policy"); |
51 // Directory under kPolicy, in the user's profile dir, where external policy | 53 |
52 // resources are stored. | 54 // Directory under kPolicy, in the user's profile dir, where policy for |
53 const base::FilePath::CharType kResourceDir[] = FILE_PATH_LITERAL("Resources"); | 55 // components is cached. |
| 56 const base::FilePath::CharType kComponentsDir[] = |
| 57 FILE_PATH_LITERAL("Components"); |
| 58 |
54 // Directory in which to store external policy data. This is specified relative | 59 // Directory in which to store external policy data. This is specified relative |
55 // to kPolicy. | 60 // to kPolicy. |
56 const base::FilePath::CharType kPolicyExternalDataDir[] = | 61 const base::FilePath::CharType kPolicyExternalDataDir[] = |
57 FILE_PATH_LITERAL("External Data"); | 62 FILE_PATH_LITERAL("External Data"); |
58 | 63 |
59 // Timeout in seconds after which to abandon the initial policy fetch and start | 64 // Timeout in seconds after which to abandon the initial policy fetch and start |
60 // the session regardless. | 65 // the session regardless. |
61 const int kInitialPolicyFetchTimeoutSeconds = 10; | 66 const int kInitialPolicyFetchTimeoutSeconds = 10; |
62 | 67 |
63 } // namespace | 68 } // namespace |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 | 149 |
145 DeviceManagementService* device_management_service = | 150 DeviceManagementService* device_management_service = |
146 connector->device_management_service(); | 151 connector->device_management_service(); |
147 if (wait_for_initial_policy) | 152 if (wait_for_initial_policy) |
148 device_management_service->ScheduleInitialization(0); | 153 device_management_service->ScheduleInitialization(0); |
149 | 154 |
150 base::FilePath profile_dir = profile->GetPath(); | 155 base::FilePath profile_dir = profile->GetPath(); |
151 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); | 156 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); |
152 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); | 157 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); |
153 const base::FilePath token_cache_file = legacy_dir.Append(kToken); | 158 const base::FilePath token_cache_file = legacy_dir.Append(kToken); |
154 const base::FilePath resource_cache_dir = | 159 const base::FilePath component_policy_cache_dir = |
155 profile_dir.Append(kPolicy).Append(kResourceDir); | 160 profile_dir.Append(kPolicy).Append(kComponentsDir); |
156 const base::FilePath external_data_dir = | 161 const base::FilePath external_data_dir = |
157 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir); | 162 profile_dir.Append(kPolicy).Append(kPolicyExternalDataDir); |
158 base::FilePath policy_key_dir; | 163 base::FilePath policy_key_dir; |
159 CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir)); | 164 CHECK(PathService::Get(chromeos::DIR_USER_POLICY_KEYS, &policy_key_dir)); |
160 | 165 |
161 scoped_ptr<UserCloudPolicyStoreChromeOS> store( | 166 scoped_ptr<UserCloudPolicyStoreChromeOS> store( |
162 new UserCloudPolicyStoreChromeOS( | 167 new UserCloudPolicyStoreChromeOS( |
163 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), | 168 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), |
164 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), | 169 chromeos::DBusThreadManager::Get()->GetSessionManagerClient(), |
165 background_task_runner, | 170 background_task_runner, |
166 username, policy_key_dir, token_cache_file, policy_cache_file)); | 171 username, policy_key_dir, token_cache_file, policy_cache_file)); |
167 | 172 |
168 scoped_refptr<base::SequencedTaskRunner> backend_task_runner = | 173 scoped_refptr<base::SequencedTaskRunner> backend_task_runner = |
169 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 174 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
170 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); | 175 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); |
171 scoped_refptr<base::SequencedTaskRunner> io_task_runner = | 176 scoped_refptr<base::SequencedTaskRunner> io_task_runner = |
172 content::BrowserThread::GetMessageLoopProxyForThread( | 177 content::BrowserThread::GetMessageLoopProxyForThread( |
173 content::BrowserThread::IO); | 178 content::BrowserThread::IO); |
174 scoped_ptr<CloudExternalDataManager> external_data_manager( | 179 scoped_ptr<CloudExternalDataManager> external_data_manager( |
175 new UserCloudExternalDataManager(base::Bind(&GetChromePolicyDetails), | 180 new UserCloudExternalDataManager(base::Bind(&GetChromePolicyDetails), |
176 backend_task_runner, | 181 backend_task_runner, |
177 io_task_runner, | 182 io_task_runner, |
178 external_data_dir, | 183 external_data_dir, |
179 store.get())); | 184 store.get())); |
180 if (force_immediate_load) | 185 if (force_immediate_load) |
181 store->LoadImmediately(); | 186 store->LoadImmediately(); |
182 | 187 |
| 188 scoped_refptr<base::SequencedTaskRunner> file_task_runner = |
| 189 content::BrowserThread::GetMessageLoopProxyForThread( |
| 190 content::BrowserThread::FILE); |
| 191 |
183 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( | 192 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( |
184 new UserCloudPolicyManagerChromeOS( | 193 new UserCloudPolicyManagerChromeOS( |
185 store.PassAs<CloudPolicyStore>(), | 194 store.PassAs<CloudPolicyStore>(), |
186 external_data_manager.Pass(), | 195 external_data_manager.Pass(), |
| 196 component_policy_cache_dir, |
| 197 wait_for_initial_policy, |
| 198 base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds), |
187 base::MessageLoopProxy::current(), | 199 base::MessageLoopProxy::current(), |
188 resource_cache_dir, | 200 file_task_runner, |
189 wait_for_initial_policy, | 201 io_task_runner)); |
190 base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds))); | |
191 manager->Init(SchemaRegistryServiceFactory::GetForContext(profile)); | 202 manager->Init(SchemaRegistryServiceFactory::GetForContext(profile)); |
192 manager->Connect(g_browser_process->local_state(), | 203 manager->Connect(g_browser_process->local_state(), |
193 device_management_service, | 204 device_management_service, |
194 g_browser_process->system_request_context(), | 205 g_browser_process->system_request_context(), |
195 affiliation); | 206 affiliation); |
196 | 207 |
197 DCHECK(managers_.find(profile) == managers_.end()); | 208 DCHECK(managers_.find(profile) == managers_.end()); |
198 managers_[profile] = manager.get(); | 209 managers_[profile] = manager.get(); |
199 return manager.Pass(); | 210 return manager.Pass(); |
200 } | 211 } |
(...skipping 15 matching lines...) Expand all Loading... |
216 BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); | 227 BrowserContextKeyedBaseFactory::BrowserContextDestroyed(context); |
217 } | 228 } |
218 | 229 |
219 void UserCloudPolicyManagerFactoryChromeOS::SetEmptyTestingFactory( | 230 void UserCloudPolicyManagerFactoryChromeOS::SetEmptyTestingFactory( |
220 content::BrowserContext* context) {} | 231 content::BrowserContext* context) {} |
221 | 232 |
222 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( | 233 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( |
223 content::BrowserContext* context) {} | 234 content::BrowserContext* context) {} |
224 | 235 |
225 } // namespace policy | 236 } // namespace policy |
OLD | NEW |