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

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

Issue 10834004: Correct const accessors in base/values.(h|cc) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: One more, Windows-only Created 8 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/policy_loader_win.h" 5 #include "chrome/browser/policy/policy_loader_win.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include <string.h> 9 #include <string.h>
10 10
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 255 }
256 256
257 // Returns the default type for registry entries of |reg_type|, when there is 257 // Returns the default type for registry entries of |reg_type|, when there is
258 // no schema defined type for a policy. 258 // no schema defined type for a policy.
259 base::Value::Type GetDefaultFor(DWORD reg_type) { 259 base::Value::Type GetDefaultFor(DWORD reg_type) {
260 return reg_type == REG_DWORD ? base::Value::TYPE_INTEGER : 260 return reg_type == REG_DWORD ? base::Value::TYPE_INTEGER :
261 base::Value::TYPE_STRING; 261 base::Value::TYPE_STRING;
262 } 262 }
263 263
264 // Returns the entry with key |name| in |dictionary| (can be NULL), or NULL. 264 // Returns the entry with key |name| in |dictionary| (can be NULL), or NULL.
265 base::DictionaryValue* GetEntry(const base::DictionaryValue* dictionary, 265 const base::DictionaryValue* GetEntry(const base::DictionaryValue* dictionary,
266 const std::string& name) { 266 const std::string& name) {
267 if (!dictionary) 267 if (!dictionary)
268 return NULL; 268 return NULL;
269 base::DictionaryValue* entry = NULL; 269 const base::DictionaryValue* entry = NULL;
270 dictionary->GetDictionary(name, &entry); 270 dictionary->GetDictionary(name, &entry);
271 return entry; 271 return entry;
272 } 272 }
273 273
274 // Returns the schema for property |name| given the |schema| of an object. 274 // Returns the schema for property |name| given the |schema| of an object.
275 // Returns the "additionalProperties" schema if no specific schema for 275 // Returns the "additionalProperties" schema if no specific schema for
276 // |name| is present. Returns NULL if no schema is found. 276 // |name| is present. Returns NULL if no schema is found.
277 base::DictionaryValue* GetSchemaFor(const base::DictionaryValue* schema, 277 const base::DictionaryValue* GetSchemaFor(const base::DictionaryValue* schema,
278 const std::string& name) { 278 const std::string& name) {
279 base::DictionaryValue* properties = GetEntry(schema, kProperties); 279 const base::DictionaryValue* properties = GetEntry(schema, kProperties);
280 base::DictionaryValue* sub_schema = GetEntry(properties, name); 280 const base::DictionaryValue* sub_schema = GetEntry(properties, name);
281 if (sub_schema) 281 if (sub_schema)
282 return sub_schema; 282 return sub_schema;
283 // "additionalProperties" can be a boolean, but that case is ignored. 283 // "additionalProperties" can be a boolean, but that case is ignored.
284 return GetEntry(schema, kAdditionalProperties); 284 return GetEntry(schema, kAdditionalProperties);
285 } 285 }
286 286
287 // Converts string |value| to another |type|, if possible. 287 // Converts string |value| to another |type|, if possible.
288 base::Value* ConvertComponentStringValue(const string16& value, 288 base::Value* ConvertComponentStringValue(const string16& value,
289 base::Value::Type type) { 289 base::Value::Type type) {
290 switch (type) { 290 switch (type) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 462
463 for (RegistryKeyIterator it(hive, path.c_str()); it.Valid(); ++it) { 463 for (RegistryKeyIterator it(hive, path.c_str()); it.Valid(); ++it) {
464 string16 name16(it.Name()); 464 string16 name16(it.Name());
465 std::string name(UTF16ToUTF8(name16)); 465 std::string name(UTF16ToUTF8(name16));
466 if (dict->HasKey(name)) { 466 if (dict->HasKey(name)) {
467 DLOG(WARNING) << "Ignoring registry key because a value exists with the " 467 DLOG(WARNING) << "Ignoring registry key because a value exists with the "
468 "same name: " << path << kPathSep << name; 468 "same name: " << path << kPathSep << name;
469 continue; 469 continue;
470 } 470 }
471 471
472 base::DictionaryValue* sub_schema = GetSchemaFor(schema, name); 472 const base::DictionaryValue* sub_schema = GetSchemaFor(schema, name);
473 base::Value::Type type = GetType(sub_schema, base::Value::TYPE_DICTIONARY); 473 base::Value::Type type = GetType(sub_schema, base::Value::TYPE_DICTIONARY);
474 base::Value* value = NULL; 474 base::Value* value = NULL;
475 const string16 sub_path = path + kPathSep + name16; 475 const string16 sub_path = path + kPathSep + name16;
476 if (type == base::Value::TYPE_DICTIONARY) { 476 if (type == base::Value::TYPE_DICTIONARY) {
477 value = ReadComponentDictionaryValue(hive, sub_path, sub_schema); 477 value = ReadComponentDictionaryValue(hive, sub_path, sub_schema);
478 } else if (type == base::Value::TYPE_LIST) { 478 } else if (type == base::Value::TYPE_LIST) {
479 value = ReadComponentListValue(hive, sub_path, sub_schema); 479 value = ReadComponentListValue(hive, sub_path, sub_schema);
480 } else { 480 } else {
481 DLOG(WARNING) << "Can't read a simple type in registry key at " << path; 481 DLOG(WARNING) << "Can't read a simple type in registry key at " << path;
482 } 482 }
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 680
681 void PolicyLoaderWin::OnObjectSignaled(HANDLE object) { 681 void PolicyLoaderWin::OnObjectSignaled(HANDLE object) {
682 DCHECK(object == user_policy_changed_event_.handle() || 682 DCHECK(object == user_policy_changed_event_.handle() ||
683 object == machine_policy_changed_event_.handle()) 683 object == machine_policy_changed_event_.handle())
684 << "unexpected object signaled policy reload, obj = " 684 << "unexpected object signaled policy reload, obj = "
685 << std::showbase << std::hex << object; 685 << std::showbase << std::hex << object;
686 Reload(false); 686 Reload(false);
687 } 687 }
688 688
689 } // namespace policy 689 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698