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

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

Issue 2647323004: Move download attribution right after CheckDownloadUrl (Closed)
Patch Set: nits Created 3 years, 10 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
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 // Helper class which handles communication with the SafeBrowsing servers for 5 // Helper class which handles communication with the SafeBrowsing servers for
6 // improved binary download protection. 6 // improved binary download protection.
7 7
8 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_
9 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ 9 #define CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_
10 10
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // is finished and written to disk. 111 // is finished and written to disk.
112 virtual void CheckClientDownload( 112 virtual void CheckClientDownload(
113 content::DownloadItem* item, 113 content::DownloadItem* item,
114 const CheckDownloadCallback& callback); 114 const CheckDownloadCallback& callback);
115 115
116 // Checks whether any of the URLs in the redirect chain of the 116 // Checks whether any of the URLs in the redirect chain of the
117 // download match the SafeBrowsing bad binary URL list. The result is 117 // download match the SafeBrowsing bad binary URL list. The result is
118 // delivered asynchronously via the given callback. This method must be 118 // delivered asynchronously via the given callback. This method must be
119 // called on the UI thread, and the callback will also be invoked on the UI 119 // called on the UI thread, and the callback will also be invoked on the UI
120 // thread. Pre-condition: !info.download_url_chain.empty(). 120 // thread. Pre-condition: !info.download_url_chain.empty().
121 virtual void CheckDownloadUrl(const content::DownloadItem& item, 121 virtual void CheckDownloadUrl(content::DownloadItem* item,
122 const CheckDownloadCallback& callback); 122 const CheckDownloadCallback& callback);
123 123
124 // Returns true iff the download specified by |info| should be scanned by 124 // Returns true iff the download specified by |info| should be scanned by
125 // CheckClientDownload() for malicious content. 125 // CheckClientDownload() for malicious content.
126 virtual bool IsSupportedDownload( 126 virtual bool IsSupportedDownload(
127 const content::DownloadItem& item, 127 const content::DownloadItem& item,
128 const base::FilePath& target_path) const; 128 const base::FilePath& target_path) const;
129 129
130 virtual void CheckPPAPIDownloadRequest( 130 virtual void CheckPPAPIDownloadRequest(
131 const GURL& requestor_url, 131 const GURL& requestor_url,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 REASON_LOCAL_FILE = 24, 216 REASON_LOCAL_FILE = 24,
217 REASON_REMOTE_FILE = 25, 217 REASON_REMOTE_FILE = 25,
218 REASON_SAMPLED_UNSUPPORTED_FILE = 26, 218 REASON_SAMPLED_UNSUPPORTED_FILE = 26,
219 REASON_VERDICT_UNKNOWN = 27, 219 REASON_VERDICT_UNKNOWN = 27,
220 REASON_MAX // Always add new values before this one. 220 REASON_MAX // Always add new values before this one.
221 }; 221 };
222 222
223 private: 223 private:
224 class CheckClientDownloadRequest; 224 class CheckClientDownloadRequest;
225 class PPAPIDownloadRequest; 225 class PPAPIDownloadRequest;
226 friend class DownloadSBClient;
226 friend class DownloadProtectionServiceTest; 227 friend class DownloadProtectionServiceTest;
227 friend class DownloadDangerPromptTest; 228 friend class DownloadDangerPromptTest;
228 229
229 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest, 230 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest,
230 CheckClientDownloadWhitelistedUrlWithoutSampling); 231 CheckClientDownloadWhitelistedUrlWithoutSampling);
231 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest, 232 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest,
232 CheckClientDownloadWhitelistedUrlWithSampling); 233 CheckClientDownloadWhitelistedUrlWithSampling);
233 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest, 234 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest,
234 CheckClientDownloadValidateRequest); 235 CheckClientDownloadValidateRequest);
235 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest, 236 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 // list of strings that need to be checked against the download whitelist to 289 // list of strings that need to be checked against the download whitelist to
289 // determine whether the certificate is whitelisted. 290 // determine whether the certificate is whitelisted.
290 static void GetCertificateWhitelistStrings( 291 static void GetCertificateWhitelistStrings(
291 const net::X509Certificate& certificate, 292 const net::X509Certificate& certificate,
292 const net::X509Certificate& issuer, 293 const net::X509Certificate& issuer,
293 std::vector<std::string>* whitelist_strings); 294 std::vector<std::string>* whitelist_strings);
294 295
295 // Returns the URL that will be used for download requests. 296 // Returns the URL that will be used for download requests.
296 static GURL GetDownloadRequestUrl(); 297 static GURL GetDownloadRequestUrl();
297 298
298 // If kDownloadAttribution feature is enabled, identify and add referrer chain 299 // If kDownloadAttribution feature is enabled, identify referrer chain info of
299 // info of a download to ClientDownloadRequest proto. This function also 300 // a download. This function also records UMA stats of download attribution
300 // records UMA stats of download attribution result. 301 // result.
301 void AddReferrerChainToClientDownloadRequest( 302 std::unique_ptr<ReferrerChain> IdentifyReferrerChain(
302 const GURL& download_url, 303 const GURL& download_url,
303 content::WebContents* web_contents, 304 content::WebContents* web_contents);
304 ClientDownloadRequest* out_request);
305 305
306 // If kDownloadAttribution feature is enabled, identify referrer chain of the 306 // If kDownloadAttribution feature is enabled, identify referrer chain of the
307 // PPAPI download based on the frame URL where the download is initiated. 307 // PPAPI download based on the frame URL where the download is initiated.
308 // Then add referrer chain info to ClientDownloadRequest proto. This function 308 // Then add referrer chain info to ClientDownloadRequest proto. This function
309 // also records UMA stats of download attribution result. 309 // also records UMA stats of download attribution result.
310 void AddReferrerChainToPPAPIClientDownloadRequest( 310 void AddReferrerChainToPPAPIClientDownloadRequest(
311 const GURL& initiating_frame_url, 311 const GURL& initiating_frame_url,
312 int tab_id, 312 int tab_id,
313 bool has_user_gesture, 313 bool has_user_gesture,
314 ClientDownloadRequest* out_request); 314 ClientDownloadRequest* out_request);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 std::set<std::string> manual_blacklist_hashes_; 354 std::set<std::string> manual_blacklist_hashes_;
355 355
356 // Rate of whitelisted downloads we sample to send out download ping. 356 // Rate of whitelisted downloads we sample to send out download ping.
357 double whitelist_sample_rate_; 357 double whitelist_sample_rate_;
358 358
359 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); 359 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService);
360 }; 360 };
361 } // namespace safe_browsing 361 } // namespace safe_browsing
362 362
363 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ 363 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698