Commit 94610a49 authored by wfh@chromium.org's avatar wfh@chromium.org

Always read and write Google Update registry values from the 32-bit hive, even on 64-bit systems.

BUG=380371

Review URL: https://codereview.chromium.org/316753003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274907 0039d316-1c4b-4281-b951-d872f2087c98
parent 6c915b62
......@@ -75,6 +75,7 @@ bool WriteGoogleUpdateStrKeyInternal(const AppRegistrationData& app_reg_data,
// presubmit: allow wstring
const std::wstring& value,
const wchar_t* const aggregate) {
const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY;
if (system_install) {
DCHECK(aggregate);
// Machine installs require each OS user to write a unique key under a
......@@ -89,13 +90,12 @@ bool WriteGoogleUpdateStrKeyInternal(const AppRegistrationData& app_reg_data,
base::string16 reg_path(app_reg_data.GetStateMediumKey());
reg_path.append(L"\\");
reg_path.append(name);
RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_SET_VALUE);
RegKey key(HKEY_LOCAL_MACHINE, reg_path.c_str(), kAccess);
key.WriteValue(google_update::kRegAggregateMethod, aggregate);
return (key.WriteValue(uniquename.c_str(), value.c_str()) == ERROR_SUCCESS);
} else {
// User installs are easy: just write the values to HKCU tree.
RegKey key(HKEY_CURRENT_USER, app_reg_data.GetStateKey().c_str(),
KEY_SET_VALUE);
RegKey key(HKEY_CURRENT_USER, app_reg_data.GetStateKey().c_str(), kAccess);
return (key.WriteValue(name, value.c_str()) == ERROR_SUCCESS);
}
}
......@@ -226,12 +226,13 @@ bool GoogleUpdateSettings::GetCollectStatsConsentAtLevel(bool system_install) {
RegKey key;
DWORD value = 0;
bool have_value = false;
const REGSAM kAccess = KEY_QUERY_VALUE | KEY_WOW64_32KEY;
// For system-level installs, try ClientStateMedium first.
have_value =
system_install &&
key.Open(HKEY_LOCAL_MACHINE, dist->GetStateMediumKey().c_str(),
KEY_QUERY_VALUE) == ERROR_SUCCESS &&
kAccess) == ERROR_SUCCESS &&
key.ReadValueDW(google_update::kRegUsageStatsField,
&value) == ERROR_SUCCESS;
......@@ -240,7 +241,7 @@ bool GoogleUpdateSettings::GetCollectStatsConsentAtLevel(bool system_install) {
have_value =
key.Open(system_install ? HKEY_LOCAL_MACHINE : HKEY_CURRENT_USER,
dist->GetStateKey().c_str(),
KEY_QUERY_VALUE) == ERROR_SUCCESS &&
kAccess) == ERROR_SUCCESS &&
key.ReadValueDW(google_update::kRegUsageStatsField,
&value) == ERROR_SUCCESS;
}
......@@ -271,7 +272,8 @@ bool GoogleUpdateSettings::SetCollectStatsConsentAtLevel(bool system_install,
std::wstring reg_path =
system_install ? dist->GetStateMediumKey() : dist->GetStateKey();
RegKey key;
LONG result = key.Create(root_key, reg_path.c_str(), KEY_SET_VALUE);
LONG result = key.Create(
root_key, reg_path.c_str(), KEY_SET_VALUE | KEY_WOW64_32KEY);
if (result != ERROR_SUCCESS) {
LOG(ERROR) << "Failed opening key " << reg_path << " to set "
<< google_update::kRegUsageStatsField << "; result: " << result;
......@@ -303,13 +305,14 @@ bool GoogleUpdateSettings::SetEULAConsent(
bool consented) {
DCHECK(dist);
const DWORD eula_accepted = consented ? 1 : 0;
const REGSAM kAccess = KEY_SET_VALUE | KEY_WOW64_32KEY;
std::wstring reg_path = dist->GetStateMediumKey();
bool succeeded = true;
RegKey key;
// Write the consent value into the product's ClientStateMedium key.
if (key.Create(HKEY_LOCAL_MACHINE, reg_path.c_str(),
KEY_SET_VALUE) != ERROR_SUCCESS ||
kAccess) != ERROR_SUCCESS ||
key.WriteValue(google_update::kRegEULAAceptedField,
eula_accepted) != ERROR_SUCCESS) {
succeeded = false;
......@@ -325,7 +328,7 @@ bool GoogleUpdateSettings::SetEULAConsent(
BrowserDistribution::CHROME_BINARIES);
reg_path = dist->GetStateMediumKey();
if (key.Create(HKEY_LOCAL_MACHINE, reg_path.c_str(),
KEY_SET_VALUE) != ERROR_SUCCESS ||
kAccess) != ERROR_SUCCESS ||
key.WriteValue(google_update::kRegEULAAceptedField,
eula_accepted) != ERROR_SUCCESS) {
succeeded = false;
......@@ -697,7 +700,7 @@ base::string16 GoogleUpdateSettings::GetUninstallCommandLine(
RegKey update_key;
if (update_key.Open(root_key, google_update::kRegPathGoogleUpdate,
KEY_QUERY_VALUE) == ERROR_SUCCESS) {
KEY_QUERY_VALUE | KEY_WOW64_32KEY) == ERROR_SUCCESS) {
update_key.ReadValue(google_update::kRegUninstallCmdLine, &cmd_line);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment