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 // 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> |
| 11 #include <shlobj.h> | 11 #include <shlobj.h> |
| 12 #include <string> | |
| 12 #include <time.h> | 13 #include <time.h> |
| 13 #include <vector> | 14 #include <vector> |
| 14 | 15 |
| 15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 16 #include "base/file_path.h" | 17 #include "base/file_path.h" |
| 17 #include "base/file_util.h" | 18 #include "base/file_util.h" |
| 18 #include "base/logging.h" | 19 #include "base/logging.h" |
| 19 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 21 #include "base/string16.h" | |
| 20 #include "base/string_util.h" | 22 #include "base/string_util.h" |
| 23 #include "base/stringprintf.h" | |
| 21 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
| 22 #include "base/version.h" | 25 #include "base/version.h" |
| 23 #include "base/win/registry.h" | 26 #include "base/win/registry.h" |
| 24 #include "base/win/windows_version.h" | 27 #include "base/win/windows_version.h" |
| 25 #include "chrome/common/chrome_constants.h" | 28 #include "chrome/common/chrome_constants.h" |
| 26 #include "chrome/installer/setup/install.h" | 29 #include "chrome/installer/setup/install.h" |
| 27 #include "chrome/installer/setup/setup_constants.h" | 30 #include "chrome/installer/setup/setup_constants.h" |
| 28 #include "chrome/installer/util/conditional_work_item_list.h" | 31 #include "chrome/installer/util/conditional_work_item_list.h" |
| 29 #include "chrome/installer/util/create_reg_key_work_item.h" | 32 #include "chrome/installer/util/create_reg_key_work_item.h" |
| 30 #include "chrome/installer/util/google_update_constants.h" | 33 #include "chrome/installer/util/google_update_constants.h" |
| 31 #include "chrome/installer/util/helper.h" | 34 #include "chrome/installer/util/helper.h" |
| 32 #include "chrome/installer/util/installation_state.h" | 35 #include "chrome/installer/util/installation_state.h" |
| 33 #include "chrome/installer/util/installer_state.h" | 36 #include "chrome/installer/util/installer_state.h" |
| 34 #include "chrome/installer/util/install_util.h" | 37 #include "chrome/installer/util/install_util.h" |
| 35 #include "chrome/installer/util/l10n_string_util.h" | 38 #include "chrome/installer/util/l10n_string_util.h" |
| 36 #include "chrome/installer/util/product.h" | 39 #include "chrome/installer/util/product.h" |
| 37 #include "chrome/installer/util/set_reg_value_work_item.h" | 40 #include "chrome/installer/util/set_reg_value_work_item.h" |
| 38 #include "chrome/installer/util/shell_util.h" | 41 #include "chrome/installer/util/shell_util.h" |
| 39 #include "chrome/installer/util/util_constants.h" | 42 #include "chrome/installer/util/util_constants.h" |
| 40 #include "chrome/installer/util/work_item_list.h" | 43 #include "chrome/installer/util/work_item_list.h" |
| 41 #include "chrome_frame/chrome_tab.h" | 44 #include "chrome_frame/chrome_tab.h" |
| 42 | 45 |
| 43 using base::win::RegKey; | 46 using base::win::RegKey; |
| 44 | 47 |
| 48 namespace { | |
| 49 | |
| 50 // Elements that make up install target paths. | |
| 51 const wchar_t kDictionaries[] = L"Dictionaries"; | |
| 52 const wchar_t kImages[] = L"Images"; | |
| 53 const wchar_t kLogoImage[] = L"Logo.png"; | |
| 54 const wchar_t kSmallLogoImage[] = L"SmallLogo.png"; | |
| 55 const wchar_t kSplashScreenImage[] = L"splash-620x300.png"; | |
| 56 const wchar_t kVisualElementsManifest[] = L"VisualElementsManifest.xml"; | |
| 57 const wchar_t kWowHelperExe[] = L"wow_helper.exe"; | |
| 58 | |
| 59 // Adds work items to |install_list| to lay down a version specific | |
| 60 // VisualElementsManifest.xml beside chrome.exe. | |
| 61 void AddVisualElementsInstallWorkItems(const FilePath& src_path, | |
| 62 const FilePath& target_path, | |
| 63 const FilePath& temp_path, | |
| 64 const Version& new_version, | |
| 65 WorkItemList* install_list) { | |
| 66 DCHECK(install_list); | |
| 67 | |
| 68 string16 images_dir = ASCIIToUTF16(new_version.GetString()); | |
| 69 images_dir.push_back(FilePath::kSeparators[0]); | |
| 70 images_dir.append(kImages); | |
| 71 images_dir.push_back(FilePath::kSeparators[0]); | |
| 72 | |
| 73 // Some distributions of Chromium may not include visual elements. Only | |
| 74 // proceed if this distribution does. | |
| 75 if (!file_util::PathExists(src_path.Append(images_dir + kLogoImage))) { | |
|
gab
2012/05/01 01:59:13
No need to use a conditional work item list here,
| |
| 76 LOG(WARNING) << "No visual elements found, skipping related work items."; | |
| 77 } else { | |
| 78 const wchar_t manifest_template[] = | |
| 79 L"<Application\r\n" | |
| 80 L" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n" | |
| 81 L" <VisualElements\r\n" | |
| 82 L" DisplayName=\"%ls\"\r\n" | |
| 83 L" Logo=\"%ls\"\r\n" | |
| 84 L" SmallLogo=\"%ls\"\r\n" | |
| 85 L" ForegroundText=\"light\"\r\n" | |
| 86 L" BackgroundColor=\"white\">\r\n" | |
| 87 L" <DefaultTile ShowName=\"allLogos\"/>\r\n" | |
| 88 L" <SplashScreen Image=\"%ls\"/>\r\n" | |
| 89 L" </VisualElements>\r\n" | |
| 90 L"</Application>"; | |
| 91 | |
| 92 // Fill the manifest with the desired values. | |
| 93 string16 manifest; | |
| 94 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | |
| 95 const string16 display_name = dist->GetAppShortCutName(); | |
| 96 const string16 logo_path = images_dir + kLogoImage; | |
| 97 const string16 small_logo_path = images_dir + kSmallLogoImage; | |
| 98 const string16 splash_path = images_dir + kSplashScreenImage; | |
| 99 base::SStringPrintf(&manifest, manifest_template, display_name, logo_path, | |
|
gab
2012/05/01 01:59:13
Testing the installer now, this call fails silentl
| |
| 100 small_logo_path, splash_path); | |
| 101 | |
| 102 // Write the manifest to the directory where the archive was extracted. | |
| 103 const std::string manifest_utf8 = UTF16ToUTF8(manifest); | |
| 104 file_util::WriteFile(src_path.Append(kVisualElementsManifest), | |
| 105 manifest_utf8.c_str(), manifest_utf8.size()); | |
| 106 | |
| 107 // Add a work item to move the new manifest to |target_path|. | |
| 108 install_list->AddMoveTreeWorkItem( | |
| 109 src_path.Append(kVisualElementsManifest).value(), | |
| 110 target_path.Append(kVisualElementsManifest).value(), | |
| 111 temp_path.value(), | |
| 112 WorkItem::ALWAYS_MOVE); | |
| 113 } | |
| 114 } | |
| 115 | |
| 116 } // namespace | |
| 117 | |
| 45 namespace installer { | 118 namespace installer { |
| 46 | 119 |
| 47 // Local helper to call AddRegisterComDllWorkItems for all DLLs in a set of | 120 // Local helper to call AddRegisterComDllWorkItems for all DLLs in a set of |
| 48 // products managed by a given package. | 121 // products managed by a given package. |
| 49 void AddRegisterComDllWorkItemsForPackage(const InstallerState& installer_state, | 122 void AddRegisterComDllWorkItemsForPackage(const InstallerState& installer_state, |
| 50 const Version* old_version, | 123 const Version* old_version, |
| 51 const Version& new_version, | 124 const Version& new_version, |
| 52 WorkItemList* work_item_list) { | 125 WorkItemList* work_item_list) { |
| 53 // First collect the list of DLLs to be registered from each product. | 126 // First collect the list of DLLs to be registered from each product. |
| 54 std::vector<FilePath> com_dll_list; | 127 std::vector<FilePath> com_dll_list; |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 } | 835 } |
| 763 | 836 |
| 764 // Extra executable for 64 bit systems. | 837 // Extra executable for 64 bit systems. |
| 765 // NOTE: We check for "not disabled" so that if the API call fails, we play it | 838 // NOTE: We check for "not disabled" so that if the API call fails, we play it |
| 766 // safe and copy the executable anyway. | 839 // safe and copy the executable anyway. |
| 767 // NOTE: the file wow_helper.exe is only needed for Vista and below. | 840 // NOTE: the file wow_helper.exe is only needed for Vista and below. |
| 768 if (base::win::OSInfo::GetInstance()->wow64_status() != | 841 if (base::win::OSInfo::GetInstance()->wow64_status() != |
| 769 base::win::OSInfo::WOW64_DISABLED && | 842 base::win::OSInfo::WOW64_DISABLED && |
| 770 base::win::GetVersion() <= base::win::VERSION_VISTA) { | 843 base::win::GetVersion() <= base::win::VERSION_VISTA) { |
| 771 install_list->AddMoveTreeWorkItem( | 844 install_list->AddMoveTreeWorkItem( |
| 772 src_path.Append(installer::kWowHelperExe).value(), | 845 src_path.Append(kWowHelperExe).value(), |
| 773 target_path.Append(installer::kWowHelperExe).value(), | 846 target_path.Append(kWowHelperExe).value(), |
| 774 temp_path.value(), | 847 temp_path.value(), |
| 775 WorkItem::ALWAYS_MOVE); | 848 WorkItem::ALWAYS_MOVE); |
| 776 } | 849 } |
| 777 | 850 |
| 778 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | 851 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
| 779 // Desktop only (i.e. not supporting Metro) versions of Chromium do not have | 852 AddVisualElementsInstallWorkItems(src_path, target_path, temp_path, |
| 780 // to include visual elements. | 853 new_version, install_list); |
| 781 scoped_ptr<WorkItemList> win8_work_items( | |
| 782 WorkItem::CreateConditionalWorkItemList(new ConditionRunIfFileExists( | |
| 783 src_path.Append(L"visualelementsmanifest.xml")))); | |
| 784 // TODO (gab): All of these hard-coded strings are temporary and will be | |
| 785 // deleted in the patch following this one. | |
| 786 win8_work_items->AddMoveTreeWorkItem( | |
| 787 src_path.Append(L"visualelementsmanifest.xml").value(), | |
| 788 target_path.Append(L"visualelementsmanifest.xml").value(), | |
| 789 temp_path.value(), | |
| 790 WorkItem::ALWAYS_MOVE); | |
| 791 win8_work_items->AddMoveTreeWorkItem( | |
| 792 src_path.Append(L"logo.png").value(), | |
| 793 target_path.Append(L"logo.png").value(), | |
| 794 temp_path.value(), | |
| 795 WorkItem::ALWAYS_MOVE); | |
| 796 win8_work_items->AddMoveTreeWorkItem( | |
| 797 src_path.Append(L"smalllogo.png").value(), | |
| 798 target_path.Append(L"smalllogo.png").value(), | |
| 799 temp_path.value(), | |
| 800 WorkItem::ALWAYS_MOVE); | |
| 801 win8_work_items->AddMoveTreeWorkItem( | |
| 802 src_path.Append(L"splash-620x300.png").value(), | |
| 803 target_path.Append(L"splash-620x300.png").value(), | |
| 804 temp_path.value(), | |
| 805 WorkItem::ALWAYS_MOVE); | |
| 806 install_list->AddWorkItem(win8_work_items.release()); | |
| 807 } | 854 } |
| 808 | 855 |
| 809 // In the past, we copied rather than moved for system level installs so that | 856 // In the past, we copied rather than moved for system level installs so that |
| 810 // the permissions of %ProgramFiles% would be picked up. Now that |temp_path| | 857 // the permissions of %ProgramFiles% would be picked up. Now that |temp_path| |
| 811 // is in %ProgramFiles% for system level installs (and in %LOCALAPPDATA% | 858 // is in %ProgramFiles% for system level installs (and in %LOCALAPPDATA% |
| 812 // otherwise), there is no need to do this. | 859 // otherwise), there is no need to do this. |
| 813 // Note that we pass true for check_duplicates to avoid failing on in-use | 860 // Note that we pass true for check_duplicates to avoid failing on in-use |
| 814 // repair runs if the current_version is the same as the new_version. | 861 // repair runs if the current_version is the same as the new_version. |
| 815 bool check_for_duplicates = | 862 bool check_for_duplicates = |
| 816 (current_version != NULL && current_version->get() != NULL && | 863 (current_version != NULL && current_version->get() != NULL && |
| 817 current_version->get()->Equals(new_version)); | 864 current_version->get()->Equals(new_version)); |
| 818 install_list->AddMoveTreeWorkItem( | 865 install_list->AddMoveTreeWorkItem( |
| 819 src_path.AppendASCII(new_version.GetString()).value(), | 866 src_path.AppendASCII(new_version.GetString()).value(), |
| 820 target_path.AppendASCII(new_version.GetString()).value(), | 867 target_path.AppendASCII(new_version.GetString()).value(), |
| 821 temp_path.value(), | 868 temp_path.value(), |
| 822 check_for_duplicates ? WorkItem::CHECK_DUPLICATES : | 869 check_for_duplicates ? WorkItem::CHECK_DUPLICATES : |
| 823 WorkItem::ALWAYS_MOVE); | 870 WorkItem::ALWAYS_MOVE); |
| 824 | 871 |
| 825 // Copy the default Dictionaries only if the folder doesn't exist already. | 872 // Copy the default Dictionaries only if the folder doesn't exist already. |
| 826 // TODO(grt): Use AddMoveTreeWorkItem in a conditional WorkItemList, which | 873 // TODO(grt): Use AddMoveTreeWorkItem in a conditional WorkItemList, which |
| 827 // will be more efficient in space and time. | 874 // will be more efficient in space and time. |
| 828 install_list->AddCopyTreeWorkItem( | 875 install_list->AddCopyTreeWorkItem( |
| 829 src_path.Append(installer::kDictionaries).value(), | 876 src_path.Append(kDictionaries).value(), |
| 830 target_path.Append(installer::kDictionaries).value(), | 877 target_path.Append(kDictionaries).value(), |
| 831 temp_path.value(), WorkItem::IF_NOT_PRESENT); | 878 temp_path.value(), WorkItem::IF_NOT_PRESENT); |
| 832 | 879 |
| 833 // Delete any old_chrome.exe if present (ignore failure if it's in use). | 880 // Delete any old_chrome.exe if present (ignore failure if it's in use). |
| 834 install_list->AddDeleteTreeWorkItem( | 881 install_list->AddDeleteTreeWorkItem( |
| 835 target_path.Append(installer::kChromeOldExe), temp_path) | 882 target_path.Append(installer::kChromeOldExe), temp_path) |
| 836 ->set_ignore_failure(true); | 883 ->set_ignore_failure(true); |
| 837 | 884 |
| 838 // Copy installer in install directory and | 885 // Copy installer in install directory and |
| 839 // add shortcut in Control Panel->Add/Remove Programs. | 886 // add shortcut in Control Panel->Add/Remove Programs. |
| 840 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path, | 887 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path, |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1425 } else { | 1472 } else { |
| 1426 DCHECK(operation == REMOVE_COMMAND); | 1473 DCHECK(operation == REMOVE_COMMAND); |
| 1427 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), | 1474 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), |
| 1428 cmd_key)->set_log_message( | 1475 cmd_key)->set_log_message( |
| 1429 "removing quick-enable-cf command"); | 1476 "removing quick-enable-cf command"); |
| 1430 } | 1477 } |
| 1431 } | 1478 } |
| 1432 } | 1479 } |
| 1433 | 1480 |
| 1434 } // namespace installer | 1481 } // namespace installer |
| OLD | NEW |