OLD | NEW |
1 // Copyright (c) 2011 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 "content/browser/safe_util_win.h" | 8 #include "content/browser/safe_util_win.h" |
9 | 9 |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "base/win/scoped_comptr.h" | 15 #include "base/win/scoped_comptr.h" |
16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
17 #include "ui/base/win/shell.h" | 17 #include "ui/base/win/shell.h" |
18 | 18 |
| 19 namespace content { |
19 namespace { | 20 namespace { |
20 | 21 |
21 // This GUID is associated with any 'don't ask me again' settings that the | 22 // This GUID is associated with any 'don't ask me again' settings that the |
22 // user can select for different file types. | 23 // user can select for different file types. |
23 // {2676A9A2-D919-4fee-9187-152100393AB2} | 24 // {2676A9A2-D919-4fee-9187-152100393AB2} |
24 static const GUID kClientID = { 0x2676a9a2, 0xd919, 0x4fee, | 25 static const GUID kClientID = { 0x2676a9a2, 0xd919, 0x4fee, |
25 { 0x91, 0x87, 0x15, 0x21, 0x0, 0x39, 0x3a, 0xb2 } }; | 26 { 0x91, 0x87, 0x15, 0x21, 0x0, 0x39, 0x3a, 0xb2 } }; |
26 | 27 |
27 // Sets the Zone Identifier on the file to "Internet" (3). Returns true if the | 28 // Sets the Zone Identifier on the file to "Internet" (3). Returns true if the |
28 // function succeeds, false otherwise. A failure is expected on system where | 29 // function succeeds, false otherwise. A failure is expected on system where |
(...skipping 20 matching lines...) Expand all Loading... |
49 if (!result || !flush_result || written != kIdentifierSize) { | 50 if (!result || !flush_result || written != kIdentifierSize) { |
50 NOTREACHED(); | 51 NOTREACHED(); |
51 return false; | 52 return false; |
52 } | 53 } |
53 | 54 |
54 return true; | 55 return true; |
55 } | 56 } |
56 | 57 |
57 } | 58 } |
58 | 59 |
59 namespace win_util { | |
60 | |
61 // This function implementation is based on the attachment execution | 60 // This function implementation is based on the attachment execution |
62 // services functionally deployed with IE6 or Service pack 2. This | 61 // services functionally deployed with IE6 or Service pack 2. This |
63 // functionality is exposed in the IAttachmentExecute COM interface. | 62 // functionality is exposed in the IAttachmentExecute COM interface. |
64 // more information at: | 63 // more information at: |
65 // http://msdn2.microsoft.com/en-us/library/ms647048.aspx | 64 // http://msdn2.microsoft.com/en-us/library/ms647048.aspx |
66 bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, | 65 bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, |
67 const FilePath& full_path, | 66 const FilePath& full_path, |
68 const std::wstring& source_url) { | 67 const std::wstring& source_url) { |
69 base::win::ScopedComPtr<IAttachmentExecute> attachment_services; | 68 base::win::ScopedComPtr<IAttachmentExecute> attachment_services; |
70 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); | 69 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 145 |
147 hr = attachment_services->SetSource(UTF8ToWide(source_url.spec()).c_str()); | 146 hr = attachment_services->SetSource(UTF8ToWide(source_url.spec()).c_str()); |
148 if (FAILED(hr)) | 147 if (FAILED(hr)) |
149 return hr; | 148 return hr; |
150 | 149 |
151 // A failure in the Save() call below could result in the downloaded file | 150 // A failure in the Save() call below could result in the downloaded file |
152 // being deleted. | 151 // being deleted. |
153 return attachment_services->Save(); | 152 return attachment_services->Save(); |
154 } | 153 } |
155 | 154 |
156 } // namespace win_util | 155 } // namespace content |
OLD | NEW |