Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Implementation of the installation validator. | 5 // Implementation of the installation validator. |
| 6 | 6 |
| 7 #include "chrome/installer/util/installation_validator.h" | 7 #include "chrome/installer/util/installation_validator.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 bool expected = flags_exp.find(check_list[i].exp_key) != flags_exp.end(); | 194 bool expected = flags_exp.find(check_list[i].exp_key) != flags_exp.end(); |
| 195 if (check_list[i].val != expected) { | 195 if (check_list[i].val != expected) { |
| 196 *is_valid = false; | 196 *is_valid = false; |
| 197 LOG(ERROR) << ctx.dist->GetDisplayName() << ": " | 197 LOG(ERROR) << ctx.dist->GetDisplayName() << ": " |
| 198 << name << " command should " << (expected ? "" : "not ") | 198 << name << " command should " << (expected ? "" : "not ") |
| 199 << check_list[i].msg << "."; | 199 << check_list[i].msg << "."; |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| 204 // Validates both "install-application" and "install-extension" depending on | |
| 205 // what is passed in. | |
| 206 void InstallationValidator::ValidateInstallCommand( | |
|
Devlin
2014/09/30 18:03:01
My understanding is that, since these should never
grt (UTC plus 2)
2014/09/30 18:30:33
Could you make it validate that the commands aren'
Devlin
2014/09/30 18:51:02
I *think* (still very new to this code, so could b
grt (UTC plus 2)
2014/09/30 18:59:26
i think you're right, thanks.
| |
| 207 const ProductContext& ctx, | |
| 208 const AppCommand& app_cmd, | |
| 209 const wchar_t* expected_command, | |
| 210 const wchar_t* expected_app_name, | |
| 211 const char* expected_switch, | |
| 212 bool* is_valid) { | |
| 213 DCHECK(is_valid); | |
| 214 | |
| 215 CommandLine cmd_line(CommandLine::FromString(app_cmd.command_line())); | |
| 216 base::string16 name(expected_command); | |
| 217 | |
| 218 base::FilePath expected_path( | |
| 219 installer::GetChromeInstallPath(ctx.system_install, ctx.dist) | |
| 220 .Append(expected_app_name)); | |
| 221 | |
| 222 if (!base::FilePath::CompareEqualIgnoreCase(expected_path.value(), | |
| 223 cmd_line.GetProgram().value())) { | |
| 224 *is_valid = false; | |
| 225 LOG(ERROR) << name << "'s path is not " | |
| 226 << expected_path.value() << ": " | |
| 227 << cmd_line.GetProgram().value(); | |
| 228 } | |
| 229 | |
| 230 SwitchExpectations expected; | |
| 231 expected.push_back(std::make_pair(std::string(expected_switch), true)); | |
| 232 | |
| 233 ValidateCommandExpectations(ctx, cmd_line, expected, name, is_valid); | |
| 234 | |
| 235 std::set<base::string16> flags_exp; | |
| 236 flags_exp.insert(google_update::kRegSendsPingsField); | |
| 237 flags_exp.insert(google_update::kRegWebAccessibleField); | |
| 238 flags_exp.insert(google_update::kRegRunAsUserField); | |
| 239 ValidateAppCommandFlags(ctx, app_cmd, flags_exp, name, is_valid); | |
| 240 } | |
| 241 | |
| 242 // Validates the "install-application" Google Update product command. | |
| 243 void InstallationValidator::ValidateInstallAppCommand( | |
| 244 const ProductContext& ctx, | |
| 245 const AppCommand& app_cmd, | |
| 246 bool* is_valid) { | |
| 247 ValidateInstallCommand(ctx, app_cmd, kCmdInstallApp, | |
| 248 installer::kChromeAppHostExe, | |
| 249 ::switches::kInstallFromWebstore, is_valid); | |
| 250 } | |
| 251 | |
| 252 // Validates the "install-extension" Google Update product command. | |
| 253 void InstallationValidator::ValidateInstallExtensionCommand( | |
| 254 const ProductContext& ctx, | |
| 255 const AppCommand& app_cmd, | |
| 256 bool* is_valid) { | |
| 257 ValidateInstallCommand(ctx, app_cmd, kCmdInstallExtension, | |
| 258 installer::kChromeExe, | |
| 259 ::switches::kLimitedInstallFromWebstore, is_valid); | |
| 260 } | |
| 261 | |
| 262 // Validates the "on-os-upgrade" Google Update internal command. | 204 // Validates the "on-os-upgrade" Google Update internal command. |
| 263 void InstallationValidator::ValidateOnOsUpgradeCommand( | 205 void InstallationValidator::ValidateOnOsUpgradeCommand( |
| 264 const ProductContext& ctx, | 206 const ProductContext& ctx, |
| 265 const AppCommand& app_cmd, | 207 const AppCommand& app_cmd, |
| 266 bool* is_valid) { | 208 bool* is_valid) { |
| 267 DCHECK(is_valid); | 209 DCHECK(is_valid); |
| 268 | 210 |
| 269 CommandLine cmd_line(CommandLine::FromString(app_cmd.command_line())); | 211 CommandLine cmd_line(CommandLine::FromString(app_cmd.command_line())); |
| 270 base::string16 name(kCmdOnOsUpgrade); | 212 base::string16 name(kCmdOnOsUpgrade); |
| 271 | 213 |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 } | 621 } |
| 680 | 622 |
| 681 // Validates the Google Update commands for the product described in |ctx|. | 623 // Validates the Google Update commands for the product described in |ctx|. |
| 682 void InstallationValidator::ValidateAppCommands( | 624 void InstallationValidator::ValidateAppCommands( |
| 683 const ProductContext& ctx, | 625 const ProductContext& ctx, |
| 684 bool* is_valid) { | 626 bool* is_valid) { |
| 685 DCHECK(is_valid); | 627 DCHECK(is_valid); |
| 686 | 628 |
| 687 CommandExpectations expectations; | 629 CommandExpectations expectations; |
| 688 | 630 |
| 689 if (ctx.dist->GetType() == BrowserDistribution::CHROME_APP_HOST) { | 631 if (ctx.dist->GetType() == BrowserDistribution::CHROME_BROWSER) |
| 690 expectations[kCmdInstallApp] = &ValidateInstallAppCommand; | |
| 691 } | |
| 692 if (ctx.dist->GetType() == BrowserDistribution::CHROME_BROWSER) { | |
| 693 expectations[kCmdInstallExtension] = &ValidateInstallExtensionCommand; | |
| 694 expectations[kCmdOnOsUpgrade] = &ValidateOnOsUpgradeCommand; | 632 expectations[kCmdOnOsUpgrade] = &ValidateOnOsUpgradeCommand; |
| 695 } | |
| 696 | 633 |
| 697 ValidateAppCommandExpectations(ctx, expectations, is_valid); | 634 ValidateAppCommandExpectations(ctx, expectations, is_valid); |
| 698 } | 635 } |
| 699 | 636 |
| 700 // Validates usagestats for the product or binaries in |ctx|. | 637 // Validates usagestats for the product or binaries in |ctx|. |
| 701 void InstallationValidator::ValidateUsageStats(const ProductContext& ctx, | 638 void InstallationValidator::ValidateUsageStats(const ProductContext& ctx, |
| 702 bool* is_valid) { | 639 bool* is_valid) { |
| 703 DWORD usagestats = 0; | 640 DWORD usagestats = 0; |
| 704 if (ctx.state.GetUsageStats(&usagestats)) { | 641 if (ctx.state.GetUsageStats(&usagestats)) { |
| 705 if (!ctx.rules.UsageStatsAllowed(ctx)) { | 642 if (!ctx.rules.UsageStatsAllowed(ctx)) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 InstallationType* type) { | 752 InstallationType* type) { |
| 816 DCHECK(type); | 753 DCHECK(type); |
| 817 InstallationState machine_state; | 754 InstallationState machine_state; |
| 818 | 755 |
| 819 machine_state.Initialize(); | 756 machine_state.Initialize(); |
| 820 | 757 |
| 821 return ValidateInstallationTypeForState(machine_state, system_level, type); | 758 return ValidateInstallationTypeForState(machine_state, system_level, type); |
| 822 } | 759 } |
| 823 | 760 |
| 824 } // namespace installer | 761 } // namespace installer |
| OLD | NEW |