| OLD | NEW |
| 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 // Implementation of the SafeBrowsingBlockingPage class. | 5 // Implementation of the SafeBrowsingBlockingPage class. |
| 6 | 6 |
| 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" | 7 #include "chrome/browser/safe_browsing/safe_browsing_blocking_page.h" |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 11 #include "base/histogram.h" | 11 #include "base/histogram.h" |
| 12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/chrome_thread.h" |
| 15 #include "chrome/browser/dom_operation_notification_details.h" | 15 #include "chrome/browser/dom_operation_notification_details.h" |
| 16 #include "chrome/browser/dom_ui/new_tab_ui.h" | 16 #include "chrome/browser/dom_ui/new_tab_ui.h" |
| 17 #include "chrome/browser/google_util.h" | 17 #include "chrome/browser/google_util.h" |
| 18 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 18 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 19 #include "chrome/browser/tab_contents/navigation_controller.h" | 19 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 20 #include "chrome/browser/tab_contents/navigation_entry.h" | 20 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 21 #include "chrome/browser/tab_contents/tab_util.h" | 21 #include "chrome/browser/tab_contents/tab_util.h" |
| 22 #include "chrome/browser/tab_contents/tab_contents.h" | 22 #include "chrome/browser/tab_contents/tab_contents.h" |
| 23 #include "chrome/common/jstemplate_builder.h" | 23 #include "chrome/common/jstemplate_builder.h" |
| 24 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 } | 430 } |
| 431 InterstitialPage::DontProceed(); | 431 InterstitialPage::DontProceed(); |
| 432 // We are now deleted. | 432 // We are now deleted. |
| 433 } | 433 } |
| 434 | 434 |
| 435 // static | 435 // static |
| 436 void SafeBrowsingBlockingPage::NotifySafeBrowsingService( | 436 void SafeBrowsingBlockingPage::NotifySafeBrowsingService( |
| 437 SafeBrowsingService* sb_service, | 437 SafeBrowsingService* sb_service, |
| 438 const UnsafeResourceList& unsafe_resources, | 438 const UnsafeResourceList& unsafe_resources, |
| 439 bool proceed) { | 439 bool proceed) { |
| 440 MessageLoop* message_loop; | 440 ChromeThread::PostTask( |
| 441 if (g_browser_process->io_thread()) | 441 ChromeThread::IO, FROM_HERE, |
| 442 message_loop = g_browser_process->io_thread()->message_loop(); | 442 NewRunnableMethod( |
| 443 else // For unit-tests, just post on the current thread. | 443 sb_service, &SafeBrowsingService::OnBlockingPageDone, |
| 444 message_loop = MessageLoop::current(); | 444 unsafe_resources, proceed)); |
| 445 | |
| 446 message_loop->PostTask(FROM_HERE, NewRunnableMethod( | |
| 447 sb_service, &SafeBrowsingService::OnBlockingPageDone, unsafe_resources, | |
| 448 proceed)); | |
| 449 } | 445 } |
| 450 | 446 |
| 451 // static | 447 // static |
| 452 SafeBrowsingBlockingPage::UnsafeResourceMap* | 448 SafeBrowsingBlockingPage::UnsafeResourceMap* |
| 453 SafeBrowsingBlockingPage::GetUnsafeResourcesMap() { | 449 SafeBrowsingBlockingPage::GetUnsafeResourcesMap() { |
| 454 return Singleton<UnsafeResourceMap>::get(); | 450 return Singleton<UnsafeResourceMap>::get(); |
| 455 } | 451 } |
| 456 | 452 |
| 457 // static | 453 // static |
| 458 void SafeBrowsingBlockingPage::ShowBlockingPage( | 454 void SafeBrowsingBlockingPage::ShowBlockingPage( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); | 487 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); |
| 492 (*unsafe_resource_map)[tab_contents].push_back(unsafe_resource); | 488 (*unsafe_resource_map)[tab_contents].push_back(unsafe_resource); |
| 493 } | 489 } |
| 494 | 490 |
| 495 // static | 491 // static |
| 496 bool SafeBrowsingBlockingPage::IsMainPage( | 492 bool SafeBrowsingBlockingPage::IsMainPage( |
| 497 const UnsafeResourceList& unsafe_resources) { | 493 const UnsafeResourceList& unsafe_resources) { |
| 498 return unsafe_resources.size() == 1 && | 494 return unsafe_resources.size() == 1 && |
| 499 unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME; | 495 unsafe_resources[0].resource_type == ResourceType::MAIN_FRAME; |
| 500 } | 496 } |
| OLD | NEW |