Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(798)

Side by Side Diff: components/policy/core/common/cloud/component_cloud_policy_store.cc

Issue 1323923002: Remove use of JSONReader::DeprecatedRead from components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Error fix Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698