| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 CHROME_INSTALLER_UTIL_REGISTRY_ENTRY_H_ | 5 #ifndef CHROME_INSTALLER_UTIL_REGISTRY_ENTRY_H_ |
| 6 #define CHROME_INSTALLER_UTIL_REGISTRY_ENTRY_H_ | 6 #define CHROME_INSTALLER_UTIL_REGISTRY_ENTRY_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <stdint.h> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 12 | 13 |
| 13 class WorkItemList; | 14 class WorkItemList; |
| 14 | 15 |
| 15 // This class represents a single registry entry (a key and its value). A | 16 // This class represents a single registry entry (a key and its value). A |
| 16 // collection of registry entries should be collected into a list and written | 17 // collection of registry entries should be collected into a list and written |
| 17 // transactionally using a WorkItemList. This is preferred to writing to the | 18 // transactionally using a WorkItemList. This is preferred to writing to the |
| 18 // registry directly, because if anything goes wrong, they can be rolled back. | 19 // registry directly, because if anything goes wrong, they can be rolled back. |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 // the correct name and value in HKLM. | 78 // the correct name and value in HKLM. |
| 78 // |look_for_in| specifies roots (HKCU and/or HKLM) in which to look for the | 79 // |look_for_in| specifies roots (HKCU and/or HKLM) in which to look for the |
| 79 // key, unspecified roots are not looked into (i.e. the the key is assumed not | 80 // key, unspecified roots are not looked into (i.e. the the key is assumed not |
| 80 // to exist in them). | 81 // to exist in them). |
| 81 // |look_for_in| must at least specify one root to look into. | 82 // |look_for_in| must at least specify one root to look into. |
| 82 // If |look_for_in| is LOOK_IN_HKCU_THEN_HKLM, this method mimics Windows' | 83 // If |look_for_in| is LOOK_IN_HKCU_THEN_HKLM, this method mimics Windows' |
| 83 // behavior when searching in HKCR (HKCU takes precedence over HKLM). For | 84 // behavior when searching in HKCR (HKCU takes precedence over HKLM). For |
| 84 // registrations outside of HKCR on versions of Windows prior to Win8, | 85 // registrations outside of HKCR on versions of Windows prior to Win8, |
| 85 // Chrome's values go in HKLM. This function will make unnecessary (but | 86 // Chrome's values go in HKLM. This function will make unnecessary (but |
| 86 // harmless) queries into HKCU in that case. | 87 // harmless) queries into HKCU in that case. |
| 87 bool ExistsInRegistry(uint32 look_for_in) const; | 88 bool ExistsInRegistry(uint32_t look_for_in) const; |
| 88 | 89 |
| 89 // Checks if the current registry entry exists in \|key_path_|\|name_|, | 90 // Checks if the current registry entry exists in \|key_path_|\|name_|, |
| 90 // regardless of value. Same lookup rules as ExistsInRegistry. | 91 // regardless of value. Same lookup rules as ExistsInRegistry. |
| 91 // Unlike ExistsInRegistry, this returns true if some other value is present | 92 // Unlike ExistsInRegistry, this returns true if some other value is present |
| 92 // with the same key. | 93 // with the same key. |
| 93 bool KeyExistsInRegistry(uint32 look_for_in) const; | 94 bool KeyExistsInRegistry(uint32_t look_for_in) const; |
| 94 | 95 |
| 95 const base::string16& key_path() const { return key_path_; } | 96 const base::string16& key_path() const { return key_path_; } |
| 96 | 97 |
| 97 private: | 98 private: |
| 98 // States this RegistryKey can be in compared to the registry. | 99 // States this RegistryKey can be in compared to the registry. |
| 99 enum RegistryStatus { | 100 enum RegistryStatus { |
| 100 // |name_| does not exist in the registry | 101 // |name_| does not exist in the registry |
| 101 DOES_NOT_EXIST, | 102 DOES_NOT_EXIST, |
| 102 // |name_| exists, but its value != |value_| | 103 // |name_| exists, but its value != |value_| |
| 103 DIFFERENT_VALUE, | 104 DIFFERENT_VALUE, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 117 | 118 |
| 118 // Helper function for ExistsInRegistry(). | 119 // Helper function for ExistsInRegistry(). |
| 119 // Returns the RegistryStatus of the current registry entry in | 120 // Returns the RegistryStatus of the current registry entry in |
| 120 // |root|\|key_path_|\|name_|. | 121 // |root|\|key_path_|\|name_|. |
| 121 RegistryStatus StatusInRegistryUnderRoot(HKEY root) const; | 122 RegistryStatus StatusInRegistryUnderRoot(HKEY root) const; |
| 122 | 123 |
| 123 DISALLOW_COPY_AND_ASSIGN(RegistryEntry); | 124 DISALLOW_COPY_AND_ASSIGN(RegistryEntry); |
| 124 }; | 125 }; |
| 125 | 126 |
| 126 #endif // CHROME_INSTALLER_UTIL_REGISTRY_ENTRY_H_ | 127 #endif // CHROME_INSTALLER_UTIL_REGISTRY_ENTRY_H_ |
| OLD | NEW |