| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/safe_browsing/client_side_detection_service.h" | 5 #include "chrome/browser/safe_browsing/client_side_detection_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 const ClientReportMalwareRequestCallback& callback) { | 361 const ClientReportMalwareRequestCallback& callback) { |
| 362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 363 scoped_ptr<ClientMalwareRequest> request(verdict); | 363 scoped_ptr<ClientMalwareRequest> request(verdict); |
| 364 | 364 |
| 365 if (!enabled_) { | 365 if (!enabled_) { |
| 366 if (!callback.is_null()) | 366 if (!callback.is_null()) |
| 367 callback.Run(GURL(request->url()), GURL(request->url()), false); | 367 callback.Run(GURL(request->url()), GURL(request->url()), false); |
| 368 return; | 368 return; |
| 369 } | 369 } |
| 370 | 370 |
| 371 if (OverMalwareReportLimit()) { | |
| 372 UpdateEnumUMAHistogram(REPORT_HIT_LIMIT); | |
| 373 DVLOG(1) << "Too many malware report requests sent recently." | |
| 374 << "Skip sending malware report for " << GURL(request->url()); | |
| 375 if (!callback.is_null()) | |
| 376 callback.Run(GURL(request->url()), GURL(request->url()), false); | |
| 377 return; | |
| 378 } | |
| 379 | |
| 380 std::string request_data; | 371 std::string request_data; |
| 381 if (!request->SerializeToString(&request_data)) { | 372 if (!request->SerializeToString(&request_data)) { |
| 382 UpdateEnumUMAHistogram(REPORT_FAILED_SERIALIZATION); | 373 UpdateEnumUMAHistogram(REPORT_FAILED_SERIALIZATION); |
| 383 DVLOG(1) << "Unable to serialize the CSD request. Proto file changed?"; | 374 DVLOG(1) << "Unable to serialize the CSD request. Proto file changed?"; |
| 384 if (!callback.is_null()) | 375 if (!callback.is_null()) |
| 385 callback.Run(GURL(request->url()), GURL(request->url()), false); | 376 callback.Run(GURL(request->url()), GURL(request->url()), false); |
| 386 return; | 377 return; |
| 387 } | 378 } |
| 388 | 379 |
| 389 net::URLFetcher* fetcher = net::URLFetcher::Create( | 380 net::URLFetcher* fetcher = net::URLFetcher::Create( |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 GURL ClientSideDetectionService::GetClientReportUrl( | 671 GURL ClientSideDetectionService::GetClientReportUrl( |
| 681 const std::string& report_url) { | 672 const std::string& report_url) { |
| 682 GURL url(report_url); | 673 GURL url(report_url); |
| 683 std::string api_key = google_apis::GetAPIKey(); | 674 std::string api_key = google_apis::GetAPIKey(); |
| 684 if (!api_key.empty()) | 675 if (!api_key.empty()) |
| 685 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 676 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
| 686 | 677 |
| 687 return url; | 678 return url; |
| 688 } | 679 } |
| 689 } // namespace safe_browsing | 680 } // namespace safe_browsing |
| OLD | NEW |