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> | |
vandebo (ex-Chrome)
2013/08/07 16:13:14
Are these needed?
Greg Billock
2013/08/07 17:00:56
yes
| |
9 #include <windows.h> | |
10 #endif | |
11 | |
12 #include "base/bind.h" | |
13 #include "base/callback.h" | |
14 #include "base/files/scoped_platform_file_closer.h" | |
vandebo (ex-Chrome)
2013/08/07 16:13:14
Lots of unused headers. At least:
scoped_platfor
Greg Billock
2013/08/07 17:00:56
Done.
| |
15 #include "base/guid.h" | |
16 #include "base/location.h" | |
17 #include "base/logging.h" | |
18 #include "base/memory/scoped_ptr.h" | |
19 #include "base/memory/weak_ptr.h" | |
20 #include "base/stl_util.h" | |
21 #include "base/strings/utf_string_conversions.h" | |
22 #include "base/threading/thread_restrictions.h" | |
23 #include "chrome/common/chrome_constants.h" | |
24 #include "content/public/browser/browser_thread.h" | |
25 | |
26 #if defined(OS_WIN) | |
27 #include "base/file_util.h" | |
28 #endif | |
29 | |
30 using content::BrowserThread; | |
31 | |
32 namespace chrome { | |
33 | |
34 namespace { | |
35 | |
36 #if defined(OS_WIN) | |
37 base::PlatformFileError ScanFile( | |
38 const base::FilePath& dest_platform_path) { | |
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | |
40 base::PlatformFileError result = base::PLATFORM_FILE_OK; | |
vandebo (ex-Chrome)
2013/08/07 16:13:14
I don't think you need this.
Greg Billock
2013/08/07 17:00:56
Moved lower
| |
41 | |
42 std::string client_guid(chrome::kApplicationClientIDStringForAVScanning); | |
43 | |
44 GUID guid = GUID_NULL; | |
45 if (!client_guid.empty() && base::IsValidGUID(client_guid)) { | |
Lei Zhang
2013/08/07 01:03:05
I don't think you need this, the constant should a
Greg Billock
2013/08/07 17:00:56
Done.
| |
46 HRESULT hr = CLSIDFromString(base::UTF8ToUTF16(client_guid).c_str(), &guid); | |
47 if (FAILED(hr)) | |
48 guid = GUID_NULL; | |
49 } | |
50 | |
51 // Execute an AV check of the transferred file. S_OK means | |
52 // the file was OK. Other results may indicate the file was | |
53 // deleted. Any other results, including E_FAIL and | |
54 // INET_E_SECURITY_PROBLEM, are notified as security errors. | |
55 HRESULT scan_result = base::AVScanFile(dest_platform_path, std::string(), | |
Lei Zhang
2013/08/07 01:03:05
nit: I'd prefer to wrap after the equal sign.
HRES
Greg Billock
2013/08/07 17:00:56
Done.
| |
56 guid); | |
57 if (scan_result != S_OK) | |
58 result = base::PLATFORM_FILE_ERROR_SECURITY; | |
vandebo (ex-Chrome)
2013/08/07 16:13:14
Just return here.
Greg Billock
2013/08/07 17:00:56
Done.
| |
59 | |
60 return result; | |
61 } | |
62 #endif | |
63 | |
64 } // namespace | |
65 | |
66 ScanningFileValidator::~ScanningFileValidator() {} | |
67 | |
68 void ScanningFileValidator::StartPostWriteValidation( | |
69 const base::FilePath& dest_platform_path, | |
70 const ResultCallback& result_callback) { | |
71 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | |
72 | |
73 #if defined(OS_WIN) | |
74 BrowserThread::PostTaskAndReplyWithResult( | |
75 BrowserThread::FILE, | |
76 FROM_HERE, | |
77 base::Bind(&ScanFile, dest_platform_path), | |
78 result_callback); | |
79 #else | |
80 result_callback.Run(base::PLATFORM_FILE_OK); | |
81 #endif | |
82 } | |
83 | |
84 ScanningFileValidator::ScanningFileValidator() { | |
85 } | |
86 | |
87 } // namespace chrome | |
OLD | NEW |