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(), |
grt (UTC plus 2)
2012/09/20 15:58:31
chromium style suggests wrapping this more densely
robertshield
2012/09/21 01:24:43
suggests -> allows :-) but sure, done.
grt (UTC plus 2)
2012/09/21 01:35:41
true. there seems to be an overall "conserve vert
| |
80 full_path.DirName().value(), | |
81 string16(), | |
82 0); | |
77 } | 83 } |
78 | 84 |
79 bool OpenItemViaShellNoZoneCheck(const FilePath& full_path) { | 85 bool OpenItemViaShellNoZoneCheck(const FilePath& full_path) { |
80 return OpenAnyViaShell(full_path.value(), string16(), | 86 return OpenAnyViaShell(full_path.value(), |
81 SEE_MASK_NOZONECHECKS | SEE_MASK_FLAG_DDEWAIT); | 87 string16(), |
88 string16(), | |
89 SEE_MASK_NOZONECHECKS | SEE_MASK_FLAG_DDEWAIT); | |
82 } | 90 } |
83 | 91 |
84 void SetAppIdForWindow(const string16& app_id, HWND hwnd) { | 92 void SetAppIdForWindow(const string16& app_id, HWND hwnd) { |
85 SetAppIdAndIconForWindow(app_id, string16(), hwnd); | 93 SetAppIdAndIconForWindow(app_id, string16(), hwnd); |
86 } | 94 } |
87 | 95 |
88 void SetAppIconForWindow(const string16& app_icon, HWND hwnd) { | 96 void SetAppIconForWindow(const string16& app_icon, HWND hwnd) { |
89 SetAppIdAndIconForWindow(string16(), app_icon, hwnd); | 97 SetAppIdAndIconForWindow(string16(), app_icon, hwnd); |
90 } | 98 } |
91 | 99 |
92 bool IsAeroGlassEnabled() { | 100 bool IsAeroGlassEnabled() { |
93 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 101 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
94 return false; | 102 return false; |
95 // If composition is not enabled, we behave like on XP. | 103 // If composition is not enabled, we behave like on XP. |
96 BOOL enabled = FALSE; | 104 BOOL enabled = FALSE; |
97 return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; | 105 return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; |
98 } | 106 } |
99 | 107 |
100 } // namespace win | 108 } // namespace win |
101 } // namespace ui | 109 } // namespace ui |
OLD | NEW |