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

Unified Diff: chrome/browser/safe_browsing/client_side_detection_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/client_side_detection_service.cc
diff --git a/chrome/browser/safe_browsing/client_side_detection_service.cc b/chrome/browser/safe_browsing/client_side_detection_service.cc
index 0d989bda99fd77cbda09275dc7699d96323e7f71..239c402379b1c160322f831ef507f9300de5a55c 100644
--- a/chrome/browser/safe_browsing/client_side_detection_service.cc
+++ b/chrome/browser/safe_browsing/client_side_detection_service.cc
@@ -25,7 +25,9 @@
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
#include "crypto/sha2.h"
+#include "google_apis/google_api_keys.h"
#include "googleurl/src/gurl.h"
+#include "net/base/escape.h"
#include "net/base/load_flags.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_status_code.h"
@@ -303,7 +305,7 @@ void ClientSideDetectionService::StartClientReportPhishingRequest(
}
net::URLFetcher* fetcher = net::URLFetcher::Create(
- 0 /* ID used for testing */, GURL(kClientReportPhishingUrl),
+ 0 /* ID used for testing */, GURL(GetClientReportPhishingUrl()),
net::URLFetcher::POST, this);
// Remember which callback and URL correspond to the current fetcher object.
@@ -532,4 +534,15 @@ bool ClientSideDetectionService::ModelHasValidHashIds(
}
return true;
}
+
+// static
+std::string ClientSideDetectionService::GetClientReportPhishingUrl() {
+ std::string url = kClientReportPhishingUrl;
+ 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