OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <dwmapi.h> | 7 #include <dwmapi.h> |
8 #include <shellapi.h> | 8 #include <shellapi.h> |
9 #include <shlobj.h> // Must be before propkey. | 9 #include <shlobj.h> // Must be before propkey. |
10 #include <propkey.h> | 10 #include <propkey.h> |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 SHELLEXECUTEINFO sei = { sizeof(sei) }; | 51 SHELLEXECUTEINFO sei = { sizeof(sei) }; |
52 sei.fMask = SEE_MASK_FLAG_DDEWAIT; | 52 sei.fMask = SEE_MASK_FLAG_DDEWAIT; |
53 sei.nShow = SW_SHOWNORMAL; | 53 sei.nShow = SW_SHOWNORMAL; |
54 sei.lpVerb = L"openas"; | 54 sei.lpVerb = L"openas"; |
55 sei.lpFile = full_path.c_str(); | 55 sei.lpFile = full_path.c_str(); |
56 return (TRUE == ::ShellExecuteExW(&sei)); | 56 return (TRUE == ::ShellExecuteExW(&sei)); |
57 } | 57 } |
58 | 58 |
59 bool OpenAnyViaShell(const string16& full_path, | 59 bool OpenAnyViaShell(const string16& full_path, |
60 const string16& directory, | 60 const string16& directory, |
| 61 const string16& args, |
61 DWORD mask) { | 62 DWORD mask) { |
62 SHELLEXECUTEINFO sei = { sizeof(sei) }; | 63 SHELLEXECUTEINFO sei = { sizeof(sei) }; |
63 sei.fMask = mask; | 64 sei.fMask = mask; |
64 sei.nShow = SW_SHOWNORMAL; | 65 sei.nShow = SW_SHOWNORMAL; |
65 sei.lpFile = full_path.c_str(); | 66 sei.lpFile = full_path.c_str(); |
66 sei.lpDirectory = directory.c_str(); | 67 sei.lpDirectory = directory.c_str(); |
| 68 if (!args.empty()) |
| 69 sei.lpParameters = args.c_str(); |
67 | 70 |
68 if (::ShellExecuteExW(&sei)) | 71 if (::ShellExecuteExW(&sei)) |
69 return true; | 72 return true; |
70 if (::GetLastError() == ERROR_NO_ASSOCIATION) | 73 if (::GetLastError() == ERROR_NO_ASSOCIATION) |
71 return OpenItemWithExternalApp(full_path); | 74 return OpenItemWithExternalApp(full_path); |
72 return false; | 75 return false; |
73 } | 76 } |
74 | 77 |
75 bool OpenItemViaShell(const FilePath& full_path) { | 78 bool OpenItemViaShell(const FilePath& full_path) { |
76 return OpenAnyViaShell(full_path.value(), full_path.DirName().value(), 0); | 79 return OpenAnyViaShell(full_path.value(), full_path.DirName().value(), |
| 80 string16(), 0); |
77 } | 81 } |
78 | 82 |
79 bool OpenItemViaShellNoZoneCheck(const FilePath& full_path) { | 83 bool OpenItemViaShellNoZoneCheck(const FilePath& full_path) { |
80 return OpenAnyViaShell(full_path.value(), string16(), | 84 return OpenAnyViaShell(full_path.value(), string16(), string16(), |
81 SEE_MASK_NOZONECHECKS | SEE_MASK_FLAG_DDEWAIT); | 85 SEE_MASK_NOZONECHECKS | SEE_MASK_FLAG_DDEWAIT); |
82 } | 86 } |
83 | 87 |
84 void SetAppIdForWindow(const string16& app_id, HWND hwnd) { | 88 void SetAppIdForWindow(const string16& app_id, HWND hwnd) { |
85 SetAppIdAndIconForWindow(app_id, string16(), hwnd); | 89 SetAppIdAndIconForWindow(app_id, string16(), hwnd); |
86 } | 90 } |
87 | 91 |
88 void SetAppIconForWindow(const string16& app_icon, HWND hwnd) { | 92 void SetAppIconForWindow(const string16& app_icon, HWND hwnd) { |
89 SetAppIdAndIconForWindow(string16(), app_icon, hwnd); | 93 SetAppIdAndIconForWindow(string16(), app_icon, hwnd); |
90 } | 94 } |
91 | 95 |
92 bool IsAeroGlassEnabled() { | 96 bool IsAeroGlassEnabled() { |
93 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 97 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
94 return false; | 98 return false; |
95 // If composition is not enabled, we behave like on XP. | 99 // If composition is not enabled, we behave like on XP. |
96 BOOL enabled = FALSE; | 100 BOOL enabled = FALSE; |
97 return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; | 101 return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; |
98 } | 102 } |
99 | 103 |
100 } // namespace win | 104 } // namespace win |
101 } // namespace ui | 105 } // namespace ui |
OLD | NEW |