summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-17 13:55:20 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-17 13:55:20 +0000
commite4b54e3e6f3086905b27cdcfe86667d0ad157f94 (patch)
tree806f5f7978af0a104e4283432108cf40c0ff4c5a
parent4ed078d35441b584ca576cb28869979061037f70 (diff)
downloadchromium_src-e4b54e3e6f3086905b27cdcfe86667d0ad157f94.zip
chromium_src-e4b54e3e6f3086905b27cdcfe86667d0ad157f94.tar.gz
chromium_src-e4b54e3e6f3086905b27cdcfe86667d0ad157f94.tar.bz2
Add a function for determining if official Google Chrome API key is used.
I'd like to add this for handling several features of Google Drive API that is only available for whitelisted first-party client. By checking the key by the newly added function, we can provide better fallbacks for clients with third-party keys, instead of just failing. BUG=332332, 324166 Review URL: https://codereview.chromium.org/131743018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245504 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--google_apis/google_api_keys.cc8
-rw-r--r--google_apis/google_api_keys.h4
2 files changed, 12 insertions, 0 deletions
diff --git a/google_apis/google_api_keys.cc b/google_apis/google_api_keys.cc
index 94f6812..2cf92fd 100644
--- a/google_apis/google_api_keys.cc
+++ b/google_apis/google_api_keys.cc
@@ -269,4 +269,12 @@ std::string GetOAuth2ClientSecret(OAuth2Client client) {
return g_api_key_cache.Get().GetClientSecret(client);
}
+bool IsGoogleChromeAPIKeyUsed() {
+#if defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
+ return true;
+#else
+ return false;
+#endif
+}
+
} // namespace google_apis
diff --git a/google_apis/google_api_keys.h b/google_apis/google_api_keys.h
index 8f4bc7e..5acdf26 100644
--- a/google_apis/google_api_keys.h
+++ b/google_apis/google_api_keys.h
@@ -90,6 +90,10 @@ std::string GetOAuth2ClientID(OAuth2Client client);
// in, e.g. URL-escaped if you use it in a URL.
std::string GetOAuth2ClientSecret(OAuth2Client client);
+// Returns if the API key using in the current build is the one for official
+// Google Chrome.
+bool IsGoogleChromeAPIKeyUsed();
+
} // namespace google_apis
#endif // GOOGLE_APIS_GOOGLE_API_KEYS_H_