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

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: rework Created 7 years, 5 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
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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
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,
726 browser_dist->GetAppShortCutName(), true); 727 browser_dist->GetDisplayName(),
728 true);
727 install_list->AddSetRegValueWorkItem(reg_root, 729 install_list->AddSetRegValueWorkItem(reg_root,
728 uninstall_reg, installer::kUninstallStringField, 730 uninstall_reg, installer::kUninstallStringField,
729 quoted_uninstall_cmd.GetCommandLineString(), true); 731 quoted_uninstall_cmd.GetCommandLineString(), true);
730 install_list->AddSetRegValueWorkItem(reg_root, 732 install_list->AddSetRegValueWorkItem(reg_root,
731 uninstall_reg, 733 uninstall_reg,
732 L"InstallLocation", 734 L"InstallLocation",
733 install_path.value(), 735 install_path.value(),
734 true); 736 true);
735 737
736 BrowserDistribution* dist = product.distribution(); 738 BrowserDistribution* dist = product.distribution();
737 string16 chrome_icon = ShellUtil::FormatIconLocation( 739 string16 chrome_icon = ShellUtil::FormatIconLocation(
738 install_path.Append(dist->GetIconFilename()).value(), 740 install_path.Append(dist->GetIconFilename()).value(),
739 dist->GetIconIndex()); 741 dist->GetIconIndex(BrowserDistribution::SHORTCUT_CHROME));
740 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 742 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
741 L"DisplayIcon", chrome_icon, true); 743 L"DisplayIcon", chrome_icon, true);
742 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 744 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
743 L"NoModify", static_cast<DWORD>(1), 745 L"NoModify", static_cast<DWORD>(1),
744 true); 746 true);
745 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 747 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
746 L"NoRepair", static_cast<DWORD>(1), 748 L"NoRepair", static_cast<DWORD>(1),
747 true); 749 true);
748 750
749 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 751 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
(...skipping 29 matching lines...) Expand all
779 void AddVersionKeyWorkItems(HKEY root, 781 void AddVersionKeyWorkItems(HKEY root,
780 BrowserDistribution* dist, 782 BrowserDistribution* dist,
781 const Version& new_version, 783 const Version& new_version,
782 bool add_language_identifier, 784 bool add_language_identifier,
783 WorkItemList* list) { 785 WorkItemList* list) {
784 // Create Version key for each distribution (if not already present) and set 786 // Create Version key for each distribution (if not already present) and set
785 // the new product version as the last step. 787 // the new product version as the last step.
786 string16 version_key(dist->GetVersionKey()); 788 string16 version_key(dist->GetVersionKey());
787 list->AddCreateRegKeyWorkItem(root, version_key); 789 list->AddCreateRegKeyWorkItem(root, version_key);
788 790
789 string16 product_name(dist->GetAppShortCutName()); 791 string16 product_name(dist->GetDisplayName());
790 list->AddSetRegValueWorkItem(root, version_key, google_update::kRegNameField, 792 list->AddSetRegValueWorkItem(root, version_key, google_update::kRegNameField,
791 product_name, true); // overwrite name also 793 product_name, true); // overwrite name also
792 list->AddSetRegValueWorkItem(root, version_key, 794 list->AddSetRegValueWorkItem(root, version_key,
793 google_update::kRegOopcrashesField, 795 google_update::kRegOopcrashesField,
794 static_cast<DWORD>(1), 796 static_cast<DWORD>(1),
795 false); // set during first install 797 false); // set during first install
796 if (add_language_identifier) { 798 if (add_language_identifier) {
797 // Write the language identifier of the current translation. Omaha's set of 799 // 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 800 // languages is a superset of Chrome's set of translations with this one
799 // exception: what Chrome calls "en-us", Omaha calls "en". sigh. 801 // 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"; 840 LOG(ERROR) << "No products found in AddOemInstallWorkItems";
839 return; 841 return;
840 } 842 }
841 const ProductState* source_product = 843 const ProductState* source_product =
842 original_state.GetNonVersionedProductState(system_install, source_type); 844 original_state.GetNonVersionedProductState(system_install, source_type);
843 845
844 string16 oem_install; 846 string16 oem_install;
845 if (source_product->GetOemInstall(&oem_install)) { 847 if (source_product->GetOemInstall(&oem_install)) {
846 VLOG(1) << "Mirroring oeminstall=\"" << oem_install << "\" from " 848 VLOG(1) << "Mirroring oeminstall=\"" << oem_install << "\" from "
847 << BrowserDistribution::GetSpecificDistribution(source_type)-> 849 << BrowserDistribution::GetSpecificDistribution(source_type)->
848 GetAppShortCutName(); 850 GetDisplayName();
849 install_list->AddCreateRegKeyWorkItem(root_key, multi_key); 851 install_list->AddCreateRegKeyWorkItem(root_key, multi_key);
850 // Always overwrite an old value. 852 // Always overwrite an old value.
851 install_list->AddSetRegValueWorkItem(root_key, multi_key, 853 install_list->AddSetRegValueWorkItem(root_key, multi_key,
852 google_update::kRegOemInstallField, 854 google_update::kRegOemInstallField,
853 oem_install, true); 855 oem_install, true);
854 } else { 856 } else {
855 // Clear any old value. 857 // Clear any old value.
856 install_list->AddDeleteRegValueWorkItem( 858 install_list->AddDeleteRegValueWorkItem(
857 root_key, multi_key, google_update::kRegOemInstallField); 859 root_key, multi_key, google_update::kRegOemInstallField);
858 } 860 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 (!have_eula_accepted || dword_value > eula_accepted)) { 895 (!have_eula_accepted || dword_value > eula_accepted)) {
894 have_eula_accepted = true; 896 have_eula_accepted = true;
895 eula_accepted = dword_value; 897 eula_accepted = dword_value;
896 product_type = this_type; 898 product_type = this_type;
897 } 899 }
898 } 900 }
899 901
900 if (have_eula_accepted) { 902 if (have_eula_accepted) {
901 VLOG(1) << "Mirroring eulaaccepted=" << eula_accepted << " from " 903 VLOG(1) << "Mirroring eulaaccepted=" << eula_accepted << " from "
902 << BrowserDistribution::GetSpecificDistribution(product_type)-> 904 << BrowserDistribution::GetSpecificDistribution(product_type)->
903 GetAppShortCutName(); 905 GetDisplayName();
904 install_list->AddCreateRegKeyWorkItem(root_key, multi_key); 906 install_list->AddCreateRegKeyWorkItem(root_key, multi_key);
905 install_list->AddSetRegValueWorkItem( 907 install_list->AddSetRegValueWorkItem(
906 root_key, multi_key, google_update::kRegEULAAceptedField, 908 root_key, multi_key, google_update::kRegEULAAceptedField,
907 eula_accepted, true); 909 eula_accepted, true);
908 } else { 910 } else {
909 // Clear any old value. 911 // Clear any old value.
910 install_list->AddDeleteRegValueWorkItem( 912 install_list->AddDeleteRegValueWorkItem(
911 root_key, multi_key, google_update::kRegEULAAceptedField); 913 root_key, multi_key, google_update::kRegEULAAceptedField);
912 } 914 }
913 } 915 }
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1432 const Version& new_version, 1434 const Version& new_version,
1433 const Product& product, 1435 const Product& product,
1434 WorkItemList* list) { 1436 WorkItemList* list) {
1435 string16 handler_class_uuid; 1437 string16 handler_class_uuid;
1436 BrowserDistribution* distribution = product.distribution(); 1438 BrowserDistribution* distribution = product.distribution();
1437 if (!distribution->GetCommandExecuteImplClsid(&handler_class_uuid)) { 1439 if (!distribution->GetCommandExecuteImplClsid(&handler_class_uuid)) {
1438 if (InstallUtil::IsChromeSxSProcess()) { 1440 if (InstallUtil::IsChromeSxSProcess()) {
1439 CleanupBadCanaryDelegateExecuteRegistration(target_path, list); 1441 CleanupBadCanaryDelegateExecuteRegistration(target_path, list);
1440 } else { 1442 } else {
1441 VLOG(1) << "No DelegateExecute verb handler processing to do for " 1443 VLOG(1) << "No DelegateExecute verb handler processing to do for "
1442 << distribution->GetAppShortCutName(); 1444 << distribution->GetDisplayName();
1443 } 1445 }
1444 return; 1446 return;
1445 } 1447 }
1446 1448
1447 HKEY root = installer_state.root_key(); 1449 HKEY root = installer_state.root_key();
1448 string16 delegate_execute_path(L"Software\\Classes\\CLSID\\"); 1450 string16 delegate_execute_path(L"Software\\Classes\\CLSID\\");
1449 delegate_execute_path.append(handler_class_uuid); 1451 delegate_execute_path.append(handler_class_uuid);
1450 1452
1451 // Unconditionally remove registration regardless of whether or not it is 1453 // Unconditionally remove registration regardless of whether or not it is
1452 // needed since builds after r132190 included it when it wasn't strictly 1454 // needed since builds after r132190 included it when it wasn't strictly
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1494 const Version& new_version, 1496 const Version& new_version,
1495 const Product& product, 1497 const Product& product,
1496 WorkItemList* list) { 1498 WorkItemList* list) {
1497 DCHECK(installer_state.operation() != InstallerState::UNINSTALL); 1499 DCHECK(installer_state.operation() != InstallerState::UNINSTALL);
1498 BrowserDistribution* distribution = product.distribution(); 1500 BrowserDistribution* distribution = product.distribution();
1499 1501
1500 if (!product.is_chrome() || !installer_state.system_install()) { 1502 if (!product.is_chrome() || !installer_state.system_install()) {
1501 const char* install_level = 1503 const char* install_level =
1502 installer_state.system_install() ? "system" : "user"; 1504 installer_state.system_install() ? "system" : "user";
1503 VLOG(1) << "No Active Setup processing to do for " << install_level 1505 VLOG(1) << "No Active Setup processing to do for " << install_level
1504 << "-level " << distribution->GetAppShortCutName(); 1506 << "-level " << distribution->GetDisplayName();
1505 return; 1507 return;
1506 } 1508 }
1507 DCHECK(installer_state.RequiresActiveSetup()); 1509 DCHECK(installer_state.RequiresActiveSetup());
1508 1510
1509 const HKEY root = HKEY_LOCAL_MACHINE; 1511 const HKEY root = HKEY_LOCAL_MACHINE;
1510 const string16 active_setup_path( 1512 const string16 active_setup_path(
1511 InstallUtil::GetActiveSetupPath(distribution)); 1513 InstallUtil::GetActiveSetupPath(distribution));
1512 1514
1513 VLOG(1) << "Adding registration items for Active Setup."; 1515 VLOG(1) << "Adding registration items for Active Setup.";
1514 list->AddCreateRegKeyWorkItem(root, active_setup_path); 1516 list->AddCreateRegKeyWorkItem(root, active_setup_path);
1515 list->AddSetRegValueWorkItem(root, active_setup_path, L"", 1517 list->AddSetRegValueWorkItem(root, active_setup_path, L"",
1516 distribution->GetAppShortCutName(), true); 1518 distribution->GetDisplayName(), true);
1517 1519
1518 base::FilePath active_setup_exe(installer_state.GetInstallerDirectory( 1520 base::FilePath active_setup_exe(installer_state.GetInstallerDirectory(
1519 new_version).Append(kActiveSetupExe)); 1521 new_version).Append(kActiveSetupExe));
1520 CommandLine cmd(active_setup_exe); 1522 CommandLine cmd(active_setup_exe);
1521 cmd.AppendSwitch(installer::switches::kConfigureUserSettings); 1523 cmd.AppendSwitch(installer::switches::kConfigureUserSettings);
1522 cmd.AppendSwitch(installer::switches::kVerboseLogging); 1524 cmd.AppendSwitch(installer::switches::kVerboseLogging);
1523 cmd.AppendSwitch(installer::switches::kSystemLevel); 1525 cmd.AppendSwitch(installer::switches::kSystemLevel);
1524 product.AppendProductFlags(&cmd); 1526 product.AppendProductFlags(&cmd);
1525 list->AddSetRegValueWorkItem(root, active_setup_path, L"StubPath", 1527 list->AddSetRegValueWorkItem(root, active_setup_path, L"StubPath",
1526 cmd.GetCommandLineString(), true); 1528 cmd.GetCommandLineString(), true);
1527 1529
1528 // TODO(grt): http://crbug.com/75152 Write a reference to a localized 1530 // TODO(grt): http://crbug.com/75152 Write a reference to a localized
1529 // resource. 1531 // resource.
1530 list->AddSetRegValueWorkItem(root, active_setup_path, L"Localized Name", 1532 list->AddSetRegValueWorkItem(root, active_setup_path, L"Localized Name",
1531 distribution->GetAppShortCutName(), true); 1533 distribution->GetDisplayName(), true);
1532 1534
1533 list->AddSetRegValueWorkItem(root, active_setup_path, L"IsInstalled", 1535 list->AddSetRegValueWorkItem(root, active_setup_path, L"IsInstalled",
1534 static_cast<DWORD>(1U), true); 1536 static_cast<DWORD>(1U), true);
1535 1537
1536 list->AddSetRegValueWorkItem(root, active_setup_path, L"Version", 1538 list->AddSetRegValueWorkItem(root, active_setup_path, L"Version",
1537 kActiveSetupVersion, true); 1539 kActiveSetupVersion, true);
1538 } 1540 }
1539 1541
1540 void AddDeleteOldIELowRightsPolicyWorkItems( 1542 void AddDeleteOldIELowRightsPolicyWorkItems(
1541 const InstallerState& installer_state, 1543 const InstallerState& installer_state,
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 if (installer_state.system_install()) 1714 if (installer_state.system_install())
1713 cmd_line.AppendSwitch(switches::kSystemLevel); 1715 cmd_line.AppendSwitch(switches::kSystemLevel);
1714 AppCommand cmd(cmd_line.GetCommandLineString()); 1716 AppCommand cmd(cmd_line.GetCommandLineString());
1715 cmd.set_sends_pings(true); 1717 cmd.set_sends_pings(true);
1716 cmd.set_is_web_accessible(true); 1718 cmd.set_is_web_accessible(true);
1717 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); 1719 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list);
1718 } 1720 }
1719 } 1721 }
1720 1722
1721 } // namespace installer 1723 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698