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

Side by Side Diff: chrome/browser/media_galleries/fileapi/av_scanning_file_validator.cc

Issue 22441004: [MediaGalleries] Introduce an AV-checking base class for copy-move validation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: missing header 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/av_scanning_file_validator.h"
6
7 #if defined(OS_WIN)
8 #include <windows.h>
9 #include <shlobj.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/win/scoped_comptr.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 base::win::ScopedComPtr<IAttachmentExecute> attachment_services;
36 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices);
37
38 if (FAILED(hr)) {
39 // The thread must have COM initialized.
40 DCHECK_NE(CO_E_NOTINITIALIZED, hr);
41 return base::PLATFORM_FILE_ERROR_SECURITY;
42 }
43
44 hr = attachment_services->SetLocalPath(dest_platform_path.value().c_str());
45 if (FAILED(hr))
46 return base::PLATFORM_FILE_ERROR_SECURITY;
47
48 // A failure in the Save() call below could result in the downloaded file
49 // being deleted.
50 HRESULT scan_result = attachment_services->Save();
51 if (scan_result == S_OK)
52 return base::PLATFORM_FILE_OK;
53
54 return base::PLATFORM_FILE_ERROR_SECURITY;
55 }
56 #endif
57
58 } // namespace
59
60 AVScanningFileValidator::~AVScanningFileValidator() {}
61
62 void AVScanningFileValidator::StartPostWriteValidation(
63 const base::FilePath& dest_platform_path,
64 const ResultCallback& result_callback) {
65 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
66
67 #if defined(OS_WIN)
68 BrowserThread::PostTaskAndReplyWithResult(
69 BrowserThread::FILE,
70 FROM_HERE,
71 base::Bind(&ScanFile, dest_platform_path),
72 result_callback);
73 #else
74 result_callback.Run(base::PLATFORM_FILE_OK);
75 #endif
76 }
77
78 AVScanningFileValidator::AVScanningFileValidator() {
79 }
80
81 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698