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

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

Issue 2451623005: Remove Dangerous indicator after going back from interstitial (Closed)
Patch Set: add another test and expand one Created 4 years, 1 month 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 // The Safe Browsing service is responsible for downloading anti-phishing and 5 // The Safe Browsing service is responsible for downloading anti-phishing and
6 // anti-malware tables and checking urls against them. 6 // anti-malware tables and checking urls against them.
7 7
8 #ifndef CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_
9 #define CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ 9 #define CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Called on the UI thread to display an interstitial page. 121 // Called on the UI thread to display an interstitial page.
122 // |url| is the url of the resource that matches a safe browsing list. 122 // |url| is the url of the resource that matches a safe browsing list.
123 // If the request contained a chain of redirects, |url| is the last url 123 // If the request contained a chain of redirects, |url| is the last url
124 // in the chain, and |original_url| is the first one (the root of the 124 // in the chain, and |original_url| is the first one (the root of the
125 // chain). Otherwise, |original_url| = |url|. 125 // chain). Otherwise, |original_url| = |url|.
126 virtual void DisplayBlockingPage(const UnsafeResource& resource); 126 virtual void DisplayBlockingPage(const UnsafeResource& resource);
127 127
128 // A convenience wrapper method for IsUrlWhitelistedOrPendingForWebContents. 128 // A convenience wrapper method for IsUrlWhitelistedOrPendingForWebContents.
129 bool IsWhitelisted(const UnsafeResource& resource); 129 bool IsWhitelisted(const UnsafeResource& resource);
130 130
131 // Checks if we already displayed an interstitial for that top-level 131 // Checks if we already displayed or are displaying an interstitial
132 // site in a given WebContents. If |whitelist_only|, it returns true only if 132 // for the top-level site |url| in a given WebContents. If
133 // the user chose to ignore the interstitial; otherwise it returns true as 133 // |whitelist_only|, it returns true only if the user chose to ignore
134 // long as the user has seen an interstitial (regardless of response). 134 // the interstitial. Otherwise, it returns true if an interstitial for
135 // Called on the UI thread. 135 // |url| is already displaying *or* if the user has seen an
136 // interstitial for |url| before in this WebContents and proceeded
137 // through it. Called on the UI thread.
136 bool IsUrlWhitelistedOrPendingForWebContents( 138 bool IsUrlWhitelistedOrPendingForWebContents(
137 const GURL& url, 139 const GURL& url,
138 bool is_subresource, 140 bool is_subresource,
139 content::NavigationEntry* entry, 141 content::NavigationEntry* entry,
140 content::WebContents* web_contents, 142 content::WebContents* web_contents,
141 bool whitelist_only); 143 bool whitelist_only);
142 144
143 // The blocking page on the UI thread has completed. 145 // The blocking page for |web_contents| on the UI thread has
Nathan Parker 2016/10/31 23:54:38 Excellent comments, thank you.
146 // completed, with |proceed| set to true if the user has chosen to
147 // proceed through the blocking page and false
148 // otherwise. |web_contents| is the WebContents that was displaying
149 // the blocking page. |main_frame_url| is the top-level URL on which
150 // the blocking page was displayed. If |proceed| is true,
151 // |main_frame_url| is whitelisted so that the user will not see
152 // another warning for that URL in this WebContents.
144 void OnBlockingPageDone(const std::vector<UnsafeResource>& resources, 153 void OnBlockingPageDone(const std::vector<UnsafeResource>& resources,
145 bool proceed); 154 bool proceed,
155 content::WebContents* web_contents,
156 const GURL& main_frame_url);
146 157
147 // Log the user perceived delay caused by SafeBrowsing. This delay is the time 158 // Log the user perceived delay caused by SafeBrowsing. This delay is the time
148 // delta starting from when we would have started reading data from the 159 // delta starting from when we would have started reading data from the
149 // network, and ending when the SafeBrowsing check completes indicating that 160 // network, and ending when the SafeBrowsing check completes indicating that
150 // the current page is 'safe'. 161 // the current page is 'safe'.
151 void LogPauseDelay(base::TimeDelta time); 162 void LogPauseDelay(base::TimeDelta time);
152 163
153 // Called on the IO thread by the ThreatDetails with the serialized 164 // Called on the IO thread by the ThreatDetails with the serialized
154 // protocol buffer, so the service can send it over. 165 // protocol buffer, so the service can send it over.
155 virtual void SendSerializedThreatDetails(const std::string& serialized); 166 virtual void SendSerializedThreatDetails(const std::string& serialized);
(...skipping 11 matching lines...) Expand all
167 const base::Closure& callback); 178 const base::Closure& callback);
168 179
169 // Report permission action to SafeBrowsing servers. Can only be called on UI 180 // Report permission action to SafeBrowsing servers. Can only be called on UI
170 // thread. 181 // thread.
171 void ReportPermissionAction(const PermissionReportInfo& report_info); 182 void ReportPermissionAction(const PermissionReportInfo& report_info);
172 183
173 // Add and remove observers. These methods must be invoked on the UI thread. 184 // Add and remove observers. These methods must be invoked on the UI thread.
174 void AddObserver(Observer* observer); 185 void AddObserver(Observer* observer);
175 void RemoveObserver(Observer* remove); 186 void RemoveObserver(Observer* remove);
176 187
188 // Creates the whitelist URL set for tests that create a blocking page
189 // themselves and then simulate OnBlockingPageDone(). OnBlockingPageDone()
190 // expects the whitelist to exist, but the tests don't necessarily call
191 // DisplayBlockingPage(), which creates it.
192 static void CreateWhitelistForTesting(content::WebContents* web_contents);
193
177 protected: 194 protected:
178 virtual ~SafeBrowsingUIManager(); 195 virtual ~SafeBrowsingUIManager();
179 196
180 private: 197 private:
181 friend class base::RefCountedThreadSafe<SafeBrowsingUIManager>; 198 friend class base::RefCountedThreadSafe<SafeBrowsingUIManager>;
182 friend class SafeBrowsingUIManagerTest; 199 friend class SafeBrowsingUIManagerTest;
183 friend class TestSafeBrowsingUIManager; 200 friend class TestSafeBrowsingUIManager;
184 201
185 // Call protocol manager on IO thread to report hits of unsafe contents. 202 // Call protocol manager on IO thread to report hits of unsafe contents.
186 void ReportSafeBrowsingHitOnIOThread( 203 void ReportSafeBrowsingHitOnIOThread(
187 const safe_browsing::HitReport& hit_report); 204 const safe_browsing::HitReport& hit_report);
188 205
189 // Sends an invalid certificate chain report over the network. 206 // Sends an invalid certificate chain report over the network.
190 void ReportInvalidCertificateChainOnIOThread( 207 void ReportInvalidCertificateChainOnIOThread(
191 const std::string& serialized_report); 208 const std::string& serialized_report);
192 209
193 // Report permission action to SafeBrowsing servers. 210 // Report permission action to SafeBrowsing servers.
194 void ReportPermissionActionOnIOThread( 211 void ReportPermissionActionOnIOThread(
195 const PermissionReportInfo& report_info); 212 const PermissionReportInfo& report_info);
196 213
197 // Updates the whitelist URL set. Called on the UI thread. 214 // Updates the whitelist URL set for |web_contents|. Called on the UI thread.
198 void AddToWhitelistUrlSet(const UnsafeResource& resource, bool is_pending); 215 void AddToWhitelistUrlSet(const GURL& whitelist_url,
estark 2016/10/28 18:01:33 I changed this from taking a |resource| to taking
216 content::WebContents* web_contents,
217 bool is_pending);
218
219 // Removes |whitelist_url| from the pending whitelist for
220 // |web_contents|. Called on the UI thread.
221 void RemoveFromPendingWhitelistUrlSet(const GURL& whitelist_url,
222 content::WebContents* web_contents);
223
224 static GURL GetMainFrameWhitelistUrlForResourceForTesting(
225 const safe_browsing::SafeBrowsingUIManager::UnsafeResource& resource);
199 226
200 // Safebrowsing service. 227 // Safebrowsing service.
201 scoped_refptr<SafeBrowsingService> sb_service_; 228 scoped_refptr<SafeBrowsingService> sb_service_;
202 229
203 base::ObserverList<Observer> observer_list_; 230 base::ObserverList<Observer> observer_list_;
204 231
205 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); 232 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager);
206 }; 233 };
207 234
208 } // namespace safe_browsing 235 } // namespace safe_browsing
209 236
210 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ 237 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698