OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 | 5 |
6 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 6 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/histogram.h" | 9 #include "base/histogram.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 ChromeThread::IO, FROM_HERE, | 203 ChromeThread::IO, FROM_HERE, |
204 NewRunnableMethod(this, &SafeBrowsingService::OnCheckDone, check)); | 204 NewRunnableMethod(this, &SafeBrowsingService::OnCheckDone, check)); |
205 | 205 |
206 return false; | 206 return false; |
207 } | 207 } |
208 | 208 |
209 void SafeBrowsingService::DisplayBlockingPage(const GURL& url, | 209 void SafeBrowsingService::DisplayBlockingPage(const GURL& url, |
210 ResourceType::Type resource_type, | 210 ResourceType::Type resource_type, |
211 UrlCheckResult result, | 211 UrlCheckResult result, |
212 Client* client, | 212 Client* client, |
213 MessageLoop* ui_loop, | |
214 int render_process_host_id, | 213 int render_process_host_id, |
215 int render_view_id) { | 214 int render_view_id) { |
216 // Check if the user has already ignored our warning for this render_view | 215 // Check if the user has already ignored our warning for this render_view |
217 // and domain. | 216 // and domain. |
218 for (size_t i = 0; i < white_listed_entries_.size(); ++i) { | 217 for (size_t i = 0; i < white_listed_entries_.size(); ++i) { |
219 const WhiteListedEntry& entry = white_listed_entries_[i]; | 218 const WhiteListedEntry& entry = white_listed_entries_[i]; |
220 if (entry.render_process_host_id == render_process_host_id && | 219 if (entry.render_process_host_id == render_process_host_id && |
221 entry.render_view_id == render_view_id && | 220 entry.render_view_id == render_view_id && |
222 entry.result == result && | 221 entry.result == result && |
223 entry.domain == | 222 entry.domain == |
224 net::RegistryControlledDomainService::GetDomainAndRegistry(url)) { | 223 net::RegistryControlledDomainService::GetDomainAndRegistry(url)) { |
225 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 224 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( |
226 this, &SafeBrowsingService::NotifyClientBlockingComplete, | 225 this, &SafeBrowsingService::NotifyClientBlockingComplete, |
227 client, true)); | 226 client, true)); |
228 return; | 227 return; |
229 } | 228 } |
230 } | 229 } |
231 | 230 |
232 UnsafeResource resource; | 231 UnsafeResource resource; |
233 resource.url = url; | 232 resource.url = url; |
234 resource.resource_type = resource_type; | 233 resource.resource_type = resource_type; |
235 resource.threat_type= result; | 234 resource.threat_type= result; |
236 resource.client = client; | 235 resource.client = client; |
237 resource.render_process_host_id = render_process_host_id; | 236 resource.render_process_host_id = render_process_host_id; |
238 resource.render_view_id = render_view_id; | 237 resource.render_view_id = render_view_id; |
239 | 238 |
240 // The blocking page must be created from the UI thread. | 239 // The blocking page must be created from the UI thread. |
241 ui_loop->PostTask(FROM_HERE, NewRunnableMethod(this, | 240 ChromeThread::PostTask( |
242 &SafeBrowsingService::DoDisplayBlockingPage, | 241 ChromeThread::UI, FROM_HERE, |
243 resource)); | 242 NewRunnableMethod( |
| 243 this, &SafeBrowsingService::DoDisplayBlockingPage, resource)); |
244 } | 244 } |
245 | 245 |
246 // Invoked on the UI thread. | 246 // Invoked on the UI thread. |
247 void SafeBrowsingService::DoDisplayBlockingPage( | 247 void SafeBrowsingService::DoDisplayBlockingPage( |
248 const UnsafeResource& resource) { | 248 const UnsafeResource& resource) { |
249 // The tab might have been closed. | 249 // The tab might have been closed. |
250 TabContents* wc = | 250 TabContents* wc = |
251 tab_util::GetTabContentsByID(resource.render_process_host_id, | 251 tab_util::GetTabContentsByID(resource.render_process_host_id, |
252 resource.render_view_id); | 252 resource.render_view_id); |
253 | 253 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 // report if it's not there. | 673 // report if it's not there. |
674 std::string list; | 674 std::string list; |
675 std::vector<SBPrefix> prefix_hits; | 675 std::vector<SBPrefix> prefix_hits; |
676 std::vector<SBFullHashResult> full_hits; | 676 std::vector<SBFullHashResult> full_hits; |
677 database_->ContainsUrl(page_url, &list, &prefix_hits, &full_hits, | 677 database_->ContainsUrl(page_url, &list, &prefix_hits, &full_hits, |
678 protocol_manager_->last_update()); | 678 protocol_manager_->last_update()); |
679 | 679 |
680 if (full_hits.empty()) | 680 if (full_hits.empty()) |
681 protocol_manager_->ReportMalware(malware_url, page_url, referrer_url); | 681 protocol_manager_->ReportMalware(malware_url, page_url, referrer_url); |
682 } | 682 } |
OLD | NEW |