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