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

Side by Side Diff: components/policy/core/common/registry_dict_win.h

Issue 102493002: Use schemas bundled in extensions to convert policies loaded on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 #ifndef COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_ 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_
7 7
8 #include <windows.h> 8 #include <windows.h>
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/strings/string16.h" 15 #include "base/strings/string16.h"
16 #include "components/policy/policy_export.h" 16 #include "components/policy/policy_export.h"
17 17
18 namespace base { 18 namespace base {
19 class DictionaryValue;
20 class Value; 19 class Value;
21 } 20 }
22 21
23 namespace policy { 22 namespace policy {
24 23
24 class Schema;
25
25 // A case-insensitive string comparison functor. 26 // A case-insensitive string comparison functor.
26 struct POLICY_EXPORT CaseInsensitiveStringCompare { 27 struct POLICY_EXPORT CaseInsensitiveStringCompare {
27 bool operator()(const std::string& a, const std::string& b) const; 28 bool operator()(const std::string& a, const std::string& b) const;
28 }; 29 };
29 30
30 // In-memory representation of a registry subtree. Using a 31 // In-memory representation of a registry subtree. Using a
31 // base::DictionaryValue directly seems tempting, but that doesn't handle the 32 // base::DictionaryValue directly seems tempting, but that doesn't handle the
32 // registry's case-insensitive-but-case-preserving semantics properly. 33 // registry's case-insensitive-but-case-preserving semantics properly.
33 class POLICY_EXPORT RegistryDict { 34 class POLICY_EXPORT RegistryDict {
34 public: 35 public:
(...skipping 28 matching lines...) Expand all
63 // Merge keys and values from |other|, giving precedence to |other|. 64 // Merge keys and values from |other|, giving precedence to |other|.
64 void Merge(const RegistryDict& other); 65 void Merge(const RegistryDict& other);
65 66
66 // Swap with |other|. 67 // Swap with |other|.
67 void Swap(RegistryDict* other); 68 void Swap(RegistryDict* other);
68 69
69 // Read a Windows registry subtree into this registry dictionary object. 70 // Read a Windows registry subtree into this registry dictionary object.
70 void ReadRegistry(HKEY hive, const base::string16& root); 71 void ReadRegistry(HKEY hive, const base::string16& root);
71 72
72 // Converts the dictionary to base::Value representation. For key/value name 73 // Converts the dictionary to base::Value representation. For key/value name
73 // collisions, the key wins. |schema| supplies an optional JSON schema that 74 // collisions, the key wins. |schema| is used to determine the expected type
74 // will be used to map types to base::Value types. The returned object is 75 // for each policy.
75 // either a base::DictionaryValue or a base::ListValue. 76 // The returned object is either a base::DictionaryValue or a base::ListValue.
76 scoped_ptr<base::Value> ConvertToJSON( 77 scoped_ptr<base::Value> ConvertToJSON(const Schema& schema) const;
77 const base::DictionaryValue* schema) const;
78 78
79 const KeyMap& keys() const { return keys_; } 79 const KeyMap& keys() const { return keys_; }
80 const ValueMap& values() const { return values_; } 80 const ValueMap& values() const { return values_; }
81 81
82 private: 82 private:
83 KeyMap keys_; 83 KeyMap keys_;
84 ValueMap values_; 84 ValueMap values_;
85 85
86 DISALLOW_COPY_AND_ASSIGN(RegistryDict); 86 DISALLOW_COPY_AND_ASSIGN(RegistryDict);
87 }; 87 };
88 88
89 } // namespace policy 89 } // namespace policy
90 90
91 #endif // COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_ 91 #endif // COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_
OLDNEW
« no previous file with comments | « components/policy/core/common/policy_loader_win_unittest.cc ('k') | components/policy/core/common/registry_dict_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698