| Index: chrome/installer/util/install_util.cc
|
| diff --git a/chrome/installer/util/install_util.cc b/chrome/installer/util/install_util.cc
|
| index f7dccea263c8bc2f0c43b040dd191b70324d294e..048439ff2200f0f6a29f3c1be24449eca25b0125 100644
|
| --- a/chrome/installer/util/install_util.cc
|
| +++ b/chrome/installer/util/install_util.cc
|
| @@ -12,6 +12,7 @@
|
| #include <shlwapi.h>
|
|
|
| #include <algorithm>
|
| +#include <vector>
|
|
|
| #include "base/command_line.h"
|
| #include "base/files/file_util.h"
|
| @@ -19,6 +20,9 @@
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/path_service.h"
|
| #include "base/process/launch.h"
|
| +#include "base/strings/string16.h"
|
| +#include "base/strings/string_number_conversions.h"
|
| +#include "base/strings/string_split.h"
|
| #include "base/strings/string_util.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/sys_info.h"
|
| @@ -128,6 +132,62 @@ HWND CreateUACForegroundWindow() {
|
|
|
| } // namespace
|
|
|
| +base::string16 InstallUtil::GetActiveSetupVersionFromExisting(
|
| + ActiveSetupVersionComponent component,
|
| + ActiveSetupVersionOperation operation,
|
| + int value,
|
| + const base::string16& existing_version) {
|
| + std::vector<base::string16> version_components = base::SplitString(
|
| + existing_version, L",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
|
| +
|
| + // If |existing_version| was empty or otherwise corrupted, turn it into a
|
| + // valid one.
|
| + if (version_components.size() != 4U)
|
| + version_components.assign(4U, L"0");
|
| +
|
| + switch (operation) {
|
| + case SET:
|
| + version_components[component] = base::IntToString16(value);
|
| + break;
|
| + case BUMP:
|
| + int previous_value;
|
| + if (base::StringToInt(version_components[component], &previous_value)) {
|
| + version_components[component] =
|
| + base::IntToString16(previous_value + value);
|
| + }
|
| + break;
|
| + }
|
| +
|
| + return JoinString(version_components, L',');
|
| +}
|
| +
|
| +bool InstallUtil::UpdateActiveSetupVersion(
|
| + BrowserDistribution* dist,
|
| + ActiveSetupVersionComponent component,
|
| + ActiveSetupVersionOperation operation,
|
| + int value) {
|
| + base::string16 active_setup_reg(GetActiveSetupPath(dist));
|
| + base::win::RegKey active_setup_key;
|
| + if (active_setup_key.Open(HKEY_LOCAL_MACHINE, active_setup_reg.c_str(),
|
| + KEY_QUERY_VALUE | KEY_SET_VALUE) != ERROR_SUCCESS) {
|
| + VLOG(1) << "Unable to open Active Setup key.";
|
| + return false;
|
| + }
|
| +
|
| + base::string16 existing_version;
|
| + if (active_setup_key.ReadValue(L"Version",
|
| + &existing_version) != ERROR_SUCCESS) {
|
| + VLOG(1) << "Unable to read Active Setup key to string.";
|
| + return false;
|
| + }
|
| +
|
| + base::string16 updated_version = GetActiveSetupVersionFromExisting(
|
| + component, operation, value, existing_version);
|
| +
|
| + return active_setup_key.WriteValue(L"Version", updated_version.c_str()) ==
|
| + ERROR_SUCCESS;
|
| +}
|
| +
|
| base::string16 InstallUtil::GetActiveSetupPath(BrowserDistribution* dist) {
|
| static const wchar_t kInstalledComponentsPath[] =
|
| L"Software\\Microsoft\\Active Setup\\Installed Components\\";
|
|
|