OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/media_galleries/fileapi/av_scanning_file_validator.h" | 5 #include "chrome/browser/media_galleries/fileapi/av_scanning_file_validator.h" |
6 | 6 |
7 #if defined(OS_WIN) | 7 #if defined(OS_WIN) |
8 #include <windows.h> | 8 #include <windows.h> |
| 9 #include <objbase.h> |
9 #include <shlobj.h> | 10 #include <shlobj.h> |
10 #endif | 11 #endif |
11 | 12 |
12 #include "base/bind.h" | 13 #include "base/bind.h" |
13 #include "base/callback.h" | 14 #include "base/callback.h" |
14 #include "base/location.h" | 15 #include "base/location.h" |
15 #include "base/logging.h" | 16 #include "base/logging.h" |
16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
17 #include "build/build_config.h" | 18 #include "build/build_config.h" |
18 #include "chrome/common/chrome_constants.h" | 19 #include "chrome/common/chrome_constants.h" |
19 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
20 | 21 |
21 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
22 #include "base/win/scoped_comptr.h" | 23 #include "base/win/scoped_comptr.h" |
23 #endif | 24 #endif |
24 | 25 |
25 using content::BrowserThread; | 26 using content::BrowserThread; |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
30 base::File::Error ScanFile(const base::FilePath& dest_platform_path) { | 31 base::File::Error ScanFile(const base::FilePath& dest_platform_path) { |
31 DCHECK_CURRENTLY_ON(BrowserThread::FILE); | 32 DCHECK_CURRENTLY_ON(BrowserThread::FILE); |
32 | 33 |
33 base::win::ScopedComPtr<IAttachmentExecute> attachment_services; | 34 base::win::ScopedComPtr<IAttachmentExecute> attachment_services; |
34 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); | 35 HRESULT hr = ::CoCreateInstance(CLSID_AttachmentServices, nullptr, CLSCTX_ALL, |
| 36 IID_PPV_ARGS(&attachment_services)); |
35 | 37 |
36 if (FAILED(hr)) { | 38 if (FAILED(hr)) { |
37 // The thread must have COM initialized. | 39 // The thread must have COM initialized. |
38 DCHECK_NE(CO_E_NOTINITIALIZED, hr); | 40 DCHECK_NE(CO_E_NOTINITIALIZED, hr); |
39 return base::File::FILE_ERROR_SECURITY; | 41 return base::File::FILE_ERROR_SECURITY; |
40 } | 42 } |
41 | 43 |
42 hr = attachment_services->SetLocalPath(dest_platform_path.value().c_str()); | 44 hr = attachment_services->SetLocalPath(dest_platform_path.value().c_str()); |
43 if (FAILED(hr)) | 45 if (FAILED(hr)) |
44 return base::File::FILE_ERROR_SECURITY; | 46 return base::File::FILE_ERROR_SECURITY; |
(...skipping 23 matching lines...) Expand all Loading... |
68 FROM_HERE, | 70 FROM_HERE, |
69 base::Bind(&ScanFile, dest_platform_path), | 71 base::Bind(&ScanFile, dest_platform_path), |
70 result_callback); | 72 result_callback); |
71 #else | 73 #else |
72 result_callback.Run(base::File::FILE_OK); | 74 result_callback.Run(base::File::FILE_OK); |
73 #endif | 75 #endif |
74 } | 76 } |
75 | 77 |
76 AVScanningFileValidator::AVScanningFileValidator() { | 78 AVScanningFileValidator::AVScanningFileValidator() { |
77 } | 79 } |
OLD | NEW |