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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 typedef void (*CommandValidatorFn)(const ProductContext& ctx, | 83 typedef void (*CommandValidatorFn)(const ProductContext& ctx, |
84 const AppCommand& command, | 84 const AppCommand& command, |
85 bool* is_valid); | 85 bool* is_valid); |
86 typedef std::map<std::wstring, CommandValidatorFn> CommandExpectations; | 86 typedef std::map<std::wstring, CommandValidatorFn> CommandExpectations; |
87 | 87 |
88 // An interface to product-specific validation rules. | 88 // An interface to product-specific validation rules. |
89 class ProductRules { | 89 class ProductRules { |
90 public: | 90 public: |
91 virtual ~ProductRules() { } | 91 virtual ~ProductRules() { } |
92 virtual BrowserDistribution::Type distribution_type() const = 0; | 92 virtual BrowserDistribution::Type distribution_type() const = 0; |
93 virtual void AddProductSwitchExpectations( | 93 virtual void AddUninstallSwitchExpectations( |
| 94 const InstallationState& machine_state, |
| 95 bool system_install, |
| 96 const ProductState& product_state, |
| 97 SwitchExpectations* expectations) const = 0; |
| 98 virtual void AddRenameSwitchExpectations( |
94 const InstallationState& machine_state, | 99 const InstallationState& machine_state, |
95 bool system_install, | 100 bool system_install, |
96 const ProductState& product_state, | 101 const ProductState& product_state, |
97 SwitchExpectations* expectations) const = 0; | 102 SwitchExpectations* expectations) const = 0; |
98 // Return true if the rules allow usagestats setting. | 103 // Return true if the rules allow usagestats setting. |
99 virtual bool UsageStatsAllowed(const ProductState& product_state) const = 0; | 104 virtual bool UsageStatsAllowed(const ProductState& product_state) const = 0; |
100 }; | 105 }; |
101 | 106 |
102 // Validation rules for the Chrome browser. | 107 // Validation rules for the Chrome browser. |
103 class ChromeRules : public ProductRules { | 108 class ChromeRules : public ProductRules { |
104 public: | 109 public: |
105 virtual BrowserDistribution::Type distribution_type() const OVERRIDE; | 110 virtual BrowserDistribution::Type distribution_type() const OVERRIDE; |
106 virtual void AddProductSwitchExpectations( | 111 virtual void AddUninstallSwitchExpectations( |
| 112 const InstallationState& machine_state, |
| 113 bool system_install, |
| 114 const ProductState& product_state, |
| 115 SwitchExpectations* expectations) const OVERRIDE; |
| 116 virtual void AddRenameSwitchExpectations( |
107 const InstallationState& machine_state, | 117 const InstallationState& machine_state, |
108 bool system_install, | 118 bool system_install, |
109 const ProductState& product_state, | 119 const ProductState& product_state, |
110 SwitchExpectations* expectations) const OVERRIDE; | 120 SwitchExpectations* expectations) const OVERRIDE; |
111 virtual bool UsageStatsAllowed( | 121 virtual bool UsageStatsAllowed( |
112 const ProductState& product_state) const OVERRIDE; | 122 const ProductState& product_state) const OVERRIDE; |
113 }; | 123 }; |
114 | 124 |
115 // Validation rules for Chrome Frame. | 125 // Validation rules for Chrome Frame. |
116 class ChromeFrameRules : public ProductRules { | 126 class ChromeFrameRules : public ProductRules { |
117 public: | 127 public: |
118 virtual BrowserDistribution::Type distribution_type() const OVERRIDE; | 128 virtual BrowserDistribution::Type distribution_type() const OVERRIDE; |
119 virtual void AddProductSwitchExpectations( | 129 virtual void AddUninstallSwitchExpectations( |
| 130 const InstallationState& machine_state, |
| 131 bool system_install, |
| 132 const ProductState& product_state, |
| 133 SwitchExpectations* expectations) const OVERRIDE; |
| 134 virtual void AddRenameSwitchExpectations( |
120 const InstallationState& machine_state, | 135 const InstallationState& machine_state, |
121 bool system_install, | 136 bool system_install, |
122 const ProductState& product_state, | 137 const ProductState& product_state, |
123 SwitchExpectations* expectations) const OVERRIDE; | 138 SwitchExpectations* expectations) const OVERRIDE; |
124 virtual bool UsageStatsAllowed( | 139 virtual bool UsageStatsAllowed( |
125 const ProductState& product_state) const OVERRIDE; | 140 const ProductState& product_state) const OVERRIDE; |
126 }; | 141 }; |
127 | 142 |
128 // Validation rules for the multi-install Chrome binaries. | 143 // Validation rules for the multi-install Chrome binaries. |
129 class ChromeBinariesRules : public ProductRules { | 144 class ChromeBinariesRules : public ProductRules { |
130 public: | 145 public: |
131 virtual BrowserDistribution::Type distribution_type() const OVERRIDE; | 146 virtual BrowserDistribution::Type distribution_type() const OVERRIDE; |
132 virtual void AddProductSwitchExpectations( | 147 virtual void AddUninstallSwitchExpectations( |
| 148 const InstallationState& machine_state, |
| 149 bool system_install, |
| 150 const ProductState& product_state, |
| 151 SwitchExpectations* expectations) const OVERRIDE; |
| 152 virtual void AddRenameSwitchExpectations( |
133 const InstallationState& machine_state, | 153 const InstallationState& machine_state, |
134 bool system_install, | 154 bool system_install, |
135 const ProductState& product_state, | 155 const ProductState& product_state, |
136 SwitchExpectations* expectations) const OVERRIDE; | 156 SwitchExpectations* expectations) const OVERRIDE; |
137 virtual bool UsageStatsAllowed( | 157 virtual bool UsageStatsAllowed( |
138 const ProductState& product_state) const OVERRIDE; | 158 const ProductState& product_state) const OVERRIDE; |
139 }; | 159 }; |
140 | 160 |
141 struct ProductContext { | 161 struct ProductContext { |
142 const InstallationState& machine_state; | 162 const InstallationState& machine_state; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 // A collection of all valid installation types. | 211 // A collection of all valid installation types. |
192 static const InstallationType kInstallationTypes[]; | 212 static const InstallationType kInstallationTypes[]; |
193 | 213 |
194 private: | 214 private: |
195 DISALLOW_IMPLICIT_CONSTRUCTORS(InstallationValidator); | 215 DISALLOW_IMPLICIT_CONSTRUCTORS(InstallationValidator); |
196 }; | 216 }; |
197 | 217 |
198 } // namespace installer | 218 } // namespace installer |
199 | 219 |
200 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ | 220 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ |
OLD | NEW |