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

Unified Diff: chrome/browser/safe_browsing/protocol_manager.cc

Issue 10914274: Include an API key in SafeBrowsing requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to new safebrowsing test server. Created 8 years, 3 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 | « DEPS ('k') | chrome/browser/safe_browsing/protocol_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/protocol_manager.cc
diff --git a/chrome/browser/safe_browsing/protocol_manager.cc b/chrome/browser/safe_browsing/protocol_manager.cc
index 3329d0bf02f920c8c7362cb00139920af93dc89d..913d7728b97e2b48993c10df54f5ee9c9eb8a4e8 100644
--- a/chrome/browser/safe_browsing/protocol_manager.cc
+++ b/chrome/browser/safe_browsing/protocol_manager.cc
@@ -20,6 +20,7 @@
#include "chrome/common/chrome_version_info.h"
#include "chrome/common/env_vars.h"
#include "content/public/browser/browser_thread.h"
+#include "google_apis/google_api_keys.h"
#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "net/url_request/url_fetcher.h"
@@ -649,6 +650,11 @@ std::string SafeBrowsingProtocolManager::ComposeUrl(
std::string url = base::StringPrintf("%s/%s?client=%s&appver=%s&pver=2.2",
prefix.c_str(), method.c_str(),
client_name.c_str(), version.c_str());
+ std::string api_key = google_apis::GetAPIKey();
+ if (!api_key.empty()) {
+ base::StringAppendF(&url, "&key=%s",
+ net::EscapeQueryParamValue(api_key, true).c_str());
+ }
if (!additional_query.empty()) {
DCHECK(url.find("?") != std::string::npos);
url.append("&");
@@ -712,6 +718,11 @@ GURL SafeBrowsingProtocolManager::MalwareDetailsUrl() const {
url_prefix_.c_str(),
client_name_.c_str(),
version_.c_str());
+ std::string api_key = google_apis::GetAPIKey();
+ if (!api_key.empty()) {
+ base::StringAppendF(&url, "&key=%s",
+ net::EscapeQueryParamValue(api_key, true).c_str());
+ }
return GURL(url);
}
« no previous file with comments | « DEPS ('k') | chrome/browser/safe_browsing/protocol_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698