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 // Classes for managing the SafeBrowsing interstitial pages. | 5 // Classes for managing the SafeBrowsing interstitial pages. |
6 // | 6 // |
7 // When a user is about to visit a page the SafeBrowsing system has deemed to | 7 // When a user is about to visit a page the SafeBrowsing system has deemed to |
8 // be malicious, either as malware or a phishing page, we show an interstitial | 8 // be malicious, either as malware or a phishing page, we show an interstitial |
9 // page with some options (go back, continue) to give the user a chance to avoid | 9 // page with some options (go back, continue) to give the user a chance to avoid |
10 // the harmful page. | 10 // the harmful page. |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 // is gone (if the user enables the feature). | 187 // is gone (if the user enables the feature). |
188 scoped_refptr<ThreatDetails> threat_details_; | 188 scoped_refptr<ThreatDetails> threat_details_; |
189 | 189 |
190 bool proceeded_; | 190 bool proceeded_; |
191 | 191 |
192 // Which type of Safe Browsing interstitial this is. | 192 // Which type of Safe Browsing interstitial this is. |
193 enum SBInterstitialReason { | 193 enum SBInterstitialReason { |
194 SB_REASON_MALWARE, | 194 SB_REASON_MALWARE, |
195 SB_REASON_HARMFUL, | 195 SB_REASON_HARMFUL, |
196 SB_REASON_PHISHING, | 196 SB_REASON_PHISHING, |
197 } interstitial_reason_; | 197 }; |
| 198 SBInterstitialReason interstitial_reason_; |
198 | 199 |
199 // The factory used to instantiate SafeBrowsingBlockingPage objects. | 200 // The factory used to instantiate SafeBrowsingBlockingPage objects. |
200 // Useful for tests, so they can provide their own implementation of | 201 // Useful for tests, so they can provide their own implementation of |
201 // SafeBrowsingBlockingPage. | 202 // SafeBrowsingBlockingPage. |
202 static SafeBrowsingBlockingPageFactory* factory_; | 203 static SafeBrowsingBlockingPageFactory* factory_; |
203 | 204 |
204 private: | 205 private: |
205 // Fills the passed dictionary with the values to be passed to the template | 206 // Fills the passed dictionary with the values to be passed to the template |
206 // when creating the HTML. | 207 // when creating the HTML. |
207 void PopulateExtendedReportingOption(base::DictionaryValue* load_time_data); | 208 void PopulateExtendedReportingOption(base::DictionaryValue* load_time_data); |
208 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data); | 209 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data); |
209 void PopulateHarmfulLoadTimeData(base::DictionaryValue* load_time_data); | 210 void PopulateHarmfulLoadTimeData(base::DictionaryValue* load_time_data); |
210 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data); | 211 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data); |
211 | 212 |
212 std::string GetMetricPrefix() const; | 213 static std::string GetMetricPrefix(const UnsafeResourceList& unsafe_resources, |
213 std::string GetExtraMetricsSuffix() const; | 214 SBInterstitialReason interstitial_reason); |
214 std::string GetRapporPrefix() const; | 215 static std::string GetExtraMetricsSuffix( |
215 std::string GetDeprecatedRapporPrefix() const; | 216 const UnsafeResourceList& unsafe_resources); |
216 std::string GetSamplingEventName() const; | 217 static std::string GetRapporPrefix(SBInterstitialReason interstitial_reason); |
| 218 static std::string GetDeprecatedRapporPrefix( |
| 219 SBInterstitialReason interstitial_reason); |
| 220 static std::string GetSamplingEventName( |
| 221 SBInterstitialReason interstitial_reason); |
| 222 |
| 223 static SBInterstitialReason GetInterstitialReason( |
| 224 const UnsafeResourceList& unsafe_resources); |
| 225 |
| 226 static std::unique_ptr<ChromeMetricsHelper> CreateMetricsHelper( |
| 227 content::WebContents* web_contents, |
| 228 const UnsafeResourceList& unsafe_resources); |
217 | 229 |
218 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); | 230 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); |
219 }; | 231 }; |
220 | 232 |
221 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. | 233 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. |
222 class SafeBrowsingBlockingPageFactory { | 234 class SafeBrowsingBlockingPageFactory { |
223 public: | 235 public: |
224 virtual ~SafeBrowsingBlockingPageFactory() { } | 236 virtual ~SafeBrowsingBlockingPageFactory() { } |
225 | 237 |
226 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 238 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
227 SafeBrowsingUIManager* ui_manager, | 239 SafeBrowsingUIManager* ui_manager, |
228 content::WebContents* web_contents, | 240 content::WebContents* web_contents, |
229 const GURL& main_frame_url, | 241 const GURL& main_frame_url, |
230 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; | 242 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; |
231 }; | 243 }; |
232 | 244 |
233 } // namespace safe_browsing | 245 } // namespace safe_browsing |
234 | 246 |
235 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ | 247 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ |
OLD | NEW |