Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Unified Diff: google_apis/google_api_keys.cc

Issue 2939403002: Disable environment variable override of API keys on official builds. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | google_apis/google_api_keys_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: google_apis/google_api_keys.cc
diff --git a/google_apis/google_api_keys.cc b/google_apis/google_api_keys.cc
index ab92d1e4dccf7420e8c0b72b49b8f8343c995016..015b254b5494615b540d798ee3be0791c09c0db4 100644
--- a/google_apis/google_api_keys.cc
+++ b/google_apis/google_api_keys.cc
@@ -246,7 +246,8 @@ class APIKeyCache {
// Gets a value for a key. In priority order, this will be the value
// provided via a command-line switch, the value provided via an
// environment variable, or finally a value baked into the build.
- // |command_line_switch| may be NULL.
+ // |command_line_switch| may be NULL. Official Google Chrome builds will not
+ // use the value provided by an environment variable.
static std::string CalculateKeyValue(const char* baked_in_value,
const char* environment_variable_name,
const char* command_line_switch,
@@ -265,11 +266,17 @@ class APIKeyCache {
<< " with value " << key_value << " from Info.plist.";
}
#endif
+
+#if !defined(GOOGLE_CHROME_BUILD)
+ // Don't allow using the environment to override API keys for official
+ // Google Chrome builds. There have been reports of mangled environments
+ // affecting users (crbug.com/710575).
if (environment->GetVar(environment_variable_name, &temp)) {
key_value = temp;
VLOG(1) << "Overriding API key " << environment_variable_name
<< " with value " << key_value << " from environment variable.";
}
+#endif
if (command_line_switch && command_line->HasSwitch(command_line_switch)) {
key_value = command_line->GetSwitchValueASCII(command_line_switch);
« no previous file with comments | « no previous file | google_apis/google_api_keys_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698