toolkit/mozapps/update/content/updates.xml

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/mozapps/update/content/updates.xml	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,309 @@
     1.4 +<?xml version="1.0"?>
     1.5 +<!-- This Source Code Form is subject to the terms of the Mozilla Public
     1.6 +   - License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 +   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     1.8 +
     1.9 +
    1.10 +<!DOCTYPE bindings SYSTEM "chrome://mozapps/locale/update/updates.dtd">
    1.11 +
    1.12 +<bindings id="updatesBindings"
    1.13 +          xmlns="http://www.mozilla.org/xbl"
    1.14 +          xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.15 +          xmlns:xbl="http://www.mozilla.org/xbl">
    1.16 +  
    1.17 +  <binding id="remotecontent">
    1.18 +    <content>
    1.19 +      <xul:vbox flex="1" class="loadingBox">
    1.20 +        <xul:hbox align="start">
    1.21 +          <xul:image class="remoteLoadingThrobber" xbl:inherits="state"/>
    1.22 +          <xul:vbox flex="1">
    1.23 +            <xul:description flex="1" class="remoteLoadingMessage" crop="right"/>
    1.24 +          </xul:vbox>
    1.25 +        </xul:hbox>
    1.26 +      </xul:vbox>
    1.27 +      <xul:vbox flex="1">
    1.28 +        <xul:browser class="remoteContent" type="content" disablehistory="true"
    1.29 +                     flex="1"/>
    1.30 +      </xul:vbox>
    1.31 +      <xul:stringbundle anonid="strings" 
    1.32 +                        src="chrome://mozapps/locale/update/updates.properties"/>
    1.33 +    </content>
    1.34 +    <implementation>
    1.35 +      <constructor><![CDATA[
    1.36 +        // just to be safe, turn off js, auth, plugins, and subframes
    1.37 +        var docShell = this._content.docShell;
    1.38 +        docShell.allowJavascript = false;
    1.39 +        docShell.allowAuth = false;
    1.40 +        docShell.allowPlugins = false;
    1.41 +        //allow redirects
    1.42 +        //docShell.allowMetaRedirects = false;
    1.43 +        docShell.allowSubframes = false;
    1.44 +        //allow images
    1.45 +        //docShell.allowImages = false;
    1.46 +      ]]></constructor>
    1.47 +
    1.48 +      <destructor><![CDATA[
    1.49 +        // clean up the listener but you may not have one if you never showed
    1.50 +        // the page with a <remotecontent> element
    1.51 +        if (this._remoteProgressListener) 
    1.52 +          this._content.webProgress
    1.53 +              .removeProgressListener(this._remoteProgressListener);
    1.54 +      ]]></destructor>
    1.55 +
    1.56 +      <field name="_message">
    1.57 +        document.getAnonymousElementByAttribute(this, "class", "remoteLoadingMessage");
    1.58 +      </field>
    1.59 +      <field name="_content">
    1.60 +        document.getAnonymousElementByAttribute(this, "class", "remoteContent");
    1.61 +      </field>
    1.62 +      <field name="_strings">
    1.63 +        document.getAnonymousElementByAttribute(this, "anonid", "strings");
    1.64 +      </field>
    1.65 +
    1.66 +      <field name="update_name">null</field>
    1.67 +      <field name="update_version">null</field>
    1.68 +      <field name="_remoteProgressListener">null</field>
    1.69 +
    1.70 +      <method name="_setMessageValue">
    1.71 +        <parameter name="value"/>
    1.72 +        <body><![CDATA[
    1.73 +          while (this._message.hasChildNodes())
    1.74 +            this._message.removeChild(this._message.firstChild);
    1.75 +          this._message.appendChild(document.createTextNode(value));
    1.76 +        ]]></body>
    1.77 +      </method>
    1.78 +
    1.79 +      <method name="onError">
    1.80 +        <body><![CDATA[
    1.81 +          this.setAttribute("selectedIndex", "0");
    1.82 +
    1.83 +          var errorPropertyName = this.getAttribute("id") + "NotFound";
    1.84 +          var statusText = this._strings.getFormattedString(errorPropertyName, 
    1.85 +                                                            [this.update_name]);
    1.86 +          this._setMessageValue(statusText);
    1.87 +          this.setAttribute("state", "error");
    1.88 +          var e = document.createEvent("Events");
    1.89 +          e.initEvent("load", false, true);
    1.90 +          this.dispatchEvent(e);
    1.91 +        ]]></body>
    1.92 +      </method>
    1.93 +
    1.94 +      <method name="onLoad">
    1.95 +        <body><![CDATA[
    1.96 +          var doc = this._content.contentDocument;
    1.97 +          var type = this.getAttribute("remotetype");
    1.98 +          if (!doc.body.hasAttribute(type)) {
    1.99 +            this.onError();
   1.100 +            return;
   1.101 +          }
   1.102 +          // The remote html can tell us to zoom out the page if the page
   1.103 +          // will create scrollbars by adding a zoomOutToFit attribute to the
   1.104 +          // body of the billboard's html. Since zooming out will not always
   1.105 +          // remove the scrollbars even though the page fits in the client
   1.106 +          // region after zooming out the web page should hide the scrollbar(s)
   1.107 +          // using css. If you choose to use zoomOutToFit you should also verify
   1.108 +          // it is working the way you expect it to with the billboard you have
   1.109 +          // created. Possible values for zoomOutToFit are:
   1.110 +          // both: zoom out if the width or height is greater than the client
   1.111 +          //       region.
   1.112 +          // height: zoom out if the height is greater than the client region.
   1.113 +          // width: zoom out if the width is greater than the client region.
   1.114 +          if (doc.body.hasAttribute("zoomOutToFit")) {
   1.115 +            let zoomAdjustWidth = 1;
   1.116 +            let zoomAdjustHeight = 1;
   1.117 +            let zoomOutType = doc.body.getAttribute("zoomOutToFit");
   1.118 +            if ((zoomOutType == "both" || zoomOutType == "width") &&
   1.119 +                doc.width > this.clientWidth)
   1.120 +              zoomAdjustWidth = Math.floor((this.clientWidth / doc.width) * 100) * .01;
   1.121 +
   1.122 +            if ((zoomOutType == "both" || zoomOutType == "height") &&
   1.123 +                doc.height > this.clientHeight)
   1.124 +              zoomAdjustHeight = Math.floor((this.clientHeight / doc.height) * 100) * .01;
   1.125 +
   1.126 +            var zoomAdjust = zoomAdjustWidth < zoomAdjustHeight ? zoomAdjustWidth
   1.127 +                                                                : zoomAdjustHeight;
   1.128 +            if (zoomAdjust < 1)
   1.129 +              this._content.markupDocumentViewer.fullZoom = zoomAdjust;
   1.130 +          }
   1.131 +
   1.132 +          this.setAttribute("selectedIndex", "1");
   1.133 +          this.setAttribute("state", "loaded");
   1.134 +
   1.135 +          var e = document.createEvent("Events");
   1.136 +          e.initEvent("load", false, true);
   1.137 +          this.dispatchEvent(e);
   1.138 +        ]]></body>
   1.139 +      </method>
   1.140 +
   1.141 +      <method name="onStart">
   1.142 +        <body><![CDATA[
   1.143 +          this.setAttribute("selectedIndex", "0");
   1.144 +
   1.145 +          this.setAttribute("state", "loading");
   1.146 +          var loadingPropertyName = this.getAttribute("id") + "Downloading";
   1.147 +          this._setMessageValue(this._strings.getFormattedString(
   1.148 +            loadingPropertyName, [this.update_name, this.update_version]));
   1.149 +        ]]></body>
   1.150 +      </method>
   1.151 +
   1.152 +      <property name="url">
   1.153 +        <getter><![CDATA[
   1.154 +          return this.getAttribute("url");
   1.155 +        ]]></getter>
   1.156 +        <setter><![CDATA[
   1.157 +          if (this._remoteProgressListener) 
   1.158 +            this._content.webProgress
   1.159 +                .removeProgressListener(this._remoteProgressListener);
   1.160 +
   1.161 +          var self = this;
   1.162 +
   1.163 +          this._remoteProgressListener = {
   1.164 +            QueryInterface: function(aIID) 
   1.165 +            {
   1.166 +              if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
   1.167 +                  aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
   1.168 +                  aIID.equals(Components.interfaces.nsISupports))
   1.169 +                return this;
   1.170 +              throw Components.results.NS_NOINTERFACE;
   1.171 +            },
   1.172 +            onLocationChange: function() {},
   1.173 +            onProgressChange: function() {},
   1.174 +            onStatusChange:   function() {},
   1.175 +            onSecurityChange: function() {},
   1.176 +            onStateChange:    function(aWebProgress, aRequest, 
   1.177 +                                       aStateFlags, aStatus) 
   1.178 +            {
   1.179 +              if (!aRequest)
   1.180 +                return;
   1.181 +
   1.182 +              const nsIWebProgressListener = 
   1.183 +                Components.interfaces.nsIWebProgressListener;
   1.184 + 
   1.185 +              if (aStateFlags & nsIWebProgressListener.STATE_IS_NETWORK) 
   1.186 +              {
   1.187 +                if (aStateFlags & nsIWebProgressListener.STATE_START) 
   1.188 +                  self.onStart();
   1.189 +                else if (aStateFlags & nsIWebProgressListener.STATE_STOP)
   1.190 +                {
   1.191 +                  const nsIHttpChannel = Components.interfaces.nsIHttpChannel;
   1.192 +                  try {
   1.193 +                    var channel = aRequest.QueryInterface(nsIHttpChannel);
   1.194 +                    if (channel.requestSucceeded) 
   1.195 +                    {
   1.196 +                      // if we get here, the load was OK, report success
   1.197 +                      self.onLoad();
   1.198 +                      return;
   1.199 +                    }
   1.200 +                  }
   1.201 +                  catch (ex) 
   1.202 +                  {
   1.203 +                    // the channel.requestSucceeded can throw
   1.204 +                    // NS_ERROR_NOT_AVAILABLE if you can't reach the server
   1.205 +                    // so we treat that as an error
   1.206 +                  }
   1.207 +
   1.208 +                  // everything else (like a 404) is an error
   1.209 +                  self.onError();
   1.210 +                }
   1.211 +              }
   1.212 +            }
   1.213 +          }
   1.214 +
   1.215 +          this._content.webProgress
   1.216 +              .addProgressListener(this._remoteProgressListener,
   1.217 +               Components.interfaces.nsIWebProgress.NOTIFY_ALL);
   1.218 +
   1.219 +          // load the url now that the listener is registered
   1.220 +          this._content.setAttribute("src", val);
   1.221 +        ]]></setter>
   1.222 +      </property>
   1.223 +
   1.224 +      <property name="testFileUrl">
   1.225 +        <getter><![CDATA[
   1.226 +          return this.getAttribute("testFileUrl");
   1.227 +        ]]></getter>
   1.228 +        <setter><![CDATA[
   1.229 +          this._content.setAttribute("src", val);
   1.230 +          this.onLoad()
   1.231 +        ]]></setter>
   1.232 +      </property>
   1.233 +
   1.234 +      <method name="stopDownloading">
   1.235 +        <body><![CDATA[
   1.236 +          this._content.stop();
   1.237 +        ]]></body>
   1.238 +      </method>
   1.239 +    </implementation>
   1.240 +  </binding>
   1.241 +
   1.242 +  <binding id="updateheader" extends="chrome://global/content/bindings/wizard.xml#wizard-header">
   1.243 +    <resources>
   1.244 +      <stylesheet src="chrome://global/skin/wizard.css"/>
   1.245 +    </resources>
   1.246 +    <content>
   1.247 +      <xul:hbox class="wizard-header update-header" flex="1">
   1.248 +        <xul:vbox class="wizard-header-box-1">
   1.249 +          <xul:vbox class="wizard-header-box-text">
   1.250 +            <xul:label class="wizard-header-label" xbl:inherits="value=label"/>
   1.251 +          </xul:vbox>
   1.252 +        </xul:vbox>
   1.253 +      </xul:hbox>
   1.254 +    </content>
   1.255 +  </binding>
   1.256 +
   1.257 +  <binding id="update" extends="chrome://global/content/bindings/richlistbox.xml#richlistitem">
   1.258 +    <content>
   1.259 +      <xul:hbox>
   1.260 +        <xul:label class="update-name" xbl:inherits="value=name" flex="1" crop="right"/>
   1.261 +        <xul:label xbl:inherits="href=detailsURL,hidden=hideDetailsURL" class="text-link"
   1.262 +                   value="&update.details.label;"/>
   1.263 +      </xul:hbox>
   1.264 +      <xul:label class="update-type" xbl:inherits="value=type"/>
   1.265 +      <xul:grid>
   1.266 +        <xul:columns>
   1.267 +          <xul:column class="update-label-column"/>
   1.268 +          <xul:column flex="1"/>
   1.269 +        </xul:columns>
   1.270 +        <xul:rows>
   1.271 +          <xul:row>
   1.272 +            <xul:label class="update-installedOn-label">&update.installedOn.label;</xul:label>
   1.273 +            <xul:label class="update-installedOn-value" xbl:inherits="value=installDate" flex="1" crop="right"/>
   1.274 +          </xul:row>
   1.275 +          <xul:row>
   1.276 +            <xul:label class="update-status-label">&update.status.label;</xul:label>
   1.277 +            <xul:description class="update-status-value" flex="1"/>
   1.278 +          </xul:row>
   1.279 +        </xul:rows>
   1.280 +      </xul:grid>
   1.281 +    </content>
   1.282 +    <implementation>
   1.283 +      <property name="name"
   1.284 +                onget="return this.getAttribute('name');"
   1.285 +                onset="this.setAttribute('name', val); return val;"/>
   1.286 +      <property name="detailsURL"
   1.287 +                onget="return this.getAttribute('detailsURL');"
   1.288 +                onset="this.setAttribute('detailsURL', val); return val;"/>
   1.289 +      <property name="installDate"
   1.290 +                onget="return this.getAttribute('installDate');"
   1.291 +                onset="this.setAttribute('installDate', val); return val;"/>
   1.292 +      <property name="type"
   1.293 +                onget="return this.getAttribute('type');"
   1.294 +                onset="this.setAttribute('type', val); return val;"/>
   1.295 +      <property name="hideDetailsURL"
   1.296 +                onget="return this.getAttribute('hideDetailsURL');"
   1.297 +                onset="this.setAttribute('hideDetailsURL', val); return val;"/>
   1.298 +      <property name="status"
   1.299 +                onget="return this.getAttribute('status');">
   1.300 +        <setter><![CDATA[
   1.301 +          this.setAttribute("status", val);
   1.302 +          var field = document.getAnonymousElementByAttribute(this, "class", "update-status-value");
   1.303 +          while (field.hasChildNodes())
   1.304 +            field.removeChild(field.firstChild);
   1.305 +          field.appendChild(document.createTextNode(val));
   1.306 +          return val;
   1.307 +        ]]></setter>
   1.308 +      </property>
   1.309 +    </implementation>
   1.310 +  </binding>
   1.311 +</bindings>
   1.312 +

mercurial