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

Side by Side Diff: chrome/installer/setup/install_worker.cc

Issue 15255004: Refactor of BrowserDistribution. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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 unified diff | Download patch
« no previous file with comments | « chrome/installer/setup/install_unittest.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // This file contains the definitions of the installer functions that build 5 // This file contains the definitions of the installer functions that build
6 // the WorkItemList used to install the application. 6 // the WorkItemList used to install the application.
7 7
8 #include "chrome/installer/setup/install_worker.h" 8 #include "chrome/installer/setup/install_worker.h"
9 9
10 #include <oaidl.h> 10 #include <oaidl.h>
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 if (installer_state.system_install()) { 431 if (installer_state.system_install()) {
432 PathService::Get(base::DIR_COMMON_START_MENU, &uninstall_link); 432 PathService::Get(base::DIR_COMMON_START_MENU, &uninstall_link);
433 } else { 433 } else {
434 PathService::Get(base::DIR_START_MENU, &uninstall_link); 434 PathService::Get(base::DIR_START_MENU, &uninstall_link);
435 } 435 }
436 436
437 if (uninstall_link.empty()) { 437 if (uninstall_link.empty()) {
438 LOG(ERROR) << "Failed to get location for shortcut."; 438 LOG(ERROR) << "Failed to get location for shortcut.";
439 } else { 439 } else {
440 uninstall_link = uninstall_link.Append( 440 uninstall_link = uninstall_link.Append(
441 product.distribution()->GetAppShortCutName()); 441 product.distribution()->GetStartMenuShortcutSubfolder(
442 BrowserDistribution::SUBFOLDER_CHROME));
442 uninstall_link = uninstall_link.Append( 443 uninstall_link = uninstall_link.Append(
443 product.distribution()->GetUninstallLinkName() + installer::kLnkExt); 444 product.distribution()->GetUninstallLinkName() + installer::kLnkExt);
444 VLOG(1) << "Deleting old uninstall shortcut (if present): " 445 VLOG(1) << "Deleting old uninstall shortcut (if present): "
445 << uninstall_link.value(); 446 << uninstall_link.value();
446 WorkItem* delete_link = work_item_list->AddDeleteTreeWorkItem( 447 WorkItem* delete_link = work_item_list->AddDeleteTreeWorkItem(
447 uninstall_link, temp_path); 448 uninstall_link, temp_path);
448 delete_link->set_ignore_failure(true); 449 delete_link->set_ignore_failure(true);
449 delete_link->set_log_message( 450 delete_link->set_log_message(
450 "Failed to delete old uninstall shortcut."); 451 "Failed to delete old uninstall shortcut.");
451 } 452 }
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 // MSI installations will manage their own uninstall shortcuts. 716 // MSI installations will manage their own uninstall shortcuts.
716 if (!installer_state.is_msi() && product.ShouldCreateUninstallEntry()) { 717 if (!installer_state.is_msi() && product.ShouldCreateUninstallEntry()) {
717 // We need to quote the command line for the Add/Remove Programs dialog. 718 // We need to quote the command line for the Add/Remove Programs dialog.
718 CommandLine quoted_uninstall_cmd(installer_path); 719 CommandLine quoted_uninstall_cmd(installer_path);
719 DCHECK_EQ(quoted_uninstall_cmd.GetCommandLineString()[0], '"'); 720 DCHECK_EQ(quoted_uninstall_cmd.GetCommandLineString()[0], '"');
720 quoted_uninstall_cmd.AppendArguments(uninstall_arguments, false); 721 quoted_uninstall_cmd.AppendArguments(uninstall_arguments, false);
721 722
722 string16 uninstall_reg = browser_dist->GetUninstallRegPath(); 723 string16 uninstall_reg = browser_dist->GetUninstallRegPath();
723 install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg); 724 install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg);
724 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 725 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
725 installer::kUninstallDisplayNameField, 726 installer::kUninstallDisplayNameField, browser_dist->GetDisplayName(),
726 browser_dist->GetAppShortCutName(), true); 727 true);
727 install_list->AddSetRegValueWorkItem(reg_root, 728 install_list->AddSetRegValueWorkItem(reg_root,
728 uninstall_reg, installer::kUninstallStringField, 729 uninstall_reg, installer::kUninstallStringField,
729 quoted_uninstall_cmd.GetCommandLineString(), true); 730 quoted_uninstall_cmd.GetCommandLineString(), true);
730 install_list->AddSetRegValueWorkItem(reg_root, 731 install_list->AddSetRegValueWorkItem(reg_root,
731 uninstall_reg, 732 uninstall_reg,
732 L"InstallLocation", 733 L"InstallLocation",
733 install_path.value(), 734 install_path.value(),
734 true); 735 true);
735 736
736 BrowserDistribution* dist = product.distribution(); 737 BrowserDistribution* dist = product.distribution();
737 string16 chrome_icon = ShellUtil::FormatIconLocation( 738 string16 chrome_icon = ShellUtil::FormatIconLocation(
738 install_path.Append(dist->GetIconFilename()).value(), 739 install_path.Append(dist->GetIconFilename()).value(),
739 dist->GetIconIndex()); 740 dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME));
740 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 741 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
741 L"DisplayIcon", chrome_icon, true); 742 L"DisplayIcon", chrome_icon, true);
742 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 743 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
743 L"NoModify", static_cast<DWORD>(1), 744 L"NoModify", static_cast<DWORD>(1),
744 true); 745 true);
745 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 746 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
746 L"NoRepair", static_cast<DWORD>(1), 747 L"NoRepair", static_cast<DWORD>(1),
747 true); 748 true);
748 749
749 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 750 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
(...skipping 29 matching lines...) Expand all
779 void AddVersionKeyWorkItems(HKEY root, 780 void AddVersionKeyWorkItems(HKEY root,
780 BrowserDistribution* dist, 781 BrowserDistribution* dist,
781 const Version& new_version, 782 const Version& new_version,
782 bool add_language_identifier, 783 bool add_language_identifier,
783 WorkItemList* list) { 784 WorkItemList* list) {
784 // Create Version key for each distribution (if not already present) and set 785 // Create Version key for each distribution (if not already present) and set
785 // the new product version as the last step. 786 // the new product version as the last step.
786 string16 version_key(dist->GetVersionKey()); 787 string16 version_key(dist->GetVersionKey());
787 list->AddCreateRegKeyWorkItem(root, version_key); 788 list->AddCreateRegKeyWorkItem(root, version_key);
788 789
789 string16 product_name(dist->GetAppShortCutName()); 790 string16 product_name(dist->GetDisplayName());
790 list->AddSetRegValueWorkItem(root, version_key, google_update::kRegNameField, 791 list->AddSetRegValueWorkItem(root, version_key, google_update::kRegNameField,
791 product_name, true); // overwrite name also 792 product_name, true); // overwrite name also
792 list->AddSetRegValueWorkItem(root, version_key, 793 list->AddSetRegValueWorkItem(root, version_key,
793 google_update::kRegOopcrashesField, 794 google_update::kRegOopcrashesField,
794 static_cast<DWORD>(1), 795 static_cast<DWORD>(1),
795 false); // set during first install 796 false); // set during first install
796 if (add_language_identifier) { 797 if (add_language_identifier) {
797 // Write the language identifier of the current translation. Omaha's set of 798 // Write the language identifier of the current translation. Omaha's set of
798 // languages is a superset of Chrome's set of translations with this one 799 // languages is a superset of Chrome's set of translations with this one
799 // exception: what Chrome calls "en-us", Omaha calls "en". sigh. 800 // exception: what Chrome calls "en-us", Omaha calls "en". sigh.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 LOG(ERROR) << "No products found in AddOemInstallWorkItems"; 839 LOG(ERROR) << "No products found in AddOemInstallWorkItems";
839 return; 840 return;
840 } 841 }
841 const ProductState* source_product = 842 const ProductState* source_product =
842 original_state.GetNonVersionedProductState(system_install, source_type); 843 original_state.GetNonVersionedProductState(system_install, source_type);
843 844
844 string16 oem_install; 845 string16 oem_install;
845 if (source_product->GetOemInstall(&oem_install)) { 846 if (source_product->GetOemInstall(&oem_install)) {
846 VLOG(1) << "Mirroring oeminstall=\"" << oem_install << "\" from " 847 VLOG(1) << "Mirroring oeminstall=\"" << oem_install << "\" from "
847 << BrowserDistribution::GetSpecificDistribution(source_type)-> 848 << BrowserDistribution::GetSpecificDistribution(source_type)->
848 GetAppShortCutName(); 849 GetDisplayName();
849 install_list->AddCreateRegKeyWorkItem(root_key, multi_key); 850 install_list->AddCreateRegKeyWorkItem(root_key, multi_key);
850 // Always overwrite an old value. 851 // Always overwrite an old value.
851 install_list->AddSetRegValueWorkItem(root_key, multi_key, 852 install_list->AddSetRegValueWorkItem(root_key, multi_key,
852 google_update::kRegOemInstallField, 853 google_update::kRegOemInstallField,
853 oem_install, true); 854 oem_install, true);
854 } else { 855 } else {
855 // Clear any old value. 856 // Clear any old value.
856 install_list->AddDeleteRegValueWorkItem( 857 install_list->AddDeleteRegValueWorkItem(
857 root_key, multi_key, google_update::kRegOemInstallField); 858 root_key, multi_key, google_update::kRegOemInstallField);
858 } 859 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 (!have_eula_accepted || dword_value > eula_accepted)) { 894 (!have_eula_accepted || dword_value > eula_accepted)) {
894 have_eula_accepted = true; 895 have_eula_accepted = true;
895 eula_accepted = dword_value; 896 eula_accepted = dword_value;
896 product_type = this_type; 897 product_type = this_type;
897 } 898 }
898 } 899 }
899 900
900 if (have_eula_accepted) { 901 if (have_eula_accepted) {
901 VLOG(1) << "Mirroring eulaaccepted=" << eula_accepted << " from " 902 VLOG(1) << "Mirroring eulaaccepted=" << eula_accepted << " from "
902 << BrowserDistribution::GetSpecificDistribution(product_type)-> 903 << BrowserDistribution::GetSpecificDistribution(product_type)->
903 GetAppShortCutName(); 904 GetDisplayName();
904 install_list->AddCreateRegKeyWorkItem(root_key, multi_key); 905 install_list->AddCreateRegKeyWorkItem(root_key, multi_key);
905 install_list->AddSetRegValueWorkItem( 906 install_list->AddSetRegValueWorkItem(
906 root_key, multi_key, google_update::kRegEULAAceptedField, 907 root_key, multi_key, google_update::kRegEULAAceptedField,
907 eula_accepted, true); 908 eula_accepted, true);
908 } else { 909 } else {
909 // Clear any old value. 910 // Clear any old value.
910 install_list->AddDeleteRegValueWorkItem( 911 install_list->AddDeleteRegValueWorkItem(
911 root_key, multi_key, google_update::kRegEULAAceptedField); 912 root_key, multi_key, google_update::kRegEULAAceptedField);
912 } 913 }
913 } 914 }
(...skipping 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 } 1427 }
1427 } 1428 }
1428 } 1429 }
1429 1430
1430 void AddDelegateExecuteWorkItems(const InstallerState& installer_state, 1431 void AddDelegateExecuteWorkItems(const InstallerState& installer_state,
1431 const base::FilePath& target_path, 1432 const base::FilePath& target_path,
1432 const Version& new_version, 1433 const Version& new_version,
1433 const Product& product, 1434 const Product& product,
1434 WorkItemList* list) { 1435 WorkItemList* list) {
1435 string16 handler_class_uuid; 1436 string16 handler_class_uuid;
1436 BrowserDistribution* distribution = product.distribution(); 1437 BrowserDistribution* dist = product.distribution();
1437 if (!distribution->GetCommandExecuteImplClsid(&handler_class_uuid)) { 1438 if (!dist->GetCommandExecuteImplClsid(&handler_class_uuid)) {
1438 if (InstallUtil::IsChromeSxSProcess()) { 1439 if (InstallUtil::IsChromeSxSProcess()) {
1439 CleanupBadCanaryDelegateExecuteRegistration(target_path, list); 1440 CleanupBadCanaryDelegateExecuteRegistration(target_path, list);
1440 } else { 1441 } else {
1441 VLOG(1) << "No DelegateExecute verb handler processing to do for " 1442 VLOG(1) << "No DelegateExecute verb handler processing to do for "
1442 << distribution->GetAppShortCutName(); 1443 << dist->GetDisplayName();
1443 } 1444 }
1444 return; 1445 return;
1445 } 1446 }
1446 1447
1447 HKEY root = installer_state.root_key(); 1448 HKEY root = installer_state.root_key();
1448 string16 delegate_execute_path(L"Software\\Classes\\CLSID\\"); 1449 string16 delegate_execute_path(L"Software\\Classes\\CLSID\\");
1449 delegate_execute_path.append(handler_class_uuid); 1450 delegate_execute_path.append(handler_class_uuid);
1450 1451
1451 // Unconditionally remove registration regardless of whether or not it is 1452 // Unconditionally remove registration regardless of whether or not it is
1452 // needed since builds after r132190 included it when it wasn't strictly 1453 // needed since builds after r132190 included it when it wasn't strictly
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 list->AddCreateRegKeyWorkItem(root, subkey); 1489 list->AddCreateRegKeyWorkItem(root, subkey);
1489 } 1490 }
1490 } 1491 }
1491 1492
1492 void AddActiveSetupWorkItems(const InstallerState& installer_state, 1493 void AddActiveSetupWorkItems(const InstallerState& installer_state,
1493 const base::FilePath& setup_path, 1494 const base::FilePath& setup_path,
1494 const Version& new_version, 1495 const Version& new_version,
1495 const Product& product, 1496 const Product& product,
1496 WorkItemList* list) { 1497 WorkItemList* list) {
1497 DCHECK(installer_state.operation() != InstallerState::UNINSTALL); 1498 DCHECK(installer_state.operation() != InstallerState::UNINSTALL);
1498 BrowserDistribution* distribution = product.distribution(); 1499 BrowserDistribution* dist = product.distribution();
1499 1500
1500 if (!product.is_chrome() || !installer_state.system_install()) { 1501 if (!product.is_chrome() || !installer_state.system_install()) {
1501 const char* install_level = 1502 const char* install_level =
1502 installer_state.system_install() ? "system" : "user"; 1503 installer_state.system_install() ? "system" : "user";
1503 VLOG(1) << "No Active Setup processing to do for " << install_level 1504 VLOG(1) << "No Active Setup processing to do for " << install_level
1504 << "-level " << distribution->GetAppShortCutName(); 1505 << "-level " << dist->GetDisplayName();
1505 return; 1506 return;
1506 } 1507 }
1507 DCHECK(installer_state.RequiresActiveSetup()); 1508 DCHECK(installer_state.RequiresActiveSetup());
1508 1509
1509 const HKEY root = HKEY_LOCAL_MACHINE; 1510 const HKEY root = HKEY_LOCAL_MACHINE;
1510 const string16 active_setup_path( 1511 const string16 active_setup_path(InstallUtil::GetActiveSetupPath(dist));
1511 InstallUtil::GetActiveSetupPath(distribution));
1512 1512
1513 VLOG(1) << "Adding registration items for Active Setup."; 1513 VLOG(1) << "Adding registration items for Active Setup.";
1514 list->AddCreateRegKeyWorkItem(root, active_setup_path); 1514 list->AddCreateRegKeyWorkItem(root, active_setup_path);
1515 list->AddSetRegValueWorkItem(root, active_setup_path, L"", 1515 list->AddSetRegValueWorkItem(root, active_setup_path, L"",
1516 distribution->GetAppShortCutName(), true); 1516 dist->GetDisplayName(), true);
1517 1517
1518 base::FilePath active_setup_exe(installer_state.GetInstallerDirectory( 1518 base::FilePath active_setup_exe(installer_state.GetInstallerDirectory(
1519 new_version).Append(kActiveSetupExe)); 1519 new_version).Append(kActiveSetupExe));
1520 CommandLine cmd(active_setup_exe); 1520 CommandLine cmd(active_setup_exe);
1521 cmd.AppendSwitch(installer::switches::kConfigureUserSettings); 1521 cmd.AppendSwitch(installer::switches::kConfigureUserSettings);
1522 cmd.AppendSwitch(installer::switches::kVerboseLogging); 1522 cmd.AppendSwitch(installer::switches::kVerboseLogging);
1523 cmd.AppendSwitch(installer::switches::kSystemLevel); 1523 cmd.AppendSwitch(installer::switches::kSystemLevel);
1524 product.AppendProductFlags(&cmd); 1524 product.AppendProductFlags(&cmd);
1525 list->AddSetRegValueWorkItem(root, active_setup_path, L"StubPath", 1525 list->AddSetRegValueWorkItem(root, active_setup_path, L"StubPath",
1526 cmd.GetCommandLineString(), true); 1526 cmd.GetCommandLineString(), true);
1527 1527
1528 // TODO(grt): http://crbug.com/75152 Write a reference to a localized 1528 // TODO(grt): http://crbug.com/75152 Write a reference to a localized
1529 // resource. 1529 // resource.
1530 list->AddSetRegValueWorkItem(root, active_setup_path, L"Localized Name", 1530 list->AddSetRegValueWorkItem(root, active_setup_path, L"Localized Name",
1531 distribution->GetAppShortCutName(), true); 1531 dist->GetDisplayName(), true);
1532 1532
1533 list->AddSetRegValueWorkItem(root, active_setup_path, L"IsInstalled", 1533 list->AddSetRegValueWorkItem(root, active_setup_path, L"IsInstalled",
1534 static_cast<DWORD>(1U), true); 1534 static_cast<DWORD>(1U), true);
1535 1535
1536 list->AddSetRegValueWorkItem(root, active_setup_path, L"Version", 1536 list->AddSetRegValueWorkItem(root, active_setup_path, L"Version",
1537 kActiveSetupVersion, true); 1537 kActiveSetupVersion, true);
1538 } 1538 }
1539 1539
1540 void AddDeleteOldIELowRightsPolicyWorkItems( 1540 void AddDeleteOldIELowRightsPolicyWorkItems(
1541 const InstallerState& installer_state, 1541 const InstallerState& installer_state,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 if (installer_state.system_install()) 1712 if (installer_state.system_install())
1713 cmd_line.AppendSwitch(switches::kSystemLevel); 1713 cmd_line.AppendSwitch(switches::kSystemLevel);
1714 AppCommand cmd(cmd_line.GetCommandLineString()); 1714 AppCommand cmd(cmd_line.GetCommandLineString());
1715 cmd.set_sends_pings(true); 1715 cmd.set_sends_pings(true);
1716 cmd.set_is_web_accessible(true); 1716 cmd.set_is_web_accessible(true);
1717 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); 1717 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list);
1718 } 1718 }
1719 } 1719 }
1720 1720
1721 } // namespace installer 1721 } // namespace installer
OLDNEW
« no previous file with comments | « chrome/installer/setup/install_unittest.cc ('k') | chrome/installer/setup/setup_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698