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

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

Issue 10665002: Implement installation of the Chrome App Host. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: A basic working app host installer/uninstaller. Created 8 years, 5 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 | Annotate | Revision Log
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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // locate the setup.exe instance used for binary patching. 133 // locate the setup.exe instance used for binary patching.
134 // Do not quote the command line for the MSI invocation. 134 // Do not quote the command line for the MSI invocation.
135 FilePath install_path(installer_state.target_path()); 135 FilePath install_path(installer_state.target_path());
136 FilePath installer_path(installer_state.GetInstallerDirectory(new_version)); 136 FilePath installer_path(installer_state.GetInstallerDirectory(new_version));
137 installer_path = installer_path.Append(setup_path.BaseName()); 137 installer_path = installer_path.Append(setup_path.BaseName());
138 138
139 CommandLine uninstall_arguments(CommandLine::NO_PROGRAM); 139 CommandLine uninstall_arguments(CommandLine::NO_PROGRAM);
140 AppendUninstallCommandLineFlags(installer_state, product, 140 AppendUninstallCommandLineFlags(installer_state, product,
141 &uninstall_arguments); 141 &uninstall_arguments);
142 142
143 // TODO(erikwright): What does this mean? Chrome Frame _is_ in Add/Remove, No?
tommi (sloooow) - chröme 2012/07/12 08:11:31 I think the comment is out of date and was probabl
grt (UTC plus 2) 2012/07/12 18:37:10 I think it refers to ready-mode, where Chrome Fram
erikwright (departed) 2012/07/16 20:13:11 Done.
143 // The Chrome uninstallation command serves as the master uninstall command 144 // The Chrome uninstallation command serves as the master uninstall command
144 // for Chrome + all other products (i.e. Chrome Frame) that do not have an 145 // for Chrome + all other products (i.e. Chrome Frame) that do not have an
145 // uninstall entry in the Add/Remove Programs dialog. We skip this processing 146 // uninstall entry in the Add/Remove Programs dialog. We skip this processing
146 // in case of uninstall since this means that Chrome Frame is being 147 // in case of uninstall since this means that Chrome Frame is being
147 // uninstalled, so there's no need to do any looping. 148 // uninstalled, so there's no need to do any looping.
148 if (product.is_chrome() && 149 if (product.is_chrome() &&
149 installer_state.operation() != InstallerState::UNINSTALL) { 150 installer_state.operation() != InstallerState::UNINSTALL) {
150 const Products& products = installer_state.products(); 151 const Products& products = installer_state.products();
151 for (size_t i = 0; i < products.size(); ++i) { 152 for (size_t i = 0; i < products.size(); ++i) {
152 const Product& p = *products[i]; 153 const Product& p = *products[i];
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 // do a few post install tasks: 557 // do a few post install tasks:
557 // - Handle the case of in-use-update by updating "opv" (old version) key or 558 // - Handle the case of in-use-update by updating "opv" (old version) key or
558 // deleting it if not required. 559 // deleting it if not required.
559 // - Register any new dlls and unregister old dlls. 560 // - Register any new dlls and unregister old dlls.
560 // - If this is an MSI install, ensures that the MSI marker is set, and sets 561 // - If this is an MSI install, ensures that the MSI marker is set, and sets
561 // it if not. 562 // it if not.
562 // If these operations are successful, the function returns true, otherwise 563 // If these operations are successful, the function returns true, otherwise
563 // false. 564 // false.
564 bool AppendPostInstallTasks(const InstallerState& installer_state, 565 bool AppendPostInstallTasks(const InstallerState& installer_state,
565 const FilePath& setup_path, 566 const FilePath& setup_path,
566 const FilePath& new_chrome_exe,
567 const Version* current_version, 567 const Version* current_version,
568 const Version& new_version, 568 const Version& new_version,
569 const FilePath& temp_path, 569 const FilePath& temp_path,
570 WorkItemList* post_install_task_list) { 570 WorkItemList* post_install_task_list) {
571 DCHECK(post_install_task_list); 571 DCHECK(post_install_task_list);
572 572
573 HKEY root = installer_state.root_key(); 573 HKEY root = installer_state.root_key();
574 const Products& products = installer_state.products(); 574 const Products& products = installer_state.products();
575 FilePath new_chrome_exe(
576 installer_state.target_path().Append(installer::kChromeNewExe));
575 577
576 // Append work items that will only be executed if this was an update. 578 // Append work items that will only be executed if this was an update.
577 // We update the 'opv' value with the current version that is active, 579 // We update the 'opv' value with the current version that is active,
578 // the 'cpv' value with the critical update version (if present), and the 580 // the 'cpv' value with the critical update version (if present), and the
579 // 'cmd' value with the rename command to run. 581 // 'cmd' value with the rename command to run.
580 { 582 {
581 scoped_ptr<WorkItemList> in_use_update_work_items( 583 scoped_ptr<WorkItemList> in_use_update_work_items(
582 WorkItem::CreateConditionalWorkItemList( 584 WorkItem::CreateConditionalWorkItemList(
583 new ConditionRunIfFileExists(new_chrome_exe))); 585 new ConditionRunIfFileExists(new_chrome_exe)));
584 in_use_update_work_items->set_log_message("InUseUpdateWorkItemList"); 586 in_use_update_work_items->set_log_message("InUseUpdateWorkItemList");
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 if (installer_state.is_multi_install()) { 707 if (installer_state.is_multi_install()) {
706 AddSetMsiMarkerWorkItem(installer_state, 708 AddSetMsiMarkerWorkItem(installer_state,
707 installer_state.multi_package_binaries_distribution(), true, 709 installer_state.multi_package_binaries_distribution(), true,
708 post_install_task_list); 710 post_install_task_list);
709 } 711 }
710 } 712 }
711 713
712 return true; 714 return true;
713 } 715 }
714 716
715 void AddInstallWorkItems(const InstallationState& original_state, 717 void AddChromeWorkItems(const InstallationState& original_state,
716 const InstallerState& installer_state, 718 const InstallerState& installer_state,
717 const FilePath& setup_path, 719 const FilePath& setup_path,
718 const FilePath& archive_path, 720 const FilePath& archive_path,
719 const FilePath& src_path, 721 const FilePath& src_path,
720 const FilePath& temp_path, 722 const FilePath& temp_path,
721 const Version& new_version, 723 const Version& new_version,
722 scoped_ptr<Version>* current_version, 724 scoped_ptr<Version>* current_version,
723 WorkItemList* install_list) { 725 WorkItemList* install_list) {
724 DCHECK(install_list);
725
726 const FilePath& target_path = installer_state.target_path(); 726 const FilePath& target_path = installer_state.target_path();
727 727
728 // A temp directory that work items need and the actual install directory.
729 install_list->AddCreateDirWorkItem(temp_path);
730 install_list->AddCreateDirWorkItem(target_path);
731
732 if (current_version != NULL && current_version->get() != NULL) { 728 if (current_version != NULL && current_version->get() != NULL) {
733 // Delete the archive from an existing install to save some disk space. We 729 // Delete the archive from an existing install to save some disk space. We
734 // make this an unconditional work item since there's no need to roll this 730 // make this an unconditional work item since there's no need to roll this
735 // back; if installation fails we'll be moved to the "-full" channel anyway. 731 // back; if installation fails we'll be moved to the "-full" channel anyway.
736 FilePath old_installer_dir( 732 FilePath old_installer_dir(
737 installer_state.GetInstallerDirectory(**current_version)); 733 installer_state.GetInstallerDirectory(**current_version));
738 FilePath old_archive(old_installer_dir.Append(archive_path.BaseName())); 734 FilePath old_archive(old_installer_dir.Append(archive_path.BaseName()));
739 install_list->AddDeleteTreeWorkItem(old_archive, temp_path) 735 install_list->AddDeleteTreeWorkItem(old_archive, temp_path)
740 ->set_ignore_failure(true); 736 ->set_ignore_failure(true);
741 } 737 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 // Delete any old_chrome.exe if present (ignore failure if it's in use). 829 // Delete any old_chrome.exe if present (ignore failure if it's in use).
834 install_list->AddDeleteTreeWorkItem( 830 install_list->AddDeleteTreeWorkItem(
835 target_path.Append(installer::kChromeOldExe), temp_path) 831 target_path.Append(installer::kChromeOldExe), temp_path)
836 ->set_ignore_failure(true); 832 ->set_ignore_failure(true);
837 833
838 // Copy installer in install directory and 834 // Copy installer in install directory and
839 // add shortcut in Control Panel->Add/Remove Programs. 835 // add shortcut in Control Panel->Add/Remove Programs.
840 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path, 836 AddInstallerCopyTasks(installer_state, setup_path, archive_path, temp_path,
841 new_version, install_list); 837 new_version, install_list);
842 838
839 }
840
841 void AddInstallWorkItems(const InstallationState& original_state,
842 const InstallerState& installer_state,
843 const FilePath& setup_path,
844 const FilePath& archive_path,
845 const FilePath& src_path,
846 const FilePath& temp_path,
847 const Version& new_version,
848 scoped_ptr<Version>* current_version,
849 WorkItemList* install_list) {
850 DCHECK(install_list);
851
852 const FilePath& target_path = installer_state.target_path();
853
854 // A temp directory that work items need and the actual install directory.
855 install_list->AddCreateDirWorkItem(temp_path);
856 install_list->AddCreateDirWorkItem(target_path);
857
858 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER) ||
859 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) ||
860 installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES)) {
861 AddChromeWorkItems(original_state,
862 installer_state,
863 setup_path,
864 archive_path,
865 src_path,
866 temp_path,
867 new_version,
868 current_version,
869 install_list);
870 }
871
872 if (installer_state.FindProduct(BrowserDistribution::CHROME_APP_HOST)) {
873 install_list->AddCopyTreeWorkItem(
874 src_path.Append(installer::kChromeAppHostExe).value(),
875 target_path.Append(installer::kChromeAppHostExe).value(),
876 temp_path.value(),
877 WorkItem::ALWAYS,
878 L"");
879 }
880
843 const HKEY root = installer_state.root_key(); 881 const HKEY root = installer_state.root_key();
844 // Only set "lang" for user-level installs since for system-level, the install 882 // Only set "lang" for user-level installs since for system-level, the install
845 // language may not be related to a given user's runtime language. 883 // language may not be related to a given user's runtime language.
846 const bool add_language_identifier = !installer_state.system_install(); 884 const bool add_language_identifier = !installer_state.system_install();
847 885
848 const Products& products = installer_state.products(); 886 const Products& products = installer_state.products();
849 for (size_t i = 0; i < products.size(); ++i) { 887 for (size_t i = 0; i < products.size(); ++i) {
850 const Product* product = products[i]; 888 const Product* product = products[i];
851 889
852 AddUninstallShortcutWorkItems(installer_state, setup_path, new_version, 890 AddUninstallShortcutWorkItems(installer_state, setup_path, new_version,
(...skipping 22 matching lines...) Expand all
875 913
876 // Copy over brand, usagestats, and other values. 914 // Copy over brand, usagestats, and other values.
877 AddGoogleUpdateWorkItems(original_state, installer_state, install_list); 915 AddGoogleUpdateWorkItems(original_state, installer_state, install_list);
878 916
879 AddQuickEnableWorkItems(installer_state, original_state, &setup_path, 917 AddQuickEnableWorkItems(installer_state, original_state, &setup_path,
880 &new_version, install_list); 918 &new_version, install_list);
881 919
882 // Append the tasks that run after the installation. 920 // Append the tasks that run after the installation.
883 AppendPostInstallTasks(installer_state, 921 AppendPostInstallTasks(installer_state,
884 setup_path, 922 setup_path,
885 new_chrome_exe,
886 current_version->get(), 923 current_version->get(),
887 new_version, 924 new_version,
888 temp_path, 925 temp_path,
889 install_list); 926 install_list);
890 } 927 }
891 928
892 void AddRegisterComDllWorkItems(const FilePath& dll_folder, 929 void AddRegisterComDllWorkItems(const FilePath& dll_folder,
893 const std::vector<FilePath>& dll_list, 930 const std::vector<FilePath>& dll_list,
894 bool system_level, 931 bool system_level,
895 bool do_register, 932 bool do_register,
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 const FilePath* setup_path, 1338 const FilePath* setup_path,
1302 const Version* new_version, 1339 const Version* new_version,
1303 WorkItemList* work_item_list) { 1340 WorkItemList* work_item_list) {
1304 DCHECK(setup_path || 1341 DCHECK(setup_path ||
1305 installer_state.operation() == InstallerState::UNINSTALL); 1342 installer_state.operation() == InstallerState::UNINSTALL);
1306 DCHECK(new_version || 1343 DCHECK(new_version ||
1307 installer_state.operation() == InstallerState::UNINSTALL); 1344 installer_state.operation() == InstallerState::UNINSTALL);
1308 DCHECK(work_item_list); 1345 DCHECK(work_item_list);
1309 1346
1310 const bool system_install = installer_state.system_install(); 1347 const bool system_install = installer_state.system_install();
1311 bool have_multi_chrome = false; 1348 bool have_chrome_binaries = false;
1312 bool have_chrome_frame = false; 1349 bool have_chrome_frame = false;
1313 1350
1314 // STEP 1: Figure out the state of the machine before the operation. 1351 // STEP 1: Figure out the state of the machine before the operation.
1315 const ProductState* product_state = NULL; 1352 const ProductState* product_state = NULL;
1316 1353
1317 // Is multi-install Chrome already on the machine? 1354 // Is Chrome Binaries already on the machine?
tommi (sloooow) - chröme 2012/07/12 08:11:31 s/Is/Are the
erikwright (departed) 2012/07/16 20:13:11 Done.
1318 product_state = 1355 product_state =
1319 machine_state.GetProductState(system_install, 1356 machine_state.GetProductState(system_install,
1320 BrowserDistribution::CHROME_BROWSER); 1357 BrowserDistribution::CHROME_BINARIES);
1321 if (product_state != NULL && product_state->is_multi_install()) 1358 if (product_state != NULL && product_state->is_multi_install())
1322 have_multi_chrome = true; 1359 have_chrome_binaries = true;
1323 1360
1324 // Is Chrome Frame !ready-mode already on the machine? 1361 // Is Chrome Frame !ready-mode already on the machine?
1325 product_state = 1362 product_state =
1326 machine_state.GetProductState(system_install, 1363 machine_state.GetProductState(system_install,
1327 BrowserDistribution::CHROME_FRAME); 1364 BrowserDistribution::CHROME_FRAME);
1328 if (product_state != NULL && 1365 if (product_state != NULL &&
1329 !product_state->uninstall_command().HasSwitch( 1366 !product_state->uninstall_command().HasSwitch(
1330 switches::kChromeFrameReadyMode)) 1367 switches::kChromeFrameReadyMode))
1331 have_chrome_frame = true; 1368 have_chrome_frame = true;
1332 1369
1333 // STEP 2: Now take into account the current operation. 1370 // STEP 2: Now take into account the current operation.
1334 const Product* product = NULL; 1371 const Product* product = NULL;
1335 1372
1336 if (installer_state.operation() == InstallerState::UNINSTALL) { 1373 if (installer_state.operation() == InstallerState::UNINSTALL) {
1337 // Forget about multi-install Chrome if it is being uninstalled. 1374 // Forget about multi-install Chrome if it is being uninstalled.
1338 product = 1375 product =
1339 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); 1376 installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES);
1340 if (product != NULL && installer_state.is_multi_install()) 1377 if (product != NULL && installer_state.is_multi_install())
1341 have_multi_chrome = false; 1378 have_chrome_binaries = false;
1342 1379
1343 // Forget about Chrome Frame if it is being uninstalled. Note that we don't 1380 // Forget about Chrome Frame if it is being uninstalled. Note that we don't
1344 // bother to check !HasOption(kOptionReadyMode) since have_chrome_frame 1381 // bother to check !HasOption(kOptionReadyMode) since have_chrome_frame
1345 // should have been false for that case in the first place. It's odd if it 1382 // should have been false for that case in the first place. It's odd if it
1346 // wasn't, but the right thing to do in that case is to proceed with the 1383 // wasn't, but the right thing to do in that case is to proceed with the
1347 // thought that CF will not be installed in any sense when we reach the 1384 // thought that CF will not be installed in any sense when we reach the
1348 // finish line. 1385 // finish line.
1349 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) != NULL) 1386 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) != NULL)
1350 have_chrome_frame = false; 1387 have_chrome_frame = false;
1351 } else { 1388 } else {
1352 // Check if we're installing multi-install Chrome. 1389 // Check if we're installing Chrome Binaries
1353 product = 1390 product =
1354 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); 1391 installer_state.FindProduct(BrowserDistribution::CHROME_BINARIES);
1355 if (product != NULL && installer_state.is_multi_install()) 1392 if (product != NULL && installer_state.is_multi_install())
1356 have_multi_chrome = true; 1393 have_chrome_binaries = true;
1357 1394
1358 // Check if we're installing Chrome Frame !ready-mode. 1395 // Check if we're installing Chrome Frame !ready-mode.
1359 product = installer_state.FindProduct(BrowserDistribution::CHROME_FRAME); 1396 product = installer_state.FindProduct(BrowserDistribution::CHROME_FRAME);
1360 if (product != NULL && !product->HasOption(kOptionReadyMode)) 1397 if (product != NULL && !product->HasOption(kOptionReadyMode))
1361 have_chrome_frame = true; 1398 have_chrome_frame = true;
1362 } 1399 }
1363 1400
1364 // STEP 3: Decide what to do based on the final state of things. 1401 // STEP 3: Decide what to do based on the final state of things.
1365 enum QuickEnableOperation { 1402 enum QuickEnableOperation {
1366 DO_NOTHING, 1403 DO_NOTHING,
1367 ADD_COMMAND, 1404 ADD_COMMAND,
1368 REMOVE_COMMAND 1405 REMOVE_COMMAND
1369 } operation = DO_NOTHING; 1406 } operation = DO_NOTHING;
1370 FilePath binaries_setup_path; 1407 FilePath binaries_setup_path;
1371 1408
1372 if (have_chrome_frame) { 1409 if (have_chrome_frame) {
1373 // Chrome Frame !ready-mode is or will be installed. Unconditionally remove 1410 // Chrome Frame !ready-mode is or will be installed. Unconditionally remove
1374 // the quick-enable-cf command from the binaries. We do this even if 1411 // the quick-enable-cf command from the binaries. We do this even if
1375 // multi-install Chrome isn't installed since we don't want them left 1412 // multi-install Chrome isn't installed since we don't want them left
1376 // behind in any case. 1413 // behind in any case.
1377 operation = REMOVE_COMMAND; 1414 operation = REMOVE_COMMAND;
1378 } else if (have_multi_chrome) { 1415 } else if (have_chrome_binaries) {
1379 // Chrome Frame isn't (to be) installed or is (to be) installed only in 1416 // Chrome Frame isn't (to be) installed or is (to be) installed only in
1380 // ready-mode, while multi-install Chrome is (to be) installed. Add the 1417 // ready-mode, while multi-install Chrome is (to be) installed. Add the
1381 // quick-enable-cf command to the binaries. 1418 // quick-enable-cf command to the binaries.
1382 operation = ADD_COMMAND; 1419 operation = ADD_COMMAND;
1383 // The path to setup.exe contains the version of the Chrome binaries, so it 1420 // The path to setup.exe contains the version of the Chrome binaries, so it
1384 // takes a little work to get it right. 1421 // takes a little work to get it right.
1385 if (installer_state.operation() == InstallerState::UNINSTALL) { 1422 if (installer_state.operation() == InstallerState::UNINSTALL) {
1386 // Chrome Frame is being uninstalled. Use the path to the currently 1423 // One or more products are being uninstalled, but not the binaries. Use
1387 // installed Chrome setup.exe. 1424 // the path to the currently installed Chrome setup.exe.
1388 product_state = 1425 product_state =
1389 machine_state.GetProductState(system_install, 1426 machine_state.GetProductState(system_install,
1390 BrowserDistribution::CHROME_BROWSER); 1427 BrowserDistribution::CHROME_BINARIES);
1391 DCHECK(product_state); 1428 DCHECK(product_state);
1392 binaries_setup_path = product_state->uninstall_command().GetProgram(); 1429 binaries_setup_path = product_state->uninstall_command().GetProgram();
1393 } else { 1430 } else {
1394 // Chrome is being installed, updated, or otherwise being operated on. 1431 // Chrome Binaries are being installed, updated, or otherwise operated on.
1395 // Use the path to the given |setup_path| in the normal location of 1432 // Use the path to the given |setup_path| in the normal location of
1396 // multi-install Chrome of the given |version|. 1433 // multi-install Chrome Binaries of the given |version|.
1397 DCHECK(installer_state.is_multi_install()); 1434 DCHECK(installer_state.is_multi_install());
1398 binaries_setup_path = 1435 binaries_setup_path =
1399 installer_state.GetInstallerDirectory(*new_version).Append( 1436 installer_state.GetInstallerDirectory(*new_version).Append(
1400 setup_path->BaseName()); 1437 setup_path->BaseName());
1401 } 1438 }
1402 } 1439 }
1403 1440
1404 // STEP 4: Take action. 1441 // STEP 4: Take action.
1405 if (operation != DO_NOTHING) { 1442 if (operation != DO_NOTHING) {
1406 // Get the path to the quick-enable-cf command for the binaries. 1443 // Get the path to the quick-enable-cf command for the binaries.
(...skipping 18 matching lines...) Expand all
1425 } else { 1462 } else {
1426 DCHECK(operation == REMOVE_COMMAND); 1463 DCHECK(operation == REMOVE_COMMAND);
1427 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), 1464 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(),
1428 cmd_key)->set_log_message( 1465 cmd_key)->set_log_message(
1429 "removing quick-enable-cf command"); 1466 "removing quick-enable-cf command");
1430 } 1467 }
1431 } 1468 }
1432 } 1469 }
1433 1470
1434 } // namespace installer 1471 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698