| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 const base::Version& new_version, | 194 const base::Version& new_version, |
| 195 const BrowserDistribution* dist, | 195 const BrowserDistribution* dist, |
| 196 WorkItemList* list); | 196 WorkItemList* list); |
| 197 | 197 |
| 198 // A predicate that compares the program portion of a command line with a | 198 // A predicate that compares the program portion of a command line with a |
| 199 // given file path. First, the file paths are compared directly. If they do | 199 // given file path. First, the file paths are compared directly. If they do |
| 200 // not match, the filesystem is consulted to determine if the paths reference | 200 // not match, the filesystem is consulted to determine if the paths reference |
| 201 // the same file. | 201 // the same file. |
| 202 class ProgramCompare : public RegistryValuePredicate { | 202 class ProgramCompare : public RegistryValuePredicate { |
| 203 public: | 203 public: |
| 204 enum class ComparisonType { | |
| 205 // Evaluation compares existing files. | |
| 206 FILE, | |
| 207 // Evaluation compares existing files or directories. | |
| 208 FILE_OR_DIRECTORY, | |
| 209 }; | |
| 210 | |
| 211 // Constructs a ProgramCompare with FILE as ComparisonType. | |
| 212 explicit ProgramCompare(const base::FilePath& path_to_match); | 204 explicit ProgramCompare(const base::FilePath& path_to_match); |
| 213 | |
| 214 // Constructs a ProgramCompare with |comparison_type| as ComparisonType. | |
| 215 ProgramCompare(const base::FilePath& path_to_match, | |
| 216 ComparisonType comparison_type); | |
| 217 | |
| 218 ~ProgramCompare() override; | 205 ~ProgramCompare() override; |
| 219 bool Evaluate(const base::string16& value) const override; | 206 bool Evaluate(const base::string16& value) const override; |
| 220 bool EvaluatePath(const base::FilePath& path) const; | 207 bool EvaluatePath(const base::FilePath& path) const; |
| 221 | 208 |
| 222 protected: | 209 protected: |
| 223 static bool OpenForInfo(const base::FilePath& path, | 210 static bool OpenForInfo(const base::FilePath& path, base::File* file); |
| 224 base::File* file, | |
| 225 ComparisonType comparison_type); | |
| 226 static bool GetInfo(const base::File& file, | 211 static bool GetInfo(const base::File& file, |
| 227 BY_HANDLE_FILE_INFORMATION* info); | 212 BY_HANDLE_FILE_INFORMATION* info); |
| 228 | 213 |
| 229 base::FilePath path_to_match_; | 214 base::FilePath path_to_match_; |
| 230 base::File file_; | 215 base::File file_; |
| 231 BY_HANDLE_FILE_INFORMATION file_info_; | 216 BY_HANDLE_FILE_INFORMATION file_info_; |
| 232 ComparisonType comparison_type_; | |
| 233 | 217 |
| 234 private: | 218 private: |
| 235 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); | 219 DISALLOW_COPY_AND_ASSIGN(ProgramCompare); |
| 236 }; // class ProgramCompare | 220 }; // class ProgramCompare |
| 237 | 221 |
| 238 private: | 222 private: |
| 239 DISALLOW_COPY_AND_ASSIGN(InstallUtil); | 223 DISALLOW_COPY_AND_ASSIGN(InstallUtil); |
| 240 }; | 224 }; |
| 241 | 225 |
| 242 | 226 |
| 243 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ | 227 #endif // CHROME_INSTALLER_UTIL_INSTALL_UTIL_H_ |
| OLD | NEW |