0

[google_apis] Crash if the API key was already configured

This CL crashes the application if the API key is overriden after its
first usage.

Bug: 40164066
Change-Id: I28e978c90589f9df49f0cda903734c9f3cba5064
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5837037
Reviewed-by: Alex Ilin <alexilin@chromium.org>
Commit-Queue: Mihai Sardarescu <msarda@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1351396}
This commit is contained in:
Mihai Sardarescu
2024-09-05 14:13:13 +00:00
committed by Chromium LUCI CQ
parent 80f7b98ee0
commit dc3ef35dfb
2 changed files with 9 additions and 4 deletions

@ -113,10 +113,11 @@ COMPONENT_EXPORT(GOOGLE_APIS) std::string GetFresnelAPIKey();
#endif
#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)
// Sets the API key. This should be called as early as possible before this
// API key is even accessed. It must be called before GetAPIKey.
// TODO(crbug.com/40164066): Enforce this is called before GetAPIKey.
COMPONENT_EXPORT(GOOGLE_APIS) void SetAPIKey(const std::string& 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.