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

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

Issue 330653006: Include the latest binary download info in safe browsing incident reports. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iterator cleanup Created 6 years, 5 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 | Annotate | Revision Log
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"
6
5 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/logging.h"
6 9
7 namespace safe_browsing { 10 namespace safe_browsing {
8 namespace download_protection_util { 11 namespace download_protection_util {
9 12
10 bool IsArchiveFile(const base::FilePath& file) { 13 bool IsArchiveFile(const base::FilePath& file) {
11 return file.MatchesExtension(FILE_PATH_LITERAL(".zip")); 14 return file.MatchesExtension(FILE_PATH_LITERAL(".zip"));
12 } 15 }
13 16
14 bool IsBinaryFile(const base::FilePath& file) { 17 bool IsBinaryFile(const base::FilePath& file) {
15 return ( 18 return (
(...skipping 11 matching lines...) Expand all
27 file.MatchesExtension(FILE_PATH_LITERAL(".scr")) || 30 file.MatchesExtension(FILE_PATH_LITERAL(".scr")) ||
28 file.MatchesExtension(FILE_PATH_LITERAL(".vb")) || 31 file.MatchesExtension(FILE_PATH_LITERAL(".vb")) ||
29 file.MatchesExtension(FILE_PATH_LITERAL(".vbs")) || 32 file.MatchesExtension(FILE_PATH_LITERAL(".vbs")) ||
30 // Chrome extensions and android APKs are also reported. 33 // Chrome extensions and android APKs are also reported.
31 file.MatchesExtension(FILE_PATH_LITERAL(".crx")) || 34 file.MatchesExtension(FILE_PATH_LITERAL(".crx")) ||
32 file.MatchesExtension(FILE_PATH_LITERAL(".apk")) || 35 file.MatchesExtension(FILE_PATH_LITERAL(".apk")) ||
33 // Archives _may_ contain binaries, we'll check in ExtractFileFeatures. 36 // Archives _may_ contain binaries, we'll check in ExtractFileFeatures.
34 IsArchiveFile(file)); 37 IsArchiveFile(file));
35 } 38 }
36 39
40 ClientDownloadRequest::DownloadType GetDownloadType(
41 const base::FilePath& file) {
42 DCHECK(IsBinaryFile(file));
43 if (file.MatchesExtension(FILE_PATH_LITERAL(".apk")))
44 return ClientDownloadRequest::ANDROID_APK;
45 else if (file.MatchesExtension(FILE_PATH_LITERAL(".crx")))
46 return ClientDownloadRequest::CHROME_EXTENSION;
47 // 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.
49 else if (file.MatchesExtension(FILE_PATH_LITERAL(".zip")))
50 return ClientDownloadRequest::ZIPPED_EXECUTABLE;
51 return ClientDownloadRequest::WIN_EXECUTABLE;
52 }
53
37 } // namespace download_protection_util 54 } // namespace download_protection_util
38 } // namespace safe_browsing 55 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698