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 LONG 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, |
121 const base::string16& value_name); | 123 const base::string16& value_name); |
122 | 124 |
123 // An interface to a predicate function for use by DeleteRegistryKeyIf and | 125 // An interface to a predicate function for use by DeleteRegistryKeyIf and |
124 // DeleteRegistryValueIf. | 126 // DeleteRegistryValueIf. |
125 class RegistryValuePredicate { | 127 class RegistryValuePredicate { |
126 public: | 128 public: |
(...skipping 10 matching lines...) Expand all Loading... |
137 | 139 |
138 // Deletes the key |key_to_delete_path| under |root_key| iff the value | 140 // 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 | 141 // |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 | 142 // |predicate|. |value_name| may be either NULL or an empty string to test |
141 // the key's default value. | 143 // the key's default value. |
142 static ConditionalDeleteResult DeleteRegistryKeyIf( | 144 static ConditionalDeleteResult DeleteRegistryKeyIf( |
143 HKEY root_key, | 145 HKEY root_key, |
144 const base::string16& key_to_delete_path, | 146 const base::string16& key_to_delete_path, |
145 const base::string16& key_to_test_path, | 147 const base::string16& key_to_test_path, |
146 const wchar_t* value_name, | 148 const wchar_t* value_name, |
147 const RegistryValuePredicate& predicate); | 149 const RegistryValuePredicate& predicate, |
| 150 REGSAM wow64_access); |
148 | 151 |
149 // Deletes the value |value_name| in the key |key_path| under |root_key| iff | 152 // 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 | 153 // its current value satisfies |predicate|. |value_name| may be either NULL |
151 // or an empty string to test/delete the key's default value. | 154 // or an empty string to test/delete the key's default value. |
152 static ConditionalDeleteResult DeleteRegistryValueIf( | 155 static ConditionalDeleteResult DeleteRegistryValueIf( |
153 HKEY root_key, | 156 HKEY root_key, |
154 const wchar_t* key_path, | 157 const wchar_t* key_path, |
155 const wchar_t* value_name, | 158 const wchar_t* value_name, |
156 const RegistryValuePredicate& predicate); | 159 const RegistryValuePredicate& predicate, |
| 160 REGSAM wow64_access); |
157 | 161 |
158 // A predicate that performs a case-sensitive string comparison. | 162 // A predicate that performs a case-sensitive string comparison. |
159 class ValueEquals : public RegistryValuePredicate { | 163 class ValueEquals : public RegistryValuePredicate { |
160 public: | 164 public: |
161 explicit ValueEquals(const base::string16& value_to_match) | 165 explicit ValueEquals(const base::string16& value_to_match) |
162 : value_to_match_(value_to_match) { } | 166 : value_to_match_(value_to_match) { } |
163 virtual bool Evaluate(const base::string16& value) const OVERRIDE; | 167 virtual bool Evaluate(const base::string16& value) const OVERRIDE; |
164 protected: | 168 protected: |
165 base::string16 value_to_match_; | 169 base::string16 value_to_match_; |
166 private: | 170 private: |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 private: | 205 private: |
202 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); | 206 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); |
203 }; // class ProgramCompare | 207 }; // class ProgramCompare |
204 | 208 |
205 private: | 209 private: |
206 DISALLOW_COPY_AND_ASSIGN(InstallUtil); | 210 DISALLOW_COPY_AND_ASSIGN(InstallUtil); |
207 }; | 211 }; |
208 | 212 |
209 | 213 |
210 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ | 214 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ |
OLD | NEW |