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 #include "chrome/installer/setup/setup_main.h" | 5 #include "chrome/installer/setup/setup_main.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <msi.h> | 8 #include <msi.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 MiniDumpWithProcessThreadData | // Get PEB and TEB. | 84 MiniDumpWithProcessThreadData | // Get PEB and TEB. |
85 MiniDumpWithUnloadedModules | // Get unloaded modules when available. | 85 MiniDumpWithUnloadedModules | // Get unloaded modules when available. |
86 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. | 86 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. |
87 | 87 |
88 namespace { | 88 namespace { |
89 | 89 |
90 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; | 90 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; |
91 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; | 91 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; |
92 const wchar_t kDisplayVersion[] = L"DisplayVersion"; | 92 const wchar_t kDisplayVersion[] = L"DisplayVersion"; |
93 const wchar_t kMsiDisplayVersionOverwriteDelay[] = L"10"; // seconds as string | 93 const wchar_t kMsiDisplayVersionOverwriteDelay[] = L"10"; // seconds as string |
94 const wchar_t kMsiProductIdPrefix[] = L"EnterpriseProduct"; | |
94 | 95 |
95 // Overwrite an existing DisplayVersion as written by the MSI installer | 96 // Overwrite an existing DisplayVersion as written by the MSI installer |
96 // with the real version number of Chrome. | 97 // with the real version number of Chrome. |
97 LONG OverwriteDisplayVersion(const base::string16& path, | 98 LONG OverwriteDisplayVersion(const base::string16& path, |
98 const base::string16& value, | 99 const base::string16& value, |
99 REGSAM wowkey) { | 100 REGSAM wowkey) { |
100 base::win::RegKey key; | 101 base::win::RegKey key; |
101 LONG result = 0; | 102 LONG result = 0; |
102 base::string16 existing; | 103 base::string16 existing; |
103 if ((result = key.Open(HKEY_LOCAL_MACHINE, path.c_str(), | 104 if ((result = key.Open(HKEY_LOCAL_MACHINE, path.c_str(), |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
202 // Specify an empty path for the patch source since it isn't yet known that | 203 // Specify an empty path for the patch source since it isn't yet known that |
203 // one is needed. It will be supplied in UncompressAndPatchChromeArchive if it | 204 // one is needed. It will be supplied in UncompressAndPatchChromeArchive if it |
204 // is. | 205 // is. |
205 return scoped_ptr<installer::ArchivePatchHelper>( | 206 return scoped_ptr<installer::ArchivePatchHelper>( |
206 new installer::ArchivePatchHelper(working_directory, | 207 new installer::ArchivePatchHelper(working_directory, |
207 compressed_archive, | 208 compressed_archive, |
208 base::FilePath(), | 209 base::FilePath(), |
209 target)); | 210 target)); |
210 } | 211 } |
211 | 212 |
213 base::string16 FindMsiProductId(const InstallerState& installer_state, | |
grt (UTC plus 2)
2015/10/09 13:16:39
please include robert's excellent doc comment for
bcwhite
2015/10/09 19:16:51
Done.
| |
214 const Product* product) { | |
215 HKEY reg_root = installer_state.root_key(); | |
216 BrowserDistribution* dist = product->distribution(); | |
217 DCHECK(dist); | |
218 | |
219 base::win::RegistryValueIterator value_iter(reg_root, | |
220 dist->GetStateKey().c_str()); | |
221 for (; value_iter.Valid(); ++value_iter) { | |
222 base::string16 value_name(value_iter.Name()); | |
223 if (base::StartsWith( | |
224 value_name, kMsiProductIdPrefix, base::CompareCase::INSENSITIVE_ASCII)) | |
225 return value_name.substr(arraysize(kMsiProductIdPrefix) - 1); | |
grt (UTC plus 2)
2015/10/09 13:16:39
nit: braces around this
bcwhite
2015/10/09 19:16:51
Done.
| |
226 } | |
227 return base::string16(); | |
228 } | |
229 | |
212 // Workhorse for producing an uncompressed archive (chrome.7z) given a | 230 // Workhorse for producing an uncompressed archive (chrome.7z) given a |
213 // chrome.packed.7z containing either a patch file based on the version of | 231 // chrome.packed.7z containing either a patch file based on the version of |
214 // chrome being updated or the full uncompressed archive. Returns true on | 232 // chrome being updated or the full uncompressed archive. Returns true on |
215 // success, in which case |archive_type| is populated based on what was found. | 233 // success, in which case |archive_type| is populated based on what was found. |
216 // Returns false on failure, in which case |install_status| contains the error | 234 // Returns false on failure, in which case |install_status| contains the error |
217 // code and the result is written to the registry (via WriteInstallerResult). | 235 // code and the result is written to the registry (via WriteInstallerResult). |
218 bool UncompressAndPatchChromeArchive( | 236 bool UncompressAndPatchChromeArchive( |
219 const installer::InstallationState& original_state, | 237 const installer::InstallationState& original_state, |
220 const installer::InstallerState& installer_state, | 238 const installer::InstallerState& installer_state, |
221 installer::ArchivePatchHelper* archive_helper, | 239 installer::ArchivePatchHelper* archive_helper, |
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1647 for (Products::const_iterator it = products.begin(); it < products.end(); | 1665 for (Products::const_iterator it = products.begin(); it < products.end(); |
1648 ++it) { | 1666 ++it) { |
1649 const Product& product = **it; | 1667 const Product& product = **it; |
1650 product.LaunchUserExperiment(setup_path, install_status, system_install); | 1668 product.LaunchUserExperiment(setup_path, install_status, system_install); |
1651 } | 1669 } |
1652 } | 1670 } |
1653 | 1671 |
1654 // If the installation completed successfully... | 1672 // If the installation completed successfully... |
1655 if (InstallUtil::GetInstallReturnCode(install_status) == 0) { | 1673 if (InstallUtil::GetInstallReturnCode(install_status) == 0) { |
1656 // Update the DisplayVersion created by an MSI-based install. | 1674 // Update the DisplayVersion created by an MSI-based install. |
1675 base::FilePath master_preferences_file( | |
1676 installer_state.target_path().AppendASCII( | |
1677 installer::kDefaultMasterPrefs)); | |
1657 std::string install_id; | 1678 std::string install_id; |
1658 if (prefs.GetString(installer::master_preferences::kMsiProductId, | 1679 if (prefs.GetString(installer::master_preferences::kMsiProductId, |
1659 &install_id)) { | 1680 &install_id)) { |
1681 // A currently active MSI install will have specified the master- | |
1682 // preferences file on the command-line that includes the product-id. | |
1683 // We must delay the setting of the DisplayVersion until after the | |
1684 // grandparent "msiexec" process has exited. | |
1660 base::FilePath new_setup = | 1685 base::FilePath new_setup = |
1661 installer_state.GetInstallerDirectory(*installer_version) | 1686 installer_state.GetInstallerDirectory(*installer_version) |
1662 .Append(kSetupExe); | 1687 .Append(kSetupExe); |
1663 DelayedOverwriteDisplayVersions( | 1688 DelayedOverwriteDisplayVersions( |
1664 new_setup, install_id, *installer_version); | 1689 new_setup, install_id, *installer_version); |
1690 } else { | |
1691 // Only when called by the MSI installer do we need to delay setting | |
1692 // the DisplayVersion. In other runs, such as those done by the auto- | |
1693 // update action, we set the value immediately. | |
1694 const Product* chrome = installer_state.FindProduct( | |
1695 BrowserDistribution::CHROME_BROWSER); | |
1696 if (chrome != NULL) { | |
1697 // Get the app's GUID from an entry in ClientState | |
grt (UTC plus 2)
2015/10/09 13:16:39
nit:
// Get the app's MSI product ID from
bcwhite
2015/10/09 19:16:51
Done.
| |
1698 base::string16 app_guid = FindMsiProductId(installer_state, chrome); | |
1699 if (!app_guid.empty()) { | |
1700 OverwriteDisplayVersions(app_guid, | |
1701 base::UTF8ToUTF16( | |
1702 installer_version->GetString())); | |
1703 } | |
1704 } | |
1665 } | 1705 } |
1666 // Return the path to the directory containing the newly installed | 1706 // Return the path to the directory containing the newly installed |
1667 // setup.exe and uncompressed archive if the caller requested it. | 1707 // setup.exe and uncompressed archive if the caller requested it. |
1668 if (installer_directory) { | 1708 if (installer_directory) { |
1669 *installer_directory = | 1709 *installer_directory = |
1670 installer_state.GetInstallerDirectory(*installer_version); | 1710 installer_state.GetInstallerDirectory(*installer_version); |
1671 } | 1711 } |
1672 } | 1712 } |
1673 | 1713 |
1674 // temp_path's dtor will take care of deleting or scheduling itself for | 1714 // temp_path's dtor will take care of deleting or scheduling itself for |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1826 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1866 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
1827 // to pass through, since this is only returned on uninstall which is | 1867 // to pass through, since this is only returned on uninstall which is |
1828 // never invoked directly by Google Update. | 1868 // never invoked directly by Google Update. |
1829 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1869 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1830 } | 1870 } |
1831 | 1871 |
1832 VLOG(1) << "Installation complete, returning: " << return_code; | 1872 VLOG(1) << "Installation complete, returning: " << return_code; |
1833 | 1873 |
1834 return return_code; | 1874 return return_code; |
1835 } | 1875 } |
OLD | NEW |