Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <msi.h> | 6 #include <msi.h> |
| 7 #include <shellapi.h> | 7 #include <shellapi.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/at_exit.h" | 12 #include "base/at_exit.h" |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/file_version_info.h" | 16 #include "base/file_version_info.h" |
| 17 #include "base/path_service.h" | 17 #include "base/path_service.h" |
| 18 #include "base/process_util.h" | 18 #include "base/process_util.h" |
| 19 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
| 20 #include "base/string_util.h" | 20 #include "base/string_util.h" |
| 21 #include "base/utf_string_conversions.h" | 21 #include "base/utf_string_conversions.h" |
| 22 #include "base/values.h" | 22 #include "base/values.h" |
| 23 #include "base/win/registry.h" | |
| 23 #include "base/win/scoped_handle.h" | 24 #include "base/win/scoped_handle.h" |
| 24 #include "base/win/win_util.h" | 25 #include "base/win/win_util.h" |
| 25 #include "base/win/windows_version.h" | 26 #include "base/win/windows_version.h" |
| 26 #include "breakpad/src/client/windows/handler/exception_handler.h" | 27 #include "breakpad/src/client/windows/handler/exception_handler.h" |
| 27 #include "chrome/common/chrome_switches.h" | 28 #include "chrome/common/chrome_switches.h" |
| 28 #include "chrome/installer/setup/chrome_frame_ready_mode.h" | 29 #include "chrome/installer/setup/chrome_frame_ready_mode.h" |
| 29 #include "chrome/installer/setup/install.h" | 30 #include "chrome/installer/setup/install.h" |
| 30 #include "chrome/installer/setup/setup_constants.h" | 31 #include "chrome/installer/setup/setup_constants.h" |
| 31 #include "chrome/installer/setup/setup_util.h" | 32 #include "chrome/installer/setup/setup_util.h" |
| 32 #include "chrome/installer/setup/uninstall.h" | 33 #include "chrome/installer/setup/uninstall.h" |
| 33 #include "chrome/installer/util/browser_distribution.h" | 34 #include "chrome/installer/util/browser_distribution.h" |
| 35 #include "chrome/installer/util/channel_info.h" | |
| 34 #include "chrome/installer/util/delete_after_reboot_helper.h" | 36 #include "chrome/installer/util/delete_after_reboot_helper.h" |
| 35 #include "chrome/installer/util/delete_tree_work_item.h" | 37 #include "chrome/installer/util/delete_tree_work_item.h" |
| 36 #include "chrome/installer/util/google_update_settings.h" | 38 #include "chrome/installer/util/google_update_settings.h" |
| 37 #include "chrome/installer/util/google_update_constants.h" | 39 #include "chrome/installer/util/google_update_constants.h" |
| 38 #include "chrome/installer/util/helper.h" | 40 #include "chrome/installer/util/helper.h" |
| 39 #include "chrome/installer/util/html_dialog.h" | 41 #include "chrome/installer/util/html_dialog.h" |
| 40 #include "chrome/installer/util/install_util.h" | 42 #include "chrome/installer/util/install_util.h" |
| 41 #include "chrome/installer/util/installer_state.h" | 43 #include "chrome/installer/util/installer_state.h" |
| 42 #include "chrome/installer/util/installation_state.h" | 44 #include "chrome/installer/util/installation_state.h" |
| 43 #include "chrome/installer/util/l10n_string_util.h" | 45 #include "chrome/installer/util/l10n_string_util.h" |
| 44 #include "chrome/installer/util/logging_installer.h" | 46 #include "chrome/installer/util/logging_installer.h" |
| 45 #include "chrome/installer/util/lzma_util.h" | 47 #include "chrome/installer/util/lzma_util.h" |
| 46 #include "chrome/installer/util/master_preferences.h" | 48 #include "chrome/installer/util/master_preferences.h" |
| 47 #include "chrome/installer/util/master_preferences_constants.h" | 49 #include "chrome/installer/util/master_preferences_constants.h" |
| 48 #include "chrome/installer/util/package_properties.h" | |
| 49 #include "chrome/installer/util/shell_util.h" | 50 #include "chrome/installer/util/shell_util.h" |
| 50 #include "chrome/installer/util/util_constants.h" | 51 #include "chrome/installer/util/util_constants.h" |
| 51 | 52 |
| 52 #include "installer_util_strings.h" // NOLINT | 53 #include "installer_util_strings.h" // NOLINT |
| 53 | 54 |
| 54 using installer::InstallerState; | 55 using installer::InstallerState; |
| 55 using installer::InstallationState; | 56 using installer::InstallationState; |
| 56 using installer::Product; | 57 using installer::Product; |
| 57 using installer::ProductPackageMapping; | |
| 58 using installer::ProductState; | 58 using installer::ProductState; |
| 59 using installer::Products; | 59 using installer::Products; |
| 60 using installer::Package; | |
| 61 using installer::Packages; | |
| 62 using installer::MasterPreferences; | 60 using installer::MasterPreferences; |
| 63 | 61 |
| 64 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; | 62 const wchar_t kChromePipeName[] = L"\\\\.\\pipe\\ChromeCrashServices"; |
| 65 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; | 63 const wchar_t kGoogleUpdatePipeName[] = L"\\\\.\\pipe\\GoogleCrashServices\\"; |
| 66 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; | 64 const wchar_t kSystemPrincipalSid[] = L"S-1-5-18"; |
| 67 | 65 |
| 68 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( | 66 const MINIDUMP_TYPE kLargerDumpType = static_cast<MINIDUMP_TYPE>( |
| 69 MiniDumpWithProcessThreadData | // Get PEB and TEB. | 67 MiniDumpWithProcessThreadData | // Get PEB and TEB. |
| 70 MiniDumpWithUnloadedModules | // Get unloaded modules when available. | 68 MiniDumpWithUnloadedModules | // Get unloaded modules when available. |
| 71 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. | 69 MiniDumpWithIndirectlyReferencedMemory); // Get memory referenced by stack. |
| 72 | 70 |
| 73 namespace { | 71 namespace { |
| 74 | 72 |
| 75 // This method unpacks and uncompresses the given archive file. For Chrome | 73 // This method unpacks and uncompresses the given archive file. For Chrome |
| 76 // install we are creating a uncompressed archive that contains all the files | 74 // install we are creating a uncompressed archive that contains all the files |
| 77 // needed for the installer. This uncompressed archive is later compressed. | 75 // needed for the installer. This uncompressed archive is later compressed. |
| 78 // | 76 // |
| 79 // This method first uncompresses archive specified by parameter "archive" | 77 // This method first uncompresses archive specified by parameter "archive" |
| 80 // and assumes that it will result in an uncompressed full archive file | 78 // and assumes that it will result in an uncompressed full archive file |
| 81 // (chrome.7z) or uncompressed archive patch file (chrome_patch.diff). If it | 79 // (chrome.7z) or uncompressed archive patch file (chrome_patch.diff). If it |
| 82 // is patch file, it is applied to the old archive file that should be | 80 // is patch file, it is applied to the old archive file that should be |
| 83 // present on the system already. As the final step the new archive file | 81 // present on the system already. As the final step the new archive file |
| 84 // is unpacked in the path specified by parameter "output_directory". | 82 // is unpacked in the path specified by parameter "output_directory". |
| 85 DWORD UnPackArchive(const FilePath& archive, | 83 DWORD UnPackArchive(const FilePath& archive, |
| 86 const Package& installation, | 84 const InstallerState& installer_state, |
| 87 const FilePath& temp_path, | 85 const FilePath& temp_path, |
| 88 const FilePath& output_directory, | 86 const FilePath& output_directory, |
| 89 bool& incremental_install) { | 87 bool& incremental_install) { |
| 90 // First uncompress the payload. This could be a differential | 88 // First uncompress the payload. This could be a differential |
| 91 // update (patch.7z) or full archive (chrome.7z). If this uncompress fails | 89 // update (patch.7z) or full archive (chrome.7z). If this uncompress fails |
| 92 // return with error. | 90 // return with error. |
| 93 std::wstring unpacked_file; | 91 std::wstring unpacked_file; |
| 94 int32 ret = LzmaUtil::UnPackArchive(archive.value(), temp_path.value(), | 92 int32 ret = LzmaUtil::UnPackArchive(archive.value(), temp_path.value(), |
| 95 &unpacked_file); | 93 &unpacked_file); |
| 96 if (ret != NO_ERROR) | 94 if (ret != NO_ERROR) |
| 97 return ret; | 95 return ret; |
| 98 | 96 |
| 99 FilePath uncompressed_archive(temp_path.Append(installer::kChromeArchive)); | 97 FilePath uncompressed_archive(temp_path.Append(installer::kChromeArchive)); |
| 100 scoped_ptr<Version> archive_version( | 98 scoped_ptr<Version> archive_version( |
| 101 installer::GetVersionFromArchiveDir(installation.path())); | 99 installer::GetVersionFromArchiveDir(installer_state.target_path())); |
| 102 | 100 |
| 103 // Check if this is differential update and if it is, patch it to the | 101 // Check if this is differential update and if it is, patch it to the |
| 104 // installer archive that should already be on the machine. We assume | 102 // installer archive that should already be on the machine. We assume |
| 105 // it is a differential installer if chrome.7z is not found. | 103 // it is a differential installer if chrome.7z is not found. |
| 106 if (!file_util::PathExists(uncompressed_archive)) { | 104 if (!file_util::PathExists(uncompressed_archive)) { |
| 107 incremental_install = true; | 105 incremental_install = true; |
| 108 VLOG(1) << "Differential patch found. Applying to existing archive."; | 106 VLOG(1) << "Differential patch found. Applying to existing archive."; |
| 109 if (!archive_version.get()) { | 107 if (!archive_version.get()) { |
| 110 LOG(ERROR) << "Can not use differential update when Chrome is not " | 108 LOG(ERROR) << "Can not use differential update when Chrome is not " |
| 111 << "installed on the system."; | 109 << "installed on the system."; |
| 112 return installer::CHROME_NOT_INSTALLED; | 110 return installer::CHROME_NOT_INSTALLED; |
| 113 } | 111 } |
| 114 | 112 |
| 115 FilePath existing_archive(installation.path().Append( | 113 FilePath existing_archive(installer_state.target_path().Append( |
| 116 UTF8ToWide(archive_version->GetString()))); | 114 UTF8ToWide(archive_version->GetString()))); |
| 117 existing_archive = existing_archive.Append(installer::kInstallerDir); | 115 existing_archive = existing_archive.Append(installer::kInstallerDir); |
| 118 existing_archive = existing_archive.Append(installer::kChromeArchive); | 116 existing_archive = existing_archive.Append(installer::kChromeArchive); |
| 119 if (int i = installer::ApplyDiffPatch(FilePath(existing_archive), | 117 if (int i = installer::ApplyDiffPatch(FilePath(existing_archive), |
| 120 FilePath(unpacked_file), | 118 FilePath(unpacked_file), |
| 121 FilePath(uncompressed_archive))) { | 119 FilePath(uncompressed_archive))) { |
| 122 LOG(ERROR) << "Binary patching failed with error " << i; | 120 LOG(ERROR) << "Binary patching failed with error " << i; |
| 123 return i; | 121 return i; |
| 124 } | 122 } |
| 125 } | 123 } |
| 126 | 124 |
| 127 // Unpack the uncompressed archive. | 125 // Unpack the uncompressed archive. |
| 128 return LzmaUtil::UnPackArchive(uncompressed_archive.value(), | 126 return LzmaUtil::UnPackArchive(uncompressed_archive.value(), |
| 129 output_directory.value(), &unpacked_file); | 127 output_directory.value(), &unpacked_file); |
| 130 } | 128 } |
| 131 | 129 |
| 132 | 130 |
| 133 // This function is called when --rename-chrome-exe option is specified on | 131 // This function is called when --rename-chrome-exe option is specified on |
| 134 // setup.exe command line. This function assumes an in-use update has happened | 132 // setup.exe command line. This function assumes an in-use update has happened |
| 135 // for Chrome so there should be a file called new_chrome.exe on the file | 133 // for Chrome so there should be a file called new_chrome.exe on the file |
| 136 // system and a key called 'opv' in the registry. This function will move | 134 // system and a key called 'opv' in the registry. This function will move |
| 137 // new_chrome.exe to chrome.exe and delete 'opv' key in one atomic operation. | 135 // new_chrome.exe to chrome.exe and delete 'opv' key in one atomic operation. |
| 138 installer::InstallStatus RenameChromeExecutables( | 136 installer::InstallStatus RenameChromeExecutables( |
| 139 const Package& installation) { | 137 const InstallerState& installer_state) { |
| 140 FilePath chrome_exe(installation.path().Append(installer::kChromeExe)); | 138 const FilePath &target_path = installer_state.target_path(); |
| 141 FilePath chrome_old_exe(installation.path().Append( | 139 FilePath chrome_exe(target_path.Append(installer::kChromeExe)); |
| 142 installer::kChromeOldExe)); | 140 FilePath chrome_old_exe(target_path.Append(installer::kChromeOldExe)); |
| 143 FilePath chrome_new_exe(installation.path().Append( | 141 FilePath chrome_new_exe(target_path.Append(installer::kChromeNewExe)); |
| 144 installer::kChromeNewExe)); | |
| 145 | 142 |
| 146 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); | 143 scoped_ptr<WorkItemList> install_list(WorkItem::CreateWorkItemList()); |
| 147 install_list->AddDeleteTreeWorkItem(chrome_old_exe); | 144 install_list->AddDeleteTreeWorkItem(chrome_old_exe); |
| 148 FilePath temp_path; | 145 FilePath temp_path; |
| 149 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { | 146 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { |
| 150 LOG(ERROR) << "Failed to create Temp directory " << temp_path.value(); | 147 LOG(ERROR) << "Failed to create Temp directory " << temp_path.value(); |
| 151 return installer::RENAME_FAILED; | 148 return installer::RENAME_FAILED; |
| 152 } | 149 } |
| 153 | 150 |
| 154 install_list->AddCopyTreeWorkItem(chrome_new_exe.value(), | 151 install_list->AddCopyTreeWorkItem(chrome_new_exe.value(), |
| 155 chrome_exe.value(), | 152 chrome_exe.value(), |
| 156 temp_path.ToWStringHack(), | 153 temp_path.ToWStringHack(), |
| 157 WorkItem::IF_DIFFERENT, | 154 WorkItem::IF_DIFFERENT, |
| 158 std::wstring()); | 155 std::wstring()); |
| 159 install_list->AddDeleteTreeWorkItem(chrome_new_exe); | 156 install_list->AddDeleteTreeWorkItem(chrome_new_exe); |
| 160 | 157 |
| 161 HKEY reg_root = installation.system_level() ? HKEY_LOCAL_MACHINE : | 158 HKEY reg_root = installer_state.root_key(); |
| 162 HKEY_CURRENT_USER; | 159 BrowserDistribution* distribution = installer_state.multi_install() ? |
| 163 const Products& products = installation.products(); | 160 installer_state.multi_package_binaries_distribution() : |
| 164 for (size_t i = 0; i < products.size(); ++i) { | 161 installer_state.products()[0]->distribution(); |
| 165 const Product* product = products[i]; | 162 std::wstring version_key(distribution->GetVersionKey()); |
| 166 BrowserDistribution* browser_dist = product->distribution(); | 163 install_list->AddDeleteRegValueWorkItem(reg_root, |
| 167 std::wstring version_key(browser_dist->GetVersionKey()); | 164 version_key, |
| 168 install_list->AddDeleteRegValueWorkItem(reg_root, | 165 google_update::kRegOldVersionField); |
| 169 version_key, | 166 install_list->AddDeleteRegValueWorkItem(reg_root, |
| 170 google_update::kRegOldVersionField); | 167 version_key, |
| 171 install_list->AddDeleteRegValueWorkItem(reg_root, | 168 google_update::kRegRenameCmdField); |
| 172 version_key, | 169 |
| 173 google_update::kRegRenameCmdField); | |
| 174 } | |
| 175 installer::InstallStatus ret = installer::RENAME_SUCCESSFUL; | 170 installer::InstallStatus ret = installer::RENAME_SUCCESSFUL; |
| 176 if (!install_list->Do()) { | 171 if (!install_list->Do()) { |
| 177 LOG(ERROR) << "Renaming of executables failed. Rolling back any changes."; | 172 LOG(ERROR) << "Renaming of executables failed. Rolling back any changes."; |
| 178 install_list->Rollback(); | 173 install_list->Rollback(); |
| 179 ret = installer::RENAME_FAILED; | 174 ret = installer::RENAME_FAILED; |
| 180 } | 175 } |
| 181 file_util::Delete(temp_path, true); | 176 file_util::Delete(temp_path, true); |
| 182 return ret; | 177 return ret; |
| 183 } | 178 } |
| 184 | 179 |
| 180 // Multi-install conditions: | |
| 181 // We will push --multi-install --chrome --chrome-frame --ready-mode to Chrome | |
| 182 // installations: | |
| 183 // - If a non-multi CF installation is present, remove CF from the set of | |
| 184 // products. | |
| 185 // - If a multi CF installation is present, preserve all options from the | |
| 186 // installation (i.e., ignore the command-line options). | |
| 187 // We will push --multi-install --chrome-frame to Chrome Frame installations. | |
| 188 // - If a non-multi CF installation is present, fail. | |
| 189 // - If a Chrome installation on a different channel is present, fail. | |
| 190 // - If a Chrome installation is present, add it to the set of products to | |
| 191 // install. | |
|
robertshield
2011/01/20 22:06:06
This comment, while useful, is specific to the cur
grt (UTC plus 2)
2011/01/21 05:27:51
Done.
| |
| 185 bool CheckPreInstallConditions(const InstallationState& original_state, | 192 bool CheckPreInstallConditions(const InstallationState& original_state, |
| 186 const InstallerState& installer_state, | |
| 187 const Package& installation, | |
| 188 const MasterPreferences& prefs, | 193 const MasterPreferences& prefs, |
| 194 InstallerState* installer_state, | |
| 189 installer::InstallStatus* status) { | 195 installer::InstallStatus* status) { |
| 190 const Products& products = installation.products(); | 196 const Products& products = installer_state->products(); |
| 191 DCHECK(products.size()); | 197 DCHECK(products.size()); |
| 192 | 198 |
| 193 bool is_first_install = true; | 199 bool is_first_install = true; |
| 194 const bool system_level = installation.system_level(); | 200 const bool system_level = installer_state->system_install(); |
| 201 | |
| 202 if (installer_state->multi_install()) { | |
| 203 const Product* chrome = | |
| 204 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); | |
| 205 const Product* chrome_frame = | |
| 206 installer_state->FindProduct(BrowserDistribution::CHROME_FRAME); | |
| 207 const ProductState* cf_state = | |
| 208 original_state.GetProductState(system_level, | |
| 209 BrowserDistribution::CHROME_FRAME); | |
| 210 if (chrome != NULL) { | |
| 211 if (chrome_frame != NULL && | |
| 212 chrome_frame->HasOption(installer::kOptionReadyMode)) { | |
| 213 // We're being asked to install Chrome with Chrome Frame in ready-mode. | |
| 214 // This is an optimistic operation: if a SxS install of Chrome Frame | |
| 215 // is already present, don't touch it; if a multi-install of Chrome | |
| 216 // Frame is present, preserve its settings (ready-mode, CEEE). | |
| 217 if (cf_state != NULL) { | |
| 218 installer_state->RemoveProduct(chrome_frame); | |
| 219 chrome_frame = NULL; | |
| 220 if (cf_state->multi_install()) { | |
| 221 chrome_frame = installer_state->AddProductFromState( | |
| 222 BrowserDistribution::CHROME_FRAME, *cf_state); | |
| 223 VLOG(1) << "Upgrading existing multi-install " | |
| 224 << chrome_frame->distribution()->GetApplicationName() | |
| 225 << " rather than installing in ready-mode."; | |
| 226 } else { | |
| 227 VLOG(1) << "Skipping upgrade of single-install Chrome Frame rather " | |
| 228 "than installing in ready-mode."; | |
| 229 } | |
| 230 } else { | |
| 231 VLOG(1) << "Performing initial install of Chrome Frame ready-mode."; | |
| 232 } | |
| 233 } | |
| 234 } else if (chrome_frame != NULL) { | |
|
robertshield
2011/01/20 22:06:06
This is fair, but we will need explicit integratio
grt (UTC plus 2)
2011/01/21 05:27:51
It seems fairly straightforward. Are you comforta
| |
| 235 // We're being asked to install or update Chrome Frame alone. Fail if a | |
| 236 // single-install of Chrome Frame is already installed. | |
| 237 // TODO(grt): Add support for migration of Chrome Frame from single- to | |
| 238 // multi-install. | |
| 239 if (cf_state != NULL && !cf_state->multi_install()) { | |
| 240 *status = installer::NON_MULTI_INSTALLATION_EXISTS; | |
| 241 InstallUtil::WriteInstallerResult(system_level, | |
| 242 installer_state->state_key(), *status, | |
| 243 IDS_INSTALL_NON_MULTI_INSTALLATION_EXISTS_BASE, NULL); | |
| 244 return false; | |
| 245 } | |
| 246 const ProductState* chrome_state = | |
| 247 original_state.GetProductState(system_level, | |
| 248 BrowserDistribution::CHROME_BROWSER); | |
| 249 if (chrome_state != NULL) { | |
| 250 base::win::RegKey key; | |
| 251 installer::ChannelInfo cf_channel; | |
| 252 // Chrome Frame may not yet be installed, so peek into the registry | |
| 253 // directly to see what channel Google Update has specified. There will | |
| 254 // be no value if we're not being managed by Google Update. | |
| 255 if (key.Open(installer_state->root_key(), | |
| 256 chrome_frame->distribution()->GetStateKey().c_str(), | |
| 257 KEY_QUERY_VALUE) == ERROR_SUCCESS) { | |
| 258 cf_channel.Initialize(key); | |
| 259 } | |
| 260 // Fail if Chrome is already installed but is on a different update | |
| 261 // channel. | |
| 262 if (!cf_channel.EqualsBaseOf(chrome_state->channel())) { | |
| 263 *status = installer::CONFLICTING_CHANNEL_EXISTS; | |
| 264 InstallUtil::WriteInstallerResult(system_level, | |
| 265 installer_state->state_key(), *status, | |
| 266 IDS_INSTALL_CONFLICTING_CHANNEL_EXISTS_BASE, NULL); | |
| 267 return false; | |
| 268 } | |
| 269 // Otherwise, add Chrome to the set of products so that it is updated, | |
| 270 // too. | |
| 271 chrome = installer_state->AddProductFromState( | |
| 272 BrowserDistribution::CHROME_BROWSER, *chrome_state); | |
| 273 VLOG(1) << "Upgrading existing multi-install " | |
| 274 << chrome->distribution()->GetApplicationName() | |
| 275 << " along with " | |
| 276 << chrome_frame->distribution()->GetApplicationName(); | |
| 277 } | |
| 278 } | |
| 279 } | |
| 195 | 280 |
| 196 for (size_t i = 0; i < products.size(); ++i) { | 281 for (size_t i = 0; i < products.size(); ++i) { |
| 197 const Product* product = products[i]; | 282 const Product* product = products[i]; |
| 198 BrowserDistribution* browser_dist = product->distribution(); | 283 BrowserDistribution* browser_dist = product->distribution(); |
| 284 | |
| 285 // Ensure that existing installs are of the same package type. | |
| 199 const ProductState* product_state = | 286 const ProductState* product_state = |
| 200 original_state.GetProductState(system_level, browser_dist->GetType()); | 287 original_state.GetProductState(system_level, browser_dist->GetType()); |
| 201 if (product_state != NULL) | 288 if (product_state != NULL) { |
| 202 is_first_install = false; | 289 is_first_install = false; |
| 290 // Is the existing install's package type the same as this run? | |
| 291 if (installer_state->multi_install()) { | |
| 292 if (!product_state->multi_install()) { | |
| 293 *status = installer::NON_MULTI_INSTALLATION_EXISTS; | |
| 294 InstallUtil::WriteInstallerResult(system_level, | |
| 295 installer_state->state_key(), *status, | |
| 296 IDS_INSTALL_NON_MULTI_INSTALLATION_EXISTS_BASE, NULL); | |
| 297 return false; | |
| 298 } | |
| 299 } else { | |
| 300 if (product_state->multi_install()) { | |
| 301 *status = installer::MULTI_INSTALLATION_EXISTS; | |
| 302 InstallUtil::WriteInstallerResult(system_level, | |
| 303 installer_state->state_key(), *status, | |
| 304 IDS_INSTALL_MULTI_INSTALLATION_EXISTS_BASE, NULL); | |
| 305 return false; | |
| 306 } | |
| 307 } | |
| 308 } | |
| 203 | 309 |
| 204 // Check to avoid simultaneous per-user and per-machine installs. | 310 // Check to avoid simultaneous per-user and per-machine installs. |
| 205 const ProductState* other_state = | 311 const ProductState* other_state = |
| 206 original_state.GetProductState(!system_level, browser_dist->GetType()); | 312 original_state.GetProductState(!system_level, browser_dist->GetType()); |
| 207 | |
| 208 if (other_state != NULL) { | 313 if (other_state != NULL) { |
| 209 LOG(ERROR) << "Already installed version " | 314 LOG(ERROR) << "Already installed version " |
| 210 << other_state->version().GetString() | 315 << other_state->version().GetString() |
| 211 << " conflicts with the current install mode."; | 316 << " conflicts with the current install mode."; |
| 212 if (!system_level && is_first_install && product->is_chrome()) { | 317 if (!system_level && is_first_install && product->is_chrome()) { |
| 213 // This is user-level install and there is a system-level chrome | 318 // This is user-level install and there is a system-level chrome |
| 214 // installation. Instruct Omaha to launch the existing one. There | 319 // installation. Instruct Google Update to launch the existing one. |
| 215 // should be no error dialog. | 320 // There should be no error dialog. |
|
robertshield
2011/01/20 22:06:06
As a nit: having the launching of the existing sys
grt (UTC plus 2)
2011/01/21 05:27:51
Done.
| |
| 216 FilePath chrome_exe(installer::GetChromeInstallPath(!system_level, | 321 FilePath chrome_exe(installer::GetChromeInstallPath(!system_level, |
| 217 browser_dist)); | 322 browser_dist)); |
| 218 if (chrome_exe.empty()) { | 323 if (chrome_exe.empty()) { |
| 219 // If we failed to construct install path. Give up. | 324 // If we failed to construct install path. Give up. |
| 220 *status = installer::OS_ERROR; | 325 *status = installer::OS_ERROR; |
| 221 InstallUtil::WriteInstallerResult(system_level, | 326 InstallUtil::WriteInstallerResult(system_level, |
| 222 installer_state.state_key(), *status, IDS_INSTALL_OS_ERROR_BASE, | 327 installer_state->state_key(), *status, IDS_INSTALL_OS_ERROR_BASE, |
| 223 NULL); | 328 NULL); |
| 224 } else { | 329 } else { |
| 225 *status = installer::EXISTING_VERSION_LAUNCHED; | 330 *status = installer::EXISTING_VERSION_LAUNCHED; |
| 226 chrome_exe = chrome_exe.Append(installer::kChromeExe); | 331 chrome_exe = chrome_exe.Append(installer::kChromeExe); |
| 227 CommandLine cmd(chrome_exe); | 332 CommandLine cmd(chrome_exe); |
| 228 cmd.AppendSwitch(switches::kFirstRun); | 333 cmd.AppendSwitch(switches::kFirstRun); |
| 229 InstallUtil::WriteInstallerResult(system_level, | 334 InstallUtil::WriteInstallerResult(system_level, |
| 230 installer_state.state_key(), *status, 0, NULL); | 335 installer_state->state_key(), *status, 0, NULL); |
| 231 VLOG(1) << "Launching existing system-level chrome instead."; | 336 VLOG(1) << "Launching existing system-level chrome instead."; |
| 232 base::LaunchApp(cmd, false, false, NULL); | 337 base::LaunchApp(cmd, false, false, NULL); |
| 233 } | 338 } |
| 234 return false; | 339 return false; |
| 235 } | 340 } |
| 236 | 341 |
| 237 // If the following compile assert fires it means that the InstallStatus | 342 // If the following compile assert fires it means that the InstallStatus |
| 238 // enumeration changed which will break the contract between the old | 343 // enumeration changed which will break the contract between the old |
| 239 // chrome installed and the new setup.exe that is trying to upgrade. | 344 // chrome installed and the new setup.exe that is trying to upgrade. |
| 240 COMPILE_ASSERT(installer::SXS_OPTION_NOT_SUPPORTED == 33, | 345 COMPILE_ASSERT(installer::SXS_OPTION_NOT_SUPPORTED == 33, |
| 241 dont_change_enum); | 346 dont_change_enum); |
|
robertshield
2011/01/20 22:06:06
I feel this COMPILE_ASSERT should be next to the i
grt (UTC plus 2)
2011/01/21 05:27:51
Me too, but it doesn't seem to work there for some
| |
| 242 | 347 |
| 243 // This is an update, not an install. Omaha should know the difference | 348 // This is an update, not an install. Omaha should know the difference |
| 244 // and not show a dialog. | 349 // and not show a dialog. |
| 245 *status = system_level ? installer::USER_LEVEL_INSTALL_EXISTS : | 350 *status = system_level ? installer::USER_LEVEL_INSTALL_EXISTS : |
| 246 installer::SYSTEM_LEVEL_INSTALL_EXISTS; | 351 installer::SYSTEM_LEVEL_INSTALL_EXISTS; |
| 247 int str_id = system_level ? IDS_INSTALL_USER_LEVEL_EXISTS_BASE : | 352 int str_id = system_level ? IDS_INSTALL_USER_LEVEL_EXISTS_BASE : |
| 248 IDS_INSTALL_SYSTEM_LEVEL_EXISTS_BASE; | 353 IDS_INSTALL_SYSTEM_LEVEL_EXISTS_BASE; |
| 249 InstallUtil::WriteInstallerResult(system_level, | 354 InstallUtil::WriteInstallerResult(system_level, |
| 250 installer_state.state_key(), *status, str_id, NULL); | 355 installer_state->state_key(), *status, str_id, NULL); |
| 251 return false; | 356 return false; |
| 252 } | 357 } |
| 253 } | 358 } |
| 254 | 359 |
| 360 // See what products are already installed in multi mode. When we do multi | |
| 361 // installs, we must upgrade all installations since they share the binaries. | |
| 362 if (installer_state->multi_install()) { | |
| 363 BrowserDistribution::Type product_checks[] = { | |
| 364 BrowserDistribution::CHROME_BROWSER, | |
| 365 BrowserDistribution::CHROME_FRAME | |
| 366 }; | |
| 367 | |
| 368 for (size_t i = 0; i < arraysize(product_checks); ++i) { | |
| 369 BrowserDistribution::Type type = product_checks[i]; | |
| 370 if (!installer_state->FindProduct(type)) { | |
| 371 const ProductState* state = | |
| 372 original_state.GetProductState(system_level, type); | |
| 373 if ((state != NULL) && state->multi_install()) { | |
| 374 installer_state->AddProductFromState(type, *state); | |
| 375 VLOG(1) << "Product already installed and must be included: " | |
| 376 << BrowserDistribution::GetSpecificDistribution( | |
| 377 type)->GetApplicationName(); | |
|
robertshield
2011/01/20 22:06:06
indent looks like it should be three more spaces i
grt (UTC plus 2)
2011/01/21 05:27:51
Done.
| |
| 378 } | |
| 379 } | |
| 380 } | |
| 381 } | |
| 382 | |
| 255 // If no previous installation of Chrome, make sure installation directory | 383 // If no previous installation of Chrome, make sure installation directory |
| 256 // either does not exist or can be deleted (i.e. is not locked by some other | 384 // either does not exist or can be deleted (i.e. is not locked by some other |
| 257 // process). | 385 // process). |
| 258 if (is_first_install) { | 386 if (is_first_install) { |
| 259 if (file_util::PathExists(installation.path()) && | 387 if (file_util::PathExists(installer_state->target_path()) && |
| 260 !file_util::Delete(installation.path(), true)) { | 388 !file_util::Delete(installer_state->target_path(), true)) { |
| 261 LOG(ERROR) << "Installation directory " << installation.path().value() | 389 LOG(ERROR) << "Installation directory " |
| 390 << installer_state->target_path().value() | |
| 262 << " exists and can not be deleted."; | 391 << " exists and can not be deleted."; |
| 263 *status = installer::INSTALL_DIR_IN_USE; | 392 *status = installer::INSTALL_DIR_IN_USE; |
| 264 int str_id = IDS_INSTALL_DIR_IN_USE_BASE; | 393 int str_id = IDS_INSTALL_DIR_IN_USE_BASE; |
| 265 InstallUtil::WriteInstallerResult(system_level, | 394 InstallUtil::WriteInstallerResult(system_level, |
| 266 installer_state.state_key(), *status, str_id, NULL); | 395 installer_state->state_key(), *status, str_id, NULL); |
| 267 return false; | 396 return false; |
| 268 } | 397 } |
| 269 } | 398 } |
| 270 | 399 |
| 271 return true; | 400 return true; |
| 272 } | 401 } |
| 273 | 402 |
| 274 installer::InstallStatus InstallChrome(const InstallationState& original_state, | 403 installer::InstallStatus InstallChrome(const InstallationState& original_state, |
| 275 const InstallerState& installer_state, | 404 const CommandLine& cmd_line, |
| 276 const CommandLine& cmd_line, const Package& installation, | 405 const MasterPreferences& prefs, |
| 277 const MasterPreferences& prefs) { | 406 InstallerState* installer_state) { |
| 407 const bool system_install = installer_state->system_install(); | |
| 278 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; | 408 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; |
| 279 if (!CheckPreInstallConditions(original_state, installer_state, installation, | 409 if (!CheckPreInstallConditions(original_state, prefs, installer_state, |
| 280 prefs, &install_status)) | 410 &install_status)) |
| 281 return install_status; | 411 return install_status; |
| 282 | 412 |
| 283 // For install the default location for chrome.packed.7z is in current | 413 // For install the default location for chrome.packed.7z is in current |
| 284 // folder, so get that value first. | 414 // folder, so get that value first. |
| 285 FilePath archive(cmd_line.GetProgram().DirName().Append( | 415 FilePath archive(cmd_line.GetProgram().DirName().Append( |
| 286 installer::kChromeCompressedArchive)); | 416 installer::kChromeCompressedArchive)); |
| 287 | 417 |
| 288 // If --install-archive is given, get the user specified value | 418 // If --install-archive is given, get the user specified value |
| 289 if (cmd_line.HasSwitch(installer::switches::kInstallArchive)) { | 419 if (cmd_line.HasSwitch(installer::switches::kInstallArchive)) { |
| 290 archive = cmd_line.GetSwitchValuePath( | 420 archive = cmd_line.GetSwitchValuePath( |
| 291 installer::switches::kInstallArchive); | 421 installer::switches::kInstallArchive); |
| 292 } | 422 } |
| 293 VLOG(1) << "Archive found to install Chrome " << archive.value(); | 423 VLOG(1) << "Archive found to install Chrome " << archive.value(); |
| 294 const Products& products = installation.products(); | 424 const Products& products = installer_state->products(); |
| 295 | 425 |
| 296 // Create a temp folder where we will unpack Chrome archive. If it fails, | 426 // Create a temp folder where we will unpack Chrome archive. If it fails, |
| 297 // then we are doomed, so return immediately and no cleanup is required. | 427 // then we are doomed, so return immediately and no cleanup is required. |
| 298 FilePath temp_path; | 428 FilePath temp_path; |
| 299 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { | 429 if (!file_util::CreateNewTempDirectory(L"chrome_", &temp_path)) { |
| 300 LOG(ERROR) << "Could not create temporary path."; | 430 LOG(ERROR) << "Could not create temporary path."; |
| 301 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 431 InstallUtil::WriteInstallerResult(system_install, |
| 302 installer_state.state_key(), installer::TEMP_DIR_FAILED, | 432 installer_state->state_key(), installer::TEMP_DIR_FAILED, |
| 303 IDS_INSTALL_TEMP_DIR_FAILED_BASE, NULL); | 433 IDS_INSTALL_TEMP_DIR_FAILED_BASE, NULL); |
| 304 return installer::TEMP_DIR_FAILED; | 434 return installer::TEMP_DIR_FAILED; |
| 305 } | 435 } |
| 306 VLOG(1) << "created path " << temp_path.value(); | 436 VLOG(1) << "created path " << temp_path.value(); |
| 307 | 437 |
| 308 FilePath unpack_path(temp_path.Append(installer::kInstallSourceDir)); | 438 FilePath unpack_path(temp_path.Append(installer::kInstallSourceDir)); |
| 309 bool incremental_install = false; | 439 bool incremental_install = false; |
| 310 if (UnPackArchive(archive, installation, temp_path, unpack_path, | 440 if (UnPackArchive(archive, *installer_state, temp_path, unpack_path, |
| 311 incremental_install)) { | 441 incremental_install)) { |
| 312 install_status = installer::UNCOMPRESSION_FAILED; | 442 install_status = installer::UNCOMPRESSION_FAILED; |
| 313 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 443 InstallUtil::WriteInstallerResult(system_install, |
| 314 installer_state.state_key(), install_status, | 444 installer_state->state_key(), install_status, |
| 315 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, NULL); | 445 IDS_INSTALL_UNCOMPRESSION_FAILED_BASE, NULL); |
| 316 } else { | 446 } else { |
| 317 VLOG(1) << "unpacked to " << unpack_path.value(); | 447 VLOG(1) << "unpacked to " << unpack_path.value(); |
| 318 FilePath src_path(unpack_path.Append(installer::kInstallSourceChromeDir)); | 448 FilePath src_path(unpack_path.Append(installer::kInstallSourceChromeDir)); |
| 319 scoped_ptr<Version> | 449 scoped_ptr<Version> |
| 320 installer_version(installer::GetVersionFromArchiveDir(src_path)); | 450 installer_version(installer::GetVersionFromArchiveDir(src_path)); |
| 321 if (!installer_version.get()) { | 451 if (!installer_version.get()) { |
| 322 LOG(ERROR) << "Did not find any valid version in installer."; | 452 LOG(ERROR) << "Did not find any valid version in installer."; |
| 323 install_status = installer::INVALID_ARCHIVE; | 453 install_status = installer::INVALID_ARCHIVE; |
| 324 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 454 InstallUtil::WriteInstallerResult(system_install, |
| 325 installer_state.state_key(), install_status, | 455 installer_state->state_key(), install_status, |
| 326 IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); | 456 IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); |
| 327 } else { | 457 } else { |
| 328 // TODO(tommi): Move towards having only a single version that is common | 458 // TODO(tommi): Move towards having only a single version that is common |
| 329 // to all products. Only the package should have a version since it | 459 // to all products. Only the package should have a version since it |
| 330 // represents all the binaries. When a single product is upgraded, all | 460 // represents all the binaries. When a single product is upgraded, all |
| 331 // currently installed product for the shared binary installation, should | 461 // currently installed product for the shared binary installation, should |
| 332 // (or rather must) be upgraded. | 462 // (or rather must) be upgraded. |
| 333 VLOG(1) << "version to install: " << installer_version->GetString(); | 463 VLOG(1) << "version to install: " << installer_version->GetString(); |
| 334 bool higher_version_installed = false; | 464 bool higher_version_installed = false; |
| 335 for (size_t i = 0; i < installation.products().size(); ++i) { | 465 for (size_t i = 0; i < installer_state->products().size(); ++i) { |
| 336 const Product* product = installation.products()[i]; | 466 const Product* product = installer_state->products()[i]; |
| 337 const ProductState* product_state = | 467 const ProductState* product_state = |
| 338 original_state.GetProductState(installer_state.system_install(), | 468 original_state.GetProductState(system_install, |
| 339 product->distribution()->GetType()); | 469 product->distribution()->GetType()); |
| 340 if (product_state != NULL && | 470 if (product_state != NULL && |
| 341 (product_state->version().CompareTo(*installer_version) > 0)) { | 471 (product_state->version().CompareTo(*installer_version) > 0)) { |
| 342 LOG(ERROR) << "Higher version is already installed."; | 472 LOG(ERROR) << "Higher version is already installed."; |
| 343 higher_version_installed = true; | 473 higher_version_installed = true; |
| 344 install_status = installer::HIGHER_VERSION_EXISTS; | 474 install_status = installer::HIGHER_VERSION_EXISTS; |
| 345 | 475 |
| 346 if (product->is_chrome()) { | 476 if (product->is_chrome()) { |
| 347 // TODO(robertshield): We should take the installer result text | 477 // TODO(robertshield): We should take the installer result text |
| 348 // strings from the Product. | 478 // strings from the Product. |
| 349 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 479 InstallUtil::WriteInstallerResult(system_install, |
| 350 installer_state.state_key(), install_status, | 480 installer_state->state_key(), install_status, |
| 351 IDS_INSTALL_HIGHER_VERSION_BASE, NULL); | 481 IDS_INSTALL_HIGHER_VERSION_BASE, NULL); |
| 352 } else { | 482 } else { |
| 353 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 483 InstallUtil::WriteInstallerResult(system_install, |
| 354 installer_state.state_key(), install_status, | 484 installer_state->state_key(), install_status, |
| 355 IDS_INSTALL_HIGHER_VERSION_CF_BASE, NULL); | 485 IDS_INSTALL_HIGHER_VERSION_CF_BASE, NULL); |
| 356 } | 486 } |
| 357 } | 487 } |
| 358 } | 488 } |
| 359 | 489 |
| 360 if (!higher_version_installed) { | 490 if (!higher_version_installed) { |
| 361 // We want to keep uncompressed archive (chrome.7z) that we get after | 491 // We want to keep uncompressed archive (chrome.7z) that we get after |
| 362 // uncompressing and binary patching. Get the location for this file. | 492 // uncompressing and binary patching. Get the location for this file. |
| 363 FilePath archive_to_copy(temp_path.Append(installer::kChromeArchive)); | 493 FilePath archive_to_copy(temp_path.Append(installer::kChromeArchive)); |
| 364 FilePath prefs_source_path(cmd_line.GetSwitchValueNative( | 494 FilePath prefs_source_path(cmd_line.GetSwitchValueNative( |
| 365 installer::switches::kInstallerData)); | 495 installer::switches::kInstallerData)); |
| 366 install_status = installer::InstallOrUpdateProduct(original_state, | 496 install_status = installer::InstallOrUpdateProduct(original_state, |
| 367 installer_state, cmd_line.GetProgram(), archive_to_copy, temp_path, | 497 *installer_state, cmd_line.GetProgram(), archive_to_copy, temp_path, |
| 368 prefs_source_path, prefs, *installer_version, installation); | 498 prefs_source_path, prefs, *installer_version); |
| 369 | 499 |
| 370 int install_msg_base = IDS_INSTALL_FAILED_BASE; | 500 int install_msg_base = IDS_INSTALL_FAILED_BASE; |
| 371 std::wstring chrome_exe; | 501 std::wstring chrome_exe; |
| 372 if (install_status == installer::SAME_VERSION_REPAIR_FAILED) { | 502 if (install_status == installer::SAME_VERSION_REPAIR_FAILED) { |
| 373 if (FindProduct(products, BrowserDistribution::CHROME_FRAME)) { | 503 if (installer_state->FindProduct(BrowserDistribution::CHROME_FRAME)) { |
| 374 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_CF_BASE; | 504 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_CF_BASE; |
| 375 } else { | 505 } else { |
| 376 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_BASE; | 506 install_msg_base = IDS_SAME_VERSION_REPAIR_FAILED_BASE; |
| 377 } | 507 } |
| 378 } else if (install_status != installer::INSTALL_FAILED) { | 508 } else if (install_status != installer::INSTALL_FAILED) { |
| 379 if (installation.path().empty()) { | 509 if (installer_state->target_path().empty()) { |
| 380 // If we failed to construct install path, it means the OS call to | 510 // If we failed to construct install path, it means the OS call to |
| 381 // get %ProgramFiles% or %AppData% failed. Report this as failure. | 511 // get %ProgramFiles% or %AppData% failed. Report this as failure. |
| 382 install_msg_base = IDS_INSTALL_OS_ERROR_BASE; | 512 install_msg_base = IDS_INSTALL_OS_ERROR_BASE; |
| 383 install_status = installer::OS_ERROR; | 513 install_status = installer::OS_ERROR; |
| 384 } else { | 514 } else { |
| 385 chrome_exe = installation.path() | 515 chrome_exe = installer_state->target_path() |
| 386 .Append(installer::kChromeExe).value(); | 516 .Append(installer::kChromeExe).value(); |
| 387 chrome_exe = L"\"" + chrome_exe + L"\""; | 517 chrome_exe = L"\"" + chrome_exe + L"\""; |
| 388 install_msg_base = 0; | 518 install_msg_base = 0; |
| 389 } | 519 } |
| 390 } | 520 } |
| 391 | 521 |
| 392 const Product* chrome_install = | 522 const Product* chrome_install = |
| 393 FindProduct(products, BrowserDistribution::CHROME_BROWSER); | 523 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 394 | 524 |
| 395 bool value = false; | 525 bool value = false; |
| 396 if (chrome_install) { | 526 if (chrome_install) { |
| 397 prefs.GetBool( | 527 prefs.GetBool( |
| 398 installer::master_preferences::kDoNotRegisterForUpdateLaunch, | 528 installer::master_preferences::kDoNotRegisterForUpdateLaunch, |
| 399 &value); | 529 &value); |
| 400 } else { | 530 } else { |
| 401 value = true; // Never register. | 531 value = true; // Never register. |
| 402 } | 532 } |
| 403 | 533 |
| 404 bool write_chrome_launch_string = (!value) && | 534 bool write_chrome_launch_string = (!value) && |
| 405 (install_status != installer::IN_USE_UPDATED); | 535 (install_status != installer::IN_USE_UPDATED); |
| 406 | 536 |
| 407 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 537 InstallUtil::WriteInstallerResult(system_install, |
| 408 installer_state.state_key(), install_status, install_msg_base, | 538 installer_state->state_key(), install_status, install_msg_base, |
| 409 write_chrome_launch_string ? &chrome_exe : NULL); | 539 write_chrome_launch_string ? &chrome_exe : NULL); |
| 410 | 540 |
| 411 if (install_status == installer::FIRST_INSTALL_SUCCESS) { | 541 if (install_status == installer::FIRST_INSTALL_SUCCESS) { |
| 412 VLOG(1) << "First install successful."; | 542 VLOG(1) << "First install successful."; |
| 413 if (chrome_install) { | 543 if (chrome_install) { |
| 414 // We never want to launch Chrome in system level install mode. | 544 // We never want to launch Chrome in system level install mode. |
| 415 bool do_not_launch_chrome = false; | 545 bool do_not_launch_chrome = false; |
| 416 prefs.GetBool( | 546 prefs.GetBool( |
| 417 installer::master_preferences::kDoNotLaunchChrome, | 547 installer::master_preferences::kDoNotLaunchChrome, |
| 418 &do_not_launch_chrome); | 548 &do_not_launch_chrome); |
| 419 if (!installation.system_level() && !do_not_launch_chrome) | 549 if (!system_install && !do_not_launch_chrome) |
| 420 chrome_install->LaunchChrome(); | 550 chrome_install->LaunchChrome(installer_state->target_path()); |
| 421 } | 551 } |
| 422 } else if ((install_status == installer::NEW_VERSION_UPDATED) || | 552 } else if ((install_status == installer::NEW_VERSION_UPDATED) || |
| 423 (install_status == installer::IN_USE_UPDATED)) { | 553 (install_status == installer::IN_USE_UPDATED)) { |
| 424 for (size_t i = 0; i < products.size(); ++i) { | 554 for (size_t i = 0; i < products.size(); ++i) { |
| 425 installer::RemoveLegacyRegistryKeys( | 555 installer::RemoveLegacyRegistryKeys( |
| 426 products[i]->distribution()); | 556 products[i]->distribution()); |
| 427 } | 557 } |
| 428 } | 558 } |
| 429 } | 559 } |
| 430 } | 560 } |
| 431 // There might be an experiment (for upgrade usually) that needs to happen. | 561 // There might be an experiment (for upgrade usually) that needs to happen. |
| 432 // An experiment's outcome can include chrome's uninstallation. If that is | 562 // An experiment's outcome can include chrome's uninstallation. If that is |
| 433 // the case we would not do that directly at this point but in another | 563 // the case we would not do that directly at this point but in another |
| 434 // instance of setup.exe | 564 // instance of setup.exe |
| 435 // | 565 // |
| 436 // There is another way to reach this same function if this is a system | 566 // There is another way to reach this same function if this is a system |
| 437 // level install. See HandleNonInstallCmdLineOptions(). | 567 // level install. See HandleNonInstallCmdLineOptions(). |
| 438 for (size_t i = 0; i < products.size(); ++i) { | 568 for (size_t i = 0; i < products.size(); ++i) { |
| 439 const Product* product = products[i]; | 569 const Product* product = products[i]; |
| 440 product->distribution()->LaunchUserExperiment(install_status, | 570 product->distribution()->LaunchUserExperiment(install_status, |
| 441 *installer_version, *product, installation.system_level()); | 571 *installer_version, *product, system_install); |
| 442 } | 572 } |
| 443 } | 573 } |
| 444 | 574 |
| 445 // Delete temporary files. These include install temporary directory | 575 // Delete temporary files. These include install temporary directory |
| 446 // and master profile file if present. Note that we do not care about rollback | 576 // and master profile file if present. Note that we do not care about rollback |
| 447 // here and we schedule for deletion on reboot below if the deletes fail. As | 577 // here and we schedule for deletion on reboot below if the deletes fail. As |
| 448 // such, we do not use DeleteTreeWorkItem. | 578 // such, we do not use DeleteTreeWorkItem. |
| 449 VLOG(1) << "Deleting temporary directory " << temp_path.value(); | 579 VLOG(1) << "Deleting temporary directory " << temp_path.value(); |
| 450 bool cleanup_success = file_util::Delete(temp_path, true); | 580 bool cleanup_success = file_util::Delete(temp_path, true); |
| 451 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { | 581 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 465 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { | 595 if (cmd_line.HasSwitch(installer::switches::kInstallerData)) { |
| 466 std::wstring prefs_path = cmd_line.GetSwitchValueNative( | 596 std::wstring prefs_path = cmd_line.GetSwitchValueNative( |
| 467 installer::switches::kInstallerData); | 597 installer::switches::kInstallerData); |
| 468 ScheduleDirectoryForDeletion(prefs_path.c_str()); | 598 ScheduleDirectoryForDeletion(prefs_path.c_str()); |
| 469 } | 599 } |
| 470 } | 600 } |
| 471 | 601 |
| 472 for (size_t i = 0; i < products.size(); ++i) { | 602 for (size_t i = 0; i < products.size(); ++i) { |
| 473 const Product* product = products[i]; | 603 const Product* product = products[i]; |
| 474 product->distribution()->UpdateInstallStatus( | 604 product->distribution()->UpdateInstallStatus( |
| 475 installer_state.system_install(), incremental_install, | 605 system_install, incremental_install, prefs.is_multi_install(), |
| 476 prefs.is_multi_install(), install_status); | 606 install_status); |
| 477 } | 607 } |
| 478 if (prefs.is_multi_install()) { | 608 if (installer_state->multi_install()) { |
| 479 installation.properties()->UpdateInstallStatus( | 609 installer_state->multi_package_binaries_distribution()->UpdateInstallStatus( |
| 480 installer_state.system_install(), incremental_install, true, | 610 system_install, incremental_install, true, install_status); |
| 481 install_status); | |
| 482 } | 611 } |
| 483 | 612 |
| 484 return install_status; | 613 return install_status; |
| 485 } | 614 } |
| 486 | 615 |
| 487 installer::InstallStatus UninstallProduct( | 616 installer::InstallStatus UninstallProduct( |
| 488 const InstallationState& original_state, | 617 const InstallationState& original_state, |
| 489 const InstallerState& installer_state, | 618 const InstallerState& installer_state, |
| 490 const CommandLine& cmd_line, | 619 const CommandLine& cmd_line, |
| 491 const Product& product) { | 620 const Product& product) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 return installer::EULA_ACCEPTED_OPT_IN; | 661 return installer::EULA_ACCEPTED_OPT_IN; |
| 533 } | 662 } |
| 534 VLOG(1) << "EULA accepted (no opt-in)"; | 663 VLOG(1) << "EULA accepted (no opt-in)"; |
| 535 return installer::EULA_ACCEPTED; | 664 return installer::EULA_ACCEPTED; |
| 536 } | 665 } |
| 537 | 666 |
| 538 // This method processes any command line options that make setup.exe do | 667 // This method processes any command line options that make setup.exe do |
| 539 // various tasks other than installation (renaming chrome.exe, showing eula | 668 // various tasks other than installation (renaming chrome.exe, showing eula |
| 540 // among others). This function returns true if any such command line option | 669 // among others). This function returns true if any such command line option |
| 541 // has been found and processed (so setup.exe should exit at that point). | 670 // has been found and processed (so setup.exe should exit at that point). |
| 542 bool HandleNonInstallCmdLineOptions(const InstallerState& installer_state, | 671 bool HandleNonInstallCmdLineOptions(const InstallationState& original_state, |
| 543 const CommandLine& cmd_line, | 672 const CommandLine& cmd_line, |
| 544 const ProductPackageMapping& installs, | 673 InstallerState* installer_state, |
|
robertshield
2011/01/20 22:06:06
Could installer_state be a const ref here?
grt (UTC plus 2)
2011/01/21 05:27:51
Done.
| |
| 545 int* exit_code) { | 674 int* exit_code) { |
| 546 DCHECK(installs.products().size()); | |
| 547 bool handled = true; | 675 bool handled = true; |
| 548 // TODO(tommi): Split these checks up into functions and use a data driven | 676 // TODO(tommi): Split these checks up into functions and use a data driven |
| 549 // map of switch->function. | 677 // map of switch->function. |
| 550 if (cmd_line.HasSwitch(installer::switches::kUpdateSetupExe)) { | 678 if (cmd_line.HasSwitch(installer::switches::kUpdateSetupExe)) { |
| 551 installer::InstallStatus status = installer::SETUP_PATCH_FAILED; | 679 installer::InstallStatus status = installer::SETUP_PATCH_FAILED; |
| 552 // If --update-setup-exe command line option is given, we apply the given | 680 // If --update-setup-exe command line option is given, we apply the given |
| 553 // patch to current exe, and store the resulting binary in the path | 681 // patch to current exe, and store the resulting binary in the path |
| 554 // specified by --new-setup-exe. But we need to first unpack the file | 682 // specified by --new-setup-exe. But we need to first unpack the file |
| 555 // given in --update-setup-exe. | 683 // given in --update-setup-exe. |
| 556 FilePath temp_path; | 684 FilePath temp_path; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 569 if (!installer::ApplyDiffPatch(old_setup_exe, | 697 if (!installer::ApplyDiffPatch(old_setup_exe, |
| 570 FilePath(uncompressed_patch), | 698 FilePath(uncompressed_patch), |
| 571 new_setup_exe)) | 699 new_setup_exe)) |
| 572 status = installer::NEW_VERSION_UPDATED; | 700 status = installer::NEW_VERSION_UPDATED; |
| 573 } | 701 } |
| 574 } | 702 } |
| 575 | 703 |
| 576 *exit_code = InstallUtil::GetInstallReturnCode(status); | 704 *exit_code = InstallUtil::GetInstallReturnCode(status); |
| 577 if (*exit_code) { | 705 if (*exit_code) { |
| 578 LOG(WARNING) << "setup.exe patching failed."; | 706 LOG(WARNING) << "setup.exe patching failed."; |
| 579 InstallUtil::WriteInstallerResult(installer_state.system_install(), | 707 InstallUtil::WriteInstallerResult(installer_state->system_install(), |
| 580 installer_state.state_key(), status, IDS_SETUP_PATCH_FAILED_BASE, | 708 installer_state->state_key(), status, IDS_SETUP_PATCH_FAILED_BASE, |
| 581 NULL); | 709 NULL); |
| 582 } | 710 } |
| 583 file_util::Delete(temp_path, true); | 711 file_util::Delete(temp_path, true); |
| 584 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) { | 712 } else if (cmd_line.HasSwitch(installer::switches::kShowEula)) { |
| 585 // Check if we need to show the EULA. If it is passed as a command line | 713 // Check if we need to show the EULA. If it is passed as a command line |
| 586 // then the dialog is shown and regardless of the outcome setup exits here. | 714 // then the dialog is shown and regardless of the outcome setup exits here. |
| 587 std::wstring inner_frame = | 715 std::wstring inner_frame = |
| 588 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); | 716 cmd_line.GetSwitchValueNative(installer::switches::kShowEula); |
| 589 *exit_code = ShowEULADialog(inner_frame); | 717 *exit_code = ShowEULADialog(inner_frame); |
| 590 if (installer::EULA_REJECTED != *exit_code) | 718 if (installer::EULA_REJECTED != *exit_code) |
| 591 GoogleUpdateSettings::SetEULAConsent(*installs.packages()[0].get(), true); | 719 GoogleUpdateSettings::SetEULAConsent(*installer_state, true); |
| 592 } else if (cmd_line.HasSwitch( | 720 } else if (cmd_line.HasSwitch( |
| 593 installer::switches::kRegisterChromeBrowser)) { | 721 installer::switches::kRegisterChromeBrowser)) { |
| 594 const Product* chrome_install = | 722 const Product* chrome_install = |
| 595 FindProduct(installs.products(), BrowserDistribution::CHROME_BROWSER); | 723 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 596 DCHECK(chrome_install); | |
| 597 if (chrome_install) { | 724 if (chrome_install) { |
| 598 // If --register-chrome-browser option is specified, register all | 725 // If --register-chrome-browser option is specified, register all |
| 599 // Chrome protocol/file associations as well as register it as a valid | 726 // Chrome protocol/file associations as well as register it as a valid |
| 600 // browser for Start Menu->Internet shortcut. This option should only | 727 // browser for Start Menu->Internet shortcut. This option should only |
| 601 // be used when setup.exe is launched with admin rights. We do not | 728 // be used when setup.exe is launched with admin rights. We do not |
| 602 // make any user specific changes in this option. | 729 // make any user specific changes in this option. |
| 603 std::wstring chrome_exe(cmd_line.GetSwitchValueNative( | 730 std::wstring chrome_exe(cmd_line.GetSwitchValueNative( |
| 604 installer::switches::kRegisterChromeBrowser)); | 731 installer::switches::kRegisterChromeBrowser)); |
| 605 std::wstring suffix; | 732 std::wstring suffix; |
| 606 if (cmd_line.HasSwitch( | 733 if (cmd_line.HasSwitch( |
| 607 installer::switches::kRegisterChromeBrowserSuffix)) { | 734 installer::switches::kRegisterChromeBrowserSuffix)) { |
| 608 suffix = cmd_line.GetSwitchValueNative( | 735 suffix = cmd_line.GetSwitchValueNative( |
| 609 installer::switches::kRegisterChromeBrowserSuffix); | 736 installer::switches::kRegisterChromeBrowserSuffix); |
| 610 } | 737 } |
| 611 *exit_code = ShellUtil::RegisterChromeBrowser( | 738 *exit_code = ShellUtil::RegisterChromeBrowser( |
| 612 chrome_install->distribution(), chrome_exe, suffix, false); | 739 chrome_install->distribution(), chrome_exe, suffix, false); |
| 613 } else { | 740 } else { |
| 614 LOG(ERROR) << "Can't register browser - Chrome distribution not found"; | 741 LOG(DFATAL) << "Can't register browser - Chrome distribution not found"; |
| 615 *exit_code = installer::UNKNOWN_STATUS; | 742 *exit_code = installer::UNKNOWN_STATUS; |
| 616 } | 743 } |
| 617 } else if (cmd_line.HasSwitch(installer::switches::kRenameChromeExe)) { | 744 } else if (cmd_line.HasSwitch(installer::switches::kRenameChromeExe)) { |
| 618 // If --rename-chrome-exe is specified, we want to rename the executables | 745 // If --rename-chrome-exe is specified, we want to rename the executables |
| 619 // and exit. | 746 // and exit. |
| 620 const Packages& packages = installs.packages(); | 747 *exit_code = RenameChromeExecutables(*installer_state); |
| 621 DCHECK_EQ(1U, packages.size()); | |
| 622 for (size_t i = 0; i < packages.size(); ++i) | |
| 623 *exit_code = RenameChromeExecutables(*packages[i].get()); | |
| 624 } else if (cmd_line.HasSwitch( | 748 } else if (cmd_line.HasSwitch( |
| 625 installer::switches::kRemoveChromeRegistration)) { | 749 installer::switches::kRemoveChromeRegistration)) { |
| 626 // This is almost reverse of --register-chrome-browser option above. | 750 // This is almost reverse of --register-chrome-browser option above. |
| 627 // Here we delete Chrome browser registration. This option should only | 751 // Here we delete Chrome browser registration. This option should only |
| 628 // be used when setup.exe is launched with admin rights. We do not | 752 // be used when setup.exe is launched with admin rights. We do not |
| 629 // make any user specific changes in this option. | 753 // make any user specific changes in this option. |
| 630 std::wstring suffix; | 754 std::wstring suffix; |
| 631 if (cmd_line.HasSwitch( | 755 if (cmd_line.HasSwitch( |
| 632 installer::switches::kRegisterChromeBrowserSuffix)) { | 756 installer::switches::kRegisterChromeBrowserSuffix)) { |
| 633 suffix = cmd_line.GetSwitchValueNative( | 757 suffix = cmd_line.GetSwitchValueNative( |
| 634 installer::switches::kRegisterChromeBrowserSuffix); | 758 installer::switches::kRegisterChromeBrowserSuffix); |
| 635 } | 759 } |
| 636 installer::InstallStatus tmp = installer::UNKNOWN_STATUS; | 760 installer::InstallStatus tmp = installer::UNKNOWN_STATUS; |
| 637 const Product* chrome_install = | 761 const Product* chrome_install = |
| 638 FindProduct(installs.products(), BrowserDistribution::CHROME_BROWSER); | 762 installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 639 DCHECK(chrome_install); | 763 DCHECK(chrome_install); |
| 640 if (chrome_install) { | 764 if (chrome_install) { |
| 641 installer::DeleteChromeRegistrationKeys(chrome_install->distribution(), | 765 installer::DeleteChromeRegistrationKeys(chrome_install->distribution(), |
| 642 HKEY_LOCAL_MACHINE, suffix, tmp); | 766 HKEY_LOCAL_MACHINE, suffix, tmp); |
| 643 } | 767 } |
| 644 *exit_code = tmp; | 768 *exit_code = tmp; |
| 645 } else if (cmd_line.HasSwitch(installer::switches::kInactiveUserToast)) { | 769 } else if (cmd_line.HasSwitch(installer::switches::kInactiveUserToast)) { |
| 646 // Launch the inactive user toast experiment. | 770 // Launch the inactive user toast experiment. |
| 647 int flavor = -1; | 771 int flavor = -1; |
| 648 base::StringToInt(cmd_line.GetSwitchValueNative( | 772 base::StringToInt(cmd_line.GetSwitchValueNative( |
| 649 installer::switches::kInactiveUserToast), &flavor); | 773 installer::switches::kInactiveUserToast), &flavor); |
| 650 DCHECK_NE(-1, flavor); | 774 DCHECK_NE(-1, flavor); |
| 651 if (flavor == -1) { | 775 if (flavor == -1) { |
| 652 *exit_code = installer::UNKNOWN_STATUS; | 776 *exit_code = installer::UNKNOWN_STATUS; |
| 653 } else { | 777 } else { |
| 654 const Products& products = installs.products(); | 778 const Products& products = installer_state->products(); |
| 655 for (size_t i = 0; i < products.size(); ++i) { | 779 for (size_t i = 0; i < products.size(); ++i) { |
| 656 const Product* product = products[i]; | 780 const Product* product = products[i]; |
| 657 BrowserDistribution* browser_dist = product->distribution(); | 781 BrowserDistribution* browser_dist = product->distribution(); |
| 658 browser_dist->InactiveUserToastExperiment(flavor, *product); | 782 browser_dist->InactiveUserToastExperiment(flavor, *product, |
| 783 installer_state->target_path()); | |
| 659 } | 784 } |
| 660 } | 785 } |
| 661 } else if (cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { | 786 } else if (cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { |
| 662 const Products& products = installs.products(); | 787 const Products& products = installer_state->products(); |
| 663 for (size_t i = 0; i < products.size(); ++i) { | 788 for (size_t i = 0; i < products.size(); ++i) { |
| 664 const Product* product = products[i]; | 789 const Product* product = products[i]; |
| 665 BrowserDistribution* browser_dist = product->distribution(); | 790 BrowserDistribution* browser_dist = product->distribution(); |
| 666 // We started as system-level and have been re-launched as user level | 791 // We started as system-level and have been re-launched as user level |
| 667 // to continue with the toast experiment. | 792 // to continue with the toast experiment. |
| 668 scoped_ptr<Version> installed_version( | 793 scoped_ptr<Version> installed_version( |
| 669 InstallUtil::GetChromeVersion(browser_dist, installs.system_level())); | 794 InstallUtil::GetChromeVersion(browser_dist, |
| 795 installer_state->system_install())); | |
| 670 browser_dist->LaunchUserExperiment(installer::REENTRY_SYS_UPDATE, | 796 browser_dist->LaunchUserExperiment(installer::REENTRY_SYS_UPDATE, |
| 671 *installed_version, *product, true); | 797 *installed_version, *product, true); |
| 672 } | 798 } |
| 673 } else if (cmd_line.HasSwitch( | 799 } else if (cmd_line.HasSwitch( |
| 674 installer::switches::kChromeFrameReadyModeOptIn)) { | 800 installer::switches::kChromeFrameReadyModeOptIn)) { |
| 675 *exit_code = InstallUtil::GetInstallReturnCode( | 801 *exit_code = InstallUtil::GetInstallReturnCode( |
| 676 installer::ChromeFrameReadyModeOptIn(installer_state, cmd_line)); | 802 installer::ChromeFrameReadyModeOptIn(original_state, installer_state)); |
|
robertshield
2011/01/20 22:06:06
I think this is the only place you need to pass a
grt (UTC plus 2)
2011/01/21 05:27:51
Done.
| |
| 677 } else if (cmd_line.HasSwitch( | 803 } else if (cmd_line.HasSwitch( |
| 678 installer::switches::kChromeFrameReadyModeTempOptOut)) { | 804 installer::switches::kChromeFrameReadyModeTempOptOut)) { |
| 679 *exit_code = InstallUtil::GetInstallReturnCode( | 805 *exit_code = InstallUtil::GetInstallReturnCode( |
| 680 installer::ChromeFrameReadyModeTempOptOut(cmd_line)); | 806 installer::ChromeFrameReadyModeTempOptOut(original_state, |
| 807 *installer_state)); | |
| 681 } else if (cmd_line.HasSwitch( | 808 } else if (cmd_line.HasSwitch( |
| 682 installer::switches::kChromeFrameReadyModeEndTempOptOut)) { | 809 installer::switches::kChromeFrameReadyModeEndTempOptOut)) { |
| 683 *exit_code = InstallUtil::GetInstallReturnCode( | 810 *exit_code = InstallUtil::GetInstallReturnCode( |
| 684 installer::ChromeFrameReadyModeEndTempOptOut(cmd_line)); | 811 installer::ChromeFrameReadyModeEndTempOptOut(original_state, |
| 812 *installer_state)); | |
| 685 } else { | 813 } else { |
| 686 handled = false; | 814 handled = false; |
| 687 } | 815 } |
| 688 | 816 |
| 689 return handled; | 817 return handled; |
| 690 } | 818 } |
| 691 | 819 |
| 692 bool ShowRebootDialog() { | 820 bool ShowRebootDialog() { |
| 693 // Get a token for this process. | 821 // Get a token for this process. |
| 694 HANDLE token; | 822 HANDLE token; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 736 return false; | 864 return false; |
| 737 } | 865 } |
| 738 initialized_ = true; | 866 initialized_ = true; |
| 739 return true; | 867 return true; |
| 740 } | 868 } |
| 741 | 869 |
| 742 private: | 870 private: |
| 743 bool initialized_; | 871 bool initialized_; |
| 744 }; | 872 }; |
| 745 | 873 |
| 746 bool PopulateInstallations(bool for_uninstall, | |
| 747 const MasterPreferences& prefs, | |
| 748 ProductPackageMapping* installations) { | |
| 749 DCHECK(installations); | |
| 750 bool success = true; | |
| 751 | 874 |
| 752 bool implicit_chrome_install = false; | |
| 753 bool implicit_gcf_install = false; | |
| 754 | 875 |
| 755 // See what products are already installed in multi mode. | |
| 756 // When we do multi installs, we must upgrade all installations in sync since | |
| 757 // they share the binaries. Be careful to not do this when we're uninstalling | |
| 758 // a product. | |
| 759 if (prefs.is_multi_install() && !for_uninstall) { | |
| 760 struct CheckInstall { | |
| 761 bool* installed; | |
| 762 BrowserDistribution::Type type; | |
| 763 } product_checks[] = { | |
| 764 {&implicit_chrome_install, BrowserDistribution::CHROME_BROWSER}, | |
| 765 {&implicit_gcf_install, BrowserDistribution::CHROME_FRAME}, | |
| 766 }; | |
| 767 | 876 |
| 768 for (size_t i = 0; i < arraysize(product_checks); ++i) { | |
| 769 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | |
| 770 product_checks[i].type, prefs); | |
| 771 *product_checks[i].installed = installer::IsInstalledAsMulti( | |
| 772 installations->system_level(), dist); | |
| 773 LOG_IF(INFO, *product_checks[i].installed) | |
| 774 << "Product already installed and must be included: " | |
| 775 << dist->GetApplicationName(); | |
| 776 } | |
| 777 } | |
| 778 | |
| 779 if (prefs.install_chrome() || implicit_chrome_install) { | |
| 780 VLOG(1) << (for_uninstall ? "Uninstall" : "Install") | |
| 781 << " distribution: Chrome"; | |
| 782 success = installations->AddDistribution( | |
| 783 BrowserDistribution::CHROME_BROWSER, prefs); | |
| 784 } | |
| 785 | |
| 786 if (success && (prefs.install_chrome_frame() || implicit_gcf_install)) { | |
| 787 VLOG(1) << (for_uninstall ? "Uninstall" : "Install") | |
| 788 << " distribution: Chrome Frame"; | |
| 789 success = installations->AddDistribution( | |
| 790 BrowserDistribution::CHROME_FRAME, prefs); | |
| 791 } | |
| 792 return success; | |
| 793 } | |
| 794 | 877 |
| 795 // Returns the Custom information for the client identified by the exe path | 878 // Returns the Custom information for the client identified by the exe path |
| 796 // passed in. This information is used for crash reporting. | 879 // passed in. This information is used for crash reporting. |
| 797 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { | 880 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { |
| 798 std::wstring product; | 881 std::wstring product; |
| 799 std::wstring version; | 882 std::wstring version; |
| 800 scoped_ptr<FileVersionInfo> | 883 scoped_ptr<FileVersionInfo> |
| 801 version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); | 884 version_info(FileVersionInfo::CreateFileVersionInfo(FilePath(exe_path))); |
| 802 if (version_info.get()) { | 885 if (version_info.get()) { |
| 803 version = version_info->product_version(); | 886 version = version_info->product_version(); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 876 | 959 |
| 877 VLOG(1) << "multi install is " << prefs.is_multi_install(); | 960 VLOG(1) << "multi install is " << prefs.is_multi_install(); |
| 878 bool system_install = false; | 961 bool system_install = false; |
| 879 prefs.GetBool(installer::master_preferences::kSystemLevel, &system_install); | 962 prefs.GetBool(installer::master_preferences::kSystemLevel, &system_install); |
| 880 VLOG(1) << "system install is " << system_install; | 963 VLOG(1) << "system install is " << system_install; |
| 881 | 964 |
| 882 google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( | 965 google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( |
| 883 InitializeCrashReporting(system_install)); | 966 InitializeCrashReporting(system_install)); |
| 884 | 967 |
| 885 InstallationState original_state; | 968 InstallationState original_state; |
| 886 original_state.Initialize(prefs); | 969 original_state.Initialize(); |
| 887 | 970 |
| 888 InstallerState installer_state; | 971 InstallerState installer_state; |
| 889 installer_state.Initialize(prefs, original_state); | 972 installer_state.Initialize(cmd_line, prefs, original_state); |
| 890 const bool is_uninstall = cmd_line.HasSwitch(installer::switches::kUninstall); | 973 const bool is_uninstall = cmd_line.HasSwitch(installer::switches::kUninstall); |
| 891 | 974 |
| 892 ProductPackageMapping installations(prefs.is_multi_install(), system_install); | |
| 893 if (!PopulateInstallations(is_uninstall, prefs, &installations)) { | |
| 894 // Currently this can only fail if one of the installations is a multi and | |
| 895 // a pre-existing single installation exists or vice versa. | |
| 896 installer::InstallStatus status = installer::NON_MULTI_INSTALLATION_EXISTS; | |
| 897 int string_id = IDS_INSTALL_NON_MULTI_INSTALLATION_EXISTS_BASE; | |
| 898 if (!prefs.is_multi_install()) { | |
| 899 status = installer::MULTI_INSTALLATION_EXISTS; | |
| 900 string_id = IDS_INSTALL_MULTI_INSTALLATION_EXISTS_BASE; | |
| 901 } | |
| 902 LOG(ERROR) << "Failed to populate installations: " << status; | |
| 903 InstallUtil::WriteInstallerResult(system_install, | |
| 904 installer_state.state_key(), status, string_id, NULL); | |
| 905 return status; | |
| 906 } | |
| 907 | |
| 908 // Check to make sure current system is WinXP or later. If not, log | 975 // Check to make sure current system is WinXP or later. If not, log |
| 909 // error message and get out. | 976 // error message and get out. |
| 910 if (!InstallUtil::IsOSSupported()) { | 977 if (!InstallUtil::IsOSSupported()) { |
| 911 LOG(ERROR) << "Chrome only supports Windows XP or later."; | 978 LOG(ERROR) << "Chrome only supports Windows XP or later."; |
| 912 InstallUtil::WriteInstallerResult(system_install, | 979 InstallUtil::WriteInstallerResult(system_install, |
| 913 installer_state.state_key(), installer::OS_NOT_SUPPORTED, | 980 installer_state.state_key(), installer::OS_NOT_SUPPORTED, |
| 914 IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL); | 981 IDS_INSTALL_OS_NOT_SUPPORTED_BASE, NULL); |
| 915 return installer::OS_NOT_SUPPORTED; | 982 return installer::OS_NOT_SUPPORTED; |
| 916 } | 983 } |
| 917 | 984 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 933 cmd_line.HasSwitch(installer::switches::kRegisterChromeBrowser) || | 1000 cmd_line.HasSwitch(installer::switches::kRegisterChromeBrowser) || |
| 934 cmd_line.HasSwitch( | 1001 cmd_line.HasSwitch( |
| 935 installer::switches::kRemoveChromeRegistration) || | 1002 installer::switches::kRemoveChromeRegistration) || |
| 936 cmd_line.HasSwitch(installer::switches::kInactiveUserToast) || | 1003 cmd_line.HasSwitch(installer::switches::kInactiveUserToast) || |
| 937 cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { | 1004 cmd_line.HasSwitch(installer::switches::kSystemLevelToast)) { |
| 938 return installer::SXS_OPTION_NOT_SUPPORTED; | 1005 return installer::SXS_OPTION_NOT_SUPPORTED; |
| 939 } | 1006 } |
| 940 } | 1007 } |
| 941 | 1008 |
| 942 int exit_code = 0; | 1009 int exit_code = 0; |
| 943 if (HandleNonInstallCmdLineOptions(installer_state, cmd_line, installations, | 1010 if (HandleNonInstallCmdLineOptions(original_state, cmd_line, &installer_state, |
| 944 &exit_code)) | 1011 &exit_code)) |
| 945 return exit_code; | 1012 return exit_code; |
| 946 | 1013 |
| 947 if (system_install && !IsUserAnAdmin()) { | 1014 if (system_install && !IsUserAnAdmin()) { |
| 948 if (base::win::GetVersion() >= base::win::VERSION_VISTA && | 1015 if (base::win::GetVersion() >= base::win::VERSION_VISTA && |
| 949 !cmd_line.HasSwitch(installer::switches::kRunAsAdmin)) { | 1016 !cmd_line.HasSwitch(installer::switches::kRunAsAdmin)) { |
| 950 CommandLine new_cmd(CommandLine::NO_PROGRAM); | 1017 CommandLine new_cmd(CommandLine::NO_PROGRAM); |
| 951 new_cmd.AppendArguments(cmd_line, true); | 1018 new_cmd.AppendArguments(cmd_line, true); |
| 952 // Append --run-as-admin flag to let the new instance of setup.exe know | 1019 // Append --run-as-admin flag to let the new instance of setup.exe know |
| 953 // that we already tried to launch ourselves as admin. | 1020 // that we already tried to launch ourselves as admin. |
| 954 new_cmd.AppendSwitch(installer::switches::kRunAsAdmin); | 1021 new_cmd.AppendSwitch(installer::switches::kRunAsAdmin); |
| 955 DWORD exit_code = installer::UNKNOWN_STATUS; | 1022 DWORD exit_code = installer::UNKNOWN_STATUS; |
| 956 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); | 1023 InstallUtil::ExecuteExeAsAdmin(new_cmd, &exit_code); |
| 957 return exit_code; | 1024 return exit_code; |
| 958 } else { | 1025 } else { |
| 959 LOG(ERROR) << "Non admin user can not install system level Chrome."; | 1026 LOG(ERROR) << "Non admin user can not install system level Chrome."; |
| 960 InstallUtil::WriteInstallerResult(system_install, | 1027 InstallUtil::WriteInstallerResult(system_install, |
| 961 installer_state.state_key(), installer::INSUFFICIENT_RIGHTS, | 1028 installer_state.state_key(), installer::INSUFFICIENT_RIGHTS, |
| 962 IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE, NULL); | 1029 IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE, NULL); |
| 963 return installer::INSUFFICIENT_RIGHTS; | 1030 return installer::INSUFFICIENT_RIGHTS; |
| 964 } | 1031 } |
| 965 } | 1032 } |
| 966 | 1033 |
| 967 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; | 1034 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; |
| 968 // If --uninstall option is given, uninstall chrome | 1035 // If --uninstall option is given, uninstall chrome |
|
robertshield
2011/01/20 22:06:06
This comment looks out of date.
grt (UTC plus 2)
2011/01/21 05:27:51
Done.
| |
| 969 if (is_uninstall) { | 1036 if (is_uninstall) { |
| 970 for (size_t i = 0; i < installations.products().size(); ++i) { | 1037 const Products& products = installer_state.products(); |
| 1038 for (size_t i = 0; i < products.size(); ++i) { | |
| 971 install_status = UninstallProduct(original_state, installer_state, | 1039 install_status = UninstallProduct(original_state, installer_state, |
| 972 cmd_line, *installations.products()[i]); | 1040 cmd_line, *products[i]); |
| 973 } | 1041 } |
| 974 } else { | 1042 } else { |
| 975 // If --uninstall option is not specified, we assume it is install case. | 1043 // If --uninstall option is not specified, we assume it is install case. |
| 976 const Packages& packages = installations.packages(); | 1044 VLOG(1) << "Installing to " << installer_state.target_path().value(); |
| 977 VLOG(1) << "Installing to " << packages.size() << " target paths"; | 1045 install_status = InstallChrome(original_state, cmd_line, prefs, |
|
robertshield
2011/01/20 22:06:06
InstallChrome -> InstallProducts?
grt (UTC plus 2)
2011/01/21 05:27:51
Done.
| |
| 978 for (size_t i = 0; i < packages.size(); ++i) { | 1046 &installer_state); |
| 979 install_status = InstallChrome(original_state, installer_state, cmd_line, | |
| 980 *packages[i].get(), prefs); | |
| 981 } | |
| 982 } | 1047 } |
| 983 | 1048 |
| 984 const Product* cf_install = | 1049 const Product* cf_install = |
| 985 FindProduct(installations.products(), BrowserDistribution::CHROME_FRAME); | 1050 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME); |
| 986 | 1051 |
| 987 if (cf_install && | 1052 if (cf_install && |
| 988 !cmd_line.HasSwitch(installer::switches::kForceUninstall)) { | 1053 !cmd_line.HasSwitch(installer::switches::kForceUninstall)) { |
| 989 if (install_status == installer::UNINSTALL_REQUIRES_REBOOT) { | 1054 if (install_status == installer::UNINSTALL_REQUIRES_REBOOT) { |
| 990 ShowRebootDialog(); | 1055 ShowRebootDialog(); |
| 991 } else if (is_uninstall) { | 1056 } else if (is_uninstall) { |
| 992 // Only show the message box if Chrome Frame was the only product being | 1057 // Only show the message box if Chrome Frame was the only product being |
| 993 // uninstalled. | 1058 // uninstalled. |
| 994 if (installations.products().size() == 1U) { | 1059 if (installer_state.products().size() == 1U) { |
| 995 ::MessageBoxW(NULL, | 1060 ::MessageBoxW(NULL, |
| 996 installer::GetLocalizedString( | 1061 installer::GetLocalizedString( |
| 997 IDS_UNINSTALL_COMPLETE_BASE).c_str(), | 1062 IDS_UNINSTALL_COMPLETE_BASE).c_str(), |
| 998 cf_install->distribution()->GetApplicationName().c_str(), | 1063 cf_install->distribution()->GetApplicationName().c_str(), |
| 999 MB_OK); | 1064 MB_OK); |
| 1000 } | 1065 } |
| 1001 } | 1066 } |
| 1002 } | 1067 } |
| 1003 | 1068 |
| 1004 int return_code = 0; | 1069 int return_code = 0; |
| 1005 // MSI demands that custom actions always return 0 (ERROR_SUCCESS) or it will | 1070 // MSI demands that custom actions always return 0 (ERROR_SUCCESS) or it will |
| 1006 // rollback the action. If we're uninstalling we want to avoid this, so always | 1071 // rollback the action. If we're uninstalling we want to avoid this, so always |
| 1007 // report success, squashing any more informative return codes. | 1072 // report success, squashing any more informative return codes. |
| 1008 // TODO(tommi): Fix this loop when IsMsi has been moved out of the Product | 1073 if (!(installer_state.msi() && is_uninstall)) |
| 1009 // class. | 1074 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
| 1010 for (size_t i = 0; i < installations.products().size(); ++i) { | 1075 // to pass through, since this is only returned on uninstall which is |
| 1011 const Product* product = installations.products()[i]; | 1076 // never invoked directly by Google Update. |
| 1012 if (!(product->IsMsi() && is_uninstall)) { | 1077 return_code = InstallUtil::GetInstallReturnCode(install_status); |
| 1013 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | |
| 1014 // to pass through, since this is only returned on uninstall which is | |
| 1015 // never invoked directly by Google Update. | |
| 1016 return_code = InstallUtil::GetInstallReturnCode(install_status); | |
| 1017 } | |
| 1018 } | |
| 1019 | 1078 |
| 1020 VLOG(1) << "Installation complete, returning: " << return_code; | 1079 VLOG(1) << "Installation complete, returning: " << return_code; |
| 1021 | 1080 |
| 1022 return return_code; | 1081 return return_code; |
| 1023 } | 1082 } |
| OLD | NEW |