| 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 #ifndef CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ | 5 #ifndef CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ |
| 6 #define CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ | 6 #define CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 // returning true and populating |type| if valid. | 88 // returning true and populating |type| if valid. |
| 89 static bool ValidateInstallationType(bool system_level, | 89 static bool ValidateInstallationType(bool system_level, |
| 90 InstallationType* type); | 90 InstallationType* type); |
| 91 | 91 |
| 92 protected: | 92 protected: |
| 93 struct ProductContext; | 93 struct ProductContext; |
| 94 typedef std::vector<std::pair<std::string, bool> > SwitchExpectations; | 94 typedef std::vector<std::pair<std::string, bool> > SwitchExpectations; |
| 95 typedef void (*CommandValidatorFn)(const ProductContext& ctx, | 95 typedef void (*CommandValidatorFn)(const ProductContext& ctx, |
| 96 const AppCommand& app_cmd, | 96 const AppCommand& app_cmd, |
| 97 bool* is_valid); | 97 bool* is_valid); |
| 98 typedef std::map<string16, CommandValidatorFn> CommandExpectations; | 98 typedef std::map<base::string16, CommandValidatorFn> CommandExpectations; |
| 99 | 99 |
| 100 // An interface to product-specific validation rules. | 100 // An interface to product-specific validation rules. |
| 101 class ProductRules { | 101 class ProductRules { |
| 102 public: | 102 public: |
| 103 virtual ~ProductRules() { } | 103 virtual ~ProductRules() { } |
| 104 virtual BrowserDistribution::Type distribution_type() const = 0; | 104 virtual BrowserDistribution::Type distribution_type() const = 0; |
| 105 virtual void AddUninstallSwitchExpectations( | 105 virtual void AddUninstallSwitchExpectations( |
| 106 const ProductContext& ctx, | 106 const ProductContext& ctx, |
| 107 SwitchExpectations* expectations) const = 0; | 107 SwitchExpectations* expectations) const = 0; |
| 108 virtual void AddRenameSwitchExpectations( | 108 virtual void AddRenameSwitchExpectations( |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 const InstallationState& machine_state; | 180 const InstallationState& machine_state; |
| 181 bool system_install; | 181 bool system_install; |
| 182 BrowserDistribution* dist; | 182 BrowserDistribution* dist; |
| 183 const ProductState& state; | 183 const ProductState& state; |
| 184 const ProductRules& rules; | 184 const ProductRules& rules; |
| 185 }; | 185 }; |
| 186 | 186 |
| 187 // Helper to validate the values of bool elements in AppCommand, and to output | 187 // Helper to validate the values of bool elements in AppCommand, and to output |
| 188 // error messages. |flag_expect| is a bit mask specifying the expected | 188 // error messages. |flag_expect| is a bit mask specifying the expected |
| 189 // presence/absence of bool variables. | 189 // presence/absence of bool variables. |
| 190 static void ValidateAppCommandFlags(const ProductContext& ctx, | 190 static void ValidateAppCommandFlags( |
| 191 const AppCommand& app_cmd, | 191 const ProductContext& ctx, |
| 192 const std::set<string16>& flags_expected, | 192 const AppCommand& app_cmd, |
| 193 const string16& name, | 193 const std::set<base::string16>& flags_expected, |
| 194 bool* is_valid); | 194 const base::string16& name, |
| 195 bool* is_valid); |
| 195 static void ValidateInstallCommand(const ProductContext& ctx, | 196 static void ValidateInstallCommand(const ProductContext& ctx, |
| 196 const AppCommand& app_cmd, | 197 const AppCommand& app_cmd, |
| 197 const wchar_t* expected_command, | 198 const wchar_t* expected_command, |
| 198 const wchar_t* expected_app_name, | 199 const wchar_t* expected_app_name, |
| 199 const char* expected_switch, | 200 const char* expected_switch, |
| 200 bool* is_valid); | 201 bool* is_valid); |
| 201 static void ValidateInstallAppCommand(const ProductContext& ctx, | 202 static void ValidateInstallAppCommand(const ProductContext& ctx, |
| 202 const AppCommand& app_cmd, | 203 const AppCommand& app_cmd, |
| 203 bool* is_valid); | 204 bool* is_valid); |
| 204 static void ValidateInstallExtensionCommand(const ProductContext& ctx, | 205 static void ValidateInstallExtensionCommand(const ProductContext& ctx, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 220 const CommandExpectations& expectations, | 221 const CommandExpectations& expectations, |
| 221 bool* is_valid); | 222 bool* is_valid); |
| 222 static void ValidateBinariesCommands(const ProductContext& ctx, | 223 static void ValidateBinariesCommands(const ProductContext& ctx, |
| 223 bool* is_valid); | 224 bool* is_valid); |
| 224 static void ValidateBinaries(const InstallationState& machine_state, | 225 static void ValidateBinaries(const InstallationState& machine_state, |
| 225 bool system_install, | 226 bool system_install, |
| 226 const ProductState& binaries_state, | 227 const ProductState& binaries_state, |
| 227 bool* is_valid); | 228 bool* is_valid); |
| 228 static void ValidateSetupPath(const ProductContext& ctx, | 229 static void ValidateSetupPath(const ProductContext& ctx, |
| 229 const base::FilePath& setup_exe, | 230 const base::FilePath& setup_exe, |
| 230 const string16& purpose, | 231 const base::string16& purpose, |
| 231 bool* is_valid); | 232 bool* is_valid); |
| 232 static void ValidateCommandExpectations(const ProductContext& ctx, | 233 static void ValidateCommandExpectations(const ProductContext& ctx, |
| 233 const CommandLine& command, | 234 const CommandLine& command, |
| 234 const SwitchExpectations& expected, | 235 const SwitchExpectations& expected, |
| 235 const string16& source, | 236 const base::string16& source, |
| 236 bool* is_valid); | 237 bool* is_valid); |
| 237 static void ValidateUninstallCommand(const ProductContext& ctx, | 238 static void ValidateUninstallCommand(const ProductContext& ctx, |
| 238 const CommandLine& command, | 239 const CommandLine& command, |
| 239 const string16& source, | 240 const base::string16& source, |
| 240 bool* is_valid); | 241 bool* is_valid); |
| 241 static void ValidateRenameCommand(const ProductContext& ctx, | 242 static void ValidateRenameCommand(const ProductContext& ctx, |
| 242 bool* is_valid); | 243 bool* is_valid); |
| 243 static void ValidateOldVersionValues(const ProductContext& ctx, | 244 static void ValidateOldVersionValues(const ProductContext& ctx, |
| 244 bool* is_valid); | 245 bool* is_valid); |
| 245 static void ValidateMultiInstallProduct(const ProductContext& ctx, | 246 static void ValidateMultiInstallProduct(const ProductContext& ctx, |
| 246 bool* is_valid); | 247 bool* is_valid); |
| 247 static void ValidateAppCommands(const ProductContext& ctx, | 248 static void ValidateAppCommands(const ProductContext& ctx, |
| 248 bool* is_valid); | 249 bool* is_valid); |
| 249 static void ValidateUsageStats(const ProductContext& ctx, | 250 static void ValidateUsageStats(const ProductContext& ctx, |
| 250 bool* is_valid); | 251 bool* is_valid); |
| 251 static void ValidateProduct(const InstallationState& machine_state, | 252 static void ValidateProduct(const InstallationState& machine_state, |
| 252 bool system_install, | 253 bool system_install, |
| 253 const ProductState& product_state, | 254 const ProductState& product_state, |
| 254 const ProductRules& rules, | 255 const ProductRules& rules, |
| 255 bool* is_valid); | 256 bool* is_valid); |
| 256 | 257 |
| 257 // A collection of all valid installation types. | 258 // A collection of all valid installation types. |
| 258 static const InstallationType kInstallationTypes[]; | 259 static const InstallationType kInstallationTypes[]; |
| 259 | 260 |
| 260 private: | 261 private: |
| 261 DISALLOW_IMPLICIT_CONSTRUCTORS(InstallationValidator); | 262 DISALLOW_IMPLICIT_CONSTRUCTORS(InstallationValidator); |
| 262 }; | 263 }; |
| 263 | 264 |
| 264 } // namespace installer | 265 } // namespace installer |
| 265 | 266 |
| 266 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ | 267 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ |
| OLD | NEW |