| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // SafeBrowsingBlockingPage. | 212 // SafeBrowsingBlockingPage. |
| 213 static SafeBrowsingBlockingPageFactory* factory_; | 213 static SafeBrowsingBlockingPageFactory* factory_; |
| 214 | 214 |
| 215 // How many times is this same URL in history? Used for histogramming. | 215 // How many times is this same URL in history? Used for histogramming. |
| 216 int num_visits_; | 216 int num_visits_; |
| 217 CancelableRequestConsumer request_consumer_; | 217 CancelableRequestConsumer request_consumer_; |
| 218 | 218 |
| 219 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); | 219 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage); |
| 220 }; | 220 }; |
| 221 | 221 |
| 222 class SafeBrowsingBlockingPageV1 : public SafeBrowsingBlockingPage { | |
| 223 public: | |
| 224 // Don't instanciate this class directly, use ShowBlockingPage instead. | |
| 225 SafeBrowsingBlockingPageV1(SafeBrowsingUIManager* ui_manager, | |
| 226 content::WebContents* web_contents, | |
| 227 const UnsafeResourceList& unsafe_resources); | |
| 228 | |
| 229 // InterstitialPageDelegate method: | |
| 230 virtual std::string GetHTMLContents() OVERRIDE; | |
| 231 | |
| 232 private: | |
| 233 // Fills the passed dictionary with the strings passed to JS Template when | |
| 234 // creating the HTML. | |
| 235 void PopulateMultipleThreatStringDictionary(base::DictionaryValue* strings); | |
| 236 void PopulateMalwareStringDictionary(base::DictionaryValue* strings); | |
| 237 void PopulatePhishingStringDictionary(base::DictionaryValue* strings); | |
| 238 | |
| 239 // A helper method used by the Populate methods above used to populate common | |
| 240 // fields. | |
| 241 void PopulateStringDictionary(base::DictionaryValue* strings, | |
| 242 const base::string16& title, | |
| 243 const base::string16& headline, | |
| 244 const base::string16& description1, | |
| 245 const base::string16& description2, | |
| 246 const base::string16& description3); | |
| 247 | |
| 248 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV1); | |
| 249 }; | |
| 250 | |
| 251 class SafeBrowsingBlockingPageV2 : public SafeBrowsingBlockingPage { | |
| 252 public: | |
| 253 // Don't instanciate this class directly, use ShowBlockingPage instead. | |
| 254 SafeBrowsingBlockingPageV2(SafeBrowsingUIManager* ui_manager, | |
| 255 content::WebContents* web_contents, | |
| 256 const UnsafeResourceList& unsafe_resources); | |
| 257 | |
| 258 // InterstitialPageDelegate method: | |
| 259 virtual std::string GetHTMLContents() OVERRIDE; | |
| 260 | |
| 261 private: | |
| 262 // Fills the passed dictionary with the strings passed to JS Template when | |
| 263 // creating the HTML. | |
| 264 void PopulateMultipleThreatStringDictionary(base::DictionaryValue* strings); | |
| 265 void PopulateMalwareStringDictionary(base::DictionaryValue* strings); | |
| 266 void PopulatePhishingStringDictionary(base::DictionaryValue* strings); | |
| 267 | |
| 268 // A helper method used by the Populate methods above used to populate common | |
| 269 // fields. | |
| 270 void PopulateStringDictionary(base::DictionaryValue* strings, | |
| 271 const base::string16& title, | |
| 272 const base::string16& headline, | |
| 273 const base::string16& description1, | |
| 274 const base::string16& description2, | |
| 275 const base::string16& description3); | |
| 276 | |
| 277 // For the FieldTrial: this contains the name of the condition. | |
| 278 std::string trialCondition_; | |
| 279 | |
| 280 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV2); | |
| 281 }; | |
| 282 | |
| 283 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. | 222 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. |
| 284 class SafeBrowsingBlockingPageFactory { | 223 class SafeBrowsingBlockingPageFactory { |
| 285 public: | 224 public: |
| 286 virtual ~SafeBrowsingBlockingPageFactory() { } | 225 virtual ~SafeBrowsingBlockingPageFactory() { } |
| 287 | 226 |
| 288 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( | 227 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( |
| 289 SafeBrowsingUIManager* ui_manager, | 228 SafeBrowsingUIManager* ui_manager, |
| 290 content::WebContents* web_contents, | 229 content::WebContents* web_contents, |
| 291 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; | 230 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; |
| 292 }; | 231 }; |
| 293 | 232 |
| 294 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ | 233 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ |
| OLD | NEW |