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

Unified Diff: chrome/browser/media_galleries/fileapi/supported_image_type_validator.cc

Issue 21355004: [Downloads] Move client guid for AV scanning of downloaded files to chrome/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Changes Created 7 years, 4 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/media_galleries/fileapi/supported_image_type_validator.cc
diff --git a/chrome/browser/media_galleries/fileapi/supported_image_type_validator.cc b/chrome/browser/media_galleries/fileapi/supported_image_type_validator.cc
index 9ae76253c3bb4db6d4584970202449ed06684405..b5441b31073eae55f78ddb11f948491fd2b65bed 100644
--- a/chrome/browser/media_galleries/fileapi/supported_image_type_validator.cc
+++ b/chrome/browser/media_galleries/fileapi/supported_image_type_validator.cc
@@ -16,6 +16,10 @@
#include "chrome/browser/image_decoder.h"
#include "content/public/browser/browser_thread.h"
+#if defined(OS_WIN)
+#include "base/file_util.h"
+#endif
+
using content::BrowserThread;
namespace chrome {
@@ -84,6 +88,25 @@ class ImageDecoderDelegateAdapter : public ImageDecoder::Delegate {
DISALLOW_COPY_AND_ASSIGN(ImageDecoderDelegateAdapter);
};
+#if defined(OS_WIN)
+base::PlatformFileError ScanFile(const base::FilePath& dest_platform_path) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
+ base::PlatformFileError result = base::PLATFORM_FILE_OK;
+
+ // Execute an AV check of the transferred file. S_OK means
+ // the file was OK. Other results may indicate the file was
+ // deleted. Any other results, including E_FAIL and
+ // INET_E_SECURITY_PROBLEM, are notified as security errors.
+ HRESULT scan_result =
+ base::ScanAndSaveDownloadedFile(dest_platform_path, std::string());
+ if (scan_result != S_OK)
+ result = base::PLATFORM_FILE_ERROR_SECURITY;
+
+ return result;
+}
+#endif
+
+
} // namespace
SupportedImageTypeValidator::~SupportedImageTypeValidator() {}
@@ -120,13 +143,16 @@ void SupportedImageTypeValidator::StartPostWriteValidation(
const base::FilePath& dest_platform_path,
const ResultCallback& result_callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- post_write_callback_ = result_callback;
- // TODO(gbillock): Insert AV call here in the right validator.
- BrowserThread::PostTask(
- BrowserThread::IO,
+#if defined(OS_WIN)
+ BrowserThread::PostTaskAndReplyWithResult(
+ BrowserThread::FILE,
FROM_HERE,
- base::Bind(post_write_callback_, base::PLATFORM_FILE_OK));
+ base::Bind(&ScanFile, dest_platform_path),
+ result_callback);
+#else
+ result_callback.Run(base::PLATFORM_FILE_OK);
+#endif
}
SupportedImageTypeValidator::SupportedImageTypeValidator(

Powered by Google App Engine
This is Rietveld 408576698