| 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 <shlobj.h> // Must be before propkey. | 8 #include <shlobj.h> // Must be before propkey. |
| 9 #include <propkey.h> | 9 #include <propkey.h> |
| 10 #include <shellapi.h> | 10 #include <shellapi.h> |
| 11 | 11 |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/debug/alias.h" | 13 #include "base/debug/alias.h" |
| 14 #include "base/files/file.h" | 14 #include "base/files/file.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/native_library.h" | 16 #include "base/native_library.h" |
| 17 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 18 #include "base/threading/thread_restrictions.h" | 18 #include "base/threading/thread_restrictions.h" |
| 19 #include "base/win/metro.h" | |
| 20 #include "base/win/scoped_comptr.h" | 19 #include "base/win/scoped_comptr.h" |
| 21 #include "base/win/win_util.h" | 20 #include "base/win/win_util.h" |
| 22 #include "base/win/windows_version.h" | 21 #include "base/win/windows_version.h" |
| 23 #include "ui/base/ui_base_switches.h" | 22 #include "ui/base/ui_base_switches.h" |
| 24 | 23 |
| 25 namespace ui { | 24 namespace ui { |
| 26 namespace win { | 25 namespace win { |
| 27 | 26 |
| 28 namespace { | 27 namespace { |
| 29 | 28 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // resulting error does not cause UI due to the SEE_MASK_FLAG_NO_UI flag in | 91 // resulting error does not cause UI due to the SEE_MASK_FLAG_NO_UI flag in |
| 93 // kDefaultOpenFlags. | 92 // kDefaultOpenFlags. |
| 94 return InvokeShellExecute(full_path.value(), full_path.value(), | 93 return InvokeShellExecute(full_path.value(), full_path.value(), |
| 95 base::string16(), L"explore", | 94 base::string16(), L"explore", |
| 96 kDefaultOpenFlags) == ERROR_SUCCESS; | 95 kDefaultOpenFlags) == ERROR_SUCCESS; |
| 97 } | 96 } |
| 98 | 97 |
| 99 bool PreventWindowFromPinning(HWND hwnd) { | 98 bool PreventWindowFromPinning(HWND hwnd) { |
| 100 DCHECK(hwnd); | 99 DCHECK(hwnd); |
| 101 | 100 |
| 102 // This functionality is only available on Win7+. It also doesn't make sense | 101 // This functionality is only available on Win7+. |
| 103 // to do this for Chrome Metro. | 102 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 104 if (base::win::GetVersion() < base::win::VERSION_WIN7 || | |
| 105 base::win::IsMetroProcess()) | |
| 106 return false; | 103 return false; |
| 107 | 104 |
| 108 base::win::ScopedComPtr<IPropertyStore> pps; | 105 base::win::ScopedComPtr<IPropertyStore> pps; |
| 109 if (FAILED(SHGetPropertyStoreForWindow(hwnd, | 106 if (FAILED(SHGetPropertyStoreForWindow(hwnd, |
| 110 IID_PPV_ARGS(pps.Receive())))) | 107 IID_PPV_ARGS(pps.Receive())))) |
| 111 return false; | 108 return false; |
| 112 | 109 |
| 113 return base::win::SetBooleanValueForPropertyStore( | 110 return base::win::SetBooleanValueForPropertyStore( |
| 114 pps.get(), PKEY_AppUserModel_PreventPinning, true); | 111 pps.get(), PKEY_AppUserModel_PreventPinning, true); |
| 115 } | 112 } |
| 116 | 113 |
| 117 // TODO(calamity): investigate moving this out of the UI thread as COM | 114 // TODO(calamity): investigate moving this out of the UI thread as COM |
| 118 // operations may spawn nested message loops which can cause issues. | 115 // operations may spawn nested message loops which can cause issues. |
| 119 void SetAppDetailsForWindow(const base::string16& app_id, | 116 void SetAppDetailsForWindow(const base::string16& app_id, |
| 120 const base::string16& app_icon, | 117 const base::string16& app_icon, |
| 121 const base::string16& relaunch_command, | 118 const base::string16& relaunch_command, |
| 122 const base::string16& relaunch_display_name, | 119 const base::string16& relaunch_display_name, |
| 123 HWND hwnd) { | 120 HWND hwnd) { |
| 124 DCHECK(hwnd); | 121 DCHECK(hwnd); |
| 125 | 122 |
| 126 // This functionality is only available on Win7+. It also doesn't make sense | 123 // This functionality is only available on Win7+. |
| 127 // to do this for Chrome Metro. | 124 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 128 if (base::win::GetVersion() < base::win::VERSION_WIN7 || | |
| 129 base::win::IsMetroProcess()) | |
| 130 return; | 125 return; |
| 131 | 126 |
| 132 base::win::ScopedComPtr<IPropertyStore> pps; | 127 base::win::ScopedComPtr<IPropertyStore> pps; |
| 133 if (FAILED(SHGetPropertyStoreForWindow(hwnd, | 128 if (FAILED(SHGetPropertyStoreForWindow(hwnd, |
| 134 IID_PPV_ARGS(pps.Receive())))) | 129 IID_PPV_ARGS(pps.Receive())))) |
| 135 return; | 130 return; |
| 136 | 131 |
| 137 if (!app_id.empty()) | 132 if (!app_id.empty()) |
| 138 base::win::SetAppIdForPropertyStore(pps.get(), app_id.c_str()); | 133 base::win::SetAppIdForPropertyStore(pps.get(), app_id.c_str()); |
| 139 if (!app_icon.empty()) { | 134 if (!app_icon.empty()) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 SetAppDetailsForWindow(base::string16(), | 169 SetAppDetailsForWindow(base::string16(), |
| 175 base::string16(), | 170 base::string16(), |
| 176 relaunch_command, | 171 relaunch_command, |
| 177 display_name, | 172 display_name, |
| 178 hwnd); | 173 hwnd); |
| 179 } | 174 } |
| 180 | 175 |
| 181 void ClearWindowPropertyStore(HWND hwnd) { | 176 void ClearWindowPropertyStore(HWND hwnd) { |
| 182 DCHECK(hwnd); | 177 DCHECK(hwnd); |
| 183 | 178 |
| 184 // This functionality is only available on Win7+. It also doesn't make sense | 179 // This functionality is only available on Win7+. |
| 185 // to do this for Chrome Metro. | 180 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 186 if (base::win::GetVersion() < base::win::VERSION_WIN7 || | |
| 187 base::win::IsMetroProcess()) | |
| 188 return; | 181 return; |
| 189 | 182 |
| 190 base::win::ScopedComPtr<IPropertyStore> pps; | 183 base::win::ScopedComPtr<IPropertyStore> pps; |
| 191 if (FAILED(SHGetPropertyStoreForWindow(hwnd, | 184 if (FAILED(SHGetPropertyStoreForWindow(hwnd, |
| 192 IID_PPV_ARGS(pps.Receive())))) | 185 IID_PPV_ARGS(pps.Receive())))) |
| 193 return; | 186 return; |
| 194 | 187 |
| 195 DWORD property_count; | 188 DWORD property_count; |
| 196 if (FAILED(pps->GetCount(&property_count))) | 189 if (FAILED(pps->GetCount(&property_count))) |
| 197 return; | 190 return; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 219 // at the same feature level. See bug 426573. | 212 // at the same feature level. See bug 426573. |
| 220 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 213 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 221 return false; | 214 return false; |
| 222 // If composition is not enabled, we behave like on XP. | 215 // If composition is not enabled, we behave like on XP. |
| 223 BOOL enabled = FALSE; | 216 BOOL enabled = FALSE; |
| 224 return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; | 217 return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; |
| 225 } | 218 } |
| 226 | 219 |
| 227 } // namespace win | 220 } // namespace win |
| 228 } // namespace ui | 221 } // namespace ui |
| OLD | NEW |