Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page.h

Issue 445493002: Delete the Safe Browsing V2 interstitial and Finch trial (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed the SafeBrowsingBlockingPageV3 subclass Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 const UnsafeResource& unsafe_resource); 69 const UnsafeResource& unsafe_resource);
70 70
71 // Shows a blocking page warning the user about phishing/malware for a 71 // Shows a blocking page warning the user about phishing/malware for a
72 // specific resource. 72 // specific resource.
73 // You can call this method several times, if an interstitial is already 73 // You can call this method several times, if an interstitial is already
74 // showing, the new one will be queued and displayed if the user decides 74 // showing, the new one will be queued and displayed if the user decides
75 // to proceed on the currently showing interstitial. 75 // to proceed on the currently showing interstitial.
76 static void ShowBlockingPage( 76 static void ShowBlockingPage(
77 SafeBrowsingUIManager* ui_manager, const UnsafeResource& resource); 77 SafeBrowsingUIManager* ui_manager, const UnsafeResource& resource);
78 78
79 // InterstitialPageDelegate method:
Dan Beam 2014/08/08 02:34:33 combine with other methods
felt 2014/08/08 02:37:38 Done, and reordered to be in same order as Interst
80 virtual std::string GetHTMLContents() OVERRIDE;
81
79 // Makes the passed |factory| the factory used to instantiate 82 // Makes the passed |factory| the factory used to instantiate
80 // SafeBrowsingBlockingPage objects. Useful for tests. 83 // SafeBrowsingBlockingPage objects. Useful for tests.
81 static void RegisterFactory(SafeBrowsingBlockingPageFactory* factory) { 84 static void RegisterFactory(SafeBrowsingBlockingPageFactory* factory) {
82 factory_ = factory; 85 factory_ = factory;
83 } 86 }
84 87
85 // InterstitialPageDelegate method: 88 // InterstitialPageDelegate method:
Dan Beam 2014/08/08 02:34:33 ^
felt 2014/08/08 02:37:38 Acknowledged.
86 virtual void CommandReceived(const std::string& command) OVERRIDE; 89 virtual void CommandReceived(const std::string& command) OVERRIDE;
87 virtual void OverrideRendererPrefs( 90 virtual void OverrideRendererPrefs(
88 content::RendererPreferences* prefs) OVERRIDE; 91 content::RendererPreferences* prefs) OVERRIDE;
89 virtual void OnProceed() OVERRIDE; 92 virtual void OnProceed() OVERRIDE;
90 virtual void OnDontProceed() OVERRIDE; 93 virtual void OnDontProceed() OVERRIDE;
91 94
92 protected: 95 protected:
93 template <class TestSBInterstitialPage>
94 friend class SafeBrowsingBlockingPageTest; 96 friend class SafeBrowsingBlockingPageTest;
95 template <class TestSBInterstitialPage>
96 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, 97 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest,
97 ProceedThenDontProceed); 98 ProceedThenDontProceed);
98 99
99 void DontCreateViewForTesting(); 100 void DontCreateViewForTesting();
100 void Show(); 101 void Show();
101 void SetReportingPreference(bool report); 102 void SetReportingPreference(bool report);
102 void UpdateReportingPref(); // Used for the transition from old to new pref. 103 void UpdateReportingPref(); // Used for the transition from old to new pref.
103 104
104 // Don't instantiate this class directly, use ShowBlockingPage instead. 105 // Don't instantiate this class directly, use ShowBlockingPage instead.
105 SafeBrowsingBlockingPage(SafeBrowsingUIManager* ui_manager, 106 SafeBrowsingBlockingPage(SafeBrowsingUIManager* ui_manager,
106 content::WebContents* web_contents, 107 content::WebContents* web_contents,
107 const UnsafeResourceList& unsafe_resources); 108 const UnsafeResourceList& unsafe_resources);
108 109
109 // After a malware interstitial where the user opted-in to the 110 // After a malware interstitial where the user opted-in to the
110 // report but clicked "proceed anyway", we delay the call to 111 // report but clicked "proceed anyway", we delay the call to
111 // MalwareDetails::FinishCollection() by this much time (in 112 // MalwareDetails::FinishCollection() by this much time (in
112 // milliseconds), in order to get data from the blocked resource itself. 113 // milliseconds), in order to get data from the blocked resource itself.
113 int64 malware_details_proceed_delay_ms_; 114 int64 malware_details_proceed_delay_ms_;
114 content::InterstitialPage* interstitial_page() const { 115 content::InterstitialPage* interstitial_page() const {
115 return interstitial_page_; 116 return interstitial_page_;
116 } 117 }
117 118
118 template <class TestSBInterstitialPage>
119 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, 119 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest,
120 MalwareReportsTransitionDisabled); 120 MalwareReportsTransitionDisabled);
121 template <class TestSBInterstitialPage>
122 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, 121 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest,
123 MalwareReportsToggling); 122 MalwareReportsToggling);
124 123
125 enum BlockingPageEvent { 124 enum BlockingPageEvent {
126 SHOW, 125 SHOW,
127 PROCEED, 126 PROCEED,
128 DONT_PROCEED, 127 DONT_PROCEED,
129 SHOW_ADVANCED, 128 SHOW_ADVANCED,
130 }; 129 };
131 130
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 225
227 // The factory used to instantiate SafeBrowsingBlockingPage objects. 226 // The factory used to instantiate SafeBrowsingBlockingPage objects.
228 // Usefull for tests, so they can provide their own implementation of 227 // Usefull for tests, so they can provide their own implementation of
229 // SafeBrowsingBlockingPage. 228 // SafeBrowsingBlockingPage.
230 static SafeBrowsingBlockingPageFactory* factory_; 229 static SafeBrowsingBlockingPageFactory* factory_;
231 230
232 // How many times is this same URL in history? Used for histogramming. 231 // How many times is this same URL in history? Used for histogramming.
233 int num_visits_; 232 int num_visits_;
234 base::CancelableTaskTracker request_tracker_; 233 base::CancelableTaskTracker request_tracker_;
235 234
236 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage);
237 };
238
239 class SafeBrowsingBlockingPageV1 : public SafeBrowsingBlockingPage {
240 public:
241 // Don't instantiate this class directly, use ShowBlockingPage instead.
242 SafeBrowsingBlockingPageV1(SafeBrowsingUIManager* ui_manager,
243 content::WebContents* web_contents,
244 const UnsafeResourceList& unsafe_resources);
245
246 // InterstitialPageDelegate method:
247 virtual std::string GetHTMLContents() OVERRIDE;
248
249 private:
250 // Fills the passed dictionary with the strings passed to JS Template when
251 // creating the HTML.
252 void PopulateMultipleThreatStringDictionary(base::DictionaryValue* strings);
253 void PopulateMalwareStringDictionary(base::DictionaryValue* strings);
254 void PopulatePhishingStringDictionary(base::DictionaryValue* strings);
255
256 // A helper method used by the Populate methods above used to populate common
257 // fields.
258 void PopulateStringDictionary(base::DictionaryValue* strings,
259 const base::string16& title,
260 const base::string16& headline,
261 const base::string16& description1,
262 const base::string16& description2,
263 const base::string16& description3);
264
265 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV1);
266 };
267
268 class SafeBrowsingBlockingPageV2 : public SafeBrowsingBlockingPage {
269 public:
270 // Don't instantiate this class directly, use ShowBlockingPage instead.
271 SafeBrowsingBlockingPageV2(SafeBrowsingUIManager* ui_manager,
272 content::WebContents* web_contents,
273 const UnsafeResourceList& unsafe_resources);
274
275 // InterstitialPageDelegate method:
276 virtual std::string GetHTMLContents() OVERRIDE;
277
278 private:
279 // Fills the passed dictionary with the strings passed to JS Template when
280 // creating the HTML.
281 void PopulateMultipleThreatStringDictionary(base::DictionaryValue* strings);
282 void PopulateMalwareStringDictionary(base::DictionaryValue* strings);
283 void PopulatePhishingStringDictionary(base::DictionaryValue* strings);
284
285 // A helper method used by the Populate methods above used to populate common
286 // fields.
287 void PopulateStringDictionary(base::DictionaryValue* strings,
288 const base::string16& title,
289 const base::string16& headline,
290 const base::string16& description1,
291 const base::string16& description2,
292 const base::string16& description3);
293
294 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV2);
295 };
296
297 class SafeBrowsingBlockingPageV3 : public SafeBrowsingBlockingPage {
298 public:
299 SafeBrowsingBlockingPageV3(SafeBrowsingUIManager* ui_manager,
300 content::WebContents* web_contents,
301 const UnsafeResourceList& unsafe_resources);
302
303 // InterstitialPageDelegate method:
304 virtual std::string GetHTMLContents() OVERRIDE;
305
306 private: 235 private:
307 // Fills the passed dictionary with the values to be passed to the template 236 // Fills the passed dictionary with the values to be passed to the template
308 // when creating the HTML. 237 // when creating the HTML.
309 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data); 238 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data);
310 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data); 239 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data);
311 240
312 // For the M37 FieldTrial: this contains the name of the condition. 241 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPage);
313 std::string trial_condition_;
314
315 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV3);
316 }; 242 };
317 243
318 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. 244 // Factory for creating SafeBrowsingBlockingPage. Useful for tests.
319 class SafeBrowsingBlockingPageFactory { 245 class SafeBrowsingBlockingPageFactory {
320 public: 246 public:
321 virtual ~SafeBrowsingBlockingPageFactory() { } 247 virtual ~SafeBrowsingBlockingPageFactory() { }
322 248
323 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( 249 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage(
324 SafeBrowsingUIManager* ui_manager, 250 SafeBrowsingUIManager* ui_manager,
325 content::WebContents* web_contents, 251 content::WebContents* web_contents,
326 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; 252 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0;
327 }; 253 };
328 254
329 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ 255 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698