summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-03 18:27:37 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-03 18:27:37 +0000
commit4d5d69164a86de9fd33c5795f35d0e2116eb2e0b (patch)
tree6486213347c81ef46ec0afe259ff5e6f74ff0ac4
parentdb8a5a4a95416ecf33edaf227793ef2353613b3c (diff)
downloadchromium_src-4d5d69164a86de9fd33c5795f35d0e2116eb2e0b.zip
chromium_src-4d5d69164a86de9fd33c5795f35d0e2116eb2e0b.tar.gz
chromium_src-4d5d69164a86de9fd33c5795f35d0e2116eb2e0b.tar.bz2
Read Google Update registry keys first from HKCU then from HKLM to handle system level install case.
BUG=1455516. Review URL: http://codereview.chromium.org/8974 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4462 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/installer/util/google_update_settings.cc50
1 files changed, 29 insertions, 21 deletions
diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc
index 859ca02..394c017 100644
--- a/chrome/installer/util/google_update_settings.cc
+++ b/chrome/installer/util/google_update_settings.cc
@@ -7,47 +7,55 @@
#include "base/registry.h"
#include "chrome/installer/util/google_update_constants.h"
-bool GoogleUpdateSettings::GetCollectStatsConsent() {
+namespace {
+
+std::wstring GetClientStateKeyPath() {
std::wstring reg_path(google_update::kRegPathClientState);
reg_path.append(L"\\");
reg_path.append(google_update::kChromeGuid);
+ return reg_path;
+}
+
+bool ReadGoogleUpdateStrKey(const wchar_t* const key_name,
+ std::wstring* value) {
+ std::wstring reg_path = GetClientStateKeyPath();
+ RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ);
+ if (!key.ReadValue(key_name, value)) {
+ RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ);
+ return hklm_key.ReadValue(key_name, value);
+ }
+ return true;
+}
+}
+
+bool GoogleUpdateSettings::GetCollectStatsConsent() {
+ std::wstring reg_path = GetClientStateKeyPath();
RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ);
DWORD value;
- if (!key.ReadValueDW(google_update::kRegUsageStatsField, &value))
- return false;
+ if (!key.ReadValueDW(google_update::kRegUsageStatsField, &value)) {
+ RegKey hklm_key(HKEY_LOCAL_MACHINE, reg_path.c_str(), KEY_READ);
+ if (!hklm_key.ReadValueDW(google_update::kRegUsageStatsField, &value))
+ return false;
+ }
return (1 == value);
}
bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) {
- std::wstring reg_path(google_update::kRegPathClientState);
- reg_path.append(L"\\");
- reg_path.append(google_update::kChromeGuid);
+ std::wstring reg_path = GetClientStateKeyPath();
RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ | KEY_WRITE);
DWORD value = consented ? 1 : 0;
return key.WriteValue(google_update::kRegUsageStatsField, value);
}
bool GoogleUpdateSettings::GetBrowser(std::wstring* browser) {
- std::wstring reg_path(google_update::kRegPathClientState);
- reg_path.append(L"\\");
- reg_path.append(google_update::kChromeGuid);
- RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ);
- return key.ReadValue(google_update::kRegBrowserField, browser);
+ return ReadGoogleUpdateStrKey(google_update::kRegBrowserField, browser);
}
bool GoogleUpdateSettings::GetLanguage(std::wstring* language) {
- std::wstring reg_path(google_update::kRegPathClientState);
- reg_path.append(L"\\");
- reg_path.append(google_update::kChromeGuid);
- RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ);
- return key.ReadValue(google_update::kRegLangField, language);
+ return ReadGoogleUpdateStrKey(google_update::kRegLangField, language);
}
bool GoogleUpdateSettings::GetBrand(std::wstring* brand) {
- std::wstring reg_path(google_update::kRegPathClientState);
- reg_path.append(L"\\");
- reg_path.append(google_update::kChromeGuid);
- RegKey key(HKEY_CURRENT_USER, reg_path.c_str(), KEY_READ);
- return key.ReadValue(google_update::kRegRLZBrandField, brand);
+ return ReadGoogleUpdateStrKey(google_update::kRegRLZBrandField, brand);
}