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.
5 #ifndef CHROME_INSTALLER_GCAPI_GCAPI_H_
6 #define CHROME_INSTALLER_GCAPI_GCAPI_H_
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)
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)
25 // Error conditions for CanOfferRelaunch().
26 #define RELAUNCH_ERROR_NOTINSTALLED (1 << 0)
27 #define RELAUNCH_ERROR_INVALID_PARTNER (1 << 1)
28 #define RELAUNCH_ERROR_PINGS_SENT (1 << 2)
29 #define RELAUNCH_ERROR_NOTDORMANT (1 << 3)
30 #define RELAUNCH_ERROR_ALREADY_RELAUNCHED (1 << 4)
31 #define RELAUNCH_ERROR_INVALID_INPUT (1 << 5)
32 #define RELAUNCH_ERROR_RELAUNCH_FAILED (1 << 6)
34 // Flags to indicate how GCAPI is invoked
35 #define GCAPI_INVOKED_STANDARD_SHELL (1 << 0)
36 #define GCAPI_INVOKED_UAC_ELEVATION (1 << 1)
42 // The minimum number of days an installation can be dormant before reactivation
44 const int kReactivationMinDaysDormant
= 50;
46 // The minimum number of days an installation can be dormant before a relaunch
48 const int kRelaunchMinDaysDormant
= 30;
50 // This function returns TRUE if Google Chrome should be offered.
51 // If the return is FALSE, the |reasons| DWORD explains why. If you don't care
52 // for the reason, you can pass NULL for |reasons|.
53 // |set_flag| indicates whether a flag should be set indicating that Chrome was
54 // offered within the last six months; if passed FALSE, this method will not
55 // set the flag even if Chrome can be offered. If passed TRUE, this method
56 // will set the flag only if Chrome can be offered.
57 // |shell_mode| should be set to one of GCAPI_INVOKED_STANDARD_SHELL or
58 // GCAPI_INVOKED_UAC_ELEVATION depending on whether this method is invoked
59 // from an elevated or non-elevated process.
60 BOOL __stdcall
GoogleChromeCompatibilityCheck(BOOL set_flag
,
64 // This function launches Google Chrome after a successful install. Make
65 // sure COM library is NOT initialized before you call this function (so if
66 // you called CoInitialize, call CoUninitialize before calling this function).
67 BOOL __stdcall
LaunchGoogleChrome();
69 // This function launches Google Chrome after a successful install, ensuring
70 // that any windows that it makes are shunted to the background. Make sure COM
71 // library is NOT initialized before you call this function (so if you called
72 // CoInitialize, call CoUninitialize before calling this function).
73 BOOL __stdcall
LaunchGoogleChromeInBackground();
75 // This function launches Google Chrome after a successful install at the given
76 // x,y coordinates with size height,length. Pass -1 for x and y to avoid moving
77 // the window. Pass -1 for width and height to avoid resizing the window. Set
78 // in_background to true to move Google Chrome behind all other windows or false
79 // to have it appear at the default z-order. Make sure that COM is NOT
80 // initialized before you call this function (so if you called CoInitialize,
81 // call CoUninitialize before calling this function). This call is synchronous,
82 // meaning it waits for Chrome to launch and appear to resize it before
84 BOOL __stdcall
LaunchGoogleChromeWithDimensions(int x
,
90 // This function returns the number of days since Google Chrome was last run by
91 // the current user. If both user-level and machine-wide installations are
92 // present on the system, it will return the lowest last-run-days count of
94 // Returns -1 if Chrome is not installed, the last run date is in the future,
95 // or we are otherwise unable to determine how long since Chrome was last
97 int __stdcall
GoogleChromeDaysSinceLastRun();
99 // Returns true if a vendor with the specified |brand_code| may offer
100 // reactivation at this time. Returns false if the vendor may not offer
101 // reactivation at this time, and places one of the REACTIVATE_ERROR_XXX values
102 // in |error_code| if |error_code| is non-null.
103 // |shell_mode| should be set to one of GCAPI_INVOKED_STANDARD_SHELL or
104 // GCAPI_INVOKED_UAC_ELEVATION depending on whether this method is invoked
105 // from an elevated or non-elevated process.
106 BOOL __stdcall
CanOfferReactivation(const wchar_t* brand_code
,
110 // Attempts to reactivate Chrome for the specified |brand_code|. Returns false
111 // if reactivation fails, and places one of the REACTIVATE_ERROR_XXX values
112 // in |error_code| if |error_code| is non-null.
113 // |shell_mode| should be set to one of GCAPI_INVOKED_STANDARD_SHELL or
114 // GCAPI_INVOKED_UAC_ELEVATION depending on whether this method is invoked
115 // from an elevated or non-elevated process.
116 BOOL __stdcall
ReactivateChrome(const wchar_t* brand_code
,
120 // Returns true if a vendor may offer relaunch at this time. Returns false if
121 // the vendor may not offer relaunching at this time, and places one of the
122 // RELAUNCH_ERROR_XXX values in |error_code| if |error_code| is non-null. The
123 // installed brandcode must be in |partner_brandcode_list|. |shell_mode| should
124 // be set to one of GCAPI_INVOKED_STANDARD_SHELL or GCAPI_INVOKED_UAC_ELEVATION
125 // depending on whether this method is invoked from an elevated or non-elevated
127 BOOL __stdcall
CanOfferRelaunch(const wchar_t** partner_brandcode_list
,
128 int partner_brandcode_list_length
,
132 // Returns true if a vendor may relaunch at this time (and stores that a
133 // relaunch was offered). Returns false if the vendor may not relaunch
134 // at this time, and places one of the RELAUNCH_ERROR_XXX values in |error_code|
135 // if |error_code| is non-null. As for |CanOfferRelaunch|, the installed
136 // brandcode must be in |partner_brandcode_list|. |shell_mode| should be set to
137 // one of GCAPI_INVOKED_STANDARD_SHELL or GCAPI_INVOKED_UAC_ELEVATION depending
138 // on whether this method is invoked from an elevated or non-elevated process.
139 // The |relaunch_brandcode| will be stored as the brandcode that was used for
140 // offering this relaunch.
141 BOOL __stdcall
SetRelaunchOffered(const wchar_t** partner_brandcode_list
,
142 int partner_brandcode_list_length
,
143 const wchar_t* relaunch_brandcode
,
147 // Function pointer type declarations to use with GetProcAddress.
148 typedef BOOL (__stdcall
*GCCC_CompatibilityCheck
)(BOOL
, int, DWORD
*);
149 typedef BOOL (__stdcall
*GCCC_LaunchGC
)();
150 typedef BOOL (__stdcall
*GCCC_LaunchGoogleChromeInBackground
)();
151 typedef BOOL (__stdcall
*GCCC_LaunchGCWithDimensions
)(int, int, int, int, bool);
152 typedef int (__stdcall
*GCCC_GoogleChromeDaysSinceLastRun
)();
153 typedef BOOL (__stdcall
*GCCC_CanOfferReactivation
)(const wchar_t*,
156 typedef BOOL (__stdcall
*GCCC_ReactivateChrome
)(const wchar_t*,
159 typedef BOOL (__stdcall
*GCCC_CanOfferRelaunch
)(const wchar_t**,
163 typedef BOOL (__stdcall
*GCCC_SetRelaunchOffered
)(const wchar_t**,
173 #endif // CHROME_INSTALLER_GCAPI_GCAPI_H_