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 #ifndef COMPONENTS_SAFE_BROWSING_BASE_BLOCKING_PAGE_H_ | 5 #ifndef COMPONENTS_SAFE_BROWSING_BASE_BLOCKING_PAGE_H_ |
6 #define COMPONENTS_SAFE_BROWSING_BASE_BLOCKING_PAGE_H_ | 6 #define COMPONENTS_SAFE_BROWSING_BASE_BLOCKING_PAGE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "components/safe_browsing/base_ui_manager.h" | 13 #include "components/safe_browsing/base_ui_manager.h" |
14 #include "components/security_interstitials/content/security_interstitial_page.h
" | 14 #include "components/security_interstitials/content/security_interstitial_page.h
" |
| 15 #include "components/security_interstitials/core/metrics_helper.h" |
15 #include "components/security_interstitials/core/safe_browsing_error_ui.h" | 16 #include "components/security_interstitials/core/safe_browsing_error_ui.h" |
16 #include "content/public/browser/interstitial_page_delegate.h" | 17 #include "content/public/browser/interstitial_page_delegate.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 | 19 |
19 namespace history { | |
20 class HistoryService; | |
21 } | |
22 | |
23 namespace safe_browsing { | 20 namespace safe_browsing { |
24 | 21 |
25 // Base class for managing the SafeBrowsing interstitial pages. | 22 // Base class for managing the SafeBrowsing interstitial pages. |
26 class BaseBlockingPage | 23 class BaseBlockingPage |
27 : public security_interstitials::SecurityInterstitialPage { | 24 : public security_interstitials::SecurityInterstitialPage { |
28 public: | 25 public: |
29 typedef security_interstitials::UnsafeResource UnsafeResource; | 26 typedef security_interstitials::UnsafeResource UnsafeResource; |
30 typedef security_interstitials::SafeBrowsingErrorUI SafeBrowsingErrorUI; | 27 typedef security_interstitials::SafeBrowsingErrorUI SafeBrowsingErrorUI; |
31 typedef std::vector<UnsafeResource> UnsafeResourceList; | 28 typedef std::vector<UnsafeResource> UnsafeResourceList; |
32 typedef std::unordered_map<content::WebContents*, UnsafeResourceList> | 29 typedef std::unordered_map<content::WebContents*, UnsafeResourceList> |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 BaseUIManager* ui_manager() const; | 94 BaseUIManager* ui_manager() const; |
98 | 95 |
99 const GURL main_frame_url() const; | 96 const GURL main_frame_url() const; |
100 | 97 |
101 UnsafeResourceList unsafe_resources() const; | 98 UnsafeResourceList unsafe_resources() const; |
102 | 99 |
103 SafeBrowsingErrorUI* sb_error_ui() const; | 100 SafeBrowsingErrorUI* sb_error_ui() const; |
104 | 101 |
105 void set_proceeded(bool proceeded); | 102 void set_proceeded(bool proceeded); |
106 | 103 |
| 104 static security_interstitials::MetricsHelper::ReportDetails GetReportingInfo( |
| 105 const UnsafeResourceList& unsafe_resources); |
| 106 |
| 107 // Called after OnProceed(). Does nothing in this class, but can be overridden |
| 108 // to handle malicious subresources. |
| 109 virtual void HandleSubresourcesAfterProceed(); |
| 110 |
| 111 void SetThreatDetailsProceedDelayForTesting(int64_t delay); |
| 112 |
107 private: | 113 private: |
108 static std::unique_ptr< | 114 static std::unique_ptr< |
109 security_interstitials::SecurityInterstitialControllerClient> | 115 security_interstitials::SecurityInterstitialControllerClient> |
110 CreateControllerClient(content::WebContents* web_contents, | 116 CreateControllerClient(content::WebContents* web_contents, |
111 const UnsafeResourceList& unsafe_resources, | 117 const UnsafeResourceList& unsafe_resources, |
112 history::HistoryService* history_service, | 118 BaseUIManager* ui_manager); |
113 const std::string& app_locale, | |
114 const GURL& default_safe_page); | |
115 | 119 |
116 // For reporting back user actions. | 120 // For reporting back user actions. |
117 BaseUIManager* ui_manager_; | 121 BaseUIManager* ui_manager_; |
118 | 122 |
119 // The URL of the main frame that caused the warning. | 123 // The URL of the main frame that caused the warning. |
120 GURL main_frame_url_; | 124 GURL main_frame_url_; |
121 | 125 |
122 // The index of a navigation entry that should be removed when DontProceed() | 126 // The index of a navigation entry that should be removed when DontProceed() |
123 // is invoked, -1 if entry should not be removed. | 127 // is invoked, -1 if entry should not be removed. |
124 const int navigation_entry_index_to_remove_; | 128 const int navigation_entry_index_to_remove_; |
125 | 129 |
126 // The list of unsafe resources this page is warning about. | 130 // The list of unsafe resources this page is warning about. |
127 UnsafeResourceList unsafe_resources_; | 131 UnsafeResourceList unsafe_resources_; |
128 | 132 |
129 // For displaying safe browsing interstitial. | 133 // For displaying safe browsing interstitial. |
130 std::unique_ptr<SafeBrowsingErrorUI> sb_error_ui_; | 134 std::unique_ptr<SafeBrowsingErrorUI> sb_error_ui_; |
131 | 135 |
132 // Indicate whether user has proceeded this blocking page. | 136 // Indicate whether user has proceeded this blocking page. |
133 bool proceeded_; | 137 bool proceeded_; |
134 | 138 |
| 139 // After a safe browsing interstitial where the user opted-in to the |
| 140 // report but clicked "proceed anyway", we delay the call to |
| 141 // ThreatDetails::FinishCollection() by this much time (in |
| 142 // milliseconds), in order to get data from the blocked resource itself. |
| 143 int64_t threat_details_proceed_delay_ms_; |
| 144 |
135 DISALLOW_COPY_AND_ASSIGN(BaseBlockingPage); | 145 DISALLOW_COPY_AND_ASSIGN(BaseBlockingPage); |
136 }; | 146 }; |
137 | 147 |
138 } // namespace safe_browsing | 148 } // namespace safe_browsing |
139 | 149 |
140 #endif // COMPONENTS_SAFE_BROWSING_BASE_BLOCKING_PAGE_H_ | 150 #endif // COMPONENTS_SAFE_BROWSING_BASE_BLOCKING_PAGE_H_ |
OLD | NEW |