| 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 "ui/base/win/shell.h" | 5 #include "ui/base/win/shell.h" |
| 6 | 6 |
| 7 #include <shellapi.h> | 7 #include <shellapi.h> |
| 8 #include <shlobj.h> // Must be before propkey. | 8 #include <shlobj.h> // Must be before propkey. |
| 9 #include <propkey.h> | 9 #include <propkey.h> |
| 10 | 10 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 } | 70 } |
| 71 | 71 |
| 72 // Cleanup. | 72 // Cleanup. |
| 73 base::UnloadNativeLibrary(shell32_library); | 73 base::UnloadNativeLibrary(shell32_library); |
| 74 } | 74 } |
| 75 | 75 |
| 76 } // namespace | 76 } // namespace |
| 77 | 77 |
| 78 // Open an item via a shell execute command. Error code checking and casting | 78 // Open an item via a shell execute command. Error code checking and casting |
| 79 // explanation: http://msdn2.microsoft.com/en-us/library/ms647732.aspx | 79 // explanation: http://msdn2.microsoft.com/en-us/library/ms647732.aspx |
| 80 bool OpenItemViaShell(const FilePath& full_path) { | 80 bool OpenItemViaShell(const FilePath& full_path, |
| 81 HINSTANCE h = ::ShellExecuteW( | 81 base::ProcessHandle* process_handle) { |
| 82 NULL, NULL, full_path.value().c_str(), NULL, | 82 SHELLEXECUTEINFO sei = { sizeof(sei) }; |
| 83 full_path.DirName().value().c_str(), SW_SHOWNORMAL); | 83 if (process_handle) |
| 84 | 84 sei.fMask = SEE_MASK_NOCLOSEPROCESS; |
| 85 LONG_PTR error = reinterpret_cast<LONG_PTR>(h); | 85 sei.nShow = SW_SHOWNORMAL; |
| 86 if (error > 32) | 86 sei.lpVerb = NULL; |
| 87 sei.lpFile = full_path.value().c_str(); |
| 88 sei.lpDirectory = full_path.DirName().value().c_str(); |
| 89 if (::ShellExecuteExW(&sei)) { |
| 90 process_handle = sei.hProcess; |
| 87 return true; | 91 return true; |
| 88 | 92 } |
| 93 LONG_PTR error = reinterpret_cast<LONG_PTR>(sei.hInstApp); |
| 89 if ((error == SE_ERR_NOASSOC)) | 94 if ((error == SE_ERR_NOASSOC)) |
| 90 return OpenItemWithExternalApp(full_path.value()); | 95 return OpenItemWithExternalApp(full_path.value()); |
| 91 | |
| 92 return false; | 96 return false; |
| 93 } | 97 } |
| 94 | 98 |
| 95 bool OpenItemViaShellNoZoneCheck(const FilePath& full_path) { | 99 bool OpenItemViaShellNoZoneCheck(const FilePath& full_path) { |
| 96 SHELLEXECUTEINFO sei = { sizeof(sei) }; | 100 SHELLEXECUTEINFO sei = { sizeof(sei) }; |
| 97 sei.fMask = SEE_MASK_NOZONECHECKS | SEE_MASK_FLAG_DDEWAIT; | 101 sei.fMask = SEE_MASK_NOZONECHECKS | SEE_MASK_FLAG_DDEWAIT; |
| 98 sei.nShow = SW_SHOWNORMAL; | 102 sei.nShow = SW_SHOWNORMAL; |
| 99 sei.lpVerb = NULL; | 103 sei.lpVerb = NULL; |
| 100 sei.lpFile = full_path.value().c_str(); | 104 sei.lpFile = full_path.value().c_str(); |
| 101 if (::ShellExecuteExW(&sei)) | 105 if (::ShellExecuteExW(&sei)) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 120 void SetAppIdForWindow(const string16& app_id, HWND hwnd) { | 124 void SetAppIdForWindow(const string16& app_id, HWND hwnd) { |
| 121 SetAppIdAndIconForWindow(app_id, string16(), hwnd); | 125 SetAppIdAndIconForWindow(app_id, string16(), hwnd); |
| 122 } | 126 } |
| 123 | 127 |
| 124 void SetAppIconForWindow(const string16& app_icon, HWND hwnd) { | 128 void SetAppIconForWindow(const string16& app_icon, HWND hwnd) { |
| 125 SetAppIdAndIconForWindow(string16(), app_icon, hwnd); | 129 SetAppIdAndIconForWindow(string16(), app_icon, hwnd); |
| 126 } | 130 } |
| 127 | 131 |
| 128 } // namespace win | 132 } // namespace win |
| 129 } // namespace ui | 133 } // namespace ui |
| OLD | NEW |