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