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

Side by Side 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: Reimplementing registry changes using AppCommand; adding checks in InstallationValidator. Created 8 years, 3 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) 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 LOG(ERROR) << "install-application command is not configured to send " 234 LOG(ERROR) << "install-application command is not configured to send "
235 << "pings."; 235 << "pings.";
236 } 236 }
237 237
238 if (!command.is_web_accessible()) { 238 if (!command.is_web_accessible()) {
239 *is_valid = false; 239 *is_valid = false;
240 LOG(ERROR) << "install-application command is not web accessible."; 240 LOG(ERROR) << "install-application command is not web accessible.";
241 } 241 }
242 } 242 }
243 243
244 // Validates the "on-os-upgrade" Google Update internal command.
245 void InstallationValidator::ValidateOnOsUpgradeCommand(
246 const ProductContext& ctx,
247 const AppCommand& command,
248 bool* is_valid) {
249 DCHECK(is_valid);
250
251 CommandLine the_command(CommandLine::FromString(command.command_line()));
252
253 ValidateSetupPath(ctx, the_command.GetProgram(), "on os upgrade", is_valid);
254
255 SwitchExpectations expected;
256
257 expected.push_back(std::make_pair(std::string(switches::kOnOsUpgrade), true));
258 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.
259 ctx.system_install));
260 expected.push_back(std::make_pair(std::string(switches::kMultiInstall),
261 ctx.state.is_multi_install()));
262
263 ValidateCommandExpectations(ctx, the_command, expected, "on os upgrade",
264 is_valid);
265
266 if (!command.is_auto_run_on_os_upgrade()) {
267 *is_valid = false;
268 LOG(ERROR) << "On-os-upgrade command is not marked to run on OS upgrade.";
269 }
270
271 if (command.sends_pings()) {
272 *is_valid = false;
273 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
274 }
275
276 if (command.is_web_accessible()) {
277 *is_valid = false;
278 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.
279 }
280 }
281
244 // Validates the "quick-enable-cf" Google Update product command. 282 // Validates the "quick-enable-cf" Google Update product command.
245 void InstallationValidator::ValidateQuickEnableCfCommand( 283 void InstallationValidator::ValidateQuickEnableCfCommand(
246 const ProductContext& ctx, 284 const ProductContext& ctx,
247 const AppCommand& command, 285 const AppCommand& command,
248 bool* is_valid) { 286 bool* is_valid) {
249 DCHECK(is_valid); 287 DCHECK(is_valid);
250 288
251 CommandLine the_command(CommandLine::FromString(command.command_line())); 289 CommandLine the_command(CommandLine::FromString(command.command_line()));
252 290
253 ValidateSetupPath(ctx, the_command.GetProgram(), "quick enable cf", is_valid); 291 ValidateSetupPath(ctx, the_command.GetProgram(), "quick enable cf", is_valid);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 519
482 // Chrome Frame must be multi-install if Chrome & App Host are not present. 520 // Chrome Frame must be multi-install if Chrome & App Host are not present.
483 if (cf_state != NULL && app_host_state == NULL && chrome_state == NULL && 521 if (cf_state != NULL && app_host_state == NULL && chrome_state == NULL &&
484 !cf_state->is_multi_install()) { 522 !cf_state->is_multi_install()) {
485 *is_valid = false; 523 *is_valid = false;
486 LOG(ERROR) << "Chrome Binaries are present without Chrome nor App Host " 524 LOG(ERROR) << "Chrome Binaries are present without Chrome nor App Host "
487 << "yet Chrome Frame is not multi-install."; 525 << "yet Chrome Frame is not multi-install.";
488 } 526 }
489 527
490 ChromeBinariesRules binaries_rules; 528 ChromeBinariesRules binaries_rules;
491 ProductContext ctx = { 529 ProductContext ctx(machine_state, system_install, binaries_state,
492 machine_state, 530 binaries_rules);
493 system_install,
494 BrowserDistribution::GetSpecificDistribution(
495 BrowserDistribution::CHROME_BINARIES),
496 binaries_state,
497 binaries_rules
498 };
499 531
500 ValidateBinariesCommands(ctx, is_valid); 532 ValidateBinariesCommands(ctx, is_valid);
501 533
502 ValidateUsageStats(ctx, is_valid); 534 ValidateUsageStats(ctx, is_valid);
503 } 535 }
504 536
505 // Validates the path to |setup_exe| for the product described by |ctx|. 537 // Validates the path to |setup_exe| for the product described by |ctx|.
506 void InstallationValidator::ValidateSetupPath(const ProductContext& ctx, 538 void InstallationValidator::ValidateSetupPath(const ProductContext& ctx,
507 const FilePath& setup_exe, 539 const FilePath& setup_exe,
508 const char* purpose, 540 const char* purpose,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 void InstallationValidator::ValidateAppCommands( 716 void InstallationValidator::ValidateAppCommands(
685 const ProductContext& ctx, 717 const ProductContext& ctx,
686 bool* is_valid) { 718 bool* is_valid) {
687 DCHECK(is_valid); 719 DCHECK(is_valid);
688 720
689 CommandExpectations expectations; 721 CommandExpectations expectations;
690 722
691 if (ctx.dist->GetType() == BrowserDistribution::CHROME_APP_HOST) { 723 if (ctx.dist->GetType() == BrowserDistribution::CHROME_APP_HOST) {
692 expectations[kCmdInstallApp] = &ValidateInstallAppCommand; 724 expectations[kCmdInstallApp] = &ValidateInstallAppCommand;
693 } 725 }
726 if (ctx.dist->GetType() == BrowserDistribution::CHROME_BROWSER) {
727 expectations[kCmdOnOsUpgrade] = &ValidateOnOsUpgradeCommand;
728 }
694 729
695 ValidateAppCommandExpectations(ctx, expectations, is_valid); 730 ValidateAppCommandExpectations(ctx, expectations, is_valid);
696 } 731 }
697 732
698 // Validates usagestats for the product or binaries in |ctx|. 733 // Validates usagestats for the product or binaries in |ctx|.
699 void InstallationValidator::ValidateUsageStats(const ProductContext& ctx, 734 void InstallationValidator::ValidateUsageStats(const ProductContext& ctx,
700 bool* is_valid) { 735 bool* is_valid) {
701 DWORD usagestats = 0; 736 DWORD usagestats = 0;
702 if (ctx.state.GetUsageStats(&usagestats)) { 737 if (ctx.state.GetUsageStats(&usagestats)) {
703 if (!ctx.rules.UsageStatsAllowed(ctx.state)) { 738 if (!ctx.rules.UsageStatsAllowed(ctx.state)) {
704 *is_valid = false; 739 *is_valid = false;
705 LOG(ERROR) << ctx.dist->GetAppShortCutName() 740 LOG(ERROR) << ctx.dist->GetAppShortCutName()
706 << " has a usagestats value (" << usagestats 741 << " has a usagestats value (" << usagestats
707 << "), yet should not."; 742 << "), yet should not.";
708 } else if (usagestats != 0 && usagestats != 1) { 743 } else if (usagestats != 0 && usagestats != 1) {
709 *is_valid = false; 744 *is_valid = false;
710 LOG(ERROR) << ctx.dist->GetAppShortCutName() 745 LOG(ERROR) << ctx.dist->GetAppShortCutName()
711 << " has an unsupported usagestats value (" << usagestats 746 << " has an unsupported usagestats value (" << usagestats
712 << ")."; 747 << ").";
713 } 748 }
714 } 749 }
715 } 750 }
716 751
717 // Validates the product described in |product_state| according to |rules|. 752 // Validates the product described in |product_state| according to |rules|.
718 void InstallationValidator::ValidateProduct( 753 void InstallationValidator::ValidateProduct(const ProductContext& ctx,
719 const InstallationState& machine_state, 754 bool* is_valid) {
720 bool system_install,
721 const ProductState& product_state,
722 const ProductRules& rules,
723 bool* is_valid) {
724 DCHECK(is_valid); 755 DCHECK(is_valid);
725 ProductContext ctx = {
726 machine_state,
727 system_install,
728 BrowserDistribution::GetSpecificDistribution(rules.distribution_type()),
729 product_state,
730 rules
731 };
732 756
733 ValidateUninstallCommand(ctx, product_state.uninstall_command(), 757 ValidateUninstallCommand(ctx, ctx.state.uninstall_command(),
734 "Google Update uninstall command", is_valid); 758 "Google Update uninstall command", is_valid);
735 759
736 ValidateOldVersionValues(ctx, is_valid); 760 ValidateOldVersionValues(ctx, is_valid);
737 761
738 if (product_state.is_multi_install()) 762 if (ctx.state.is_multi_install())
739 ValidateMultiInstallProduct(ctx, is_valid); 763 ValidateMultiInstallProduct(ctx, is_valid);
740 764
741 ValidateAppCommands(ctx, is_valid); 765 ValidateAppCommands(ctx, is_valid);
742 766
743 ValidateUsageStats(ctx, is_valid); 767 ValidateUsageStats(ctx, is_valid);
744 } 768 }
745 769
746 // static 770 // static
747 bool InstallationValidator::ValidateInstallationTypeForState( 771 bool InstallationValidator::ValidateInstallationTypeForState(
748 const InstallationState& machine_state, 772 const InstallationState& machine_state,
749 bool system_level, 773 bool system_level,
750 InstallationType* type) { 774 InstallationType* type) {
751 DCHECK(type); 775 DCHECK(type);
752 bool rock_on = true; 776 bool rock_on = true;
753 *type = NO_PRODUCTS; 777 *type = NO_PRODUCTS;
754 778
755 // Does the system have any multi-installed products? 779 // Does the system have any multi-installed products?
756 const ProductState* multi_state = 780 const ProductState* multi_state =
757 machine_state.GetProductState(system_level, 781 machine_state.GetProductState(system_level,
758 BrowserDistribution::CHROME_BINARIES); 782 BrowserDistribution::CHROME_BINARIES);
759 if (multi_state != NULL) 783 if (multi_state != NULL)
760 ValidateBinaries(machine_state, system_level, *multi_state, &rock_on); 784 ValidateBinaries(machine_state, system_level, *multi_state, &rock_on);
761 785
762 // Is Chrome installed? 786 // Is Chrome installed?
763 const ProductState* product_state = 787 const ProductState* product_state =
764 machine_state.GetProductState(system_level, 788 machine_state.GetProductState(system_level,
765 BrowserDistribution::CHROME_BROWSER); 789 BrowserDistribution::CHROME_BROWSER);
766 if (product_state != NULL) { 790 if (product_state != NULL) {
767 ChromeRules chrome_rules; 791 ChromeRules chrome_rules;
768 ValidateProduct(machine_state, system_level, *product_state, 792 ProductContext ctx(machine_state, system_level, *product_state,
769 chrome_rules, &rock_on); 793 chrome_rules);
794 ValidateProduct(ctx, &rock_on);
770 *type = static_cast<InstallationType>( 795 *type = static_cast<InstallationType>(
771 *type | (product_state->is_multi_install() ? 796 *type | (product_state->is_multi_install() ?
772 ProductBits::CHROME_MULTI : 797 ProductBits::CHROME_MULTI :
773 ProductBits::CHROME_SINGLE)); 798 ProductBits::CHROME_SINGLE));
774 } 799 }
775 800
776 // Is Chrome Frame installed? 801 // Is Chrome Frame installed?
777 product_state = 802 product_state =
778 machine_state.GetProductState(system_level, 803 machine_state.GetProductState(system_level,
779 BrowserDistribution::CHROME_FRAME); 804 BrowserDistribution::CHROME_FRAME);
780 if (product_state != NULL) { 805 if (product_state != NULL) {
781 ChromeFrameRules chrome_frame_rules; 806 ChromeFrameRules chrome_frame_rules;
782 ValidateProduct(machine_state, system_level, *product_state, 807 ProductContext ctx(machine_state, system_level, *product_state,
783 chrome_frame_rules, &rock_on); 808 chrome_frame_rules);
809 ValidateProduct(ctx, &rock_on);
784 int cf_bit = !product_state->is_multi_install() ? 810 int cf_bit = !product_state->is_multi_install() ?
785 ProductBits::CHROME_FRAME_SINGLE : 811 ProductBits::CHROME_FRAME_SINGLE :
786 (product_state->uninstall_command().HasSwitch( 812 (product_state->uninstall_command().HasSwitch(
787 switches::kChromeFrameReadyMode) ? 813 switches::kChromeFrameReadyMode) ?
788 ProductBits::CHROME_FRAME_READY_MODE : 814 ProductBits::CHROME_FRAME_READY_MODE :
789 ProductBits::CHROME_FRAME_MULTI); 815 ProductBits::CHROME_FRAME_MULTI);
790 *type = static_cast<InstallationType>(*type | cf_bit); 816 *type = static_cast<InstallationType>(*type | cf_bit);
791 } 817 }
792 818
793 // Is Chrome App Host installed? 819 // Is Chrome App Host installed?
794 product_state = 820 product_state =
795 machine_state.GetProductState(system_level, 821 machine_state.GetProductState(system_level,
796 BrowserDistribution::CHROME_APP_HOST); 822 BrowserDistribution::CHROME_APP_HOST);
797 if (product_state != NULL) { 823 if (product_state != NULL) {
798 ChromeAppHostRules chrome_app_host_rules; 824 ChromeAppHostRules chrome_app_host_rules;
799 ValidateProduct(machine_state, system_level, *product_state, 825 ProductContext ctx(machine_state, system_level, *product_state,
800 chrome_app_host_rules, &rock_on); 826 chrome_app_host_rules);
827 ValidateProduct(ctx, &rock_on);
801 *type = static_cast<InstallationType>(*type | ProductBits::CHROME_APP_HOST); 828 *type = static_cast<InstallationType>(*type | ProductBits::CHROME_APP_HOST);
802 if (system_level) { 829 if (system_level) {
803 LOG(ERROR) << "Chrome App Host must not be installed at system level."; 830 LOG(ERROR) << "Chrome App Host must not be installed at system level.";
804 rock_on = false; 831 rock_on = false;
805 } 832 }
806 if (!product_state->is_multi_install()) { 833 if (!product_state->is_multi_install()) {
807 LOG(ERROR) << "Chrome App Host must always be multi-install."; 834 LOG(ERROR) << "Chrome App Host must always be multi-install.";
808 rock_on = false; 835 rock_on = false;
809 } 836 }
810 } 837 }
(...skipping 12 matching lines...) Expand all
823 InstallationType* type) { 850 InstallationType* type) {
824 DCHECK(type); 851 DCHECK(type);
825 InstallationState machine_state; 852 InstallationState machine_state;
826 853
827 machine_state.Initialize(); 854 machine_state.Initialize();
828 855
829 return ValidateInstallationTypeForState(machine_state, system_level, type); 856 return ValidateInstallationTypeForState(machine_state, system_level, type);
830 } 857 }
831 858
832 } // namespace installer 859 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698