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

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

Issue 379563006: Merge 281089 "Include the latest binary download info in safe br..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: 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
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/incident_report_uploader.h » ('j') | 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/browser/safe_browsing/download_protection_service.h" 5 #include "chrome/browser/safe_browsing/download_protection_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 namespace { 49 namespace {
50 static const int64 kDownloadRequestTimeoutMs = 7000; 50 static const int64 kDownloadRequestTimeoutMs = 7000;
51 } // namespace 51 } // namespace
52 52
53 namespace safe_browsing { 53 namespace safe_browsing {
54 54
55 const char DownloadProtectionService::kDownloadRequestUrl[] = 55 const char DownloadProtectionService::kDownloadRequestUrl[] =
56 "https://sb-ssl.google.com/safebrowsing/clientreport/download"; 56 "https://sb-ssl.google.com/safebrowsing/clientreport/download";
57 57
58 namespace { 58 namespace {
59 ClientDownloadRequest::DownloadType GetDownloadType(
60 const base::FilePath& file) {
61 DCHECK(download_protection_util::IsBinaryFile(file));
62 if (file.MatchesExtension(FILE_PATH_LITERAL(".apk")))
63 return ClientDownloadRequest::ANDROID_APK;
64 else if (file.MatchesExtension(FILE_PATH_LITERAL(".crx")))
65 return ClientDownloadRequest::CHROME_EXTENSION;
66 // For zip files, we use the ZIPPED_EXECUTABLE type since we will only send
67 // the pingback if we find an executable inside the zip archive.
68 else if (file.MatchesExtension(FILE_PATH_LITERAL(".zip")))
69 return ClientDownloadRequest::ZIPPED_EXECUTABLE;
70 return ClientDownloadRequest::WIN_EXECUTABLE;
71 }
72
73 // List of extensions for which we track some UMA stats. 59 // List of extensions for which we track some UMA stats.
74 enum MaliciousExtensionType { 60 enum MaliciousExtensionType {
75 EXTENSION_EXE, 61 EXTENSION_EXE,
76 EXTENSION_MSI, 62 EXTENSION_MSI,
77 EXTENSION_CAB, 63 EXTENSION_CAB,
78 EXTENSION_SYS, 64 EXTENSION_SYS,
79 EXTENSION_SCR, 65 EXTENSION_SCR,
80 EXTENSION_DRV, 66 EXTENSION_DRV,
81 EXTENSION_BAT, 67 EXTENSION_BAT,
82 EXTENSION_ZIP, 68 EXTENSION_ZIP,
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 const GURL& final_url = item.GetUrlChain().back(); 456 const GURL& final_url = item.GetUrlChain().back();
471 if (!final_url.is_valid() || final_url.is_empty() || 457 if (!final_url.is_valid() || final_url.is_empty() ||
472 !final_url.IsStandard() || final_url.SchemeIsFile()) { 458 !final_url.IsStandard() || final_url.SchemeIsFile()) {
473 *reason = REASON_INVALID_URL; 459 *reason = REASON_INVALID_URL;
474 return false; 460 return false;
475 } 461 }
476 if (!download_protection_util::IsBinaryFile(target_path)) { 462 if (!download_protection_util::IsBinaryFile(target_path)) {
477 *reason = REASON_NOT_BINARY_FILE; 463 *reason = REASON_NOT_BINARY_FILE;
478 return false; 464 return false;
479 } 465 }
480 *type = GetDownloadType(target_path); 466 *type = download_protection_util::GetDownloadType(target_path);
481 return true; 467 return true;
482 } 468 }
483 469
484 private: 470 private:
485 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>; 471 friend struct BrowserThread::DeleteOnThread<BrowserThread::UI>;
486 friend class base::DeleteHelper<CheckClientDownloadRequest>; 472 friend class base::DeleteHelper<CheckClientDownloadRequest>;
487 473
488 virtual ~CheckClientDownloadRequest() { 474 virtual ~CheckClientDownloadRequest() {
489 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 475 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
490 DCHECK(item_ == NULL); 476 DCHECK(item_ == NULL);
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 GURL DownloadProtectionService::GetDownloadRequestUrl() { 1049 GURL DownloadProtectionService::GetDownloadRequestUrl() {
1064 GURL url(kDownloadRequestUrl); 1050 GURL url(kDownloadRequestUrl);
1065 std::string api_key = google_apis::GetAPIKey(); 1051 std::string api_key = google_apis::GetAPIKey();
1066 if (!api_key.empty()) 1052 if (!api_key.empty())
1067 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); 1053 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true));
1068 1054
1069 return url; 1055 return url;
1070 } 1056 }
1071 1057
1072 } // namespace safe_browsing 1058 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/incident_report_uploader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698