diff options
author | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-16 00:32:17 +0000 |
---|---|---|
committer | mattm@chromium.org <mattm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-16 00:32:17 +0000 |
commit | 2bec828dfe5a003391903726e1718b18d3d7559d (patch) | |
tree | 67e3dad9541644e6b59be6679322a16bc6f875ef /chrome/installer/gcapi | |
parent | fc94684be6d98cd4c08f27c500099036ba9f7889 (diff) | |
download | chromium_src-2bec828dfe5a003391903726e1718b18d3d7559d.zip chromium_src-2bec828dfe5a003391903726e1718b18d3d7559d.tar.gz chromium_src-2bec828dfe5a003391903726e1718b18d3d7559d.tar.bz2 |
Revert 217872 "Adds the CanOfferRelaunch function.", android webview_licenses.py seems confused by this file.
> Adds the CanOfferRelaunch function.
>
> R=robertshield@chromium.org, rogerta@chromium.org
> BUG=266926
>
> Review URL: https://codereview.chromium.org/23191002
TBR=macourteau@chromium.org
Review URL: https://codereview.chromium.org/23274002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217879 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/gcapi')
-rw-r--r-- | chrome/installer/gcapi/gcapi.cc | 111 | ||||
-rw-r--r-- | chrome/installer/gcapi/gcapi.def | 1 | ||||
-rw-r--r-- | chrome/installer/gcapi/gcapi.h | 28 |
3 files changed, 19 insertions, 121 deletions
diff --git a/chrome/installer/gcapi/gcapi.cc b/chrome/installer/gcapi/gcapi.cc index a65e1f2..c4a2d6e 100644 --- a/chrome/installer/gcapi/gcapi.cc +++ b/chrome/installer/gcapi/gcapi.cc @@ -38,7 +38,6 @@ #include "chrome/installer/gcapi/gcapi_reactivation.h" #include "chrome/installer/launcher_support/chrome_launcher_support.h" #include "chrome/installer/util/google_update_constants.h" -#include "chrome/installer/util/google_update_settings.h" #include "chrome/installer/util/util_constants.h" #include "chrome/installer/util/wmi.h" #include "google_update/google_update_idl.h" @@ -70,12 +69,6 @@ const wchar_t kChromeRegVersion[] = L"pv"; const wchar_t kNoChromeOfferUntil[] = L"SOFTWARE\\Google\\No Chrome Offer Until"; -const wchar_t kC1FPendingKey[] = - L"Software\\Google\\Common\\Rlz\\Events\\C"; -const wchar_t kC1FSentKey[] = - L"Software\\Google\\Common\\Rlz\\StatefulEvents\\C"; -const wchar_t kC1FKey[] = L"C1F"; - // Prefix used to match the window class for Chrome windows. const wchar_t kChromeWindowClassPrefix[] = L"Chrome_WidgetWin_"; @@ -190,31 +183,30 @@ bool CanReOfferChrome(BOOL set_flag) { return can_re_offer; } -bool IsChromeInstalled(HKEY root_key) { - RegKey key; - return key.Open(root_key, kChromeRegClientsKey, KEY_READ) == ERROR_SUCCESS && - key.HasValue(kChromeRegVersion); -} - -bool IsC1FSent() { - RegKey key; - DWORD value; - - if (key.Open(HKEY_LOCAL_MACHINE, kC1FPendingKey, KEY_READ) == ERROR_SUCCESS && - key.ReadValueDW(kC1FKey, &value) == ERROR_SUCCESS && - value == 1) { - return true; - } - - if (key.Open(HKEY_CURRENT_USER, kC1FPendingKey, KEY_READ) == ERROR_SUCCESS && - key.ReadValueDW(kC1FKey, &value) == ERROR_SUCCESS && - value == 1) { +// Helper function to read a value from registry. Returns true if value +// is read successfully and stored in parameter value. Returns false otherwise. +bool ReadValueFromRegistry(HKEY root_key, const wchar_t* sub_key, + const wchar_t* value_name, wchar_t* value, + size_t* size) { + HKEY key; + if ((::RegOpenKeyEx(root_key, sub_key, NULL, + KEY_READ, &key) == ERROR_SUCCESS) && + (::RegQueryValueEx(key, value_name, NULL, NULL, + reinterpret_cast<LPBYTE>(value), + reinterpret_cast<LPDWORD>(size)) == ERROR_SUCCESS)) { + ::RegCloseKey(key); return true; } - return false; } +bool IsChromeInstalled(HKEY root_key) { + wchar_t version[64]; + size_t size = _countof(version); + return ReadValueFromRegistry(root_key, kChromeRegClientsKey, + kChromeRegVersion, version, &size); +} + enum WindowsVersion { VERSION_BELOW_XP_SP2, VERSION_XP_SP2_UP_TO_VISTA, // "but not including" @@ -674,68 +666,3 @@ BOOL __stdcall ReactivateChrome(wchar_t* brand_code, return result; } - -BOOL __stdcall CanOfferRelaunch(const wchar_t** partner_brandcode_list, - int partner_brandcode_list_length, - int shell_mode, - DWORD* error_code) { - DCHECK(error_code); - - if (!partner_brandcode_list || partner_brandcode_list_length <= 0) { - if (error_code) - *error_code = RELAUNCH_ERROR_INVALID_INPUT; - return FALSE; - } - - // These conditions need to be satisfied for relaunch: - // (a) Chrome should be installed; - if (!IsChromeInstalled(HKEY_LOCAL_MACHINE) && - (shell_mode == GCAPI_INVOKED_STANDARD_SHELL && - !IsChromeInstalled(HKEY_CURRENT_USER))) { - if (error_code) - *error_code = RELAUNCH_ERROR_NOTINSTALLED; - return FALSE; - } - - // (b) the installed brandcode should belong to that partner (in - // brandcode_list); - std::wstring installed_brandcode; - bool valid_brandcode = false; - if (GoogleUpdateSettings::GetBrand(&installed_brandcode)) { - for (int i = 0; i < partner_brandcode_list_length; ++i) { - if (!_wcsicmp(installed_brandcode.c_str(), partner_brandcode_list[i])) { - valid_brandcode = true; - break; - } - } - } - - if (!valid_brandcode) { - if (error_code) - *error_code = RELAUNCH_ERROR_INVALID_PARTNER; - return FALSE; - } - - // (c) C1F ping should not have been sent; - if (IsC1FSent()) { - if (error_code) - *error_code = RELAUNCH_ERROR_PINGS_SENT; - return FALSE; - } - - // (d) a minimum period (30 days) must have passed since Chrome was last used; - int days_since_last_run = GoogleChromeDaysSinceLastRun(); - if (days_since_last_run >= 0 && - days_since_last_run < kRelaunchMinDaysDormant) { - if (error_code) - *error_code = RELAUNCH_ERROR_NOTDORMANT; - return FALSE; - } - - // (e) a minimum period (6 months) must have passed since the previous - // relaunch offer; - // TODO(macourteau): add this check once |SetRelaunchOffered| has been - // implemented. Return RELAUNCH_ERROR_ALREADY_RELAUNCHED on error. - - return TRUE; -} diff --git a/chrome/installer/gcapi/gcapi.def b/chrome/installer/gcapi/gcapi.def index f26c826..e6abeae 100644 --- a/chrome/installer/gcapi/gcapi.def +++ b/chrome/installer/gcapi/gcapi.def @@ -8,4 +8,3 @@ EXPORTS GoogleChromeDaysSinceLastRun CanOfferReactivation ReactivateChrome - CanOfferRelaunch diff --git a/chrome/installer/gcapi/gcapi.h b/chrome/installer/gcapi/gcapi.h index 8a9486b..1951c5b 100644 --- a/chrome/installer/gcapi/gcapi.h +++ b/chrome/installer/gcapi/gcapi.h @@ -22,14 +22,6 @@ #define REACTIVATE_ERROR_INVALID_INPUT (1 << 3) #define REACTIVATE_ERROR_REACTIVATION_FAILED (1 << 4) -// Error conditions for CanOfferRelaunch(). -#define RELAUNCH_ERROR_NOTINSTALLED (1 << 0) -#define RELAUNCH_ERROR_INVALID_PARTNER (1 << 1) -#define RELAUNCH_ERROR_PINGS_SENT (1 << 2) -#define RELAUNCH_ERROR_NOTDORMANT (1 << 3) -#define RELAUNCH_ERROR_ALREADY_RELAUNCHED (1 << 4) -#define RELAUNCH_ERROR_INVALID_INPUT (1 << 5) - // Flags to indicate how GCAPI is invoked #define GCAPI_INVOKED_STANDARD_SHELL (1 << 0) #define GCAPI_INVOKED_UAC_ELEVATION (1 << 1) @@ -42,10 +34,6 @@ extern "C" { // may be offered. const int kReactivationMinDaysDormant = 50; -// The minimum number of days an installation can be dormant before a relaunch -// may be offered. -const int kRelaunchMinDaysDormant = 30; - // This function returns TRUE if Google Chrome should be offered. // If the return is FALSE, the |reasons| DWORD explains why. If you don't care // for the reason, you can pass NULL for |reasons|. @@ -116,18 +104,6 @@ BOOL __stdcall ReactivateChrome(wchar_t* brand_code, int shell_mode, DWORD* error_code); -// Returns true if a vendor may offer relaunch at this time. Returns false if -// the vendor may not offer reactivation at this time, and places one of the -// RELAUNCH_ERROR_XXX values in |error_code| if |error_code| is non-null. The -// installed brandcode must be in |partner_brandcode_list|. |shell_mode| should -// be set to one of GCAPI_INVOKED_STANDARD_SHELL or GCAPI_INVOKED_UAC_ELEVATION -// depending on whether this method is invoked from an elevated or non-elevated -// process. -BOOL __stdcall CanOfferRelaunch(const wchar_t** partner_brandcode_list, - int partner_brandcode_list_length, - int shell_mode, - DWORD* error_code); - // Function pointer type declarations to use with GetProcAddress. typedef BOOL (__stdcall *GCCC_CompatibilityCheck)(BOOL, int, DWORD *); typedef BOOL (__stdcall *GCCC_LaunchGC)(); @@ -140,10 +116,6 @@ typedef BOOL (__stdcall *GCCC_CanOfferReactivation)(const wchar_t*, typedef BOOL (__stdcall *GCCC_ReactivateChrome)(const wchar_t*, int, DWORD*); -typedef BOOL (__stdcall *GCCC_CanOfferRelaunch)(const wchar_t**, - int, - int, - DWORD*); #ifdef __cplusplus } // extern "C" |