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

Side by Side Diff: chrome/common/safe_browsing/download_protection_util.cc

Issue 555373005: Revert "Safebrowsing: allow sending enhanced download protection pings on OSX." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « chrome/common/safe_browsing/csd.proto ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "chrome/common/safe_browsing/download_protection_util.h" 5 #include "chrome/common/safe_browsing/download_protection_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace safe_browsing { 10 namespace safe_browsing {
11 namespace download_protection_util { 11 namespace download_protection_util {
12 12
13 bool IsArchiveFile(const base::FilePath& file) { 13 bool IsArchiveFile(const base::FilePath& file) {
14 // TODO(mattm): should .dmg be checked here instead of IsBinaryFile?
15 return file.MatchesExtension(FILE_PATH_LITERAL(".zip")); 14 return file.MatchesExtension(FILE_PATH_LITERAL(".zip"));
16 } 15 }
17 16
18 bool IsBinaryFile(const base::FilePath& file) { 17 bool IsBinaryFile(const base::FilePath& file) {
19 return ( 18 return (
20 // Executable extensions for MS Windows. 19 // Executable extensions for MS Windows.
21 file.MatchesExtension(FILE_PATH_LITERAL(".bas")) || 20 file.MatchesExtension(FILE_PATH_LITERAL(".bas")) ||
22 file.MatchesExtension(FILE_PATH_LITERAL(".bat")) || 21 file.MatchesExtension(FILE_PATH_LITERAL(".bat")) ||
23 file.MatchesExtension(FILE_PATH_LITERAL(".cab")) || 22 file.MatchesExtension(FILE_PATH_LITERAL(".cab")) ||
24 file.MatchesExtension(FILE_PATH_LITERAL(".cmd")) || 23 file.MatchesExtension(FILE_PATH_LITERAL(".cmd")) ||
25 file.MatchesExtension(FILE_PATH_LITERAL(".com")) || 24 file.MatchesExtension(FILE_PATH_LITERAL(".com")) ||
26 file.MatchesExtension(FILE_PATH_LITERAL(".exe")) || 25 file.MatchesExtension(FILE_PATH_LITERAL(".exe")) ||
27 file.MatchesExtension(FILE_PATH_LITERAL(".hta")) || 26 file.MatchesExtension(FILE_PATH_LITERAL(".hta")) ||
28 file.MatchesExtension(FILE_PATH_LITERAL(".msi")) || 27 file.MatchesExtension(FILE_PATH_LITERAL(".msi")) ||
29 file.MatchesExtension(FILE_PATH_LITERAL(".pif")) || 28 file.MatchesExtension(FILE_PATH_LITERAL(".pif")) ||
30 file.MatchesExtension(FILE_PATH_LITERAL(".reg")) || 29 file.MatchesExtension(FILE_PATH_LITERAL(".reg")) ||
31 file.MatchesExtension(FILE_PATH_LITERAL(".scr")) || 30 file.MatchesExtension(FILE_PATH_LITERAL(".scr")) ||
32 file.MatchesExtension(FILE_PATH_LITERAL(".vb")) || 31 file.MatchesExtension(FILE_PATH_LITERAL(".vb")) ||
33 file.MatchesExtension(FILE_PATH_LITERAL(".vbs")) || 32 file.MatchesExtension(FILE_PATH_LITERAL(".vbs")) ||
34 // Chrome extensions and android APKs are also reported. 33 // Chrome extensions and android APKs are also reported.
35 file.MatchesExtension(FILE_PATH_LITERAL(".crx")) || 34 file.MatchesExtension(FILE_PATH_LITERAL(".crx")) ||
36 file.MatchesExtension(FILE_PATH_LITERAL(".apk")) || 35 file.MatchesExtension(FILE_PATH_LITERAL(".apk")) ||
37 // Mac extensions.
38 file.MatchesExtension(FILE_PATH_LITERAL(".dmg")) ||
39 file.MatchesExtension(FILE_PATH_LITERAL(".pkg")) ||
40 file.MatchesExtension(FILE_PATH_LITERAL(".osx")) ||
41 file.MatchesExtension(FILE_PATH_LITERAL(".app")) ||
42 // Archives _may_ contain binaries, we'll check in ExtractFileFeatures. 36 // Archives _may_ contain binaries, we'll check in ExtractFileFeatures.
43 IsArchiveFile(file)); 37 IsArchiveFile(file));
44 } 38 }
45 39
46 ClientDownloadRequest::DownloadType GetDownloadType( 40 ClientDownloadRequest::DownloadType GetDownloadType(
47 const base::FilePath& file) { 41 const base::FilePath& file) {
48 DCHECK(IsBinaryFile(file)); 42 DCHECK(IsBinaryFile(file));
49 if (file.MatchesExtension(FILE_PATH_LITERAL(".apk"))) 43 if (file.MatchesExtension(FILE_PATH_LITERAL(".apk")))
50 return ClientDownloadRequest::ANDROID_APK; 44 return ClientDownloadRequest::ANDROID_APK;
51 else if (file.MatchesExtension(FILE_PATH_LITERAL(".crx"))) 45 else if (file.MatchesExtension(FILE_PATH_LITERAL(".crx")))
52 return ClientDownloadRequest::CHROME_EXTENSION; 46 return ClientDownloadRequest::CHROME_EXTENSION;
53 // For zip files, we use the ZIPPED_EXECUTABLE type since we will only send 47 // For zip files, we use the ZIPPED_EXECUTABLE type since we will only send
54 // the pingback if we find an executable inside the zip archive. 48 // the pingback if we find an executable inside the zip archive.
55 else if (file.MatchesExtension(FILE_PATH_LITERAL(".zip"))) 49 else if (file.MatchesExtension(FILE_PATH_LITERAL(".zip")))
56 return ClientDownloadRequest::ZIPPED_EXECUTABLE; 50 return ClientDownloadRequest::ZIPPED_EXECUTABLE;
57 else if (file.MatchesExtension(FILE_PATH_LITERAL(".dmg")) ||
58 file.MatchesExtension(FILE_PATH_LITERAL(".pkg")) ||
59 file.MatchesExtension(FILE_PATH_LITERAL(".osx")) ||
60 file.MatchesExtension(FILE_PATH_LITERAL(".app")))
61 return ClientDownloadRequest::MAC_EXECUTABLE;
62 return ClientDownloadRequest::WIN_EXECUTABLE; 51 return ClientDownloadRequest::WIN_EXECUTABLE;
63 } 52 }
64 53
65 } // namespace download_protection_util 54 } // namespace download_protection_util
66 } // namespace safe_browsing 55 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « chrome/common/safe_browsing/csd.proto ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698