Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1012)

Side by Side Diff: chrome/installer/util/installation_validator.h

Issue 6588003: Add support for the quick-enable-cf command to the installer. This encompase... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 10 #include <string>
10 #include <utility> 11 #include <utility>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/basictypes.h" 14 #include "base/basictypes.h"
14 #include "base/compiler_specific.h" 15 #include "base/compiler_specific.h"
15 #include "base/ref_counted.h" 16 #include "base/ref_counted.h"
16 #include "base/scoped_ptr.h" 17 #include "base/scoped_ptr.h"
17 #include "chrome/installer/util/browser_distribution.h" 18 #include "chrome/installer/util/browser_distribution.h"
18 #include "chrome/installer/util/channel_info.h" 19 #include "chrome/installer/util/channel_info.h"
19 20
20 class FilePath; 21 class FilePath;
21 class Version; 22 class Version;
22 23
23 namespace installer { 24 namespace installer {
24 25
25 class InstallationState; 26 class InstallationState;
27 class ProductCommand;
26 class ProductState; 28 class ProductState;
27 29
28 // A class that validates the state of an installation. Violations are logged 30 // A class that validates the state of an installation. Violations are logged
29 // via LOG(ERROR). 31 // via LOG(ERROR).
30 class InstallationValidator { 32 class InstallationValidator {
31 public: 33 public:
32 class ProductBits { 34 class ProductBits {
33 public: 35 public:
34 // Bits that form the components of an installation type. 36 // Bits that form the components of an installation type.
35 enum { 37 enum {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const InstallationState& machine_state, 71 const InstallationState& machine_state,
70 bool system_level, 72 bool system_level,
71 InstallationType* type); 73 InstallationType* type);
72 74
73 // Validates the machine's current installation at user or system level, 75 // Validates the machine's current installation at user or system level,
74 // returning true and populating |type| if valid. 76 // returning true and populating |type| if valid.
75 static bool ValidateInstallationType(bool system_level, 77 static bool ValidateInstallationType(bool system_level,
76 InstallationType* type); 78 InstallationType* type);
77 79
78 protected: 80 protected:
81 struct ProductContext;
79 typedef std::vector<std::pair<std::string, bool> > SwitchExpectations; 82 typedef std::vector<std::pair<std::string, bool> > SwitchExpectations;
83 typedef void (*CommandValidatorFn)(const ProductContext& ctx,
84 const ProductCommand& command,
85 bool* is_valid);
86 typedef std::map<std::wstring, CommandValidatorFn> CommandExpectations;
80 87
81 // An interface to product-specific validation rules. 88 // An interface to product-specific validation rules.
82 class ProductRules { 89 class ProductRules {
83 public: 90 public:
84 virtual ~ProductRules() { } 91 virtual ~ProductRules() { }
85 virtual BrowserDistribution::Type distribution_type() const = 0; 92 virtual BrowserDistribution::Type distribution_type() const = 0;
86 virtual void AddProductSwitchExpectations( 93 virtual void AddProductSwitchExpectations(
87 const InstallationState& machine_state, 94 const InstallationState& machine_state,
88 bool system_install, 95 bool system_install,
89 const ProductState& product_state, 96 const ProductState& product_state,
(...skipping 15 matching lines...) Expand all
105 class ChromeFrameRules : public ProductRules { 112 class ChromeFrameRules : public ProductRules {
106 public: 113 public:
107 virtual BrowserDistribution::Type distribution_type() const OVERRIDE; 114 virtual BrowserDistribution::Type distribution_type() const OVERRIDE;
108 virtual void AddProductSwitchExpectations( 115 virtual void AddProductSwitchExpectations(
109 const InstallationState& machine_state, 116 const InstallationState& machine_state,
110 bool system_install, 117 bool system_install,
111 const ProductState& product_state, 118 const ProductState& product_state,
112 SwitchExpectations* expectations) const OVERRIDE; 119 SwitchExpectations* expectations) const OVERRIDE;
113 }; 120 };
114 121
122 // Validation rules for the multi-install Chrome binaries.
123 class ChromeBinariesRules : public ProductRules {
124 public:
125 virtual BrowserDistribution::Type distribution_type() const OVERRIDE;
126 virtual void AddProductSwitchExpectations(
127 const InstallationState& machine_state,
128 bool system_install,
129 const ProductState& product_state,
130 SwitchExpectations* expectations) const OVERRIDE;
131 };
132
115 struct ProductContext { 133 struct ProductContext {
116 const InstallationState& machine_state; 134 const InstallationState& machine_state;
117 bool system_install; 135 bool system_install;
118 BrowserDistribution* dist; 136 BrowserDistribution* dist;
119 const ProductState& state; 137 const ProductState& state;
120 const ProductRules& rules; 138 const ProductRules& rules;
121 }; 139 };
122 140
141 static void ValidateQuickEnableCfCommand(const ProductContext& ctx,
142 const ProductCommand& command,
143 bool* is_valid);
144 static void ValidateProductCommandExpectations(
145 const ProductContext& ctx,
146 const CommandExpectations& expectations,
147 bool* is_valid);
148 static void ValidateBinariesCommands(const ProductContext& ctx,
149 bool* is_valid);
123 static void ValidateBinaries(const InstallationState& machine_state, 150 static void ValidateBinaries(const InstallationState& machine_state,
124 bool system_install, 151 bool system_install,
125 const ProductState& binaries_state, 152 const ProductState& binaries_state,
126 bool* is_valid); 153 bool* is_valid);
127 static void ValidateSetupPath(const ProductContext& ctx, 154 static void ValidateSetupPath(const ProductContext& ctx,
128 const FilePath& setup_exe, 155 const FilePath& setup_exe,
129 const char* purpose, 156 const char* purpose,
130 bool* is_valid); 157 bool* is_valid);
131 static void ValidateCommandExpectations(const ProductContext& ctx, 158 static void ValidateCommandExpectations(const ProductContext& ctx,
132 const CommandLine& command, 159 const CommandLine& command,
133 const SwitchExpectations& expected, 160 const SwitchExpectations& expected,
134 const char* source, 161 const char* source,
135 bool* is_valid); 162 bool* is_valid);
136 static void ValidateUninstallCommand(const ProductContext& ctx, 163 static void ValidateUninstallCommand(const ProductContext& ctx,
137 const CommandLine& command, 164 const CommandLine& command,
138 const char* source, 165 const char* source,
139 bool* is_valid); 166 bool* is_valid);
140 static void ValidateRenameCommand(const ProductContext& ctx, 167 static void ValidateRenameCommand(const ProductContext& ctx,
141 bool* is_valid); 168 bool* is_valid);
142 static void ValidateOldVersionValues(const ProductContext& ctx, 169 static void ValidateOldVersionValues(const ProductContext& ctx,
143 bool* is_valid); 170 bool* is_valid);
144 static void ValidateMultiInstallProduct(const ProductContext& ctx, 171 static void ValidateMultiInstallProduct(const ProductContext& ctx,
145 bool* is_valid); 172 bool* is_valid);
173 static void ValidateProductCommands(const ProductContext& ctx,
174 bool* is_valid);
146 static void ValidateProduct(const InstallationState& machine_state, 175 static void ValidateProduct(const InstallationState& machine_state,
147 bool system_install, 176 bool system_install,
148 const ProductState& product_state, 177 const ProductState& product_state,
149 const ProductRules& rules, 178 const ProductRules& rules,
150 bool* is_valid); 179 bool* is_valid);
151 180
152 // A collection of all valid installation types. 181 // A collection of all valid installation types.
153 static const InstallationType kInstallationTypes[]; 182 static const InstallationType kInstallationTypes[];
154 183
155 private: 184 private:
156 DISALLOW_IMPLICIT_CONSTRUCTORS(InstallationValidator); 185 DISALLOW_IMPLICIT_CONSTRUCTORS(InstallationValidator);
157 }; 186 };
158 187
159 } // namespace installer 188 } // namespace installer
160 189
161 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_ 190 #endif // CHROME_INSTALLER_UTIL_INSTALLATION_VALIDATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698