| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 const wchar_t* key_path, | 158 const wchar_t* key_path, |
| 159 REGSAM wow64_access, | 159 REGSAM wow64_access, |
| 160 const wchar_t* value_name, | 160 const wchar_t* value_name, |
| 161 const RegistryValuePredicate& predicate); | 161 const RegistryValuePredicate& predicate); |
| 162 | 162 |
| 163 // A predicate that performs a case-sensitive string comparison. | 163 // A predicate that performs a case-sensitive string comparison. |
| 164 class ValueEquals : public RegistryValuePredicate { | 164 class ValueEquals : public RegistryValuePredicate { |
| 165 public: | 165 public: |
| 166 explicit ValueEquals(const base::string16& value_to_match) | 166 explicit ValueEquals(const base::string16& value_to_match) |
| 167 : value_to_match_(value_to_match) { } | 167 : value_to_match_(value_to_match) { } |
| 168 virtual bool Evaluate(const base::string16& value) const OVERRIDE; | 168 virtual bool Evaluate(const base::string16& value) const override; |
| 169 protected: | 169 protected: |
| 170 base::string16 value_to_match_; | 170 base::string16 value_to_match_; |
| 171 private: | 171 private: |
| 172 DISALLOW_COPY_AND_ASSIGN(ValueEquals); | 172 DISALLOW_COPY_AND_ASSIGN(ValueEquals); |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 // Returns zero on install success, or an InstallStatus value otherwise. | 175 // Returns zero on install success, or an InstallStatus value otherwise. |
| 176 static int GetInstallReturnCode(installer::InstallStatus install_status); | 176 static int GetInstallReturnCode(installer::InstallStatus install_status); |
| 177 | 177 |
| 178 // Composes |program| and |arguments| into |command_line|. | 178 // Composes |program| and |arguments| into |command_line|. |
| 179 static void MakeUninstallCommand(const base::string16& program, | 179 static void MakeUninstallCommand(const base::string16& program, |
| 180 const base::string16& arguments, | 180 const base::string16& arguments, |
| 181 base::CommandLine* command_line); | 181 base::CommandLine* command_line); |
| 182 | 182 |
| 183 // Returns a string in the form YYYYMMDD of the current date. | 183 // Returns a string in the form YYYYMMDD of the current date. |
| 184 static base::string16 GetCurrentDate(); | 184 static base::string16 GetCurrentDate(); |
| 185 | 185 |
| 186 // A predicate that compares the program portion of a command line with a | 186 // A predicate that compares the program portion of a command line with a |
| 187 // given file path. First, the file paths are compared directly. If they do | 187 // given file path. First, the file paths are compared directly. If they do |
| 188 // not match, the filesystem is consulted to determine if the paths reference | 188 // not match, the filesystem is consulted to determine if the paths reference |
| 189 // the same file. | 189 // the same file. |
| 190 class ProgramCompare : public RegistryValuePredicate { | 190 class ProgramCompare : public RegistryValuePredicate { |
| 191 public: | 191 public: |
| 192 explicit ProgramCompare(const base::FilePath& path_to_match); | 192 explicit ProgramCompare(const base::FilePath& path_to_match); |
| 193 virtual ~ProgramCompare(); | 193 virtual ~ProgramCompare(); |
| 194 virtual bool Evaluate(const base::string16& value) const OVERRIDE; | 194 virtual bool Evaluate(const base::string16& value) const override; |
| 195 bool EvaluatePath(const base::FilePath& path) const; | 195 bool EvaluatePath(const base::FilePath& path) const; |
| 196 | 196 |
| 197 protected: | 197 protected: |
| 198 static bool OpenForInfo(const base::FilePath& path, base::File* file); | 198 static bool OpenForInfo(const base::FilePath& path, base::File* file); |
| 199 static bool GetInfo(const base::File& file, | 199 static bool GetInfo(const base::File& file, |
| 200 BY_HANDLE_FILE_INFORMATION* info); | 200 BY_HANDLE_FILE_INFORMATION* info); |
| 201 | 201 |
| 202 base::FilePath path_to_match_; | 202 base::FilePath path_to_match_; |
| 203 base::File file_; | 203 base::File file_; |
| 204 BY_HANDLE_FILE_INFORMATION file_info_; | 204 BY_HANDLE_FILE_INFORMATION file_info_; |
| 205 | 205 |
| 206 private: | 206 private: |
| 207 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); | 207 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); |
| 208 }; // class ProgramCompare | 208 }; // class ProgramCompare |
| 209 | 209 |
| 210 private: | 210 private: |
| 211 DISALLOW_COPY_AND_ASSIGN(InstallUtil); | 211 DISALLOW_COPY_AND_ASSIGN(InstallUtil); |
| 212 }; | 212 }; |
| 213 | 213 |
| 214 | 214 |
| 215 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ | 215 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ |
| OLD | NEW |