mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-05 08:35:26 +00:00
282 lines
11 KiB
XML
282 lines
11 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<!DOCTYPE bindings SYSTEM "chrome://mozapps/locale/update/updates.dtd">
|
|
|
|
<bindings id="updatesBindings"
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
xmlns:xbl="http://www.mozilla.org/xbl">
|
|
|
|
<binding id="link">
|
|
<implementation>
|
|
<property name="href"
|
|
onget="return this.getAttribute('href');"
|
|
onset="this.setAttribute('href', val); return val;"/>
|
|
</implementation>
|
|
<handlers>
|
|
<handler event="keypress" keycode="VK_ENTER" action="this.click()" />
|
|
<handler event="keypress" keycode="VK_RETURN" action="this.click()" />
|
|
<handler event="click">
|
|
<![CDATA[
|
|
if (event.button != 0)
|
|
return;
|
|
|
|
# If we're not a browser, use the external protocol service to load the URI.
|
|
#ifndef MOZ_PHOENIX
|
|
var uri = Components.classes["@mozilla.org/network/io-service;1"]
|
|
.getService(Components.interfaces.nsIIOService)
|
|
.newURI(this.getAttribute("href"), null, null);
|
|
|
|
var protocolSvc = Components.classes["@mozilla.org/uriloader/external-protocol-service;1"]
|
|
.getService(Components.interfaces.nsIExternalProtocolService);
|
|
if (protocolSvc.isExposedProtocol(uri.scheme))
|
|
protocolSvc.loadUrl(uri);
|
|
# If we're a browser, open a new browser window instead.
|
|
#else
|
|
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
|
.getService(Components.interfaces.nsIWindowWatcher);
|
|
var ary = Components.classes["@mozilla.org/supports-array;1"]
|
|
.createInstance(Components.interfaces.nsISupportsArray);
|
|
var url = Components.classes["@mozilla.org/supports-string;1"]
|
|
.createInstance(Components.interfaces.nsISupportsString);
|
|
url.data = this.getAttribute("href")
|
|
ary.AppendElement(url);
|
|
|
|
ww.openWindow(null, "chrome://browser/content/browser.xul",
|
|
"_blank", "chrome,all,dialog=no", ary);
|
|
#endif
|
|
]]>
|
|
</handler>
|
|
</handlers>
|
|
</binding>
|
|
|
|
<binding id="update" extends="chrome://mozapps/content/shared/richview.xml#richview-item">
|
|
<resources>
|
|
<stylesheet src="chrome://mozapps/content/update/updates.css"/>
|
|
</resources>
|
|
<content>
|
|
<xul:hbox pack="start">
|
|
<xul:label class="update-item-name" xbl:inherits="value=name" crop="right" flex="1"/>
|
|
<xul:link class="update-item-details" xbl:inherits="href=detailsURL">&details.link;</xul:link>
|
|
</xul:hbox>
|
|
<xul:deck anonid="modeDeck">
|
|
<xul:label class="update-item-status" xbl:inherits="value=status" flex="1"/>
|
|
<xul:vbox>
|
|
<xul:progressmeter class="update-item-progress" anonid="progress"
|
|
mode="undetermined"/>
|
|
<xul:hbox align="center">
|
|
<xul:label class="update-item-status" xbl:inherits="value=status" flex="1" crop="right"/>
|
|
<xul:button class="update-item-pause" anonid="pause-button"
|
|
label="&pause.label;" accesskey="&pause.accesskey;"/>
|
|
</xul:hbox>
|
|
</xul:vbox>
|
|
</xul:deck>
|
|
<xul:stringbundle anonid="strings"
|
|
src="chrome://mozapps/locale/update/updates.properties"/>
|
|
</content>
|
|
<implementation>
|
|
<field name="_update">null</field>
|
|
<field name="_strings">
|
|
document.getAnonymousElementByAttribute(this, "anonid", "strings");
|
|
</field>
|
|
<field name="_progressBar">
|
|
document.getAnonymousElementByAttribute(this, "anonid", "progress");
|
|
</field>
|
|
<field name="_modeDeck">
|
|
document.getAnonymousElementByAttribute(this, "anonid", "modeDeck");
|
|
</field>
|
|
<method name="setUpdate">
|
|
<parameter name="update"/>
|
|
<body><![CDATA[
|
|
this._update = update;
|
|
|
|
this.setAttribute("name", update.name);
|
|
this.setAttribute("detailsURL", update.detailsURL);
|
|
this.state = update.state;
|
|
]]></body>
|
|
</method>
|
|
|
|
<property name="progress">
|
|
<getter><![CDATA[
|
|
return parseInt(this._progressBar.getAttribute("value"));
|
|
]]></getter>
|
|
<setter><![CDATA[
|
|
this._progressBar.setAttribute("value", val);
|
|
]]></setter>
|
|
</property>
|
|
|
|
<field name="_started">false</field>
|
|
<method name="startDownload">
|
|
<body><![CDATA[
|
|
if (!this._started) {
|
|
this._progressBar.setAttribute("mode", "normal");
|
|
this._started = true;
|
|
}
|
|
]]></body>
|
|
</method>
|
|
|
|
<method name="stopDownload">
|
|
<body><![CDATA[
|
|
if (this._started) {
|
|
this._progressBar.setAttribute("mode", "undetermined");
|
|
this._started = false;
|
|
}
|
|
]]></body>
|
|
</method>
|
|
|
|
<property name="state">
|
|
<getter><![CDATA[
|
|
return this.getAttribute("state");
|
|
]]></getter>
|
|
<setter><![CDATA[
|
|
this.setAttribute("state", val);
|
|
this._modeDeck.setAttribute("selectedIndex", val == "downloading" ? 1 : 0);
|
|
if (val == "failed") {
|
|
var failed = this._strings.getString("statusFailed");
|
|
this.setAttribute("status", failed);
|
|
}
|
|
else if (val != "downloading") {
|
|
var sdf =
|
|
Components.classes["@mozilla.org/intl/scriptabledateformat;1"].
|
|
getService(Components.interfaces.nsIScriptableDateFormat);
|
|
var installDate = new Date(this._update.installDate);
|
|
var dateString = sdf.FormatDateTime("", sdf.dateFormatLong,
|
|
sdf.timeFormatSeconds,
|
|
date.getFullYear(),
|
|
date.getMonth() + 1,
|
|
date.getDate(),
|
|
date.getHours(),
|
|
date.getMinutes(),
|
|
date.getSeconds());
|
|
dateString = this._strings.getFormattedString("statusSucceededFormat",
|
|
[dateString]);
|
|
this.setAttribute("status", dateString);
|
|
}
|
|
return val;
|
|
]]></setter>
|
|
</property>
|
|
<field name="eventPrefix">"update-"</field>
|
|
</implementation>
|
|
<handlers>
|
|
<handler event="command"><![CDATA[
|
|
if (event.originalTarget.getAttribute("anonid") == "pause-button")
|
|
this.fireEvent("pause");
|
|
]]></handler>
|
|
</handlers>
|
|
</binding>
|
|
|
|
<binding id="license">
|
|
<content>
|
|
<xul:vbox flex="1" class="loadingBox">
|
|
<xul:hbox align="start">
|
|
<xul:image class="licenseLoadingThrobber" xbl:inherits="state"/>
|
|
<xul:vbox flex="1">
|
|
<xul:description flex="1" class="licenseLoadingMessage" crop="right"/>
|
|
</xul:vbox>
|
|
</xul:hbox>
|
|
</xul:vbox>
|
|
<xul:vbox flex="1">
|
|
<xul:browser class="licenseContent" flex="1"/>
|
|
</xul:vbox>
|
|
<xul:stringbundle anonid="strings"
|
|
src="chrome://mozapps/locale/update/updates.properties"/>
|
|
</content>
|
|
<implementation>
|
|
<constructor>
|
|
if (this.hasAttribute("url"))
|
|
this.url = this.getAttribute("url");
|
|
</constructor>
|
|
|
|
<field name="_request">null</field>
|
|
<field name="_message">
|
|
document.getAnonymousElementByAttribute(this, "class", "licenseLoadingMessage");
|
|
</field>
|
|
<field name="_content">
|
|
document.getAnonymousElementByAttribute(this, "class", "licenseContent");
|
|
</field>
|
|
<field name="_strings">
|
|
document.getAnonymousElementByAttribute(this, "anonid", "strings");
|
|
</field>
|
|
|
|
<method name="_setMessageValue">
|
|
<parameter name="value"/>
|
|
<body><![CDATA[
|
|
while (this._message.hasChildNodes())
|
|
this._message.removeChild(this._message.firstChild);
|
|
this._message.appendChild(document.createTextNode(value));
|
|
]]></body>
|
|
</method>
|
|
|
|
<method name="onError">
|
|
<parameter name="event"/>
|
|
<body><![CDATA[
|
|
var status = this._request.status;
|
|
var statusText = this._request.statusText
|
|
LOG("license.onError: error during load, status code = " + status +
|
|
", message: " + statusText);
|
|
|
|
if (status == 404)
|
|
statusText = this._strings.getString("license404Error");
|
|
|
|
this._setMessageValue(statusText);
|
|
this.setAttribute("state", "error");
|
|
]]></body>
|
|
</method>
|
|
<method name="onLoad">
|
|
<parameter name="event"/>
|
|
<body><![CDATA[
|
|
LOG("license.onLoad: request completed downloading document");
|
|
this.setAttribute("selectedIndex", "1");
|
|
var doc = this._content.contentWindow.document;
|
|
doc.documentElement.innerHTML = this._request.responseText;
|
|
|
|
var e = document.createEvent("Events");
|
|
e.initEvent("load", false, true);
|
|
this.dispatchEvent(e);
|
|
]]></body>
|
|
</method>
|
|
<method name="onProgress">
|
|
<parameter name="event"/>
|
|
<body><![CDATA[
|
|
LOG("license.onProgress: download progress: " + event.position + "/" + event.totalSize);
|
|
]]></body>
|
|
</method>
|
|
|
|
<property name="url">
|
|
<getter><![CDATA[
|
|
return this.getAttribute("url");
|
|
]]></getter>
|
|
<setter><![CDATA[
|
|
this.setAttribute("url", val);
|
|
|
|
this._request = Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"]
|
|
.createInstance(Components.interfaces.nsIXMLHttpRequest);
|
|
this._request.open("GET", val, true);
|
|
this._request.setRequestHeader("Cache-Control", "no-cache");
|
|
|
|
var self = this;
|
|
this._request.onerror = function(event) { self.onError(event); };
|
|
this._request.onload = function(event) { self.onLoad(event); };
|
|
this._request.onprogress = function(event) { self.onProgress(event); };
|
|
|
|
this.setAttribute("state", "loading");
|
|
this._setMessageValue(this._strings.getString("downloadingLicense"));
|
|
|
|
LOG("license.set_url: sending request to " + val);
|
|
this._request.send(null);
|
|
]]></setter>
|
|
</property>
|
|
|
|
<method name="stopDownloading">
|
|
<body><![CDATA[
|
|
const READY_STATE_COMPLETED = 4
|
|
if (this._request &&
|
|
this._request.readyState != READY_STATE_COMPLETED)
|
|
this._request.abort();
|
|
]]></body>
|
|
</method>
|
|
</implementation>
|
|
</binding>
|
|
</bindings>
|
|
|