Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: content/browser/safe_util_win.cc

Issue 12213066: Use base namespace for FilePath in content/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
(...skipping 13 matching lines...) Expand all
24 // {2676A9A2-D919-4fee-9187-152100393AB2} 24 // {2676A9A2-D919-4fee-9187-152100393AB2}
25 static const GUID kClientID = { 0x2676a9a2, 0xd919, 0x4fee, 25 static const GUID kClientID = { 0x2676a9a2, 0xd919, 0x4fee,
26 { 0x91, 0x87, 0x15, 0x21, 0x0, 0x39, 0x3a, 0xb2 } }; 26 { 0x91, 0x87, 0x15, 0x21, 0x0, 0x39, 0x3a, 0xb2 } };
27 27
28 // 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
29 // function succeeds, false otherwise. A failure is expected on system where 29 // function succeeds, false otherwise. A failure is expected on system where
30 // the Zone Identifier is not supported, like a machine with a FAT32 filesystem. 30 // the Zone Identifier is not supported, like a machine with a FAT32 filesystem.
31 // This function does not invoke Windows Attachment Execution Services. 31 // This function does not invoke Windows Attachment Execution Services.
32 // 32 //
33 // |full_path| is the path to the downloaded file. 33 // |full_path| is the path to the downloaded file.
34 bool SetInternetZoneIdentifierDirectly(const FilePath& full_path) { 34 bool SetInternetZoneIdentifierDirectly(const base::FilePath& full_path) {
35 const DWORD kShare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; 35 const DWORD kShare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
36 std::wstring path = full_path.value() + L":Zone.Identifier"; 36 std::wstring path = full_path.value() + L":Zone.Identifier";
37 HANDLE file = CreateFile(path.c_str(), GENERIC_WRITE, kShare, NULL, 37 HANDLE file = CreateFile(path.c_str(), GENERIC_WRITE, kShare, NULL,
38 OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); 38 OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
39 if (INVALID_HANDLE_VALUE == file) 39 if (INVALID_HANDLE_VALUE == file)
40 return false; 40 return false;
41 41
42 static const char kIdentifier[] = "[ZoneTransfer]\r\nZoneId=3\r\n"; 42 static const char kIdentifier[] = "[ZoneTransfer]\r\nZoneId=3\r\n";
43 // Don't include trailing null in data written. 43 // Don't include trailing null in data written.
44 static const DWORD kIdentifierSize = arraysize(kIdentifier) - 1; 44 static const DWORD kIdentifierSize = arraysize(kIdentifier) - 1;
(...skipping 11 matching lines...) Expand all
56 } 56 }
57 57
58 } 58 }
59 59
60 // This function implementation is based on the attachment execution 60 // This function implementation is based on the attachment execution
61 // services functionally deployed with IE6 or Service pack 2. This 61 // services functionally deployed with IE6 or Service pack 2. This
62 // functionality is exposed in the IAttachmentExecute COM interface. 62 // functionality is exposed in the IAttachmentExecute COM interface.
63 // more information at: 63 // more information at:
64 // http://msdn2.microsoft.com/en-us/library/ms647048.aspx 64 // http://msdn2.microsoft.com/en-us/library/ms647048.aspx
65 bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, 65 bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title,
66 const FilePath& full_path, 66 const base::FilePath& full_path,
67 const std::wstring& source_url) { 67 const std::wstring& source_url) {
68 base::win::ScopedComPtr<IAttachmentExecute> attachment_services; 68 base::win::ScopedComPtr<IAttachmentExecute> attachment_services;
69 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); 69 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices);
70 if (FAILED(hr)) { 70 if (FAILED(hr)) {
71 // We don't have Attachment Execution Services, it must be a pre-XP.SP2 71 // We don't have Attachment Execution Services, it must be a pre-XP.SP2
72 // Windows installation, or the thread does not have COM initialized. 72 // Windows installation, or the thread does not have COM initialized.
73 if (hr == CO_E_NOTINITIALIZED) { 73 if (hr == CO_E_NOTINITIALIZED) {
74 NOTREACHED(); 74 NOTREACHED();
75 return false; 75 return false;
76 } 76 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // decode and show the publisher and the certificate. 112 // decode and show the publisher and the certificate.
113 hr = attachment_services->Prompt(hwnd, ATTACHMENT_PROMPT_EXEC, &action); 113 hr = attachment_services->Prompt(hwnd, ATTACHMENT_PROMPT_EXEC, &action);
114 if (FAILED(hr) || (ATTACHMENT_ACTION_CANCEL == action)) { 114 if (FAILED(hr) || (ATTACHMENT_ACTION_CANCEL == action)) {
115 // The user has declined opening the item. 115 // The user has declined opening the item.
116 return false; 116 return false;
117 } 117 }
118 } 118 }
119 return ui::win::OpenItemViaShellNoZoneCheck(full_path); 119 return ui::win::OpenItemViaShellNoZoneCheck(full_path);
120 } 120 }
121 121
122 HRESULT ScanAndSaveDownloadedFile(const FilePath& full_path, 122 HRESULT ScanAndSaveDownloadedFile(const base::FilePath& full_path,
123 const GURL& source_url) { 123 const GURL& source_url) {
124 base::win::ScopedComPtr<IAttachmentExecute> attachment_services; 124 base::win::ScopedComPtr<IAttachmentExecute> attachment_services;
125 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); 125 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices);
126 126
127 if (FAILED(hr)) { 127 if (FAILED(hr)) {
128 // The thread must have COM initialized. 128 // The thread must have COM initialized.
129 DCHECK_NE(CO_E_NOTINITIALIZED, hr); 129 DCHECK_NE(CO_E_NOTINITIALIZED, hr);
130 130
131 // We don't have Attachment Execution Services, it must be a pre-XP.SP2 131 // We don't have Attachment Execution Services, it must be a pre-XP.SP2
132 // Windows installation, or the thread does not have COM initialized. Try to 132 // Windows installation, or the thread does not have COM initialized. Try to
(...skipping 13 matching lines...) Expand all
146 hr = attachment_services->SetSource(UTF8ToWide(source_url.spec()).c_str()); 146 hr = attachment_services->SetSource(UTF8ToWide(source_url.spec()).c_str());
147 if (FAILED(hr)) 147 if (FAILED(hr))
148 return hr; 148 return hr;
149 149
150 // 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
151 // being deleted. 151 // being deleted.
152 return attachment_services->Save(); 152 return attachment_services->Save();
153 } 153 }
154 154
155 } // namespace content 155 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_browsertest.cc ('k') | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698