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

Unified Diff: chrome/common/win_safe_util.cc

Issue 590001: Respect the SaveZoneInformation policy when marking downloaded files as unsaf... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/win_safe_util.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « chrome/common/win_safe_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698