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/ui_manager.h" | 5 #include "chrome/browser/safe_browsing/ui_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/debug/leak_tracker.h" | 10 #include "base/debug/leak_tracker.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "base/threading/thread_restrictions.h" | 14 #include "base/threading/thread_restrictions.h" |
15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
16 #include "chrome/browser/safe_browsing/malware_details.h" | 16 #include "chrome/browser/safe_browsing/malware_details.h" |
17 #include "chrome/browser/safe_browsing/metadata.pb.h" | 17 #include "chrome/browser/safe_browsing/metadata.pb.h" |
18 #include "chrome/browser/safe_browsing/ping_manager.h" | 18 #include "chrome/browser/safe_browsing/ping_manager.h" |
19 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 19 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
20 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 20 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
21 #include "chrome/browser/tab_contents/tab_util.h" | 21 #include "chrome/browser/tab_contents/tab_util.h" |
22 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
23 #include "components/metrics/metrics_service.h" | 23 #include "components/metrics/metrics_service.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
25 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
26 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
28 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 28 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
29 #include "net/ssl/ssl_info.h" | |
29 #include "net/url_request/url_request_context.h" | 30 #include "net/url_request/url_request_context.h" |
30 #include "net/url_request/url_request_context_getter.h" | 31 #include "net/url_request/url_request_context_getter.h" |
31 | 32 |
32 using content::BrowserThread; | 33 using content::BrowserThread; |
33 using content::NavigationEntry; | 34 using content::NavigationEntry; |
34 using content::WebContents; | 35 using content::WebContents; |
35 | 36 |
36 struct SafeBrowsingUIManager::WhiteListedEntry { | 37 struct SafeBrowsingUIManager::WhiteListedEntry { |
37 int render_process_host_id; | 38 int render_process_host_id; |
38 int render_view_id; | 39 int render_view_id; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 if (!CanReportStats()) | 207 if (!CanReportStats()) |
207 return; | 208 return; |
208 | 209 |
209 BrowserThread::PostTask( | 210 BrowserThread::PostTask( |
210 BrowserThread::IO, FROM_HERE, | 211 BrowserThread::IO, FROM_HERE, |
211 base::Bind(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread, this, | 212 base::Bind(&SafeBrowsingUIManager::ReportSafeBrowsingHitOnIOThread, this, |
212 malicious_url, page_url, referrer_url, is_subresource, | 213 malicious_url, page_url, referrer_url, is_subresource, |
213 threat_type, post_data)); | 214 threat_type, post_data)); |
214 } | 215 } |
215 | 216 |
217 void SafeBrowsingUIManager::ReportInvalidCertificateChain( | |
218 const std::string& hostname, | |
219 const net::SSLInfo& ssl_info, | |
220 const base::Closure& callback) { | |
221 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
222 BrowserThread::PostTaskAndReply( | |
223 BrowserThread::IO, FROM_HERE, | |
224 base::Bind( | |
225 &SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread, this, | |
226 hostname, ssl_info), | |
227 callback); | |
228 } | |
229 | |
216 void SafeBrowsingUIManager::AddObserver(Observer* observer) { | 230 void SafeBrowsingUIManager::AddObserver(Observer* observer) { |
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 231 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
218 observer_list_.AddObserver(observer); | 232 observer_list_.AddObserver(observer); |
219 } | 233 } |
220 | 234 |
221 void SafeBrowsingUIManager::RemoveObserver(Observer* observer) { | 235 void SafeBrowsingUIManager::RemoveObserver(Observer* observer) { |
222 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 236 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
223 observer_list_.RemoveObserver(observer); | 237 observer_list_.RemoveObserver(observer); |
224 } | 238 } |
225 | 239 |
(...skipping 13 matching lines...) Expand all Loading... | |
239 | 253 |
240 DVLOG(1) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url | 254 DVLOG(1) << "ReportSafeBrowsingHit: " << malicious_url << " " << page_url |
241 << " " << referrer_url << " " << is_subresource << " " | 255 << " " << referrer_url << " " << is_subresource << " " |
242 << threat_type; | 256 << threat_type; |
243 sb_service_->ping_manager()->ReportSafeBrowsingHit( | 257 sb_service_->ping_manager()->ReportSafeBrowsingHit( |
244 malicious_url, page_url, | 258 malicious_url, page_url, |
245 referrer_url, is_subresource, | 259 referrer_url, is_subresource, |
246 threat_type, post_data); | 260 threat_type, post_data); |
247 } | 261 } |
248 | 262 |
263 void SafeBrowsingUIManager::ReportInvalidCertificateChainOnIOThread( | |
264 const std::string& hostname, | |
265 const net::SSLInfo& ssl_info) { | |
266 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
267 sb_service_->ping_manager()->ReportInvalidCertificateChain(hostname, | |
mattm
2015/03/23 05:31:17
This should have null checks like in SendSerialize
estark
2015/03/23 16:42:13
Done.
| |
268 ssl_info); | |
269 } | |
270 | |
249 // If the user had opted-in to send MalwareDetails, this gets called | 271 // If the user had opted-in to send MalwareDetails, this gets called |
250 // when the report is ready. | 272 // when the report is ready. |
251 void SafeBrowsingUIManager::SendSerializedMalwareDetails( | 273 void SafeBrowsingUIManager::SendSerializedMalwareDetails( |
252 const std::string& serialized) { | 274 const std::string& serialized) { |
253 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 275 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
254 | 276 |
255 // The service may delete the ping manager (i.e. when user disabling service, | 277 // The service may delete the ping manager (i.e. when user disabling service, |
256 // etc). This happens on the IO thread. | 278 // etc). This happens on the IO thread. |
257 if (sb_service_.get() == NULL || sb_service_->ping_manager() == NULL) | 279 if (sb_service_.get() == NULL || sb_service_->ping_manager() == NULL) |
258 return; | 280 return; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
298 (entry.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL && | 320 (entry.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL && |
299 resource.threat_type == SB_THREAT_TYPE_URL_MALWARE))) { | 321 resource.threat_type == SB_THREAT_TYPE_URL_MALWARE))) { |
300 return entry.domain == | 322 return entry.domain == |
301 net::registry_controlled_domains::GetDomainAndRegistry( | 323 net::registry_controlled_domains::GetDomainAndRegistry( |
302 resource.url, | 324 resource.url, |
303 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | 325 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
304 } | 326 } |
305 } | 327 } |
306 return false; | 328 return false; |
307 } | 329 } |
308 | |
OLD | NEW |