Issue #303 Part 1: Move basilisk files from /browser to /application/basilisk

This commit is contained in:
wolfbeast 2018-06-04 13:17:38 +02:00 committed by Roy Tam
commit 177b28a898
1938 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,32 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* 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/. */
function initFeedTab(feeds)
{
for (let feed of feeds) {
let [name, type, url] = feed;
addRow(name, type, url);
}
var feedListbox = document.getElementById("feedListbox");
document.getElementById("feedTab").hidden = feedListbox.getRowCount() == 0;
}
function onSubscribeFeed()
{
var listbox = document.getElementById("feedListbox");
openUILinkIn(listbox.selectedItem.getAttribute("feedURL"), "current",
{ ignoreAlt: true });
}
function addRow(name, type, url)
{
var item = document.createElement("richlistitem");
item.setAttribute("feed", "true");
item.setAttribute("name", name);
item.setAttribute("type", type);
item.setAttribute("feedURL", url);
document.getElementById("feedListbox").appendChild(item);
}

View file

@ -0,0 +1,40 @@
<?xml version="1.0"?>
<!-- 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/. -->
<!DOCTYPE bindings [
<!ENTITY % pageInfoDTD SYSTEM "chrome://browser/locale/pageInfo.dtd">
%pageInfoDTD;
]>
<bindings id="feedBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="feed" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
<content>
<xul:vbox flex="1">
<xul:hbox flex="1">
<xul:textbox flex="1" readonly="true" xbl:inherits="value=name"
class="feedTitle"/>
<xul:label xbl:inherits="value=type"/>
</xul:hbox>
<xul:vbox>
<xul:vbox align="start">
<xul:hbox>
<xul:label xbl:inherits="value=feedURL,tooltiptext=feedURL" class="text-link" flex="1"
onclick="openUILink(this.value, event);" crop="end"/>
</xul:hbox>
</xul:vbox>
</xul:vbox>
<xul:hbox flex="1" class="feed-subscribe">
<xul:spacer flex="1"/>
<xul:button label="&feedSubscribe;" accesskey="&feedSubscribe.accesskey;"
oncommand="onSubscribeFeed()"/>
</xul:hbox>
</xul:vbox>
</content>
</binding>
</bindings>

View file

@ -0,0 +1,26 @@
/* 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/. */
#viewGroup > radio {
-moz-binding: url("chrome://browser/content/pageinfo/pageInfo.xml#viewbutton");
}
richlistitem[feed] {
-moz-binding: url("chrome://browser/content/pageinfo/feeds.xml#feed");
}
richlistitem[feed]:not([selected="true"]) .feed-subscribe {
display: none;
}
groupbox[closed="true"] > .groupbox-body {
visibility: collapse;
}
#thepreviewimage {
display: block;
/* This following entry can be removed when Bug 522850 is fixed. */
min-width: 1px;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,20 @@
<?xml version="1.0"?>
<!-- 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/. -->
<bindings id="pageInfoBindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<!-- based on preferences.xml paneButton -->
<binding id="viewbutton" extends="chrome://global/content/bindings/radio.xml#radio" role="xullistitem">
<content>
<xul:image class="viewButtonIcon" xbl:inherits="src"/>
<xul:label class="viewButtonLabel" xbl:inherits="value=label"/>
</content>
</binding>
</bindings>

View file

@ -0,0 +1,438 @@
<?xml version="1.0"?>
# 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/.
<?xml-stylesheet href="chrome://browser/content/pageinfo/pageInfo.css" type="text/css"?>
<?xml-stylesheet href="chrome://browser/skin/pageInfo.css" type="text/css"?>
<!DOCTYPE window [
<!ENTITY % pageInfoDTD SYSTEM "chrome://browser/locale/pageInfo.dtd">
%pageInfoDTD;
]>
#ifdef XP_MACOSX
<?xul-overlay href="chrome://browser/content/macBrowserOverlay.xul"?>
#endif
<window id="main-window"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
windowtype="Browser:page-info"
onload="onLoadPageInfo()"
onunload="onUnloadPageInfo()"
align="stretch"
screenX="10" screenY="10"
width="&pageInfoWindow.width;" height="&pageInfoWindow.height;"
persist="screenX screenY width height sizemode">
<script type="application/javascript" src="chrome://global/content/globalOverlay.js"/>
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
<script type="application/javascript" src="chrome://global/content/treeUtils.js"/>
<script type="application/javascript" src="chrome://browser/content/pageinfo/pageInfo.js"/>
<script type="application/javascript" src="chrome://browser/content/pageinfo/feeds.js"/>
<script type="application/javascript" src="chrome://browser/content/pageinfo/permissions.js"/>
<script type="application/javascript" src="chrome://browser/content/pageinfo/security.js"/>
<script type="application/javascript" src="chrome://browser/content/utilityOverlay.js"/>
<stringbundleset id="pageinfobundleset">
<stringbundle id="pageinfobundle" src="chrome://browser/locale/pageInfo.properties"/>
<stringbundle id="pkiBundle" src="chrome://pippki/locale/pippki.properties"/>
<stringbundle id="browserBundle" src="chrome://browser/locale/browser.properties"/>
</stringbundleset>
<commandset id="pageInfoCommandSet">
<command id="cmd_close" oncommand="window.close();"/>
<command id="cmd_help" oncommand="doHelpButton();"/>
<command id="cmd_copy" oncommand="doCopy();"/>
<command id="cmd_selectall" oncommand="doSelectAll();"/>
<!-- permissions tab -->
<command id="cmd_pluginsDef" oncommand="onCheckboxClick('plugins');"/>
<command id="cmd_pluginsToggle" oncommand="onPluginRadioClick(event);"/>
</commandset>
<keyset id="pageInfoKeySet">
<key key="&closeWindow.key;" modifiers="accel" command="cmd_close"/>
<key keycode="VK_ESCAPE" command="cmd_close"/>
#ifdef XP_MACOSX
<key key="." modifiers="meta" command="cmd_close"/>
#else
<key keycode="VK_F1" command="cmd_help"/>
#endif
<key key="&copy.key;" modifiers="accel" command="cmd_copy"/>
<key key="&selectall.key;" modifiers="accel" command="cmd_selectall"/>
<key key="&selectall.key;" modifiers="alt" command="cmd_selectall"/>
</keyset>
<menupopup id="picontext">
<menuitem id="menu_selectall" label="&selectall.label;" command="cmd_selectall" accesskey="&selectall.accesskey;"/>
<menuitem id="menu_copy" label="&copy.label;" command="cmd_copy" accesskey="&copy.accesskey;"/>
</menupopup>
<windowdragbox id="topBar" class="viewGroupWrapper">
<radiogroup id="viewGroup" class="chromeclass-toolbar" orient="horizontal">
<radio id="generalTab" label="&generalTab;" accesskey="&generalTab.accesskey;"
oncommand="showTab('general');"/>
<radio id="mediaTab" label="&mediaTab;" accesskey="&mediaTab.accesskey;"
oncommand="showTab('media');" hidden="true"/>
<radio id="feedTab" label="&feedTab;" accesskey="&feedTab.accesskey;"
oncommand="showTab('feed');" hidden="true"/>
<radio id="permTab" label="&permTab;" accesskey="&permTab.accesskey;"
oncommand="showTab('perm');"/>
<radio id="securityTab" label="&securityTab;" accesskey="&securityTab.accesskey;"
oncommand="showTab('security');"/>
<!-- Others added by overlay -->
</radiogroup>
</windowdragbox>
<deck id="mainDeck" flex="1">
<!-- General page information -->
<vbox id="generalPanel">
<grid id="generalGrid">
<columns>
<column/>
<column class="gridSeparator"/>
<column flex="1"/>
</columns>
<rows id="generalRows">
<row id="generalTitle">
<label control="titletext" value="&generalTitle;"/>
<separator/>
<textbox readonly="true" id="titletext"/>
</row>
<row id="generalURLRow">
<label control="urltext" value="&generalURL;"/>
<separator/>
<textbox readonly="true" id="urltext"/>
</row>
<row id="generalSeparatorRow1">
<separator class="thin"/>
</row>
<row id="generalTypeRow">
<label control="typetext" value="&generalType;"/>
<separator/>
<textbox readonly="true" id="typetext"/>
</row>
<row id="generalModeRow">
<label control="modetext" value="&generalMode;"/>
<separator/>
<textbox readonly="true" crop="end" id="modetext"/>
</row>
<row id="generalEncodingRow">
<label control="encodingtext" value="&generalEncoding2;"/>
<separator/>
<textbox readonly="true" id="encodingtext"/>
</row>
<row id="generalSizeRow">
<label control="sizetext" value="&generalSize;"/>
<separator/>
<textbox readonly="true" id="sizetext"/>
</row>
<row id="generalReferrerRow">
<label control="refertext" value="&generalReferrer;"/>
<separator/>
<textbox readonly="true" id="refertext"/>
</row>
<row id="generalSeparatorRow2">
<separator class="thin"/>
</row>
<row id="generalModifiedRow">
<label control="modifiedtext" value="&generalModified;"/>
<separator/>
<textbox readonly="true" id="modifiedtext"/>
</row>
</rows>
</grid>
<separator class="thin"/>
<groupbox id="metaTags" flex="1" class="collapsable treebox">
<caption id="metaTagsCaption" onclick="toggleGroupbox('metaTags');"/>
<tree id="metatree" flex="1" hidecolumnpicker="true" contextmenu="picontext">
<treecols>
<treecol id="meta-name" label="&generalMetaName;"
persist="width" flex="1"
onclick="gMetaView.onPageMediaSort('meta-name');"/>
<splitter class="tree-splitter"/>
<treecol id="meta-content" label="&generalMetaContent;"
persist="width" flex="4"
onclick="gMetaView.onPageMediaSort('meta-content');"/>
</treecols>
<treechildren id="metatreechildren" flex="1"/>
</tree>
</groupbox>
<hbox pack="end">
<button command="cmd_help" label="&helpButton.label;" dlgtype="help"/>
</hbox>
</vbox>
<!-- Media information -->
<vbox id="mediaPanel">
<tree id="imagetree" onselect="onImageSelect();" contextmenu="picontext"
ondragstart="onBeginLinkDrag(event,'image-address','image-alt')">
<treecols>
<treecol sortSeparators="true" primary="true" persist="width" flex="10"
width="10" id="image-address" label="&mediaAddress;"
onclick="gImageView.onPageMediaSort('image-address');"/>
<splitter class="tree-splitter"/>
<treecol sortSeparators="true" persist="hidden width" flex="2"
width="2" id="image-type" label="&mediaType;"
onclick="gImageView.onPageMediaSort('image-type');"/>
<splitter class="tree-splitter"/>
<treecol sortSeparators="true" hidden="true" persist="hidden width" flex="2"
width="2" id="image-size" label="&mediaSize;" value="size"
onclick="gImageView.onPageMediaSort('image-size');"/>
<splitter class="tree-splitter"/>
<treecol sortSeparators="true" hidden="true" persist="hidden width" flex="4"
width="4" id="image-alt" label="&mediaAltHeader;"
onclick="gImageView.onPageMediaSort('image-alt');"/>
<splitter class="tree-splitter"/>
<treecol sortSeparators="true" hidden="true" persist="hidden width" flex="1"
width="1" id="image-count" label="&mediaCount;"
onclick="gImageView.onPageMediaSort('image-count');"/>
</treecols>
<treechildren id="imagetreechildren" flex="1"/>
</tree>
<splitter orient="vertical" id="mediaSplitter"/>
<vbox flex="1" id="mediaPreviewBox" collapsed="true">
<grid id="mediaGrid">
<columns>
<column id="mediaLabelColumn"/>
<column class="gridSeparator"/>
<column flex="1"/>
</columns>
<rows id="mediaRows">
<row id="mediaLocationRow">
<label control="imageurltext" value="&mediaLocation;"/>
<separator/>
<textbox readonly="true" id="imageurltext"/>
</row>
<row id="mediaTypeRow">
<label control="imagetypetext" value="&generalType;"/>
<separator/>
<textbox readonly="true" id="imagetypetext"/>
</row>
<row id="mediaSizeRow">
<label control="imagesizetext" value="&generalSize;"/>
<separator/>
<textbox readonly="true" id="imagesizetext"/>
</row>
<row id="mediaDimensionRow">
<label control="imagedimensiontext" value="&mediaDimension;"/>
<separator/>
<textbox readonly="true" id="imagedimensiontext"/>
</row>
<row id="mediaTextRow">
<label control="imagetext" value="&mediaText;"/>
<separator/>
<textbox readonly="true" id="imagetext"/>
</row>
<row id="mediaLongdescRow">
<label control="imagelongdesctext" value="&mediaLongdesc;"/>
<separator/>
<textbox readonly="true" id="imagelongdesctext"/>
</row>
</rows>
</grid>
<hbox id="imageSaveBox" align="end">
<vbox id="blockImageBox">
<checkbox id="blockImage" hidden="true" oncommand="onBlockImage()"
accesskey="&mediaBlockImage.accesskey;"/>
<label control="thepreviewimage" value="&mediaPreview;" class="header"/>
</vbox>
<spacer id="imageSaveBoxSpacer" flex="1"/>
<button label="&selectall.label;" accesskey="&selectall.accesskey;"
id="selectallbutton"
oncommand="doSelectAllMedia();"/>
<button label="&mediaSaveAs;" accesskey="&mediaSaveAs.accesskey;"
icon="save" id="imagesaveasbutton"
oncommand="saveMedia();"/>
</hbox>
<vbox id="imagecontainerbox" class="inset iframe" flex="1" pack="center">
<hbox id="theimagecontainer" pack="center">
<image id="thepreviewimage"/>
</hbox>
<hbox id="brokenimagecontainer" pack="center" collapsed="true">
<image id="brokenimage" src="resource://gre-resources/broken-image.png"/>
</hbox>
</vbox>
</vbox>
<hbox id="mediaSaveBox" collapsed="true">
<spacer id="mediaSaveBoxSpacer" flex="1"/>
<button label="&mediaSaveAs;" accesskey="&mediaSaveAs2.accesskey;"
icon="save" id="mediasaveasbutton"
oncommand="saveMedia();"/>
</hbox>
<hbox pack="end">
<button command="cmd_help" label="&helpButton.label;" dlgtype="help"/>
</hbox>
</vbox>
<!-- Feeds -->
<vbox id="feedPanel">
<richlistbox id="feedListbox" flex="1"/>
</vbox>
<!-- Permissions -->
<vbox id="permPanel">
<hbox id="permHostBox">
<label value="&permissionsFor;" control="hostText" />
<textbox id="hostText" class="header" readonly="true"
crop="end" flex="1"/>
</hbox>
<vbox id="permList" flex="1">
<hbox id="perm-indexedDB-extras">
<spacer flex="1"/>
<vbox id="permIndexedDBStatusBox" pack="center">
<label id="indexedDBStatus" control="indexedDBClear" hidden="true"/>
</vbox>
<button id="indexedDBClear" label="&permClearStorage;" hidden="true"
accesskey="&permClearStorage.accesskey;" onclick="onIndexedDBClear();"/>
</hbox>
<vbox class="permission" id="perm-plugins-row">
<label class="permissionLabel" id="permPluginsLabel"
value="&permPlugins;" control="pluginsRadioGroup"/>
<hbox id="permPluginTemplate" role="group" aria-labelledby="permPluginsLabel" align="baseline">
<label class="permPluginTemplateLabel"/>
<spacer flex="1"/>
<radiogroup class="permPluginTemplateRadioGroup" orient="horizontal" command="cmd_pluginsToggle">
<radio class="permPluginTemplateRadioDefault" label="&permUseDefault;"/>
<radio class="permPluginTemplateRadioAsk" label="&permAskAlways;"/>
<radio class="permPluginTemplateRadioAllow" label="&permAllow;"/>
<radio class="permPluginTemplateRadioBlock" label="&permBlock;"/>
</radiogroup>
</hbox>
</vbox>
</vbox>
<hbox pack="end">
<button command="cmd_help" label="&helpButton.label;" dlgtype="help"/>
</hbox>
</vbox>
<!-- Security & Privacy -->
<vbox id="securityPanel">
<!-- Identity Section -->
<groupbox id="security-identity-groupbox" flex="1">
<caption id="security-identity" label="&securityView.identity.header;"/>
<grid id="security-identity-grid" flex="1">
<columns>
<column/>
<column flex="1"/>
</columns>
<rows id="security-identity-rows">
<!-- Domain -->
<row id="security-identity-domain-row">
<label id="security-identity-domain-label"
class="fieldLabel"
value="&securityView.identity.domain;"
control="security-identity-domain-value"/>
<textbox id="security-identity-domain-value"
class="fieldValue" readonly="true"/>
</row>
<!-- Owner -->
<row id="security-identity-owner-row">
<label id="security-identity-owner-label"
class="fieldLabel"
value="&securityView.identity.owner;"
control="security-identity-owner-value"/>
<textbox id="security-identity-owner-value"
class="fieldValue" readonly="true"/>
</row>
<!-- Verifier -->
<row id="security-identity-verifier-row">
<label id="security-identity-verifier-label"
class="fieldLabel"
value="&securityView.identity.verifier;"
control="security-identity-verifier-value"/>
<textbox id="security-identity-verifier-value"
class="fieldValue" readonly="true" />
</row>
</rows>
</grid>
<spacer flex="1"/>
<!-- Cert button -->
<hbox id="security-view-cert-box" pack="end">
<button id="security-view-cert" label="&securityView.certView;"
accesskey="&securityView.accesskey;"
oncommand="security.viewCert();"/>
</hbox>
</groupbox>
<!-- Privacy & History section -->
<groupbox id="security-privacy-groupbox" flex="1">
<caption id="security-privacy" label="&securityView.privacy.header;" />
<grid id="security-privacy-grid">
<columns>
<column flex="1"/>
<column flex="1"/>
</columns>
<rows id="security-privacy-rows">
<!-- History -->
<row id="security-privacy-history-row">
<label id="security-privacy-history-label"
control="security-privacy-history-value"
class="fieldLabel">&securityView.privacy.history;</label>
<textbox id="security-privacy-history-value"
class="fieldValue"
value="&securityView.unknown;"
readonly="true"/>
</row>
<!-- Cookies -->
<row id="security-privacy-cookies-row">
<label id="security-privacy-cookies-label"
control="security-privacy-cookies-value"
class="fieldLabel">&securityView.privacy.cookies;</label>
<hbox id="security-privacy-cookies-box" align="center">
<textbox id="security-privacy-cookies-value"
class="fieldValue"
value="&securityView.unknown;"
flex="1"
readonly="true"/>
<button id="security-view-cookies"
label="&securityView.privacy.viewCookies;"
accesskey="&securityView.privacy.viewCookies.accessKey;"
oncommand="security.viewCookies();"/>
</hbox>
</row>
<!-- Passwords -->
<row id="security-privacy-passwords-row">
<label id="security-privacy-passwords-label"
control="security-privacy-passwords-value"
class="fieldLabel">&securityView.privacy.passwords;</label>
<hbox id="security-privacy-passwords-box" align="center">
<textbox id="security-privacy-passwords-value"
class="fieldValue"
value="&securityView.unknown;"
flex="1"
readonly="true"/>
<button id="security-view-password"
label="&securityView.privacy.viewPasswords;"
accesskey="&securityView.privacy.viewPasswords.accessKey;"
oncommand="security.viewPasswords();"/>
</hbox>
</row>
</rows>
</grid>
</groupbox>
<!-- Technical Details section -->
<groupbox id="security-technical-groupbox" flex="1">
<caption id="security-technical" label="&securityView.technical.header;" />
<vbox id="security-technical-box" flex="1">
<label id="security-technical-shortform" class="fieldValue"/>
<description id="security-technical-longform1" class="fieldLabel"/>
<description id="security-technical-longform2" class="fieldLabel"/>
<description id="security-technical-certificate-transparency" class="fieldLabel"/>
</vbox>
</groupbox>
<hbox pack="end">
<button command="cmd_help" label="&helpButton.label;" dlgtype="help"/>
</hbox>
</vbox>
<!-- Others added by overlay -->
</deck>
#ifdef XP_MACOSX
#include ../browserMountPoints.inc
#endif
</window>

View file

@ -0,0 +1,334 @@
/* 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/. */
Components.utils.import("resource:///modules/SitePermissions.jsm");
Components.utils.import("resource://gre/modules/BrowserUtils.jsm");
const nsIQuotaManagerService = Components.interfaces.nsIQuotaManagerService;
var gPermURI;
var gPermPrincipal;
var gUsageRequest;
// Array of permissionIDs sorted alphabetically by label.
var gPermissions = SitePermissions.listPermissions().sort((a, b) => {
let firstLabel = SitePermissions.getPermissionLabel(a);
let secondLabel = SitePermissions.getPermissionLabel(b);
return firstLabel.localeCompare(secondLabel);
});
gPermissions.push("plugins");
var permissionObserver = {
observe: function (aSubject, aTopic, aData)
{
if (aTopic == "perm-changed") {
var permission = aSubject.QueryInterface(Components.interfaces.nsIPermission);
if (permission.matchesURI(gPermURI, true)) {
if (gPermissions.indexOf(permission.type) > -1)
initRow(permission.type);
else if (permission.type.startsWith("plugin"))
setPluginsRadioState();
}
}
}
};
function onLoadPermission(uri, principal)
{
var permTab = document.getElementById("permTab");
if (SitePermissions.isSupportedURI(uri)) {
gPermURI = uri;
gPermPrincipal = principal;
var hostText = document.getElementById("hostText");
hostText.value = gPermURI.prePath;
for (var i of gPermissions)
initRow(i);
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.addObserver(permissionObserver, "perm-changed", false);
onUnloadRegistry.push(onUnloadPermission);
permTab.hidden = false;
}
else
permTab.hidden = true;
}
function onUnloadPermission()
{
var os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
os.removeObserver(permissionObserver, "perm-changed");
if (gUsageRequest) {
gUsageRequest.cancel();
gUsageRequest = null;
}
}
function initRow(aPartId)
{
if (aPartId == "plugins") {
initPluginsRow();
return;
}
createRow(aPartId);
var checkbox = document.getElementById(aPartId + "Def");
var command = document.getElementById("cmd_" + aPartId + "Toggle");
var perm = SitePermissions.get(gPermURI, aPartId);
if (perm) {
checkbox.checked = false;
command.removeAttribute("disabled");
}
else {
checkbox.checked = true;
command.setAttribute("disabled", "true");
perm = SitePermissions.getDefault(aPartId);
}
setRadioState(aPartId, perm);
if (aPartId == "indexedDB") {
initIndexedDBRow();
}
}
function createRow(aPartId) {
let rowId = "perm-" + aPartId + "-row";
if (document.getElementById(rowId))
return;
let commandId = "cmd_" + aPartId + "Toggle";
let labelId = "perm-" + aPartId + "-label";
let radiogroupId = aPartId + "RadioGroup";
let command = document.createElement("command");
command.setAttribute("id", commandId);
command.setAttribute("oncommand", "onRadioClick('" + aPartId + "');");
document.getElementById("pageInfoCommandSet").appendChild(command);
let row = document.createElement("vbox");
row.setAttribute("id", rowId);
row.setAttribute("class", "permission");
let label = document.createElement("label");
label.setAttribute("id", labelId);
label.setAttribute("control", radiogroupId);
label.setAttribute("value", SitePermissions.getPermissionLabel(aPartId));
label.setAttribute("class", "permissionLabel");
row.appendChild(label);
let controls = document.createElement("hbox");
controls.setAttribute("role", "group");
controls.setAttribute("aria-labelledby", labelId);
let checkbox = document.createElement("checkbox");
checkbox.setAttribute("id", aPartId + "Def");
checkbox.setAttribute("oncommand", "onCheckboxClick('" + aPartId + "');");
checkbox.setAttribute("label", gBundle.getString("permissions.useDefault"));
controls.appendChild(checkbox);
let spacer = document.createElement("spacer");
spacer.setAttribute("flex", "1");
controls.appendChild(spacer);
let radiogroup = document.createElement("radiogroup");
radiogroup.setAttribute("id", radiogroupId);
radiogroup.setAttribute("orient", "horizontal");
for (let state of SitePermissions.getAvailableStates(aPartId)) {
let radio = document.createElement("radio");
radio.setAttribute("id", aPartId + "#" + state);
radio.setAttribute("label", SitePermissions.getStateLabel(aPartId, state));
radio.setAttribute("command", commandId);
radiogroup.appendChild(radio);
}
controls.appendChild(radiogroup);
row.appendChild(controls);
document.getElementById("permList").appendChild(row);
}
function onCheckboxClick(aPartId)
{
var command = document.getElementById("cmd_" + aPartId + "Toggle");
var checkbox = document.getElementById(aPartId + "Def");
if (checkbox.checked) {
SitePermissions.remove(gPermURI, aPartId);
command.setAttribute("disabled", "true");
var perm = SitePermissions.getDefault(aPartId);
setRadioState(aPartId, perm);
}
else {
onRadioClick(aPartId);
command.removeAttribute("disabled");
}
}
function onPluginRadioClick(aEvent) {
onRadioClick(aEvent.originalTarget.getAttribute("id").split('#')[0]);
}
function onRadioClick(aPartId)
{
var radioGroup = document.getElementById(aPartId + "RadioGroup");
var id = radioGroup.selectedItem.id;
var permission = id.split('#')[1];
SitePermissions.set(gPermURI, aPartId, permission);
}
function setRadioState(aPartId, aValue)
{
var radio = document.getElementById(aPartId + "#" + aValue);
if (radio) {
radio.radioGroup.selectedItem = radio;
}
}
function initIndexedDBRow()
{
let row = document.getElementById("perm-indexedDB-row");
let extras = document.getElementById("perm-indexedDB-extras");
row.appendChild(extras);
var quotaManagerService =
Components.classes["@mozilla.org/dom/quota-manager-service;1"]
.getService(nsIQuotaManagerService);
gUsageRequest =
quotaManagerService.getUsageForPrincipal(gPermPrincipal,
onIndexedDBUsageCallback);
var status = document.getElementById("indexedDBStatus");
var button = document.getElementById("indexedDBClear");
status.value = "";
status.setAttribute("hidden", "true");
button.setAttribute("hidden", "true");
}
function onIndexedDBClear()
{
Components.classes["@mozilla.org/dom/quota-manager-service;1"]
.getService(nsIQuotaManagerService)
.clearStoragesForPrincipal(gPermPrincipal);
Components.classes["@mozilla.org/serviceworkers/manager;1"]
.getService(Components.interfaces.nsIServiceWorkerManager)
.removeAndPropagate(gPermURI.host);
SitePermissions.remove(gPermURI, "indexedDB");
initIndexedDBRow();
}
function onIndexedDBUsageCallback(request)
{
let uri = request.principal.URI;
if (!uri.equals(gPermURI)) {
throw new Error("Callback received for bad URI: " + uri);
}
let usage = request.result.usage;
if (usage) {
if (!("DownloadUtils" in window)) {
Components.utils.import("resource://gre/modules/DownloadUtils.jsm");
}
var status = document.getElementById("indexedDBStatus");
var button = document.getElementById("indexedDBClear");
status.value =
gBundle.getFormattedString("indexedDBUsage",
DownloadUtils.convertByteUnits(usage));
status.removeAttribute("hidden");
button.removeAttribute("hidden");
}
}
function fillInPluginPermissionTemplate(aPluginName, aPermissionString) {
let permPluginTemplate = document.getElementById("permPluginTemplate").cloneNode(true);
permPluginTemplate.setAttribute("permString", aPermissionString);
let attrs = [
[ ".permPluginTemplateLabel", "value", aPluginName ],
[ ".permPluginTemplateRadioGroup", "id", aPermissionString + "RadioGroup" ],
[ ".permPluginTemplateRadioDefault", "id", aPermissionString + "#0" ],
[ ".permPluginTemplateRadioAsk", "id", aPermissionString + "#3" ],
[ ".permPluginTemplateRadioAllow", "id", aPermissionString + "#1" ],
[ ".permPluginTemplateRadioBlock", "id", aPermissionString + "#2" ]
];
for (let attr of attrs) {
permPluginTemplate.querySelector(attr[0]).setAttribute(attr[1], attr[2]);
}
return permPluginTemplate;
}
function clearPluginPermissionTemplate() {
let permPluginTemplate = document.getElementById("permPluginTemplate");
permPluginTemplate.hidden = true;
permPluginTemplate.removeAttribute("permString");
document.querySelector(".permPluginTemplateLabel").removeAttribute("value");
document.querySelector(".permPluginTemplateRadioGroup").removeAttribute("id");
document.querySelector(".permPluginTemplateRadioAsk").removeAttribute("id");
document.querySelector(".permPluginTemplateRadioAllow").removeAttribute("id");
document.querySelector(".permPluginTemplateRadioBlock").removeAttribute("id");
}
function initPluginsRow() {
let vulnerableLabel = document.getElementById("browserBundle").getString("pluginActivateVulnerable.label");
let pluginHost = Components.classes["@mozilla.org/plugin/host;1"].getService(Components.interfaces.nsIPluginHost);
let permissionMap = new Map();
for (let plugin of pluginHost.getPluginTags()) {
if (plugin.disabled) {
continue;
}
for (let mimeType of plugin.getMimeTypes()) {
let permString = pluginHost.getPermissionStringForType(mimeType);
if (!permissionMap.has(permString)) {
let name = BrowserUtils.makeNicePluginName(plugin.name);
if (permString.startsWith("plugin-vulnerable:")) {
name += " \u2014 " + vulnerableLabel;
}
permissionMap.set(permString, name);
}
}
}
let entries = Array.from(permissionMap, item => ({ name: item[1], permission: item[0] }));
entries.sort(function(a, b) {
return a.name.localeCompare(b.name);
});
let permissionEntries = entries.map(p => fillInPluginPermissionTemplate(p.name, p.permission));
let permPluginsRow = document.getElementById("perm-plugins-row");
clearPluginPermissionTemplate();
if (permissionEntries.length < 1) {
permPluginsRow.hidden = true;
return;
}
for (let permissionEntry of permissionEntries) {
permPluginsRow.appendChild(permissionEntry);
}
setPluginsRadioState();
}
function setPluginsRadioState() {
let box = document.getElementById("perm-plugins-row");
for (let permissionEntry of box.childNodes) {
if (permissionEntry.hasAttribute("permString")) {
let permString = permissionEntry.getAttribute("permString");
let permission = SitePermissions.get(gPermURI, permString);
setRadioState(permString, permission);
}
}
}

View file

@ -0,0 +1,388 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* 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/. */
Components.utils.import("resource://gre/modules/BrowserUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "LoginHelper",
"resource://gre/modules/LoginHelper.jsm");
var security = {
init: function(uri, windowInfo) {
this.uri = uri;
this.windowInfo = windowInfo;
},
// Display the server certificate (static)
viewCert : function () {
var cert = security._cert;
viewCertHelper(window, cert);
},
_getSecurityInfo : function() {
const nsISSLStatusProvider = Components.interfaces.nsISSLStatusProvider;
const nsISSLStatus = Components.interfaces.nsISSLStatus;
// We don't have separate info for a frame, return null until further notice
// (see bug 138479)
if (!this.windowInfo.isTopWindow)
return null;
var hostName = this.windowInfo.hostName;
var ui = security._getSecurityUI();
if (!ui)
return null;
var isBroken =
(ui.state & Components.interfaces.nsIWebProgressListener.STATE_IS_BROKEN);
var isMixed =
(ui.state & (Components.interfaces.nsIWebProgressListener.STATE_LOADED_MIXED_ACTIVE_CONTENT |
Components.interfaces.nsIWebProgressListener.STATE_LOADED_MIXED_DISPLAY_CONTENT));
var isInsecure =
(ui.state & Components.interfaces.nsIWebProgressListener.STATE_IS_INSECURE);
var isEV =
(ui.state & Components.interfaces.nsIWebProgressListener.STATE_IDENTITY_EV_TOPLEVEL);
ui.QueryInterface(nsISSLStatusProvider);
var status = ui.SSLStatus;
if (!isInsecure && status) {
status.QueryInterface(nsISSLStatus);
var cert = status.serverCert;
var issuerName =
this.mapIssuerOrganization(cert.issuerOrganization) || cert.issuerName;
var retval = {
hostName : hostName,
cAName : issuerName,
encryptionAlgorithm : undefined,
encryptionStrength : undefined,
version: undefined,
isBroken : isBroken,
isMixed : isMixed,
isEV : isEV,
cert : cert,
certificateTransparency : undefined
};
var version;
try {
retval.encryptionAlgorithm = status.cipherName;
retval.encryptionStrength = status.secretKeyLength;
version = status.protocolVersion;
}
catch (e) {
}
switch (version) {
case nsISSLStatus.SSL_VERSION_3:
retval.version = "SSL 3";
break;
case nsISSLStatus.TLS_VERSION_1:
retval.version = "TLS 1.0";
break;
case nsISSLStatus.TLS_VERSION_1_1:
retval.version = "TLS 1.1";
break;
case nsISSLStatus.TLS_VERSION_1_2:
retval.version = "TLS 1.2"
break;
case nsISSLStatus.TLS_VERSION_1_3:
retval.version = "TLS 1.3"
break;
}
// Select status text to display for Certificate Transparency.
switch (status.certificateTransparencyStatus) {
case nsISSLStatus.CERTIFICATE_TRANSPARENCY_NOT_APPLICABLE:
// CT compliance checks were not performed,
// do not display any status text.
retval.certificateTransparency = null;
break;
case nsISSLStatus.CERTIFICATE_TRANSPARENCY_NONE:
retval.certificateTransparency = "None";
break;
case nsISSLStatus.CERTIFICATE_TRANSPARENCY_OK:
retval.certificateTransparency = "OK";
break;
case nsISSLStatus.CERTIFICATE_TRANSPARENCY_UNKNOWN_LOG:
retval.certificateTransparency = "UnknownLog";
break;
case nsISSLStatus.CERTIFICATE_TRANSPARENCY_INVALID:
retval.certificateTransparency = "Invalid";
break;
}
return retval;
}
return {
hostName : hostName,
cAName : "",
encryptionAlgorithm : "",
encryptionStrength : 0,
version: "",
isBroken : isBroken,
isMixed : isMixed,
isEV : isEV,
cert : null,
certificateTransparency : null
};
},
// Find the secureBrowserUI object (if present)
_getSecurityUI : function() {
if (window.opener.gBrowser)
return window.opener.gBrowser.securityUI;
return null;
},
// Interface for mapping a certificate issuer organization to
// the value to be displayed.
// Bug 82017 - this implementation should be moved to pipnss C++ code
mapIssuerOrganization: function(name) {
if (!name) return null;
if (name == "RSA Data Security, Inc.") return "Verisign, Inc.";
// No mapping required
return name;
},
/**
* Open the cookie manager window
*/
viewCookies : function()
{
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var win = wm.getMostRecentWindow("Browser:Cookies");
var eTLDService = Components.classes["@mozilla.org/network/effective-tld-service;1"].
getService(Components.interfaces.nsIEffectiveTLDService);
var eTLD;
try {
eTLD = eTLDService.getBaseDomain(this.uri);
}
catch (e) {
// getBaseDomain will fail if the host is an IP address or is empty
eTLD = this.uri.asciiHost;
}
if (win) {
win.gCookiesWindow.setFilter(eTLD);
win.focus();
}
else
window.openDialog("chrome://browser/content/preferences/cookies.xul",
"Browser:Cookies", "", {filterString : eTLD});
},
/**
* Open the login manager window
*/
viewPasswords : function() {
LoginHelper.openPasswordManager(window, this._getSecurityInfo().hostName);
},
_cert : null
};
function securityOnLoad(uri, windowInfo) {
security.init(uri, windowInfo);
var info = security._getSecurityInfo();
if (!info) {
document.getElementById("securityTab").hidden = true;
return;
}
document.getElementById("securityTab").hidden = false;
const pageInfoBundle = document.getElementById("pageinfobundle");
/* Set Identity section text */
setText("security-identity-domain-value", info.hostName);
var owner, verifier;
if (info.cert && !info.isBroken) {
// Try to pull out meaningful values. Technically these fields are optional
// so we'll employ fallbacks where appropriate. The EV spec states that Org
// fields must be specified for subject and issuer so that case is simpler.
if (info.isEV) {
owner = info.cert.organization;
verifier = security.mapIssuerOrganization(info.cAName);
}
else {
// Technically, a non-EV cert might specify an owner in the O field or not,
// depending on the CA's issuing policies. However we don't have any programmatic
// way to tell those apart, and no policy way to establish which organization
// vetting standards are good enough (that's what EV is for) so we default to
// treating these certs as domain-validated only.
owner = pageInfoBundle.getString("securityNoOwner");
verifier = security.mapIssuerOrganization(info.cAName ||
info.cert.issuerCommonName ||
info.cert.issuerName);
}
}
else {
// We don't have valid identity credentials.
owner = pageInfoBundle.getString("securityNoOwner");
verifier = pageInfoBundle.getString("notset");
}
setText("security-identity-owner-value", owner);
setText("security-identity-verifier-value", verifier);
/* Manage the View Cert button*/
var viewCert = document.getElementById("security-view-cert");
if (info.cert) {
security._cert = info.cert;
viewCert.collapsed = false;
}
else
viewCert.collapsed = true;
/* Set Privacy & History section text */
var yesStr = pageInfoBundle.getString("yes");
var noStr = pageInfoBundle.getString("no");
setText("security-privacy-cookies-value",
hostHasCookies(uri) ? yesStr : noStr);
setText("security-privacy-passwords-value",
realmHasPasswords(uri) ? yesStr : noStr);
var visitCount = previousVisitCount(info.hostName);
if (visitCount > 1) {
setText("security-privacy-history-value",
pageInfoBundle.getFormattedString("securityNVisits", [visitCount.toLocaleString()]));
}
else if (visitCount == 1) {
setText("security-privacy-history-value",
pageInfoBundle.getString("securityOneVisit"));
}
else {
setText("security-privacy-history-value", noStr);
}
/* Set the Technical Detail section messages */
const pkiBundle = document.getElementById("pkiBundle");
var hdr;
var msg1;
var msg2;
if (info.isBroken) {
if (info.isMixed) {
hdr = pkiBundle.getString("pageInfo_MixedContent");
msg1 = pkiBundle.getString("pageInfo_MixedContent2");
} else {
hdr = pkiBundle.getFormattedString("pageInfo_BrokenEncryption",
[info.encryptionAlgorithm,
info.encryptionStrength + "",
info.version]);
msg1 = pkiBundle.getString("pageInfo_WeakCipher");
}
msg2 = pkiBundle.getString("pageInfo_Privacy_None2");
}
else if (info.encryptionStrength > 0) {
hdr = pkiBundle.getFormattedString("pageInfo_EncryptionWithBitsAndProtocol",
[info.encryptionAlgorithm,
info.encryptionStrength + "",
info.version]);
msg1 = pkiBundle.getString("pageInfo_Privacy_Encrypted1");
msg2 = pkiBundle.getString("pageInfo_Privacy_Encrypted2");
security._cert = info.cert;
}
else {
hdr = pkiBundle.getString("pageInfo_NoEncryption");
if (info.hostName != null)
msg1 = pkiBundle.getFormattedString("pageInfo_Privacy_None1", [info.hostName]);
else
msg1 = pkiBundle.getString("pageInfo_Privacy_None4");
msg2 = pkiBundle.getString("pageInfo_Privacy_None2");
}
setText("security-technical-shortform", hdr);
setText("security-technical-longform1", msg1);
setText("security-technical-longform2", msg2);
const ctStatus =
document.getElementById("security-technical-certificate-transparency");
if (info.certificateTransparency) {
ctStatus.hidden = false;
ctStatus.value = pkiBundle.getString(
"pageInfo_CertificateTransparency_" + info.certificateTransparency);
} else {
ctStatus.hidden = true;
}
}
function setText(id, value)
{
var element = document.getElementById(id);
if (!element)
return;
if (element.localName == "textbox" || element.localName == "label")
element.value = value;
else {
if (element.hasChildNodes())
element.removeChild(element.firstChild);
var textNode = document.createTextNode(value);
element.appendChild(textNode);
}
}
function viewCertHelper(parent, cert)
{
if (!cert)
return;
var cd = Components.classes[CERTIFICATEDIALOGS_CONTRACTID].getService(nsICertificateDialogs);
cd.viewCert(parent, cert);
}
/**
* Return true iff we have cookies for uri
*/
function hostHasCookies(uri) {
var cookieManager = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager2);
return cookieManager.countCookiesFromHost(uri.asciiHost) > 0;
}
/**
* Return true iff realm (proto://host:port) (extracted from uri) has
* saved passwords
*/
function realmHasPasswords(uri) {
var passwordManager = Components.classes["@mozilla.org/login-manager;1"]
.getService(Components.interfaces.nsILoginManager);
return passwordManager.countLogins(uri.prePath, "", "") > 0;
}
/**
* Return the number of previous visits recorded for host before today.
*
* @param host - the domain name to look for in history
*/
function previousVisitCount(host, endTimeReference) {
if (!host)
return false;
var historyService = Components.classes["@mozilla.org/browser/nav-history-service;1"]
.getService(Components.interfaces.nsINavHistoryService);
var options = historyService.getNewQueryOptions();
options.resultType = options.RESULTS_AS_VISIT;
// Search for visits to this host before today
var query = historyService.getNewQuery();
query.endTimeReference = query.TIME_RELATIVE_TODAY;
query.endTime = 0;
query.domain = host;
var result = historyService.executeQuery(query, options);
result.root.containerOpen = true;
var cc = result.root.childCount;
result.root.containerOpen = false;
return cc;
}