| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #include "android_webview/browser/aw_safe_browsing_blocking_page.h" | 5 #include "android_webview/browser/aw_safe_browsing_blocking_page.h" |
| 6 | 6 |
| 7 #include "android_webview/browser/aw_safe_browsing_ui_manager.h" | 7 #include "android_webview/browser/aw_safe_browsing_ui_manager.h" |
| 8 #include "components/security_interstitials/content/security_interstitial_contro
ller_client.h" | 8 #include "components/security_interstitials/content/security_interstitial_contro
ller_client.h" |
| 9 #include "components/security_interstitials/content/unsafe_resource.h" | 9 #include "components/security_interstitials/content/unsafe_resource.h" |
| 10 #include "components/security_interstitials/core/safe_browsing_error_ui.h" | 10 #include "components/security_interstitials/core/base_safe_browsing_error_ui.h" |
| 11 #include "content/public/browser/interstitial_page.h" | 11 #include "content/public/browser/interstitial_page.h" |
| 12 #include "content/public/browser/navigation_entry.h" | 12 #include "content/public/browser/navigation_entry.h" |
| 13 #include "content/public/browser/web_contents.h" | 13 #include "content/public/browser/web_contents.h" |
| 14 | 14 |
| 15 using content::InterstitialPage; | 15 using content::InterstitialPage; |
| 16 using content::WebContents; | 16 using content::WebContents; |
| 17 using security_interstitials::SafeBrowsingErrorUI; | 17 using security_interstitials::BaseSafeBrowsingErrorUI; |
| 18 using security_interstitials::SecurityInterstitialControllerClient; | 18 using security_interstitials::SecurityInterstitialControllerClient; |
| 19 | 19 |
| 20 namespace android_webview { | 20 namespace android_webview { |
| 21 | 21 |
| 22 AwSafeBrowsingBlockingPage::AwSafeBrowsingBlockingPage( | 22 AwSafeBrowsingBlockingPage::AwSafeBrowsingBlockingPage( |
| 23 AwSafeBrowsingUIManager* ui_manager, | 23 AwSafeBrowsingUIManager* ui_manager, |
| 24 WebContents* web_contents, | 24 WebContents* web_contents, |
| 25 const GURL& main_frame_url, | 25 const GURL& main_frame_url, |
| 26 const UnsafeResourceList& unsafe_resources, | 26 const UnsafeResourceList& unsafe_resources, |
| 27 std::unique_ptr<SecurityInterstitialControllerClient> controller_client, | 27 std::unique_ptr<SecurityInterstitialControllerClient> controller_client, |
| 28 const SafeBrowsingErrorUI::SBErrorDisplayOptions& display_options) | 28 const BaseSafeBrowsingErrorUI::SBErrorDisplayOptions& display_options) |
| 29 : BaseBlockingPage(ui_manager, | 29 : BaseBlockingPage(ui_manager, |
| 30 web_contents, | 30 web_contents, |
| 31 main_frame_url, | 31 main_frame_url, |
| 32 unsafe_resources, | 32 unsafe_resources, |
| 33 std::move(controller_client), | 33 std::move(controller_client), |
| 34 display_options) {} | 34 display_options) {} |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 void AwSafeBrowsingBlockingPage::ShowBlockingPage( | 37 void AwSafeBrowsingBlockingPage::ShowBlockingPage( |
| 38 AwSafeBrowsingUIManager* ui_manager, | 38 AwSafeBrowsingUIManager* ui_manager, |
| 39 const UnsafeResource& unsafe_resource) { | 39 const UnsafeResource& unsafe_resource) { |
| 40 DVLOG(1) << __func__ << " " << unsafe_resource.url.spec(); | 40 DVLOG(1) << __func__ << " " << unsafe_resource.url.spec(); |
| 41 WebContents* web_contents = unsafe_resource.web_contents_getter.Run(); | 41 WebContents* web_contents = unsafe_resource.web_contents_getter.Run(); |
| 42 | 42 |
| 43 if (InterstitialPage::GetInterstitialPage(web_contents) && | 43 if (InterstitialPage::GetInterstitialPage(web_contents) && |
| 44 unsafe_resource.is_subresource) { | 44 unsafe_resource.is_subresource) { |
| 45 // This is an interstitial for a page's resource, let's queue it. | 45 // This is an interstitial for a page's resource, let's queue it. |
| 46 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); | 46 UnsafeResourceMap* unsafe_resource_map = GetUnsafeResourcesMap(); |
| 47 (*unsafe_resource_map)[web_contents].push_back(unsafe_resource); | 47 (*unsafe_resource_map)[web_contents].push_back(unsafe_resource); |
| 48 } else { | 48 } else { |
| 49 // There is no interstitial currently showing, or we are about to display a | 49 // There is no interstitial currently showing, or we are about to display a |
| 50 // new one for the main frame. If there is already an interstitial, showing | 50 // new one for the main frame. If there is already an interstitial, showing |
| 51 // the new one will automatically hide the old one. | 51 // the new one will automatically hide the old one. |
| 52 content::NavigationEntry* entry = | 52 content::NavigationEntry* entry = |
| 53 unsafe_resource.GetNavigationEntryForResource(); | 53 unsafe_resource.GetNavigationEntryForResource(); |
| 54 const UnsafeResourceList unsafe_resources{unsafe_resource}; | 54 const UnsafeResourceList unsafe_resources{unsafe_resource}; |
| 55 SafeBrowsingErrorUI::SBErrorDisplayOptions display_options = | 55 BaseSafeBrowsingErrorUI::SBErrorDisplayOptions display_options = |
| 56 SafeBrowsingErrorUI::SBErrorDisplayOptions( | 56 BaseSafeBrowsingErrorUI::SBErrorDisplayOptions( |
| 57 IsMainPageLoadBlocked(unsafe_resources), | 57 IsMainPageLoadBlocked(unsafe_resources), |
| 58 false, // kSafeBrowsingExtendedReportingOptInAllowed | 58 false, // kSafeBrowsingExtendedReportingOptInAllowed |
| 59 false, // is_off_the_record | 59 false, // is_off_the_record |
| 60 false, // is_extended_reporting | 60 false, // is_extended_reporting |
| 61 false, // is_scout | 61 false, // is_scout |
| 62 false, // kSafeBrowsingProceedAnywayDisabled | 62 false, // kSafeBrowsingProceedAnywayDisabled |
| 63 true); // is_resource_cancellable | 63 true); // is_resource_cancellable |
| 64 AwSafeBrowsingBlockingPage* blocking_page = new AwSafeBrowsingBlockingPage( | 64 AwSafeBrowsingBlockingPage* blocking_page = new AwSafeBrowsingBlockingPage( |
| 65 ui_manager, web_contents, entry ? entry->GetURL() : GURL(), | 65 ui_manager, web_contents, entry ? entry->GetURL() : GURL(), |
| 66 unsafe_resources, | 66 unsafe_resources, |
| 67 CreateControllerClient(web_contents, unsafe_resources, ui_manager), | 67 CreateControllerClient(web_contents, unsafe_resources, ui_manager), |
| 68 display_options); | 68 display_options); |
| 69 blocking_page->Show(); | 69 blocking_page->Show(); |
| 70 } | 70 } |
| 71 } | 71 } |
| 72 | 72 |
| 73 } // namespace android_webview | 73 } // namespace android_webview |
| OLD | NEW |