| 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> |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // This functionality is only available on Win7+. | 102 // This functionality is only available on Win7+. |
| 103 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 103 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 104 return false; | 104 return false; |
| 105 | 105 |
| 106 base::win::ScopedComPtr<IPropertyStore> pps; | 106 base::win::ScopedComPtr<IPropertyStore> pps; |
| 107 if (FAILED(SHGetPropertyStoreForWindow(hwnd, | 107 if (FAILED(SHGetPropertyStoreForWindow(hwnd, |
| 108 IID_PPV_ARGS(pps.Receive())))) | 108 IID_PPV_ARGS(pps.Receive())))) |
| 109 return false; | 109 return false; |
| 110 | 110 |
| 111 return base::win::SetBooleanValueForPropertyStore( | 111 return base::win::SetBooleanValueForPropertyStore( |
| 112 pps.get(), PKEY_AppUserModel_PreventPinning, true); | 112 pps.Get(), PKEY_AppUserModel_PreventPinning, true); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // TODO(calamity): investigate moving this out of the UI thread as COM | 115 // TODO(calamity): investigate moving this out of the UI thread as COM |
| 116 // operations may spawn nested message loops which can cause issues. | 116 // operations may spawn nested message loops which can cause issues. |
| 117 void SetAppDetailsForWindow(const base::string16& app_id, | 117 void SetAppDetailsForWindow(const base::string16& app_id, |
| 118 const base::FilePath& app_icon_path, | 118 const base::FilePath& app_icon_path, |
| 119 int app_icon_index, | 119 int app_icon_index, |
| 120 const base::string16& relaunch_command, | 120 const base::string16& relaunch_command, |
| 121 const base::string16& relaunch_display_name, | 121 const base::string16& relaunch_display_name, |
| 122 HWND hwnd) { | 122 HWND hwnd) { |
| 123 DCHECK(hwnd); | 123 DCHECK(hwnd); |
| 124 | 124 |
| 125 // This functionality is only available on Win7+. | 125 // This functionality is only available on Win7+. |
| 126 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 126 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 127 return; | 127 return; |
| 128 | 128 |
| 129 base::win::ScopedComPtr<IPropertyStore> pps; | 129 base::win::ScopedComPtr<IPropertyStore> pps; |
| 130 if (FAILED(SHGetPropertyStoreForWindow(hwnd, | 130 if (FAILED(SHGetPropertyStoreForWindow(hwnd, |
| 131 IID_PPV_ARGS(pps.Receive())))) | 131 IID_PPV_ARGS(pps.Receive())))) |
| 132 return; | 132 return; |
| 133 | 133 |
| 134 if (!app_id.empty()) | 134 if (!app_id.empty()) |
| 135 base::win::SetAppIdForPropertyStore(pps.get(), app_id.c_str()); | 135 base::win::SetAppIdForPropertyStore(pps.Get(), app_id.c_str()); |
| 136 if (!app_icon_path.empty()) { | 136 if (!app_icon_path.empty()) { |
| 137 // Always add the icon index explicitly to prevent bad interaction with the | 137 // Always add the icon index explicitly to prevent bad interaction with the |
| 138 // index notation when file path has commas. | 138 // index notation when file path has commas. |
| 139 base::win::SetStringValueForPropertyStore( | 139 base::win::SetStringValueForPropertyStore( |
| 140 pps.get(), PKEY_AppUserModel_RelaunchIconResource, | 140 pps.Get(), PKEY_AppUserModel_RelaunchIconResource, |
| 141 base::StringPrintf(L"%ls,%d", app_icon_path.value().c_str(), | 141 base::StringPrintf(L"%ls,%d", app_icon_path.value().c_str(), |
| 142 app_icon_index) | 142 app_icon_index) |
| 143 .c_str()); | 143 .c_str()); |
| 144 } | 144 } |
| 145 if (!relaunch_command.empty()) { | 145 if (!relaunch_command.empty()) { |
| 146 base::win::SetStringValueForPropertyStore( | 146 base::win::SetStringValueForPropertyStore( |
| 147 pps.get(), PKEY_AppUserModel_RelaunchCommand, | 147 pps.Get(), PKEY_AppUserModel_RelaunchCommand, |
| 148 relaunch_command.c_str()); | 148 relaunch_command.c_str()); |
| 149 } | 149 } |
| 150 if (!relaunch_display_name.empty()) { | 150 if (!relaunch_display_name.empty()) { |
| 151 base::win::SetStringValueForPropertyStore( | 151 base::win::SetStringValueForPropertyStore( |
| 152 pps.get(), PKEY_AppUserModel_RelaunchDisplayNameResource, | 152 pps.Get(), PKEY_AppUserModel_RelaunchDisplayNameResource, |
| 153 relaunch_display_name.c_str()); | 153 relaunch_display_name.c_str()); |
| 154 } | 154 } |
| 155 } | 155 } |
| 156 | 156 |
| 157 void SetAppIdForWindow(const base::string16& app_id, HWND hwnd) { | 157 void SetAppIdForWindow(const base::string16& app_id, HWND hwnd) { |
| 158 SetAppDetailsForWindow(app_id, base::FilePath(), 0, base::string16(), | 158 SetAppDetailsForWindow(app_id, base::FilePath(), 0, base::string16(), |
| 159 base::string16(), hwnd); | 159 base::string16(), hwnd); |
| 160 } | 160 } |
| 161 | 161 |
| 162 void SetAppIconForWindow(const base::FilePath& app_icon_path, | 162 void SetAppIconForWindow(const base::FilePath& app_icon_path, |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // at the same feature level. See bug 426573. | 212 // at the same feature level. See bug 426573. |
| 213 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 213 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
| 214 return false; | 214 return false; |
| 215 // If composition is not enabled, we behave like on XP. | 215 // If composition is not enabled, we behave like on XP. |
| 216 BOOL enabled = FALSE; | 216 BOOL enabled = FALSE; |
| 217 return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; | 217 return SUCCEEDED(DwmIsCompositionEnabled(&enabled)) && enabled; |
| 218 } | 218 } |
| 219 | 219 |
| 220 } // namespace win | 220 } // namespace win |
| 221 } // namespace ui | 221 } // namespace ui |
| OLD | NEW |