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

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: Add int values for histograms to ensure they match 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 = 0,
163 REASON_SB_DISABLED, 164 REASON_SB_DISABLED = 1,
164 REASON_WHITELISTED_URL, 165 REASON_WHITELISTED_URL = 2,
165 REASON_WHITELISTED_REFERRER, 166 REASON_WHITELISTED_REFERRER = 3,
166 REASON_INVALID_REQUEST_PROTO, 167 REASON_INVALID_REQUEST_PROTO = 4,
167 REASON_SERVER_PING_FAILED, 168 REASON_SERVER_PING_FAILED = 5,
168 REASON_INVALID_RESPONSE_PROTO, 169 REASON_INVALID_RESPONSE_PROTO = 6,
169 REASON_NOT_BINARY_FILE, 170 REASON_NOT_BINARY_FILE = 7,
170 REASON_REQUEST_CANCELED, 171 REASON_REQUEST_CANCELED = 8,
171 REASON_DOWNLOAD_DANGEROUS, 172 REASON_DOWNLOAD_DANGEROUS = 9,
172 REASON_DOWNLOAD_SAFE, 173 REASON_DOWNLOAD_SAFE = 10,
173 REASON_EMPTY_URL_CHAIN, 174 REASON_EMPTY_URL_CHAIN = 11,
174 DEPRECATED_REASON_HTTPS_URL, 175 DEPRECATED_REASON_HTTPS_URL = 12,
175 REASON_PING_DISABLED, 176 REASON_PING_DISABLED = 13,
176 REASON_TRUSTED_EXECUTABLE, 177 REASON_TRUSTED_EXECUTABLE = 14,
177 REASON_OS_NOT_SUPPORTED, 178 REASON_OS_NOT_SUPPORTED = 15,
178 REASON_DOWNLOAD_UNCOMMON, 179 REASON_DOWNLOAD_UNCOMMON = 16,
179 REASON_DOWNLOAD_NOT_SUPPORTED, 180 REASON_DOWNLOAD_NOT_SUPPORTED = 17,
180 REASON_INVALID_RESPONSE_VERDICT, 181 REASON_INVALID_RESPONSE_VERDICT = 18,
181 REASON_ARCHIVE_WITHOUT_BINARIES, 182 REASON_ARCHIVE_WITHOUT_BINARIES = 19,
182 REASON_DOWNLOAD_DANGEROUS_HOST, 183 REASON_DOWNLOAD_DANGEROUS_HOST = 20,
183 REASON_DOWNLOAD_POTENTIALLY_UNWANTED, 184 REASON_DOWNLOAD_POTENTIALLY_UNWANTED = 21,
184 REASON_UNSUPPORTED_URL_SCHEME, 185 REASON_UNSUPPORTED_URL_SCHEME = 22,
185 REASON_MANUAL_BLACKLIST, 186 REASON_MANUAL_BLACKLIST = 23,
186 REASON_LOCAL_FILE, 187 REASON_LOCAL_FILE = 24,
187 REASON_REMOTE_FILE, 188 REASON_REMOTE_FILE = 25,
189 REASON_SAMPLED_UNSUPPORTED_FILE = 26,
188 REASON_MAX // Always add new values before this one. 190 REASON_MAX // Always add new values before this one.
189 }; 191 };
190 192
191 private: 193 private:
192 class CheckClientDownloadRequest; 194 class CheckClientDownloadRequest;
193 class PPAPIDownloadRequest; 195 class PPAPIDownloadRequest;
194 friend class DownloadProtectionServiceTest; 196 friend class DownloadProtectionServiceTest;
195 friend class DownloadDangerPromptTest; 197 friend class DownloadDangerPromptTest;
196 198
197 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest, 199 FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest,
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 std::set<std::string> manual_blacklist_hashes_; 300 std::set<std::string> manual_blacklist_hashes_;
299 301
300 // Rate of whitelisted downloads we sample to send out download ping. 302 // Rate of whitelisted downloads we sample to send out download ping.
301 double whitelist_sample_rate_; 303 double whitelist_sample_rate_;
302 304
303 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService); 305 DISALLOW_COPY_AND_ASSIGN(DownloadProtectionService);
304 }; 306 };
305 } // namespace safe_browsing 307 } // namespace safe_browsing
306 308
307 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_ 309 #endif // CHROME_BROWSER_SAFE_BROWSING_DOWNLOAD_PROTECTION_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698