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

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

Issue 1509073002: Fixes for Safe Browsing with unrelated pending navigations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review changes for comment #13-15 Created 5 years 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
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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // Interstitial type, used in tests. 58 // Interstitial type, used in tests.
59 static content::InterstitialPageDelegate::TypeID kTypeForTesting; 59 static content::InterstitialPageDelegate::TypeID kTypeForTesting;
60 60
61 ~SafeBrowsingBlockingPage() override; 61 ~SafeBrowsingBlockingPage() override;
62 62
63 // Creates a blocking page. Use ShowBlockingPage if you don't need to access 63 // Creates a blocking page. Use ShowBlockingPage if you don't need to access
64 // the blocking page directly. 64 // the blocking page directly.
65 static SafeBrowsingBlockingPage* CreateBlockingPage( 65 static SafeBrowsingBlockingPage* CreateBlockingPage(
66 SafeBrowsingUIManager* ui_manager, 66 SafeBrowsingUIManager* ui_manager,
67 content::WebContents* web_contents, 67 content::WebContents* web_contents,
68 const GURL& main_frame_url,
68 const UnsafeResource& unsafe_resource); 69 const UnsafeResource& unsafe_resource);
69 70
70 // 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
71 // specific resource. 72 // specific resource.
72 // 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
73 // 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
74 // to proceed on the currently showing interstitial. 75 // to proceed on the currently showing interstitial.
75 static void ShowBlockingPage( 76 static void ShowBlockingPage(
76 SafeBrowsingUIManager* ui_manager, const UnsafeResource& resource); 77 SafeBrowsingUIManager* ui_manager, const UnsafeResource& resource);
77 78
(...skipping 10 matching lines...) Expand all
88 void OverrideRendererPrefs(content::RendererPreferences* prefs) override; 89 void OverrideRendererPrefs(content::RendererPreferences* prefs) override;
89 content::InterstitialPageDelegate::TypeID GetTypeForTesting() const override; 90 content::InterstitialPageDelegate::TypeID GetTypeForTesting() const override;
90 91
91 // Checks the threat type to decide if we should report ThreatDetails. 92 // Checks the threat type to decide if we should report ThreatDetails.
92 static bool ShouldReportThreatDetails(SBThreatType threat_type); 93 static bool ShouldReportThreatDetails(SBThreatType threat_type);
93 94
94 protected: 95 protected:
95 friend class SafeBrowsingBlockingPageTest; 96 friend class SafeBrowsingBlockingPageTest;
96 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest, 97 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest,
97 ProceedThenDontProceed); 98 ProceedThenDontProceed);
99 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest,
100 MalwareReportsDisabled);
101 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest,
102 MalwareReportsToggling);
103 FRIEND_TEST_ALL_PREFIXES(SafeBrowsingBlockingPageTest,
104 ExtendedReportingNotShownOnSecurePage);
105 FRIEND_TEST_ALL_PREFIXES(
106 SafeBrowsingBlockingPageTest,
107 ExtendedReportingNotShownOnSecurePageWithSecureSubresource);
108 FRIEND_TEST_ALL_PREFIXES(
109 SafeBrowsingBlockingPageTest,
110 ExtendedReportingNotShownOnSecurePageWithInsecureSubresource);
111 FRIEND_TEST_ALL_PREFIXES(
112 SafeBrowsingBlockingPageTest,
113 ExtendedReportingOnInsecurePageWithSecureSubresource);
114 FRIEND_TEST_ALL_PREFIXES(
115 SafeBrowsingBlockingPageTest,
116 ExtendedReportingNotShownOnSecurePageWithPendingInsecureLoad);
98 117
99 void UpdateReportingPref(); // Used for the transition from old to new pref. 118 void UpdateReportingPref(); // Used for the transition from old to new pref.
100 119
101 // Don't instantiate this class directly, use ShowBlockingPage instead. 120 // Don't instantiate this class directly, use ShowBlockingPage instead.
102 SafeBrowsingBlockingPage(SafeBrowsingUIManager* ui_manager, 121 SafeBrowsingBlockingPage(SafeBrowsingUIManager* ui_manager,
103 content::WebContents* web_contents, 122 content::WebContents* web_contents,
123 const GURL& main_frame_url,
104 const UnsafeResourceList& unsafe_resources); 124 const UnsafeResourceList& unsafe_resources);
105 125
106 // SecurityInterstitialPage methods: 126 // SecurityInterstitialPage methods:
107 bool ShouldCreateNewNavigation() const override; 127 bool ShouldCreateNewNavigation() const override;
108 void PopulateInterstitialStrings( 128 void PopulateInterstitialStrings(
109 base::DictionaryValue* load_time_data) override; 129 base::DictionaryValue* load_time_data) override;
110 void AfterShow() override {} 130 void AfterShow() override {}
111 131
112 // After a safe browsing interstitial where the user opted-in to the 132 // After a safe browsing interstitial where the user opted-in to the
113 // report but clicked "proceed anyway", we delay the call to 133 // report but clicked "proceed anyway", we delay the call to
(...skipping 30 matching lines...) Expand all
144 164
145 // For reporting back user actions. 165 // For reporting back user actions.
146 SafeBrowsingUIManager* ui_manager_; 166 SafeBrowsingUIManager* ui_manager_;
147 167
148 // True if the interstitial is blocking the main page because it is on one 168 // True if the interstitial is blocking the main page because it is on one
149 // of our lists. False if a subresource is being blocked, or in the case of 169 // of our lists. False if a subresource is being blocked, or in the case of
150 // client-side detection where the interstitial is shown after page load 170 // client-side detection where the interstitial is shown after page load
151 // finishes. 171 // finishes.
152 bool is_main_frame_load_blocked_; 172 bool is_main_frame_load_blocked_;
153 173
174 // The URL of the main frame that caused the warning.
175 GURL main_frame_url_;
176
154 // The index of a navigation entry that should be removed when DontProceed() 177 // The index of a navigation entry that should be removed when DontProceed()
155 // is invoked, -1 if not entry should be removed. 178 // is invoked, -1 if not entry should be removed.
156 int navigation_entry_index_to_remove_; 179 int navigation_entry_index_to_remove_;
157 180
158 // The list of unsafe resources this page is warning about. 181 // The list of unsafe resources this page is warning about.
159 UnsafeResourceList unsafe_resources_; 182 UnsafeResourceList unsafe_resources_;
160 183
161 // A ThreatDetails object that we start generating when the 184 // A ThreatDetails object that we start generating when the
162 // blocking page is shown. The object will be sent when the warning 185 // blocking page is shown. The object will be sent when the warning
163 // is gone (if the user enables the feature). 186 // is gone (if the user enables the feature).
(...skipping 30 matching lines...) Expand all
194 }; 217 };
195 218
196 // Factory for creating SafeBrowsingBlockingPage. Useful for tests. 219 // Factory for creating SafeBrowsingBlockingPage. Useful for tests.
197 class SafeBrowsingBlockingPageFactory { 220 class SafeBrowsingBlockingPageFactory {
198 public: 221 public:
199 virtual ~SafeBrowsingBlockingPageFactory() { } 222 virtual ~SafeBrowsingBlockingPageFactory() { }
200 223
201 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage( 224 virtual SafeBrowsingBlockingPage* CreateSafeBrowsingPage(
202 SafeBrowsingUIManager* ui_manager, 225 SafeBrowsingUIManager* ui_manager,
203 content::WebContents* web_contents, 226 content::WebContents* web_contents,
227 const GURL& main_frame_url,
204 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0; 228 const SafeBrowsingBlockingPage::UnsafeResourceList& unsafe_resources) = 0;
205 }; 229 };
206 230
207 } // namespace safe_browsing 231 } // namespace safe_browsing
208 232
209 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_ 233 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_BLOCKING_PAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698