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 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 IssueChunkRequest(); | 642 IssueChunkRequest(); |
643 } | 643 } |
644 } | 644 } |
645 | 645 |
646 // Sends a SafeBrowsing "hit" for UMA users. | 646 // Sends a SafeBrowsing "hit" for UMA users. |
647 void SafeBrowsingProtocolManager::ReportSafeBrowsingHit( | 647 void SafeBrowsingProtocolManager::ReportSafeBrowsingHit( |
648 const GURL& malicious_url, | 648 const GURL& malicious_url, |
649 const GURL& page_url, | 649 const GURL& page_url, |
650 const GURL& referrer_url, | 650 const GURL& referrer_url, |
651 bool is_subresource, | 651 bool is_subresource, |
652 SafeBrowsingService::UrlCheckResult threat_type) { | 652 SafeBrowsingService::UrlCheckResult threat_type, |
| 653 const std::string& post_data) { |
653 GURL report_url = SafeBrowsingHitUrl(malicious_url, page_url, | 654 GURL report_url = SafeBrowsingHitUrl(malicious_url, page_url, |
654 referrer_url, is_subresource, | 655 referrer_url, is_subresource, |
655 threat_type); | 656 threat_type); |
656 URLFetcher* report = new URLFetcher(report_url, URLFetcher::GET, this); | 657 URLFetcher* report = new URLFetcher( |
| 658 report_url, post_data.empty() ? URLFetcher::GET : URLFetcher::POST, this); |
657 report->set_load_flags(net::LOAD_DISABLE_CACHE); | 659 report->set_load_flags(net::LOAD_DISABLE_CACHE); |
658 report->set_request_context(request_context_getter_); | 660 report->set_request_context(request_context_getter_); |
| 661 if (!post_data.empty()) |
| 662 report->set_upload_data("text/plain", post_data); |
659 report->Start(); | 663 report->Start(); |
660 safebrowsing_reports_.insert(report); | 664 safebrowsing_reports_.insert(report); |
661 } | 665 } |
662 | 666 |
663 // Sends malware details for users who opt-in. | 667 // Sends malware details for users who opt-in. |
664 void SafeBrowsingProtocolManager::ReportMalwareDetails( | 668 void SafeBrowsingProtocolManager::ReportMalwareDetails( |
665 const std::string& report) { | 669 const std::string& report) { |
666 GURL report_url = MalwareDetailsUrl(); | 670 GURL report_url = MalwareDetailsUrl(); |
667 URLFetcher* fetcher = new URLFetcher(report_url, URLFetcher::POST, this); | 671 URLFetcher* fetcher = new URLFetcher(report_url, URLFetcher::POST, this); |
668 fetcher->set_load_flags(net::LOAD_DISABLE_CACHE); | 672 fetcher->set_load_flags(net::LOAD_DISABLE_CACHE); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 if (!additional_query_.empty()) { | 819 if (!additional_query_.empty()) { |
816 if (next_url.find("?") != std::string::npos) { | 820 if (next_url.find("?") != std::string::npos) { |
817 next_url.append("&"); | 821 next_url.append("&"); |
818 } else { | 822 } else { |
819 next_url.append("?"); | 823 next_url.append("?"); |
820 } | 824 } |
821 next_url.append(additional_query_); | 825 next_url.append(additional_query_); |
822 } | 826 } |
823 return GURL(next_url); | 827 return GURL(next_url); |
824 } | 828 } |
OLD | NEW |