OLD | NEW |
---|---|
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 // This file declares utility functions for the installer. The original reason | 5 // This file declares utility functions for the installer. The original reason |
6 // for putting these functions in installer\util library is so that we can | 6 // for putting these functions in installer\util library is so that we can |
7 // separate out the critical logic and write unit tests for it. | 7 // separate out the critical logic and write unit tests for it. |
8 | 8 |
9 #ifndef CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ | 9 #ifndef CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ |
10 #define CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ | 10 #define CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 // by either --chrome-sxs or the executable path). | 106 // by either --chrome-sxs or the executable path). |
107 static bool IsChromeSxSProcess(); | 107 static bool IsChromeSxSProcess(); |
108 | 108 |
109 // Returns true if the sentinel file exists (or the path cannot be obtained). | 109 // Returns true if the sentinel file exists (or the path cannot be obtained). |
110 static bool IsFirstRunSentinelPresent(); | 110 static bool IsFirstRunSentinelPresent(); |
111 | 111 |
112 // Populates |path| with EULA sentinel file path. Returns false on error. | 112 // Populates |path| with EULA sentinel file path. Returns false on error. |
113 static bool GetEULASentinelFilePath(base::FilePath* path); | 113 static bool GetEULASentinelFilePath(base::FilePath* path); |
114 | 114 |
115 // Deletes the registry key at path key_path under the key given by root_key. | 115 // Deletes the registry key at path key_path under the key given by root_key. |
116 static bool DeleteRegistryKey(HKEY root_key, const base::string16& key_path); | 116 static bool DeleteRegistryKey(HKEY root_key, |
117 const base::string16& key_path, | |
118 REGSAM wow64_access); | |
117 | 119 |
118 // Deletes the registry value named value_name at path key_path under the key | 120 // Deletes the registry value named value_name at path key_path under the key |
119 // given by reg_root. | 121 // given by reg_root. |
120 static bool DeleteRegistryValue(HKEY reg_root, const base::string16& key_path, | 122 static bool DeleteRegistryValue(HKEY reg_root, const base::string16& key_path, |
123 REGSAM wow64_access, | |
grt (UTC plus 2)
2014/05/22 22:17:23
nice catch!
| |
121 const base::string16& value_name); | 124 const base::string16& value_name); |
122 | 125 |
123 // An interface to a predicate function for use by DeleteRegistryKeyIf and | 126 // An interface to a predicate function for use by DeleteRegistryKeyIf and |
124 // DeleteRegistryValueIf. | 127 // DeleteRegistryValueIf. |
125 class RegistryValuePredicate { | 128 class RegistryValuePredicate { |
126 public: | 129 public: |
127 virtual ~RegistryValuePredicate() { } | 130 virtual ~RegistryValuePredicate() { } |
128 virtual bool Evaluate(const base::string16& value) const = 0; | 131 virtual bool Evaluate(const base::string16& value) const = 0; |
129 }; | 132 }; |
130 | 133 |
131 // The result of a conditional delete operation (i.e., DeleteFOOIf). | 134 // The result of a conditional delete operation (i.e., DeleteFOOIf). |
132 enum ConditionalDeleteResult { | 135 enum ConditionalDeleteResult { |
133 NOT_FOUND, // The condition was not satisfied. | 136 NOT_FOUND, // The condition was not satisfied. |
134 DELETED, // The condition was satisfied and the delete succeeded. | 137 DELETED, // The condition was satisfied and the delete succeeded. |
135 DELETE_FAILED // The condition was satisfied but the delete failed. | 138 DELETE_FAILED // The condition was satisfied but the delete failed. |
136 }; | 139 }; |
137 | 140 |
138 // Deletes the key |key_to_delete_path| under |root_key| iff the value | 141 // Deletes the key |key_to_delete_path| under |root_key| iff the value |
139 // |value_name| in the key |key_to_test_path| under |root_key| satisfies | 142 // |value_name| in the key |key_to_test_path| under |root_key| satisfies |
140 // |predicate|. |value_name| may be either NULL or an empty string to test | 143 // |predicate|. |value_name| may be either NULL or an empty string to test |
141 // the key's default value. | 144 // the key's default value. |
142 static ConditionalDeleteResult DeleteRegistryKeyIf( | 145 static ConditionalDeleteResult DeleteRegistryKeyIf( |
143 HKEY root_key, | 146 HKEY root_key, |
144 const base::string16& key_to_delete_path, | 147 const base::string16& key_to_delete_path, |
145 const base::string16& key_to_test_path, | 148 const base::string16& key_to_test_path, |
149 REGSAM wow64_access, | |
146 const wchar_t* value_name, | 150 const wchar_t* value_name, |
147 const RegistryValuePredicate& predicate); | 151 const RegistryValuePredicate& predicate); |
148 | 152 |
149 // Deletes the value |value_name| in the key |key_path| under |root_key| iff | 153 // Deletes the value |value_name| in the key |key_path| under |root_key| iff |
150 // its current value satisfies |predicate|. |value_name| may be either NULL | 154 // its current value satisfies |predicate|. |value_name| may be either NULL |
151 // or an empty string to test/delete the key's default value. | 155 // or an empty string to test/delete the key's default value. |
152 static ConditionalDeleteResult DeleteRegistryValueIf( | 156 static ConditionalDeleteResult DeleteRegistryValueIf( |
153 HKEY root_key, | 157 HKEY root_key, |
154 const wchar_t* key_path, | 158 const wchar_t* key_path, |
159 REGSAM wow64_access, | |
155 const wchar_t* value_name, | 160 const wchar_t* value_name, |
156 const RegistryValuePredicate& predicate); | 161 const RegistryValuePredicate& predicate); |
157 | 162 |
158 // A predicate that performs a case-sensitive string comparison. | 163 // A predicate that performs a case-sensitive string comparison. |
159 class ValueEquals : public RegistryValuePredicate { | 164 class ValueEquals : public RegistryValuePredicate { |
160 public: | 165 public: |
161 explicit ValueEquals(const base::string16& value_to_match) | 166 explicit ValueEquals(const base::string16& value_to_match) |
162 : value_to_match_(value_to_match) { } | 167 : value_to_match_(value_to_match) { } |
163 virtual bool Evaluate(const base::string16& value) const OVERRIDE; | 168 virtual bool Evaluate(const base::string16& value) const OVERRIDE; |
164 protected: | 169 protected: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
201 private: | 206 private: |
202 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); | 207 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); |
203 }; // class ProgramCompare | 208 }; // class ProgramCompare |
204 | 209 |
205 private: | 210 private: |
206 DISALLOW_COPY_AND_ASSIGN(InstallUtil); | 211 DISALLOW_COPY_AND_ASSIGN(InstallUtil); |
207 }; | 212 }; |
208 | 213 |
209 | 214 |
210 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ | 215 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ |
OLD | NEW |