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

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

Issue 580593003: Reland Safebrowsing: allow sending enhanced download protection pings on OSX. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed tests 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?
14 return file.MatchesExtension(FILE_PATH_LITERAL(".zip")); 15 return file.MatchesExtension(FILE_PATH_LITERAL(".zip"));
15 } 16 }
16 17
17 bool IsBinaryFile(const base::FilePath& file) { 18 bool IsBinaryFile(const base::FilePath& file) {
18 return ( 19 return (
19 // Executable extensions for MS Windows. 20 // Executable extensions for MS Windows.
20 file.MatchesExtension(FILE_PATH_LITERAL(".bas")) || 21 file.MatchesExtension(FILE_PATH_LITERAL(".bas")) ||
21 file.MatchesExtension(FILE_PATH_LITERAL(".bat")) || 22 file.MatchesExtension(FILE_PATH_LITERAL(".bat")) ||
22 file.MatchesExtension(FILE_PATH_LITERAL(".cab")) || 23 file.MatchesExtension(FILE_PATH_LITERAL(".cab")) ||
23 file.MatchesExtension(FILE_PATH_LITERAL(".cmd")) || 24 file.MatchesExtension(FILE_PATH_LITERAL(".cmd")) ||
24 file.MatchesExtension(FILE_PATH_LITERAL(".com")) || 25 file.MatchesExtension(FILE_PATH_LITERAL(".com")) ||
25 file.MatchesExtension(FILE_PATH_LITERAL(".exe")) || 26 file.MatchesExtension(FILE_PATH_LITERAL(".exe")) ||
26 file.MatchesExtension(FILE_PATH_LITERAL(".hta")) || 27 file.MatchesExtension(FILE_PATH_LITERAL(".hta")) ||
27 file.MatchesExtension(FILE_PATH_LITERAL(".msi")) || 28 file.MatchesExtension(FILE_PATH_LITERAL(".msi")) ||
28 file.MatchesExtension(FILE_PATH_LITERAL(".pif")) || 29 file.MatchesExtension(FILE_PATH_LITERAL(".pif")) ||
29 file.MatchesExtension(FILE_PATH_LITERAL(".reg")) || 30 file.MatchesExtension(FILE_PATH_LITERAL(".reg")) ||
30 file.MatchesExtension(FILE_PATH_LITERAL(".scr")) || 31 file.MatchesExtension(FILE_PATH_LITERAL(".scr")) ||
31 file.MatchesExtension(FILE_PATH_LITERAL(".vb")) || 32 file.MatchesExtension(FILE_PATH_LITERAL(".vb")) ||
32 file.MatchesExtension(FILE_PATH_LITERAL(".vbs")) || 33 file.MatchesExtension(FILE_PATH_LITERAL(".vbs")) ||
33 // Chrome extensions and android APKs are also reported. 34 // Chrome extensions and android APKs are also reported.
34 file.MatchesExtension(FILE_PATH_LITERAL(".crx")) || 35 file.MatchesExtension(FILE_PATH_LITERAL(".crx")) ||
35 file.MatchesExtension(FILE_PATH_LITERAL(".apk")) || 36 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")) ||
36 // Archives _may_ contain binaries, we'll check in ExtractFileFeatures. 42 // Archives _may_ contain binaries, we'll check in ExtractFileFeatures.
37 IsArchiveFile(file)); 43 IsArchiveFile(file));
38 } 44 }
39 45
40 ClientDownloadRequest::DownloadType GetDownloadType( 46 ClientDownloadRequest::DownloadType GetDownloadType(
41 const base::FilePath& file) { 47 const base::FilePath& file) {
42 DCHECK(IsBinaryFile(file)); 48 DCHECK(IsBinaryFile(file));
43 if (file.MatchesExtension(FILE_PATH_LITERAL(".apk"))) 49 if (file.MatchesExtension(FILE_PATH_LITERAL(".apk")))
44 return ClientDownloadRequest::ANDROID_APK; 50 return ClientDownloadRequest::ANDROID_APK;
45 else if (file.MatchesExtension(FILE_PATH_LITERAL(".crx"))) 51 else if (file.MatchesExtension(FILE_PATH_LITERAL(".crx")))
46 return ClientDownloadRequest::CHROME_EXTENSION; 52 return ClientDownloadRequest::CHROME_EXTENSION;
47 // For zip files, we use the ZIPPED_EXECUTABLE type since we will only send 53 // For zip files, we use the ZIPPED_EXECUTABLE type since we will only send
48 // the pingback if we find an executable inside the zip archive. 54 // the pingback if we find an executable inside the zip archive.
49 else if (file.MatchesExtension(FILE_PATH_LITERAL(".zip"))) 55 else if (file.MatchesExtension(FILE_PATH_LITERAL(".zip")))
50 return ClientDownloadRequest::ZIPPED_EXECUTABLE; 56 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;
51 return ClientDownloadRequest::WIN_EXECUTABLE; 62 return ClientDownloadRequest::WIN_EXECUTABLE;
52 } 63 }
53 64
54 } // namespace download_protection_util 65 } // namespace download_protection_util
55 } // namespace safe_browsing 66 } // 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