Revision control
Copy as Markdown
Other Tools
<?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
<!DOCTYPE bindings [
<!ENTITY % datamanDTD SYSTEM "chrome://communicator/locale/dataman/dataman.dtd">
%datamanDTD;
]>
<bindings id="datamanBindings"
<binding id="perm-base-item"
<implementation>
<constructor><![CDATA[
var permLabel = this.type;
try {
permLabel = SitePermissions.getPermissionLabel(this.type);
}
catch (e) {
}
this.setAttribute("label", permLabel);
this._updateRadio();
]]></constructor>
<property name="capability">
<getter><![CDATA[
if (this.hasAttribute("capability"))
return this.getAttribute("capability");
return -1;
]]></getter>
<setter><![CDATA[
this.setAttribute("capability", val);
this._updateRadio();
]]></setter>
</property>
<property name="host" readonly="true"
onget="return this.getAttribute('host');"/>
<property name="type" readonly="true"
onget="return this.getAttribute('type');"/>
<method name="_updateRadio">
<body><![CDATA[
let radio = document.getAnonymousElementByAttribute(this, "anonid",
"permSetting-" + this.capability);
if (radio)
radio.radioGroup.selectedItem = radio;
else {
let radioGroup = document.getAnonymousElementByAttribute(this, "anonid",
"radioGroup");
radioGroup.selectedIndex = -1;
}
]]></body>
</method>
<method name="useDefault">
<parameter name="aChecked"/>
<parameter name="aUIUpdateOnly"/>
<body><![CDATA[
let checkbox = document.getAnonymousElementByAttribute(this, "anonid",
"useDefault");
if (checkbox.checked != aChecked)
checkbox.checked = aChecked;
let radioGroup = document.getAnonymousElementByAttribute(this, "anonid",
"radioGroup");
radioGroup.disabled = aChecked;
if (aChecked) {
if (!aUIUpdateOnly)
gPerms.removeItem(this.host, this.type);
this.capability = SitePermissions.getDefault(this.type);
}
this._updateRadio();
]]></body>
</method>
<method name="setCapability">
<parameter name="aValue"/>
<parameter name="aUIUpdateOnly"/>
<body><![CDATA[
this.capability = aValue;
let radio = document.getAnonymousElementByAttribute(this, "anonid",
"permSetting-" + aValue);
if (radio && !radio.selected)
radio.radioGroup.selectedItem = radio;
if (!aUIUpdateOnly)
gPerms.updateItem(this.host, this.type, aValue);
]]></body>
</method>
<method name="handleKeyPress">
<parameter name="aEvent"/>
<body><![CDATA[
if (aEvent.keyCode == KeyEvent.DOM_VK_DELETE ||
(AppConstants.platform == "macosx" &&
aEvent.keyCode == KeyEvent.DOM_VK_BACK_SPACE)) {
this.useDefault(true);
}
]]></body>
</method>
</implementation>
<handlers>
<handler event="keypress" phase="capturing"
action="return this.handleKeyPress(event);"/>
</handlers>
</binding>
<binding id="perm-generic-item"
<content>
<xul:hbox>
<xul:label anonid="permHost" class="hostLabel" xbl:inherits="value=displayHost"/>
<xul:label anonid="permLabel" class="permissionLabel" xbl:inherits="value=label" control="radioGroup"/>
</xul:hbox>
<xul:hbox role="group" aria-labelledby="permLabel">
<xul:checkbox class="indent" anonid="useDefault" label="&perm.UseDefault;"
oncommand="document.getBindingParent(this).useDefault(this.checked);"/>
<xul:spacer flex="1"/>
<xul:radiogroup anonid="radioGroup" orient="horizontal">
<xul:radio anonid="permSetting-1" label="&perm.Allow;"
oncommand="document.getBindingParent(this).setCapability(Services.perms.ALLOW_ACTION);"/>
<xul:radio anonid="permSetting-2" label="&perm.Block;"
oncommand="document.getBindingParent(this).setCapability(Services.perms.DENY_ACTION);"/>
</xul:radiogroup>
</xul:hbox>
</content>
</binding>
<binding id="perm-cookie-item"
<content>
<xul:hbox>
<xul:label anonid="permHost" class="hostLabel" xbl:inherits="value=displayHost"/>
<xul:label anonid="permLabel" class="permissionLabel" xbl:inherits="value=label" control="radioGroup"/>
</xul:hbox>
<xul:hbox role="group" aria-labelledby="permLabel">
<xul:checkbox class="indent" anonid="useDefault" label="&perm.UseDefault;"
oncommand="document.getBindingParent(this).useDefault(this.checked);"/>
<xul:spacer flex="1"/>
<xul:radiogroup anonid="radioGroup" orient="horizontal">
<xul:radio anonid="permSetting-1" label="&perm.Allow;"
oncommand="document.getBindingParent(this).setCapability(Services.perms.ALLOW_ACTION);"/>
<xul:radio anonid="permSetting-8" label="&perm.AllowSession;"
oncommand="document.getBindingParent(this).setCapability(Ci.nsICookiePermission.ACCESS_SESSION);"/>
<xul:radio anonid="permSetting-2" label="&perm.Block;"
oncommand="document.getBindingParent(this).setCapability(Services.perms.DENY_ACTION);"/>
</xul:radiogroup>
</xul:hbox>
</content>
</binding>
<binding id="perm-geo-item"
<content>
<xul:hbox>
<xul:label anonid="permHost" class="hostLabel" xbl:inherits="value=displayHost"/>
<xul:label anonid="permLabel" class="permissionLabel" xbl:inherits="value=label" control="radioGroup"/>
</xul:hbox>
<xul:hbox role="group" aria-labelledby="permLabel">
<xul:checkbox class="indent" anonid="useDefault" label="&perm.AskAlways;"
oncommand="document.getBindingParent(this).useDefault(this.checked);"/>
<xul:spacer flex="1"/>
<xul:radiogroup anonid="radioGroup" orient="horizontal">
<xul:radio anonid="permSetting-1" label="&perm.Allow;"
oncommand="document.getBindingParent(this).setCapability(Services.perms.ALLOW_ACTION);"/>
<xul:radio anonid="permSetting-2" label="&perm.Block;"
oncommand="document.getBindingParent(this).setCapability(Services.perms.DENY_ACTION);"/>
</xul:radiogroup>
</xul:hbox>
</content>
</binding>
<binding id="perm-password-item" extends="chrome://communicator/content/dataman/dataman.xml#perm-base-item">
<content>
<xul:hbox>
<xul:label anonid="permHost" class="hostLabel" xbl:inherits="value=displayHost"/>
<xul:label anonid="permLabel" class="permissionLabel" xbl:inherits="value=label" control="radioGroup"/>
</xul:hbox>
<xul:hbox role="group" aria-labelledby="permLabel">
<xul:checkbox class="indent" anonid="useDefault" hidden="true"/>
<xul:spacer flex="1"/>
<xul:radiogroup anonid="radioGroup" orient="horizontal">
<xul:radio anonid="permSetting-1" label="&perm.AskAlways;"
oncommand="document.getBindingParent(this).setCapability(Services.perms.ALLOW_ACTION);"/>
<xul:radio anonid="permSetting-2" label="&perm.NeverSave;"
oncommand="document.getBindingParent(this).setCapability(Services.perms.DENY_ACTION);"/>
</xul:radiogroup>
</xul:hbox>
</content>
<implementation>
<method name="useDefault">
<parameter name="aChecked"/>
<body><![CDATA[
// just for compat, makes it easier to generically "delete" perms
if (aChecked)
this.setCapability(Services.perms.ALLOW_ACTION);
]]></body>
</method>
<method name="setCapability">
<parameter name="aValue"/>
<parameter name="aUIUpdateOnly"/>
<body><![CDATA[
this.capability = aValue;
let radio = document.getAnonymousElementByAttribute(this, "anonid",
"permSetting-" + aValue);
if (radio && !radio.selected)
radio.radioGroup.selectedItem = radio;
if (!aUIUpdateOnly)
Services.logins.setLoginSavingEnabled(this.host, aValue == Services.perms.ALLOW_ACTION);
]]></body>
</method>
</implementation>
</binding>
<binding id="perm-content-item"
<content>
<xul:hbox>
<xul:label anonid="permHost" class="hostLabel" xbl:inherits="value=displayHost"/>
<xul:label anonid="permLabel" class="permissionLabel" xbl:inherits="value=label" control="radioGroup"/>
</xul:hbox>
<xul:hbox role="group" aria-labelledby="permLabel">
<xul:checkbox class="indent" anonid="useDefault" label="&perm.UseDefault;"
oncommand="document.getBindingParent(this).useDefault(this.checked);"/>
<xul:spacer flex="1"/>
<xul:radiogroup anonid="radioGroup" orient="horizontal">
<xul:radio anonid="permSetting-1" label="&perm.Allow;"
oncommand="document.getBindingParent(this).setCapability(Services.perms.ALLOW_ACTION);"/>
<xul:radio anonid="permSetting-3" label="&perm.AllowSameDomain;"
oncommand="document.getBindingParent(this).setCapability(NOFOREIGN);"/>
<xul:radio anonid="permSetting-2" label="&perm.Block;"
oncommand="document.getBindingParent(this).setCapability(Services.perms.DENY_ACTION);"/>
</xul:radiogroup>
</xul:hbox>
</content>
</binding>
</bindings>