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 <string> | |
10 #include <utility> | 9 #include <utility> |
11 #include <vector> | 10 #include <vector> |
12 | 11 |
13 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
14 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/string16.h" |
15 #include "chrome/installer/util/browser_distribution.h" | 15 #include "chrome/installer/util/browser_distribution.h" |
16 | 16 |
17 class CommandLine; | 17 class CommandLine; |
18 class FilePath; | 18 class FilePath; |
19 | 19 |
20 namespace installer { | 20 namespace installer { |
21 | 21 |
22 class InstallationState; | 22 class InstallationState; |
23 class AppCommand; | 23 class AppCommand; |
24 class ProductState; | 24 class ProductState; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // returning true and populating |type| if valid. | 90 // returning true and populating |type| if valid. |
91 static bool ValidateInstallationType(bool system_level, | 91 static bool ValidateInstallationType(bool system_level, |
92 InstallationType* type); | 92 InstallationType* type); |
93 | 93 |
94 protected: | 94 protected: |
95 struct ProductContext; | 95 struct ProductContext; |
96 typedef std::vector<std::pair<std::string, bool> > SwitchExpectations; | 96 typedef std::vector<std::pair<std::string, bool> > SwitchExpectations; |
97 typedef void (*CommandValidatorFn)(const ProductContext& ctx, | 97 typedef void (*CommandValidatorFn)(const ProductContext& ctx, |
98 const AppCommand& command, | 98 const AppCommand& command, |
99 bool* is_valid); | 99 bool* is_valid); |
100 typedef std::map<std::wstring, CommandValidatorFn> CommandExpectations; | 100 typedef std::map<string16, CommandValidatorFn> CommandExpectations; |
101 | 101 |
102 // An interface to product-specific validation rules. | 102 // An interface to product-specific validation rules. |
103 class ProductRules { | 103 class ProductRules { |
104 public: | 104 public: |
105 virtual ~ProductRules() { } | 105 virtual ~ProductRules() { } |
106 virtual BrowserDistribution::Type distribution_type() const = 0; | 106 virtual BrowserDistribution::Type distribution_type() const = 0; |
107 virtual void AddUninstallSwitchExpectations( | 107 virtual void AddUninstallSwitchExpectations( |
108 const InstallationState& machine_state, | 108 const InstallationState& machine_state, |
109 bool system_install, | 109 bool system_install, |
110 const ProductState& product_state, | 110 const ProductState& product_state, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 virtual void AddRenameSwitchExpectations( | 184 virtual void AddRenameSwitchExpectations( |
185 const InstallationState& machine_state, | 185 const InstallationState& machine_state, |
186 bool system_install, | 186 bool system_install, |
187 const ProductState& product_state, | 187 const ProductState& product_state, |
188 SwitchExpectations* expectations) const OVERRIDE; | 188 SwitchExpectations* expectations) const OVERRIDE; |
189 virtual bool UsageStatsAllowed( | 189 virtual bool UsageStatsAllowed( |
190 const ProductState& product_state) const OVERRIDE; | 190 const ProductState& product_state) const OVERRIDE; |
191 }; | 191 }; |
192 | 192 |
193 struct ProductContext { | 193 struct ProductContext { |
| 194 ProductContext(const InstallationState& machine_state_in, |
| 195 bool system_install_in, |
| 196 const ProductState& state_in, |
| 197 const ProductRules& rules_in) |
| 198 : machine_state(machine_state_in), |
| 199 system_install(system_install_in), |
| 200 dist(BrowserDistribution::GetSpecificDistribution( |
| 201 rules_in.distribution_type())), |
| 202 state(state_in), |
| 203 rules(rules_in) { |
| 204 } |
| 205 |
194 const InstallationState& machine_state; | 206 const InstallationState& machine_state; |
195 bool system_install; | 207 bool system_install; |
196 BrowserDistribution* dist; | 208 BrowserDistribution* dist; |
197 const ProductState& state; | 209 const ProductState& state; |
198 const ProductRules& rules; | 210 const ProductRules& rules; |
199 }; | 211 }; |
200 | 212 |
| 213 static void ValidateOnOsUpgradeCommand(const ProductContext& ctx, |
| 214 const AppCommand& command, |
| 215 bool* is_valid); |
201 static void ValidateInstallAppCommand(const ProductContext& ctx, | 216 static void ValidateInstallAppCommand(const ProductContext& ctx, |
202 const AppCommand& command, | 217 const AppCommand& command, |
203 bool* is_valid); | 218 bool* is_valid); |
204 static void ValidateQuickEnableCfCommand(const ProductContext& ctx, | 219 static void ValidateQuickEnableCfCommand(const ProductContext& ctx, |
205 const AppCommand& command, | 220 const AppCommand& command, |
206 bool* is_valid); | 221 bool* is_valid); |
207 static void ValidateQuickEnableApplicationHostCommand( | 222 static void ValidateQuickEnableApplicationHostCommand( |
208 const ProductContext& ctx, | 223 const ProductContext& ctx, |
209 const AppCommand& command, | 224 const AppCommand& command, |
210 bool* is_valid); | 225 bool* is_valid); |
211 | 226 |
212 static void ValidateAppCommandExpectations( | 227 static void ValidateAppCommandExpectations( |
213 const ProductContext& ctx, | 228 const ProductContext& ctx, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // A collection of all valid installation types. | 266 // A collection of all valid installation types. |
252 static const InstallationType kInstallationTypes[]; | 267 static const InstallationType kInstallationTypes[]; |
253 | 268 |
254 private: | 269 private: |
255 DISALLOW_IMPLICIT_CONSTRUCTORS(InstallationValidator); | 270 DISALLOW_IMPLICIT_CONSTRUCTORS(InstallationValidator); |
256 }; | 271 }; |
257 | 272 |
258 } // namespace installer | 273 } // namespace installer |
259 | 274 |
260 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ | 275 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ |
OLD | NEW |