OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include <atlcomcli.h> | 7 #include <atlcomcli.h> |
8 | 8 |
9 #include "chrome/common/win_safe_util.h" | 9 #include "chrome/common/win_safe_util.h" |
10 | 10 |
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/string_util.h" | 14 #include "base/string_util.h" |
15 #include "chrome/common/win_util.h" | 15 #include "chrome/common/win_util.h" |
16 | 16 |
17 namespace win_util { | 17 namespace win_util { |
18 | 18 |
19 // This is the COM IAttachmentExecute interface definition. | |
20 // In the current Chrome headers it is not present because the _WIN32_IE macro | |
21 // is not set at the XPSP2 or IE60 level. We have placed guards to avoid double | |
22 // declaration in case we change the _WIN32_IE macro. | |
23 #ifndef __IAttachmentExecute_INTERFACE_DEFINED__ | |
24 #define __IAttachmentExecute_INTERFACE_DEFINED__ | |
25 | |
26 typedef | |
27 enum tagATTACHMENT_PROMPT | |
28 { ATTACHMENT_PROMPT_NONE = 0, | |
29 ATTACHMENT_PROMPT_SAVE = 0x1, | |
30 ATTACHMENT_PROMPT_EXEC = 0x2, | |
31 ATTACHMENT_PROMPT_EXEC_OR_SAVE = 0x3 | |
32 } ATTACHMENT_PROMPT; | |
33 | |
34 typedef | |
35 enum tagATTACHMENT_ACTION | |
36 { ATTACHMENT_ACTION_CANCEL = 0, | |
37 ATTACHMENT_ACTION_SAVE = 0x1, | |
38 ATTACHMENT_ACTION_EXEC = 0x2 | |
39 } ATTACHMENT_ACTION; | |
40 | |
41 MIDL_INTERFACE("73db1241-1e85-4581-8e4f-a81e1d0f8c57") | |
42 IAttachmentExecute : public IUnknown | |
43 { | |
44 public: | |
45 virtual HRESULT STDMETHODCALLTYPE SetClientTitle( | |
46 /* [string][in] */ LPCWSTR pszTitle) = 0; | |
47 | |
48 virtual HRESULT STDMETHODCALLTYPE SetClientGuid( | |
49 /* [in] */ REFGUID guid) = 0; | |
50 | |
51 virtual HRESULT STDMETHODCALLTYPE SetLocalPath( | |
52 /* [string][in] */ LPCWSTR pszLocalPath) = 0; | |
53 | |
54 virtual HRESULT STDMETHODCALLTYPE SetFileName( | |
55 /* [string][in] */ LPCWSTR pszFileName) = 0; | |
56 | |
57 virtual HRESULT STDMETHODCALLTYPE SetSource( | |
58 /* [string][in] */ LPCWSTR pszSource) = 0; | |
59 | |
60 virtual HRESULT STDMETHODCALLTYPE SetReferrer( | |
61 /* [string][in] */ LPCWSTR pszReferrer) = 0; | |
62 | |
63 virtual HRESULT STDMETHODCALLTYPE CheckPolicy( void) = 0; | |
64 | |
65 virtual HRESULT STDMETHODCALLTYPE Prompt( | |
66 /* [in] */ HWND hwnd, | |
67 /* [in] */ ATTACHMENT_PROMPT prompt, | |
68 /* [out] */ ATTACHMENT_ACTION *paction) = 0; | |
69 | |
70 virtual HRESULT STDMETHODCALLTYPE Save( void) = 0; | |
71 | |
72 virtual HRESULT STDMETHODCALLTYPE Execute( | |
73 /* [in] */ HWND hwnd, | |
74 /* [string][in] */ LPCWSTR pszVerb, | |
75 HANDLE *phProcess) = 0; | |
76 | |
77 virtual HRESULT STDMETHODCALLTYPE SaveWithUI( | |
78 HWND hwnd) = 0; | |
79 | |
80 virtual HRESULT STDMETHODCALLTYPE ClearClientState( void) = 0; | |
81 | |
82 }; | |
83 | |
84 #endif // __IAttachmentExecute_INTERFACE_DEFINED__ | |
85 | |
86 // This function implementation is based on the attachment execution | 19 // This function implementation is based on the attachment execution |
87 // services functionally deployed with IE6 or Service pack 2. This | 20 // services functionally deployed with IE6 or Service pack 2. This |
88 // functionality is exposed in the IAttachmentExecute COM interface. | 21 // functionality is exposed in the IAttachmentExecute COM interface. |
89 // more information at: | 22 // more information at: |
90 // http://msdn2.microsoft.com/en-us/library/ms647048.aspx | 23 // http://msdn2.microsoft.com/en-us/library/ms647048.aspx |
91 bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, | 24 bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, |
92 const FilePath& full_path, | 25 const FilePath& full_path, |
93 const std::wstring& source_url, | 26 const std::wstring& source_url, |
94 bool ask_for_app) { | 27 bool ask_for_app) { |
95 ATL::CComPtr<IAttachmentExecute> attachment_services; | 28 ATL::CComPtr<IAttachmentExecute> attachment_services; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 if (!result || written != arraysize(kIdentifier)) { | 112 if (!result || written != arraysize(kIdentifier)) { |
180 DCHECK(FALSE); | 113 DCHECK(FALSE); |
181 return false; | 114 return false; |
182 } | 115 } |
183 | 116 |
184 return true; | 117 return true; |
185 } | 118 } |
186 | 119 |
187 } // namespace win_util | 120 } // namespace win_util |
188 | 121 |
OLD | NEW |