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 "chrome/common/win_safe_util.h" | 8 #include "chrome/common/win_safe_util.h" |
9 | 9 |
| 10 #include "app/win/shell.h" |
10 #include "base/file_path.h" | 11 #include "base/file_path.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/path_service.h" | 13 #include "base/path_service.h" |
13 #include "base/string_util.h" | 14 #include "base/string_util.h" |
14 #include "base/win/scoped_comptr.h" | 15 #include "base/win/scoped_comptr.h" |
15 #include "ui/base/win/shell.h" | |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 // This GUID is associated with any 'don't ask me again' settings that the | 19 // This GUID is associated with any 'don't ask me again' settings that the |
20 // user can select for different file types. | 20 // user can select for different file types. |
21 // {2676A9A2-D919-4fee-9187-152100393AB2} | 21 // {2676A9A2-D919-4fee-9187-152100393AB2} |
22 static const GUID kClientID = { 0x2676a9a2, 0xd919, 0x4fee, | 22 static const GUID kClientID = { 0x2676a9a2, 0xd919, 0x4fee, |
23 { 0x91, 0x87, 0x15, 0x21, 0x0, 0x39, 0x3a, 0xb2 } }; | 23 { 0x91, 0x87, 0x15, 0x21, 0x0, 0x39, 0x3a, 0xb2 } }; |
24 | 24 |
25 // Directly writes the ZoneIdentifier stream, without using the | 25 // Directly writes the ZoneIdentifier stream, without using the |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 const std::wstring& source_url) { | 63 const std::wstring& source_url) { |
64 base::win::ScopedComPtr<IAttachmentExecute> attachment_services; | 64 base::win::ScopedComPtr<IAttachmentExecute> attachment_services; |
65 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); | 65 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); |
66 if (FAILED(hr)) { | 66 if (FAILED(hr)) { |
67 // We don't have Attachment Execution Services, it must be a pre-XP.SP2 | 67 // We don't have Attachment Execution Services, it must be a pre-XP.SP2 |
68 // Windows installation, or the thread does not have COM initialized. | 68 // Windows installation, or the thread does not have COM initialized. |
69 if (hr == CO_E_NOTINITIALIZED) { | 69 if (hr == CO_E_NOTINITIALIZED) { |
70 NOTREACHED(); | 70 NOTREACHED(); |
71 return false; | 71 return false; |
72 } | 72 } |
73 return ui::win::OpenItemViaShell(full_path); | 73 return app::win::OpenItemViaShell(full_path); |
74 } | 74 } |
75 | 75 |
76 attachment_services->SetClientGuid(kClientID); | 76 attachment_services->SetClientGuid(kClientID); |
77 | 77 |
78 if (!window_title.empty()) | 78 if (!window_title.empty()) |
79 attachment_services->SetClientTitle(window_title.c_str()); | 79 attachment_services->SetClientTitle(window_title.c_str()); |
80 | 80 |
81 // To help windows decide if the downloaded file is dangerous we can provide | 81 // To help windows decide if the downloaded file is dangerous we can provide |
82 // what the documentation calls evidence. Which we provide now: | 82 // what the documentation calls evidence. Which we provide now: |
83 // | 83 // |
(...skipping 21 matching lines...) Expand all Loading... |
105 ATTACHMENT_ACTION action; | 105 ATTACHMENT_ACTION action; |
106 // We cannot control what the prompt says or does directly but it | 106 // We cannot control what the prompt says or does directly but it |
107 // is a pretty decent dialog; for example, if an executable is signed it can | 107 // is a pretty decent dialog; for example, if an executable is signed it can |
108 // decode and show the publisher and the certificate. | 108 // decode and show the publisher and the certificate. |
109 hr = attachment_services->Prompt(hwnd, ATTACHMENT_PROMPT_EXEC, &action); | 109 hr = attachment_services->Prompt(hwnd, ATTACHMENT_PROMPT_EXEC, &action); |
110 if (FAILED(hr) || (ATTACHMENT_ACTION_CANCEL == action)) { | 110 if (FAILED(hr) || (ATTACHMENT_ACTION_CANCEL == action)) { |
111 // The user has declined opening the item. | 111 // The user has declined opening the item. |
112 return false; | 112 return false; |
113 } | 113 } |
114 } | 114 } |
115 return ui::win::OpenItemViaShellNoZoneCheck(full_path); | 115 return app::win::OpenItemViaShellNoZoneCheck(full_path); |
116 } | 116 } |
117 | 117 |
118 bool SetInternetZoneIdentifier(const FilePath& full_path, | 118 bool SetInternetZoneIdentifier(const FilePath& full_path, |
119 const std::wstring& source_url) { | 119 const std::wstring& source_url) { |
120 base::win::ScopedComPtr<IAttachmentExecute> attachment_services; | 120 base::win::ScopedComPtr<IAttachmentExecute> attachment_services; |
121 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); | 121 HRESULT hr = attachment_services.CreateInstance(CLSID_AttachmentServices); |
122 | 122 |
123 if (FAILED(hr)) { | 123 if (FAILED(hr)) { |
124 // We don't have Attachment Execution Services, it must be a pre-XP.SP2 | 124 // We don't have Attachment Execution Services, it must be a pre-XP.SP2 |
125 // Windows installation, or the thread does not have COM initialized. | 125 // Windows installation, or the thread does not have COM initialized. |
(...skipping 20 matching lines...) Expand all Loading... |
146 return false; | 146 return false; |
147 | 147 |
148 hr = attachment_services->Save(); | 148 hr = attachment_services->Save(); |
149 if (FAILED(hr)) | 149 if (FAILED(hr)) |
150 return false; | 150 return false; |
151 | 151 |
152 return true; | 152 return true; |
153 } | 153 } |
154 | 154 |
155 } // namespace win_util | 155 } // namespace win_util |
OLD | NEW |