| 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, is_main_frame_load_blocked_, url_, this); | 314 web_contents, IsMainPageLoadBlocked(unsafe_resources), 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 | |
| 889 void SafeBrowsingBlockingPage::ShowBlockingPage( | 875 void SafeBrowsingBlockingPage::ShowBlockingPage( |
| 890 SafeBrowsingUIManager* ui_manager, | 876 SafeBrowsingUIManager* ui_manager, |
| 891 const UnsafeResource& unsafe_resource) { | 877 const UnsafeResource& unsafe_resource) { |
| 892 DVLOG(1) << __FUNCTION__ << " " << unsafe_resource.url.spec(); | 878 DVLOG(1) << __FUNCTION__ << " " << unsafe_resource.url.spec(); |
| 893 WebContents* web_contents = tab_util::GetWebContentsByID( | 879 WebContents* web_contents = tab_util::GetWebContentsByID( |
| 894 unsafe_resource.render_process_host_id, unsafe_resource.render_view_id); | 880 unsafe_resource.render_process_host_id, unsafe_resource.render_view_id); |
| 895 | 881 |
| 896 InterstitialPage* interstitial = | 882 InterstitialPage* interstitial = |
| 897 InterstitialPage::GetInterstitialPage(web_contents); | 883 InterstitialPage::GetInterstitialPage(web_contents); |
| 898 if (interstitial && !unsafe_resource.is_subresource) { | 884 if (interstitial && !unsafe_resource.is_subresource) { |
| 899 // There is already an interstitial showing and we are about to display a | 885 // There is already an interstitial showing and we are about to display a |
| 900 // new one for the main frame. Just hide the current one, it is now | 886 // new one for the main frame. Just hide the current one, it is now |
| 901 // irrelevent | 887 // irrelevent |
| 902 interstitial->DontProceed(); | 888 interstitial->DontProceed(); |
| 903 interstitial = NULL; | 889 interstitial = NULL; |
| 904 } | 890 } |
| 905 | 891 |
| 906 if (!interstitial) { | 892 if (!interstitial) { |
| 907 // There are no interstitial currently showing in that tab, go ahead and | 893 // There are no interstitial currently showing in that tab, go ahead and |
| 908 // show this interstitial. | 894 // 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(); |
| 909 SafeBrowsingBlockingPage* blocking_page = | 901 SafeBrowsingBlockingPage* blocking_page = |
| 910 CreateBlockingPage(ui_manager, web_contents, unsafe_resource); | 902 factory_->CreateSafeBrowsingPage(ui_manager, web_contents, resources); |
| 911 blocking_page->interstitial_page_->Show(); | 903 blocking_page->interstitial_page_->Show(); |
| 912 return; | 904 return; |
| 913 } | 905 } |
| 914 | 906 |
| 915 // This is an interstitial for a page's resource, let's queue it. | 907 // This is an interstitial for a page's resource, let's queue it. |
| 916 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); | 908 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); |
| 917 (*unsafe_resource_map)[web_contents].push_back(unsafe_resource); | 909 (*unsafe_resource_map)[web_contents].push_back(unsafe_resource); |
| 918 } | 910 } |
| 919 | 911 |
| 920 // static | 912 // static |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1401 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, | 1393 IDS_PHISHING_V3_PRIMARY_PARAGRAPH, |
| 1402 base::UTF8ToUTF16(url_.host()))); | 1394 base::UTF8ToUTF16(url_.host()))); |
| 1403 load_time_data->SetString( | 1395 load_time_data->SetString( |
| 1404 "explanationParagraph", | 1396 "explanationParagraph", |
| 1405 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, | 1397 l10n_util::GetStringFUTF16(IDS_PHISHING_V3_EXPLANATION_PARAGRAPH, |
| 1406 base::UTF8ToUTF16(url_.host()))); | 1398 base::UTF8ToUTF16(url_.host()))); |
| 1407 load_time_data->SetString( | 1399 load_time_data->SetString( |
| 1408 "finalParagraph", | 1400 "finalParagraph", |
| 1409 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); | 1401 l10n_util::GetStringUTF16(IDS_PHISHING_V3_PROCEED_PARAGRAPH)); |
| 1410 } | 1402 } |
| OLD | NEW |