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