| OLD | NEW |
| (Empty) |
| 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_COMMON_NET_GOOGLE_APIS_GOOGLE_API_KEYS_H_ | |
| 6 #define CHROME_COMMON_NET_GOOGLE_APIS_GOOGLE_API_KEYS_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 // These functions enable you to retrieve keys to use for Google APIs | |
| 11 // such as Translate and Safe Browsing. | |
| 12 // | |
| 13 // You can retrieve either an "API key" (sometimes called a developer | |
| 14 // key) which identifies you (or the company you work for) as a | |
| 15 // developer, or you can retrieve the "client ID" and "client secret" | |
| 16 // used by you (or the company you work for) to generate OAuth2 | |
| 17 // requests. | |
| 18 // | |
| 19 // Each developer (or group of developers working together for a | |
| 20 // single company) must request a Google API key and the client ID and | |
| 21 // client secret for OAuth2. See | |
| 22 // https://developers.google.com/console/help/ and | |
| 23 // https://developers.google.com/console/. | |
| 24 // | |
| 25 // The keys must either be provided using preprocessor variables (set | |
| 26 // via e.g. ~/.gyp/include.gypi). Alternatively, they can be | |
| 27 // overridden at runtime using environment variables of the same name. | |
| 28 // | |
| 29 // The names of the preprocessor variables (or environment variables | |
| 30 // to override them at runtime) are as follows: | |
| 31 // - GOOGLE_API_KEY: The API key, a.k.a. developer key. | |
| 32 // - GOOGLE_DEFAULT_CLIENT_ID: If set, this is used as the default for | |
| 33 // all client IDs not otherwise set. This is intended only for | |
| 34 // development. | |
| 35 // - GOOGLE_DEFAULT_CLIENT_SECRET: If set, this is used as the default | |
| 36 // for all client secrets. This is intended only for development. | |
| 37 // - GOOGLE_CLIENT_ID_[client name] | |
| 38 // (e.g. GOOGLE_CLIENT_ID_CLOUD_PRINT, i.e. one for each item in the | |
| 39 // OAuth2Client enumeration below) | |
| 40 // - GOOGLE_CLIENT_SECRET_[client name] | |
| 41 // (e.g. GOOGLE_CLIENT_SECRET_CLOUD_PRINT, i.e. one for each item in | |
| 42 // the OAuth2Client enumeration below) | |
| 43 // | |
| 44 // The GOOGLE_CLIENT_ID_MAIN and GOOGLE_CLIENT_SECRET_MAIN values can | |
| 45 // also be set via the command line (this overrides any other | |
| 46 // setting). The command-line parameters are --oauth2-client-id and | |
| 47 // --oauth2-client-secret. | |
| 48 // | |
| 49 // If some of the parameters mentioned above are not provided, | |
| 50 // Chromium will still build and run, but services that require them | |
| 51 // may fail to work without warning. They should do so gracefully, | |
| 52 // similar to what would happen when a network connection is | |
| 53 // unavailable. | |
| 54 | |
| 55 namespace google_apis { | |
| 56 | |
| 57 // Retrieves the API key, a.k.a. developer key, or the empty string | |
| 58 // if not set. | |
| 59 // | |
| 60 // Note that the key should be escaped for the context you use it in, | |
| 61 // e.g. URL-escaped if you use it in a URL. | |
| 62 std::string GetAPIKey(); | |
| 63 | |
| 64 // Represents the different sets of client IDs and secrets in use. | |
| 65 enum OAuth2Client { | |
| 66 CLIENT_MAIN, // Several different features use this. | |
| 67 CLIENT_CLOUD_PRINT, | |
| 68 CLIENT_REMOTING, | |
| 69 | |
| 70 CLIENT_NUM_ITEMS // Must be last item. | |
| 71 }; | |
| 72 | |
| 73 // Retrieves the OAuth2 client ID for the specified client, or the | |
| 74 // empty string if not set. | |
| 75 // | |
| 76 // Note that the ID should be escaped for the context you use it in, | |
| 77 // e.g. URL-escaped if you use it in a URL. | |
| 78 std::string GetOAuth2ClientID(OAuth2Client client); | |
| 79 | |
| 80 // Retrieves the OAuth2 client secret for the specified client, or the | |
| 81 // empty string if not set. | |
| 82 // | |
| 83 // Note that the secret should be escaped for the context you use it | |
| 84 // in, e.g. URL-escaped if you use it in a URL. | |
| 85 std::string GetOAuth2ClientSecret(OAuth2Client client); | |
| 86 | |
| 87 } // namespace google_apis | |
| 88 | |
| 89 #endif // CHROME_COMMON_NET_GOOGLE_APIS_GOOGLE_API_KEYS_H_ | |
| OLD | NEW |