Migrate remaining usages of google_apis::GetNonStableAPIKey()
This CL is purely cleanup; there are no functional changes (in particular the same all callers continue to use the same API key as previously). AX-Relnotes: n/a. Bug: 40216037,355652328 Change-Id: Ic3d13df0e6b33a5e4ac76a61294f70dee1aaaf7d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5741205 Reviewed-by: Alex Ilin <alexilin@chromium.org> Reviewed-by: Sylvain Defresne <sdefresne@chromium.org> Reviewed-by: Nate Fischer <ntfschr@chromium.org> Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com> Commit-Queue: James Lee <ljjlee@google.com> Cr-Commit-Position: refs/heads/main@{#1334802}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
1a6092d117
commit
4c20facac8
android_webview/browser
chrome/browser
accessibility
ash
login
oobe_quick_start
feed
ip_protection
query_tiles
ui
components
autofill
core
browser
crowdsourcing
endpoint_fetcher
manta
password_manager
core
browser
leak_detection
google_apis
@ -38,17 +38,6 @@
|
||||
#include "net/third_party/quiche/src/quiche/blind_sign_auth/proto/blind_sign_auth_options.pb.h"
|
||||
#include "net/third_party/quiche/src/quiche/blind_sign_auth/proto/spend_token_data.pb.h"
|
||||
|
||||
namespace {
|
||||
// TODO(crbug.com/40216037): Once `google_apis::GetAPIKey()` handles this
|
||||
// logic we can remove this helper.
|
||||
std::string GetAPIKey() {
|
||||
version_info::Channel channel = version_info::android::GetChannel();
|
||||
return channel == version_info::Channel::STABLE
|
||||
? google_apis::GetAPIKey()
|
||||
: google_apis::GetNonStableAPIKey();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace android_webview {
|
||||
|
||||
AwIpProtectionConfigProvider::AwIpProtectionConfigProvider(
|
||||
@ -71,7 +60,7 @@ void AwIpProtectionConfigProvider::SetUp() {
|
||||
->GetURLLoaderFactoryForBrowserProcess()
|
||||
.get(),
|
||||
ip_protection::IpProtectionConfigProviderHelper::kWebViewIpBlinding,
|
||||
GetAPIKey());
|
||||
google_apis::GetAPIKey(version_info::android::GetChannel()));
|
||||
}
|
||||
|
||||
if (!bsa_) {
|
||||
|
@ -43,14 +43,6 @@ using LanguageInfo = language::UrlLanguageHistogram::LanguageInfo;
|
||||
|
||||
namespace {
|
||||
|
||||
// Returns the Chrome Google API key for the channel of this build.
|
||||
std::string APIKeyForChannel() {
|
||||
if (chrome::GetChannel() == version_info::Channel::STABLE) {
|
||||
return google_apis::GetAPIKey();
|
||||
}
|
||||
return google_apis::GetNonStableAPIKey();
|
||||
}
|
||||
|
||||
AccessibilityLabelsService::ImageAnnotatorBinder&
|
||||
GetImageAnnotatorBinderOverride() {
|
||||
static base::NoDestructor<AccessibilityLabelsService::ImageAnnotatorBinder>
|
||||
@ -237,7 +229,8 @@ void AccessibilityLabelsService::BindImageAnnotator(
|
||||
auto* manta_service = manta::MantaServiceFactory::GetForProfile(profile_);
|
||||
CHECK(manta_service);
|
||||
service_ = std::make_unique<image_annotation::ImageAnnotationService>(
|
||||
std::move(service_receiver), APIKeyForChannel(),
|
||||
std::move(service_receiver),
|
||||
google_apis::GetAPIKey(chrome::GetChannel()),
|
||||
profile_->GetURLLoaderFactory(),
|
||||
manta_service->CreateAnchovyProvider(),
|
||||
std::make_unique<ImageAnnotatorClient>(profile_));
|
||||
|
@ -531,9 +531,7 @@ void SecondDeviceAuthBroker::FetchChallengeBytes(
|
||||
/*post_data=*/kGetChallengeDataRequest,
|
||||
/*headers=*/std::vector<std::string>(),
|
||||
/*cors_exempt_headers=*/std::vector<std::string>(),
|
||||
/*annotation_tag=*/kChallengeDataAnnotation,
|
||||
/*is_stable_channel=*/chrome::GetChannel() ==
|
||||
version_info::Channel::STABLE);
|
||||
/*annotation_tag=*/kChallengeDataAnnotation, chrome::GetChannel());
|
||||
|
||||
metrics_.RecordChallengeBytesRequested();
|
||||
endpoint_fetcher_->PerformRequest(
|
||||
@ -592,9 +590,7 @@ void SecondDeviceAuthBroker::FetchAuthCode(
|
||||
CreateStartSessionRequestData(fido_assertion_info, certificate),
|
||||
/*headers=*/std::vector<std::string>(),
|
||||
/*cors_exempt_headers=*/std::vector<std::string>(),
|
||||
/*annotation_tag=*/kStartSessionAnnotation,
|
||||
/*is_stable_channel=*/chrome::GetChannel() ==
|
||||
version_info::Channel::STABLE);
|
||||
/*annotation_tag=*/kStartSessionAnnotation, chrome::GetChannel());
|
||||
|
||||
metrics_.RecordGaiaAuthenticationStarted();
|
||||
endpoint_fetcher_->PerformRequest(
|
||||
|
@ -199,10 +199,7 @@ FeedServiceFactory::BuildServiceInstanceForBrowserContext(
|
||||
IdentityManagerFactory::GetForProfile(profile);
|
||||
std::string api_key;
|
||||
if (google_apis::IsGoogleChromeAPIKeyUsed()) {
|
||||
bool is_stable_channel =
|
||||
chrome::GetChannel() == version_info::Channel::STABLE;
|
||||
api_key = is_stable_channel ? google_apis::GetAPIKey()
|
||||
: google_apis::GetNonStableAPIKey();
|
||||
api_key = google_apis::GetAPIKey(chrome::GetChannel());
|
||||
}
|
||||
|
||||
scoped_refptr<base::SequencedTaskRunner> background_task_runner =
|
||||
|
@ -38,16 +38,6 @@
|
||||
#include "net/third_party/quiche/src/quiche/blind_sign_auth/proto/blind_sign_auth_options.pb.h"
|
||||
#include "net/third_party/quiche/src/quiche/blind_sign_auth/proto/spend_token_data.pb.h"
|
||||
|
||||
namespace {
|
||||
// TODO(crbug.com/40216037): Once `google_apis::GetAPIKey()` handles this
|
||||
// logic we can remove this helper.
|
||||
std::string GetAPIKey() {
|
||||
return chrome::GetChannel() == version_info::Channel::STABLE
|
||||
? google_apis::GetAPIKey()
|
||||
: google_apis::GetNonStableAPIKey();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
IpProtectionConfigProvider::IpProtectionConfigProvider(
|
||||
signin::IdentityManager* identity_manager,
|
||||
privacy_sandbox::TrackingProtectionSettings* tracking_protection_settings,
|
||||
@ -79,7 +69,7 @@ void IpProtectionConfigProvider::SetUp() {
|
||||
std::make_unique<ip_protection::IpProtectionProxyConfigFetcher>(
|
||||
url_loader_factory_.get(),
|
||||
ip_protection::IpProtectionConfigProviderHelper::kChromeIpBlinding,
|
||||
GetAPIKey());
|
||||
google_apis::GetAPIKey(chrome::GetChannel()));
|
||||
}
|
||||
if (!bsa_) {
|
||||
if (!blind_sign_auth_) {
|
||||
|
@ -35,16 +35,6 @@
|
||||
#endif
|
||||
|
||||
namespace query_tiles {
|
||||
namespace {
|
||||
|
||||
std::string GetGoogleAPIKey() {
|
||||
bool is_stable_channel =
|
||||
chrome::GetChannel() == version_info::Channel::STABLE;
|
||||
return is_stable_channel ? google_apis::GetAPIKey()
|
||||
: google_apis::GetNonStableAPIKey();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
TileServiceFactory* TileServiceFactory::GetInstance() {
|
||||
@ -105,11 +95,12 @@ std::unique_ptr<KeyedService> TileServiceFactory::BuildServiceInstanceFor(
|
||||
default_server_url =
|
||||
base::android::ConvertJavaStringToUTF8(env, j_server_url);
|
||||
#endif
|
||||
return CreateTileService(image_fetcher_service, db_provider, storage_dir,
|
||||
background_task_scheduler, accept_languanges,
|
||||
GetCountryCode(), GetGoogleAPIKey(), client_version,
|
||||
default_server_url, url_loader_factory,
|
||||
ProfileKey::FromSimpleFactoryKey(key)->GetPrefs());
|
||||
return CreateTileService(
|
||||
image_fetcher_service, db_provider, storage_dir,
|
||||
background_task_scheduler, accept_languanges, GetCountryCode(),
|
||||
google_apis::GetAPIKey(chrome::GetChannel()), client_version,
|
||||
default_server_url, url_loader_factory,
|
||||
ProfileKey::FromSimpleFactoryKey(key)->GetPrefs());
|
||||
}
|
||||
|
||||
} // namespace query_tiles
|
||||
|
@ -796,9 +796,7 @@ void LensOverlayQueryController::FetchEndpoint(
|
||||
/*post_data=*/request_data_string,
|
||||
/*headers=*/headers,
|
||||
/*cors_exempt_headers=*/cors_exempt_headers,
|
||||
/*annotation_tag=*/kTrafficAnnotationTag,
|
||||
/*is_stable_channel=*/chrome::GetChannel() ==
|
||||
version_info::Channel::STABLE);
|
||||
/*annotation_tag=*/kTrafficAnnotationTag, chrome::GetChannel());
|
||||
EndpointFetcher* fetcher = endpoint_fetcher.get();
|
||||
base::SequencedTaskRunner::GetCurrentDefault()->PostTask(
|
||||
FROM_HERE, base::BindOnce(std::move(fetcher_created_callback),
|
||||
|
@ -97,9 +97,7 @@ std::unique_ptr<EndpointFetcher> CreateEndpointFetcher(
|
||||
/*post_data=*/"",
|
||||
/*headers=*/std::vector<std::string>(),
|
||||
/*cors_exempt_headers=*/std::vector<std::string>(),
|
||||
/*annotation_tag=*/annotation_tag,
|
||||
/*is_stable_channel=*/chrome::GetChannel() ==
|
||||
version_info::Channel::STABLE);
|
||||
/*annotation_tag=*/annotation_tag, chrome::GetChannel());
|
||||
}
|
||||
|
||||
const base::Value::List* FindList(
|
||||
|
@ -567,10 +567,7 @@ std::string GetAPIKeyForUrl(version_info::Channel channel) {
|
||||
}
|
||||
|
||||
// Get the API key from Chrome baked keys.
|
||||
if (channel == version_info::Channel::STABLE) {
|
||||
return google_apis::GetAPIKey();
|
||||
}
|
||||
return google_apis::GetNonStableAPIKey();
|
||||
return google_apis::GetAPIKey(channel);
|
||||
}
|
||||
|
||||
std::optional<std::vector<variations::VariationID>>& GetActiveExperiments() {
|
||||
|
@ -15,6 +15,7 @@ source_set("endpoint_fetcher") {
|
||||
"//components/signin/public/identity_manager",
|
||||
"//components/version_info:channel",
|
||||
"//google_apis",
|
||||
"//google_apis/common",
|
||||
"//net",
|
||||
"//services/data_decoder/public/cpp",
|
||||
"//services/network/public/cpp",
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "components/signin/public/identity_manager/access_token_info.h"
|
||||
#include "components/signin/public/identity_manager/identity_manager.h"
|
||||
#include "components/version_info/channel.h"
|
||||
#include "google_apis/common/api_key_request_util.h"
|
||||
#include "google_apis/gaia/gaia_urls.h"
|
||||
#include "google_apis/google_api_keys.h"
|
||||
#include "net/http/http_status_code.h"
|
||||
@ -60,7 +61,7 @@ EndpointFetcher::EndpointFetcher(
|
||||
const std::vector<std::string>& headers,
|
||||
const std::vector<std::string>& cors_exempt_headers,
|
||||
const net::NetworkTrafficAnnotationTag& annotation_tag,
|
||||
bool is_stable_channel)
|
||||
version_info::Channel channel)
|
||||
: auth_type_(CHROME_API_KEY),
|
||||
url_(url),
|
||||
http_method_(http_method),
|
||||
@ -74,7 +75,7 @@ EndpointFetcher::EndpointFetcher(
|
||||
identity_manager_(nullptr),
|
||||
consent_level_(std::nullopt),
|
||||
sanitize_response_(true),
|
||||
is_stable_channel_(is_stable_channel) {}
|
||||
channel_(channel) {}
|
||||
|
||||
EndpointFetcher::EndpointFetcher(
|
||||
const scoped_refptr<network::SharedURLLoaderFactory>& url_loader_factory,
|
||||
@ -233,10 +234,7 @@ void EndpointFetcher::PerformRequest(
|
||||
base::StringPrintf("Bearer %s", key));
|
||||
break;
|
||||
case CHROME_API_KEY: {
|
||||
std::string api_key = is_stable_channel_
|
||||
? google_apis::GetAPIKey()
|
||||
: google_apis::GetNonStableAPIKey();
|
||||
resource_request->headers.SetHeader("x-goog-api-key", api_key);
|
||||
google_apis::AddDefaultAPIKeyToRequest(*resource_request, channel_);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -32,6 +32,10 @@ struct AccessTokenInfo;
|
||||
class IdentityManager;
|
||||
} // namespace signin
|
||||
|
||||
namespace version_info {
|
||||
enum class Channel;
|
||||
}
|
||||
|
||||
class GoogleServiceAuthError;
|
||||
class GURL;
|
||||
|
||||
@ -91,7 +95,7 @@ class EndpointFetcher {
|
||||
const std::vector<std::string>& headers,
|
||||
const std::vector<std::string>& cors_exempt_headers,
|
||||
const net::NetworkTrafficAnnotationTag& annotation_tag,
|
||||
bool is_stable_channel);
|
||||
version_info::Channel channel);
|
||||
|
||||
// Constructor if no authentication is needed.
|
||||
EndpointFetcher(
|
||||
@ -181,7 +185,7 @@ class EndpointFetcher {
|
||||
// null if `identity_manager_` is null.
|
||||
const std::optional<signin::ConsentLevel> consent_level_;
|
||||
bool sanitize_response_;
|
||||
bool is_stable_channel_;
|
||||
version_info::Channel channel_;
|
||||
|
||||
// Members set in Fetch
|
||||
std::unique_ptr<const signin::PrimaryAccountAccessTokenFetcher>
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "components/manta/base_provider.h"
|
||||
|
||||
#include "base/containers/fixed_flat_map.h"
|
||||
#include "base/version_info/channel.h"
|
||||
#include "components/manta/proto/manta.pb.h"
|
||||
|
||||
namespace manta {
|
||||
@ -157,7 +158,7 @@ std::unique_ptr<EndpointFetcher> BaseProvider::CreateEndpointFetcherForDemoMode(
|
||||
/*cors_exempt_headers=*/std::vector<std::string>(),
|
||||
/*annotation_tag=*/annotation_tag,
|
||||
// ChromeOS always uses the stable channel API key
|
||||
/*is_stable_channel=*/true);
|
||||
version_info::Channel::STABLE);
|
||||
}
|
||||
|
||||
} // namespace manta
|
||||
|
@ -25,12 +25,7 @@ std::optional<std::string> GetAPIKey(bool signed_in_user,
|
||||
if (signed_in_user) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
if (channel == version_info::Channel::STABLE) {
|
||||
return google_apis::GetAPIKey();
|
||||
}
|
||||
|
||||
return google_apis::GetNonStableAPIKey();
|
||||
return google_apis::GetAPIKey(channel);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -393,18 +393,15 @@ bool HasAPIKeyConfigured() {
|
||||
}
|
||||
|
||||
std::string GetAPIKey(::version_info::Channel channel) {
|
||||
return channel == ::version_info::Channel::STABLE ? GetAPIKey()
|
||||
: GetNonStableAPIKey();
|
||||
return channel == ::version_info::Channel::STABLE
|
||||
? GetAPIKey()
|
||||
: g_api_key_cache.Get().api_key_non_stable();
|
||||
}
|
||||
|
||||
std::string GetAPIKey() {
|
||||
return g_api_key_cache.Get().api_key();
|
||||
}
|
||||
|
||||
std::string GetNonStableAPIKey() {
|
||||
return g_api_key_cache.Get().api_key_non_stable();
|
||||
}
|
||||
|
||||
std::string GetRemotingAPIKey() {
|
||||
return g_api_key_cache.Get().api_key_remoting();
|
||||
}
|
||||
|
@ -89,12 +89,6 @@ std::string GetAPIKey(version_info::Channel channel);
|
||||
// distribution channel instead of calling this function directly.
|
||||
COMPONENT_EXPORT(GOOGLE_APIS) std::string GetAPIKey();
|
||||
|
||||
// Non-stable channels may have a different Google API key.
|
||||
//
|
||||
// DEPRECATED: Use `GetAPIKey(channel)` to get the right key for your
|
||||
// distribution channel instead of calling this function directly.
|
||||
COMPONENT_EXPORT(GOOGLE_APIS) std::string GetNonStableAPIKey();
|
||||
|
||||
// Retrieves the Chrome Remote Desktop API key.
|
||||
COMPONENT_EXPORT(GOOGLE_APIS) std::string GetRemotingAPIKey();
|
||||
|
||||
|
Reference in New Issue
Block a user