| 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_store.h" | 5 #include "chrome/browser/policy/cloud/component_cloud_policy_store.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/sha1.h" | 10 #include "base/sha1.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 cached_hashes_.erase(prev); | 224 cached_hashes_.erase(prev); |
| 225 } else { | 225 } else { |
| 226 ++it; | 226 ++it; |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 | 229 |
| 230 if (purged_current_policies) | 230 if (purged_current_policies) |
| 231 delegate_->OnComponentCloudPolicyStoreUpdated(); | 231 delegate_->OnComponentCloudPolicyStoreUpdated(); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void ComponentCloudPolicyStore::Clear() { |
| 235 for (size_t i = 0; i < arraysize(kDomains); ++i) { |
| 236 cache_->Clear(kDomains[i].proto_cache_key); |
| 237 cache_->Clear(kDomains[i].data_cache_key); |
| 238 } |
| 239 cached_hashes_.clear(); |
| 240 const PolicyBundle empty_bundle; |
| 241 if (!policy_bundle_.Equals(empty_bundle)) { |
| 242 policy_bundle_.Clear(); |
| 243 delegate_->OnComponentCloudPolicyStoreUpdated(); |
| 244 } |
| 245 } |
| 246 |
| 234 bool ComponentCloudPolicyStore::ValidatePolicy( | 247 bool ComponentCloudPolicyStore::ValidatePolicy( |
| 235 scoped_ptr<em::PolicyFetchResponse> proto, | 248 scoped_ptr<em::PolicyFetchResponse> proto, |
| 236 PolicyNamespace* ns, | 249 PolicyNamespace* ns, |
| 237 em::ExternalPolicyData* payload) { | 250 em::ExternalPolicyData* payload) { |
| 238 em::PolicyData policy_data; | 251 em::PolicyData policy_data; |
| 239 if (!ValidateProto( | 252 if (!ValidateProto( |
| 240 proto.Pass(), std::string(), std::string(), payload, &policy_data)) { | 253 proto.Pass(), std::string(), std::string(), payload, &policy_data)) { |
| 241 return false; | 254 return false; |
| 242 } | 255 } |
| 243 | 256 |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 // If policy for components is ever used for device-level settings then | 352 // If policy for components is ever used for device-level settings then |
| 340 // this must support a configurable scope; assuming POLICY_SCOPE_USER is | 353 // this must support a configurable scope; assuming POLICY_SCOPE_USER is |
| 341 // fine for now. | 354 // fine for now. |
| 342 policy->Set(it.key(), level, POLICY_SCOPE_USER, value.release(), NULL); | 355 policy->Set(it.key(), level, POLICY_SCOPE_USER, value.release(), NULL); |
| 343 } | 356 } |
| 344 | 357 |
| 345 return true; | 358 return true; |
| 346 } | 359 } |
| 347 | 360 |
| 348 } // namespace policy | 361 } // namespace policy |
| OLD | NEW |