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