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

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

Issue 2072933002: Add sampling of unknown filetypes in download protection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 // Checks whether any of the URLs in the redirect chain of the 100 // Checks whether any of the URLs in the redirect chain of the
101 // download match the SafeBrowsing bad binary URL list. The result is 101 // download match the SafeBrowsing bad binary URL list. The result is
102 // delivered asynchronously via the given callback. This method must be 102 // delivered asynchronously via the given callback. This method must be
103 // called on the UI thread, and the callback will also be invoked on the UI 103 // called on the UI thread, and the callback will also be invoked on the UI
104 // thread. Pre-condition: !info.download_url_chain.empty(). 104 // thread. Pre-condition: !info.download_url_chain.empty().
105 virtual void CheckDownloadUrl(const content::DownloadItem& item, 105 virtual void CheckDownloadUrl(const content::DownloadItem& item,
106 const CheckDownloadCallback& callback); 106 const CheckDownloadCallback& callback);
107 107
108 // Returns true iff the download specified by |info| should be scanned by 108 // Returns true iff the download specified by |info| should be scanned by
109 // CheckClientDownload() for malicious content. 109 // CheckClientDownload() for malicious content.
110 virtual bool IsSupportedDownload(const content::DownloadItem& item, 110 virtual bool IsSupportedDownload(
111 const base::FilePath& target_path) const; 111 const content::DownloadItem& item,
112 const base::FilePath& target_path) const;
112 113
113 virtual void CheckPPAPIDownloadRequest( 114 virtual void CheckPPAPIDownloadRequest(
114 const GURL& requestor_url, 115 const GURL& requestor_url,
115 const base::FilePath& default_file_path, 116 const base::FilePath& default_file_path,
116 const std::vector<base::FilePath::StringType>& alternate_extensions, 117 const std::vector<base::FilePath::StringType>& alternate_extensions,
117 const CheckDownloadCallback& callback); 118 const CheckDownloadCallback& callback);
118 119
119 // Display more information to the user regarding the download specified by 120 // Display more information to the user regarding the download specified by
120 // |info|. This method is invoked when the user requests more information 121 // |info|. This method is invoked when the user requests more information
121 // about a download that was marked as malicious. 122 // about a download that was marked as malicious.
(...skipping 28 matching lines...) Expand all
150 return whitelist_sample_rate_; 151 return whitelist_sample_rate_;
151 } 152 }
152 153
153 static void SetDownloadPingToken(content::DownloadItem* item, 154 static void SetDownloadPingToken(content::DownloadItem* item,
154 const std::string& token); 155 const std::string& token);
155 156
156 static std::string GetDownloadPingToken(const content::DownloadItem* item); 157 static std::string GetDownloadPingToken(const content::DownloadItem* item);
157 158
158 protected: 159 protected:
159 // Enum to keep track why a particular download verdict was chosen. 160 // Enum to keep track why a particular download verdict was chosen.
160 // This is used to keep some stats around. 161 // Used for UMA metrics. Do not reorder.
161 enum DownloadCheckResultReason { 162 enum DownloadCheckResultReason {
162 REASON_INVALID_URL, 163 REASON_INVALID_URL,
163 REASON_SB_DISABLED, 164 REASON_SB_DISABLED,
164 REASON_WHITELISTED_URL, 165 REASON_WHITELISTED_URL,
165 REASON_WHITELISTED_REFERRER, 166 REASON_WHITELISTED_REFERRER,
166 REASON_INVALID_REQUEST_PROTO, 167 REASON_INVALID_REQUEST_PROTO,
167 REASON_SERVER_PING_FAILED, 168 REASON_SERVER_PING_FAILED,
168 REASON_INVALID_RESPONSE_PROTO, 169 REASON_INVALID_RESPONSE_PROTO,
169 REASON_NOT_BINARY_FILE, 170 REASON_NOT_BINARY_FILE,
170 REASON_REQUEST_CANCELED, 171 REASON_REQUEST_CANCELED,
171 REASON_DOWNLOAD_DANGEROUS, 172 REASON_DOWNLOAD_DANGEROUS,
172 REASON_DOWNLOAD_SAFE, 173 REASON_DOWNLOAD_SAFE,
173 REASON_EMPTY_URL_CHAIN, 174 REASON_EMPTY_URL_CHAIN,
174 DEPRECATED_REASON_HTTPS_URL, 175 DEPRECATED_REASON_HTTPS_URL,
175 REASON_PING_DISABLED, 176 REASON_PING_DISABLED,
176 REASON_TRUSTED_EXECUTABLE, 177 REASON_TRUSTED_EXECUTABLE,
177 REASON_OS_NOT_SUPPORTED, 178 REASON_OS_NOT_SUPPORTED,
178 REASON_DOWNLOAD_UNCOMMON, 179 REASON_DOWNLOAD_UNCOMMON,
179 REASON_DOWNLOAD_NOT_SUPPORTED, 180 REASON_DOWNLOAD_NOT_SUPPORTED,
180 REASON_INVALID_RESPONSE_VERDICT, 181 REASON_INVALID_RESPONSE_VERDICT,
181 REASON_ARCHIVE_WITHOUT_BINARIES, 182 REASON_ARCHIVE_WITHOUT_BINARIES,
182 REASON_DOWNLOAD_DANGEROUS_HOST, 183 REASON_DOWNLOAD_DANGEROUS_HOST,
183 REASON_DOWNLOAD_POTENTIALLY_UNWANTED, 184 REASON_DOWNLOAD_POTENTIALLY_UNWANTED,
184 REASON_UNSUPPORTED_URL_SCHEME, 185 REASON_UNSUPPORTED_URL_SCHEME,
185 REASON_MANUAL_BLACKLIST, 186 REASON_MANUAL_BLACKLIST,
187 REASON_SAMPLED_UNSUPPORTED_FILE,
186 REASON_MAX // Always add new values before this one. 188 REASON_MAX // Always add new values before this one.
187 }; 189 };
188 190
189 private: 191 private:
190 class CheckClientDownloadRequest; 192 class CheckClientDownloadRequest;
191 class PPAPIDownloadRequest; 193 class PPAPIDownloadRequest;
192 friend class DownloadProtectionServiceTest; 194 friend class DownloadProtectionServiceTest;
193 friend class DownloadDangerPromptTest; 195 friend class DownloadDangerPromptTest;
194 196
195 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest, 197 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 std::set<std::string> manual_blacklist_hashes_; 298 std::set<std::string> manual_blacklist_hashes_;
297 299
298 // Rate of whitelisted downloads we sample to send out download ping. 300 // Rate of whitelisted downloads we sample to send out download ping.
299 double whitelist_sample_rate_; 301 double whitelist_sample_rate_;
300 302
301 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); 303 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService);
302 }; 304 };
303 } // namespace safe_browsing 305 } // namespace safe_browsing
304 306
305 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ 307 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698