OLD | NEW |
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 // 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 <shlobj.h> | 10 #include <shlobj.h> |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 install_list); | 608 install_list); |
609 } | 609 } |
610 | 610 |
611 // Add any remaining work items that involve special settings for | 611 // Add any remaining work items that involve special settings for |
612 // each product. | 612 // each product. |
613 AddProductSpecificWorkItems(original_state, installer_state, setup_path, | 613 AddProductSpecificWorkItems(original_state, installer_state, setup_path, |
614 new_version, install_list); | 614 new_version, install_list); |
615 | 615 |
616 AddGoogleUpdateWorkItems(installer_state, install_list); | 616 AddGoogleUpdateWorkItems(installer_state, install_list); |
617 | 617 |
| 618 AddQuickEnableWorkItems(installer_state, original_state, &setup_path, |
| 619 &new_version, install_list); |
| 620 |
618 // Append the tasks that run after the installation. | 621 // Append the tasks that run after the installation. |
619 AppendPostInstallTasks(installer_state, | 622 AppendPostInstallTasks(installer_state, |
620 setup_path, | 623 setup_path, |
621 new_chrome_exe, | 624 new_chrome_exe, |
622 current_version->get(), | 625 current_version->get(), |
623 new_version, | 626 new_version, |
624 temp_path, | 627 temp_path, |
625 install_list); | 628 install_list); |
626 } | 629 } |
627 | 630 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 } else { | 897 } else { |
895 VLOG(1) << kIERefreshPolicy << " not supported."; | 898 VLOG(1) << kIERefreshPolicy << " not supported."; |
896 } | 899 } |
897 | 900 |
898 FreeLibrary(ieframe); | 901 FreeLibrary(ieframe); |
899 } else { | 902 } else { |
900 VLOG(1) << "Cannot load " << kIEFrameDll; | 903 VLOG(1) << "Cannot load " << kIEFrameDll; |
901 } | 904 } |
902 } | 905 } |
903 | 906 |
| 907 void AddQuickEnableWorkItems(const InstallerState& installer_state, |
| 908 const InstallationState& machine_state, |
| 909 const FilePath* setup_path, |
| 910 const Version* new_version, |
| 911 WorkItemList* work_item_list) { |
| 912 DCHECK(setup_path || |
| 913 installer_state.operation() == InstallerState::UNINSTALL); |
| 914 DCHECK(new_version || |
| 915 installer_state.operation() == InstallerState::UNINSTALL); |
| 916 DCHECK(work_item_list); |
| 917 |
| 918 const bool system_install = installer_state.system_install(); |
| 919 bool have_multi_chrome = false; |
| 920 bool have_chrome_frame = false; |
| 921 |
| 922 // STEP 1: Figure out the state of the machine before the operation. |
| 923 const ProductState* product_state = NULL; |
| 924 |
| 925 // Is multi-install Chrome already on the machine? |
| 926 product_state = |
| 927 machine_state.GetProductState(system_install, |
| 928 BrowserDistribution::CHROME_BROWSER); |
| 929 if (product_state != NULL && product_state->is_multi_install()) |
| 930 have_multi_chrome = true; |
| 931 |
| 932 // Is Chrome Frame !ready-mode already on the machine? |
| 933 product_state = |
| 934 machine_state.GetProductState(system_install, |
| 935 BrowserDistribution::CHROME_FRAME); |
| 936 if (product_state != NULL && |
| 937 !product_state->uninstall_command().HasSwitch( |
| 938 switches::kChromeFrameReadyMode)) |
| 939 have_chrome_frame = true; |
| 940 |
| 941 // STEP 2: Now take into account the current operation. |
| 942 const Product* product = NULL; |
| 943 |
| 944 if (installer_state.operation() == InstallerState::UNINSTALL) { |
| 945 // Forget about multi-install Chrome if it is being uninstalled. |
| 946 product = |
| 947 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 948 if (product != NULL && installer_state.is_multi_install()) |
| 949 have_multi_chrome = false; |
| 950 |
| 951 // Forget about Chrome Frame if it is being uninstalled. Note that we don't |
| 952 // bother to check !HasOption(kOptionReadyMode) since have_chrome_frame |
| 953 // should have been false for that case in the first place. It's odd if it |
| 954 // wasn't, but the right thing to do in that case is to proceed with the |
| 955 // thought that CF will not be installed in any sense when we reach the |
| 956 // finish line. |
| 957 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) != NULL) |
| 958 have_chrome_frame = false; |
| 959 } else { |
| 960 // Check if we're installing multi-install Chrome. |
| 961 product = |
| 962 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
| 963 if (product != NULL && installer_state.is_multi_install()) |
| 964 have_multi_chrome = true; |
| 965 |
| 966 // Check if we're installing Chrome Frame !ready-mode. |
| 967 product = installer_state.FindProduct(BrowserDistribution::CHROME_FRAME); |
| 968 if (product != NULL && !product->HasOption(kOptionReadyMode)) |
| 969 have_chrome_frame = true; |
| 970 } |
| 971 |
| 972 // STEP 3: Decide what to do based on the final state of things. |
| 973 enum QuickEnableOperation { |
| 974 DO_NOTHING, |
| 975 ADD_COMMAND, |
| 976 REMOVE_COMMAND |
| 977 } operation = DO_NOTHING; |
| 978 FilePath binaries_setup_path; |
| 979 |
| 980 if (have_chrome_frame) { |
| 981 // Chrome Frame !ready-mode is or will be installed. Unconditionally remove |
| 982 // the quick-enable-cf command from the binaries. We do this even if |
| 983 // multi-install Chrome isn't installed since we don't want them left |
| 984 // behind in any case. |
| 985 operation = REMOVE_COMMAND; |
| 986 } else if (have_multi_chrome) { |
| 987 // Chrome Frame isn't (to be) installed or is (to be) installed only in |
| 988 // ready-mode, while multi-install Chrome is (to be) installed. Add the |
| 989 // quick-enable-cf command to the binaries. |
| 990 operation = ADD_COMMAND; |
| 991 // The path to setup.exe contains the version of the Chrome binaries, so it |
| 992 // takes a little work to get it right. |
| 993 if (installer_state.operation() == InstallerState::UNINSTALL) { |
| 994 // Chrome Frame is being uninstalled. Use the path to the currently |
| 995 // installed Chrome setup.exe. |
| 996 product_state = |
| 997 machine_state.GetProductState(system_install, |
| 998 BrowserDistribution::CHROME_BROWSER); |
| 999 DCHECK(product_state); |
| 1000 binaries_setup_path = product_state->uninstall_command().GetProgram(); |
| 1001 } else { |
| 1002 // Chrome is being installed, updated, or otherwise being operated on. |
| 1003 // Use the path to the given |setup_path| in the normal location of |
| 1004 // multi-install Chrome of the given |version|. |
| 1005 DCHECK(installer_state.is_multi_install()); |
| 1006 binaries_setup_path = |
| 1007 installer_state.GetInstallerDirectory(*new_version).Append( |
| 1008 setup_path->BaseName()); |
| 1009 } |
| 1010 } |
| 1011 |
| 1012 // STEP 4: Take action. |
| 1013 if (operation != DO_NOTHING) { |
| 1014 // Get the path to the quick-enable-cf command for the binaries. |
| 1015 BrowserDistribution* binaries = |
| 1016 BrowserDistribution::GetSpecificDistribution( |
| 1017 BrowserDistribution::CHROME_BINARIES); |
| 1018 std::wstring cmd_key(binaries->GetVersionKey()); |
| 1019 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey) |
| 1020 .append(1, L'\\').append(kCmdQuickEnableCf); |
| 1021 |
| 1022 if (operation == ADD_COMMAND) { |
| 1023 DCHECK(!binaries_setup_path.empty()); |
| 1024 CommandLine cmd_line(binaries_setup_path); |
| 1025 cmd_line.AppendSwitch(switches::kMultiInstall); |
| 1026 if (installer_state.system_install()) |
| 1027 cmd_line.AppendSwitch(switches::kSystemLevel); |
| 1028 if (installer_state.verbose_logging()) |
| 1029 cmd_line.AppendSwitch(switches::kVerboseLogging); |
| 1030 cmd_line.AppendSwitch(switches::kChromeFrameQuickEnable); |
| 1031 AppCommand cmd(cmd_line.command_line_string(), true, true); |
| 1032 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); |
| 1033 } else { |
| 1034 DCHECK(operation == REMOVE_COMMAND); |
| 1035 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), |
| 1036 cmd_key)->set_log_message( |
| 1037 "removing quick-enable-cf command"); |
| 1038 } |
| 1039 } |
| 1040 } |
| 1041 |
904 } // namespace installer | 1042 } // namespace installer |
OLD | NEW |