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

Side by Side Diff: chrome/browser/safe_browsing/protocol_manager.cc

Issue 4822002: Send malware reports when a user opts-in from the safe browsing interstitial ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 GURL report_url = SafeBrowsingReportUrl(malicious_url, page_url, 597 GURL report_url = SafeBrowsingReportUrl(malicious_url, page_url,
598 referrer_url, is_subresource, 598 referrer_url, is_subresource,
599 threat_type); 599 threat_type);
600 URLFetcher* report = new URLFetcher(report_url, URLFetcher::GET, this); 600 URLFetcher* report = new URLFetcher(report_url, URLFetcher::GET, this);
601 report->set_load_flags(net::LOAD_DISABLE_CACHE); 601 report->set_load_flags(net::LOAD_DISABLE_CACHE);
602 report->set_request_context(request_context_getter_); 602 report->set_request_context(request_context_getter_);
603 report->Start(); 603 report->Start();
604 safebrowsing_reports_.insert(report); 604 safebrowsing_reports_.insert(report);
605 } 605 }
606 606
607 // Sends a malware report.
608 void SafeBrowsingProtocolManager::SendMalwareReport(
609 const std::string& report) {
610 GURL report_url = MalwareClientReportUrl();
611 URLFetcher* fetcher = new URLFetcher(report_url, URLFetcher::POST, this);
612 fetcher->set_load_flags(net::LOAD_DISABLE_CACHE);
613 fetcher->set_request_context(request_context_getter_);
614 fetcher->set_upload_data("application/octet-stream", report);
615 // Don't try too hard to send reports on failures.
616 fetcher->set_automatically_retry_on_5xx(false);
617 fetcher->Start();
618 safebrowsing_reports_.insert(fetcher);
619 }
620
621
607 // static 622 // static
608 std::string SafeBrowsingProtocolManager::FormatList( 623 std::string SafeBrowsingProtocolManager::FormatList(
609 const SBListChunkRanges& list, bool use_mac) { 624 const SBListChunkRanges& list, bool use_mac) {
610 std::string formatted_results; 625 std::string formatted_results;
611 formatted_results.append(list.name); 626 formatted_results.append(list.name);
612 formatted_results.append(";"); 627 formatted_results.append(";");
613 if (!list.adds.empty()) { 628 if (!list.adds.empty()) {
614 formatted_results.append("a:" + list.adds); 629 formatted_results.append("a:" + list.adds);
615 if (!list.subs.empty() || use_mac) 630 if (!list.subs.empty() || use_mac)
616 formatted_results.append(":"); 631 formatted_results.append(":");
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 return GURL(StringPrintf("%s&evts=%s&evtd=%s&evtr=%s&evhr=%s&evtb=%d", 712 return GURL(StringPrintf("%s&evts=%s&evtd=%s&evtr=%s&evhr=%s&evtb=%d",
698 url.c_str(), 713 url.c_str(),
699 (threat_type == SafeBrowsingService::URL_MALWARE) ? 714 (threat_type == SafeBrowsingService::URL_MALWARE) ?
700 "malblhit" : "phishblhit", 715 "malblhit" : "phishblhit",
701 EscapeQueryParamValue(malicious_url.spec(), true).c_str(), 716 EscapeQueryParamValue(malicious_url.spec(), true).c_str(),
702 EscapeQueryParamValue(page_url.spec(), true).c_str(), 717 EscapeQueryParamValue(page_url.spec(), true).c_str(),
703 EscapeQueryParamValue(referrer_url.spec(), true).c_str(), 718 EscapeQueryParamValue(referrer_url.spec(), true).c_str(),
704 is_subresource)); 719 is_subresource));
705 } 720 }
706 721
722 GURL SafeBrowsingProtocolManager::MalwareClientReportUrl() const {
723 std::string url = StringPrintf(
724 "%s/clientreport/malware?client=%s&appver=%s&pver=1.0",
725 mackey_url_prefix_.c_str(),
lzheng 2010/11/30 23:14:49 If safebrowsing backends has only one https url an
panayiotis 2010/12/01 22:34:52 Done.
726 client_name_.c_str(),
727 version_.c_str());
728 return GURL(url);
729 }
730
707 GURL SafeBrowsingProtocolManager::NextChunkUrl(const std::string& url) const { 731 GURL SafeBrowsingProtocolManager::NextChunkUrl(const std::string& url) const {
708 std::string next_url; 732 std::string next_url;
709 if (!StartsWithASCII(url, "http://", false) && 733 if (!StartsWithASCII(url, "http://", false) &&
710 !StartsWithASCII(url, "https://", false)) { 734 !StartsWithASCII(url, "https://", false)) {
711 next_url.append("http://"); 735 next_url.append("http://");
712 next_url.append(url); 736 next_url.append(url);
713 } else { 737 } else {
714 next_url = url; 738 next_url = url;
715 } 739 }
716 if (!additional_query_.empty()) { 740 if (!additional_query_.empty()) {
717 if (next_url.find("?") != std::string::npos) { 741 if (next_url.find("?") != std::string::npos) {
718 next_url.append("&"); 742 next_url.append("&");
719 } else { 743 } else {
720 next_url.append("?"); 744 next_url.append("?");
721 } 745 }
722 next_url.append(additional_query_); 746 next_url.append(additional_query_);
723 } 747 }
724 return GURL(next_url); 748 return GURL(next_url);
725 } 749 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698