| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_COMMON_WIN_SAFE_UTIL_H__ | 5 #ifndef CHROME_COMMON_WIN_SAFE_UTIL_H__ |
| 6 #define CHROME_COMMON_WIN_SAFE_UTIL_H__ | 6 #define CHROME_COMMON_WIN_SAFE_UTIL_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <windows.h> | 9 #include <windows.h> |
| 10 | 10 |
| 11 class FilePath; |
| 12 |
| 11 namespace win_util { | 13 namespace win_util { |
| 12 | 14 |
| 13 // Open or run a downloaded file via the Windows shell, possibly showing first | 15 // Open or run a downloaded file via the Windows shell, possibly showing first |
| 14 // a consent dialog if the the file is deemed dangerous. This function is an | 16 // a consent dialog if the the file is deemed dangerous. This function is an |
| 15 // enhancement over the OpenItemViaShell() function of win_util.h. | 17 // enhancement over the OpenItemViaShell() function of win_util.h. |
| 16 // | 18 // |
| 17 // The user consent dialog will be shown or not according to the windows | 19 // The user consent dialog will be shown or not according to the windows |
| 18 // execution policy defined in the registry which can be overridden per user. | 20 // execution policy defined in the registry which can be overridden per user. |
| 19 // The mechanics of the policy are explained in the Microsoft Knowledge base | 21 // The mechanics of the policy are explained in the Microsoft Knowledge base |
| 20 // number 883260: http://support.microsoft.com/kb/883260 | 22 // number 883260: http://support.microsoft.com/kb/883260 |
| 21 // | 23 // |
| 22 // The 'hwnd' is the handle to the parent window. In case a dialog is displayed | 24 // The 'hwnd' is the handle to the parent window. In case a dialog is displayed |
| 23 // the parent window will be disabled since the dialog is meant to be modal. | 25 // the parent window will be disabled since the dialog is meant to be modal. |
| 24 // The 'window_title' is the text displayed on the title bar of the dialog. If | 26 // The 'window_title' is the text displayed on the title bar of the dialog. If |
| 25 // you pass an empty string the dialog will have a generic 'windows security' | 27 // you pass an empty string the dialog will have a generic 'windows security' |
| 26 // name on the title bar. | 28 // name on the title bar. |
| 27 // | 29 // |
| 28 // You must provide a valid 'full_path' to the file to be opened and a well | 30 // You must provide a valid 'full_path' to the file to be opened and a well |
| 29 // formed url in 'source_url'. The url should identify the source of the file | 31 // formed url in 'source_url'. The url should identify the source of the file |
| 30 // but does not have to be network-reachable. If the url is malformed a | 32 // but does not have to be network-reachable. If the url is malformed a |
| 31 // dialog will be shown telling the user that the file will be blocked. | 33 // dialog will be shown telling the user that the file will be blocked. |
| 32 // | 34 // |
| 33 // In the event that there is no default application registered for the file | 35 // In the event that there is no default application registered for the file |
| 34 // specified by 'full_path' it ask the user, via the Windows "Open With" | 36 // specified by 'full_path' it ask the user, via the Windows "Open With" |
| 35 // dialog, for an application to use if 'ask_for_app' is true. | 37 // dialog, for an application to use if 'ask_for_app' is true. |
| 36 // Returns 'true' on successful open, 'false' otherwise. | 38 // Returns 'true' on successful open, 'false' otherwise. |
| 37 bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, | 39 bool SaferOpenItemViaShell(HWND hwnd, const std::wstring& window_title, |
| 38 const std::wstring& full_path, | 40 const FilePath& full_path, |
| 39 const std::wstring& source_url, bool ask_for_app); | 41 const std::wstring& source_url, bool ask_for_app); |
| 40 | 42 |
| 41 // Sets the Zone Identifier on the file to "Internet" (3). Returns true if the | 43 // Sets the Zone Identifier on the file to "Internet" (3). Returns true if the |
| 42 // function succeeds, false otherwise. A failure is expected on system where | 44 // function succeeds, false otherwise. A failure is expected on system where |
| 43 // the Zone Identifier is not supported, like a machine with a FAT32 filesystem. | 45 // the Zone Identifier is not supported, like a machine with a FAT32 filesystem. |
| 44 // It should not be considered fatal. | 46 // It should not be considered fatal. |
| 45 bool SetInternetZoneIdentifier(const std::wstring& full_path); | 47 bool SetInternetZoneIdentifier(const FilePath& full_path); |
| 46 | 48 |
| 47 } // namespace win_util | 49 } // namespace win_util |
| 48 | 50 |
| 49 #endif // CHROME_COMMON_WIN_SAFE_UTIL_H__ | 51 #endif // CHROME_COMMON_WIN_SAFE_UTIL_H__ |
| 50 | 52 |
| OLD | NEW |