Chromium Code Reviews| 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 #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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 IDS_INSTALL_MULTI_INSTALLATION_EXISTS_BASE, NULL); | 477 IDS_INSTALL_MULTI_INSTALLATION_EXISTS_BASE, NULL); |
| 478 return false; | 478 return false; |
| 479 } | 479 } |
| 480 } | 480 } |
| 481 } | 481 } |
| 482 | 482 |
| 483 return true; | 483 return true; |
| 484 } | 484 } |
| 485 | 485 |
| 486 // Checks app host pre-install conditions, specifically that this is a | 486 // Checks app host pre-install conditions, specifically that this is a |
| 487 // user-level multi-install. When the pre-install conditions are not | 487 // multi-install. When the pre-install conditions are not satisfied, the result |
| 488 // satisfied, the result is written to the registry (via WriteInstallerResult), | 488 // is written to the registry (via WriteInstallerResult), |status| is set |
| 489 // |status| is set appropriately, and false is returned. | 489 // appropriately, and false is returned. |
| 490 bool CheckAppHostPreconditions(const InstallationState& original_state, | 490 bool CheckAppLauncherPreconditions(const InstallationState& original_state, |
| 491 InstallerState* installer_state, | 491 InstallerState* installer_state, |
| 492 installer::InstallStatus* status) { | 492 installer::InstallStatus* status) { |
| 493 if (installer_state->FindProduct(BrowserDistribution::CHROME_APP_HOST)) { | 493 if (installer_state->FindProduct(BrowserDistribution::CHROME_APP_HOST)) { |
| 494 | |
| 495 if (!installer_state->is_multi_install()) { | 494 if (!installer_state->is_multi_install()) { |
|
gab
2013/05/15 22:42:20
&& instead of 2 ifs
huangs
2013/05/17 20:59:24
Done.
| |
| 496 LOG(DFATAL) << "App Launcher requires multi install"; | 495 LOG(DFATAL) << "App Launcher requires multi install"; |
| 497 *status = installer::APP_HOST_REQUIRES_MULTI_INSTALL; | 496 *status = installer::APP_HOST_REQUIRES_MULTI_INSTALL; |
| 498 // No message string since there is nothing a user can do. | 497 // No message string since there is nothing a user can do. |
| 499 installer_state->WriteInstallerResult(*status, 0, NULL); | 498 installer_state->WriteInstallerResult(*status, 0, NULL); |
| 500 return false; | 499 return false; |
| 501 } | 500 } |
| 502 | |
| 503 if (installer_state->system_install()) { | |
| 504 LOG(DFATAL) << "App Launcher may only be installed at user-level."; | |
| 505 *status = installer::APP_HOST_REQUIRES_USER_LEVEL; | |
| 506 // No message string since there is nothing a user can do. | |
| 507 installer_state->WriteInstallerResult(*status, 0, NULL); | |
| 508 return false; | |
| 509 } | |
| 510 | |
| 511 } | 501 } |
| 512 | 502 |
| 513 return true; | 503 return true; |
| 514 } | 504 } |
| 515 | 505 |
| 516 // Checks for compatibility between the current state of the system and the | 506 // Checks for compatibility between the current state of the system and the |
| 517 // desired operation. Also applies policy that mutates the desired operation; | 507 // desired operation. Also applies policy that mutates the desired operation; |
| 518 // specifically, the |installer_state| object. | 508 // specifically, the |installer_state| object. |
| 519 // Also blocks simultaneous user-level and system-level installs. In the case | 509 // Also blocks simultaneous user-level and system-level installs. In the case |
| 520 // of trying to install user-level Chrome when system-level exists, the | 510 // of trying to install user-level Chrome when system-level exists, the |
| 521 // existing system-level Chrome is launched. | 511 // existing system-level Chrome is launched. |
| 522 // When the pre-install conditions are not satisfied, the result is written to | 512 // When the pre-install conditions are not satisfied, the result is written to |
| 523 // the registry (via WriteInstallerResult), |status| is set appropriately, and | 513 // the registry (via WriteInstallerResult), |status| is set appropriately, and |
| 524 // false is returned. | 514 // false is returned. |
| 525 bool CheckPreInstallConditions(const InstallationState& original_state, | 515 bool CheckPreInstallConditions(const InstallationState& original_state, |
| 526 InstallerState* installer_state, | 516 InstallerState* installer_state, |
| 527 installer::InstallStatus* status) { | 517 installer::InstallStatus* status) { |
| 528 if (!CheckAppHostPreconditions(original_state, installer_state, status)) { | 518 if (!CheckAppLauncherPreconditions(original_state, installer_state, status)) { |
| 529 DCHECK_NE(*status, installer::UNKNOWN_STATUS); | 519 DCHECK_NE(*status, installer::UNKNOWN_STATUS); |
| 530 return false; | 520 return false; |
| 531 } | 521 } |
| 532 | 522 |
| 533 // See what products are already installed in multi mode. When we do multi | 523 // See what products are already installed in multi mode. When we do multi |
| 534 // installs, we must upgrade all installations since they share the binaries. | 524 // installs, we must upgrade all installations since they share the binaries. |
| 535 AddExistingMultiInstalls(original_state, installer_state); | 525 AddExistingMultiInstalls(original_state, installer_state); |
| 536 | 526 |
| 537 if (!CheckMultiInstallConditions(original_state, installer_state, status)) { | 527 if (!CheckMultiInstallConditions(original_state, installer_state, status)) { |
| 538 DCHECK_NE(*status, installer::UNKNOWN_STATUS); | 528 DCHECK_NE(*status, installer::UNKNOWN_STATUS); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 566 const ProductState* user_level_product_state = | 556 const ProductState* user_level_product_state = |
| 567 original_state.GetProductState(false, browser_dist->GetType()); | 557 original_state.GetProductState(false, browser_dist->GetType()); |
| 568 const ProductState* system_level_product_state = | 558 const ProductState* system_level_product_state = |
| 569 original_state.GetProductState(true, browser_dist->GetType()); | 559 original_state.GetProductState(true, browser_dist->GetType()); |
| 570 | 560 |
| 571 // Allow upgrades to proceed so that out-of-date versions are not left | 561 // Allow upgrades to proceed so that out-of-date versions are not left |
| 572 // around. | 562 // around. |
| 573 if (user_level_product_state) | 563 if (user_level_product_state) |
| 574 continue; | 564 continue; |
| 575 | 565 |
| 566 if (system_level_product_state && | |
| 567 installer_state->need_to_migrate_legacy_app_launcher()) { | |
| 568 // This is called if we we have (old) user app_host.exe coexisting with | |
| 569 // (new) system-level Chrome, and then the app_host.exe is executed. | |
| 570 // app_host.exe detects system-level Chrome, and calls new setup.exe | |
| 571 // with --app-launcher (and arrive to this point). We now call the old | |
| 572 // setup.exe to uninstall the old stuff. | |
| 573 CommandLine uninstall_cmd(InstallUtil::GetChromeUninstallCmd( | |
| 574 false, BrowserDistribution::CHROME_APP_HOST)); | |
| 575 if (!uninstall_cmd.GetProgram().empty()) { | |
| 576 uninstall_cmd.AppendSwitch(installer::switches::kSelfDestruct); | |
| 577 uninstall_cmd.AppendSwitch(installer::switches::kForceUninstall); | |
| 578 uninstall_cmd.AppendSwitch( | |
| 579 installer::switches::kDoNotRemoveSharedItems); | |
| 580 base::LaunchProcess(uninstall_cmd, base::LaunchOptions(), NULL); | |
| 581 } | |
| 582 *status = installer::APP_HOST_SELF_DESTRUCT; | |
| 583 return false; | |
| 584 } | |
| 585 | |
| 576 // This is a new user-level install... | 586 // This is a new user-level install... |
| 577 | 587 |
| 578 if (system_level_product_state) { | 588 if (system_level_product_state) { |
| 579 // ... and the product already exists at system-level. | 589 // ... and the product already exists at system-level. |
| 580 LOG(ERROR) << "Already installed version " | 590 LOG(ERROR) << "Already installed version " |
| 581 << system_level_product_state->version().GetString() | 591 << system_level_product_state->version().GetString() |
| 582 << " at system-level conflicts with this one at user-level."; | 592 << " at system-level conflicts with this one at user-level."; |
| 593 | |
|
gab
2013/05/15 22:42:20
nit: remove new empty lines :)
huangs
2013/05/17 20:59:24
Done.
| |
| 594 | |
| 583 if (product.is_chrome()) { | 595 if (product.is_chrome()) { |
| 584 // Instruct Google Update to launch the existing system-level Chrome. | 596 // Instruct Google Update to launch the existing system-level Chrome. |
| 585 // There should be no error dialog. | 597 // There should be no error dialog. |
| 586 base::FilePath install_path(installer::GetChromeInstallPath( | 598 base::FilePath install_path(installer::GetChromeInstallPath( |
| 587 true, // system | 599 true, // system |
| 588 browser_dist)); | 600 browser_dist)); |
| 589 if (install_path.empty()) { | 601 if (install_path.empty()) { |
| 590 // Give up if we failed to construct the install path. | 602 // Give up if we failed to construct the install path. |
| 591 *status = installer::OS_ERROR; | 603 *status = installer::OS_ERROR; |
| 592 installer_state->WriteInstallerResult(*status, | 604 installer_state->WriteInstallerResult(*status, |
| (...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1727 if (!(installer_state.is_msi() && is_uninstall)) | 1739 if (!(installer_state.is_msi() && is_uninstall)) |
| 1728 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1740 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
| 1729 // to pass through, since this is only returned on uninstall which is | 1741 // to pass through, since this is only returned on uninstall which is |
| 1730 // never invoked directly by Google Update. | 1742 // never invoked directly by Google Update. |
| 1731 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1743 return_code = InstallUtil::GetInstallReturnCode(install_status); |
| 1732 | 1744 |
| 1733 VLOG(1) << "Installation complete, returning: " << return_code; | 1745 VLOG(1) << "Installation complete, returning: " << return_code; |
| 1734 | 1746 |
| 1735 return return_code; | 1747 return return_code; |
| 1736 } | 1748 } |
| OLD | NEW |