| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <shlobj.h> | 5 #include <shlobj.h> |
| 6 #include <shobjidl.h> | 6 #include <shobjidl.h> |
| 7 | 7 |
| 8 #include "chrome/common/win_safe_util.h" | 8 #include "chrome/common/win_safe_util.h" |
| 9 | 9 |
| 10 #include "app/win/shell.h" | 10 #include "app/win/shell.h" |
| 11 #include "base/file_path.h" | 11 #include "base/file_path.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/scoped_comptr_win.h" | |
| 15 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/win/scoped_comptr.h" |
| 16 | 16 |
| 17 namespace win_util { | 17 namespace win_util { |
| 18 | 18 |
| 19 // This function implementation is based on the attachment execution | 19 // This function implementation is based on the attachment execution |
| 20 // services functionally deployed with IE6 or Service pack 2. This | 20 // services functionally deployed with IE6 or Service pack 2. This |
| 21 // functionality is exposed in the IAttachmentExecute COM interface. | 21 // functionality is exposed in the IAttachmentExecute COM interface. |
| 22 // more information at: | 22 // more information at: |
| 23 // http://msdn2.microsoft.com/en-us/library/ms647048.aspx | 23 // http://msdn2.microsoft.com/en-us/library/ms647048.aspx |
| 24 bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, | 24 bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, |
| 25 const FilePath& full_path, | 25 const FilePath& full_path, |
| 26 const std::wstring& source_url) { | 26 const std::wstring& source_url) { |
| 27 ScopedComPtr<IAttachmentExecute> attachment_services; | 27 base::win::ScopedComPtr<IAttachmentExecute> attachment_services; |
| 28 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); | 28 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); |
| 29 if (FAILED(hr)) { | 29 if (FAILED(hr)) { |
| 30 // We don't have Attachment Execution Services, it must be a pre-XP.SP2 | 30 // We don't have Attachment Execution Services, it must be a pre-XP.SP2 |
| 31 // Windows installation, or the thread does not have COM initialized. | 31 // Windows installation, or the thread does not have COM initialized. |
| 32 if (hr == CO_E_NOTINITIALIZED) { | 32 if (hr == CO_E_NOTINITIALIZED) { |
| 33 NOTREACHED(); | 33 NOTREACHED(); |
| 34 return false; | 34 return false; |
| 35 } | 35 } |
| 36 return app::win::OpenItemViaShell(full_path); | 36 return app::win::OpenItemViaShell(full_path); |
| 37 } | 37 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 if (!result || !flush_result || written != kIdentifierSize) { | 104 if (!result || !flush_result || written != kIdentifierSize) { |
| 105 NOTREACHED(); | 105 NOTREACHED(); |
| 106 return false; | 106 return false; |
| 107 } | 107 } |
| 108 | 108 |
| 109 return true; | 109 return true; |
| 110 } | 110 } |
| 111 | 111 |
| 112 } // namespace win_util | 112 } // namespace win_util |
| OLD | NEW |