Index: chrome/installer/setup/install_worker.cc |
diff --git a/chrome/installer/setup/install_worker.cc b/chrome/installer/setup/install_worker.cc |
index 64af4dad2d70914344cc963602cb0ccd6f3b8aac..504c68634b49d807318695f9b65d62480e01880e 100644 |
--- a/chrome/installer/setup/install_worker.cc |
+++ b/chrome/installer/setup/install_worker.cc |
@@ -1092,6 +1092,52 @@ void AddUsageStatsWorkItems(const InstallationState& original_state, |
} |
} |
+// Migrates the usagestats value from the binaries to Chrome when migrating |
+// multi-install Chrome to single-install. |
+void AddMigrateUsageStatesWorkItems(const InstallationState& original_state, |
+ const InstallerState& installer_state, |
+ WorkItemList* install_list) { |
+ // Ensure that a non-multi install or update is being processed (i.e., |
+ // no "--multi-install" on the command line). |
+ if (installer_state.is_multi_install()) |
+ return; |
+ |
+ // Ensure that Chrome is the product being installed or updated (there are no |
+ // other products, so it is especially unexpected for this to fail). |
+ const Product* chrome_product = |
+ installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
+ if (!chrome_product) { |
+ NOTREACHED(); |
robertshield
2015/01/28 23:17:59
Is it worth logging this (and maybe other, but mos
grt (UTC plus 2)
2015/01/29 17:56:51
Excellent idea. Done.
|
+ return; |
+ } |
+ |
+ const ProductState* chrome_state = original_state.GetProductState( |
+ installer_state.system_install(), |
+ BrowserDistribution::CHROME_BROWSER); |
+ // Bail out if there is not an existing multi-install Chrome that is being |
+ // updated. |
+ if (!chrome_state || !chrome_state->is_multi_install()) |
+ return; |
+ |
+ const ProductState* binaries_state = original_state.GetProductState( |
+ installer_state.system_install(), |
+ BrowserDistribution::CHROME_BINARIES); |
+ |
+ // There is nothing to be done if the binaries do not have stats. |
+ DWORD usagestats = 0; |
+ if (!binaries_state || !binaries_state->GetUsageStats(&usagestats)) |
+ return; |
+ |
+ // Write the value that was read to Chrome's ClientState key. |
+ install_list->AddSetRegValueWorkItem( |
+ installer_state.root_key(), |
+ chrome_product->distribution()->GetStateKey(), |
+ KEY_WOW64_32KEY, |
+ google_update::kRegUsageStatsField, |
+ usagestats, |
+ true); |
+} |
+ |
bool AppendPostInstallTasks(const InstallerState& installer_state, |
const base::FilePath& setup_path, |
const Version* current_version, |
@@ -1310,6 +1356,16 @@ void AddInstallWorkItems(const InstallationState& original_state, |
install_list); |
} |
+ // Ensure that the Clients key for the binaries is gone for single installs. |
+ if (!installer_state.is_multi_install()) { |
+ BrowserDistribution* binaries_dist = |
+ BrowserDistribution::GetSpecificDistribution( |
+ BrowserDistribution::CHROME_BINARIES); |
+ install_list->AddDeleteRegKeyWorkItem(root, |
+ binaries_dist->GetVersionKey(), |
+ KEY_WOW64_32KEY); |
+ } |
+ |
// TODO(huangs): Implement actual migration code and remove the hack below. |
// If installing Chrome without the legacy stand-alone App Launcher (to be |
// handled later), add "shadow" App Launcher registry keys so Google Update |
@@ -1341,6 +1397,9 @@ void AddInstallWorkItems(const InstallationState& original_state, |
// Copy over brand, usagestats, and other values. |
AddGoogleUpdateWorkItems(original_state, installer_state, install_list); |
+ // Migrate usagestats back to Chrome. |
+ AddMigrateUsageStatesWorkItems(original_state, installer_state, install_list); |
+ |
// Append the tasks that run after the installation. |
AppendPostInstallTasks(installer_state, |
setup_path, |