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

Side by Side Diff: chrome/browser/policy/component_cloud_policy_store.cc

Issue 12601006: Removing base::DictionaryValue::key_iterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Initial patch. Created 7 years, 9 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 | Annotate | Revision Log
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 "chrome/browser/policy/component_cloud_policy_store.h" 5 #include "chrome/browser/policy/component_cloud_policy_store.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/sha1.h" 9 #include "base/sha1.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 data, base::JSON_PARSE_RFC | base::JSON_DETACHABLE_CHILDREN)); 308 data, base::JSON_PARSE_RFC | base::JSON_DETACHABLE_CHILDREN));
309 base::DictionaryValue* dict = NULL; 309 base::DictionaryValue* dict = NULL;
310 if (!json || !json->GetAsDictionary(&dict)) 310 if (!json || !json->GetAsDictionary(&dict))
311 return false; 311 return false;
312 312
313 // Each top-level key maps a policy name to its description. 313 // Each top-level key maps a policy name to its description.
314 // 314 //
315 // Each description is an object that contains the policy value under the 315 // Each description is an object that contains the policy value under the
316 // "Value" key. The optional "Level" key is either "Mandatory" (default) or 316 // "Value" key. The optional "Level" key is either "Mandatory" (default) or
317 // "Recommended". 317 // "Recommended".
318 for (base::DictionaryValue::key_iterator it = dict->begin_keys(); 318 for (base::DictionaryValue::Iterator it(*dict); !it.IsAtEnd(); it.Advance()) {
319 it != dict->end_keys(); ++it) {
320 base::DictionaryValue* description = NULL; 319 base::DictionaryValue* description = NULL;
321 if (!dict->GetDictionary(*it, &description)) 320 if (!dict->GetDictionaryWithoutPathExpansion(it.key(), &description))
322 return false; 321 return false;
323 322
324 base::Value* value = NULL; 323 base::Value* value = NULL;
325 if (!description->Remove(kValue, &value)) 324 if (!description->RemoveWithoutPathExpansion(kValue, &value))
326 return false; 325 return false;
327 326
328 PolicyLevel level = POLICY_LEVEL_MANDATORY; 327 PolicyLevel level = POLICY_LEVEL_MANDATORY;
329 std::string level_string; 328 std::string level_string;
330 if (description->GetString(kLevel, &level_string) && 329 if (description->GetStringWithoutPathExpansion(kLevel, &level_string) &&
331 level_string == kRecommended) { 330 level_string == kRecommended) {
332 level = POLICY_LEVEL_RECOMMENDED; 331 level = POLICY_LEVEL_RECOMMENDED;
333 } 332 }
334 333
335 // If policy for components is ever used for device-level settings then 334 // If policy for components is ever used for device-level settings then
336 // this must support a configurable scope; assuming POLICY_SCOPE_USER is 335 // this must support a configurable scope; assuming POLICY_SCOPE_USER is
337 // fine for now. 336 // fine for now.
338 policy->Set(*it, level, POLICY_SCOPE_USER, value); 337 policy->Set(it.key(), level, POLICY_SCOPE_USER, value);
339 } 338 }
340 339
341 return true; 340 return true;
342 } 341 }
343 342
344 } // namespace policy 343 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/net/transport_security_persister.cc ('k') | chrome/browser/profiles/profile_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698