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 // 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 <string> | 9 #include <string> |
10 | 10 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 // clicked through the first warning, so we don't prepare additional | 304 // clicked through the first warning, so we don't prepare additional |
305 // reports. | 305 // reports. |
306 if (unsafe_resources.size() == 1 && | 306 if (unsafe_resources.size() == 1 && |
307 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE && | 307 unsafe_resources[0].threat_type == SB_THREAT_TYPE_URL_MALWARE && |
308 malware_details_.get() == NULL && CanShowMalwareDetailsOption()) { | 308 malware_details_.get() == NULL && CanShowMalwareDetailsOption()) { |
309 malware_details_ = MalwareDetails::NewMalwareDetails( | 309 malware_details_ = MalwareDetails::NewMalwareDetails( |
310 ui_manager_, web_contents, unsafe_resources[0]); | 310 ui_manager_, web_contents, unsafe_resources[0]); |
311 } | 311 } |
312 | 312 |
313 interstitial_page_ = InterstitialPage::Create( | 313 interstitial_page_ = InterstitialPage::Create( |
314 web_contents, IsMainPageLoadBlocked(unsafe_resources), url_, this); | 314 web_contents, is_main_frame_load_blocked_, url_, this); |
315 } | 315 } |
316 | 316 |
317 bool SafeBrowsingBlockingPage::CanShowMalwareDetailsOption() { | 317 bool SafeBrowsingBlockingPage::CanShowMalwareDetailsOption() { |
318 return (!web_contents_->GetBrowserContext()->IsOffTheRecord() && | 318 return (!web_contents_->GetBrowserContext()->IsOffTheRecord() && |
319 web_contents_->GetURL().SchemeIs(url::kHttpScheme)); | 319 web_contents_->GetURL().SchemeIs(url::kHttpScheme)); |
320 } | 320 } |
321 | 321 |
322 SafeBrowsingBlockingPage::~SafeBrowsingBlockingPage() { | 322 SafeBrowsingBlockingPage::~SafeBrowsingBlockingPage() { |
323 } | 323 } |
324 | 324 |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 ui_manager, unsafe_resources, proceed)); | 865 ui_manager, unsafe_resources, proceed)); |
866 } | 866 } |
867 | 867 |
868 // static | 868 // static |
869 SafeBrowsingBlockingPage::UnsafeResourceMap* | 869 SafeBrowsingBlockingPage::UnsafeResourceMap* |
870 SafeBrowsingBlockingPage::GetUnsafeResourcesMap() { | 870 SafeBrowsingBlockingPage::GetUnsafeResourcesMap() { |
871 return g_unsafe_resource_map.Pointer(); | 871 return g_unsafe_resource_map.Pointer(); |
872 } | 872 } |
873 | 873 |
874 // static | 874 // static |
| 875 SafeBrowsingBlockingPage* SafeBrowsingBlockingPage::CreateBlockingPage( |
| 876 SafeBrowsingUIManager* ui_manager, |
| 877 WebContents* web_contents, |
| 878 const UnsafeResource& unsafe_resource) { |
| 879 std::vector<UnsafeResource> resources; |
| 880 resources.push_back(unsafe_resource); |
| 881 // Set up the factory if this has not been done already (tests do that |
| 882 // before this method is called). |
| 883 if (!factory_) |
| 884 factory_ = g_safe_browsing_blocking_page_factory_impl.Pointer(); |
| 885 return factory_->CreateSafeBrowsingPage(ui_manager, web_contents, resources); |
| 886 } |
| 887 |
| 888 // static |
875 void SafeBrowsingBlockingPage::ShowBlockingPage( | 889 void SafeBrowsingBlockingPage::ShowBlockingPage( |
876 SafeBrowsingUIManager* ui_manager, | 890 SafeBrowsingUIManager* ui_manager, |
877 const UnsafeResource& unsafe_resource) { | 891 const UnsafeResource& unsafe_resource) { |
878 DVLOG(1) << __FUNCTION__ << " " << unsafe_resource.url.spec(); | 892 DVLOG(1) << __FUNCTION__ << " " << unsafe_resource.url.spec(); |
879 WebContents* web_contents = tab_util::GetWebContentsByID( | 893 WebContents* web_contents = tab_util::GetWebContentsByID( |
880 unsafe_resource.render_process_host_id, unsafe_resource.render_view_id); | 894 unsafe_resource.render_process_host_id, unsafe_resource.render_view_id); |
881 | 895 |
882 InterstitialPage* interstitial = | 896 InterstitialPage* interstitial = |
883 InterstitialPage::GetInterstitialPage(web_contents); | 897 InterstitialPage::GetInterstitialPage(web_contents); |
884 if (interstitial && !unsafe_resource.is_subresource) { | 898 if (interstitial && !unsafe_resource.is_subresource) { |
885 // There is already an interstitial showing and we are about to display a | 899 // There is already an interstitial showing and we are about to display a |
886 // new one for the main frame. Just hide the current one, it is now | 900 // new one for the main frame. Just hide the current one, it is now |
887 // irrelevent | 901 // irrelevent |
888 interstitial->DontProceed(); | 902 interstitial->DontProceed(); |
889 interstitial = NULL; | 903 interstitial = NULL; |
890 } | 904 } |
891 | 905 |
892 if (!interstitial) { | 906 if (!interstitial) { |
893 // There are no interstitial currently showing in that tab, go ahead and | 907 // There are no interstitial currently showing in that tab, go ahead and |
894 // show this interstitial. | 908 // show this interstitial. |
895 std::vector<UnsafeResource> resources; | |
896 resources.push_back(unsafe_resource); | |
897 // Set up the factory if this has not been done already (tests do that | |
898 // before this method is called). | |
899 if (!factory_) | |
900 factory_ = g_safe_browsing_blocking_page_factory_impl.Pointer(); | |
901 SafeBrowsingBlockingPage* blocking_page = | 909 SafeBrowsingBlockingPage* blocking_page = |
902 factory_->CreateSafeBrowsingPage(ui_manager, web_contents, resources); | 910 CreateBlockingPage(ui_manager, web_contents, unsafe_resource); |
903 blocking_page->interstitial_page_->Show(); | 911 blocking_page->interstitial_page_->Show(); |
904 return; | 912 return; |
905 } | 913 } |
906 | 914 |
907 // This is an interstitial for a page's resource, let's queue it. | 915 // This is an interstitial for a page's resource, let's queue it. |
908 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); | 916 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); |
909 (*unsafe_resource_map)[web_contents].push_back(unsafe_resource); | 917 (*unsafe_resource_map)[web_contents].push_back(unsafe_resource); |
910 } | 918 } |
911 | 919 |
912 // static | 920 // static |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, | 1401 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, |
1394 base::UTF8ToUTF16(url_.host()))); | 1402 base::UTF8ToUTF16(url_.host()))); |
1395 load_time_data->SetString( | 1403 load_time_data->SetString( |
1396 "explanationParagraph", | 1404 "explanationParagraph", |
1397 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, | 1405 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, |
1398 base::UTF8ToUTF16(url_.host()))); | 1406 base::UTF8ToUTF16(url_.host()))); |
1399 load_time_data->SetString( | 1407 load_time_data->SetString( |
1400 "finalParagraph", | 1408 "finalParagraph", |
1401 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 1409 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
1402 } | 1410 } |
OLD | NEW |