summaryrefslogtreecommitdiffstats
path: root/chrome/installer
diff options
context:
space:
mode:
authorgwilson@google.com <gwilson@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-05 21:34:18 +0000
committergwilson@google.com <gwilson@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-03-05 21:34:18 +0000
commitcf379a0d234f7516fd5beb56d4fe983e1263de16 (patch)
tree6b18b8a79a04ea0e45a3b7f6f1cb9589a5392a6b /chrome/installer
parent5bc36888465bd881c6becd2351bb5547ba4eae60 (diff)
downloadchromium_src-cf379a0d234f7516fd5beb56d4fe983e1263de16.zip
chromium_src-cf379a0d234f7516fd5beb56d4fe983e1263de16.tar.gz
chromium_src-cf379a0d234f7516fd5beb56d4fe983e1263de16.tar.bz2
Fixes a bug in the criteria checker that caused the 6-month flag to not be deleted.
BUG=8217 R=kuchhal Review URL: http://codereview.chromium.org/27307 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11038 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r--chrome/installer/gcapi/gcapi.cc104
1 files changed, 32 insertions, 72 deletions
diff --git a/chrome/installer/gcapi/gcapi.cc b/chrome/installer/gcapi/gcapi.cc
index 3f4a226..f0a27b4 100644
--- a/chrome/installer/gcapi/gcapi.cc
+++ b/chrome/installer/gcapi/gcapi.cc
@@ -23,59 +23,6 @@ const wchar_t kChromeRegLastLaunchCmd[] = L"LastInstallerSuccessLaunchCmdLine";
const wchar_t kChromeRegVersion[] = L"pv";
const wchar_t kNoChromeOfferUntil[] = L"SOFTWARE\\Google\\No Chrome Offer Until";
-// Remove any registry key with non-numeric value or with the numeric value
-// equal or less than today's date represented in YYYYMMDD form.
-void CleanUpRegistryValues() {
- HKEY key = NULL;
- if (::RegOpenKeyEx(HKEY_LOCAL_MACHINE, kNoChromeOfferUntil,
- 0, KEY_ALL_ACCESS, &key) != ERROR_SUCCESS)
- return;
-
- DWORD index = 0;
- wchar_t value_name[260];
- DWORD value_name_len = _countof(value_name);
- DWORD value_type = REG_DWORD;
- DWORD value_data = 0;
- DWORD value_len = sizeof(DWORD);
-
- // First, remove any value whose type is not DWORD.
- while (::RegEnumValue(key, index, value_name, &value_name_len, NULL,
- &value_type, NULL, &value_len) == ERROR_SUCCESS) {
- if (value_type == REG_DWORD)
- index++;
- else
- ::RegDeleteValue(key, value_name);
-
- value_name_len = _countof(value_name);
- value_type = REG_DWORD;
- value_len = sizeof(DWORD);
- }
-
- // Get today's date, and format it as YYYYMMDD numeric value.
- SYSTEMTIME now;
- ::GetLocalTime(&now);
- DWORD expiration_date = now.wYear * 10000 + now.wMonth * 100 + now.wDay;
-
- // Remove any DWORD value smaller than the number represent the
- // expiration date (YYYYMMDD).
- index = 0;
- while (::RegEnumValue(key, index, value_name, &value_name_len, NULL,
- &value_type, (LPBYTE) &value_data,
- &value_len) == ERROR_SUCCESS) {
- if (value_type == REG_DWORD && value_data > expiration_date)
- index++; // move on to next value.
- else
- ::RegDeleteValue(key, value_name); // delete this value.
-
- value_name_len = _countof(value_name);
- value_type = REG_DWORD;
- value_data = 0;
- value_len = sizeof(DWORD);
- }
-
- ::RegCloseKey(key);
-}
-
// Return the company name specified in the file version info resource.
bool GetCompanyName(const wchar_t* filename, wchar_t* buffer, DWORD out_len) {
wchar_t file_version_info[8192];
@@ -144,23 +91,38 @@ bool CanReOfferChrome(BOOL set_flag) {
if (::RegCreateKeyEx(HKEY_LOCAL_MACHINE, kNoChromeOfferUntil,
0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE,
NULL, &key, &disposition) == ERROR_SUCCESS) {
+ // Get today's date, and format it as YYYYMMDD numeric value.
+ SYSTEMTIME now;
+ GetLocalTime(&now);
+ DWORD today = now.wYear * 10000 + now.wMonth * 100 + now.wDay;
+
// Cannot re-offer, if the timer already exists and is not expired yet.
- if (::RegQueryValueEx(key, company, 0, 0, 0, 0) == ERROR_SUCCESS) {
- // The expired timers were already removed in CleanUpRegistryValues.
- // So if the key is not found, we can offer the Chrome.
+ DWORD value_type = REG_DWORD;
+ DWORD value_data = 0;
+ DWORD value_length = sizeof(DWORD);
+ if (::RegQueryValueEx(key, company, 0, &value_type,
+ reinterpret_cast<LPBYTE>(&value_data),
+ &value_length) == ERROR_SUCCESS &&
+ REG_DWORD == value_type &&
+ value_data > today) {
+ // The time has not expired, we cannot offer Chrome.
can_re_offer = false;
- } else if (set_flag) {
- // Set expiration date for offer as six months from today,
- // represented as a YYYYMMDD numeric value.
- SYSTEMTIME timer;
- ::GetLocalTime(&timer);
- timer.wMonth = timer.wMonth + 6;
- if (timer.wMonth > 12) {
- timer.wMonth = timer.wMonth - 12;
- timer.wYear = timer.wYear + 1;
+ } else {
+ // Delete the old or invalid value.
+ ::RegDeleteValue(key, company);
+ if (set_flag) {
+ // Set expiration date for offer as six months from today,
+ // represented as a YYYYMMDD numeric value.
+ SYSTEMTIME timer = now;
+ timer.wMonth = timer.wMonth + 6;
+ if (timer.wMonth > 12) {
+ timer.wMonth = timer.wMonth - 12;
+ timer.wYear = timer.wYear + 1;
+ }
+ DWORD value = timer.wYear * 10000 + timer.wMonth * 100 + timer.wDay;
+ ::RegSetValueEx(key, company, 0, REG_DWORD, (LPBYTE)&value,
+ sizeof(DWORD));
}
- DWORD value = timer.wYear * 10000 + timer.wMonth * 100 + timer.wDay;
- ::RegSetValueEx(key, company, 0, REG_DWORD, (LPBYTE)&value, sizeof(DWORD));
}
::RegCloseKey(key);
@@ -338,11 +300,9 @@ DLLEXPORT BOOL __stdcall GoogleChromeCompatibilityCheck(BOOL set_flag, DWORD *re
local_reasons |= GCCC_ERROR_INTEGRITYLEVEL;
}
- // First clean up the registry keys left over previously.
- // Then only check whether we can re-offer, if everything else is OK.
- CleanUpRegistryValues();
- if (local_reasons == 0 && !CanReOfferChrome(set_flag))
- local_reasons |= GCCC_ERROR_ALREADYOFFERED;
+ // Then only check whether we can re-offer, if everything else is OK.
+ if (local_reasons == 0 && !CanReOfferChrome(set_flag))
+ local_reasons |= GCCC_ERROR_ALREADYOFFERED;
// Done. Copy/return results.
if (reasons != NULL)