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> |
(...skipping 11 matching lines...) Expand all Loading... | |
22 #include "base/path_service.h" | 22 #include "base/path_service.h" |
23 #include "base/string16.h" | 23 #include "base/string16.h" |
24 #include "base/string_util.h" | 24 #include "base/string_util.h" |
25 #include "base/utf_string_conversions.h" | 25 #include "base/utf_string_conversions.h" |
26 #include "base/version.h" | 26 #include "base/version.h" |
27 #include "base/win/registry.h" | 27 #include "base/win/registry.h" |
28 #include "base/win/scoped_comptr.h" | 28 #include "base/win/scoped_comptr.h" |
29 #include "base/win/windows_version.h" | 29 #include "base/win/windows_version.h" |
30 #include "chrome/common/chrome_constants.h" | 30 #include "chrome/common/chrome_constants.h" |
31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/installer/launcher_support/chrome_launcher_support.h" | |
32 #include "chrome/installer/setup/install.h" | 33 #include "chrome/installer/setup/install.h" |
33 #include "chrome/installer/setup/setup_constants.h" | 34 #include "chrome/installer/setup/setup_constants.h" |
34 #include "chrome/installer/setup/setup_util.h" | 35 #include "chrome/installer/setup/setup_util.h" |
35 #include "chrome/installer/util/browser_distribution.h" | 36 #include "chrome/installer/util/browser_distribution.h" |
36 #include "chrome/installer/util/callback_work_item.h" | 37 #include "chrome/installer/util/callback_work_item.h" |
37 #include "chrome/installer/util/conditional_work_item_list.h" | 38 #include "chrome/installer/util/conditional_work_item_list.h" |
38 #include "chrome/installer/util/create_reg_key_work_item.h" | 39 #include "chrome/installer/util/create_reg_key_work_item.h" |
39 #include "chrome/installer/util/google_update_constants.h" | 40 #include "chrome/installer/util/google_update_constants.h" |
40 #include "chrome/installer/util/helper.h" | 41 #include "chrome/installer/util/helper.h" |
41 #include "chrome/installer/util/install_util.h" | 42 #include "chrome/installer/util/install_util.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 | 173 |
173 if (installer_state.RequiresActiveSetup()) { | 174 if (installer_state.RequiresActiveSetup()) { |
174 // Make a copy of setup.exe with a different name so that Active Setup | 175 // Make a copy of setup.exe with a different name so that Active Setup |
175 // doesn't require an admin on XP thanks to Application Compatibility. | 176 // doesn't require an admin on XP thanks to Application Compatibility. |
176 base::FilePath active_setup_exe(installer_dir.Append(kActiveSetupExe)); | 177 base::FilePath active_setup_exe(installer_dir.Append(kActiveSetupExe)); |
177 install_list->AddCopyTreeWorkItem( | 178 install_list->AddCopyTreeWorkItem( |
178 setup_path.value(), active_setup_exe.value(), temp_path.value(), | 179 setup_path.value(), active_setup_exe.value(), temp_path.value(), |
179 WorkItem::ALWAYS); | 180 WorkItem::ALWAYS); |
180 } | 181 } |
181 | 182 |
182 // If only the App Host (not even the Chrome Binaries) is being installed, | 183 base::FilePath archive_dst(installer_dir.Append(archive_path.BaseName())); |
183 // this must be a user-level App Host piggybacking on system-level Chrome | 184 if (archive_path != archive_dst) { |
184 // Binaries. Only setup.exe is required, and only for uninstall. | 185 // In the past, we copied rather than moved for system level installs so |
185 if (installer_state.products().size() != 1 || | 186 // that the permissions of %ProgramFiles% would be picked up. Now that |
186 !installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST)) { | 187 // |temp_path| is in %ProgramFiles% for system level installs (and in |
187 base::FilePath archive_dst(installer_dir.Append(archive_path.BaseName())); | 188 // %LOCALAPPDATA% otherwise), there is no need to do this for the archive. |
188 if (archive_path != archive_dst) { | 189 // Setup.exe, on the other hand, is created elsewhere so it must always be |
189 // In the past, we copied rather than moved for system level installs so | 190 // copied. |
190 // that the permissions of %ProgramFiles% would be picked up. Now that | 191 if (temp_path.IsParent(archive_path)) { |
191 // |temp_path| is in %ProgramFiles% for system level installs (and in | 192 install_list->AddMoveTreeWorkItem(archive_path.value(), |
192 // %LOCALAPPDATA% otherwise), there is no need to do this for the archive. | 193 archive_dst.value(), |
193 // Setup.exe, on the other hand, is created elsewhere so it must always be | 194 temp_path.value(), |
194 // copied. | 195 WorkItem::ALWAYS_MOVE); |
195 if (temp_path.IsParent(archive_path)) { | 196 } else { |
196 install_list->AddMoveTreeWorkItem(archive_path.value(), | 197 // This may occur when setup is run out of an existing installation |
197 archive_dst.value(), | 198 // directory. For example, when quick-enabling user-level App Launcher |
198 temp_path.value(), | 199 // from system-level Binaries. We can't (and don't want to) remove the |
199 WorkItem::ALWAYS_MOVE); | 200 // system-level archive. |
200 } else { | 201 install_list->AddCopyTreeWorkItem(archive_path.value(), |
201 // This may occur when setup is run out of an existing installation | 202 archive_dst.value(), |
202 // directory. For example, when quick-enabling user-level App Launcher | 203 temp_path.value(), |
203 // from system-level Binaries. We can't (and don't want to) remove the | 204 WorkItem::ALWAYS); |
204 // system-level archive. | |
205 install_list->AddCopyTreeWorkItem(archive_path.value(), | |
206 archive_dst.value(), | |
207 temp_path.value(), | |
208 WorkItem::ALWAYS); | |
209 } | |
210 } | 205 } |
211 } | 206 } |
212 } | 207 } |
213 | 208 |
214 string16 GetRegCommandKey(BrowserDistribution* dist, | 209 string16 GetRegCommandKey(BrowserDistribution* dist, |
215 const wchar_t* name) { | 210 const wchar_t* name) { |
216 string16 cmd_key(dist->GetVersionKey()); | 211 string16 cmd_key(dist->GetVersionKey()); |
217 cmd_key.append(1, base::FilePath::kSeparators[0]) | 212 cmd_key.append(1, base::FilePath::kSeparators[0]) |
218 .append(google_update::kRegCommandsKey) | 213 .append(google_update::kRegCommandsKey) |
219 .append(1, base::FilePath::kSeparators[0]) | 214 .append(1, base::FilePath::kSeparators[0]) |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
259 } | 254 } |
260 | 255 |
261 void AddInstallAppCommandWorkItems(const InstallerState& installer_state, | 256 void AddInstallAppCommandWorkItems(const InstallerState& installer_state, |
262 const InstallationState& machine_state, | 257 const InstallationState& machine_state, |
263 const Version& new_version, | 258 const Version& new_version, |
264 const Product& product, | 259 const Product& product, |
265 WorkItemList* work_item_list) { | 260 WorkItemList* work_item_list) { |
266 DCHECK(product.is_chrome_app_host()); | 261 DCHECK(product.is_chrome_app_host()); |
267 AddCommandWithParameterWorkItems(installer_state, machine_state, new_version, | 262 AddCommandWithParameterWorkItems(installer_state, machine_state, new_version, |
268 product, kCmdInstallApp, | 263 product, kCmdInstallApp, |
269 installer::kChromeAppHostExe, | 264 installer::kChromeExe, |
270 ::switches::kInstallFromWebstore, | 265 ::switches::kInstallFromWebstore, |
271 work_item_list); | 266 work_item_list); |
272 } | 267 } |
273 | 268 |
274 void AddInstallExtensionCommandWorkItem(const InstallerState& installer_state, | 269 void AddInstallExtensionCommandWorkItem(const InstallerState& installer_state, |
275 const InstallationState& machine_state, | 270 const InstallationState& machine_state, |
276 const base::FilePath& setup_path, | 271 const base::FilePath& setup_path, |
277 const Version& new_version, | 272 const Version& new_version, |
278 const Product& product, | 273 const Product& product, |
279 WorkItemList* work_item_list) { | 274 WorkItemList* work_item_list) { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
355 string16 cmd_key(GetRegCommandKey( | 350 string16 cmd_key(GetRegCommandKey( |
356 BrowserDistribution::GetSpecificDistribution( | 351 BrowserDistribution::GetSpecificDistribution( |
357 BrowserDistribution::CHROME_BINARIES), | 352 BrowserDistribution::CHROME_BINARIES), |
358 kCmdQuickEnableApplicationHost)); | 353 kCmdQuickEnableApplicationHost)); |
359 CommandLine cmd_line(GetGenericQuickEnableCommand(installer_state, | 354 CommandLine cmd_line(GetGenericQuickEnableCommand(installer_state, |
360 machine_state, | 355 machine_state, |
361 setup_path, | 356 setup_path, |
362 new_version)); | 357 new_version)); |
363 // kMultiInstall and kVerboseLogging were processed above. | 358 // kMultiInstall and kVerboseLogging were processed above. |
364 cmd_line.AppendSwitch(switches::kChromeAppLauncher); | 359 cmd_line.AppendSwitch(switches::kChromeAppLauncher); |
365 cmd_line.AppendSwitch(switches::kEnsureGoogleUpdatePresent); | |
gab
2013/04/29 20:25:41
Why is this being removed?
huangs
2013/04/30 14:01:49
This existed so an orphaned app_host.exe (i.e., it
| |
366 AppCommand cmd(cmd_line.GetCommandLineString()); | 360 AppCommand cmd(cmd_line.GetCommandLineString()); |
367 cmd.set_sends_pings(true); | 361 cmd.set_sends_pings(true); |
368 cmd.set_is_web_accessible(true); | 362 cmd.set_is_web_accessible(true); |
369 cmd.set_is_run_as_user(true); | 363 cmd.set_is_run_as_user(true); |
370 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); | 364 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); |
371 } | 365 } |
372 } | 366 } |
373 | 367 |
374 void AddProductSpecificWorkItems(const InstallationState& original_state, | 368 void AddProductSpecificWorkItems(const InstallationState& original_state, |
375 const InstallerState& installer_state, | 369 const InstallerState& installer_state, |
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
654 scoped_ptr<WorkItemList> no_rollback_list( | 648 scoped_ptr<WorkItemList> no_rollback_list( |
655 WorkItem::CreateNoRollbackWorkItemList()); | 649 WorkItem::CreateNoRollbackWorkItemList()); |
656 AddUninstallDelegateExecuteWorkItems( | 650 AddUninstallDelegateExecuteWorkItems( |
657 HKEY_CURRENT_USER, google_chrome_delegate_execute_path, | 651 HKEY_CURRENT_USER, google_chrome_delegate_execute_path, |
658 no_rollback_list.get()); | 652 no_rollback_list.get()); |
659 list->AddWorkItem(no_rollback_list.release()); | 653 list->AddWorkItem(no_rollback_list.release()); |
660 VLOG(1) << "Added deletion items for bad Canary registrations."; | 654 VLOG(1) << "Added deletion items for bad Canary registrations."; |
661 } | 655 } |
662 } | 656 } |
663 | 657 |
658 // As of M28, App Launcher is unified with Chrome. Here we delete a number of | |
659 // legacy install artifacts for the product, before new artifacts are installed. | |
660 void MigrateLegacyAppLauncher(const InstallerState& installer_state, | |
661 const base::FilePath& temp_path, | |
662 WorkItemList* install_list) { | |
663 VLOG(1) << "Migrating legacy App Launcher with app_host.exe."; | |
664 HKEY reg_root = HKEY_CURRENT_USER; | |
665 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | |
666 BrowserDistribution::CHROME_APP_HOST); | |
667 | |
668 // Delete Add/Remove entry. | |
669 string16 legacy_app_host_uninstall_reg_path( | |
670 L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" | |
671 L"Google Chrome App Launcher"); | |
gab
2013/04/29 20:25:41
Where was this set from before? Does it have to be
huangs
2013/04/30 14:01:49
This obsolete key was living in chrome_app_host_di
| |
672 install_list->AddDeleteRegKeyWorkItem(reg_root, | |
673 legacy_app_host_uninstall_reg_path); | |
674 | |
675 if (installer_state.system_install()) { | |
676 // Delete user-level registry entries for App Launcher. | |
677 install_list->AddDeleteRegKeyWorkItem(reg_root, dist->GetVersionKey()); | |
678 install_list->AddDeleteRegKeyWorkItem(reg_root, dist->GetStateKey()); | |
679 // Not updating AP values | |
680 } | |
681 | |
682 // Delete app_host.exe. | |
683 base::FilePath app_host_exe(chrome_launcher_support::GetAnyAppHostPath()); | |
gab
2013/04/29 20:25:41
This will always prefer deleting the system-level
huangs
2013/04/30 14:01:49
Yes, but app_host.exe have always been in user-lev
| |
684 if (!app_host_exe.empty()) | |
685 install_list->AddDeleteTreeWorkItem(app_host_exe, temp_path); | |
686 | |
687 // Not migrating shortcuts here. | |
688 } | |
689 | |
664 } // namespace | 690 } // namespace |
665 | 691 |
666 // This method adds work items to create (or update) Chrome uninstall entry in | 692 // This method adds work items to create (or update) Chrome uninstall entry in |
667 // either the Control Panel->Add/Remove Programs list or in the Omaha client | 693 // either the Control Panel->Add/Remove Programs list or in the Omaha client |
668 // state key if running under an MSI installer. | 694 // state key if running under an MSI installer. |
669 void AddUninstallShortcutWorkItems(const InstallerState& installer_state, | 695 void AddUninstallShortcutWorkItems(const InstallerState& installer_state, |
670 const base::FilePath& setup_path, | 696 const base::FilePath& setup_path, |
671 const Version& new_version, | 697 const Version& new_version, |
672 const Product& product, | 698 const Product& product, |
673 WorkItemList* install_list) { | 699 WorkItemList* install_list) { |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1166 const Version& new_version, | 1192 const Version& new_version, |
1167 WorkItemList* install_list) { | 1193 WorkItemList* install_list) { |
1168 DCHECK(install_list); | 1194 DCHECK(install_list); |
1169 | 1195 |
1170 const base::FilePath& target_path = installer_state.target_path(); | 1196 const base::FilePath& target_path = installer_state.target_path(); |
1171 | 1197 |
1172 // A temp directory that work items need and the actual install directory. | 1198 // A temp directory that work items need and the actual install directory. |
1173 install_list->AddCreateDirWorkItem(temp_path); | 1199 install_list->AddCreateDirWorkItem(temp_path); |
1174 install_list->AddCreateDirWorkItem(target_path); | 1200 install_list->AddCreateDirWorkItem(target_path); |
1175 | 1201 |
1202 // User-level App Launcher may be an old version that uses app_host.exe, | |
1203 // which needs to be migrated. | |
1204 if (installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES) && | |
1205 !installer_state.system_install()) { | |
1206 const ProductState* orig_product = original_state.GetProductState( | |
1207 false, BrowserDistribution::CHROME_APP_HOST); | |
1208 if (orig_product && | |
1209 chrome_launcher_support::HasLegacyAppHostExe(orig_product->version())) { | |
1210 MigrateLegacyAppLauncher(installer_state, temp_path, install_list); | |
1211 } | |
1212 } | |
1213 | |
1176 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER) || | 1214 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER) || |
1177 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) || | 1215 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) || |
1178 installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES)) { | 1216 installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES)) { |
1179 AddChromeWorkItems(original_state, | 1217 AddChromeWorkItems(original_state, |
1180 installer_state, | 1218 installer_state, |
1181 setup_path, | 1219 setup_path, |
1182 archive_path, | 1220 archive_path, |
1183 src_path, | 1221 src_path, |
1184 temp_path, | 1222 temp_path, |
1185 current_version, | 1223 current_version, |
1186 new_version, | 1224 new_version, |
1187 install_list); | 1225 install_list); |
1188 } | 1226 } |
1189 | 1227 |
1190 if (installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST)) { | |
1191 install_list->AddCopyTreeWorkItem( | |
1192 src_path.Append(installer::kChromeAppHostExe).value(), | |
1193 target_path.Append(installer::kChromeAppHostExe).value(), | |
1194 temp_path.value(), | |
1195 WorkItem::ALWAYS, | |
1196 L""); | |
1197 } | |
1198 | |
1199 // Copy installer in install directory | 1228 // Copy installer in install directory |
1200 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path, | 1229 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path, |
1201 new_version, install_list); | 1230 new_version, install_list); |
1202 | 1231 |
1203 const HKEY root = installer_state.root_key(); | 1232 const HKEY root = installer_state.root_key(); |
1204 // Only set "lang" for user-level installs since for system-level, the install | 1233 // Only set "lang" for user-level installs since for system-level, the install |
1205 // language may not be related to a given user's runtime language. | 1234 // language may not be related to a given user's runtime language. |
1206 const bool add_language_identifier = !installer_state.system_install(); | 1235 const bool add_language_identifier = !installer_state.system_install(); |
1207 | 1236 |
1208 const Products& products = installer_state.products(); | 1237 const Products& products = installer_state.products(); |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1697 if (installer_state.system_install()) | 1726 if (installer_state.system_install()) |
1698 cmd_line.AppendSwitch(switches::kSystemLevel); | 1727 cmd_line.AppendSwitch(switches::kSystemLevel); |
1699 AppCommand cmd(cmd_line.GetCommandLineString()); | 1728 AppCommand cmd(cmd_line.GetCommandLineString()); |
1700 cmd.set_sends_pings(true); | 1729 cmd.set_sends_pings(true); |
1701 cmd.set_is_web_accessible(true); | 1730 cmd.set_is_web_accessible(true); |
1702 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); | 1731 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); |
1703 } | 1732 } |
1704 } | 1733 } |
1705 | 1734 |
1706 } // namespace installer | 1735 } // namespace installer |
OLD | NEW |