[google_apis] Crash if the API key was already configured
This CL crashes the application if the API key is overridden after its first usage. Bug: 40164066 Change-Id: I71044d1d5a7e6f2f808b85fa23013b23ee411469 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5890974 Reviewed-by: David Dorwin <ddorwin@chromium.org> Reviewed-by: Alex Ilin <alexilin@chromium.org> Reviewed-by: Sylvain Defresne <sdefresne@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Commit-Queue: Mihai Sardarescu <msarda@chromium.org> Cr-Commit-Position: refs/heads/main@{#1373212}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
fa7f288e2c
commit
6075bf2174
fuchsia_web/webengine
google_apis
ios/web_view/internal
@ -116,14 +116,6 @@ COMPONENT_EXPORT(GOOGLE_APIS) const std::string& GetFresnelAPIKey();
|
||||
COMPONENT_EXPORT(GOOGLE_APIS) const std::string& GetBocaAPIKey();
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
|
||||
// Sets the API key.
|
||||
//
|
||||
// Note: This function must be called before any call to GetAPIKey().
|
||||
COMPONENT_EXPORT(GOOGLE_APIS)
|
||||
void SetAPIKey(const std::string& api_key);
|
||||
#endif
|
||||
|
||||
// Retrieves the key used to sign metrics (UMA/UKM) uploads.
|
||||
COMPONENT_EXPORT(GOOGLE_APIS) const std::string& GetMetricsKey();
|
||||
|
||||
@ -155,23 +147,37 @@ const std::string& GetOAuth2ClientID(OAuth2Client client);
|
||||
COMPONENT_EXPORT(GOOGLE_APIS)
|
||||
const std::string& GetOAuth2ClientSecret(OAuth2Client client);
|
||||
|
||||
#if BUILDFLAG(IS_IOS)
|
||||
// Sets the client id for the specified client. Should be called as early as
|
||||
// possible before these ids are accessed.
|
||||
COMPONENT_EXPORT(GOOGLE_APIS)
|
||||
void SetOAuth2ClientID(OAuth2Client client, const std::string& client_id);
|
||||
|
||||
// Sets the client secret for the specified client. Should be called as early as
|
||||
// possible before these secrets are accessed.
|
||||
COMPONENT_EXPORT(GOOGLE_APIS)
|
||||
void SetOAuth2ClientSecret(OAuth2Client client,
|
||||
const std::string& client_secret);
|
||||
#endif
|
||||
|
||||
// Returns if the API key using in the current build is the one for official
|
||||
// Google Chrome.
|
||||
COMPONENT_EXPORT(GOOGLE_APIS) bool IsGoogleChromeAPIKeyUsed();
|
||||
|
||||
#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
|
||||
// Initializes the API keys with default values and overrides the main APIKey
|
||||
// with `api_key`.
|
||||
//
|
||||
// Note: Following this call, `GetApiKey()` and `GetAPIKey(channel)` will
|
||||
// return `api_key`. This function does not override the other API keys
|
||||
// or client IDS & client secrets.
|
||||
COMPONENT_EXPORT(GOOGLE_APIS)
|
||||
void InitializeAndOverrideAPIKey(const std::string& api_key);
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_IOS)
|
||||
// Initializes the API keys with default values and overrides the `APIKey` with
|
||||
// `api_key`, all the client IDs with `client_id` and all client secrets with
|
||||
// `client_secret`.
|
||||
//
|
||||
// Note: Following this call, `GetApiKey()` and `GetAPIKey(channel)` will
|
||||
// return `api_key`, `GetOAuth2ClientID(*)` will return 'client_id' and
|
||||
// `GetOAuth2ClientSecret(*)` will return `client_secret`. This function does
|
||||
// not override the other API keys.
|
||||
COMPONENT_EXPORT(GOOGLE_APIS)
|
||||
void InitializeAndOverrideAPIKeyAndOAuthClient(
|
||||
const std::string& api_key,
|
||||
const std::string& client_id,
|
||||
const std::string& client_secret);
|
||||
#endif
|
||||
|
||||
// Sets a testing global instance of `ApiKeyCache` and returns a scoped object
|
||||
// that will restore the previous value once destroyed.
|
||||
COMPONENT_EXPORT(GOOGLE_APIS)
|
||||
|
Reference in New Issue
Block a user