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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 #include "base/bind.h"
8 #include "base/callback.h"
9 #include "base/files/scoped_platform_file_closer.h"
10 #include "base/location.h"
11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/stl_util.h"
15 #include "base/threading/thread_restrictions.h"
16 #include "content/public/browser/browser_thread.h"
17
18 #if defined(OS_WIN)
19 #include "base/file_util.h"
20 #endif
21
22 using content::BrowserThread;
23
24 namespace chrome {
25
26 namespace {
27
28 #if defined(OS_WIN)
29 base::PlatformFileError ScanFile(
30 const base::FilePath& dest_platform_path) {
31 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
32 base::PlatformFileError result = base::PLATFORM_FILE_OK;
33
34 // Execute an AV check of the transferred file. S_OK means
35 // the file was OK. Other results may indicate the file was
36 // deleted. Any other results, including E_FAIL and
37 // INET_E_SECURITY_PROBLEM, are notified as security errors.
38 HRESULT scan_result = base::AVScanFile(dest_platform_path, std::string());
39 if (scan_result != S_OK)
40 result = base::PLATFORM_FILE_ERROR_SECURITY;
41
42 return result;
43 }
44 #endif
45
46 } // namespace
47
48 ScanningFileValidator::~ScanningFileValidator() {}
49
50 void ScanningFileValidator::StartPostWriteValidation(
51 const base::FilePath& dest_platform_path,
52 const ResultCallback& result_callback) {
53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
54
55 #if defined(OS_WIN)
56 BrowserThread::PostTaskAndReplyWithResult(
57 BrowserThread::FILE,
58 FROM_HERE,
59 base::Bind(&ScanFile, dest_platform_path),
60 result_callback);
61 #else
62 BrowserThread::PostTask(
63 BrowserThread::IO,
64 FROM_HERE,
65 base::Bind(result_callback, base::PLATFORM_FILE_OK));
66 #endif
67 }
68
69 ScanningFileValidator::ScanningFileValidator() {
70 }
71
72 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698