Index: chrome/installer/setup/install_worker.cc |
=================================================================== |
--- chrome/installer/setup/install_worker.cc (revision 76463) |
+++ chrome/installer/setup/install_worker.cc (working copy) |
@@ -615,6 +615,9 @@ |
AddGoogleUpdateWorkItems(installer_state, install_list); |
+ AddQuickEnableWorkItems(installer_state, original_state, &setup_path, |
+ &new_version, install_list); |
+ |
// Append the tasks that run after the installation. |
AppendPostInstallTasks(installer_state, |
setup_path, |
@@ -901,4 +904,138 @@ |
} |
} |
+void AddQuickEnableWorkItems(const InstallerState& installer_state, |
+ const InstallationState& machine_state, |
+ const FilePath* setup_path, |
+ const Version* new_version, |
+ WorkItemList* work_item_list) { |
+ DCHECK(setup_path || |
+ installer_state.operation() == InstallerState::UNINSTALL); |
+ DCHECK(new_version || |
+ installer_state.operation() == InstallerState::UNINSTALL); |
+ DCHECK(work_item_list); |
+ |
+ const bool system_install = installer_state.system_install(); |
+ bool have_multi_chrome = false; |
+ bool have_chrome_frame = false; |
+ |
+ // STEP 1: Figure out the state of the machine before the operation. |
+ const ProductState* product_state = NULL; |
+ |
+ // Is multi-install Chrome already on the machine? |
+ product_state = |
+ machine_state.GetProductState(system_install, |
+ BrowserDistribution::CHROME_BROWSER); |
+ if (product_state != NULL && product_state->is_multi_install()) |
+ have_multi_chrome = true; |
+ |
+ // Is Chrome Frame !ready-mode already on the machine? |
+ product_state = |
+ machine_state.GetProductState(system_install, |
+ BrowserDistribution::CHROME_FRAME); |
+ if (product_state != NULL && |
+ !product_state->uninstall_command().HasSwitch( |
+ switches::kChromeFrameReadyMode)) |
+ have_chrome_frame = true; |
+ |
+ // STEP 2: Now take into account the current operation. |
+ const Product* product = NULL; |
+ |
+ if (installer_state.operation() == InstallerState::UNINSTALL) { |
+ // Maybe forget about multi-install Chrome. |
tommi (sloooow) - chröme
2011/03/02 20:30:58
This reads like a question without the question ma
grt (UTC plus 2)
2011/03/02 20:44:47
A better comment would be "Forget about multi-inst
|
+ product = |
+ installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
+ if (product != NULL && installer_state.is_multi_install()) |
+ have_multi_chrome = false; |
+ |
+ // Maybe forget about Chrome Frame. Note that we don't bother to check |
+ // !HasOption(kOptionReadyMode) since have_chrome_frame should have been |
+ // false for that case in the first place. It's odd if it wasn't, but the |
+ // right thing to do in that case is to proceed with the thought that CF |
+ // will not be installed in any sense when we reach the finish line. |
+ if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME) != NULL) |
+ have_chrome_frame = false; |
+ } else { |
+ // Maybe we're installing multi-install Chrome. |
robertshield
2011/03/02 20:58:04
nit: "Maybe" -> "Check if" here and elsewhere in t
grt (UTC plus 2)
2011/03/02 21:06:37
Done.
|
+ product = |
+ installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
+ if (product != NULL && installer_state.is_multi_install()) |
+ have_multi_chrome = true; |
+ |
+ // Maybe we're installing Chrome Frame !ready-mode. |
+ product = installer_state.FindProduct(BrowserDistribution::CHROME_FRAME); |
+ if (product != NULL && !product->HasOption(kOptionReadyMode)) |
+ have_chrome_frame = true; |
+ } |
+ |
+ // STEP 3: Decide what to do based on the final state of things. |
+ enum QuickEnableOperation { |
+ DO_NOTHING, |
+ ADD_COMMAND, |
+ REMOVE_COMMAND |
+ } operation = DO_NOTHING; |
+ FilePath binaries_setup_path; |
+ |
+ if (have_chrome_frame) { |
+ // Chrome Frame !ready-mode is or will be installed. Unconditionally remove |
+ // the quick-enable-cf command from the binaries. We do this even if |
+ // multi-install Chrome isn't installed since we don't want them left |
+ // behind in any case. |
+ operation = REMOVE_COMMAND; |
+ } else if (have_multi_chrome) { |
+ // Chrome Frame isn't (to be) installed, or is (to be) in ready-mode but |
robertshield
2011/03/02 20:58:04
Consider rephrasing to "Chrome Frame isn't (to be)
grt (UTC plus 2)
2011/03/02 21:06:37
Done.
|
+ // multi-install Chrome is. Add the quick-enable-cf command to the |
+ // binaries. |
+ operation = ADD_COMMAND; |
+ // The path to setup.exe contains the version of the Chrome binaries, so it |
+ // takes a little work to get it right. |
+ if (installer_state.operation() == InstallerState::UNINSTALL) { |
+ // Some product (Chrome Frame) is being uninstalled. Use the path to the |
robertshield
2011/03/02 20:58:04
Simplify to "Chrome Frame is being uninstalled."
grt (UTC plus 2)
2011/03/02 21:06:37
Done.
|
+ // currently installed Chrome setup.exe. |
+ product_state = |
+ machine_state.GetProductState(system_install, |
+ BrowserDistribution::CHROME_BROWSER); |
+ DCHECK(product_state); |
+ binaries_setup_path = product_state->uninstall_command().GetProgram(); |
+ } else { |
+ // Some product (Chrome) is being installed, updated, or otherwise being |
robertshield
2011/03/02 20:58:04
Simplify to "Chrome is being [...]
grt (UTC plus 2)
2011/03/02 21:06:37
Done.
|
+ // operated on. Use the path to the given |setup_path| in the normal |
+ // location of multi-install Chrome of the given |version|. |
+ DCHECK(installer_state.is_multi_install()); |
+ binaries_setup_path = |
+ installer_state.GetInstallerDirectory(*new_version).Append( |
+ setup_path->BaseName()); |
+ } |
+ } |
+ |
+ // STEP 4: Take action. |
+ if (operation != DO_NOTHING) { |
+ // Get the path to the quick-enable-cf command for the binaries. |
+ BrowserDistribution* binaries = |
+ BrowserDistribution::GetSpecificDistribution( |
+ BrowserDistribution::CHROME_BINARIES); |
+ std::wstring cmd_key(binaries->GetVersionKey()); |
+ cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey) |
+ .append(1, L'\\').append(kCmdQuickEnableCf); |
+ |
+ if (operation == ADD_COMMAND) { |
+ DCHECK(!binaries_setup_path.empty()); |
+ CommandLine cmd_line(binaries_setup_path); |
+ cmd_line.AppendSwitch(switches::kMultiInstall); |
+ if (installer_state.system_install()) |
+ cmd_line.AppendSwitch(switches::kSystemLevel); |
+ if (installer_state.verbose_logging()) |
+ cmd_line.AppendSwitch(switches::kVerboseLogging); |
+ cmd_line.AppendSwitch(switches::kChromeFrameQuickEnable); |
+ ProductCommand cmd(cmd_line.command_line_string(), true, true); |
+ cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); |
+ } else { |
+ DCHECK(operation == REMOVE_COMMAND); |
+ work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), |
+ cmd_key)->set_log_message( |
+ "removing quick-enable-cf command"); |
+ } |
+ } |
+} |
+ |
} // namespace installer |