Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service.cc

Issue 18346: Adds support for multiple malware/phishing resources in a page (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 entry.result == result && 260 entry.result == result &&
261 entry.domain == 261 entry.domain ==
262 net::RegistryControlledDomainService::GetDomainAndRegistry(url)) { 262 net::RegistryControlledDomainService::GetDomainAndRegistry(url)) {
263 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( 263 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod(
264 this, &SafeBrowsingService::NotifyClientBlockingComplete, 264 this, &SafeBrowsingService::NotifyClientBlockingComplete,
265 client, true)); 265 client, true));
266 return; 266 return;
267 } 267 }
268 } 268 }
269 269
270 BlockingPageParam param; 270 UnsafeResource resource;
271 param.url = url; 271 resource.url = url;
272 param.resource_type = resource_type; 272 resource.resource_type = resource_type;
273 param.result = result; 273 resource.threat_type= result;
274 param.client = client; 274 resource.client = client;
275 param.render_process_host_id = render_process_host_id; 275 resource.render_process_host_id = render_process_host_id;
276 param.render_view_id = render_view_id; 276 resource.render_view_id = render_view_id;
277 // The blocking page must be created from the UI thread. 277 // The blocking page must be created from the UI thread.
278 ui_loop->PostTask(FROM_HERE, NewRunnableMethod(this, 278 ui_loop->PostTask(FROM_HERE, NewRunnableMethod(this,
279 &SafeBrowsingService::DoDisplayBlockingPage, 279 &SafeBrowsingService::DoDisplayBlockingPage,
280 param)); 280 resource));
281 } 281 }
282 282
283 // Invoked on the UI thread. 283 // Invoked on the UI thread.
284 void SafeBrowsingService::DoDisplayBlockingPage( 284 void SafeBrowsingService::DoDisplayBlockingPage(
285 const BlockingPageParam& param) { 285 const UnsafeResource& resource) {
286 // The tab might have been closed. 286 // The tab might have been closed.
287 if (!tab_util::GetWebContentsByID(param.render_process_host_id, 287 if (!tab_util::GetWebContentsByID(resource.render_process_host_id,
288 param.render_view_id)) { 288 resource.render_view_id)) {
289 // The tab is gone and we did not have a chance at showing the interstitial. 289 // The tab is gone and we did not have a chance at showing the interstitial.
290 // Just act as "Don't Proceed" was chosen. 290 // Just act as "Don't Proceed" was chosen.
291 base::Thread* io_thread = g_browser_process->io_thread(); 291 base::Thread* io_thread = g_browser_process->io_thread();
292 if (!io_thread) 292 if (!io_thread)
293 return; 293 return;
294 BlockingPageParam response_param = param; 294 std::vector<UnsafeResource> resources;
295 response_param.proceed = false; 295 resources.push_back(resource);
296 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( 296 io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(
297 this, &SafeBrowsingService::OnBlockingPageDone, response_param)); 297 this, &SafeBrowsingService::OnBlockingPageDone, resources, false));
298 return; 298 return;
299 } 299 }
300 SafeBrowsingBlockingPage* blocking_page = new SafeBrowsingBlockingPage(this, 300 SafeBrowsingBlockingPage::ShowBlockingPage(this, resource);
301 param);
302 blocking_page->Show();
303 } 301 }
304 302
305 void SafeBrowsingService::CancelCheck(Client* client) { 303 void SafeBrowsingService::CancelCheck(Client* client) {
306 DCHECK(MessageLoop::current() == io_loop_); 304 DCHECK(MessageLoop::current() == io_loop_);
307 305
308 for (CurrentChecks::iterator i = checks_.begin(); i != checks_.end(); ++i) { 306 for (CurrentChecks::iterator i = checks_.begin(); i != checks_.end(); ++i) {
309 if ((*i)->client == client) 307 if ((*i)->client == client)
310 (*i)->client = NULL; 308 (*i)->client = NULL;
311 } 309 }
312 310
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 this, &SafeBrowsingService::DatabaseUpdateFinished, update_succeeded)); 510 this, &SafeBrowsingService::DatabaseUpdateFinished, update_succeeded));
513 } 511 }
514 } 512 }
515 513
516 void SafeBrowsingService::DatabaseUpdateFinished(bool update_succeeded) { 514 void SafeBrowsingService::DatabaseUpdateFinished(bool update_succeeded) {
517 DCHECK(MessageLoop::current() == db_thread_->message_loop()); 515 DCHECK(MessageLoop::current() == db_thread_->message_loop());
518 if (GetDatabase()) 516 if (GetDatabase())
519 GetDatabase()->UpdateFinished(update_succeeded); 517 GetDatabase()->UpdateFinished(update_succeeded);
520 } 518 }
521 519
522 void SafeBrowsingService::OnBlockingPageDone(const BlockingPageParam& param) { 520 void SafeBrowsingService::OnBlockingPageDone(
523 NotifyClientBlockingComplete(param.client, param.proceed); 521 const std::vector<UnsafeResource>& resources,
522 bool proceed) {
523 for (std::vector<UnsafeResource>::const_iterator iter = resources.begin();
524 iter != resources.end(); ++iter) {
525 const UnsafeResource& resource = *iter;
526 NotifyClientBlockingComplete(resource.client, proceed);
524 527
525 if (param.proceed) { 528 if (proceed) {
526 // Whitelist this domain and warning type for the given tab. 529 // Whitelist this domain and warning type for the given tab.
527 WhiteListedEntry entry; 530 WhiteListedEntry entry;
528 entry.render_process_host_id = param.render_process_host_id; 531 entry.render_process_host_id = resource.render_process_host_id;
529 entry.render_view_id = param.render_view_id; 532 entry.render_view_id = resource.render_view_id;
530 entry.domain = 533 entry.domain = net::RegistryControlledDomainService::GetDomainAndRegistry(
531 net::RegistryControlledDomainService::GetDomainAndRegistry(param.url); 534 resource.url);
532 entry.result = param.result; 535 entry.result = resource.threat_type;
533 white_listed_entries_.push_back(entry); 536 white_listed_entries_.push_back(entry);
537 }
534 } 538 }
535 } 539 }
536 540
537 void SafeBrowsingService::NotifyClientBlockingComplete(Client* client, 541 void SafeBrowsingService::NotifyClientBlockingComplete(Client* client,
538 bool proceed) { 542 bool proceed) {
539 client->OnBlockingPageComplete(proceed); 543 client->OnBlockingPageComplete(proceed);
540 } 544 }
541 545
542 // This method runs on the UI loop to access the prefs. 546 // This method runs on the UI loop to access the prefs.
543 void SafeBrowsingService::OnNewMacKeys(const std::string& client_key, 547 void SafeBrowsingService::OnNewMacKeys(const std::string& client_key,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 DCHECK(MessageLoop::current() == io_loop_); 723 DCHECK(MessageLoop::current() == io_loop_);
720 HISTOGRAM_COUNTS(L"SB.QueueDepth", queued_checks_.size()); 724 HISTOGRAM_COUNTS(L"SB.QueueDepth", queued_checks_.size());
721 while (!queued_checks_.empty()) { 725 while (!queued_checks_.empty()) {
722 QueuedCheck check = queued_checks_.front(); 726 QueuedCheck check = queued_checks_.front();
723 HISTOGRAM_TIMES(L"SB.QueueDelay", Time::Now() - check.start); 727 HISTOGRAM_TIMES(L"SB.QueueDelay", Time::Now() - check.start);
724 CheckUrl(check.url, check.client); 728 CheckUrl(check.url, check.client);
725 queued_checks_.pop_front(); 729 queued_checks_.pop_front();
726 } 730 }
727 } 731 }
728 732
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | chrome/browser/tab_contents/interstitial_page.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698