Bug 1887868 - Only set Jump List App ID if the backend is available. r=win-reviewers,handyman

This also fixes an issue where we'd calculate the same App ID for normal
and private browsing windows if taskbar.grouping.useprofile was set to
true.

Differential Revision: https://phabricator.services.mozilla.com/D205721
This commit is contained in:
Mike Conley 2024-03-27 17:26:53 +00:00
parent 3098fb46bc
commit 1f9b0577b6
3 changed files with 14 additions and 5 deletions

View File

@ -176,8 +176,9 @@ JumpListBuilder::JumpListBuilder(const nsAString& aAppUserModelId,
// the app, as it is set in the package manifest instead.
if (!mozilla::widget::WinUtils::HasPackageIdentity()) {
mIOThread->Dispatch(
NewRunnableMethod<nsString>(
"SetAppID", this, &JumpListBuilder::DoSetAppID, aAppUserModelId),
NewRunnableMethod<nsString>("SetAppID", this,
&JumpListBuilder::DoSetAppIDIfAvailable,
aAppUserModelId),
NS_DISPATCH_NORMAL);
}
}
@ -203,10 +204,13 @@ void JumpListBuilder::DoShutdownBackend() {
mJumpListBackend = nullptr;
}
void JumpListBuilder::DoSetAppID(nsString aAppUserModelID) {
void JumpListBuilder::DoSetAppIDIfAvailable(nsString aAppUserModelID) {
MOZ_ASSERT(!NS_IsMainThread());
MOZ_ASSERT(mJumpListBackend);
mJumpListBackend->SetAppID(aAppUserModelID.get());
if (mJumpListBackend->IsAvailable()) {
mJumpListBackend->SetAppID(aAppUserModelID.get());
}
}
NS_IMETHODIMP

View File

@ -64,7 +64,7 @@ class JumpListBuilder : public nsIJumpListBuilder, public nsIObserver {
void DoSetupBackend();
void DoSetupTestingBackend(RefPtr<JumpListBackend> aTestingBackend);
void DoShutdownBackend();
void DoSetAppID(nsString aAppUserModelID);
void DoSetAppIDIfAvailable(nsString aAppUserModelID);
void DoIsAvailable(const nsMainThreadPtrHandle<dom::Promise>& aPromiseHolder);
void DoCheckForRemovals(
const nsMainThreadPtrHandle<dom::Promise>& aPromiseHolder);

View File

@ -223,6 +223,11 @@ bool WinTaskbar::GenerateAppUserModelID(nsAString& aAppUserModelId,
id.AppendInt(HashString(path));
if (!id.IsEmpty()) {
aAppUserModelId.Assign(id);
if (aPrivateBrowsing) {
aAppUserModelId.AppendLiteral(";PrivateBrowsingAUMID");
}
return true;
}
}