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 "components/policy/core/common/cloud/component_cloud_policy_store.h" | 5 #include "components/policy/core/common/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/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 bool ComponentCloudPolicyStore::ValidateData( | 316 bool ComponentCloudPolicyStore::ValidateData( |
317 const std::string& data, | 317 const std::string& data, |
318 const std::string& secure_hash, | 318 const std::string& secure_hash, |
319 PolicyMap* policy) { | 319 PolicyMap* policy) { |
320 return crypto::SHA256HashString(data) == secure_hash && | 320 return crypto::SHA256HashString(data) == secure_hash && |
321 ParsePolicy(data, policy); | 321 ParsePolicy(data, policy); |
322 } | 322 } |
323 | 323 |
324 bool ComponentCloudPolicyStore::ParsePolicy(const std::string& data, | 324 bool ComponentCloudPolicyStore::ParsePolicy(const std::string& data, |
325 PolicyMap* policy) { | 325 PolicyMap* policy) { |
326 scoped_ptr<base::Value> json(base::JSONReader::DeprecatedRead( | 326 scoped_ptr<base::Value> json = base::JSONReader::Read( |
327 data, base::JSON_PARSE_RFC | base::JSON_DETACHABLE_CHILDREN)); | 327 data, base::JSON_PARSE_RFC | base::JSON_DETACHABLE_CHILDREN); |
328 base::DictionaryValue* dict = NULL; | 328 base::DictionaryValue* dict = NULL; |
329 if (!json || !json->GetAsDictionary(&dict)) | 329 if (!json || !json->GetAsDictionary(&dict)) |
330 return false; | 330 return false; |
331 | 331 |
332 // Each top-level key maps a policy name to its description. | 332 // Each top-level key maps a policy name to its description. |
333 // | 333 // |
334 // Each description is an object that contains the policy value under the | 334 // Each description is an object that contains the policy value under the |
335 // "Value" key. The optional "Level" key is either "Mandatory" (default) or | 335 // "Value" key. The optional "Level" key is either "Mandatory" (default) or |
336 // "Recommended". | 336 // "Recommended". |
337 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 337 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
(...skipping 15 matching lines...) Expand all Loading... |
353 // If policy for components is ever used for device-level settings then | 353 // If policy for components is ever used for device-level settings then |
354 // this must support a configurable scope; assuming POLICY_SCOPE_USER is | 354 // this must support a configurable scope; assuming POLICY_SCOPE_USER is |
355 // fine for now. | 355 // fine for now. |
356 policy->Set(it.key(), level, POLICY_SCOPE_USER, value.release(), NULL); | 356 policy->Set(it.key(), level, POLICY_SCOPE_USER, value.release(), NULL); |
357 } | 357 } |
358 | 358 |
359 return true; | 359 return true; |
360 } | 360 } |
361 | 361 |
362 } // namespace policy | 362 } // namespace policy |
OLD | NEW |