| OLD | NEW |
| 1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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 "components/safe_browsing/base_ping_manager.h" | 5 #include "components/safe_browsing/base_ping_manager.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 safebrowsing_reports_.insert(std::move(fetcher)); | 194 safebrowsing_reports_.insert(std::move(fetcher)); |
| 195 } | 195 } |
| 196 | 196 |
| 197 GURL BasePingManager::SafeBrowsingHitUrl( | 197 GURL BasePingManager::SafeBrowsingHitUrl( |
| 198 const safe_browsing::HitReport& hit_report) const { | 198 const safe_browsing::HitReport& hit_report) const { |
| 199 DCHECK(hit_report.threat_type == SB_THREAT_TYPE_URL_MALWARE || | 199 DCHECK(hit_report.threat_type == SB_THREAT_TYPE_URL_MALWARE || |
| 200 hit_report.threat_type == SB_THREAT_TYPE_URL_PHISHING || | 200 hit_report.threat_type == SB_THREAT_TYPE_URL_PHISHING || |
| 201 hit_report.threat_type == SB_THREAT_TYPE_URL_UNWANTED || | 201 hit_report.threat_type == SB_THREAT_TYPE_URL_UNWANTED || |
| 202 hit_report.threat_type == SB_THREAT_TYPE_BINARY_MALWARE_URL || | 202 hit_report.threat_type == SB_THREAT_TYPE_BINARY_MALWARE_URL || |
| 203 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL || | 203 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL || |
| 204 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); | 204 hit_report.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL || |
| 205 hit_report.threat_type == |
| 206 SB_THREAT_TYPE_PASSWORD_PROTECTION_PHISHING_URL); |
| 205 std::string url = ProtocolManagerHelper::ComposeUrl( | 207 std::string url = ProtocolManagerHelper::ComposeUrl( |
| 206 url_prefix_, "report", client_name_, version_, std::string(), | 208 url_prefix_, "report", client_name_, version_, std::string(), |
| 207 hit_report.extended_reporting_level); | 209 hit_report.extended_reporting_level); |
| 208 | 210 |
| 209 std::string threat_list = "none"; | 211 std::string threat_list = "none"; |
| 210 switch (hit_report.threat_type) { | 212 switch (hit_report.threat_type) { |
| 211 case SB_THREAT_TYPE_URL_MALWARE: | 213 case SB_THREAT_TYPE_URL_MALWARE: |
| 212 threat_list = "malblhit"; | 214 threat_list = "malblhit"; |
| 213 break; | 215 break; |
| 214 case SB_THREAT_TYPE_URL_PHISHING: | 216 case SB_THREAT_TYPE_URL_PHISHING: |
| 215 threat_list = "phishblhit"; | 217 threat_list = "phishblhit"; |
| 216 break; | 218 break; |
| 217 case SB_THREAT_TYPE_URL_UNWANTED: | 219 case SB_THREAT_TYPE_URL_UNWANTED: |
| 218 threat_list = "uwsblhit"; | 220 threat_list = "uwsblhit"; |
| 219 break; | 221 break; |
| 220 case SB_THREAT_TYPE_BINARY_MALWARE_URL: | 222 case SB_THREAT_TYPE_BINARY_MALWARE_URL: |
| 221 threat_list = "binurlhit"; | 223 threat_list = "binurlhit"; |
| 222 break; | 224 break; |
| 223 case SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL: | 225 case SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL: |
| 224 threat_list = "phishcsdhit"; | 226 threat_list = "phishcsdhit"; |
| 225 break; | 227 break; |
| 226 case SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL: | 228 case SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL: |
| 227 threat_list = "malcsdhit"; | 229 threat_list = "malcsdhit"; |
| 228 break; | 230 break; |
| 231 case SB_THREAT_TYPE_PASSWORD_PROTECTION_PHISHING_URL: |
| 232 threat_list = "phishpphit"; |
| 233 break; |
| 229 default: | 234 default: |
| 230 NOTREACHED(); | 235 NOTREACHED(); |
| 231 } | 236 } |
| 232 | 237 |
| 233 std::string threat_source = "none"; | 238 std::string threat_source = "none"; |
| 234 switch (hit_report.threat_source) { | 239 switch (hit_report.threat_source) { |
| 235 case safe_browsing::ThreatSource::DATA_SAVER: | 240 case safe_browsing::ThreatSource::DATA_SAVER: |
| 236 threat_source = "ds"; | 241 threat_source = "ds"; |
| 237 break; | 242 break; |
| 238 case safe_browsing::ThreatSource::REMOTE: | 243 case safe_browsing::ThreatSource::REMOTE: |
| 239 threat_source = "rem"; | 244 threat_source = "rem"; |
| 240 break; | 245 break; |
| 241 case safe_browsing::ThreatSource::LOCAL_PVER3: | 246 case safe_browsing::ThreatSource::LOCAL_PVER3: |
| 242 threat_source = "l3"; | 247 threat_source = "l3"; |
| 243 break; | 248 break; |
| 244 case safe_browsing::ThreatSource::LOCAL_PVER4: | 249 case safe_browsing::ThreatSource::LOCAL_PVER4: |
| 245 threat_source = "l4"; | 250 threat_source = "l4"; |
| 246 break; | 251 break; |
| 247 case safe_browsing::ThreatSource::CLIENT_SIDE_DETECTION: | 252 case safe_browsing::ThreatSource::CLIENT_SIDE_DETECTION: |
| 248 threat_source = "csd"; | 253 threat_source = "csd"; |
| 249 break; | 254 break; |
| 255 case safe_browsing::ThreatSource::PASSWORD_PROTECTION_SERVICE: |
| 256 threat_source = "pps"; |
| 257 break; |
| 250 case safe_browsing::ThreatSource::UNKNOWN: | 258 case safe_browsing::ThreatSource::UNKNOWN: |
| 251 NOTREACHED(); | 259 NOTREACHED(); |
| 252 } | 260 } |
| 253 | 261 |
| 254 // Add user_population component only if it's not empty. | 262 // Add user_population component only if it's not empty. |
| 255 std::string user_population_comp; | 263 std::string user_population_comp; |
| 256 if (!hit_report.population_id.empty()) { | 264 if (!hit_report.population_id.empty()) { |
| 257 // Population_id should be URL-safe, but escape it and size-limit it | 265 // Population_id should be URL-safe, but escape it and size-limit it |
| 258 // anyway since it came from outside Chrome. | 266 // anyway since it came from outside Chrome. |
| 259 std::string up_str = | 267 std::string up_str = |
| (...skipping 22 matching lines...) Expand all Loading... |
| 282 url_prefix_.c_str(), client_name_.c_str(), version_.c_str()); | 290 url_prefix_.c_str(), client_name_.c_str(), version_.c_str()); |
| 283 std::string api_key = google_apis::GetAPIKey(); | 291 std::string api_key = google_apis::GetAPIKey(); |
| 284 if (!api_key.empty()) { | 292 if (!api_key.empty()) { |
| 285 base::StringAppendF(&url, "&key=%s", | 293 base::StringAppendF(&url, "&key=%s", |
| 286 net::EscapeQueryParamValue(api_key, true).c_str()); | 294 net::EscapeQueryParamValue(api_key, true).c_str()); |
| 287 } | 295 } |
| 288 return GURL(url); | 296 return GURL(url); |
| 289 } | 297 } |
| 290 | 298 |
| 291 } // namespace safe_browsing | 299 } // namespace safe_browsing |
| OLD | NEW |