summaryrefslogtreecommitdiffstats
path: root/chrome/installer/gcapi
diff options
context:
space:
mode:
authormacourteau@chromium.org <macourteau@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-16 01:27:53 +0000
committermacourteau@chromium.org <macourteau@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-16 01:27:53 +0000
commitd3144cdf62746a49ade15a33375fc8d903a84d46 (patch)
tree8b967a51225df177bf0ef6340e0a7bcc3f213474 /chrome/installer/gcapi
parent0f7d3ebe03831208c8863bf7c372b21c07d1f6fc (diff)
downloadchromium_src-d3144cdf62746a49ade15a33375fc8d903a84d46.zip
chromium_src-d3144cdf62746a49ade15a33375fc8d903a84d46.tar.gz
chromium_src-d3144cdf62746a49ade15a33375fc8d903a84d46.tar.bz2
Fixes the comments which were triggering the android webview_licenses error.
Re-landing as the original CL had to be reverted. BUG=266926 TBR=robertshield@chromium.org, rogerta@chromium.org Review URL: https://codereview.chromium.org/22914011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217905 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/gcapi')
-rw-r--r--chrome/installer/gcapi/gcapi.cc111
-rw-r--r--chrome/installer/gcapi/gcapi.def1
-rw-r--r--chrome/installer/gcapi/gcapi.h28
3 files changed, 121 insertions, 19 deletions
diff --git a/chrome/installer/gcapi/gcapi.cc b/chrome/installer/gcapi/gcapi.cc
index c4a2d6e..f7c8794 100644
--- a/chrome/installer/gcapi/gcapi.cc
+++ b/chrome/installer/gcapi/gcapi.cc
@@ -38,6 +38,7 @@
#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"
@@ -69,6 +70,12 @@ 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_";
@@ -183,28 +190,29 @@ bool CanReOfferChrome(BOOL set_flag) {
return can_re_offer;
}
-// 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);
+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;
}
- return false;
-}
-bool IsChromeInstalled(HKEY root_key) {
- wchar_t version[64];
- size_t size = _countof(version);
- return ReadValueFromRegistry(root_key, kChromeRegClientsKey,
- kChromeRegVersion, version, &size);
+ if (key.Open(HKEY_CURRENT_USER, kC1FPendingKey, KEY_READ) == ERROR_SUCCESS &&
+ key.ReadValueDW(kC1FKey, &value) == ERROR_SUCCESS &&
+ value == 1) {
+ return true;
+ }
+
+ return false;
}
enum WindowsVersion {
@@ -666,3 +674,68 @@ 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 e6abeae..f26c826 100644
--- a/chrome/installer/gcapi/gcapi.def
+++ b/chrome/installer/gcapi/gcapi.def
@@ -8,3 +8,4 @@ EXPORTS
GoogleChromeDaysSinceLastRun
CanOfferReactivation
ReactivateChrome
+ CanOfferRelaunch
diff --git a/chrome/installer/gcapi/gcapi.h b/chrome/installer/gcapi/gcapi.h
index 1951c5b..8a9486b 100644
--- a/chrome/installer/gcapi/gcapi.h
+++ b/chrome/installer/gcapi/gcapi.h
@@ -22,6 +22,14 @@
#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)
@@ -34,6 +42,10 @@ 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|.
@@ -104,6 +116,18 @@ 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)();
@@ -116,6 +140,10 @@ 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"