Index: chrome/common/win_safe_util.cc |
=================================================================== |
--- chrome/common/win_safe_util.cc (revision 38375) |
+++ chrome/common/win_safe_util.cc (working copy) |
@@ -16,6 +16,12 @@ |
namespace win_util { |
+// This GUID is associated with any 'don't ask me again' settings that the |
+// user can select for different file types. |
+// {2676A9A2-D919-4fee-9187-152100393AB2} |
+static const GUID kClientID = { 0x2676a9a2, 0xd919, 0x4fee, |
+ { 0x91, 0x87, 0x15, 0x21, 0x0, 0x39, 0x3a, 0xb2 } }; |
+ |
// This function implementation is based on the attachment execution |
// services functionally deployed with IE6 or Service pack 2. This |
// functionality is exposed in the IAttachmentExecute COM interface. |
@@ -36,12 +42,6 @@ |
return OpenItemViaShell(full_path); |
} |
- // This GUID is associated with any 'don't ask me again' settings that the |
- // user can select for different file types. |
- // {2676A9A2-D919-4fee-9187-152100393AB2} |
- static const GUID kClientID = { 0x2676a9a2, 0xd919, 0x4fee, |
- { 0x91, 0x87, 0x15, 0x21, 0x0, 0x39, 0x3a, 0xb2 } }; |
- |
attachment_services->SetClientGuid(kClientID); |
if (!window_title.empty()) |
@@ -94,26 +94,35 @@ |
return OpenItemViaShellNoZoneCheck(full_path); |
} |
-bool SetInternetZoneIdentifier(const FilePath& full_path) { |
- const DWORD kShare = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE; |
- std::wstring path = full_path.value() + L":Zone.Identifier"; |
- HANDLE file = CreateFile(path.c_str(), GENERIC_WRITE, kShare, NULL, |
- OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); |
- if (INVALID_HANDLE_VALUE == file) |
+bool SetInternetZoneIdentifier(const FilePath& full_path, |
+ const std::wstring& source_url) { |
+ ScopedComPtr<IAttachmentExecute> attachment_services; |
+ HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); |
+ if (FAILED(hr)) { |
return false; |
+ } |
- const char kIdentifier[] = "[ZoneTransfer]\nZoneId=3"; |
- DWORD written = 0; |
- BOOL result = WriteFile(file, kIdentifier, arraysize(kIdentifier), &written, |
- NULL); |
- BOOL flush_result = FlushFileBuffers(file); |
- CloseHandle(file); |
+ hr = attachment_services->SetClientGuid(kClientID); |
+ if (FAILED(hr)) { |
+ return false; |
+ } |
- if (!result || !flush_result || written != arraysize(kIdentifier)) { |
- NOTREACHED(); |
+ hr = attachment_services->SetLocalPath(full_path.value().c_str()); |
+ if (FAILED(hr)) { |
return false; |
} |
+ // Source is necessary for files ending in ".tmp" to avoid error 0x800c000e. |
+ hr = attachment_services->SetSource(source_url.c_str()); |
+ if (FAILED(hr)) { |
+ return false; |
+ } |
+ |
+ hr = attachment_services->Save(); |
+ if (FAILED(hr)) { |
+ return false; |
+ } |
+ |
return true; |
} |