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

Side by Side Diff: chrome/installer/setup/install_worker.cc

Issue 14031025: Implementing unified Chrome / App Launcher flow, and migrating old stand-alone App Launcher. (Closed) Base URL: http://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing Start Menu root stuff; cleanups. Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // This file contains the definitions of the installer functions that build 5 // This file contains the definitions of the installer functions that build
6 // the WorkItemList used to install the application. 6 // the WorkItemList used to install the application.
7 7
8 #include "chrome/installer/setup/install_worker.h" 8 #include "chrome/installer/setup/install_worker.h"
9 9
10 #include <oaidl.h> 10 #include <oaidl.h>
(...skipping 11 matching lines...) Expand all
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
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
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
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);
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
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 M29, 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 that used app_host.exe.";
664 if (!installer_state.system_install()) {
665 // Delete Add/Remove entry. Skip this for system-level install, since in
666 // this case it's up to the self-destruct flow to call uninstall.
667 string16 legacy_app_host_uninstall_reg_path(
668 L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"
669 L"Google Chrome App Launcher");
670 install_list->AddDeleteRegKeyWorkItem(HKEY_CURRENT_USER,
671 legacy_app_host_uninstall_reg_path);
672 }
673
674 // Delete app_host.exe at the install level.
675 base::FilePath app_host_exe(
676 chrome_launcher_support::GetAppHostPathForInstallationLevel(
677 installer_state.system_install() ?
678 chrome_launcher_support::SYSTEM_LEVEL_INSTALLATION :
679 chrome_launcher_support::USER_LEVEL_INSTALLATION));
680 if (!app_host_exe.empty())
681 install_list->AddDeleteTreeWorkItem(app_host_exe, temp_path);
682 }
683
664 } // namespace 684 } // namespace
665 685
666 // This method adds work items to create (or update) Chrome uninstall entry in 686 // 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 687 // either the Control Panel->Add/Remove Programs list or in the Omaha client
668 // state key if running under an MSI installer. 688 // state key if running under an MSI installer.
669 void AddUninstallShortcutWorkItems(const InstallerState& installer_state, 689 void AddUninstallShortcutWorkItems(const InstallerState& installer_state,
670 const base::FilePath& setup_path, 690 const base::FilePath& setup_path,
671 const Version& new_version, 691 const Version& new_version,
672 const Product& product, 692 const Product& product,
673 WorkItemList* install_list) { 693 WorkItemList* install_list) {
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 const Version& new_version, 1186 const Version& new_version,
1167 WorkItemList* install_list) { 1187 WorkItemList* install_list) {
1168 DCHECK(install_list); 1188 DCHECK(install_list);
1169 1189
1170 const base::FilePath& target_path = installer_state.target_path(); 1190 const base::FilePath& target_path = installer_state.target_path();
1171 1191
1172 // A temp directory that work items need and the actual install directory. 1192 // A temp directory that work items need and the actual install directory.
1173 install_list->AddCreateDirWorkItem(temp_path); 1193 install_list->AddCreateDirWorkItem(temp_path);
1174 install_list->AddCreateDirWorkItem(target_path); 1194 install_list->AddCreateDirWorkItem(target_path);
1175 1195
1196 // User-level App Launcher may be an old version that uses app_host.exe,
1197 // which needs to be migrated.
1198 if (installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES) &&
1199 installer_state.need_to_migrate_legacy_app_launcher()) {
1200 MigrateLegacyAppLauncher(installer_state, temp_path, install_list);
1201 }
1202
1176 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER) || 1203 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER) ||
1177 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) || 1204 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) ||
1178 installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES)) { 1205 installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES)) {
1179 AddChromeWorkItems(original_state, 1206 AddChromeWorkItems(original_state,
1180 installer_state, 1207 installer_state,
1181 setup_path, 1208 setup_path,
1182 archive_path, 1209 archive_path,
1183 src_path, 1210 src_path,
1184 temp_path, 1211 temp_path,
1185 current_version, 1212 current_version,
1186 new_version, 1213 new_version,
1187 install_list); 1214 install_list);
1188 } 1215 }
1189 1216
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 1217 // Copy installer in install directory
1200 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path, 1218 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path,
1201 new_version, install_list); 1219 new_version, install_list);
1202 1220
1203 const HKEY root = installer_state.root_key(); 1221 const HKEY root = installer_state.root_key();
1204 // Only set "lang" for user-level installs since for system-level, the install 1222 // 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. 1223 // language may not be related to a given user's runtime language.
1206 const bool add_language_identifier = !installer_state.system_install(); 1224 const bool add_language_identifier = !installer_state.system_install();
1207 1225
1208 const Products& products = installer_state.products(); 1226 const Products& products = installer_state.products();
1209 for (Products::const_iterator it = products.begin(); it < products.end(); 1227 for (Products::const_iterator it = products.begin(); it < products.end();
1210 ++it) { 1228 ++it) {
1211 const Product& product = **it; 1229 const Product& product = **it;
1212 1230
1213 AddUninstallShortcutWorkItems(installer_state, setup_path, new_version, 1231 AddUninstallShortcutWorkItems(installer_state, setup_path, new_version,
1214 product, install_list); 1232 product, install_list);
1215 1233
1216 AddVersionKeyWorkItems(root, product.distribution(), new_version, 1234 AddVersionKeyWorkItems(root, product.distribution(), new_version,
1217 add_language_identifier, install_list); 1235 add_language_identifier, install_list);
1218 1236
1219 AddDelegateExecuteWorkItems(installer_state, target_path, new_version, 1237 AddDelegateExecuteWorkItems(installer_state, target_path, new_version,
1220 product, install_list); 1238 product, install_list);
1221 1239
1222 AddActiveSetupWorkItems(installer_state, setup_path, new_version, product, 1240 AddActiveSetupWorkItems(installer_state, setup_path, new_version, product,
1223 install_list); 1241 install_list);
1224 } 1242 }
1225 1243
1226 // TODO(huangs): Implement actual migration code and remove the hack below.
1227 // If installing Chrome without the legacy stand-alone App Launcher (to be
1228 // handled later), add "shadow" App Launcher registry keys so Google Update
1229 // would recognize the "dr" value in the App Launcher ClientState key.
1230 // Checking .is_multi_install() excludes Chrome Canary and stand-alone Chrome.
1231 if (installer_state.is_multi_install() &&
1232 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER) &&
1233 !installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST)) {
1234 BrowserDistribution* shadow_app_launcher_dist =
1235 BrowserDistribution::GetSpecificDistribution(
1236 BrowserDistribution::CHROME_APP_HOST);
1237 AddVersionKeyWorkItems(root, shadow_app_launcher_dist, new_version,
1238 add_language_identifier, install_list);
1239 }
1240
1241 // Add any remaining work items that involve special settings for 1244 // Add any remaining work items that involve special settings for
1242 // each product. 1245 // each product.
1243 AddProductSpecificWorkItems(original_state, installer_state, setup_path, 1246 AddProductSpecificWorkItems(original_state, installer_state, setup_path,
1244 new_version, install_list); 1247 new_version, install_list);
1245 1248
1246 // Copy over brand, usagestats, and other values. 1249 // Copy over brand, usagestats, and other values.
1247 AddGoogleUpdateWorkItems(original_state, installer_state, install_list); 1250 AddGoogleUpdateWorkItems(original_state, installer_state, install_list);
1248 1251
1249 // Append the tasks that run after the installation. 1252 // Append the tasks that run after the installation.
1250 AppendPostInstallTasks(installer_state, 1253 AppendPostInstallTasks(installer_state,
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 if (installer_state.system_install()) 1715 if (installer_state.system_install())
1713 cmd_line.AppendSwitch(switches::kSystemLevel); 1716 cmd_line.AppendSwitch(switches::kSystemLevel);
1714 AppCommand cmd(cmd_line.GetCommandLineString()); 1717 AppCommand cmd(cmd_line.GetCommandLineString());
1715 cmd.set_sends_pings(true); 1718 cmd.set_sends_pings(true);
1716 cmd.set_is_web_accessible(true); 1719 cmd.set_is_web_accessible(true);
1717 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); 1720 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list);
1718 } 1721 }
1719 } 1722 }
1720 1723
1721 } // namespace installer 1724 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698