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

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

Issue 7087030: Upgrade all multi-install products present on the system when the installer is run with only the ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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) 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>
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 output_directory.value(), &unpacked_file); 141 output_directory.value(), &unpacked_file);
142 } 142 }
143 143
144 // In multi-install, adds all products to |installer_state| that are 144 // In multi-install, adds all products to |installer_state| that are
145 // multi-installed and must be updated along with the products already present 145 // multi-installed and must be updated along with the products already present
146 // in |installer_state|. 146 // in |installer_state|.
147 void AddExistingMultiInstalls(const InstallationState& original_state, 147 void AddExistingMultiInstalls(const InstallationState& original_state,
148 InstallerState* installer_state) { 148 InstallerState* installer_state) {
149 if (installer_state->is_multi_install()) { 149 if (installer_state->is_multi_install()) {
150 // TODO(grt): Find all occurrences of such arrays and generalize/centralize. 150 // TODO(grt): Find all occurrences of such arrays and generalize/centralize.
151 BrowserDistribution::Type product_checks[] = { 151 static const BrowserDistribution::Type product_checks[] = {
152 BrowserDistribution::CHROME_BROWSER, 152 BrowserDistribution::CHROME_BROWSER,
153 BrowserDistribution::CHROME_FRAME 153 BrowserDistribution::CHROME_FRAME
154 }; 154 };
155 155
156 for (size_t i = 0; i < arraysize(product_checks); ++i) { 156 for (size_t i = 0; i < arraysize(product_checks); ++i) {
157 BrowserDistribution::Type type = product_checks[i]; 157 BrowserDistribution::Type type = product_checks[i];
158 if (!installer_state->FindProduct(type)) { 158 if (!installer_state->FindProduct(type)) {
159 const ProductState* state = 159 const ProductState* state =
160 original_state.GetProductState(installer_state->system_install(), 160 original_state.GetProductState(installer_state->system_install(),
161 type); 161 type);
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 // specifically, the |installer_state| object. 359 // specifically, the |installer_state| object.
360 // Also blocks simultaneous user-level and system-level installs. In the case 360 // Also blocks simultaneous user-level and system-level installs. In the case
361 // of trying to install user-level Chrome when system-level exists, the 361 // of trying to install user-level Chrome when system-level exists, the
362 // existing system-level Chrome is launched. 362 // existing system-level Chrome is launched.
363 // When the pre-install conditions are not satisfied, the result is written to 363 // When the pre-install conditions are not satisfied, the result is written to
364 // the registry (via WriteInstallerResult), |status| is set appropriately, and 364 // the registry (via WriteInstallerResult), |status| is set appropriately, and
365 // false is returned. 365 // false is returned.
366 bool CheckPreInstallConditions(const InstallationState& original_state, 366 bool CheckPreInstallConditions(const InstallationState& original_state,
367 InstallerState* installer_state, 367 InstallerState* installer_state,
368 installer::InstallStatus* status) { 368 installer::InstallStatus* status) {
369 // See what products are already installed in multi mode. When we do multi
370 // installs, we must upgrade all installations since they share the binaries.
371 AddExistingMultiInstalls(original_state, installer_state);
robertshield 2011/05/31 15:30:19 Nice fix :)
372
369 const Products& products = installer_state->products(); 373 const Products& products = installer_state->products();
370 DCHECK(products.size()); 374 if (products.empty()) {
375 // We haven't been given any products on which to operate.
376 LOG(ERROR)
377 << "Not given any products to install and no products found to update.";
378 *status = installer::CHROME_NOT_INSTALLED;
379 installer_state->WriteInstallerResult(*status,
380 IDS_INSTALL_NO_PRODUCTS_TO_UPDATE_BASE, NULL);
381 return false;
382 }
371 383
372 if (!CheckMultiInstallConditions(original_state, installer_state, status)) 384 if (!CheckMultiInstallConditions(original_state, installer_state, status))
373 return false; 385 return false;
374 386
375 bool is_first_install = true; 387 bool is_first_install = true;
376 const bool system_level = installer_state->system_install(); 388 const bool system_level = installer_state->system_install();
377 389
378 for (size_t i = 0; i < products.size(); ++i) { 390 for (size_t i = 0; i < products.size(); ++i) {
379 const Product* product = products[i]; 391 const Product* product = products[i];
380 BrowserDistribution* browser_dist = product->distribution(); 392 BrowserDistribution* browser_dist = product->distribution();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 441
430 // This is an update, not an install. Omaha should know the difference 442 // This is an update, not an install. Omaha should know the difference
431 // and not show a dialog. 443 // and not show a dialog.
432 *status = installer::SYSTEM_LEVEL_INSTALL_EXISTS; 444 *status = installer::SYSTEM_LEVEL_INSTALL_EXISTS;
433 installer_state->WriteInstallerResult(*status, 445 installer_state->WriteInstallerResult(*status,
434 IDS_INSTALL_SYSTEM_LEVEL_EXISTS_BASE, NULL); 446 IDS_INSTALL_SYSTEM_LEVEL_EXISTS_BASE, NULL);
435 return false; 447 return false;
436 } 448 }
437 } 449 }
438 450
439 // See what products are already installed in multi mode. When we do multi
440 // installs, we must upgrade all installations since they share the binaries.
441 AddExistingMultiInstalls(original_state, installer_state);
442
443 // If no previous installation of Chrome, make sure installation directory 451 // If no previous installation of Chrome, make sure installation directory
444 // either does not exist or can be deleted (i.e. is not locked by some other 452 // either does not exist or can be deleted (i.e. is not locked by some other
445 // process). 453 // process).
446 if (is_first_install) { 454 if (is_first_install) {
447 if (file_util::PathExists(installer_state->target_path()) && 455 if (file_util::PathExists(installer_state->target_path()) &&
448 !file_util::Delete(installer_state->target_path(), true)) { 456 !file_util::Delete(installer_state->target_path(), true)) {
449 LOG(ERROR) << "Installation directory " 457 LOG(ERROR) << "Installation directory "
450 << installer_state->target_path().value() 458 << installer_state->target_path().value()
451 << " exists and can not be deleted."; 459 << " exists and can not be deleted.";
452 *status = installer::INSTALL_DIR_IN_USE; 460 *status = installer::INSTALL_DIR_IN_USE;
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; 679 installer::InstallStatus install_status = installer::UNKNOWN_STATUS;
672 installer::ArchiveType archive_type = installer::UNKNOWN_ARCHIVE_TYPE; 680 installer::ArchiveType archive_type = installer::UNKNOWN_ARCHIVE_TYPE;
673 bool incremental_install = false; 681 bool incremental_install = false;
674 installer_state->UpdateStage(installer::PRECONDITIONS); 682 installer_state->UpdateStage(installer::PRECONDITIONS);
675 // The stage provides more fine-grained information than -multifail, so remove 683 // The stage provides more fine-grained information than -multifail, so remove
676 // the -multifail suffix from the Google Update "ap" value. 684 // the -multifail suffix from the Google Update "ap" value.
677 BrowserDistribution::GetSpecificDistribution(installer_state->state_type()) 685 BrowserDistribution::GetSpecificDistribution(installer_state->state_type())
678 ->UpdateInstallStatus(system_install, archive_type, install_status); 686 ->UpdateInstallStatus(system_install, archive_type, install_status);
679 if (CheckPreInstallConditions(original_state, installer_state, 687 if (CheckPreInstallConditions(original_state, installer_state,
680 &install_status)) { 688 &install_status)) {
689 VLOG(1) << "Installing to " << installer_state->target_path().value();
681 install_status = InstallProductsHelper( 690 install_status = InstallProductsHelper(
682 original_state, cmd_line, prefs, *installer_state, &archive_type); 691 original_state, cmd_line, prefs, *installer_state, &archive_type);
683 } 692 }
684 693
685 const Products& products = installer_state->products(); 694 const Products& products = installer_state->products();
686 695
687 for (size_t i = 0; i < products.size(); ++i) { 696 for (size_t i = 0; i < products.size(); ++i) {
688 const Product* product = products[i]; 697 const Product* product = products[i];
689 product->distribution()->UpdateInstallStatus( 698 product->distribution()->UpdateInstallStatus(
690 system_install, archive_type, install_status); 699 system_install, archive_type, install_status);
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 install_status != installer::UNINSTALL_CANCELLED && 1171 install_status != installer::UNINSTALL_CANCELLED &&
1163 i < products.size(); 1172 i < products.size();
1164 ++i) { 1173 ++i) {
1165 prod_status = UninstallProduct(original_state, installer_state, 1174 prod_status = UninstallProduct(original_state, installer_state,
1166 cmd_line, *products[i]); 1175 cmd_line, *products[i]);
1167 if (prod_status != installer::UNINSTALL_SUCCESSFUL) 1176 if (prod_status != installer::UNINSTALL_SUCCESSFUL)
1168 install_status = prod_status; 1177 install_status = prod_status;
1169 } 1178 }
1170 } else { 1179 } else {
1171 // If --uninstall option is not specified, we assume it is install case. 1180 // If --uninstall option is not specified, we assume it is install case.
1172 VLOG(1) << "Installing to " << installer_state.target_path().value();
1173 install_status = InstallProducts(original_state, cmd_line, prefs, 1181 install_status = InstallProducts(original_state, cmd_line, prefs,
1174 &installer_state); 1182 &installer_state);
1175 } 1183 }
1176 1184
1177 // Validate that the machine is now in a good state following the operation. 1185 // Validate that the machine is now in a good state following the operation.
1178 // TODO(grt): change this to log at DFATAL once we're convinced that the 1186 // TODO(grt): change this to log at DFATAL once we're convinced that the
1179 // validator handles all cases properly. 1187 // validator handles all cases properly.
1180 InstallationValidator::InstallationType installation_type = 1188 InstallationValidator::InstallationType installation_type =
1181 InstallationValidator::NO_PRODUCTS; 1189 InstallationValidator::NO_PRODUCTS;
1182 LOG_IF(ERROR, 1190 LOG_IF(ERROR,
(...skipping 27 matching lines...) Expand all
1210 if (!(installer_state.is_msi() && is_uninstall)) 1218 if (!(installer_state.is_msi() && is_uninstall))
1211 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT 1219 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT
1212 // to pass through, since this is only returned on uninstall which is 1220 // to pass through, since this is only returned on uninstall which is
1213 // never invoked directly by Google Update. 1221 // never invoked directly by Google Update.
1214 return_code = InstallUtil::GetInstallReturnCode(install_status); 1222 return_code = InstallUtil::GetInstallReturnCode(install_status);
1215 1223
1216 VLOG(1) << "Installation complete, returning: " << return_code; 1224 VLOG(1) << "Installation complete, returning: " << return_code;
1217 1225
1218 return return_code; 1226 return return_code;
1219 } 1227 }
OLDNEW
« no previous file with comments | « chrome/app/google_chrome_strings.grd ('k') | chrome/installer/util/prebuild/create_string_rc.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698