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 "chrome/installer/setup/setup_main.h" | 5 #include "chrome/installer/setup/setup_main.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <msi.h> | 8 #include <msi.h> |
9 #include <shellapi.h> | 9 #include <shellapi.h> |
10 #include <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 bool CheckPreInstallConditions(const InstallationState& original_state, | 483 bool CheckPreInstallConditions(const InstallationState& original_state, |
484 const InstallerState& installer_state, | 484 const InstallerState& installer_state, |
485 installer::InstallStatus* status) { | 485 installer::InstallStatus* status) { |
486 if (!installer_state.system_install()) { | 486 if (!installer_state.system_install()) { |
487 // This is a user-level installation. Make sure that we are not installing | 487 // This is a user-level installation. Make sure that we are not installing |
488 // on top of an existing system-level installation. | 488 // on top of an existing system-level installation. |
489 const Product& product = installer_state.product(); | 489 const Product& product = installer_state.product(); |
490 BrowserDistribution* browser_dist = product.distribution(); | 490 BrowserDistribution* browser_dist = product.distribution(); |
491 | 491 |
492 const ProductState* user_level_product_state = | 492 const ProductState* user_level_product_state = |
493 original_state.GetProductState(false, browser_dist->GetType()); | 493 original_state.GetProductState(false); |
494 const ProductState* system_level_product_state = | 494 const ProductState* system_level_product_state = |
495 original_state.GetProductState(true, browser_dist->GetType()); | 495 original_state.GetProductState(true); |
496 | 496 |
497 // Allow upgrades to proceed so that out-of-date versions are not left | 497 // Allow upgrades to proceed so that out-of-date versions are not left |
498 // around. | 498 // around. |
499 if (user_level_product_state) | 499 if (user_level_product_state) |
500 return true; | 500 return true; |
501 | 501 |
502 // This is a new user-level install... | 502 // This is a new user-level install... |
503 | 503 |
504 if (system_level_product_state) { | 504 if (system_level_product_state) { |
505 // ... and the product already exists at system-level. | 505 // ... and the product already exists at system-level. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 | 561 |
562 installer::InstallStatus UninstallProduct( | 562 installer::InstallStatus UninstallProduct( |
563 const InstallationState& original_state, | 563 const InstallationState& original_state, |
564 const InstallerState& installer_state, | 564 const InstallerState& installer_state, |
565 const base::FilePath& setup_exe, | 565 const base::FilePath& setup_exe, |
566 const base::CommandLine& cmd_line, | 566 const base::CommandLine& cmd_line, |
567 bool remove_all, | 567 bool remove_all, |
568 bool force_uninstall, | 568 bool force_uninstall, |
569 const Product& product) { | 569 const Product& product) { |
570 const ProductState* product_state = | 570 const ProductState* product_state = |
571 original_state.GetProductState(installer_state.system_install(), | 571 original_state.GetProductState(installer_state.system_install()); |
572 product.distribution()->GetType()); | |
573 if (product_state != NULL) { | 572 if (product_state != NULL) { |
574 VLOG(1) << "version on the system: " | 573 VLOG(1) << "version on the system: " |
575 << product_state->version().GetString(); | 574 << product_state->version().GetString(); |
576 } else if (!force_uninstall) { | 575 } else if (!force_uninstall) { |
577 LOG(ERROR) << product.distribution()->GetDisplayName() | 576 LOG(ERROR) << product.distribution()->GetDisplayName() |
578 << " not found for uninstall."; | 577 << " not found for uninstall."; |
579 return installer::CHROME_NOT_INSTALLED; | 578 return installer::CHROME_NOT_INSTALLED; |
580 } | 579 } |
581 | 580 |
582 return installer::UninstallProduct( | 581 return installer::UninstallProduct( |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 | 727 |
729 installer::InstallStatus RegisterDevChrome( | 728 installer::InstallStatus RegisterDevChrome( |
730 const InstallationState& original_state, | 729 const InstallationState& original_state, |
731 const InstallerState& installer_state, | 730 const InstallerState& installer_state, |
732 const base::FilePath& setup_exe, | 731 const base::FilePath& setup_exe, |
733 const base::CommandLine& cmd_line) { | 732 const base::CommandLine& cmd_line) { |
734 BrowserDistribution* chrome_dist = BrowserDistribution::GetDistribution(); | 733 BrowserDistribution* chrome_dist = BrowserDistribution::GetDistribution(); |
735 | 734 |
736 // Only proceed with registering a dev chrome if no real Chrome installation | 735 // Only proceed with registering a dev chrome if no real Chrome installation |
737 // of the same distribution are present on this system. | 736 // of the same distribution are present on this system. |
738 const ProductState* existing_chrome = | 737 const ProductState* existing_chrome = original_state.GetProductState(false); |
739 original_state.GetProductState(false, | 738 if (!existing_chrome) |
740 BrowserDistribution::CHROME_BROWSER); | 739 existing_chrome = original_state.GetProductState(true); |
741 if (!existing_chrome) { | |
742 existing_chrome = | |
743 original_state.GetProductState(true, BrowserDistribution::CHROME_BROWSER); | |
744 } | |
745 if (existing_chrome) { | 740 if (existing_chrome) { |
746 static const wchar_t kPleaseUninstallYourChromeMessage[] = | 741 static const wchar_t kPleaseUninstallYourChromeMessage[] = |
747 L"You already have a full-installation (non-dev) of %1ls, please " | 742 L"You already have a full-installation (non-dev) of %1ls, please " |
748 L"uninstall it first using Add/Remove Programs in the control panel."; | 743 L"uninstall it first using Add/Remove Programs in the control panel."; |
749 base::string16 name(chrome_dist->GetDisplayName()); | 744 base::string16 name(chrome_dist->GetDisplayName()); |
750 base::string16 message( | 745 base::string16 message( |
751 base::StringPrintf(kPleaseUninstallYourChromeMessage, name.c_str())); | 746 base::StringPrintf(kPleaseUninstallYourChromeMessage, name.c_str())); |
752 | 747 |
753 LOG(ERROR) << "Aborting operation: another installation of " << name | 748 LOG(ERROR) << "Aborting operation: another installation of " << name |
754 << " was found, as a last resort (if the product is not present " | 749 << " was found, as a last resort (if the product is not present " |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1167 LOG(ERROR) << "Did not find any valid version in installer."; | 1162 LOG(ERROR) << "Did not find any valid version in installer."; |
1168 install_status = INVALID_ARCHIVE; | 1163 install_status = INVALID_ARCHIVE; |
1169 installer_state.WriteInstallerResult(install_status, | 1164 installer_state.WriteInstallerResult(install_status, |
1170 IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); | 1165 IDS_INSTALL_INVALID_ARCHIVE_BASE, NULL); |
1171 } else { | 1166 } else { |
1172 VLOG(1) << "version to install: " << installer_version->GetString(); | 1167 VLOG(1) << "version to install: " << installer_version->GetString(); |
1173 bool proceed_with_installation = true; | 1168 bool proceed_with_installation = true; |
1174 | 1169 |
1175 if (!IsDowngradeAllowed(prefs)) { | 1170 if (!IsDowngradeAllowed(prefs)) { |
1176 const Product& product = installer_state.product(); | 1171 const Product& product = installer_state.product(); |
1177 const ProductState* product_state = original_state.GetProductState( | 1172 const ProductState* product_state = |
1178 system_install, product.distribution()->GetType()); | 1173 original_state.GetProductState(system_install); |
1179 if (product_state != NULL && | 1174 if (product_state != NULL && |
1180 (product_state->version().CompareTo(*installer_version) > 0)) { | 1175 (product_state->version().CompareTo(*installer_version) > 0)) { |
1181 LOG(ERROR) << "Higher version of " | 1176 LOG(ERROR) << "Higher version of " |
1182 << product.distribution()->GetDisplayName() | 1177 << product.distribution()->GetDisplayName() |
1183 << " is already installed."; | 1178 << " is already installed."; |
1184 int message_id = IDS_INSTALL_HIGHER_VERSION_BASE; | 1179 int message_id = IDS_INSTALL_HIGHER_VERSION_BASE; |
1185 proceed_with_installation = false; | 1180 proceed_with_installation = false; |
1186 install_status = HIGHER_VERSION_EXISTS; | 1181 install_status = HIGHER_VERSION_EXISTS; |
1187 installer_state.WriteInstallerResult(install_status, message_id, NULL); | 1182 installer_state.WriteInstallerResult(install_status, message_id, NULL); |
1188 } | 1183 } |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1496 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT | 1491 // Note that we allow the status installer::UNINSTALL_REQUIRES_REBOOT |
1497 // to pass through, since this is only returned on uninstall which is | 1492 // to pass through, since this is only returned on uninstall which is |
1498 // never invoked directly by Google Update. | 1493 // never invoked directly by Google Update. |
1499 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1494 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1500 } | 1495 } |
1501 | 1496 |
1502 VLOG(1) << "Installation complete, returning: " << return_code; | 1497 VLOG(1) << "Installation complete, returning: " << return_code; |
1503 | 1498 |
1504 return return_code; | 1499 return return_code; |
1505 } | 1500 } |
OLD | NEW |