Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/protocol_manager.h" | 5 #include "chrome/browser/safe_browsing/protocol_manager.h" |
| 6 | 6 |
| 7 #ifndef NDEBUG | 7 #ifndef NDEBUG |
| 8 #include "base/base64.h" | 8 #include "base/base64.h" |
| 9 #endif | 9 #endif |
| 10 #include "base/environment.h" | 10 #include "base/environment.h" |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 653 GURL report_url = SafeBrowsingHitUrl(malicious_url, page_url, | 653 GURL report_url = SafeBrowsingHitUrl(malicious_url, page_url, |
| 654 referrer_url, is_subresource, | 654 referrer_url, is_subresource, |
| 655 threat_type); | 655 threat_type); |
| 656 URLFetcher* report = new URLFetcher(report_url, URLFetcher::GET, this); | 656 URLFetcher* report = new URLFetcher(report_url, URLFetcher::GET, this); |
| 657 report->set_load_flags(net::LOAD_DISABLE_CACHE); | 657 report->set_load_flags(net::LOAD_DISABLE_CACHE); |
| 658 report->set_request_context(request_context_getter_); | 658 report->set_request_context(request_context_getter_); |
| 659 report->Start(); | 659 report->Start(); |
| 660 safebrowsing_reports_.insert(report); | 660 safebrowsing_reports_.insert(report); |
| 661 } | 661 } |
| 662 | 662 |
| 663 void SafeBrowsingProtocolManager::ReportSafeBrowsingHitWithChain( | |
| 664 const std::vector<GURL>& url_chain, | |
| 665 const GURL& referrer_url, | |
| 666 bool is_subresource, | |
| 667 SafeBrowsingService::UrlCheckResult threat_type) { | |
| 668 std::string post_data; | |
| 669 for (size_t i = 0; i < url_chain.size(); ++i) | |
| 670 post_data += url_chain[i].spec() + "\n"; | |
| 671 | |
| 672 GURL report_url = SafeBrowsingHitUrl(url_chain.back(), url_chain.front(), | |
|
noelutz
2011/05/06 04:24:12
Do you ever check that there is at least one eleme
panayiotis
2011/05/09 19:44:16
A check would be nice yes.
On 2011/05/06 04:24:1
mattm
2011/05/10 02:26:09
Added a DCHECK to DownloadSBClient constructor
| |
| 673 referrer_url, is_subresource, | |
| 674 threat_type); | |
| 675 URLFetcher* report = new URLFetcher(report_url, URLFetcher::POST, this); | |
| 676 report->set_load_flags(net::LOAD_DISABLE_CACHE); | |
| 677 report->set_request_context(request_context_getter_); | |
| 678 report->set_upload_data("text/plain", post_data); | |
| 679 report->Start(); | |
| 680 safebrowsing_reports_.insert(report); | |
| 681 } | |
| 682 | |
| 663 // Sends malware details for users who opt-in. | 683 // Sends malware details for users who opt-in. |
| 664 void SafeBrowsingProtocolManager::ReportMalwareDetails( | 684 void SafeBrowsingProtocolManager::ReportMalwareDetails( |
| 665 const std::string& report) { | 685 const std::string& report) { |
| 666 GURL report_url = MalwareDetailsUrl(); | 686 GURL report_url = MalwareDetailsUrl(); |
| 667 URLFetcher* fetcher = new URLFetcher(report_url, URLFetcher::POST, this); | 687 URLFetcher* fetcher = new URLFetcher(report_url, URLFetcher::POST, this); |
| 668 fetcher->set_load_flags(net::LOAD_DISABLE_CACHE); | 688 fetcher->set_load_flags(net::LOAD_DISABLE_CACHE); |
| 669 fetcher->set_request_context(request_context_getter_); | 689 fetcher->set_request_context(request_context_getter_); |
| 670 fetcher->set_upload_data("application/octet-stream", report); | 690 fetcher->set_upload_data("application/octet-stream", report); |
| 671 // Don't try too hard to send reports on failures. | 691 // Don't try too hard to send reports on failures. |
| 672 fetcher->set_automatically_retry_on_5xx(false); | 692 fetcher->set_automatically_retry_on_5xx(false); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 815 if (!additional_query_.empty()) { | 835 if (!additional_query_.empty()) { |
| 816 if (next_url.find("?") != std::string::npos) { | 836 if (next_url.find("?") != std::string::npos) { |
| 817 next_url.append("&"); | 837 next_url.append("&"); |
| 818 } else { | 838 } else { |
| 819 next_url.append("?"); | 839 next_url.append("?"); |
| 820 } | 840 } |
| 821 next_url.append(additional_query_); | 841 next_url.append(additional_query_); |
| 822 } | 842 } |
| 823 return GURL(next_url); | 843 return GURL(next_url); |
| 824 } | 844 } |
| OLD | NEW |