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

Unified Diff: chrome/browser/safe_browsing/download_protection_service.cc

Issue 2926473002: Mac Archive Type Sniffing (Closed)
Patch Set: avoiding multiple asynchronous calls in tester for mac Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/download_protection_service.cc
diff --git a/chrome/browser/safe_browsing/download_protection_service.cc b/chrome/browser/safe_browsing/download_protection_service.cc
index 8bcdac8df416083635a91feb32885d32b5a6d4ee..1c74ea0020d3371e522d39c08551417a2dcd37a8 100644
--- a/chrome/browser/safe_browsing/download_protection_service.cc
+++ b/chrome/browser/safe_browsing/download_protection_service.cc
@@ -74,6 +74,7 @@
#include "net/url_request/url_request_status.h"
#if defined(OS_MACOSX)
+#include "chrome/browser/safe_browsing/disk_image_type_sniffer_mac.h"
#include "chrome/browser/safe_browsing/sandboxed_dmg_analyzer_mac.h"
#endif
@@ -468,7 +469,19 @@ class DownloadProtectionService::CheckClientDownloadRequest
StartExtractDmgFeatures();
#endif
} else {
+#if defined(OS_MACOSX)
+ // Checks for existence of "koly" signature even if file doesn't have
+ // archive-type extension, then calls ExtractFileOrDmgFeatures() with
+ // result.
+ BrowserThread::PostTaskAndReplyWithResult(
+ BrowserThread::FILE, FROM_HERE,
+ base::Bind(DiskImageTypeSnifferMac::IsAppleDiskImage,
+ item_->GetTargetFilePath()),
+ base::Bind(&CheckClientDownloadRequest::ExtractFileOrDmgFeatures,
+ this));
+#else
StartExtractFileFeatures();
+#endif
}
}
@@ -776,6 +789,23 @@ class DownloadProtectionService::CheckClientDownloadRequest
dmg_analysis_start_time_ = base::TimeTicks::Now();
}
+ // Extracts DMG features if file has 'koly' signature, otherwise extracts
+ // regular file features.
+ void ExtractFileOrDmgFeatures(bool download_file_has_koly_signature) {
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+ UMA_HISTOGRAM_BOOLEAN(
+ "SBClientDownload."
+ "DownloadFileWithoutDiskImageExtensionHasKolySignature",
+ download_file_has_koly_signature);
+ // Returns if DownloadItem was destroyed during parsing of file metadata.
+ if (item_ == nullptr)
+ return;
+ if (download_file_has_koly_signature)
+ StartExtractDmgFeatures();
+ else
+ StartExtractFileFeatures();
+ }
+
void OnDmgAnalysisFinished(const ArchiveAnalyzerResults& results) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK_EQ(ClientDownloadRequest::MAC_EXECUTABLE, type_);

Powered by Google App Engine
This is Rietveld 408576698