Bug 1602195: Show site specific browsers as separate taskbar entries on windows. r=mhowell

Gives a site specific browser window a custom model ID and adds the same model
ID to its shortcut. This makes the window appear distinct from the rest of
Firefox's windows in the taskbar and allows for pinning the new entry to the
taskbar.

Differential Revision: https://phabricator.services.mozilla.com/D56780
This commit is contained in:
Dave Townsend
2019-12-18 22:01:40 +00:00
parent 9487a03add
commit eb784a9ee1
4 changed files with 46 additions and 2 deletions

View File

@@ -29,6 +29,8 @@
#include "windows.h"
#include "shellapi.h"
#include <propvarutil.h>
#include <propkey.h>
#ifdef _WIN32_WINNT
# undef _WIN32_WINNT
@@ -701,7 +703,9 @@ NS_IMETHODIMP
nsWindowsShellService::CreateShortcut(nsIFile* aBinary,
const nsTArray<nsString>& aArguments,
const nsAString& aDescription,
nsIFile* aIconFile, nsIFile* aTarget) {
nsIFile* aIconFile,
const nsAString& aAppUserModelId,
nsIFile* aTarget) {
NS_ENSURE_ARG(aBinary);
NS_ENSURE_ARG(aTarget);
@@ -730,6 +734,25 @@ nsWindowsShellService::CreateShortcut(nsIFile* aBinary,
link->SetIconLocation(icon.get(), 0);
}
if (!aAppUserModelId.IsEmpty()) {
RefPtr<IPropertyStore> propStore;
hr = link->QueryInterface(IID_IPropertyStore, getter_AddRefs(propStore));
NS_ENSURE_HRESULT(hr, NS_ERROR_FAILURE);
PROPVARIANT pv;
if (FAILED(InitPropVariantFromString(
PromiseFlatString(aAppUserModelId).get(), &pv))) {
return NS_ERROR_FAILURE;
}
hr = propStore->SetValue(PKEY_AppUserModel_ID, pv);
PropVariantClear(&pv);
NS_ENSURE_HRESULT(hr, NS_ERROR_FAILURE);
hr = propStore->Commit();
NS_ENSURE_HRESULT(hr, NS_ERROR_FAILURE);
}
RefPtr<IPersistFile> persist;
hr = link->QueryInterface(IID_IPersistFile, getter_AddRefs(persist));
NS_ENSURE_HRESULT(hr, NS_ERROR_FAILURE);