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/chromeos/policy/device_local_account_policy_service.h" | 5 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 scoped_refptr<net::URLRequestContextGetter> request_context) { | 166 scoped_refptr<net::URLRequestContextGetter> request_context) { |
167 if (core_.client()) | 167 if (core_.client()) |
168 return; | 168 return; |
169 | 169 |
170 scoped_ptr<CloudPolicyClient> client(CreateClient(device_settings_service, | 170 scoped_ptr<CloudPolicyClient> client(CreateClient(device_settings_service, |
171 device_management_service, | 171 device_management_service, |
172 request_context)); | 172 request_context)); |
173 if (!client) | 173 if (!client) |
174 return; | 174 return; |
175 | 175 |
| 176 CreateComponentCloudPolicyService(request_context, client.get()); |
176 core_.Connect(client.Pass()); | 177 core_.Connect(client.Pass()); |
177 external_data_manager_->Connect(request_context); | 178 external_data_manager_->Connect(request_context); |
178 core_.StartRefreshScheduler(); | 179 core_.StartRefreshScheduler(); |
179 UpdateRefreshDelay(); | 180 UpdateRefreshDelay(); |
180 CreateComponentCloudPolicyService(request_context); | |
181 } | 181 } |
182 | 182 |
183 void DeviceLocalAccountPolicyBroker::UpdateRefreshDelay() { | 183 void DeviceLocalAccountPolicyBroker::UpdateRefreshDelay() { |
184 if (core_.refresh_scheduler()) { | 184 if (core_.refresh_scheduler()) { |
185 const base::Value* policy_value = | 185 const base::Value* policy_value = |
186 store_->policy_map().GetValue(key::kPolicyRefreshRate); | 186 store_->policy_map().GetValue(key::kPolicyRefreshRate); |
187 int delay = 0; | 187 int delay = 0; |
188 if (policy_value && policy_value->GetAsInteger(&delay)) | 188 if (policy_value && policy_value->GetAsInteger(&delay)) |
189 core_.refresh_scheduler()->SetRefreshDelay(delay); | 189 core_.refresh_scheduler()->SetRefreshDelay(delay); |
190 } | 190 } |
(...skipping 15 matching lines...) Expand all Loading... |
206 | 206 |
207 void DeviceLocalAccountPolicyBroker::OnStoreError(CloudPolicyStore* store) { | 207 void DeviceLocalAccountPolicyBroker::OnStoreError(CloudPolicyStore* store) { |
208 policy_update_callback_.Run(); | 208 policy_update_callback_.Run(); |
209 } | 209 } |
210 | 210 |
211 void DeviceLocalAccountPolicyBroker::OnComponentCloudPolicyUpdated() { | 211 void DeviceLocalAccountPolicyBroker::OnComponentCloudPolicyUpdated() { |
212 policy_update_callback_.Run(); | 212 policy_update_callback_.Run(); |
213 } | 213 } |
214 | 214 |
215 void DeviceLocalAccountPolicyBroker::CreateComponentCloudPolicyService( | 215 void DeviceLocalAccountPolicyBroker::CreateComponentCloudPolicyService( |
216 const scoped_refptr<net::URLRequestContextGetter>& request_context) { | 216 const scoped_refptr<net::URLRequestContextGetter>& request_context, |
| 217 CloudPolicyClient* client) { |
217 if (CommandLine::ForCurrentProcess()->HasSwitch( | 218 if (CommandLine::ForCurrentProcess()->HasSwitch( |
218 switches::kDisableComponentCloudPolicy)) { | 219 switches::kDisableComponentCloudPolicy)) { |
219 // Disabled via the command line. | 220 // Disabled via the command line. |
220 return; | 221 return; |
221 } | 222 } |
222 | 223 |
223 scoped_ptr<ResourceCache> resource_cache( | 224 scoped_ptr<ResourceCache> resource_cache( |
224 new ResourceCache(component_policy_cache_path_, | 225 new ResourceCache(component_policy_cache_path_, |
225 content::BrowserThread::GetMessageLoopProxyForThread( | 226 content::BrowserThread::GetMessageLoopProxyForThread( |
226 content::BrowserThread::FILE))); | 227 content::BrowserThread::FILE))); |
227 | 228 |
228 component_policy_service_.reset(new ComponentCloudPolicyService( | 229 component_policy_service_.reset(new ComponentCloudPolicyService( |
229 this, | 230 this, |
230 &schema_registry_, | 231 &schema_registry_, |
231 core(), | 232 core(), |
| 233 client, |
232 resource_cache.Pass(), | 234 resource_cache.Pass(), |
233 request_context, | 235 request_context, |
234 content::BrowserThread::GetMessageLoopProxyForThread( | 236 content::BrowserThread::GetMessageLoopProxyForThread( |
235 content::BrowserThread::FILE), | 237 content::BrowserThread::FILE), |
236 content::BrowserThread::GetMessageLoopProxyForThread( | 238 content::BrowserThread::GetMessageLoopProxyForThread( |
237 content::BrowserThread::IO))); | 239 content::BrowserThread::IO))); |
238 } | 240 } |
239 | 241 |
240 DeviceLocalAccountPolicyService::DeviceLocalAccountPolicyService( | 242 DeviceLocalAccountPolicyService::DeviceLocalAccountPolicyService( |
241 chromeos::SessionManagerClient* session_manager_client, | 243 chromeos::SessionManagerClient* session_manager_client, |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 } | 560 } |
559 return nullptr; | 561 return nullptr; |
560 } | 562 } |
561 | 563 |
562 void DeviceLocalAccountPolicyService::NotifyPolicyUpdated( | 564 void DeviceLocalAccountPolicyService::NotifyPolicyUpdated( |
563 const std::string& user_id) { | 565 const std::string& user_id) { |
564 FOR_EACH_OBSERVER(Observer, observers_, OnPolicyUpdated(user_id)); | 566 FOR_EACH_OBSERVER(Observer, observers_, OnPolicyUpdated(user_id)); |
565 } | 567 } |
566 | 568 |
567 } // namespace policy | 569 } // namespace policy |
OLD | NEW |