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/base_safe_browsing_error_ui.h" | 10 #include "components/security_interstitials/core/base_safe_browsing_error_ui.h" |
| 11 #include "components/security_interstitials/core/safe_browsing_quiet_error_ui.h" |
11 #include "content/public/browser/interstitial_page.h" | 12 #include "content/public/browser/interstitial_page.h" |
12 #include "content/public/browser/navigation_entry.h" | 13 #include "content/public/browser/navigation_entry.h" |
13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
14 | 15 |
15 using content::InterstitialPage; | 16 using content::InterstitialPage; |
16 using content::WebContents; | 17 using content::WebContents; |
17 using security_interstitials::BaseSafeBrowsingErrorUI; | 18 using security_interstitials::BaseSafeBrowsingErrorUI; |
| 19 using security_interstitials::SafeBrowsingQuietErrorUI; |
18 using security_interstitials::SecurityInterstitialControllerClient; | 20 using security_interstitials::SecurityInterstitialControllerClient; |
19 | 21 |
20 namespace android_webview { | 22 namespace android_webview { |
21 | 23 |
22 AwSafeBrowsingBlockingPage::AwSafeBrowsingBlockingPage( | 24 AwSafeBrowsingBlockingPage::AwSafeBrowsingBlockingPage( |
23 AwSafeBrowsingUIManager* ui_manager, | 25 AwSafeBrowsingUIManager* ui_manager, |
24 WebContents* web_contents, | 26 WebContents* web_contents, |
25 const GURL& main_frame_url, | 27 const GURL& main_frame_url, |
26 const UnsafeResourceList& unsafe_resources, | 28 const UnsafeResourceList& unsafe_resources, |
27 std::unique_ptr<SecurityInterstitialControllerClient> controller_client, | 29 std::unique_ptr<SecurityInterstitialControllerClient> controller_client, |
28 const BaseSafeBrowsingErrorUI::SBErrorDisplayOptions& display_options) | 30 const BaseSafeBrowsingErrorUI::SBErrorDisplayOptions& display_options, |
| 31 ErrorUiType errorUiType) |
29 : BaseBlockingPage(ui_manager, | 32 : BaseBlockingPage(ui_manager, |
30 web_contents, | 33 web_contents, |
31 main_frame_url, | 34 main_frame_url, |
32 unsafe_resources, | 35 unsafe_resources, |
33 std::move(controller_client), | 36 std::move(controller_client), |
34 display_options) {} | 37 display_options) { |
| 38 if (errorUiType == ErrorUiType::QUIET_SMALL || |
| 39 errorUiType == ErrorUiType::QUIET_GIANT) { |
| 40 set_sb_error_ui(base::MakeUnique<SafeBrowsingQuietErrorUI>( |
| 41 unsafe_resources[0].url, main_frame_url, |
| 42 GetInterstitialReason(unsafe_resources), display_options, |
| 43 ui_manager->app_locale(), base::Time::NowFromSystemTime(), controller(), |
| 44 errorUiType == ErrorUiType::QUIET_GIANT)); |
| 45 } |
| 46 } |
35 | 47 |
36 // static | 48 // static |
37 void AwSafeBrowsingBlockingPage::ShowBlockingPage( | 49 void AwSafeBrowsingBlockingPage::ShowBlockingPage( |
38 AwSafeBrowsingUIManager* ui_manager, | 50 AwSafeBrowsingUIManager* ui_manager, |
39 const UnsafeResource& unsafe_resource) { | 51 const UnsafeResource& unsafe_resource) { |
40 DVLOG(1) << __func__ << " " << unsafe_resource.url.spec(); | 52 DVLOG(1) << __func__ << " " << unsafe_resource.url.spec(); |
41 WebContents* web_contents = unsafe_resource.web_contents_getter.Run(); | 53 WebContents* web_contents = unsafe_resource.web_contents_getter.Run(); |
42 | 54 |
43 if (InterstitialPage::GetInterstitialPage(web_contents) && | 55 if (InterstitialPage::GetInterstitialPage(web_contents) && |
44 unsafe_resource.is_subresource) { | 56 unsafe_resource.is_subresource) { |
(...skipping 10 matching lines...) Expand all Loading... |
55 BaseSafeBrowsingErrorUI::SBErrorDisplayOptions display_options = | 67 BaseSafeBrowsingErrorUI::SBErrorDisplayOptions display_options = |
56 BaseSafeBrowsingErrorUI::SBErrorDisplayOptions( | 68 BaseSafeBrowsingErrorUI::SBErrorDisplayOptions( |
57 IsMainPageLoadBlocked(unsafe_resources), | 69 IsMainPageLoadBlocked(unsafe_resources), |
58 false, // kSafeBrowsingExtendedReportingOptInAllowed | 70 false, // kSafeBrowsingExtendedReportingOptInAllowed |
59 false, // is_off_the_record | 71 false, // is_off_the_record |
60 false, // is_extended_reporting | 72 false, // is_extended_reporting |
61 false, // is_scout | 73 false, // is_scout |
62 false, // kSafeBrowsingProceedAnywayDisabled | 74 false, // kSafeBrowsingProceedAnywayDisabled |
63 true, // is_resource_cancellable | 75 true, // is_resource_cancellable |
64 "cpn_safe_browsing_wv"); // help_center_article_link | 76 "cpn_safe_browsing_wv"); // help_center_article_link |
| 77 |
| 78 ErrorUiType errorType = |
| 79 static_cast<ErrorUiType>(ui_manager->GetErrorUiType(unsafe_resource)); |
| 80 |
65 AwSafeBrowsingBlockingPage* blocking_page = new AwSafeBrowsingBlockingPage( | 81 AwSafeBrowsingBlockingPage* blocking_page = new AwSafeBrowsingBlockingPage( |
66 ui_manager, web_contents, entry ? entry->GetURL() : GURL(), | 82 ui_manager, web_contents, entry ? entry->GetURL() : GURL(), |
67 unsafe_resources, | 83 unsafe_resources, |
68 CreateControllerClient(web_contents, unsafe_resources, ui_manager), | 84 CreateControllerClient(web_contents, unsafe_resources, ui_manager), |
69 display_options); | 85 display_options, errorType); |
70 blocking_page->Show(); | 86 blocking_page->Show(); |
71 } | 87 } |
72 } | 88 } |
73 | 89 |
74 } // namespace android_webview | 90 } // namespace android_webview |
OLD | NEW |