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/cloud/component_cloud_policy_service.h" | 5 #include "chrome/browser/policy/cloud/component_cloud_policy_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 } | 139 } |
140 | 140 |
141 void ComponentCloudPolicyService::Backend::Init( | 141 void ComponentCloudPolicyService::Backend::Init( |
142 scoped_refptr<SchemaMap> schema_map) { | 142 scoped_refptr<SchemaMap> schema_map) { |
143 DCHECK(!schema_map_); | 143 DCHECK(!schema_map_); |
144 | 144 |
145 OnSchemasUpdated(schema_map, scoped_ptr<PolicyNamespaceList>()); | 145 OnSchemasUpdated(schema_map, scoped_ptr<PolicyNamespaceList>()); |
146 | 146 |
147 // Read the initial policy. Note that this does not trigger notifications | 147 // Read the initial policy. Note that this does not trigger notifications |
148 // through OnComponentCloudPolicyStoreUpdated. | 148 // through OnComponentCloudPolicyStoreUpdated. Note also that the cached |
| 149 // data may contain names or values that don't match the schema for that |
| 150 // component; the data must be cached without modifications so that its |
| 151 // integrity can be verified using the hash, but it must also be filtered |
| 152 // right after a Load(). |
149 store_.Load(); | 153 store_.Load(); |
150 scoped_ptr<PolicyBundle> bundle(new PolicyBundle); | 154 scoped_ptr<PolicyBundle> bundle(new PolicyBundle); |
151 bundle->CopyFrom(store_.policy()); | 155 bundle->CopyFrom(store_.policy()); |
| 156 schema_map_->FilterBundle(bundle.get()); |
152 | 157 |
153 // Start downloading any pending data. | 158 // Start downloading any pending data. |
154 updater_.reset(new ComponentCloudPolicyUpdater( | 159 updater_.reset(new ComponentCloudPolicyUpdater( |
155 task_runner_, external_policy_data_fetcher_.Pass(), &store_)); | 160 task_runner_, external_policy_data_fetcher_.Pass(), &store_)); |
156 | 161 |
157 service_task_runner_->PostTask( | 162 service_task_runner_->PostTask( |
158 FROM_HERE, | 163 FROM_HERE, |
159 base::Bind(&ComponentCloudPolicyService::OnBackendInitialized, | 164 base::Bind(&ComponentCloudPolicyService::OnBackendInitialized, |
160 service_, | 165 service_, |
161 base::Passed(&bundle))); | 166 base::Passed(&bundle))); |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 } | 492 } |
488 | 493 |
489 void ComponentCloudPolicyService::OnPolicyUpdated( | 494 void ComponentCloudPolicyService::OnPolicyUpdated( |
490 scoped_ptr<PolicyBundle> policy) { | 495 scoped_ptr<PolicyBundle> policy) { |
491 DCHECK(CalledOnValidThread()); | 496 DCHECK(CalledOnValidThread()); |
492 policy_.Swap(policy.get()); | 497 policy_.Swap(policy.get()); |
493 delegate_->OnComponentCloudPolicyUpdated(); | 498 delegate_->OnComponentCloudPolicyUpdated(); |
494 } | 499 } |
495 | 500 |
496 } // namespace policy | 501 } // namespace policy |
OLD | NEW |