Chromium Code Reviews| Index: chrome/installer/setup/install_worker.cc |
| =================================================================== |
| --- chrome/installer/setup/install_worker.cc (revision 76372) |
| +++ 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,110 @@ |
| } |
| } |
| +void AddQuickEnableWorkItems(const InstallerState& installer_state, |
|
grt (UTC plus 2)
2011/03/02 19:48:28
This function made me so sad that I rewrote it. T
tommi (sloooow) - chröme
2011/03/02 20:30:58
thanks. more easily digestible :)
grt (UTC plus 2)
2011/03/02 20:44:47
<burp>
|
| + const InstallationState& machine_state, |
| + const FilePath* setup_path, |
| + const Version* new_version, |
| + WorkItemList* work_item_list) { |
| + DCHECK(work_item_list); |
| + |
| + enum QuickEnableOperation { |
| + DO_NOTHING, |
| + ADD_COMMAND, |
| + REMOVE_COMMAND |
| + } operation = DO_NOTHING; |
| + const Version* binaries_version = NULL; |
| + FilePath binaries_setup_path; |
| + |
| + if (installer_state.operation() == InstallerState::UNINSTALL) { |
| + // Add the quick-enable command if Chrome Frame single, multi, or ready-mode |
| + // is being uninstalled, Chrome multi is installed, and Chrome multi is not |
| + // being uninstalled. |
| + const ProductState* chrome = |
| + machine_state.GetProductState(installer_state.system_install(), |
| + BrowserDistribution::CHROME_BROWSER); |
| + if (installer_state.FindProduct( |
| + BrowserDistribution::CHROME_FRAME) != NULL && |
| + chrome != NULL && chrome->is_multi_install() && |
| + installer_state.FindProduct( |
| + BrowserDistribution::CHROME_BROWSER) == NULL) { |
| + operation = ADD_COMMAND; |
| + // Chrome multi's uninstall command has the proper path to setup.exe. |
| + binaries_setup_path = chrome->uninstall_command().GetProgram(); |
| + } |
| + } else { |
|
robertshield
2011/03/02 14:58:57
Can we move the DCHECKS on setup_path and new_vers
grt (UTC plus 2)
2011/03/02 19:48:28
Done.
|
| + // Delete the quick-enable command if Chrome Frame single or Chrome Frame |
| + // multi (not ready-mode) is being installed. Note that the command can |
| + // only be present if the binaries are already installed, but we try to |
| + // remove it in any case just to be sure. |
| + const Product* cf = |
| + installer_state.FindProduct(BrowserDistribution::CHROME_FRAME); |
| + const Product* chrome = |
| + installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
| + if (cf != NULL && (!installer_state.is_multi_install() || |
| + !cf->HasOption(installer::kOptionReadyMode))) { |
| + operation = REMOVE_COMMAND; |
| + } else if (cf != NULL) { |
| + // Add the quick-enable command if Chrome Frame ready-mode is being |
| + // installed. |
| + DCHECK(cf->HasOption(installer::kOptionReadyMode)); |
|
tommi (sloooow) - chröme
2011/03/01 23:33:13
couldn't we also get here for a 'single' install (
grt (UTC plus 2)
2011/03/02 19:48:28
I don't think so (at least, that wasn't my plan).
|
| + DCHECK(setup_path); |
| + DCHECK(new_version); |
| + operation = ADD_COMMAND; |
| + // This new version's setup.exe is the one we need. |
| + binaries_version = new_version; |
| + } else if (installer_state.is_multi_install() && |
| + machine_state.GetProductState( |
| + installer_state.system_install(), |
| + BrowserDistribution::CHROME_FRAME) == NULL) { |
|
tommi (sloooow) - chröme
2011/03/01 23:33:13
What if there exists a system install of gcf and t
grt (UTC plus 2)
2011/03/02 19:48:28
Robert, Erik, and I just discussed this and reache
|
| + // Add the quick-enable command if Chrome Frame is not being installed, |
| + // we're doing a multi-install of Chrome, and single Chrome Frame is not |
| + // already installed. |
| + DCHECK(installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER)); |
| + DCHECK(new_version); |
| + operation = ADD_COMMAND; |
| + // This new version's setup.exe is the one we need. |
| + binaries_version = new_version; |
| + } else { |
| + // Else we're doing a single install of Chrome, so do nothing. |
| + DCHECK(!installer_state.is_multi_install() && chrome != NULL); |
| + } |
| + |
| + // Get the proper path to setup.exe if needed. |
| + if (operation == ADD_COMMAND) { |
| + DCHECK(binaries_version); |
| + DCHECK(!setup_path->empty()); |
| + binaries_setup_path = |
| + installer_state.GetInstallerDirectory(*binaries_version).Append( |
| + setup_path->BaseName()); |
| + } |
| + } |
| + |
| + if (operation != DO_NOTHING) { |
| + BrowserDistribution* binaries = |
| + BrowserDistribution::GetSpecificDistribution( |
| + BrowserDistribution::CHROME_BINARIES); |
| + std::wstring cmd_key(binaries->GetVersionKey()); |
| + cmd_key.append(1, L'\\').append(kCmdQuickEnableCf); |
|
erikwright (departed)
2011/03/02 15:18:16
add \\Commands here, after the version key.
grt (UTC plus 2)
2011/03/02 19:48:28
Done.
|
| + |
| + 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 |