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_MAC_GCAPI_H_
6#define CHROME_INSTALLER_GCAPI_MAC_GCAPI_H_
7
8// Error conditions for GoogleChromeCompatibilityCheck().
9#define GCCC_ERROR_ALREADYPRESENT                (1 << 0)
10#define GCCC_ERROR_ACCESSDENIED                  (1 << 1)
11#define GCCC_ERROR_OSNOTSUPPORTED                (1 << 2)
12#define GCCC_ERROR_ALREADYOFFERED                (1 << 3)
13#define GCCC_ERROR_INTEGRITYLEVEL                (1 << 4)
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19// This function returns nonzero if Google Chrome should be offered.
20// If the return value is 0, |reasons| explains why.  If you don't care for the
21// reason, you can pass NULL for |reasons|.
22int GoogleChromeCompatibilityCheck(unsigned* reasons);
23
24// This function installs Google Chrome in the application folder and optionally
25// sets up the brand code and master prefs.
26// |source_path| Path to an uninstalled Google Chrome.app directory, for example
27//               in a mounted dmg, in file system representation.
28// |brand_code| If not NULL, a string containing the brand code Google Chrome
29//              should use. Has no effect if Google Chrome has an embedded brand
30//              code. Overwrites existing brand files.
31// |master_prefs_contents| If not NULL, the _contents_ of a master prefs file
32//                         Google Chrome should use. This is not a path.
33//                         Overwrites existing master pref files.
34// Returns nonzero if Google Chrome was successfully copied. If copying
35// succeeded but writing of master prefs, brand code, or other noncrucial
36// setup tasks fail, this still returns nonzero.
37// Returns 0 if the installation failed, for example if Google Chrome was
38// already installed, or no disk space was left.
39int InstallGoogleChrome(const char* source_path,
40                        const char* brand_code,
41                        const char* master_prefs_contents,
42                        unsigned master_prefs_contents_size);
43
44// This function launches Google Chrome after a successful install, or it does
45// a best-effort search to launch an existing installation if
46// InstallGoogleChrome() returned GCCC_ERROR_ALREADYPRESENT.
47int LaunchGoogleChrome();
48
49#ifdef __cplusplus
50}  // extern "C"
51#endif
52
53#endif  // CHROME_INSTALLER_GCAPI_MAC_GCAPI_H_
54