Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2077)

Unified Diff: chrome/installer/setup/install_worker.cc

Issue 869153004: Support migrating multi-install Chrome to single-install. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..1166dc7d3fe7126613dc8d6aca1da71528e7443b 100644
--- a/chrome/installer/setup/install_worker.cc
+++ b/chrome/installer/setup/install_worker.cc
@@ -1092,6 +1092,50 @@ void AddUsageStatsWorkItems(const InstallationState& original_state,
}
}
+// Migrates the usagestats value from the binaries to Chrome when migrating
+// multi-install Chrome to single-install.
robertshield 2015/01/23 22:45:30 any reason not to do this separately first, or doe
grt (UTC plus 2) 2015/01/24 02:25:16 In the current world, usagestats is read from/writ
+void AddMigrateUsageStatesWorkItems(const InstallationState& original_state,
+ const InstallerState& installer_state,
+ WorkItemList* install_list) {
+ // This operation only applies to single-installs.
robertshield 2015/01/23 22:45:30 nit: less ambiguous: This operation only applies w
grt (UTC plus 2) 2015/01/24 02:25:15 Reworded all comments here in the hopes that they
+ if (installer_state.is_multi_install())
+ return;
+
+ // This operation only applies to Chrome.
+ const Product* chrome_product =
+ installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER);
+ if (!chrome_product) {
+ NOTREACHED();
+ return;
+ }
+
+ const ProductState* chrome_state = original_state.GetProductState(
+ installer_state.system_install(),
+ BrowserDistribution::CHROME_BROWSER);
+ // This operation only applies when updating multi-install Chrome to
+ // single-install.
+ 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 +1354,16 @@ void AddInstallWorkItems(const InstallationState& original_state,
install_list);
}
+ // Ensure that the Clients key for the binaries is gone for single installs.
robertshield 2015/01/23 22:45:30 Do we need to double check to make sure this doesn
grt (UTC plus 2) 2015/01/24 02:25:15 Line 1343 adds the Clients key for Chrome itself,
+ 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 +1395,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,
« no previous file with comments | « no previous file | chrome/installer/setup/setup_main.cc » ('j') | chrome/installer/util/installation_validator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698