toolkit/mozapps/extensions/content/selectAddons.xml

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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

mercurial