0

[google_apis] Add BUILDFLAG for whether to define SetAPIKey()

Replace iOS and Fuchsia conditions with a new
SUPPORT_EXTERNAL_GOOGLE_API_KEY BUILDFLAG so the logic is only defined
in one location and can be referenced outside //google_apis.

No build logic is changed.
`#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_FUCHSIA)` is replaced with
`#if BUILDFLAG(SUPPORT_EXTERNAL_GOOGLE_API_KEY)`, which is defined as
`is_ios || is_fuchsia`.

Bug: 1294915
Change-Id: I9a57727d7df86bd22f04c32946af4b49b1b69f29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3756795
Auto-Submit: David Dorwin <ddorwin@chromium.org>
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Commit-Queue: David Dorwin <ddorwin@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1045946}
This commit is contained in:
David Dorwin
2022-09-12 19:11:48 +00:00
committed by Chromium LUCI CQ
parent 56657e989e
commit c5f373c3a2
4 changed files with 23 additions and 3 deletions

@ -10,6 +10,7 @@
#include <string>
#include "build/build_config.h"
#include "google_apis/buildflags.h"
// These functions enable you to retrieve keys to use for Google APIs
// such as Translate and Safe Browsing.
@ -89,7 +90,7 @@ std::string GetReadAloudAPIKey();
// Retrieves the Fresnel API Key.
std::string GetFresnelAPIKey();
#if BUILDFLAG(IS_IOS) || BUILDFLAG(IS_FUCHSIA)
#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(https://crbug.com/1166007): Enforce this is called before GetAPIKey.