
This CLs adds the capability to override the API key via a feature parameter. This takes precedence over the baked-in value of the APIKey (including the value in the plist file on Apple platforms). Note: This CL also removes the google_apis/google_api_keys.cc and instead simply includes google_apis/google_api_keys-inc.cc in the source files in google_apis/BUILD. This ensures that the file is properly tracked by the build system and appears in IDEs (e.g. Xcode) and thus can be used during bebugging. Bug: 333064918 Change-Id: Id146d73ca51bba49f8d7680d80cb2c13cc005225 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5424132 Reviewed-by: Alex Ilin <alexilin@chromium.org> Commit-Queue: Mihai Sardarescu <msarda@chromium.org> Cr-Commit-Position: refs/heads/main@{#1291846}
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
// Copyright 2024 The Chromium Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "google_apis/google_api_keys_utils.h"
|
|
|
|
#include "base/feature_list.h"
|
|
#include "base/features.h"
|
|
#include "base/metrics/field_trial_params.h"
|
|
#include "base/metrics/histogram_functions.h"
|
|
|
|
namespace google_apis {
|
|
|
|
namespace {
|
|
|
|
BASE_FEATURE(kOverrideAPIKeyFeature,
|
|
"OverrideAPIKey",
|
|
base::FEATURE_DISABLED_BY_DEFAULT);
|
|
|
|
const base::FeatureParam<std::string> kOverrideAPIKeyFeatureParam{
|
|
&kOverrideAPIKeyFeature, /*name=*/"api_key", /*default_value=*/""};
|
|
|
|
} // namespace
|
|
|
|
std::string GetAPIKeyOverrideViaFeature() {
|
|
if (base::FeatureList::IsEnabled(kOverrideAPIKeyFeature)) {
|
|
std::string override_api_key = kOverrideAPIKeyFeatureParam.Get();
|
|
if (!override_api_key.empty()) {
|
|
return override_api_key;
|
|
}
|
|
}
|
|
return std::string();
|
|
}
|
|
|
|
void LogAPIKeysMatchHistogram(bool api_keys_match) {
|
|
base::UmaHistogramBoolean("Signin.APIKeyMatchesFeatureOnStartup",
|
|
api_keys_match);
|
|
}
|
|
|
|
} // namespace google_apis
|