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

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

Issue 10907225: Add API keys to SafeBrowsing client-side phishing and download verdict requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
Index: chrome/browser/safe_browsing/download_protection_service.cc
diff --git a/chrome/browser/safe_browsing/download_protection_service.cc b/chrome/browser/safe_browsing/download_protection_service.cc
index 678d5af0c1d7f0fa4879864912515a2cf5f2c731..048adc80d3ebc2e50679a8468dba3f5cd127d9c5 100644
--- a/chrome/browser/safe_browsing/download_protection_service.cc
+++ b/chrome/browser/safe_browsing/download_protection_service.cc
@@ -27,6 +27,8 @@
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/download_item.h"
#include "content/public/browser/page_navigator.h"
+#include "google_apis/google_api_keys.h"
+#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "net/base/x509_cert_types.h"
#include "net/base/x509_certificate.h"
@@ -689,7 +691,7 @@ class DownloadProtectionService::CheckClientDownloadRequest
VLOG(2) << "Sending a request for URL: "
<< info_.download_url_chain.back();
fetcher_.reset(net::URLFetcher::Create(0 /* ID used for testing */,
- GURL(kDownloadRequestUrl),
+ GURL(GetDownloadRequestUrl()),
net::URLFetcher::POST,
this));
fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE);
@@ -965,4 +967,15 @@ void DownloadProtectionService::GetCertificateWhitelistStrings(
}
}
+// static
+std::string DownloadProtectionService::GetDownloadRequestUrl() {
+ std::string url = kDownloadRequestUrl;
+ std::string api_key = google_apis::GetAPIKey();
+ if (!api_key.empty()) {
+ base::StringAppendF(&url, "?key=%s",
+ net::EscapeQueryParamValue(api_key, true).c_str());
+ }
+ return url;
+}
+
} // namespace safe_browsing

Powered by Google App Engine
This is Rietveld 408576698