diff options
author | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-17 17:01:39 +0000 |
---|---|---|
committer | joi@chromium.org <joi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-17 17:01:39 +0000 |
commit | 2b11365c597c9886474986565fcce0d3b1e5e8d6 (patch) | |
tree | 0f86d768fb56b45365c1a3c1542f24a2f57080ce /google_apis | |
parent | 72a911aabfce5f815220095f88876cdc9183ce62 (diff) | |
download | chromium_src-2b11365c597c9886474986565fcce0d3b1e5e8d6.zip chromium_src-2b11365c597c9886474986565fcce0d3b1e5e8d6.tar.gz chromium_src-2b11365c597c9886474986565fcce0d3b1e5e8d6.tar.bz2 |
Auto-detect whether internal keys should be used.
Allow overriding to explicitly use or not use internal keys,
regardless of what is auto-detected.
Fix a bug in the implementation, where the default value was not being used for unset tokens.
BUG=145584
Review URL: https://codereview.chromium.org/10933126
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157130 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rwxr-xr-x | google_apis/build/check_internal.py | 20 | ||||
-rw-r--r-- | google_apis/google_api_keys.cc | 33 |
2 files changed, 46 insertions, 7 deletions
diff --git a/google_apis/build/check_internal.py b/google_apis/build/check_internal.py new file mode 100755 index 0000000..da0ddae --- /dev/null +++ b/google_apis/build/check_internal.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +# Copyright (c) 2012 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +"""google_api's auto-internal gyp integration. + +Takes one argument, a path. Prints 1 if the path exists, 0 if not. +""" + + +import os +import sys + + +if __name__ == '__main__': + if os.path.exists(sys.argv[1]): + print 1 + else: + print 0 diff --git a/google_apis/google_api_keys.cc b/google_apis/google_api_keys.cc index 98cb95f..20366b7 100644 --- a/google_apis/google_api_keys.cc +++ b/google_apis/google_api_keys.cc @@ -15,6 +15,22 @@ #include "google_apis/internal/google_chrome_api_keys.h" #endif +// TODO(joi): Can we enable this warning without having it treated as +// an error? We don't want to fail builds, just warn, but all warnings +// from the preprocessor are currently treated as errors, at least in +// Linux builds. +#if 0 +#if !defined(GOOGLE_API_KEY) && ( \ + (!defined(GOOGLE_DEFAULT_CLIENT_ID) && \ + !defined(GOOGLE_DEFAULT_CLIENT_SECRET)) \ + || \ + (!defined(GOOGLE_CLIENT_ID_MAIN) && \ + !defined(GOOGLE_CLIENT_SECRET_MAIN))) +#warning You have not specified API keys; some features may not work. +#warning See www.chromium.org/developers/how-tos/api-keys for details. +#endif // (API keys unset) +#endif // 0 + // Used to indicate an unset key/id/secret. This works better with // various unit tests than leaving the token empty. #define DUMMY_API_TOKEN "dummytoken" @@ -196,15 +212,18 @@ class APIKeyCache { << " with value " << key_value << " from command-line switch."; } - if (key_value.size() == 0) { + if (key_value == DUMMY_API_TOKEN) { #if defined(GOOGLE_CHROME_BUILD) - // No key should be empty in an official build, except the - // default keys themselves, which will have an empty default. - CHECK(default_if_unset.size() == 0); + // No key should be unset in an official build except the + // GOOGLE_DEFAULT_* keys. The default keys don't trigger this + // check as their "unset" value is not DUMMY_API_TOKEN. + CHECK(false); #endif - LOG(INFO) << "Using default value \"" << default_if_unset - << "\" for API key " << environment_variable_name; - key_value = default_if_unset; + if (default_if_unset.size() > 0) { + LOG(INFO) << "Using default value \"" << default_if_unset + << "\" for API key " << environment_variable_name; + key_value = default_if_unset; + } } // This should remain a debug-only log. |