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

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

Issue 330753002: Browser and unit tests for the SB interstitial V3 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merged redundancy Created 6 years, 6 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 // InterstitialPageDelegate method: 77 // InterstitialPageDelegate method:
78 virtual void CommandReceived(const std::string& command) OVERRIDE; 78 virtual void CommandReceived(const std::string& command) OVERRIDE;
79 virtual void OverrideRendererPrefs( 79 virtual void OverrideRendererPrefs(
80 content::RendererPreferences* prefs) OVERRIDE; 80 content::RendererPreferences* prefs) OVERRIDE;
81 virtual void OnProceed() OVERRIDE; 81 virtual void OnProceed() OVERRIDE;
82 virtual void OnDontProceed() OVERRIDE; 82 virtual void OnDontProceed() OVERRIDE;
83 83
84 protected: 84 protected:
85 template <class TestSBInterstitialPage>
85 friend class SafeBrowsingBlockingPageTest; 86 friend class SafeBrowsingBlockingPageTest;
87 template <class TestSBInterstitialPage>
86 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, 88 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest,
87 ProceedThenDontProceed); 89 ProceedThenDontProceed);
88 friend class SafeBrowsingBlockingPageV2Test;
89 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageV2Test,
90 ProceedThenDontProceed);
91 90
92 void SetReportingPreference(bool report); 91 void SetReportingPreference(bool report);
93 92
94 // Don't instanciate this class directly, use ShowBlockingPage instead. 93 // Don't instanciate this class directly, use ShowBlockingPage instead.
95 SafeBrowsingBlockingPage(SafeBrowsingUIManager* ui_manager, 94 SafeBrowsingBlockingPage(SafeBrowsingUIManager* ui_manager,
96 content::WebContents* web_contents, 95 content::WebContents* web_contents,
97 const UnsafeResourceList& unsafe_resources); 96 const UnsafeResourceList& unsafe_resources);
98 97
99 // After a malware interstitial where the user opted-in to the 98 // After a malware interstitial where the user opted-in to the
100 // report but clicked "proceed anyway", we delay the call to 99 // report but clicked "proceed anyway", we delay the call to
101 // MalwareDetails::FinishCollection() by this much time (in 100 // MalwareDetails::FinishCollection() by this much time (in
102 // milliseconds), in order to get data from the blocked resource itself. 101 // milliseconds), in order to get data from the blocked resource itself.
103 int64 malware_details_proceed_delay_ms_; 102 int64 malware_details_proceed_delay_ms_;
104 content::InterstitialPage* interstitial_page() const { 103 content::InterstitialPage* interstitial_page() const {
105 return interstitial_page_; 104 return interstitial_page_;
106 } 105 }
107 106
107 template <class TestSBInterstitialPage>
108 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, MalwareReports); 108 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, MalwareReports);
109 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageV2Test, MalwareReports);
110 109
111 enum BlockingPageEvent { 110 enum BlockingPageEvent {
112 SHOW, 111 SHOW,
113 PROCEED, 112 PROCEED,
114 DONT_PROCEED, 113 DONT_PROCEED,
115 SHOW_ADVANCED, 114 SHOW_ADVANCED,
116 }; 115 };
117 116
118 // Records a user action for this interstitial, using the form 117 // Records a user action for this interstitial, using the form
119 // SBInterstitial[Phishing|Malware|Multiple][Show|Proceed|DontProceed]. 118 // SBInterstitial[Phishing|Malware|Multiple][Show|Proceed|DontProceed].
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 const base::string16& description1, 272 const base::string16& description1,
274 const base::string16& description2, 273 const base::string16& description2,
275 const base::string16& description3); 274 const base::string16& description3);
276 275
277 // For the FieldTrial: this contains the name of the condition. 276 // For the FieldTrial: this contains the name of the condition.
278 std::string trialCondition_; 277 std::string trialCondition_;
279 278
280 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV2); 279 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV2);
281 }; 280 };
282 281
282 class SafeBrowsingBlockingPageV3 : public SafeBrowsingBlockingPage {
283 public:
284 SafeBrowsingBlockingPageV3(SafeBrowsingUIManager* ui_manager,
285 content::WebContents* web_contents,
286 const UnsafeResourceList& unsafe_resources);
287
288 // InterstitialPageDelegate method:
289 virtual std::string GetHTMLContents() OVERRIDE;
290
291 private:
292 // Fills the passed dictionary with the values to be passed to the template
293 // when creating the HTML.
294 void PopulateMalwareLoadTimeData(base::DictionaryValue* load_time_data);
295 void PopulatePhishingLoadTimeData(base::DictionaryValue* load_time_data);
296
297 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingBlockingPageV3);
298 };
299
283 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. 300 // Factory for creating SafeBrowsingBlockingPage. Useful for tests.
284 class SafeBrowsingBlockingPageFactory { 301 class SafeBrowsingBlockingPageFactory {
285 public: 302 public:
286 virtual ~SafeBrowsingBlockingPageFactory() { } 303 virtual ~SafeBrowsingBlockingPageFactory() { }
287 304
288 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( 305 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage(
289 SafeBrowsingUIManager* ui_manager, 306 SafeBrowsingUIManager* ui_manager,
290 content::WebContents* web_contents, 307 content::WebContents* web_contents,
291 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; 308 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0;
292 }; 309 };
293 310
294 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ 311 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698