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

Unified Diff: chrome/installer/util/installation_validator.cc

Issue 10823437: Callback flow to register Chrome and update shortcuts after OS upgrade to Windows 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Abandoning the use of ON_OS_UPGRADE_SUCCESSFUL installer message. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
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..5f871939d05eb1649640170bde6f49d412a7b5b0 100644
--- a/chrome/installer/util/installation_validator.cc
+++ b/chrome/installer/util/installation_validator.cc
@@ -241,6 +241,49 @@ 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;
+
gab 2012/08/30 14:24:32 Remove this line (i.e. declare variable + initiali
huangs 2012/08/30 17:13:07 Done.
+ expected.push_back(std::make_pair(std::string(switches::kOnOsUpgrade), true));
+ expected.push_back(std::make_pair(std::string(switches::kSystemLevel),
+ ctx.system_install));
+ expected.push_back(std::make_pair(std::string(switches::kMultiInstall),
+ ctx.state.is_multi_install()));
+ const ProductState* product_state =
gab 2012/08/30 14:24:32 Move this before "SwitchExpectations expected;" so
huangs 2012/08/30 17:13:07 Made unnecessary by new change.
+ ctx.machine_state.GetProductState(ctx.system_install,
+ BrowserDistribution::CHROME_BROWSER);
+ expected.push_back(std::make_pair(std::string(switches::kChrome),
grt (UTC plus 2) 2012/08/30 04:15:25 --chrome is expected to only be present if --multi
huangs 2012/08/30 17:13:07 Done. And also "if", so "if and only if" => Check
+ product_state != NULL));
+
+ 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 should not be able to send pings.";
+ }
+
+ if (command.is_web_accessible()) {
+ *is_valid = false;
+ LOG(ERROR) << "On-os-upgrade command should not be web accessible.";
+ }
+}
+
// Validates the "quick-enable-cf" Google Update product command.
void InstallationValidator::ValidateQuickEnableCfCommand(
const ProductContext& ctx,
@@ -331,7 +374,7 @@ void InstallationValidator::ValidateAppCommandExpectations(
ctx.state.commands().GetIterators());
CommandExpectations::iterator expectation;
for (; cmd_iterators.first != cmd_iterators.second; ++cmd_iterators.first) {
- const std::wstring& cmd_id = cmd_iterators.first->first;
+ const string16& cmd_id = cmd_iterators.first->first;
// Do we have an expectation for this command?
expectation = the_expectations.find(cmd_id);
if (expectation != the_expectations.end()) {
@@ -488,14 +531,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 +728,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 +755,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 +794,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,
grt (UTC plus 2) 2012/08/30 04:15:25 this change appears to make ValidateProduct harder
gab 2012/08/30 14:24:32 I agree, the goal of making a struct to pass in ar
huangs 2012/08/30 17:13:07 Done.
+ chrome_rules);
+ ValidateProduct(ctx, &rock_on);
*type = static_cast<InstallationType>(
*type | (product_state->is_multi_install() ?
ProductBits::CHROME_MULTI :
@@ -779,8 +809,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 +827,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.";

Powered by Google App Engine
This is Rietveld 408576698