Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/media_galleries/fileapi/av_scanning_file_validator.h" | |
| 6 | |
| 7 #if defined(OS_WIN) | |
| 8 #include <windows.h> | |
| 9 #endif | |
| 10 | |
| 11 #include "base/bind.h" | |
| 12 #include "base/callback.h" | |
| 13 #include "base/location.h" | |
| 14 #include "base/logging.h" | |
| 15 #include "base/strings/utf_string_conversions.h" | |
| 16 #include "chrome/common/chrome_constants.h" | |
| 17 #include "content/public/browser/browser_thread.h" | |
| 18 | |
| 19 #if defined(OS_WIN) | |
| 20 #include "base/win/scoped_comptr.h" | |
| 21 #endif | |
| 22 | |
| 23 using content::BrowserThread; | |
| 24 | |
| 25 namespace chrome { | |
| 26 | |
| 27 namespace { | |
| 28 | |
| 29 #if defined(OS_WIN) | |
| 30 base::PlatformFileError ScanFile( | |
| 31 const base::FilePath& dest_platform_path) { | |
| 32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
| 33 | |
| 34 win::ScopedComPtr<IAttachmentExecute> attachment_services; | |
| 35 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); | |
| 36 | |
| 37 if (FAILED(hr)) { | |
| 38 // The thread must have COM initialized. | |
| 39 DCHECK_NE(CO_E_NOTINITIALIZED, hr); | |
| 40 return hr; | |
|
vandebo (ex-Chrome)
2013/08/07 18:36:01
We don't want to return hr here.
Greg Billock
2013/08/07 18:41:32
Done.
| |
| 41 } | |
| 42 | |
| 43 hr = attachment_services->SetLocalPath(full_path.value().c_str()); | |
| 44 if (FAILED(hr)) | |
| 45 return hr; | |
|
vandebo (ex-Chrome)
2013/08/07 18:36:01
or here
Greg Billock
2013/08/07 18:41:32
Done.
| |
| 46 | |
| 47 // A failure in the Save() call below could result in the downloaded file | |
| 48 // being deleted. | |
| 49 HRESULT scan_result = attachment_services->Save(); | |
| 50 if (scan_result == S_OK) | |
| 51 return base::PLATFORM_FILE_OK; | |
| 52 | |
| 53 return base::PLATFORM_FILE_ERROR_SECURITY; | |
| 54 } | |
| 55 #endif | |
| 56 | |
| 57 } // namespace | |
| 58 | |
| 59 AVScanningFileValidator::~AVScanningFileValidator() {} | |
| 60 | |
| 61 void AVScanningFileValidator::StartPostWriteValidation( | |
| 62 const base::FilePath& dest_platform_path, | |
| 63 const ResultCallback& result_callback) { | |
| 64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 65 | |
| 66 #if defined(OS_WIN) | |
| 67 BrowserThread::PostTaskAndReplyWithResult( | |
| 68 BrowserThread::FILE, | |
| 69 FROM_HERE, | |
| 70 base::Bind(&ScanFile, dest_platform_path), | |
| 71 result_callback); | |
| 72 #else | |
| 73 result_callback.Run(base::PLATFORM_FILE_OK); | |
| 74 #endif | |
| 75 } | |
| 76 | |
| 77 AVScanningFileValidator::AVScanningFileValidator() { | |
| 78 } | |
| 79 | |
| 80 } // namespace chrome | |
| OLD | NEW |