| OLD | NEW |
| 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_H_ |
| 6 #define COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_ | 6 #define COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_H_ |
| 7 | |
| 8 #include <windows.h> | |
| 9 | 7 |
| 10 #include <map> | 8 #include <map> |
| 11 #include <memory> | 9 #include <memory> |
| 12 #include <string> | 10 #include <string> |
| 13 | 11 |
| 14 #include "base/macros.h" | 12 #include "base/macros.h" |
| 15 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 16 #include "components/policy/policy_export.h" | 14 #include "components/policy/policy_export.h" |
| 17 | 15 |
| 16 #if defined(OS_WIN) |
| 17 #include <windows.h> |
| 18 #endif |
| 19 |
| 18 namespace base { | 20 namespace base { |
| 19 class Value; | 21 class Value; |
| 20 } | 22 } |
| 21 | 23 |
| 22 namespace policy { | 24 namespace policy { |
| 23 | 25 |
| 24 class Schema; | |
| 25 | |
| 26 // A case-insensitive string comparison functor. | 26 // A case-insensitive string comparison functor. |
| 27 struct POLICY_EXPORT CaseInsensitiveStringCompare { | 27 struct POLICY_EXPORT CaseInsensitiveStringCompare { |
| 28 bool operator()(const std::string& a, const std::string& b) const; | 28 bool operator()(const std::string& a, const std::string& b) const; |
| 29 }; | 29 }; |
| 30 | 30 |
| 31 // In-memory representation of a registry subtree. Using a | 31 // In-memory representation of a registry subtree. Using a |
| 32 // base::DictionaryValue directly seems tempting, but that doesn't handle the | 32 // base::DictionaryValue directly seems tempting, but that doesn't handle the |
| 33 // registry's case-insensitive-but-case-preserving semantics properly. | 33 // registry's case-insensitive-but-case-preserving semantics properly. |
| 34 class POLICY_EXPORT RegistryDict { | 34 class POLICY_EXPORT RegistryDict { |
| 35 public: | 35 public: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 62 std::unique_ptr<base::Value> RemoveValue(const std::string& name); | 62 std::unique_ptr<base::Value> RemoveValue(const std::string& name); |
| 63 // Clears all values. | 63 // Clears all values. |
| 64 void ClearValues(); | 64 void ClearValues(); |
| 65 | 65 |
| 66 // Merge keys and values from |other|, giving precedence to |other|. | 66 // Merge keys and values from |other|, giving precedence to |other|. |
| 67 void Merge(const RegistryDict& other); | 67 void Merge(const RegistryDict& other); |
| 68 | 68 |
| 69 // Swap with |other|. | 69 // Swap with |other|. |
| 70 void Swap(RegistryDict* other); | 70 void Swap(RegistryDict* other); |
| 71 | 71 |
| 72 #if defined(OS_WIN) |
| 72 // Read a Windows registry subtree into this registry dictionary object. | 73 // Read a Windows registry subtree into this registry dictionary object. |
| 73 void ReadRegistry(HKEY hive, const base::string16& root); | 74 void ReadRegistry(HKEY hive, const base::string16& root); |
| 74 | 75 |
| 75 // Converts the dictionary to base::Value representation. For key/value name | 76 // Converts the dictionary to base::Value representation. For key/value name |
| 76 // collisions, the key wins. |schema| is used to determine the expected type | 77 // collisions, the key wins. |schema| is used to determine the expected type |
| 77 // for each policy. | 78 // for each policy. |
| 78 // The returned object is either a base::DictionaryValue or a base::ListValue. | 79 // The returned object is either a base::DictionaryValue or a base::ListValue. |
| 79 std::unique_ptr<base::Value> ConvertToJSON(const Schema& schema) const; | 80 std::unique_ptr<base::Value> ConvertToJSON(const class Schema& schema) const; |
| 81 #endif |
| 80 | 82 |
| 81 const KeyMap& keys() const { return keys_; } | 83 const KeyMap& keys() const { return keys_; } |
| 82 const ValueMap& values() const { return values_; } | 84 const ValueMap& values() const { return values_; } |
| 83 | 85 |
| 84 private: | 86 private: |
| 85 KeyMap keys_; | 87 KeyMap keys_; |
| 86 ValueMap values_; | 88 ValueMap values_; |
| 87 | 89 |
| 88 DISALLOW_COPY_AND_ASSIGN(RegistryDict); | 90 DISALLOW_COPY_AND_ASSIGN(RegistryDict); |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 } // namespace policy | 93 } // namespace policy |
| 92 | 94 |
| 93 #endif // COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_WIN_H_ | 95 #endif // COMPONENTS_POLICY_CORE_COMMON_REGISTRY_DICT_H_ |
| OLD | NEW |