toolkit/mozapps/extensions/content/selectAddons.xml

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <?xml version="1.0"?>
michael@0 2
michael@0 3 <!-- This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 - License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
michael@0 6
michael@0 7 <!DOCTYPE window [
michael@0 8 <!ENTITY % updateDTD SYSTEM "chrome://mozapps/locale/extensions/selectAddons.dtd">
michael@0 9 <!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
michael@0 10 %updateDTD;
michael@0 11 %brandDTD;
michael@0 12 ]>
michael@0 13
michael@0 14 <bindings xmlns="http://www.mozilla.org/xbl"
michael@0 15 xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
michael@0 16 xmlns:xbl="http://www.mozilla.org/xbl">
michael@0 17
michael@0 18 <binding id="addon-select">
michael@0 19 <content>
michael@0 20 <xul:hbox class="select-keep select-cell">
michael@0 21 <xul:checkbox class="addon-keep-checkbox" anonid="keep"
michael@0 22 xbl:inherits="tooltiptext=name"
michael@0 23 oncommand="document.getBindingParent(this).keepChanged();"/>
michael@0 24 </xul:hbox>
michael@0 25 <xul:hbox class="select-icon select-cell">
michael@0 26 <xul:image class="addon-icon" xbl:inherits="type"/>
michael@0 27 </xul:hbox>
michael@0 28 <xul:hbox class="select-name select-cell">
michael@0 29 <xul:label class="addon-name" crop="end" style="&select.name.style;"
michael@0 30 xbl:inherits="xbl:text=name"/>
michael@0 31 </xul:hbox>
michael@0 32 <xul:hbox class="select-action select-cell">
michael@0 33 <xul:label class="addon-action-message" style="&select.action.style;"
michael@0 34 xbl:inherits="xbl:text=action"/>
michael@0 35 <xul:checkbox anonid="update" checked="true" class="addon-action-update"
michael@0 36 oncommand="document.getBindingParent(this).updateChanged();"
michael@0 37 style="&select.action.style;" xbl:inherits="label=action"/>
michael@0 38 </xul:hbox>
michael@0 39 <xul:hbox class="select-source select-cell">
michael@0 40 <xul:label class="addon-source" xbl:inherits="xbl:text=source"/>
michael@0 41 </xul:hbox>
michael@0 42 </content>
michael@0 43
michael@0 44 <implementation>
michael@0 45 <field name="_addon"/>
michael@0 46 <field name="_disabled"/>
michael@0 47 <field name="_install"/>
michael@0 48 <field name="_wasActive"/>
michael@0 49 <field name="_keep">document.getAnonymousElementByAttribute(this, "anonid", "keep");</field>
michael@0 50 <field name="_update">document.getAnonymousElementByAttribute(this, "anonid", "update");</field>
michael@0 51 <field name="_strings">document.getElementById("strings");</field>
michael@0 52
michael@0 53 <property name="action" readonly="true">
michael@0 54 <getter><![CDATA[
michael@0 55 if (!this._keep.checked) {
michael@0 56 if (this._wasActive)
michael@0 57 return "disable";
michael@0 58 else
michael@0 59 return null;
michael@0 60 }
michael@0 61
michael@0 62 if (this._addon.appDisabled && !this._install)
michael@0 63 return "incompatible";
michael@0 64
michael@0 65 if (this._install && (AddonManager.shouldAutoUpdate(this._addon) || this._update.checked))
michael@0 66 return "update";
michael@0 67
michael@0 68 if (this._addon.permissions & AddonManager.PERM_CAN_ENABLE)
michael@0 69 return "enable";
michael@0 70
michael@0 71 return null;
michael@0 72 ]]></getter>
michael@0 73 </property>
michael@0 74
michael@0 75 <method name="setAddon">
michael@0 76 <parameter name="aAddon"/>
michael@0 77 <parameter name="aInstall"/>
michael@0 78 <parameter name="aWasActive"/>
michael@0 79 <parameter name="aDistroInstalled"/>
michael@0 80 <body><![CDATA[
michael@0 81 this._addon = aAddon;
michael@0 82 this._install = aInstall;
michael@0 83 this._wasActive = aWasActive;
michael@0 84
michael@0 85 this.setAttribute("name", aAddon.name);
michael@0 86 this.setAttribute("type", aAddon.type);
michael@0 87
michael@0 88 // User and bundled add-ons default to staying enabled,
michael@0 89 // others default to disabled.
michael@0 90 switch (aAddon.scope) {
michael@0 91 case AddonManager.SCOPE_PROFILE:
michael@0 92 this._keep.checked = !aAddon.userDisabled;
michael@0 93 if (aDistroInstalled)
michael@0 94 this.setAttribute("source", this._strings.getString("source.bundled"));
michael@0 95 else
michael@0 96 this.setAttribute("source", this._strings.getString("source.profile"));
michael@0 97 break;
michael@0 98 default:
michael@0 99 this._keep.checked = false;
michael@0 100 this.setAttribute("source", this._strings.getString("source.other"));
michael@0 101 }
michael@0 102
michael@0 103 this.updateAction();
michael@0 104 ]]></body>
michael@0 105 </method>
michael@0 106
michael@0 107 <method name="setActionMessage">
michael@0 108 <body><![CDATA[
michael@0 109 if (!this._keep.checked) {
michael@0 110 // If the user no longer wants this add-on then it is either being
michael@0 111 // disabled or nothing is changing. Don't complicate matters by
michael@0 112 // talking about updates for this case
michael@0 113
michael@0 114 if (this._wasActive)
michael@0 115 this.setAttribute("action", this._strings.getString("action.disabled"));
michael@0 116 else
michael@0 117 this.setAttribute("action", "");
michael@0 118
michael@0 119 this.removeAttribute("optionalupdate");
michael@0 120 return;
michael@0 121 }
michael@0 122
michael@0 123 if (this._addon.appDisabled && !this._install) {
michael@0 124 // If the add-on is incompatible and there is no update available
michael@0 125 // then it will remain disabled
michael@0 126
michael@0 127 this.setAttribute("action", this._strings.getString("action.incompatible"));
michael@0 128
michael@0 129 this.removeAttribute("optionalupdate");
michael@0 130 return;
michael@0 131 }
michael@0 132
michael@0 133 if (this._install) {
michael@0 134 if (!AddonManager.shouldAutoUpdate(this._addon)) {
michael@0 135 this.setAttribute("optionalupdate", "true");
michael@0 136
michael@0 137 // If manual updating for the add-on then display the right
michael@0 138 // text depending on whether the update is required to make
michael@0 139 // the add-on work or not
michael@0 140 if (this._addon.appDisabled)
michael@0 141 this.setAttribute("action", this._strings.getString("action.neededupdate"));
michael@0 142 else
michael@0 143 this.setAttribute("action", this._strings.getString("action.unneededupdate"));
michael@0 144 return;
michael@0 145 }
michael@0 146
michael@0 147 this.removeAttribute("optionalupdate");
michael@0 148
michael@0 149 // If the update is needed to make the add-on compatible then
michael@0 150 // say so otherwise just say nothing about it
michael@0 151 if (this._addon.appDisabled) {
michael@0 152 this.setAttribute("action", this._strings.getString("action.autoupdate"));
michael@0 153 return;
michael@0 154 }
michael@0 155 }
michael@0 156 else {
michael@0 157 this.removeAttribute("optionalupdate");
michael@0 158 }
michael@0 159
michael@0 160 // If the add-on didn't used to be active and it now is (via a
michael@0 161 // compatibility update) or it can be enabled then the action is to
michael@0 162 // enable the add-on
michael@0 163 if (!this._wasActive && (this._addon.isActive || this._addon.permissions & AddonManager.PERM_CAN_ENABLE)) {
michael@0 164 this.setAttribute("action", this._strings.getString("action.enabled"));
michael@0 165 return;
michael@0 166 }
michael@0 167
michael@0 168 // In all other cases the add-on is simply remaining enabled
michael@0 169 this.setAttribute("action", "");
michael@0 170 ]]></body>
michael@0 171 </method>
michael@0 172
michael@0 173 <method name="updateAction">
michael@0 174 <body><![CDATA[
michael@0 175 this.setActionMessage();
michael@0 176 let installingUpdate = this._install &&
michael@0 177 (AddonManager.shouldAutoUpdate(this._addon) ||
michael@0 178 this._update.checked);
michael@0 179
michael@0 180 if (this._keep.checked && (!this._addon.appDisabled || installingUpdate))
michael@0 181 this.setAttribute("active", "true");
michael@0 182 else
michael@0 183 this.removeAttribute("active");
michael@0 184
michael@0 185 gSelect.updateButtons();
michael@0 186 ]]></body>
michael@0 187 </method>
michael@0 188
michael@0 189 <method name="updateChanged">
michael@0 190 <body><![CDATA[
michael@0 191 this.updateAction();
michael@0 192 ]]></body>
michael@0 193 </method>
michael@0 194
michael@0 195 <method name="keepChanged">
michael@0 196 <body><![CDATA[
michael@0 197 this.updateAction();
michael@0 198 ]]></body>
michael@0 199 </method>
michael@0 200
michael@0 201 <method name="keep">
michael@0 202 <body><![CDATA[
michael@0 203 this._keep.checked = true;
michael@0 204 this.keepChanged();
michael@0 205 ]]></body>
michael@0 206 </method>
michael@0 207
michael@0 208 <method name="disable">
michael@0 209 <body><![CDATA[
michael@0 210 this._keep.checked = false;
michael@0 211 this.keepChanged();
michael@0 212 ]]></body>
michael@0 213 </method>
michael@0 214
michael@0 215 <method name="apply">
michael@0 216 <body><![CDATA[
michael@0 217 this._addon.userDisabled = !this._keep.checked;
michael@0 218
michael@0 219 if (!this._install || !this._keep.checked)
michael@0 220 return;
michael@0 221
michael@0 222 if (AddonManager.shouldAutoUpdate(this._addon) || this._update.checked)
michael@0 223 this._install.install();
michael@0 224 ]]></body>
michael@0 225 </method>
michael@0 226 </implementation>
michael@0 227 </binding>
michael@0 228
michael@0 229 <binding id="addon-confirm">
michael@0 230 <content>
michael@0 231 <xul:image class="addon-icon" xbl:inherits="type"/>
michael@0 232 <xul:label class="addon-name" xbl:inherits="xbl:text=name"/>
michael@0 233 </content>
michael@0 234 </binding>
michael@0 235 </bindings>

mercurial