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 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
315 // Each top-level key maps a policy name to its description. | 315 // Each top-level key maps a policy name to its description. |
316 // | 316 // |
317 // Each description is an object that contains the policy value under the | 317 // Each description is an object that contains the policy value under the |
318 // "Value" key. The optional "Level" key is either "Mandatory" (default) or | 318 // "Value" key. The optional "Level" key is either "Mandatory" (default) or |
319 // "Recommended". | 319 // "Recommended". |
320 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { | 320 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) { |
321 base::DictionaryValue* description = NULL; | 321 base::DictionaryValue* description = NULL; |
322 if (!dict->GetDictionaryWithoutPathExpansion(it.key(), &description)) | 322 if (!dict->GetDictionaryWithoutPathExpansion(it.key(), &description)) |
323 return false; | 323 return false; |
324 | 324 |
325 base::Value* value = NULL; | 325 scoped_ptr<base::Value> value; |
326 if (!description->RemoveWithoutPathExpansion(kValue, &value)) | 326 if (!description->RemoveWithoutPathExpansion(kValue, &value)) |
327 return false; | 327 return false; |
328 | 328 |
329 PolicyLevel level = POLICY_LEVEL_MANDATORY; | 329 PolicyLevel level = POLICY_LEVEL_MANDATORY; |
330 std::string level_string; | 330 std::string level_string; |
331 if (description->GetStringWithoutPathExpansion(kLevel, &level_string) && | 331 if (description->GetStringWithoutPathExpansion(kLevel, &level_string) && |
332 level_string == kRecommended) { | 332 level_string == kRecommended) { |
333 level = POLICY_LEVEL_RECOMMENDED; | 333 level = POLICY_LEVEL_RECOMMENDED; |
334 } | 334 } |
335 | 335 |
336 // If policy for components is ever used for device-level settings then | 336 // If policy for components is ever used for device-level settings then |
337 // this must support a configurable scope; assuming POLICY_SCOPE_USER is | 337 // this must support a configurable scope; assuming POLICY_SCOPE_USER is |
338 // fine for now. | 338 // fine for now. |
339 policy->Set(it.key(), level, POLICY_SCOPE_USER, value, NULL); | 339 policy->Set(it.key(), level, POLICY_SCOPE_USER, value.release(), NULL); |
340 } | 340 } |
341 | 341 |
342 return true; | 342 return true; |
343 } | 343 } |
344 | 344 |
345 } // namespace policy | 345 } // namespace policy |
OLD | NEW |