| Index: chrome/browser/media_galleries/fileapi/scanning_file_validator.cc
|
| diff --git a/chrome/browser/media_galleries/fileapi/scanning_file_validator.cc b/chrome/browser/media_galleries/fileapi/scanning_file_validator.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..741df342b86409fa1b7f5a4f77e3f1dfa8e061d2
|
| --- /dev/null
|
| +++ b/chrome/browser/media_galleries/fileapi/scanning_file_validator.cc
|
| @@ -0,0 +1,77 @@
|
| +// Copyright 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/media_galleries/fileapi/scanning_file_validator.h"
|
| +
|
| +#if defined(OS_WIN)
|
| +#include <objbase.h>
|
| +#include <windows.h>
|
| +#endif
|
| +
|
| +#include "base/bind.h"
|
| +#include "base/callback.h"
|
| +#include "base/location.h"
|
| +#include "base/logging.h"
|
| +#include "base/strings/utf_string_conversions.h"
|
| +#include "chrome/common/chrome_constants.h"
|
| +#include "content/public/browser/browser_thread.h"
|
| +
|
| +#if defined(OS_WIN)
|
| +#include "base/file_util.h"
|
| +#endif
|
| +
|
| +using content::BrowserThread;
|
| +
|
| +namespace chrome {
|
| +
|
| +namespace {
|
| +
|
| +#if defined(OS_WIN)
|
| +base::PlatformFileError ScanFile(
|
| + const base::FilePath& dest_platform_path) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
|
| +
|
| + std::string client_guid(chrome::kApplicationClientIDStringForAVScanning);
|
| +
|
| + GUID guid = GUID_NULL;
|
| + HRESULT hr = CLSIDFromString(base::UTF8ToUTF16(client_guid).c_str(), &guid);
|
| + DCHECK(!FAILED(hr));
|
| +
|
| + // 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::AVScanFile(dest_platform_path, std::string(), guid);
|
| + if (scan_result == S_OK)
|
| + return base::PLATFORM_FILE_OK;
|
| +
|
| + return base::PLATFORM_FILE_ERROR_SECURITY;
|
| +}
|
| +#endif
|
| +
|
| +} // namespace
|
| +
|
| +ScanningFileValidator::~ScanningFileValidator() {}
|
| +
|
| +void ScanningFileValidator::StartPostWriteValidation(
|
| + const base::FilePath& dest_platform_path,
|
| + const ResultCallback& result_callback) {
|
| + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| +
|
| +#if defined(OS_WIN)
|
| + BrowserThread::PostTaskAndReplyWithResult(
|
| + BrowserThread::FILE,
|
| + FROM_HERE,
|
| + base::Bind(&ScanFile, dest_platform_path),
|
| + result_callback);
|
| +#else
|
| + result_callback.Run(base::PLATFORM_FILE_OK);
|
| +#endif
|
| +}
|
| +
|
| +ScanningFileValidator::ScanningFileValidator() {
|
| +}
|
| +
|
| +} // namespace chrome
|
|
|