#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "google_apis/google_api_keys.h"
#include <stddef.h>
#include <memory>
#include <string>
#include "base/command_line.h"
#include "base/environment.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/strings/stringize_macros.h"
#include "base/version_info/channel.h"
#include "build/branding_buildflags.h"
#include "build/chromeos_buildflags.h"
#include "google_apis/buildflags.h"
#include "google_apis/gaia/gaia_config.h"
#include "google_apis/gaia/gaia_switches.h"
#include "google_apis/google_api_keys_utils.h"
#if BUILDFLAG(IS_APPLE)
#include "google_apis/google_api_keys_mac.h"
#endif
#if defined(USE_OFFICIAL_GOOGLE_API_KEYS)
#include "google_apis/internal/google_chrome_api_keys.h"
#include "google_apis/internal/metrics_signing_key.h"
#endif
#define DUMMY_API_TOKEN …
#if !defined(GOOGLE_API_KEY)
#define GOOGLE_API_KEY …
#endif
#if !defined(GOOGLE_METRICS_SIGNING_KEY)
#define GOOGLE_METRICS_SIGNING_KEY …
#endif
#if !defined(GOOGLE_CLIENT_ID_MAIN)
#define GOOGLE_CLIENT_ID_MAIN …
#endif
#if !defined(GOOGLE_CLIENT_SECRET_MAIN)
#define GOOGLE_CLIENT_SECRET_MAIN …
#endif
#if !defined(GOOGLE_CLIENT_ID_REMOTING)
#define GOOGLE_CLIENT_ID_REMOTING …
#endif
#if !defined(GOOGLE_CLIENT_SECRET_REMOTING)
#define GOOGLE_CLIENT_SECRET_REMOTING …
#endif
#if !defined(GOOGLE_CLIENT_ID_REMOTING_HOST)
#define GOOGLE_CLIENT_ID_REMOTING_HOST …
#endif
#if !defined(GOOGLE_CLIENT_SECRET_REMOTING_HOST)
#define GOOGLE_CLIENT_SECRET_REMOTING_HOST …
#endif
#if BUILDFLAG(IS_ANDROID)
#if !defined(GOOGLE_API_KEY_ANDROID_NON_STABLE)
#define GOOGLE_API_KEY_ANDROID_NON_STABLE …
#endif
#endif
#if !defined(GOOGLE_API_KEY_REMOTING)
#define GOOGLE_API_KEY_REMOTING …
#endif
#if !defined(GOOGLE_API_KEY_SODA)
#define GOOGLE_API_KEY_SODA …
#endif
#if !BUILDFLAG(IS_ANDROID)
#if !defined(GOOGLE_API_KEY_HATS)
#define GOOGLE_API_KEY_HATS …
#endif
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
#if !defined(GOOGLE_API_KEY_SHARING)
#define GOOGLE_API_KEY_SHARING …
#endif
#if !defined(GOOGLE_API_KEY_READ_ALOUD)
#define GOOGLE_API_KEY_READ_ALOUD …
#endif
#if !defined(GOOGLE_API_KEY_FRESNEL)
#define GOOGLE_API_KEY_FRESNEL …
#endif
#endif
#if !defined(GOOGLE_DEFAULT_CLIENT_ID)
#define GOOGLE_DEFAULT_CLIENT_ID …
#endif
#if !defined(GOOGLE_DEFAULT_CLIENT_SECRET)
#define GOOGLE_DEFAULT_CLIENT_SECRET …
#endif
namespace google_apis {
const char kAPIKeysDevelopersHowToURL[] = …;
class APIKeyCache { … };
static base::LazyInstance<APIKeyCache>::DestructorAtExit g_api_key_cache = …;
bool HasAPIKeyConfigured() { … }
std::string GetAPIKey(::version_info::Channel channel) { … }
std::string GetAPIKey() { … }
std::string GetRemotingAPIKey() { … }
std::string GetSodaAPIKey() { … }
#if !BUILDFLAG(IS_ANDROID)
std::string GetHatsAPIKey() { … }
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
std::string GetSharingAPIKey() {
return g_api_key_cache.Get().api_key_sharing();
}
std::string GetReadAloudAPIKey() {
return g_api_key_cache.Get().api_key_read_aloud();
}
std::string GetFresnelAPIKey() {
return g_api_key_cache.Get().api_key_fresnel();
}
#endif
#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
void SetAPIKey(const std::string& api_key) {
g_api_key_cache.Get().set_api_key(api_key);
}
#endif
std::string GetMetricsKey() { … }
bool HasOAuthClientConfigured() { … }
std::string GetOAuth2ClientID(OAuth2Client client) { … }
std::string GetOAuth2ClientSecret(OAuth2Client client) { … }
#if BUILDFLAG(IS_IOS)
void SetOAuth2ClientID(OAuth2Client client, const std::string& client_id) {
g_api_key_cache.Get().SetClientID(client, client_id);
}
void SetOAuth2ClientSecret(OAuth2Client client,
const std::string& client_secret) {
g_api_key_cache.Get().SetClientSecret(client, client_secret);
}
#endif
bool IsGoogleChromeAPIKeyUsed() { … }
}