OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 return false; | 729 return false; |
730 } | 730 } |
731 initialized_ = true; | 731 initialized_ = true; |
732 return true; | 732 return true; |
733 } | 733 } |
734 | 734 |
735 private: | 735 private: |
736 bool initialized_; | 736 bool initialized_; |
737 }; | 737 }; |
738 | 738 |
739 bool PopulateInstallations(const MasterPreferences& prefs, | 739 bool PopulateInstallations(bool for_uninstall, |
| 740 const MasterPreferences& prefs, |
740 ProductPackageMapping* installations) { | 741 ProductPackageMapping* installations) { |
741 DCHECK(installations); | 742 DCHECK(installations); |
742 bool success = true; | 743 bool success = true; |
743 | 744 |
744 bool implicit_chrome_install = false; | 745 bool implicit_chrome_install = false; |
745 bool implicit_gcf_install = false; | 746 bool implicit_gcf_install = false; |
746 | 747 |
747 if (prefs.is_multi_install()) { | 748 // See what products are already installed in multi mode. |
748 // See what products are already installed in multi mode. | 749 // When we do multi installs, we must upgrade all installations in sync since |
749 // When we do multi installs, we must upgrade all installations | 750 // they share the binaries. Be careful to not do this when we're uninstalling |
750 // in sync since they share the binaries. | 751 // a product. |
| 752 if (prefs.is_multi_install() && !for_uninstall) { |
751 struct CheckInstall { | 753 struct CheckInstall { |
752 bool* installed; | 754 bool* installed; |
753 BrowserDistribution::Type type; | 755 BrowserDistribution::Type type; |
754 } product_checks[] = { | 756 } product_checks[] = { |
755 {&implicit_chrome_install, BrowserDistribution::CHROME_BROWSER}, | 757 {&implicit_chrome_install, BrowserDistribution::CHROME_BROWSER}, |
756 {&implicit_gcf_install, BrowserDistribution::CHROME_FRAME}, | 758 {&implicit_gcf_install, BrowserDistribution::CHROME_FRAME}, |
757 }; | 759 }; |
758 | 760 |
759 for (size_t i = 0; i < arraysize(product_checks); ++i) { | 761 for (size_t i = 0; i < arraysize(product_checks); ++i) { |
760 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( | 762 BrowserDistribution* dist = BrowserDistribution::GetSpecificDistribution( |
761 product_checks[i].type, prefs); | 763 product_checks[i].type, prefs); |
762 *product_checks[i].installed = installer::IsInstalledAsMulti( | 764 *product_checks[i].installed = installer::IsInstalledAsMulti( |
763 installations->system_level(), dist); | 765 installations->system_level(), dist); |
764 LOG_IF(INFO, *product_checks[i].installed) | 766 LOG_IF(INFO, *product_checks[i].installed) |
765 << "Product already installed and must be included: " | 767 << "Product already installed and must be included: " |
766 << dist->GetApplicationName(); | 768 << dist->GetApplicationName(); |
767 } | 769 } |
768 } | 770 } |
769 | 771 |
770 if (prefs.install_chrome() || implicit_chrome_install) { | 772 if (prefs.install_chrome() || implicit_chrome_install) { |
771 VLOG(1) << "Install distribution: Chrome"; | 773 VLOG(1) << (for_uninstall ? "Uninstall" : "Install") |
| 774 << " distribution: Chrome"; |
772 success = installations->AddDistribution( | 775 success = installations->AddDistribution( |
773 BrowserDistribution::CHROME_BROWSER, prefs); | 776 BrowserDistribution::CHROME_BROWSER, prefs); |
774 } | 777 } |
775 | 778 |
776 if (success && (prefs.install_chrome_frame() || implicit_gcf_install)) { | 779 if (success && (prefs.install_chrome_frame() || implicit_gcf_install)) { |
777 VLOG(1) << "Install distribution: Chrome Frame"; | 780 VLOG(1) << (for_uninstall ? "Uninstall" : "Install") |
| 781 << " distribution: Chrome Frame"; |
778 success = installations->AddDistribution( | 782 success = installations->AddDistribution( |
779 BrowserDistribution::CHROME_FRAME, prefs); | 783 BrowserDistribution::CHROME_FRAME, prefs); |
780 } | 784 } |
781 return success; | 785 return success; |
782 } | 786 } |
783 | 787 |
784 // Returns the Custom information for the client identified by the exe path | 788 // Returns the Custom information for the client identified by the exe path |
785 // passed in. This information is used for crash reporting. | 789 // passed in. This information is used for crash reporting. |
786 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { | 790 google_breakpad::CustomClientInfo* GetCustomInfo(const wchar_t* exe_path) { |
787 std::wstring product; | 791 std::wstring product; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
869 VLOG(1) << "system install is " << system_install; | 873 VLOG(1) << "system install is " << system_install; |
870 | 874 |
871 google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( | 875 google_breakpad::scoped_ptr<google_breakpad::ExceptionHandler> breakpad( |
872 InitializeCrashReporting(system_install)); | 876 InitializeCrashReporting(system_install)); |
873 | 877 |
874 InstallationState original_state; | 878 InstallationState original_state; |
875 original_state.Initialize(prefs); | 879 original_state.Initialize(prefs); |
876 | 880 |
877 InstallerState installer_state; | 881 InstallerState installer_state; |
878 installer_state.Initialize(prefs, original_state); | 882 installer_state.Initialize(prefs, original_state); |
| 883 const bool is_uninstall = cmd_line.HasSwitch(installer::switches::kUninstall); |
879 | 884 |
880 ProductPackageMapping installations(prefs.is_multi_install(), system_install); | 885 ProductPackageMapping installations(prefs.is_multi_install(), system_install); |
881 if (!PopulateInstallations(prefs, &installations)) { | 886 if (!PopulateInstallations(is_uninstall, prefs, &installations)) { |
882 // Currently this can only fail if one of the installations is a multi and | 887 // Currently this can only fail if one of the installations is a multi and |
883 // a pre-existing single installation exists or vice versa. | 888 // a pre-existing single installation exists or vice versa. |
884 installer::InstallStatus status = installer::NON_MULTI_INSTALLATION_EXISTS; | 889 installer::InstallStatus status = installer::NON_MULTI_INSTALLATION_EXISTS; |
885 int string_id = IDS_INSTALL_NON_MULTI_INSTALLATION_EXISTS_BASE; | 890 int string_id = IDS_INSTALL_NON_MULTI_INSTALLATION_EXISTS_BASE; |
886 if (!prefs.is_multi_install()) { | 891 if (!prefs.is_multi_install()) { |
887 status = installer::MULTI_INSTALLATION_EXISTS; | 892 status = installer::MULTI_INSTALLATION_EXISTS; |
888 string_id = IDS_INSTALL_MULTI_INSTALLATION_EXISTS_BASE; | 893 string_id = IDS_INSTALL_MULTI_INSTALLATION_EXISTS_BASE; |
889 } | 894 } |
890 LOG(ERROR) << "Failed to populate installations: " << status; | 895 LOG(ERROR) << "Failed to populate installations: " << status; |
891 InstallUtil::WriteInstallerResult(system_install, | 896 InstallUtil::WriteInstallerResult(system_install, |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 return exit_code; | 950 return exit_code; |
946 } else { | 951 } else { |
947 LOG(ERROR) << "Non admin user can not install system level Chrome."; | 952 LOG(ERROR) << "Non admin user can not install system level Chrome."; |
948 InstallUtil::WriteInstallerResult(system_install, | 953 InstallUtil::WriteInstallerResult(system_install, |
949 installer_state.state_key(), installer::INSUFFICIENT_RIGHTS, | 954 installer_state.state_key(), installer::INSUFFICIENT_RIGHTS, |
950 IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE, NULL); | 955 IDS_INSTALL_INSUFFICIENT_RIGHTS_BASE, NULL); |
951 return installer::INSUFFICIENT_RIGHTS; | 956 return installer::INSUFFICIENT_RIGHTS; |
952 } | 957 } |
953 } | 958 } |
954 | 959 |
955 bool is_uninstall = cmd_line.HasSwitch(installer::switches::kUninstall); | |
956 | |
957 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; | 960 installer::InstallStatus install_status = installer::UNKNOWN_STATUS; |
958 // If --uninstall option is given, uninstall chrome | 961 // If --uninstall option is given, uninstall chrome |
959 if (is_uninstall) { | 962 if (is_uninstall) { |
960 for (size_t i = 0; i < installations.products().size(); ++i) { | 963 for (size_t i = 0; i < installations.products().size(); ++i) { |
961 install_status = UninstallProduct(original_state, installer_state, | 964 install_status = UninstallProduct(original_state, installer_state, |
962 cmd_line, *installations.products()[i]); | 965 cmd_line, *installations.products()[i]); |
963 } | 966 } |
964 } else { | 967 } else { |
965 // If --uninstall option is not specified, we assume it is install case. | 968 // If --uninstall option is not specified, we assume it is install case. |
966 const Packages& packages = installations.packages(); | 969 const Packages& packages = installations.packages(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 // to pass through, since this is only returned on uninstall which is | 1007 // to pass through, since this is only returned on uninstall which is |
1005 // never invoked directly by Google Update. | 1008 // never invoked directly by Google Update. |
1006 return_code = InstallUtil::GetInstallReturnCode(install_status); | 1009 return_code = InstallUtil::GetInstallReturnCode(install_status); |
1007 } | 1010 } |
1008 } | 1011 } |
1009 | 1012 |
1010 VLOG(1) << "Installation complete, returning: " << return_code; | 1013 VLOG(1) << "Installation complete, returning: " << return_code; |
1011 | 1014 |
1012 return return_code; | 1015 return return_code; |
1013 } | 1016 } |
OLD | NEW |