gcapi.h revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
1// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#ifndef CHROME_INSTALLER_GCAPI_GCAPI_H_ 6#define CHROME_INSTALLER_GCAPI_GCAPI_H_ 7 8#include <windows.h> 9 10// Error conditions for GoogleChromeCompatibilityCheck(). 11#define GCCC_ERROR_USERLEVELALREADYPRESENT (1 << 0) 12#define GCCC_ERROR_SYSTEMLEVELALREADYPRESENT (1 << 1) 13#define GCCC_ERROR_ACCESSDENIED (1 << 2) 14#define GCCC_ERROR_OSNOTSUPPORTED (1 << 3) 15#define GCCC_ERROR_ALREADYOFFERED (1 << 4) 16#define GCCC_ERROR_INTEGRITYLEVEL (1 << 5) 17 18// Error conditions for CanReactivateChrome(). 19#define REACTIVATE_ERROR_NOTINSTALLED (1 << 0) 20#define REACTIVATE_ERROR_NOTDORMANT (1 << 1) 21#define REACTIVATE_ERROR_ALREADY_REACTIVATED (1 << 2) 22#define REACTIVATE_ERROR_INVALID_INPUT (1 << 3) 23#define REACTIVATE_ERROR_REACTIVATION_FAILED (1 << 4) 24 25// Flags to indicate how GCAPI is invoked 26#define GCAPI_INVOKED_STANDARD_SHELL (1 << 0) 27#define GCAPI_INVOKED_UAC_ELEVATION (1 << 1) 28 29#ifdef __cplusplus 30extern "C" { 31#endif 32 33// The minimum number of days an installation can be dormant before reactivation 34// may be offered. 35const int kReactivationMinDaysDormant = 50; 36 37// This function returns TRUE if Google Chrome should be offered. 38// If the return is FALSE, the |reasons| DWORD explains why. If you don't care 39// for the reason, you can pass NULL for |reasons|. 40// |set_flag| indicates whether a flag should be set indicating that Chrome was 41// offered within the last six months; if passed FALSE, this method will not 42// set the flag even if Chrome can be offered. If passed TRUE, this method 43// will set the flag only if Chrome can be offered. 44// |shell_mode| should be set to one of GCAPI_INVOKED_STANDARD_SHELL or 45// GCAPI_INVOKED_UAC_ELEVATION depending on whether this method is invoked 46// from an elevated or non-elevated process. 47BOOL __stdcall GoogleChromeCompatibilityCheck(BOOL set_flag, 48 int shell_mode, 49 DWORD* reasons); 50 51// This function launches Google Chrome after a successful install. Make 52// sure COM library is NOT initialized before you call this function (so if 53// you called CoInitialize, call CoUninitialize before calling this function). 54BOOL __stdcall LaunchGoogleChrome(); 55 56// This function launches Google Chrome after a successful install, ensuring 57// that any windows that it makes are shunted to the background. Make sure COM 58// library is NOT initialized before you call this function (so if you called 59// CoInitialize, call CoUninitialize before calling this function). 60BOOL __stdcall LaunchGoogleChromeInBackground(); 61 62// This function launches Google Chrome after a successful install at the given 63// x,y coordinates with size height,length. Pass -1 for x and y to avoid moving 64// the window. Pass -1 for width and height to avoid resizing the window. Set 65// in_background to true to move Google Chrome behind all other windows or false 66// to have it appear at the default z-order. Make sure that COM is NOT 67// initialized before you call this function (so if you called CoInitialize, 68// call CoUninitialize before calling this function). This call is synchronous, 69// meaning it waits for Chrome to launch and appear to resize it before 70// returning. 71BOOL __stdcall LaunchGoogleChromeWithDimensions(int x, 72 int y, 73 int width, 74 int height, 75 bool in_background); 76 77// This function returns the number of days since Google Chrome was last run by 78// the current user. If both user-level and machine-wide installations are 79// present on the system, it will return the lowest last-run-days count of 80// the two. 81// Returns -1 if Chrome is not installed, the last run date is in the future, 82// or we are otherwise unable to determine how long since Chrome was last 83// launched. 84int __stdcall GoogleChromeDaysSinceLastRun(); 85 86// Returns true if a vendor with the specified |brand_code| may offer 87// reactivation at this time. Returns false if the vendor may not offer 88// reactivation at this time, and places one of the REACTIVATE_ERROR_XXX values 89// in |error_code| if |error_code| is non-null. 90// |shell_mode| should be set to one of GCAPI_INVOKED_STANDARD_SHELL or 91// GCAPI_INVOKED_UAC_ELEVATION depending on whether this method is invoked 92// from an elevated or non-elevated process. 93BOOL __stdcall CanOfferReactivation(const wchar_t* brand_code, 94 int shell_mode, 95 DWORD* error_code); 96 97// Attempts to reactivate Chrome for the specified |brand_code|. Returns false 98// if reactivation fails, and places one of the REACTIVATE_ERROR_XXX values 99// in |error_code| if |error_code| is non-null. 100// |shell_mode| should be set to one of GCAPI_INVOKED_STANDARD_SHELL or 101// GCAPI_INVOKED_UAC_ELEVATION depending on whether this method is invoked 102// from an elevated or non-elevated process. 103BOOL __stdcall ReactivateChrome(wchar_t* brand_code, 104 int shell_mode, 105 DWORD* error_code); 106 107// Function pointer type declarations to use with GetProcAddress. 108typedef BOOL (__stdcall *GCCC_CompatibilityCheck)(BOOL, int, DWORD *); 109typedef BOOL (__stdcall *GCCC_LaunchGC)(); 110typedef BOOL (__stdcall *GCCC_LaunchGoogleChromeInBackground)(); 111typedef BOOL (__stdcall *GCCC_LaunchGCWithDimensions)(int, int, int, int, bool); 112typedef int (__stdcall *GCCC_GoogleChromeDaysSinceLastRun)(); 113typedef BOOL (__stdcall *GCCC_CanOfferReactivation)(const wchar_t*, 114 int, 115 DWORD*); 116typedef BOOL (__stdcall *GCCC_ReactivateChrome)(const wchar_t*, 117 int, 118 DWORD*); 119 120#ifdef __cplusplus 121} // extern "C" 122#endif 123 124#endif // CHROME_INSTALLER_GCAPI_GCAPI_H_ 125