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

Unified Diff: chrome/browser/media_galleries/fileapi/scanning_file_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: base updates 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/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..bdf0ff72d22ac8d5fd3006e0f6598457415df730
--- /dev/null
+++ b/chrome/browser/media_galleries/fileapi/scanning_file_validator.cc
@@ -0,0 +1,72 @@
+// 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"
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/files/scoped_platform_file_closer.h"
+#include "base/location.h"
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "base/memory/weak_ptr.h"
+#include "base/stl_util.h"
+#include "base/threading/thread_restrictions.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));
+ 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::AVScanFile(dest_platform_path, std::string());
+ if (scan_result != S_OK)
+ result = base::PLATFORM_FILE_ERROR_SECURITY;
+
+ return result;
+}
+#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
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(result_callback, base::PLATFORM_FILE_OK));
+#endif
+}
+
+ScanningFileValidator::ScanningFileValidator() {
+}
+
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698