| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 safebrowsing_reports_.insert(fetcher); | 95 safebrowsing_reports_.insert(fetcher); |
| 96 } | 96 } |
| 97 | 97 |
| 98 GURL SafeBrowsingPingManager::SafeBrowsingHitUrl( | 98 GURL SafeBrowsingPingManager::SafeBrowsingHitUrl( |
| 99 const GURL& malicious_url, const GURL& page_url, | 99 const GURL& malicious_url, const GURL& page_url, |
| 100 const GURL& referrer_url, bool is_subresource, | 100 const GURL& referrer_url, bool is_subresource, |
| 101 SBThreatType threat_type) const { | 101 SBThreatType threat_type) const { |
| 102 DCHECK(threat_type == SB_THREAT_TYPE_URL_MALWARE || | 102 DCHECK(threat_type == SB_THREAT_TYPE_URL_MALWARE || |
| 103 threat_type == SB_THREAT_TYPE_URL_PHISHING || | 103 threat_type == SB_THREAT_TYPE_URL_PHISHING || |
| 104 threat_type == SB_THREAT_TYPE_BINARY_MALWARE_URL || | 104 threat_type == SB_THREAT_TYPE_BINARY_MALWARE_URL || |
| 105 threat_type == SB_THREAT_TYPE_BINARY_MALWARE_HASH || | |
| 106 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL || | 105 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL || |
| 107 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); | 106 threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL); |
| 108 std::string url = SafeBrowsingProtocolManagerHelper::ComposeUrl( | 107 std::string url = SafeBrowsingProtocolManagerHelper::ComposeUrl( |
| 109 url_prefix_, "report", client_name_, version_, std::string()); | 108 url_prefix_, "report", client_name_, version_, std::string()); |
| 110 std::string threat_list = "none"; | 109 std::string threat_list = "none"; |
| 111 switch (threat_type) { | 110 switch (threat_type) { |
| 112 case SB_THREAT_TYPE_URL_MALWARE: | 111 case SB_THREAT_TYPE_URL_MALWARE: |
| 113 threat_list = "malblhit"; | 112 threat_list = "malblhit"; |
| 114 break; | 113 break; |
| 115 case SB_THREAT_TYPE_URL_PHISHING: | 114 case SB_THREAT_TYPE_URL_PHISHING: |
| 116 threat_list = "phishblhit"; | 115 threat_list = "phishblhit"; |
| 117 break; | 116 break; |
| 118 case SB_THREAT_TYPE_BINARY_MALWARE_URL: | 117 case SB_THREAT_TYPE_BINARY_MALWARE_URL: |
| 119 threat_list = "binurlhit"; | 118 threat_list = "binurlhit"; |
| 120 break; | 119 break; |
| 121 case SB_THREAT_TYPE_BINARY_MALWARE_HASH: | |
| 122 threat_list = "binhashhit"; | |
| 123 break; | |
| 124 case SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL: | 120 case SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL: |
| 125 threat_list = "phishcsdhit"; | 121 threat_list = "phishcsdhit"; |
| 126 break; | 122 break; |
| 127 case SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL: | 123 case SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL: |
| 128 threat_list = "malcsdhit"; | 124 threat_list = "malcsdhit"; |
| 129 break; | 125 break; |
| 130 default: | 126 default: |
| 131 NOTREACHED(); | 127 NOTREACHED(); |
| 132 } | 128 } |
| 133 return GURL(base::StringPrintf("%s&evts=%s&evtd=%s&evtr=%s&evhr=%s&evtb=%d", | 129 return GURL(base::StringPrintf("%s&evts=%s&evtd=%s&evtr=%s&evhr=%s&evtb=%d", |
| (...skipping 10 matching lines...) Expand all Loading... |
| 144 url_prefix_.c_str(), | 140 url_prefix_.c_str(), |
| 145 client_name_.c_str(), | 141 client_name_.c_str(), |
| 146 version_.c_str()); | 142 version_.c_str()); |
| 147 std::string api_key = google_apis::GetAPIKey(); | 143 std::string api_key = google_apis::GetAPIKey(); |
| 148 if (!api_key.empty()) { | 144 if (!api_key.empty()) { |
| 149 base::StringAppendF(&url, "&key=%s", | 145 base::StringAppendF(&url, "&key=%s", |
| 150 net::EscapeQueryParamValue(api_key, true).c_str()); | 146 net::EscapeQueryParamValue(api_key, true).c_str()); |
| 151 } | 147 } |
| 152 return GURL(url); | 148 return GURL(url); |
| 153 } | 149 } |
| OLD | NEW |