Bug 1693008 - show only the origin in web content dialogs when using proton, r=mtigley,fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D108713
This commit is contained in:
Gijs Kruitbosch 2021-03-23 15:02:07 +00:00
parent 4c87898068
commit bd7a32063a
4 changed files with 45 additions and 2 deletions

View File

@ -6,6 +6,9 @@ const { CommonDialog } = ChromeUtils.import(
"resource://gre/modules/CommonDialog.jsm"
);
// imported by adjustableTitle.js loaded in the same context:
/* globals PromptUtils */
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
var propBag, args, Dialog;
@ -30,6 +33,35 @@ function commonDialogOnLoad() {
root.setAttribute("neediconheader", "true");
}
let title = { raw: args.title };
if (PromptUtils.protonModals) {
let { promptPrincipal } = args;
if (promptPrincipal) {
if (promptPrincipal.isNullPrincipal) {
title = { l10nId: "common-dialog-title-null" };
} else if (promptPrincipal.isSystemPrincipal) {
title = { l10nId: "common-dialog-title-system" };
root.style.setProperty(
"--icon-url",
"url('chrome://branding/content/icon32.png')"
);
} else if (promptPrincipal.addonPolicy) {
title.raw = promptPrincipal.addonPolicy.name;
} else if (promptPrincipal.isContentPrincipal) {
try {
title.raw = promptPrincipal.hostPort;
} catch (ex) {
// hostPort getter can throw, e.g. for about URIs.
title.raw = promptPrincipal.origin;
}
// hostPort can be empty for file URIs.
if (!title.raw) {
title.raw = promptPrincipal.prePath;
}
} else {
title = { l10nId: "common-dialog-title-unknown" };
}
}
}
root.setAttribute("headertitle", JSON.stringify(title));
let ui = {

View File

@ -20,6 +20,10 @@
<dialog id="commonDialog"
buttonpack="center">
<linkset>
<html:link rel="localization" href="branding/brand.ftl"/>
<html:link rel="localization" href="toolkit/global/commonDialog.ftl"/>
</linkset>
<script src="chrome://global/content/adjustableTitle.js"/>
<script src="chrome://global/content/commonDialog.js"/>
<script src="chrome://global/content/globalOverlay.js"/>

View File

@ -1123,9 +1123,8 @@ class ModalPrompter {
return args;
}
args.promptPrincipal = this.browsingContext.window?.document.nodePrincipal;
if (IS_CONTENT) {
args.promptPrincipal = this.browsingContext.window?.document.nodePrincipal;
let docShell = this.browsingContext.docShell;
let inPermitUnload = docShell?.contentViewer?.inPermitUnload;
args.inPermitUnload = inPermitUnload;

View File

@ -0,0 +1,8 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
common-dialog-title-null = This page says
common-dialog-title-system = { -brand-short-name }
# Title displayed when the origin of a web dialog is unknown.
common-dialog-title-unknown = Unknown