fixup! [M108 Migration][API] Bring up autofill
[platform/framework/web/chromium-efl.git] / google_apis / google_api_keys.h
1 // Copyright 2012 The Chromium Authors
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 GOOGLE_APIS_GOOGLE_API_KEYS_H_
6 #define GOOGLE_APIS_GOOGLE_API_KEYS_H_
7
8 // If you add more includes to this file, you also need to add them to
9 // google_api_keys_unittest.cc.
10 #include <string>
11
12 #include "build/build_config.h"
13 #include "google_apis/buildflags.h"
14
15 // These functions enable you to retrieve keys to use for Google APIs
16 // such as Translate and Safe Browsing.
17 //
18 // You can retrieve either an "API key" (sometimes called a developer
19 // key) which identifies you (or the company you work for) as a
20 // developer, or you can retrieve the "client ID" and "client secret"
21 // used by you (or the company you work for) to generate OAuth2
22 // requests.
23 //
24 // Each developer (or group of developers working together for a
25 // single company) must request a Google API key and the client ID and
26 // client secret for OAuth2.  See
27 // https://developers.google.com/console/help/ and
28 // https://developers.google.com/console/.
29 //
30 // The keys must either be provided using preprocessor variables (set via e.g.
31 // GN args). Alternatively, they can be overridden at runtime using one of the
32 // following methods (in priority order):
33 // - Command line parameters (only for GOOGLE_CLIENT_ID_MAIN and
34 //   GOOGLE_CLIENT_SECRET_MAIN values). The command-line parameters are
35 //   --oauth2-client-id and --oauth2-client-secret.
36 // - Config file entry of the same name. Path to a config file is set via the
37 //   --gaia-config command line parameter. See google_apis/gaia/gaia_config.h
38 //   for syntax reference.
39 // - Environment variables of the same name. Environment variable overrides will
40 //   be ignored for official Google Chrome builds.
41 //
42 // The names of the preprocessor variables (or environment variables
43 // to override them at runtime in Chromium builds) are as follows:
44 // - GOOGLE_API_KEY: The API key, a.k.a. developer key.
45 // - GOOGLE_DEFAULT_CLIENT_ID: If set, this is used as the default for
46 //   all client IDs not otherwise set.  This is intended only for
47 //   development.
48 // - GOOGLE_DEFAULT_CLIENT_SECRET: If set, this is used as the default
49 //   for all client secrets.  This is intended only for development.
50 // - GOOGLE_CLIENT_ID_[client name]
51 // - GOOGLE_CLIENT_SECRET_[client name]
52 //   (e.g. GOOGLE_CLIENT_SECRET_REMOTING, i.e. one for each item in
53 //   the OAuth2Client enumeration below)
54 //
55 // If some of the parameters mentioned above are not provided,
56 // Chromium will still build and run, but services that require them
57 // may fail to work without warning.  They should do so gracefully,
58 // similar to what would happen when a network connection is
59 // unavailable.
60
61 namespace google_apis {
62
63 extern const char kAPIKeysDevelopersHowToURL[];
64
65 // Returns true if no dummy API key is set.
66 bool HasAPIKeyConfigured();
67
68 // Retrieves the API key, a.k.a. developer key, or a dummy string
69 // if not set.
70 //
71 // Note that the key should be escaped for the context you use it in,
72 // e.g. URL-escaped if you use it in a URL.
73 std::string GetAPIKey();
74
75 // Non-stable channels may have a different Google API key.
76 std::string GetNonStableAPIKey();
77
78 // Retrieves the Chrome Remote Desktop API key.
79 std::string GetRemotingAPIKey();
80
81 // Retrieves the Sharing API Key.
82 std::string GetSharingAPIKey();
83
84 // Retrieves the Speech On-Device API (SODA) API Key.
85 std::string GetSodaAPIKey();
86
87 // Retrieves the ReadAloud API Key.
88 std::string GetReadAloudAPIKey();
89
90 // Retrieves the Fresnel API Key.
91 std::string GetFresnelAPIKey();
92
93 #if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
94 // Sets the API key. This should be called as early as possible before this
95 // API key is even accessed. It must be called before GetAPIKey.
96 // TODO(https://crbug.com/1166007): Enforce this is called before GetAPIKey.
97 void SetAPIKey(const std::string& api_key);
98 #endif
99
100 // Retrieves the key used to sign metrics (UMA/UKM) uploads.
101 std::string GetMetricsKey();
102
103 // Represents the different sets of client IDs and secrets in use.
104 enum OAuth2Client {
105   CLIENT_MAIN,  // Several different features use this.
106   CLIENT_REMOTING,
107   CLIENT_REMOTING_HOST,
108
109   CLIENT_NUM_ITEMS  // Must be last item.
110 };
111
112 // Returns true if no dummy OAuth2 client ID and secret are set.
113 bool HasOAuthClientConfigured();
114
115 // Retrieves the OAuth2 client ID for the specified client, or the
116 // empty string if not set.
117 //
118 // Note that the ID should be escaped for the context you use it in,
119 // e.g. URL-escaped if you use it in a URL.
120 std::string GetOAuth2ClientID(OAuth2Client client);
121
122 // Retrieves the OAuth2 client secret for the specified client, or the
123 // empty string if not set.
124 //
125 // Note that the secret should be escaped for the context you use it
126 // in, e.g. URL-escaped if you use it in a URL.
127 std::string GetOAuth2ClientSecret(OAuth2Client client);
128
129 #if BUILDFLAG(IS_IOS)
130 // Sets the client id for the specified client. Should be called as early as
131 // possible before these ids are accessed.
132 void SetOAuth2ClientID(OAuth2Client client, const std::string& client_id);
133
134 // Sets the client secret for the specified client. Should be called as early as
135 // possible before these secrets are accessed.
136 void SetOAuth2ClientSecret(OAuth2Client client,
137                            const std::string& client_secret);
138 #endif
139 // Returns the auth token for the data reduction proxy.
140 std::string GetSpdyProxyAuthValue();
141
142 // Returns if the API key using in the current build is the one for official
143 // Google Chrome.
144 bool IsGoogleChromeAPIKeyUsed();
145
146 }  // namespace google_apis
147
148 #endif  // GOOGLE_APIS_GOOGLE_API_KEYS_H_