Chromium Code Reviews| 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..fd036470d25598a111369f6067fb9a9a95a5c53c 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,26 @@ class ImageDecoderDelegateAdapter : public ImageDecoder::Delegate { |
| DISALLOW_COPY_AND_ASSIGN(ImageDecoderDelegateAdapter); |
| }; |
| +#if defined(OS_WIN) |
| +base::PlatformFileError ScanFile( |
|
vandebo (ex-Chrome)
2013/08/05 18:05:30
Why aren't you using the base class?
Greg Billock
2013/08/05 21:42:30
Checking if the base class would satisfy the thing
vandebo (ex-Chrome)
2013/08/05 23:21:13
Yes, I think a base class that implements the Post
|
| + const base::FilePath& dest_platform_path) { |
|
Lei Zhang
2013/08/03 00:42:39
fits on previous line.
Greg Billock
2013/08/05 21:42:30
Done.
|
| + 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 +144,19 @@ 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. |
| +#if defined(OS_WIN) |
| + BrowserThread::PostTaskAndReplyWithResult( |
| + BrowserThread::FILE, |
| + FROM_HERE, |
| + base::Bind(&ScanFile, dest_platform_path), |
| + result_callback); |
| +#else |
| BrowserThread::PostTask( |
|
Lei Zhang
2013/08/03 00:42:39
You are already on the IO thread, just do:
result
Greg Billock
2013/08/05 21:42:30
Done. This changes semantics a little, but it look
|
| BrowserThread::IO, |
| FROM_HERE, |
| - base::Bind(post_write_callback_, base::PLATFORM_FILE_OK)); |
| + base::Bind(result_callback, base::PLATFORM_FILE_OK)); |
| +#endif |
| } |
| SupportedImageTypeValidator::SupportedImageTypeValidator( |