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/scanning_file_validator.h" | |
| 6 | |
| 7 #if defined(OS_WIN) | |
| 8 #include <objbase.h> | |
| 9 #include <windows.h> | |
| 10 #endif | |
| 11 | |
| 12 #include "base/bind.h" | |
| 13 #include "base/callback.h" | |
| 14 #include "base/location.h" | |
| 15 #include "base/logging.h" | |
| 16 #include "base/strings/utf_string_conversions.h" | |
| 17 #include "chrome/common/chrome_constants.h" | |
| 18 #include "content/public/browser/browser_thread.h" | |
| 19 | |
| 20 #if defined(OS_WIN) | |
| 21 #include "base/file_util.h" | |
| 22 #endif | |
| 23 | |
| 24 using content::BrowserThread; | |
| 25 | |
| 26 namespace chrome { | |
| 27 | |
| 28 namespace { | |
| 29 | |
| 30 #if defined(OS_WIN) | |
| 31 base::PlatformFileError ScanFile( | |
| 32 const base::FilePath& dest_platform_path) { | |
| 33 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
| 34 | |
| 35 std::string client_guid(chrome::kApplicationClientIDStringForAVScanning); | |
| 36 | |
| 37 GUID guid = GUID_NULL; | |
| 38 HRESULT hr = CLSIDFromString(base::UTF8ToUTF16(client_guid).c_str(), &guid); | |
| 39 DCHECK(!FAILED(hr)); | |
| 40 | |
| 41 // Execute an AV check of the transferred file. S_OK means | |
| 42 // the file was OK. Other results may indicate the file was | |
| 43 // deleted. Any other results, including E_FAIL and | |
| 44 // INET_E_SECURITY_PROBLEM, are notified as security errors. | |
| 45 HRESULT scan_result = | |
| 46 base::AVScanFile(dest_platform_path, std::string(), guid); | |
| 47 if (scan_result != S_OK) | |
|
vandebo (ex-Chrome)
2013/08/07 17:11:12
nit: flip the case of this to fail safely in the f
Greg Billock
2013/08/07 17:42:56
Done.
| |
| 48 return base::PLATFORM_FILE_ERROR_SECURITY; | |
| 49 | |
| 50 return base::PLATFORM_FILE_OK; | |
| 51 } | |
| 52 #endif | |
| 53 | |
| 54 } // namespace | |
| 55 | |
| 56 ScanningFileValidator::~ScanningFileValidator() {} | |
| 57 | |
| 58 void ScanningFileValidator::StartPostWriteValidation( | |
| 59 const base::FilePath& dest_platform_path, | |
| 60 const ResultCallback& result_callback) { | |
| 61 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
| 62 | |
| 63 #if defined(OS_WIN) | |
| 64 BrowserThread::PostTaskAndReplyWithResult( | |
| 65 BrowserThread::FILE, | |
| 66 FROM_HERE, | |
| 67 base::Bind(&ScanFile, dest_platform_path), | |
| 68 result_callback); | |
| 69 #else | |
| 70 result_callback.Run(base::PLATFORM_FILE_OK); | |
| 71 #endif | |
| 72 } | |
| 73 | |
| 74 ScanningFileValidator::ScanningFileValidator() { | |
| 75 } | |
| 76 | |
| 77 } // namespace chrome | |
| OLD | NEW |