Skip to content

Commit

Permalink
Add a function for determining if official Google Chrome API key is u…
Browse files Browse the repository at this point in the history
…sed.

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
  • Loading branch information
kinaba@chromium.org committed Jan 17, 2014
1 parent 4ed078d commit e4b54e3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions google_apis/google_api_keys.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions google_apis/google_api_keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_

0 comments on commit e4b54e3

Please sign in to comment.