Index: chrome/installer/util/installation_validator.cc |
diff --git a/chrome/installer/util/installation_validator.cc b/chrome/installer/util/installation_validator.cc |
index ccfa0a90e8ab739fe7f4598cb45f609e650c125f..00d9368f46e5e31cee20f7fcefd4deb72fe9c93a 100644 |
--- a/chrome/installer/util/installation_validator.cc |
+++ b/chrome/installer/util/installation_validator.cc |
@@ -241,6 +241,44 @@ void InstallationValidator::ValidateInstallAppCommand( |
} |
} |
+// Validates the "on-os-upgrade" Google Update internal command. |
+void InstallationValidator::ValidateOnOsUpgradeCommand( |
+ const ProductContext& ctx, |
+ const AppCommand& command, |
+ bool* is_valid) { |
+ DCHECK(is_valid); |
+ |
+ CommandLine the_command(CommandLine::FromString(command.command_line())); |
+ |
+ ValidateSetupPath(ctx, the_command.GetProgram(), "on os upgrade", is_valid); |
+ |
+ SwitchExpectations expected; |
+ |
+ expected.push_back(std::make_pair(std::string(switches::kOnOsUpgrade), true)); |
+ expected.push_back(std::make_pair(std::string(switches::kSystemLevel), |
gab
2012/08/28 16:08:19
What about switches::kChrome?
huangs
2012/08/29 17:02:54
Done.
|
+ ctx.system_install)); |
+ expected.push_back(std::make_pair(std::string(switches::kMultiInstall), |
+ ctx.state.is_multi_install())); |
+ |
+ ValidateCommandExpectations(ctx, the_command, expected, "on os upgrade", |
+ is_valid); |
+ |
+ if (!command.is_auto_run_on_os_upgrade()) { |
+ *is_valid = false; |
+ LOG(ERROR) << "On-os-upgrade command is not marked to run on OS upgrade."; |
+ } |
+ |
+ if (command.sends_pings()) { |
+ *is_valid = false; |
+ LOG(ERROR) << "On-os-upgrade command can send pings."; |
gab
2012/08/28 16:08:19
s/can/cannot
huangs
2012/08/29 17:02:54
But it should not, so "can" == bad. I'll change t
|
+ } |
+ |
+ if (command.is_web_accessible()) { |
+ *is_valid = false; |
+ LOG(ERROR) << "On-os-upgrade command can be web accessible."; |
gab
2012/08/28 16:08:19
s/can/cannot
huangs
2012/08/29 17:02:54
Same as before.
|
+ } |
+} |
+ |
// Validates the "quick-enable-cf" Google Update product command. |
void InstallationValidator::ValidateQuickEnableCfCommand( |
const ProductContext& ctx, |
@@ -488,14 +526,8 @@ void InstallationValidator::ValidateBinaries( |
} |
ChromeBinariesRules binaries_rules; |
- ProductContext ctx = { |
- machine_state, |
- system_install, |
- BrowserDistribution::GetSpecificDistribution( |
- BrowserDistribution::CHROME_BINARIES), |
- binaries_state, |
- binaries_rules |
- }; |
+ ProductContext ctx(machine_state, system_install, binaries_state, |
+ binaries_rules); |
ValidateBinariesCommands(ctx, is_valid); |
@@ -691,6 +723,9 @@ void InstallationValidator::ValidateAppCommands( |
if (ctx.dist->GetType() == BrowserDistribution::CHROME_APP_HOST) { |
expectations[kCmdInstallApp] = &ValidateInstallAppCommand; |
} |
+ if (ctx.dist->GetType() == BrowserDistribution::CHROME_BROWSER) { |
+ expectations[kCmdOnOsUpgrade] = &ValidateOnOsUpgradeCommand; |
+ } |
ValidateAppCommandExpectations(ctx, expectations, is_valid); |
} |
@@ -715,27 +750,16 @@ void InstallationValidator::ValidateUsageStats(const ProductContext& ctx, |
} |
// Validates the product described in |product_state| according to |rules|. |
-void InstallationValidator::ValidateProduct( |
- const InstallationState& machine_state, |
- bool system_install, |
- const ProductState& product_state, |
- const ProductRules& rules, |
- bool* is_valid) { |
+void InstallationValidator::ValidateProduct(const ProductContext& ctx, |
+ bool* is_valid) { |
DCHECK(is_valid); |
- ProductContext ctx = { |
- machine_state, |
- system_install, |
- BrowserDistribution::GetSpecificDistribution(rules.distribution_type()), |
- product_state, |
- rules |
- }; |
- |
- ValidateUninstallCommand(ctx, product_state.uninstall_command(), |
+ |
+ ValidateUninstallCommand(ctx, ctx.state.uninstall_command(), |
"Google Update uninstall command", is_valid); |
ValidateOldVersionValues(ctx, is_valid); |
- if (product_state.is_multi_install()) |
+ if (ctx.state.is_multi_install()) |
ValidateMultiInstallProduct(ctx, is_valid); |
ValidateAppCommands(ctx, is_valid); |
@@ -765,8 +789,9 @@ bool InstallationValidator::ValidateInstallationTypeForState( |
BrowserDistribution::CHROME_BROWSER); |
if (product_state != NULL) { |
ChromeRules chrome_rules; |
- ValidateProduct(machine_state, system_level, *product_state, |
- chrome_rules, &rock_on); |
+ ProductContext ctx(machine_state, system_level, *product_state, |
+ chrome_rules); |
+ ValidateProduct(ctx, &rock_on); |
*type = static_cast<InstallationType>( |
*type | (product_state->is_multi_install() ? |
ProductBits::CHROME_MULTI : |
@@ -779,8 +804,9 @@ bool InstallationValidator::ValidateInstallationTypeForState( |
BrowserDistribution::CHROME_FRAME); |
if (product_state != NULL) { |
ChromeFrameRules chrome_frame_rules; |
- ValidateProduct(machine_state, system_level, *product_state, |
- chrome_frame_rules, &rock_on); |
+ ProductContext ctx(machine_state, system_level, *product_state, |
+ chrome_frame_rules); |
+ ValidateProduct(ctx, &rock_on); |
int cf_bit = !product_state->is_multi_install() ? |
ProductBits::CHROME_FRAME_SINGLE : |
(product_state->uninstall_command().HasSwitch( |
@@ -796,8 +822,9 @@ bool InstallationValidator::ValidateInstallationTypeForState( |
BrowserDistribution::CHROME_APP_HOST); |
if (product_state != NULL) { |
ChromeAppHostRules chrome_app_host_rules; |
- ValidateProduct(machine_state, system_level, *product_state, |
- chrome_app_host_rules, &rock_on); |
+ ProductContext ctx(machine_state, system_level, *product_state, |
+ chrome_app_host_rules); |
+ ValidateProduct(ctx, &rock_on); |
*type = static_cast<InstallationType>(*type | ProductBits::CHROME_APP_HOST); |
if (system_level) { |
LOG(ERROR) << "Chrome App Host must not be installed at system level."; |