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/ping_manager.h" | 5 #include "chrome/browser/safe_browsing/ping_manager.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 void SafeBrowsingPingManager::ReportSafeBrowsingHit( | 88 void SafeBrowsingPingManager::ReportSafeBrowsingHit( |
89 const GURL& malicious_url, | 89 const GURL& malicious_url, |
90 const GURL& page_url, | 90 const GURL& page_url, |
91 const GURL& referrer_url, | 91 const GURL& referrer_url, |
92 bool is_subresource, | 92 bool is_subresource, |
93 SBThreatType threat_type, | 93 SBThreatType threat_type, |
94 const std::string& post_data) { | 94 const std::string& post_data) { |
95 GURL report_url = SafeBrowsingHitUrl(malicious_url, page_url, | 95 GURL report_url = SafeBrowsingHitUrl(malicious_url, page_url, |
96 referrer_url, is_subresource, | 96 referrer_url, is_subresource, |
97 threat_type); | 97 threat_type); |
98 net::URLFetcher* report = net::URLFetcher::Create( | 98 net::URLFetcher* report = |
99 report_url, | 99 net::URLFetcher::Create( |
100 post_data.empty() ? net::URLFetcher::GET : net::URLFetcher::POST, | 100 report_url, |
101 this); | 101 post_data.empty() ? net::URLFetcher::GET : net::URLFetcher::POST, |
| 102 this).release(); |
102 report->SetLoadFlags(net::LOAD_DISABLE_CACHE); | 103 report->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
103 report->SetRequestContext(request_context_getter_.get()); | 104 report->SetRequestContext(request_context_getter_.get()); |
104 if (!post_data.empty()) | 105 if (!post_data.empty()) |
105 report->SetUploadData("text/plain", post_data); | 106 report->SetUploadData("text/plain", post_data); |
106 safebrowsing_reports_.insert(report); | 107 safebrowsing_reports_.insert(report); |
107 report->Start(); | 108 report->Start(); |
108 } | 109 } |
109 | 110 |
110 // Sends malware details for users who opt-in. | 111 // Sends malware details for users who opt-in. |
111 void SafeBrowsingPingManager::ReportMalwareDetails( | 112 void SafeBrowsingPingManager::ReportMalwareDetails( |
112 const std::string& report) { | 113 const std::string& report) { |
113 GURL report_url = MalwareDetailsUrl(); | 114 GURL report_url = MalwareDetailsUrl(); |
114 net::URLFetcher* fetcher = net::URLFetcher::Create( | 115 net::URLFetcher* fetcher = |
115 report_url, net::URLFetcher::POST, this); | 116 net::URLFetcher::Create(report_url, net::URLFetcher::POST, this) |
| 117 .release(); |
116 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE); | 118 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
117 fetcher->SetRequestContext(request_context_getter_.get()); | 119 fetcher->SetRequestContext(request_context_getter_.get()); |
118 fetcher->SetUploadData("application/octet-stream", report); | 120 fetcher->SetUploadData("application/octet-stream", report); |
119 // Don't try too hard to send reports on failures. | 121 // Don't try too hard to send reports on failures. |
120 fetcher->SetAutomaticallyRetryOn5xx(false); | 122 fetcher->SetAutomaticallyRetryOn5xx(false); |
121 fetcher->Start(); | 123 fetcher->Start(); |
122 safebrowsing_reports_.insert(fetcher); | 124 safebrowsing_reports_.insert(fetcher); |
123 } | 125 } |
124 | 126 |
125 void SafeBrowsingPingManager::ReportInvalidCertificateChain( | 127 void SafeBrowsingPingManager::ReportInvalidCertificateChain( |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 url_prefix_.c_str(), | 187 url_prefix_.c_str(), |
186 client_name_.c_str(), | 188 client_name_.c_str(), |
187 version_.c_str()); | 189 version_.c_str()); |
188 std::string api_key = google_apis::GetAPIKey(); | 190 std::string api_key = google_apis::GetAPIKey(); |
189 if (!api_key.empty()) { | 191 if (!api_key.empty()) { |
190 base::StringAppendF(&url, "&key=%s", | 192 base::StringAppendF(&url, "&key=%s", |
191 net::EscapeQueryParamValue(api_key, true).c_str()); | 193 net::EscapeQueryParamValue(api_key, true).c_str()); |
192 } | 194 } |
193 return GURL(url); | 195 return GURL(url); |
194 } | 196 } |
OLD | NEW |