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/ping_manager.h" | 18 #include "chrome/browser/safe_browsing/ping_manager.h" |
18 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 19 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
19 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 20 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
20 #include "chrome/browser/tab_contents/tab_util.h" | 21 #include "chrome/browser/tab_contents/tab_util.h" |
21 #include "chrome/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
22 #include "components/metrics/metrics_service.h" | 23 #include "components/metrics/metrics_service.h" |
23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
24 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
25 #include "content/public/browser/notification_service.h" | 26 #include "content/public/browser/notification_service.h" |
26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 FROM_HERE, | 90 FROM_HERE, |
90 base::Bind(&SafeBrowsingUIManager::UpdateWhitelist, this, resource)); | 91 base::Bind(&SafeBrowsingUIManager::UpdateWhitelist, this, resource)); |
91 } | 92 } |
92 } | 93 } |
93 } | 94 } |
94 | 95 |
95 void SafeBrowsingUIManager::DisplayBlockingPage( | 96 void SafeBrowsingUIManager::DisplayBlockingPage( |
96 const UnsafeResource& resource) { | 97 const UnsafeResource& resource) { |
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 98 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
98 | 99 |
| 100 if (!resource.threat_metadata.empty() && |
| 101 resource.threat_type == SB_THREAT_TYPE_URL_MALWARE) { |
| 102 safe_browsing::MalwarePatternType proto; |
| 103 // Malware sites tagged as "landing site" should only show a warning for a |
| 104 // main-frame or sub-frame resource. (See "Types of Malware sites" under |
| 105 // https://developers.google.com/safe-browsing/developers_guide_v3#UserWarni
ngs) |
| 106 if (proto.ParseFromString(resource.threat_metadata) && |
| 107 proto.pattern_type() == safe_browsing::MalwarePatternType::LANDING && |
| 108 resource.is_subresource && !resource.is_subframe) { |
| 109 if (!resource.callback.is_null()) { |
| 110 BrowserThread::PostTask( |
| 111 BrowserThread::IO, FROM_HERE, base::Bind(resource.callback, true)); |
| 112 } |
| 113 return; |
| 114 } |
| 115 } |
| 116 |
99 // Indicate to interested observers that the resource in question matched the | 117 // Indicate to interested observers that the resource in question matched the |
100 // SB filters. If the resource is already whitelisted, OnSafeBrowsingHit | 118 // SB filters. If the resource is already whitelisted, OnSafeBrowsingHit |
101 // won't be called. | 119 // won't be called. |
102 if (resource.threat_type != SB_THREAT_TYPE_SAFE) { | 120 if (resource.threat_type != SB_THREAT_TYPE_SAFE) { |
103 FOR_EACH_OBSERVER(Observer, observer_list_, OnSafeBrowsingMatch(resource)); | 121 FOR_EACH_OBSERVER(Observer, observer_list_, OnSafeBrowsingMatch(resource)); |
104 } | 122 } |
105 | 123 |
106 // Check if the user has already ignored our warning for this render_view | 124 // Check if the user has already ignored our warning for this render_view |
107 // and domain. | 125 // and domain. |
108 if (IsWhitelisted(resource)) { | 126 if (IsWhitelisted(resource)) { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 resource.threat_type == SB_THREAT_TYPE_URL_MALWARE))) { | 284 resource.threat_type == SB_THREAT_TYPE_URL_MALWARE))) { |
267 return entry.domain == | 285 return entry.domain == |
268 net::registry_controlled_domains::GetDomainAndRegistry( | 286 net::registry_controlled_domains::GetDomainAndRegistry( |
269 resource.url, | 287 resource.url, |
270 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | 288 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
271 } | 289 } |
272 } | 290 } |
273 return false; | 291 return false; |
274 } | 292 } |
275 | 293 |
OLD | NEW |