| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 public: | 29 public: |
| 30 class ProductBits { | 30 class ProductBits { |
| 31 public: | 31 public: |
| 32 // Bits that form the components of an installation type. | 32 // Bits that form the components of an installation type. |
| 33 enum { | 33 enum { |
| 34 CHROME_SINGLE = 0x01, | 34 CHROME_SINGLE = 0x01, |
| 35 CHROME_MULTI = 0x02, | 35 CHROME_MULTI = 0x02, |
| 36 CHROME_FRAME_SINGLE = 0x04, | 36 CHROME_FRAME_SINGLE = 0x04, |
| 37 CHROME_FRAME_MULTI = 0x08, | 37 CHROME_FRAME_MULTI = 0x08, |
| 38 CHROME_FRAME_READY_MODE = 0x10, | 38 CHROME_FRAME_READY_MODE = 0x10, |
| 39 CHROME_APP_HOST = 0x20, |
| 39 }; | 40 }; |
| 40 }; // class ProductBits | 41 }; // class ProductBits |
| 41 | 42 |
| 42 // Identifiers of all valid installation types. | 43 // Identifiers of all valid installation types. |
| 43 enum InstallationType { | 44 enum InstallationType { |
| 44 NO_PRODUCTS = 0, | 45 NO_PRODUCTS = 0, |
| 45 CHROME_SINGLE = | 46 CHROME_SINGLE = |
| 46 ProductBits::CHROME_SINGLE, | 47 ProductBits::CHROME_SINGLE, |
| 47 CHROME_MULTI = | 48 CHROME_MULTI = |
| 48 ProductBits::CHROME_MULTI, | 49 ProductBits::CHROME_MULTI, |
| 49 CHROME_FRAME_SINGLE = | 50 CHROME_FRAME_SINGLE = |
| 50 ProductBits::CHROME_FRAME_SINGLE, | 51 ProductBits::CHROME_FRAME_SINGLE, |
| 51 CHROME_FRAME_SINGLE_CHROME_SINGLE = | 52 CHROME_FRAME_SINGLE_CHROME_SINGLE = |
| 52 ProductBits::CHROME_FRAME_SINGLE | ProductBits::CHROME_SINGLE, | 53 ProductBits::CHROME_FRAME_SINGLE | ProductBits::CHROME_SINGLE, |
| 53 CHROME_FRAME_SINGLE_CHROME_MULTI = | 54 CHROME_FRAME_SINGLE_CHROME_MULTI = |
| 54 ProductBits::CHROME_FRAME_SINGLE | ProductBits::CHROME_MULTI, | 55 ProductBits::CHROME_FRAME_SINGLE | ProductBits::CHROME_MULTI, |
| 55 CHROME_FRAME_MULTI = | 56 CHROME_FRAME_MULTI = |
| 56 ProductBits::CHROME_FRAME_MULTI, | 57 ProductBits::CHROME_FRAME_MULTI, |
| 57 CHROME_FRAME_MULTI_CHROME_MULTI = | 58 CHROME_FRAME_MULTI_CHROME_MULTI = |
| 58 ProductBits::CHROME_FRAME_MULTI | ProductBits::CHROME_MULTI, | 59 ProductBits::CHROME_FRAME_MULTI | ProductBits::CHROME_MULTI, |
| 59 CHROME_FRAME_READY_MODE_CHROME_MULTI = | 60 CHROME_FRAME_READY_MODE_CHROME_MULTI = |
| 60 ProductBits::CHROME_FRAME_READY_MODE | ProductBits::CHROME_MULTI, | 61 ProductBits::CHROME_FRAME_READY_MODE | ProductBits::CHROME_MULTI, |
| 62 CHROME_APP_HOST = |
| 63 ProductBits::CHROME_APP_HOST, |
| 64 CHROME_APP_HOST_CHROME_FRAME_SINGLE = |
| 65 ProductBits::CHROME_APP_HOST | ProductBits::CHROME_FRAME_SINGLE, |
| 66 CHROME_APP_HOST_CHROME_FRAME_SINGLE_CHROME_MULTI = |
| 67 ProductBits::CHROME_APP_HOST | ProductBits::CHROME_FRAME_SINGLE | |
| 68 ProductBits::CHROME_MULTI, |
| 69 CHROME_APP_HOST_CHROME_FRAME_MULTI = |
| 70 ProductBits::CHROME_APP_HOST | ProductBits::CHROME_FRAME_MULTI, |
| 71 CHROME_APP_HOST_CHROME_FRAME_MULTI_CHROME_MULTI = |
| 72 ProductBits::CHROME_APP_HOST | ProductBits::CHROME_FRAME_MULTI | |
| 73 ProductBits::CHROME_MULTI, |
| 74 CHROME_APP_HOST_CHROME_MULTI = |
| 75 ProductBits::CHROME_APP_HOST | ProductBits::CHROME_MULTI, |
| 76 CHROME_APP_HOST_CHROME_MULTI_CHROME_FRAME_READY_MODE = |
| 77 ProductBits::CHROME_APP_HOST | ProductBits::CHROME_MULTI | |
| 78 ProductBits::CHROME_FRAME_READY_MODE, |
| 61 }; | 79 }; |
| 62 | 80 |
| 63 // Validates |machine_state| at user or system level, returning true if valid. | 81 // Validates |machine_state| at user or system level, returning true if valid. |
| 64 // |type| is populated in either case, although it is a best-guess when the | 82 // |type| is populated in either case, although it is a best-guess when the |
| 65 // method returns false. | 83 // method returns false. |
| 66 static bool ValidateInstallationTypeForState( | 84 static bool ValidateInstallationTypeForState( |
| 67 const InstallationState& machine_state, | 85 const InstallationState& machine_state, |
| 68 bool system_level, | 86 bool system_level, |
| 69 InstallationType* type); | 87 InstallationType* type); |
| 70 | 88 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 SwitchExpectations* expectations) const OVERRIDE; | 147 SwitchExpectations* expectations) const OVERRIDE; |
| 130 virtual void AddRenameSwitchExpectations( | 148 virtual void AddRenameSwitchExpectations( |
| 131 const InstallationState& machine_state, | 149 const InstallationState& machine_state, |
| 132 bool system_install, | 150 bool system_install, |
| 133 const ProductState& product_state, | 151 const ProductState& product_state, |
| 134 SwitchExpectations* expectations) const OVERRIDE; | 152 SwitchExpectations* expectations) const OVERRIDE; |
| 135 virtual bool UsageStatsAllowed( | 153 virtual bool UsageStatsAllowed( |
| 136 const ProductState& product_state) const OVERRIDE; | 154 const ProductState& product_state) const OVERRIDE; |
| 137 }; | 155 }; |
| 138 | 156 |
| 157 // Validation rules for Chrome App Host. |
| 158 class ChromeAppHostRules : public ProductRules { |
| 159 public: |
| 160 virtual BrowserDistribution::Type distribution_type() const OVERRIDE; |
| 161 virtual void AddUninstallSwitchExpectations( |
| 162 const InstallationState& machine_state, |
| 163 bool system_install, |
| 164 const ProductState& product_state, |
| 165 SwitchExpectations* expectations) const OVERRIDE; |
| 166 virtual void AddRenameSwitchExpectations( |
| 167 const InstallationState& machine_state, |
| 168 bool system_install, |
| 169 const ProductState& product_state, |
| 170 SwitchExpectations* expectations) const OVERRIDE; |
| 171 virtual bool UsageStatsAllowed( |
| 172 const ProductState& product_state) const OVERRIDE; |
| 173 }; |
| 174 |
| 139 // Validation rules for the multi-install Chrome binaries. | 175 // Validation rules for the multi-install Chrome binaries. |
| 140 class ChromeBinariesRules : public ProductRules { | 176 class ChromeBinariesRules : public ProductRules { |
| 141 public: | 177 public: |
| 142 virtual BrowserDistribution::Type distribution_type() const OVERRIDE; | 178 virtual BrowserDistribution::Type distribution_type() const OVERRIDE; |
| 143 virtual void AddUninstallSwitchExpectations( | 179 virtual void AddUninstallSwitchExpectations( |
| 144 const InstallationState& machine_state, | 180 const InstallationState& machine_state, |
| 145 bool system_install, | 181 bool system_install, |
| 146 const ProductState& product_state, | 182 const ProductState& product_state, |
| 147 SwitchExpectations* expectations) const OVERRIDE; | 183 SwitchExpectations* expectations) const OVERRIDE; |
| 148 virtual void AddRenameSwitchExpectations( | 184 virtual void AddRenameSwitchExpectations( |
| 149 const InstallationState& machine_state, | 185 const InstallationState& machine_state, |
| 150 bool system_install, | 186 bool system_install, |
| 151 const ProductState& product_state, | 187 const ProductState& product_state, |
| 152 SwitchExpectations* expectations) const OVERRIDE; | 188 SwitchExpectations* expectations) const OVERRIDE; |
| 153 virtual bool UsageStatsAllowed( | 189 virtual bool UsageStatsAllowed( |
| 154 const ProductState& product_state) const OVERRIDE; | 190 const ProductState& product_state) const OVERRIDE; |
| 155 }; | 191 }; |
| 156 | 192 |
| 157 struct ProductContext { | 193 struct ProductContext { |
| 158 const InstallationState& machine_state; | 194 const InstallationState& machine_state; |
| 159 bool system_install; | 195 bool system_install; |
| 160 BrowserDistribution* dist; | 196 BrowserDistribution* dist; |
| 161 const ProductState& state; | 197 const ProductState& state; |
| 162 const ProductRules& rules; | 198 const ProductRules& rules; |
| 163 }; | 199 }; |
| 164 | 200 |
| 201 static void ValidateInstallAppCommand(const ProductContext& ctx, |
| 202 const AppCommand& command, |
| 203 bool* is_valid); |
| 165 static void ValidateQuickEnableCfCommand(const ProductContext& ctx, | 204 static void ValidateQuickEnableCfCommand(const ProductContext& ctx, |
| 166 const AppCommand& command, | 205 const AppCommand& command, |
| 167 bool* is_valid); | 206 bool* is_valid); |
| 207 static void ValidateQuickEnableApplicationHostCommand( |
| 208 const ProductContext& ctx, |
| 209 const AppCommand& command, |
| 210 bool* is_valid); |
| 211 |
| 168 static void ValidateAppCommandExpectations( | 212 static void ValidateAppCommandExpectations( |
| 169 const ProductContext& ctx, | 213 const ProductContext& ctx, |
| 170 const CommandExpectations& expectations, | 214 const CommandExpectations& expectations, |
| 171 bool* is_valid); | 215 bool* is_valid); |
| 172 static void ValidateBinariesCommands(const ProductContext& ctx, | 216 static void ValidateBinariesCommands(const ProductContext& ctx, |
| 173 bool* is_valid); | 217 bool* is_valid); |
| 174 static void ValidateBinaries(const InstallationState& machine_state, | 218 static void ValidateBinaries(const InstallationState& machine_state, |
| 175 bool system_install, | 219 bool system_install, |
| 176 const ProductState& binaries_state, | 220 const ProductState& binaries_state, |
| 177 bool* is_valid); | 221 bool* is_valid); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 207 // A collection of all valid installation types. | 251 // A collection of all valid installation types. |
| 208 static const InstallationType kInstallationTypes[]; | 252 static const InstallationType kInstallationTypes[]; |
| 209 | 253 |
| 210 private: | 254 private: |
| 211 DISALLOW_IMPLICIT_CONSTRUCTORS(InstallationValidator); | 255 DISALLOW_IMPLICIT_CONSTRUCTORS(InstallationValidator); |
| 212 }; | 256 }; |
| 213 | 257 |
| 214 } // namespace installer | 258 } // namespace installer |
| 215 | 259 |
| 216 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ | 260 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ |
| OLD | NEW |