diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-31 16:15:38 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-31 16:15:38 +0000 |
commit | e27022f2a07acc7df33f60c5e600906977b1dd17 (patch) | |
tree | 362eb589b0b2e88e9758a29f12c1528d2eb17ddc | |
parent | 1e314cf0de24d58991e66f8d66e09e6cb1454770 (diff) | |
download | chromium_src-e27022f2a07acc7df33f60c5e600906977b1dd17.zip chromium_src-e27022f2a07acc7df33f60c5e600906977b1dd17.tar.gz chromium_src-e27022f2a07acc7df33f60c5e600906977b1dd17.tar.bz2 |
Consolidate same constant defined in three different places. No change in chrome.exe size.
Review URL: http://codereview.chromium.org/8409
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4284 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/google_update_client.cc | 13 | ||||
-rw-r--r-- | chrome/installer/util/google_chrome_distribution.cc | 6 | ||||
-rw-r--r-- | chrome/installer/util/google_update_constants.cc | 12 | ||||
-rw-r--r-- | chrome/installer/util/google_update_constants.h | 18 | ||||
-rw-r--r-- | chrome/installer/util/google_update_settings.cc | 47 |
5 files changed, 53 insertions, 43 deletions
diff --git a/chrome/app/google_update_client.cc b/chrome/app/google_update_client.cc index 8c0e168..b691ec5 100644 --- a/chrome/app/google_update_client.cc +++ b/chrome/app/google_update_client.cc @@ -8,14 +8,9 @@ #include <strsafe.h> #include "chrome/app/client_util.h" +#include "chrome/installer/util/google_update_constants.h" namespace { -const wchar_t kRegistryClients[] = L"Software\\Google\\Update\\Clients\\"; -const wchar_t kRegistryClientState[] = - L"Software\\Google\\Update\\ClientState\\"; -const wchar_t kRequestParamDidRun[] = L"dr"; -const wchar_t kRegistryUpdate[] = L"Software\\Google\\Update\\"; -const wchar_t kRegistryValueCrashReportPath[] = L"CrashReportPath"; const wchar_t kEnvProductVersionKey[] = L"CHROME_VERSION"; // Allocates the out param on success. @@ -86,12 +81,12 @@ bool GoogleUpdateClient::Launch(HINSTANCE instance, if (NULL != entry) { // record did_run "dr" in client state HKEY reg_root = (user_mode_) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE; - std::wstring key_path = kRegistryClientState + guid_; + std::wstring key_path = google_update::kRegPathClientState + guid_; HKEY reg_key; if (::RegOpenKeyEx(reg_root, key_path.c_str(), 0, KEY_WRITE, ®_key) == ERROR_SUCCESS) { const wchar_t kVal[] = L"1"; - ::RegSetValueEx(reg_key, kRequestParamDidRun, 0, REG_SZ, + ::RegSetValueEx(reg_key, google_update::kRegDidRunField, 0, REG_SZ, reinterpret_cast<const BYTE *>(kVal), sizeof(kVal)); ::RegCloseKey(reg_key); } @@ -122,7 +117,7 @@ bool GoogleUpdateClient::Init(const wchar_t* client_guid, if (GoogleUpdateEnvQueryStr(kEnvProductVersionKey, &version_)) { ret = true; } else { - std::wstring key(kRegistryClients); + std::wstring key(google_update::kRegPathClients); key.append(guid_); if (client_util::GetChromiumVersion(dll_path_, key.c_str(), &version_)) ret = true; diff --git a/chrome/installer/util/google_chrome_distribution.cc b/chrome/installer/util/google_chrome_distribution.cc index ceeac44..e711c95 100644 --- a/chrome/installer/util/google_chrome_distribution.cc +++ b/chrome/installer/util/google_chrome_distribution.cc @@ -160,7 +160,7 @@ void GoogleChromeDistribution::UpdateDiffInstallStatus(bool system_install, reg_key.append(L"\\"); reg_key.append(google_update::kChromeGuid); if (!key.Open(reg_root, reg_key.c_str(), KEY_ALL_ACCESS) || - !key.ReadValue(google_update::kRegApFieldName, &ap_key_value)) { + !key.ReadValue(google_update::kRegApField, &ap_key_value)) { LOG(INFO) << "Application key not found."; if (!incremental_install || !GetInstallReturnCode(install_status)) { LOG(INFO) << "Returning without changing application key."; @@ -180,9 +180,9 @@ void GoogleChromeDistribution::UpdateDiffInstallStatus(bool system_install, std::wstring new_value = GoogleChromeDistribution::GetNewGoogleUpdateApKey( incremental_install, install_status, ap_key_value); if ((new_value.compare(ap_key_value) != 0) && - !key.WriteValue(google_update::kRegApFieldName, new_value.c_str())) { + !key.WriteValue(google_update::kRegApField, new_value.c_str())) { LOG(ERROR) << "Failed to write value " << new_value - << " to the registry field " << google_update::kRegApFieldName; + << " to the registry field " << google_update::kRegApField; } key.Close(); } diff --git a/chrome/installer/util/google_update_constants.cc b/chrome/installer/util/google_update_constants.cc index 6703850..ee75f0c 100644 --- a/chrome/installer/util/google_update_constants.cc +++ b/chrome/installer/util/google_update_constants.cc @@ -8,12 +8,18 @@ namespace google_update { const wchar_t kChromeGuid[] = L"{8A69D345-D564-463c-AFF1-A69D9E530F96}"; const wchar_t kGearsUpgradeCode[] = L"{D92DBAED-3E3E-4530-B30D-072D16C7DDD0}"; + const wchar_t kRegPathClients[] = L"Software\\Google\\Update\\Clients"; const wchar_t kRegPathClientState[] = L"Software\\Google\\Update\\ClientState"; -const wchar_t kRegApFieldName[] = L"ap"; + +const wchar_t kRegApField[] = L"ap"; +const wchar_t kRegBrowserField[] = L"browser"; +const wchar_t kRegDidRunField[] = L"dr"; +const wchar_t kRegLangField[] = L"lang"; +const wchar_t kRegLastCheckedField[] = L"LastChecked"; const wchar_t kRegNameField[] = L"name"; +const wchar_t kRegRLZBrandField[] = L"brand"; +const wchar_t kRegUsageStatsField[] = L"usagestats"; const wchar_t kRegVersionField[] = L"pv"; -const wchar_t kRegLastCheckedField[] = L"LastChecked"; - } // namespace installer diff --git a/chrome/installer/util/google_update_constants.h b/chrome/installer/util/google_update_constants.h index 00a09ad..2b24540 100644 --- a/chrome/installer/util/google_update_constants.h +++ b/chrome/installer/util/google_update_constants.h @@ -4,25 +4,29 @@ // Defines all the command-line switches used with Google Update. -#ifndef CHROME_INSTALLER_UTIL_GOOGLE_UPDATE_CONSTANTS_H__ -#define CHROME_INSTALLER_UTIL_GOOGLE_UPDATE_CONSTANTS_H__ +#ifndef CHROME_INSTALLER_UTIL_GOOGLE_UPDATE_CONSTANTS_H_ +#define CHROME_INSTALLER_UTIL_GOOGLE_UPDATE_CONSTANTS_H_ namespace google_update { extern const wchar_t kChromeGuid[]; - // Strictly speaking Google Update doesn't care about this GUID but it is still // related to install as it is used by MSI to identify Gears. extern const wchar_t kGearsUpgradeCode[]; extern const wchar_t kRegPathClients[]; extern const wchar_t kRegPathClientState[]; -extern const wchar_t kRegApFieldName[]; + +extern const wchar_t kRegApField[]; +extern const wchar_t kRegBrowserField[]; +extern const wchar_t kRegDidRunField[]; +extern const wchar_t kRegLangField[]; +extern const wchar_t kRegLastCheckedField[]; extern const wchar_t kRegNameField[]; +extern const wchar_t kRegRLZBrandField[]; +extern const wchar_t kRegUsageStatsField[]; extern const wchar_t kRegVersionField[]; -extern const wchar_t kRegLastCheckedField[]; - } // namespace google_update -#endif // CHROME_INSTALLER_UTIL_GOOGLE_UPDATE_CONSTANTS_H__ +#endif // CHROME_INSTALLER_UTIL_GOOGLE_UPDATE_CONSTANTS_H_ diff --git a/chrome/installer/util/google_update_settings.cc b/chrome/installer/util/google_update_settings.cc index 91feefe..859ca02 100644 --- a/chrome/installer/util/google_update_settings.cc +++ b/chrome/installer/util/google_update_settings.cc @@ -5,44 +5,49 @@ #include "chrome/installer/util/google_update_settings.h" #include "base/registry.h" - -namespace { - -const wchar_t kRegistryBase[] = - L"Software\\Google\\Update\\ClientState\\{8A69D345-D564-463c-AFF1-A69D9E530F96}"; -const wchar_t kUsageStatsFlag[] = L"usagestats"; -const wchar_t kBrowserUsed[] = L"browser"; -const wchar_t kSelectedLang[] = L"lang"; -const wchar_t kRLZBrand[] = L"brand"; - -} // namespace +#include "chrome/installer/util/google_update_constants.h" bool GoogleUpdateSettings::GetCollectStatsConsent() { - RegKey key(HKEY_CURRENT_USER, kRegistryBase, KEY_READ); + 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); DWORD value; - if (!key.ReadValueDW(kUsageStatsFlag, &value)) + if (!key.ReadValueDW(google_update::kRegUsageStatsField, &value)) return false; return (1 == value); } bool GoogleUpdateSettings::SetCollectStatsConsent(bool consented) { - RegKey key(HKEY_CURRENT_USER, kRegistryBase, KEY_READ | KEY_WRITE); + 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 | KEY_WRITE); DWORD value = consented ? 1 : 0; - return key.WriteValue(kUsageStatsFlag, value); + return key.WriteValue(google_update::kRegUsageStatsField, value); } bool GoogleUpdateSettings::GetBrowser(std::wstring* browser) { - RegKey key(HKEY_CURRENT_USER, kRegistryBase, KEY_READ); - return key.ReadValue(kBrowserUsed, 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); } bool GoogleUpdateSettings::GetLanguage(std::wstring* language) { - RegKey key(HKEY_CURRENT_USER, kRegistryBase, KEY_READ); - return key.ReadValue(kSelectedLang, 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); } bool GoogleUpdateSettings::GetBrand(std::wstring* brand) { - RegKey key(HKEY_CURRENT_USER, kRegistryBase, KEY_READ); - return key.ReadValue(kRLZBrand, 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); } |