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" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 sb_service_->ping_manager()->ReportMalwareDetails(serialized); | 247 sb_service_->ping_manager()->ReportMalwareDetails(serialized); |
248 } | 248 } |
249 } | 249 } |
250 | 250 |
251 void SafeBrowsingUIManager::UpdateWhitelist(const UnsafeResource& resource) { | 251 void SafeBrowsingUIManager::UpdateWhitelist(const UnsafeResource& resource) { |
252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 252 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
253 // Whitelist this domain and warning type for the given tab. | 253 // Whitelist this domain and warning type for the given tab. |
254 WhiteListedEntry entry; | 254 WhiteListedEntry entry; |
255 entry.render_process_host_id = resource.render_process_host_id; | 255 entry.render_process_host_id = resource.render_process_host_id; |
256 entry.render_view_id = resource.render_view_id; | 256 entry.render_view_id = resource.render_view_id; |
257 entry.domain = net::RegistryControlledDomainService::GetDomainAndRegistry( | 257 entry.domain = net::registry_controlled_domains::GetDomainAndRegistry( |
258 resource.url); | 258 resource.url, |
| 259 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
259 entry.threat_type = resource.threat_type; | 260 entry.threat_type = resource.threat_type; |
260 white_listed_entries_.push_back(entry); | 261 white_listed_entries_.push_back(entry); |
261 } | 262 } |
262 | 263 |
263 bool SafeBrowsingUIManager::IsWhitelisted(const UnsafeResource& resource) { | 264 bool SafeBrowsingUIManager::IsWhitelisted(const UnsafeResource& resource) { |
264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 265 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
265 // Check if the user has already ignored our warning for this render_view | 266 // Check if the user has already ignored our warning for this render_view |
266 // and domain. | 267 // and domain. |
267 for (size_t i = 0; i < white_listed_entries_.size(); ++i) { | 268 for (size_t i = 0; i < white_listed_entries_.size(); ++i) { |
268 const WhiteListedEntry& entry = white_listed_entries_[i]; | 269 const WhiteListedEntry& entry = white_listed_entries_[i]; |
269 if (entry.render_process_host_id == resource.render_process_host_id && | 270 if (entry.render_process_host_id == resource.render_process_host_id && |
270 entry.render_view_id == resource.render_view_id && | 271 entry.render_view_id == resource.render_view_id && |
271 // Threat type must be the same or in the case of phishing they can | 272 // Threat type must be the same or in the case of phishing they can |
272 // either be client-side phishing URL or a SafeBrowsing phishing URL. | 273 // either be client-side phishing URL or a SafeBrowsing phishing URL. |
273 // If we show one type of phishing warning we don't want to show a | 274 // If we show one type of phishing warning we don't want to show a |
274 // second phishing warning. | 275 // second phishing warning. |
275 (entry.threat_type == resource.threat_type || | 276 (entry.threat_type == resource.threat_type || |
276 (entry.threat_type == SB_THREAT_TYPE_URL_PHISHING && | 277 (entry.threat_type == SB_THREAT_TYPE_URL_PHISHING && |
277 resource.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL) || | 278 resource.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL) || |
278 (entry.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL && | 279 (entry.threat_type == SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL && |
279 resource.threat_type == SB_THREAT_TYPE_URL_PHISHING)) && | 280 resource.threat_type == SB_THREAT_TYPE_URL_PHISHING))) { |
280 entry.domain == | 281 return entry.domain == |
281 net::RegistryControlledDomainService::GetDomainAndRegistry( | 282 net::registry_controlled_domains::GetDomainAndRegistry( |
282 resource.url)) { | 283 resource.url, |
283 return true; | 284 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
284 } | 285 } |
285 } | 286 } |
286 return false; | 287 return false; |
287 } | 288 } |
OLD | NEW |