toolkit/mozapps/extensions/content/selectAddons.xml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/extensions/content/selectAddons.xml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,235 @@
     1.4 +<?xml version="1.0"?>
     1.5 +
     1.6 +<!-- This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +   - License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     1.9 +
    1.10 +<!DOCTYPE window [
    1.11 +<!ENTITY % updateDTD SYSTEM "chrome://mozapps/locale/extensions/selectAddons.dtd">
    1.12 +<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd">
    1.13 +%updateDTD;
    1.14 +%brandDTD;
    1.15 +]>
    1.16 +
    1.17 +<bindings xmlns="http://www.mozilla.org/xbl"
    1.18 +          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.19 +          xmlns:xbl="http://www.mozilla.org/xbl">
    1.20 +
    1.21 +  <binding id="addon-select">
    1.22 +    <content>
    1.23 +      <xul:hbox class="select-keep select-cell">
    1.24 +        <xul:checkbox class="addon-keep-checkbox" anonid="keep"
    1.25 +                      xbl:inherits="tooltiptext=name"
    1.26 +                      oncommand="document.getBindingParent(this).keepChanged();"/>
    1.27 +      </xul:hbox>
    1.28 +      <xul:hbox class="select-icon select-cell">
    1.29 +        <xul:image class="addon-icon" xbl:inherits="type"/>
    1.30 +      </xul:hbox>
    1.31 +      <xul:hbox class="select-name select-cell">
    1.32 +        <xul:label class="addon-name" crop="end" style="&select.name.style;"
    1.33 +                   xbl:inherits="xbl:text=name"/>
    1.34 +      </xul:hbox>
    1.35 +      <xul:hbox class="select-action select-cell">
    1.36 +        <xul:label class="addon-action-message" style="&select.action.style;"
    1.37 +                   xbl:inherits="xbl:text=action"/>
    1.38 +        <xul:checkbox anonid="update" checked="true" class="addon-action-update"
    1.39 +                      oncommand="document.getBindingParent(this).updateChanged();"
    1.40 +                      style="&select.action.style;" xbl:inherits="label=action"/>
    1.41 +      </xul:hbox>
    1.42 +      <xul:hbox class="select-source select-cell">
    1.43 +        <xul:label class="addon-source" xbl:inherits="xbl:text=source"/>
    1.44 +      </xul:hbox>
    1.45 +    </content>
    1.46 +
    1.47 +    <implementation>
    1.48 +      <field name="_addon"/>
    1.49 +      <field name="_disabled"/>
    1.50 +      <field name="_install"/>
    1.51 +      <field name="_wasActive"/>
    1.52 +      <field name="_keep">document.getAnonymousElementByAttribute(this, "anonid", "keep");</field>
    1.53 +      <field name="_update">document.getAnonymousElementByAttribute(this, "anonid", "update");</field>
    1.54 +      <field name="_strings">document.getElementById("strings");</field>
    1.55 +
    1.56 +      <property name="action" readonly="true">
    1.57 +        <getter><![CDATA[
    1.58 +          if (!this._keep.checked) {
    1.59 +            if (this._wasActive)
    1.60 +              return "disable";
    1.61 +            else
    1.62 +              return null;
    1.63 +          }
    1.64 +
    1.65 +          if (this._addon.appDisabled && !this._install)
    1.66 +            return "incompatible";
    1.67 +
    1.68 +          if (this._install && (AddonManager.shouldAutoUpdate(this._addon) || this._update.checked))
    1.69 +            return "update";
    1.70 +
    1.71 +          if (this._addon.permissions & AddonManager.PERM_CAN_ENABLE)
    1.72 +            return "enable";
    1.73 +
    1.74 +          return null;
    1.75 +        ]]></getter>
    1.76 +      </property>
    1.77 +
    1.78 +      <method name="setAddon">
    1.79 +        <parameter name="aAddon"/>
    1.80 +        <parameter name="aInstall"/>
    1.81 +        <parameter name="aWasActive"/>
    1.82 +        <parameter name="aDistroInstalled"/>
    1.83 +        <body><![CDATA[
    1.84 +          this._addon = aAddon;
    1.85 +          this._install = aInstall;
    1.86 +          this._wasActive = aWasActive;
    1.87 +
    1.88 +          this.setAttribute("name", aAddon.name);
    1.89 +          this.setAttribute("type", aAddon.type);
    1.90 +
    1.91 +          // User and bundled add-ons default to staying enabled,
    1.92 +          // others default to disabled.
    1.93 +          switch (aAddon.scope) {
    1.94 +            case AddonManager.SCOPE_PROFILE:
    1.95 +              this._keep.checked = !aAddon.userDisabled;
    1.96 +              if (aDistroInstalled)
    1.97 +                this.setAttribute("source", this._strings.getString("source.bundled"));
    1.98 +              else
    1.99 +                this.setAttribute("source", this._strings.getString("source.profile"));
   1.100 +              break;
   1.101 +            default:
   1.102 +              this._keep.checked = false;
   1.103 +              this.setAttribute("source", this._strings.getString("source.other"));
   1.104 +          }
   1.105 +
   1.106 +          this.updateAction();
   1.107 +        ]]></body>
   1.108 +      </method>
   1.109 +
   1.110 +      <method name="setActionMessage">
   1.111 +        <body><![CDATA[
   1.112 +          if (!this._keep.checked) {
   1.113 +            // If the user no longer wants this add-on then it is either being
   1.114 +            // disabled or nothing is changing. Don't complicate matters by
   1.115 +            // talking about updates for this case
   1.116 +
   1.117 +            if (this._wasActive)
   1.118 +              this.setAttribute("action", this._strings.getString("action.disabled"));
   1.119 +            else
   1.120 +              this.setAttribute("action", "");
   1.121 +
   1.122 +            this.removeAttribute("optionalupdate");
   1.123 +            return;
   1.124 +          }
   1.125 +
   1.126 +          if (this._addon.appDisabled && !this._install) {
   1.127 +            // If the add-on is incompatible and there is no update available
   1.128 +            // then it will remain disabled
   1.129 +
   1.130 +            this.setAttribute("action", this._strings.getString("action.incompatible"));
   1.131 +
   1.132 +            this.removeAttribute("optionalupdate");
   1.133 +            return;
   1.134 +          }
   1.135 +
   1.136 +          if (this._install) {
   1.137 +            if (!AddonManager.shouldAutoUpdate(this._addon)) {
   1.138 +              this.setAttribute("optionalupdate", "true");
   1.139 +
   1.140 +              // If manual updating for the add-on then display the right
   1.141 +              // text depending on whether the update is required to make
   1.142 +              // the add-on work or not
   1.143 +              if (this._addon.appDisabled)
   1.144 +                this.setAttribute("action", this._strings.getString("action.neededupdate"));
   1.145 +              else
   1.146 +                this.setAttribute("action", this._strings.getString("action.unneededupdate"));
   1.147 +              return;
   1.148 +            }
   1.149 +
   1.150 +            this.removeAttribute("optionalupdate");
   1.151 +
   1.152 +            // If the update is needed to make the add-on compatible then
   1.153 +            // say so otherwise just say nothing about it
   1.154 +            if (this._addon.appDisabled) {
   1.155 +              this.setAttribute("action", this._strings.getString("action.autoupdate"));
   1.156 +              return;
   1.157 +            }
   1.158 +          }
   1.159 +          else {
   1.160 +            this.removeAttribute("optionalupdate");
   1.161 +          }
   1.162 +
   1.163 +          // If the add-on didn't used to be active and it now is (via a
   1.164 +          // compatibility update) or it can be enabled then the action is to
   1.165 +          // enable the add-on
   1.166 +          if (!this._wasActive && (this._addon.isActive || this._addon.permissions & AddonManager.PERM_CAN_ENABLE)) {
   1.167 +            this.setAttribute("action", this._strings.getString("action.enabled"));
   1.168 +            return;
   1.169 +          }
   1.170 +
   1.171 +          // In all other cases the add-on is simply remaining enabled
   1.172 +          this.setAttribute("action", "");
   1.173 +        ]]></body>
   1.174 +      </method>
   1.175 +
   1.176 +      <method name="updateAction">
   1.177 +        <body><![CDATA[
   1.178 +          this.setActionMessage();
   1.179 +          let installingUpdate = this._install &&
   1.180 +                                 (AddonManager.shouldAutoUpdate(this._addon) || 
   1.181 +                                  this._update.checked);
   1.182 +
   1.183 +          if (this._keep.checked && (!this._addon.appDisabled || installingUpdate))
   1.184 +            this.setAttribute("active", "true");
   1.185 +          else
   1.186 +            this.removeAttribute("active");
   1.187 +
   1.188 +          gSelect.updateButtons();
   1.189 +        ]]></body>
   1.190 +      </method>
   1.191 +
   1.192 +      <method name="updateChanged">
   1.193 +        <body><![CDATA[
   1.194 +          this.updateAction();
   1.195 +        ]]></body>
   1.196 +      </method>
   1.197 +
   1.198 +      <method name="keepChanged">
   1.199 +        <body><![CDATA[
   1.200 +          this.updateAction();
   1.201 +        ]]></body>
   1.202 +      </method>
   1.203 +
   1.204 +      <method name="keep">
   1.205 +        <body><![CDATA[
   1.206 +          this._keep.checked = true;
   1.207 +          this.keepChanged();
   1.208 +        ]]></body>
   1.209 +      </method>
   1.210 +
   1.211 +      <method name="disable">
   1.212 +        <body><![CDATA[
   1.213 +          this._keep.checked = false;
   1.214 +          this.keepChanged();
   1.215 +        ]]></body>
   1.216 +      </method>
   1.217 +
   1.218 +      <method name="apply">
   1.219 +        <body><![CDATA[
   1.220 +          this._addon.userDisabled = !this._keep.checked;
   1.221 +
   1.222 +          if (!this._install || !this._keep.checked)
   1.223 +            return;
   1.224 +
   1.225 +          if (AddonManager.shouldAutoUpdate(this._addon) || this._update.checked)
   1.226 +            this._install.install();
   1.227 +        ]]></body>
   1.228 +      </method>
   1.229 +    </implementation>
   1.230 +  </binding>
   1.231 +
   1.232 +  <binding id="addon-confirm">
   1.233 +    <content>
   1.234 +      <xul:image class="addon-icon" xbl:inherits="type"/>
   1.235 +      <xul:label class="addon-name" xbl:inherits="xbl:text=name"/>
   1.236 +    </content>
   1.237 +  </binding>
   1.238 +</bindings>

mercurial