various updates from the branch - extension manager, update service, etc.
git-svn-id: svn://10.0.0.236/trunk@158178 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
301e39135c
commit
0793d7d778
@ -30,8 +30,7 @@ function init()
|
||||
// Description
|
||||
var descriptionArc = rdfs.GetResource(EM_NS("description"));
|
||||
var description = gExtensionDB.GetTarget(extension, descriptionArc, true);
|
||||
if (description)
|
||||
description = description.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
description = description.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
// Home Page URL
|
||||
var homepageArc = rdfs.GetResource(EM_NS("homepageURL"));
|
||||
var homepage = gExtensionDB.GetTarget(extension, homepageArc, true);
|
||||
@ -41,8 +40,7 @@ function init()
|
||||
// Creator
|
||||
var creatorArc = rdfs.GetResource(EM_NS("creator"));
|
||||
var creator = gExtensionDB.GetTarget(extension, creatorArc, true);
|
||||
if (creator)
|
||||
creator = creator.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
creator = creator.QueryInterface(Components.interfaces.nsIRDFLiteral).Value;
|
||||
|
||||
document.documentElement.setAttribute("title", extensionsStrings.getFormattedString("aboutWindowTitle", [name]));
|
||||
var extensionName = document.getElementById("extensionName");
|
||||
|
||||
@ -17,7 +17,6 @@ var gObserverIndex = -1;
|
||||
const PREF_APP_ID = "app.id";
|
||||
const PREF_EXTENSIONS_GETMORETHEMESURL = "extensions.getMoreThemesURL";
|
||||
const PREF_EXTENSIONS_GETMOREEXTENSIONSURL = "extensions.getMoreExtensionsURL";
|
||||
const PREF_EM_LAST_SELECTED_SKIN = "extensions.lastSelectedSkin";
|
||||
const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
@ -93,9 +92,10 @@ function Startup()
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
if (!isExtensions) {
|
||||
gExtensionsView.addEventListener("richview-select", onThemeSelect, false);
|
||||
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
gCurrentTheme = cr.getSelectedSkin("global");
|
||||
try {
|
||||
gCurrentTheme = pref.getCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN);
|
||||
}
|
||||
catch (e) { gCurrentTheme = "classic/1.0"; }
|
||||
|
||||
var useThemeButton = document.getElementById("useThemeButton");
|
||||
useThemeButton.hidden = false;
|
||||
@ -259,7 +259,6 @@ XPInstallDownloadManager.prototype = {
|
||||
element.setAttribute("state", "installing");
|
||||
break;
|
||||
case nsIXPIProgressDialog.INSTALL_DONE:
|
||||
dump("*** state change = " + aURL + ", state = " + aState + ", value = " + aValue + "\n");
|
||||
element.setAttribute("state", "done");
|
||||
var msg;
|
||||
if (aValue != 0) {
|
||||
@ -569,10 +568,6 @@ var gExtensionsViewController = {
|
||||
case "cmd_movedn":
|
||||
var children = gExtensionsView.children;
|
||||
return (children[children.length-1] != selectedItem);
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
case "cmd_install":
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
},
|
||||
@ -604,24 +599,17 @@ var gExtensionsViewController = {
|
||||
cmd_useTheme: function ()
|
||||
{
|
||||
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
gCurrentTheme = gExtensionsView.selected.getAttribute("internalName");
|
||||
var inUse = cr.isSkinSelected(gCurrentTheme , true);
|
||||
if (inUse == Components.interfaces.nsIChromeRegistry.FULL)
|
||||
return;
|
||||
|
||||
pref.setCharPref(PREF_GENERAL_SKINS_SELECTEDSKIN, gCurrentTheme);
|
||||
|
||||
// Set this pref so the user can reset the theme in safe mode
|
||||
pref.setCharPref(PREF_EM_LAST_SELECTED_SKIN, gCurrentTheme);
|
||||
cr.selectSkin(gCurrentTheme, true);
|
||||
cr.refreshSkins();
|
||||
|
||||
|
||||
// disable the useThemeButton
|
||||
gExtensionsViewController.onCommandUpdate();
|
||||
},
|
||||
|
||||
cmd_options: function ()
|
||||
@ -724,74 +712,9 @@ var gExtensionsViewController = {
|
||||
{
|
||||
gExtensionManager.enableExtension(stripPrefix(gExtensionsView.selected.id));
|
||||
},
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
cmd_install: function()
|
||||
{
|
||||
if (gWindowState == "extensions")
|
||||
installExtension();
|
||||
else
|
||||
installSkin();
|
||||
},
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
///////////////////////////////////////////////////////////////
|
||||
// functions to support installing of themes in thunderbird
|
||||
///////////////////////////////////////////////////////////////
|
||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||
const nsIIOService = Components.interfaces.nsIIOService;
|
||||
const nsIFileProtocolHandler = Components.interfaces.nsIFileProtocolHandler;
|
||||
const nsIURL = Components.interfaces.nsIURL;
|
||||
|
||||
function installSkin()
|
||||
{
|
||||
// 1) Prompt the user for the location of the theme to install.
|
||||
var extensionsStrings = document.getElementById("extensionsStrings");
|
||||
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
|
||||
fp.init(window, extensionsStrings.getString("installThemePickerTitle"), nsIFilePicker.modeOpen);
|
||||
|
||||
|
||||
fp.appendFilter(extensionsStrings.getString("themesFilter"), "*.jar");
|
||||
fp.appendFilters(nsIFilePicker.filterAll);
|
||||
|
||||
var ret = fp.show();
|
||||
if (ret == nsIFilePicker.returnOK)
|
||||
{
|
||||
var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(nsIIOService);
|
||||
var fileProtocolHandler =
|
||||
ioService.getProtocolHandler("file").QueryInterface(nsIFileProtocolHandler);
|
||||
var url = fileProtocolHandler.newFileURI(fp.file).QueryInterface(nsIURL);
|
||||
InstallTrigger.installChrome(InstallTrigger.SKIN, url.spec, decodeURIComponent(url.fileBaseName));
|
||||
}
|
||||
}
|
||||
|
||||
function installExtension()
|
||||
{
|
||||
var extensionsStrings = document.getElementById("extensionsStrings");
|
||||
|
||||
var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);
|
||||
fp.init(window, extensionsStrings.getString("installExtensionPickerTitle"), nsIFilePicker.modeOpen);
|
||||
|
||||
fp.appendFilter(extensionsStrings.getString("extensionFilter"), "*.xpi");
|
||||
|
||||
fp.appendFilters(nsIFilePicker.filterAll);
|
||||
|
||||
var ret = fp.show();
|
||||
if (ret == nsIFilePicker.returnOK)
|
||||
{
|
||||
var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(nsIIOService);
|
||||
var fileProtocolHandler =
|
||||
ioService.getProtocolHandler("file").QueryInterface(nsIFileProtocolHandler);
|
||||
var url = fileProtocolHandler.newFileURI(fp.file).QueryInterface(nsIURL);
|
||||
var xpi = {};
|
||||
xpi[decodeURIComponent(url.fileBaseName)] = url.spec;
|
||||
InstallTrigger.install(xpi);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
|
||||
@ -69,11 +69,7 @@
|
||||
</xul:vbox>
|
||||
<xul:vbox pack="start">
|
||||
<xul:image class="extension-button" anonid="options-button"
|
||||
#ifdef XP_WIN
|
||||
tooltiptext="&options.tooltip;"
|
||||
#else
|
||||
tooltiptext="&optionsUnix.tooltip;"
|
||||
#endif
|
||||
onclick="gExtensionsViewController.doCommand('cmd_options');"/>
|
||||
<xul:image class="extension-button" anonid="about-button"
|
||||
tooltiptext="&about.tooltip;"
|
||||
|
||||
@ -72,7 +72,7 @@
|
||||
oncommand="gExtensionsViewController.doCommand('cmd_close');"/>
|
||||
<key id="key_about" key="&cmd.info.commandKey;" modifiers="accel" command="cmd_about"
|
||||
oncommand="gExtensionsViewController.doCommand('cmd_about');"/>
|
||||
<key id="key_options" key="&cmd.options.commandKey;" modifiers="accel" command="cmd_options"
|
||||
<key id="key_options" key="&cmd.options.commandKey;" modifiers="accel" command="cmd_options"
|
||||
oncommand="gExtensionsViewController.doCommand('cmd_options');"/>
|
||||
</keyset>
|
||||
|
||||
@ -85,9 +85,6 @@
|
||||
<command id="cmd_options"/>
|
||||
<command id="cmd_about"/>
|
||||
<command id="cmd_homepage"/>
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
<command id="cmd_install"/>
|
||||
#endif
|
||||
<command id="cmd_uninstall"/>
|
||||
<command id="cmd_update"/>
|
||||
<command id="cmd_enable"/>
|
||||
@ -102,11 +99,7 @@
|
||||
<menuitem id="menuitem_useTheme" default="true" command="cmd_useTheme"
|
||||
label="&cmd.useTheme.label;" accesskey="&cmd.useTheme.accesskey;"/>
|
||||
<menuitem id="menuitem_options" default="true" command="cmd_options"
|
||||
#ifdef XP_WIN
|
||||
label="&cmd.options.label;" accesskey="&cmd.options.accesskey;"/>
|
||||
#else
|
||||
label="&cmd.optionsUnix.label;" accesskey="&cmd.optionsUnix.accesskey;"/>
|
||||
#endif
|
||||
<menuitem id="menuitem_homepage" command="cmd_homepage"
|
||||
label="&cmd.homepage.label;" accesskey="&cmd.homepage.accesskey;"/>
|
||||
<menuitem id="menuitem_about" command="cmd_about"
|
||||
@ -249,11 +242,6 @@
|
||||
<hbox>
|
||||
<hbox id="commandBar" flex="1" align="center">
|
||||
<hbox>
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
<button id="installButton"
|
||||
label="&cmd.install.label;" accesskey="&cmd.install.accesskey;" tooltiptext="&cmd.install.tooltip;"
|
||||
command="cmd_install"/>
|
||||
#endif
|
||||
<button id="uninstallButton"
|
||||
label="&cmd.uninstall.label;" accesskey="&cmd.uninstall.accesskey;" tooltiptext="&cmd.uninstall.tooltip;"
|
||||
command="cmd_uninstall"/>
|
||||
|
||||
@ -14,16 +14,10 @@
|
||||
<!ENTITY cmd.useTheme.label " Use Theme">
|
||||
<!ENTITY cmd.useTheme.accesskey "U">
|
||||
<!ENTITY cmd.useTheme.tooltip "Changes &brandShortName;'s theme.">
|
||||
<!-- the following command bar items are used by thunderbird only -->
|
||||
<!ENTITY cmd.install.label "Install">
|
||||
<!ENTITY cmd.install.tooltip "Install an extension">
|
||||
<!ENTITY cmd.install.accesskey "n">
|
||||
|
||||
<!-- Context Menu Options: Extension -->
|
||||
<!ENTITY cmd.options.label "Options">
|
||||
<!ENTITY cmd.options.accesskey "O">
|
||||
<!ENTITY cmd.optionsUnix.label "Preferences">
|
||||
<!ENTITY cmd.optionsUnix.accesskey "r">
|
||||
<!ENTITY cmd.homepage.label "Visit Home Page">
|
||||
<!ENTITY cmd.homepage.accesskey "H">
|
||||
<!ENTITY cmd.about.label "About this Extension">
|
||||
@ -45,7 +39,6 @@
|
||||
|
||||
<!-- Extension Items -->
|
||||
<!ENTITY options.tooltip "Options">
|
||||
<!ENTITY optionsUnix.tooltip "Preferences">
|
||||
<!ENTITY about.tooltip "About">
|
||||
<!ENTITY homepage.tooltip "Home Page">
|
||||
|
||||
|
||||
@ -12,9 +12,9 @@ queryUninstallExtensionMessage=If you uninstall %S, the functionality it offers
|
||||
queryUninstallThemeMessage=Do you want to uninstall %S?
|
||||
queryUninstallTitle=Uninstall %S
|
||||
|
||||
update.extensions.wsdl=http://update.mozilla.org:8080/axis/services/VersionCheck?wsdl
|
||||
extensions.getMoreExtensionsURL=http://update.mozilla.org/extensions/?application=%APPID%
|
||||
extensions.getMoreThemesURL=http://update.mozilla.org/themes/?application=%APPID%
|
||||
update.extensions.wsdl=http://localhost:8080/axis/services/VersionCheck?wsdl
|
||||
extensions.getMoreExtensionsURL=http://update.mozilla.org/extensions.php?app=%APPID%
|
||||
extensions.getMoreThemesURL=http://update.mozilla.org/themes.php?app=%APPID%
|
||||
|
||||
themesTitle=Themes
|
||||
extensionsTitle=Extensions
|
||||
@ -42,11 +42,3 @@ malformedTitle=Malformed File
|
||||
|
||||
invalidVersionMessage=%S could not install "%S" because its version information ("%S") is invalid. Please contact the author about this problem.
|
||||
invalidVersionTitle=Invalid Version
|
||||
|
||||
# The following are used by Thunderbird only in order to provide a way to load
|
||||
# extension and JAR files.
|
||||
|
||||
extensionFilter=Extensions (*.xpi)
|
||||
themesFilter=Themes (*.jar)
|
||||
installThemePickerTitle=Select a theme to install
|
||||
installExtensionPickerTitle=Select an extension to install
|
||||
|
||||
@ -61,8 +61,6 @@ interface nsIExtensionManager : nsISupports
|
||||
*/
|
||||
boolean checkForMismatches();
|
||||
|
||||
void handleCommandLineArgs();
|
||||
|
||||
// Installing Extensions
|
||||
const unsigned long FLAG_INSTALL_PROFILE = 0x01;
|
||||
const unsigned long FLAG_INSTALL_GLOBAL = 0x02;
|
||||
|
||||
79
mozilla/toolkit/mozapps/extensions/service/Extension.java
Normal file
79
mozilla/toolkit/mozapps/extensions/service/Extension.java
Normal file
@ -0,0 +1,79 @@
|
||||
package org.mozilla.update.extensions;
|
||||
|
||||
public class Extension
|
||||
{
|
||||
private int row;
|
||||
private java.lang.String id;
|
||||
private java.lang.String version;
|
||||
private java.lang.String name;
|
||||
private java.lang.String xpiURL;
|
||||
|
||||
public Extension()
|
||||
{
|
||||
}
|
||||
|
||||
public int getRow()
|
||||
{
|
||||
return row;
|
||||
}
|
||||
|
||||
public void setRow(int row)
|
||||
{
|
||||
this.row = row;
|
||||
}
|
||||
|
||||
public java.lang.String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(java.lang.String id)
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public java.lang.String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(java.lang.String version)
|
||||
{
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public java.lang.String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(java.lang.String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public java.lang.String getXpiURL()
|
||||
{
|
||||
return xpiURL;
|
||||
}
|
||||
|
||||
public void setXpiURL(java.lang.String xpiURL)
|
||||
{
|
||||
this.xpiURL = xpiURL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//public class Extension
|
||||
//{
|
||||
// public Extension()
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// public int row;
|
||||
// public String id;
|
||||
// public String version;
|
||||
// public String name;
|
||||
// public String xpiURL;
|
||||
//}
|
||||
|
||||
@ -47,7 +47,6 @@ const PREF_UPDATE_COUNT = "update.extensions.count";
|
||||
const PREF_UPDATE_EXT_WSDL_URI = "update.extensions.wsdl";
|
||||
const PREF_EM_WASINSAFEMODE = "extensions.wasInSafeMode";
|
||||
const PREF_EM_DISABLEDOBSOLETE = "extensions.disabledObsolete";
|
||||
const PREF_EM_LAST_SELECTED_SKIN = "extensions.lastSelectedSkin";
|
||||
const PREF_GENERAL_SKINS_SELECTEDSKIN = "general.skins.selectedSkin";
|
||||
|
||||
const DIR_EXTENSIONS = "extensions";
|
||||
@ -444,7 +443,7 @@ nsInstallLogWriter.prototype = {
|
||||
this._fos.write(line, line.length);
|
||||
},
|
||||
|
||||
registerChrome: function (aProviderName, aChromeType, aIsProfile)
|
||||
registerChrome: function (aProviderName, aFileURL, aChromeType, aIsProfile)
|
||||
{
|
||||
var profile = aIsProfile ? "profile" : "global";
|
||||
// register\tprofile\tpackage\t<provider_name>
|
||||
@ -486,6 +485,7 @@ nsInstallLogReader.prototype = {
|
||||
|
||||
var fis = Components.classes["@mozilla.org/network/file-input-stream;1"]
|
||||
.createInstance(Components.interfaces.nsIFileInputStream);
|
||||
dumpFile(this.uninstallLog);
|
||||
fis.init(this.uninstallLog, -1, -1, false);
|
||||
var lis = fis.QueryInterface(Components.interfaces.nsILineInputStream);
|
||||
var line = { value: "" };
|
||||
@ -498,29 +498,7 @@ nsInstallLogReader.prototype = {
|
||||
while (more);
|
||||
fis.close();
|
||||
|
||||
// Now that we've closed the stream we can remove all the files, unregister
|
||||
// chrome, etc.
|
||||
//
|
||||
// The list of lines we pass to the uninstall handler should be in this
|
||||
// order:
|
||||
// 1) File additions
|
||||
// 2) Chrome Package Registrations
|
||||
// 3) Chrome Skin and Locale Registrations
|
||||
//
|
||||
// They must be in this order since skins and locales rely on packages, and
|
||||
// the packages they rely on is not stored in the registration line so we
|
||||
// simply "deselect" for every package installed by the extension.
|
||||
var dependentLines = [];
|
||||
for (var i = 0; i < lines.length; ++i) {
|
||||
var parts = lines[i].split("\t");
|
||||
if (parts[1] == this.TOKEN_REGISTER_CHROME &&
|
||||
(parts[2] == this.CHROME_TYPE_SKIN ||
|
||||
parts[2] == this.CHROME_TYPE_LOCALE)) {
|
||||
dependentLines.push(lines.splice(i, 1));
|
||||
}
|
||||
}
|
||||
lines.concat(dependentLines);
|
||||
|
||||
// Now that we've closed the stream we can remove all the files
|
||||
for (var i = 0; i < lines.length; ++i)
|
||||
this._parseLine(lines[i]);
|
||||
},
|
||||
@ -534,16 +512,31 @@ nsInstallLogReader.prototype = {
|
||||
var filePD = aLine.substr(prefix.length, aLine.length);
|
||||
var lf = Components.classes["@mozilla.org/file/local;1"]
|
||||
.createInstance(Components.interfaces.nsILocalFile);
|
||||
lf.persistentDescriptor = filePD;
|
||||
this._listener.onAddFile(lf);
|
||||
try {
|
||||
lf.persistentDescriptor = filePD;
|
||||
this._listener.onAddFile(lf);
|
||||
}
|
||||
catch (e) {
|
||||
dump("*** nsInstallLogReader::_parseLine - failed to remove file\n");
|
||||
}
|
||||
break;
|
||||
case this.TOKEN_REGISTER_CHROME:
|
||||
var isProfile = parts[1] == this.TOKEN_PROFILE;
|
||||
this._listener.onRegisterChrome(parts[3], lf, parts[2], isProfile);
|
||||
try {
|
||||
this._listener.onRegisterChrome(parts[3], lf, parts[2], isProfile);
|
||||
}
|
||||
catch (e) {
|
||||
dump("*** nsInstallLogReader::_parseLine - failed to deregister chrome\n");
|
||||
}
|
||||
break;
|
||||
case this.TOKEN_SKIN:
|
||||
var isProfile = parts[1] == this.TOKEN_PROFILE;
|
||||
this._listener.onInstallSkin(parts[2], isProfile);
|
||||
try {
|
||||
this._listener.onInstallSkin(parts[2], isProfile);
|
||||
}
|
||||
catch (e) {
|
||||
dump("*** nsInstallLogReader::_parseLine - failed to uninstall skin\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -794,7 +787,7 @@ nsExtensionInstaller.prototype = {
|
||||
},
|
||||
|
||||
_registerChrome: function (aFile, aChromeType, aPath)
|
||||
{
|
||||
{
|
||||
var fileURL = getURLSpecFromFile(aFile);
|
||||
if (!aFile.isDirectory()) // .jar files
|
||||
fileURL = "jar:" + fileURL + "!/" + aPath;
|
||||
@ -816,80 +809,21 @@ nsExtensionInstaller.prototype = {
|
||||
cr.installLocale(fileURL, this._isProfile);
|
||||
type = this._writer.CHROME_TYPE_LOCALE;
|
||||
}
|
||||
var providerNames = this._getProviderNames(aFile, aPath, type);
|
||||
for (var i = 0; i < providerNames.length; ++i)
|
||||
this._writer.registerChrome(providerNames[i], type, this._isProfile);
|
||||
var providerName = this._getProviderName(aPath);
|
||||
this._writer.registerChrome(providerName, fileURL, type, this._isProfile);
|
||||
},
|
||||
|
||||
_getProviderNames: function (aFile, aPath, aType)
|
||||
_getProviderName: function (aPath)
|
||||
{
|
||||
if (aPath.charAt(aPath.length-1) != "/")
|
||||
aPath += "/";
|
||||
var fileName = aPath + "contents.rdf";
|
||||
var parts = aPath.split("/");
|
||||
|
||||
var providerNames = [];
|
||||
|
||||
var zipReader = Components.classes["@mozilla.org/libjar/zip-reader;1"]
|
||||
.createInstance(Components.interfaces.nsIZipReader);
|
||||
zipReader.init(aFile);
|
||||
zipReader.open();
|
||||
|
||||
try {
|
||||
zipReader.test(fileName);
|
||||
|
||||
// Extract the contents.rdf file at the location specified in the provider arc
|
||||
// and discover the list of provider names to register for that location.
|
||||
//
|
||||
// The contents.rdf file will look like this:
|
||||
//
|
||||
// <RDF:Seq about="urn:mozilla:<type>:root">
|
||||
// <RDF:li resource="urn:mozilla:<type>:itemName1"/>
|
||||
// <RDF:li resource="urn:mozilla:<type>:itemName2"/>
|
||||
// ..
|
||||
// </RDF:Seq>
|
||||
//
|
||||
// We need to explicitly walk this list here, we don't need to do so
|
||||
// for nsIXULChromeRegistry's |installPackage| method since that does
|
||||
// this same thing itself.
|
||||
var chromeManifest = getFile(this._extDirKey,
|
||||
[DIR_EXTENSIONS, DIR_TEMP,
|
||||
getRandomFileName("contents", "rdf")]);
|
||||
if (chromeManifest.exists())
|
||||
chromeManifest.remove(false);
|
||||
chromeManifest.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
|
||||
zipReader.extract(fileName, chromeManifest);
|
||||
|
||||
var rdf = Components.classes["@mozilla.org/rdf/rdf-service;1"]
|
||||
.getService(Components.interfaces.nsIRDFService);
|
||||
var fileURL = getURLSpecFromFile(chromeManifest);
|
||||
var ds = rdf.GetDataSourceBlocking(fileURL);
|
||||
|
||||
var ctr = Components.classes["@mozilla.org/rdf/container;1"]
|
||||
.createInstance(Components.interfaces.nsIRDFContainer);
|
||||
ctr.Init(ds, rdf.GetResource("urn:mozilla:" + aType + ":root"));
|
||||
|
||||
var items = ctr.GetElements();
|
||||
while (items.hasMoreElements()) {
|
||||
var item = items.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
|
||||
var nameArc = rdf.GetResource(CHROME_NS("name"));
|
||||
var name;
|
||||
if (ds.hasArcOut(item, nameArc))
|
||||
name = stringData(ds.GetTarget(item, nameArc, true));
|
||||
else {
|
||||
var parts = item.Value.split(":");
|
||||
name = parts[parts.length-1];
|
||||
}
|
||||
providerNames.push(name);
|
||||
}
|
||||
|
||||
chromeManifest.remove(false);
|
||||
for (var i = 1; i < parts.length; ++i) {
|
||||
var lastPath = parts[parts.length - i];
|
||||
if (lastPath == "")
|
||||
continue;
|
||||
return lastPath;
|
||||
}
|
||||
catch (e) { }
|
||||
|
||||
zipReader.close();
|
||||
|
||||
return providerNames;
|
||||
return lastPath;
|
||||
}
|
||||
};
|
||||
|
||||
@ -962,31 +896,17 @@ nsExtensionUninstaller.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
// XXXben - maybe we should find a way to
|
||||
_packagesForExtension: [],
|
||||
|
||||
onRegisterChrome: function (aProviderName, aFile, aChromeType, aIsProfile)
|
||||
{
|
||||
switch (aChromeType) {
|
||||
case this._reader.CHROME_TYPE_PACKAGE:
|
||||
this._packagesForExtension.push(aProviderName);
|
||||
this._cr.uninstallPackage(aProviderName, aIsProfile)
|
||||
break;
|
||||
case this._reader.CHROME_TYPE_SKIN:
|
||||
for (var i = 0; i < this._packagesForExtension.length; ++i) {
|
||||
this._cr.deselectSkinForPackage(aProviderName,
|
||||
this._packagesForExtension[i],
|
||||
aIsProfile);
|
||||
}
|
||||
// this._cr.uninstallSkin(aProviderName, aIsProfile)
|
||||
this._cr.uninstallSkin(aProviderName, aIsProfile)
|
||||
break;
|
||||
case this._reader.CHROME_TYPE_LOCALE:
|
||||
for (var i = 0; i < this._packagesForExtension.length; ++i) {
|
||||
this._cr.deselectLocaleForPackage(aProviderName,
|
||||
this._packagesForExtension[i],
|
||||
aIsProfile);
|
||||
}
|
||||
// this._cr.uninstallLocale(aProviderName, aIsProfile)
|
||||
this._cr.uninstallLocale(aProviderName, aIsProfile)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -1212,6 +1132,41 @@ function nsExtensionManager()
|
||||
os.addObserver(this, "profile-after-change", false);
|
||||
|
||||
ensureExtensionsFiles(false);
|
||||
|
||||
var cmdLineSvc = Components.classes["@mozilla.org/appshell/commandLineService;1"]
|
||||
.getService(Components.interfaces.nsICmdLineService);
|
||||
var globalExtension = cmdLineSvc.getCmdLineValue("-install-global-extension");
|
||||
if (globalExtension)
|
||||
this._checkForGlobalInstalls(globalExtension, nsIUpdateItem.TYPE_EXTENSION);
|
||||
|
||||
var globalTheme = cmdLineSvc.getCmdLineValue("-install-global-theme");
|
||||
if (globalTheme)
|
||||
this._checkForGlobalInstalls(globalTheme, nsIUpdateItem.TYPE_THEME);
|
||||
|
||||
var showList = cmdLineSvc.getCmdLineValue("-list-global-items");
|
||||
if (showList)
|
||||
this._showGlobalItemList();
|
||||
|
||||
var locked = cmdLineSvc.getCmdLineValue("-lock-item");
|
||||
if (locked) {
|
||||
this._ensureDS();
|
||||
this._ds.lockUnlockItem(locked, true);
|
||||
}
|
||||
|
||||
var unlocked = cmdLineSvc.getCmdLineValue("-unlock-item");
|
||||
if (unlocked) {
|
||||
this._ensureDS();
|
||||
this._ds.lockUnlockItem(unlocked, false);
|
||||
}
|
||||
|
||||
var needsToQuit = globalExtension || globalTheme || showList || locked || unlocked;
|
||||
if (needsToQuit) {
|
||||
// If we did a global install, shut down the app now.
|
||||
// XXXben - change to nsIAppStartup w/bsmedberg change
|
||||
var appStartup = Components.classes["@mozilla.org/appshell/appShellService;1"]
|
||||
.getService(Components.interfaces.nsIAppShellService);
|
||||
appStartup.quit(Components.interfaces.nsIAppShellService.eForceQuit);
|
||||
}
|
||||
}
|
||||
|
||||
nsExtensionManager.prototype = {
|
||||
@ -1283,7 +1238,7 @@ nsExtensionManager.prototype = {
|
||||
|
||||
var cmdLineSvc = Components.classes["@mozilla.org/appshell/commandLineService;1"]
|
||||
.getService(Components.interfaces.nsICmdLineService);
|
||||
var safeMode = cmdLineSvc.getCmdLineValue("-safe-mode") != null;
|
||||
var safeMode = cmdLineSvc.getCmdLineValue("-no-extensions") != null;
|
||||
if (!safeMode) {
|
||||
var wasInSafeModeFile = getFile(KEY_PROFILEDIR, [DIR_EXTENSIONS, FILE_WASINSAFEMODE]);
|
||||
if (wasInSafeModeFile.exists()) {
|
||||
@ -1291,20 +1246,6 @@ nsExtensionManager.prototype = {
|
||||
var win = this._showProgressWindow();
|
||||
this._ensureDS();
|
||||
|
||||
// Retrieve the skin that was selected prior to entering safe mode
|
||||
// and select it.
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var lastSelectedSkin = KEY_DEFAULT_THEME;
|
||||
try {
|
||||
lastSelectedSkin = pref.getCharPref(PREF_EM_LAST_SELECTED_SKIN);
|
||||
pref.clearUserPref(PREF_EM_LAST_SELECTED_SKIN);
|
||||
}
|
||||
catch (e) { }
|
||||
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
cr.selectSkin(lastSelectedSkin, true);
|
||||
|
||||
// Walk the list of extensions and re-activate overlays for packages
|
||||
// that aren't disabled.
|
||||
var items = this._ds.getItemsWithFlagUnset("disabled", nsIUpdateItem.TYPE_EXTENSION);
|
||||
@ -1313,12 +1254,6 @@ nsExtensionManager.prototype = {
|
||||
|
||||
wasInSafeModeFile.remove(false);
|
||||
|
||||
this._writeDefaults(true);
|
||||
try {
|
||||
this._writeDefaults(false);
|
||||
}
|
||||
catch (e) { }
|
||||
|
||||
win.close();
|
||||
|
||||
needsRestart = true;
|
||||
@ -1332,80 +1267,23 @@ nsExtensionManager.prototype = {
|
||||
|
||||
// Enter safe mode
|
||||
this._ensureDS();
|
||||
|
||||
// Save the current theme (assumed to be the theme that styles the global
|
||||
// package) and re-select the default theme ("classic/1.0")
|
||||
var pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
var cr = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Components.interfaces.nsIXULChromeRegistry);
|
||||
if (!pref.prefHasUserValue(PREF_EM_LAST_SELECTED_SKIN)) {
|
||||
pref.setCharPref(PREF_EM_LAST_SELECTED_SKIN,
|
||||
cr.getSelectedSkin("global"));
|
||||
cr.selectSkin(KEY_DEFAULT_THEME, true);
|
||||
}
|
||||
|
||||
var items = this._ds.getItemList(null, nsIUpdateItem.TYPE_EXTENSION, {});
|
||||
for (var i = 0; i < items.length; ++i)
|
||||
this._finalizeEnableDisable(items[i].id, true);
|
||||
|
||||
this._ds.safeMode = true;
|
||||
|
||||
this._writeDefaults(true);
|
||||
try {
|
||||
this._writeDefaults(false);
|
||||
}
|
||||
catch (e) { }
|
||||
|
||||
needsRestart = true;
|
||||
|
||||
var wasInSafeModeFile = getFile(KEY_PROFILEDIR, [DIR_EXTENSIONS, FILE_WASINSAFEMODE]);
|
||||
if (!wasInSafeModeFile.exists())
|
||||
wasInSafeModeFile.create(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0644);
|
||||
else {
|
||||
// If the "Safe Mode" file already exists, then we are in the second launch of an
|
||||
// app launched with -safe-mode and so we don't want to provoke any further
|
||||
// restarts or re-create the file, just continue starting normally.
|
||||
needsRestart = false;
|
||||
}
|
||||
|
||||
win.close();
|
||||
|
||||
needsRestart = true;
|
||||
}
|
||||
return needsRestart;
|
||||
},
|
||||
|
||||
handleCommandLineArgs: function ()
|
||||
{
|
||||
var cmdLineSvc = Components.classes["@mozilla.org/appshell/commandLineService;1"]
|
||||
.getService(Components.interfaces.nsICmdLineService);
|
||||
var globalExtension = cmdLineSvc.getCmdLineValue("-install-global-extension");
|
||||
if (globalExtension)
|
||||
this._checkForGlobalInstalls(globalExtension, nsIUpdateItem.TYPE_EXTENSION);
|
||||
|
||||
var globalTheme = cmdLineSvc.getCmdLineValue("-install-global-theme");
|
||||
if (globalTheme)
|
||||
this._checkForGlobalInstalls(globalTheme, nsIUpdateItem.TYPE_THEME);
|
||||
|
||||
var showList = cmdLineSvc.getCmdLineValue("-list-global-items");
|
||||
if (showList)
|
||||
this._showGlobalItemList();
|
||||
|
||||
var locked = cmdLineSvc.getCmdLineValue("-lock-item");
|
||||
if (locked) {
|
||||
this._ensureDS();
|
||||
this._ds.lockUnlockItem(locked, true);
|
||||
}
|
||||
|
||||
var unlocked = cmdLineSvc.getCmdLineValue("-unlock-item");
|
||||
if (unlocked) {
|
||||
this._ensureDS();
|
||||
this._ds.lockUnlockItem(unlocked, false);
|
||||
}
|
||||
|
||||
this._finishOperations();
|
||||
},
|
||||
|
||||
_cancelDownloads: function ()
|
||||
{
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
@ -1535,11 +1413,11 @@ nsExtensionManager.prototype = {
|
||||
dump(bundle.GetStringFromName("globalItemListExtensions"));
|
||||
var items = this.getItemList(null, nsIUpdateItem.TYPE_EXTENSION, {});
|
||||
for (var i = 0; i < items.length; ++i)
|
||||
dump(" " + items[i].id + " " + items[i].name + " " + items[i].version + "\n");
|
||||
dump(" " + items[i].id + " " + items[i].name + "\n");
|
||||
dump(bundle.GetStringFromName("globalItemListThemes"));
|
||||
items = this.getItemList(null, nsIUpdateItem.TYPE_THEME, {});
|
||||
for (var i = 0; i < items.length; ++i)
|
||||
dump(" " + items[i].id + " " + items[i].name + " " + items[i].version + "\n");
|
||||
dump(" " + items[i].id + " " + items[i].name + "\n");
|
||||
|
||||
dump("\n\n");
|
||||
},
|
||||
@ -2947,8 +2825,8 @@ nsExtensionsDataSource.prototype = {
|
||||
var newVersionInfo = newVersionInfos.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
var anon = this._rdf.GetAnonymousResource();
|
||||
targetDS.Assert(anon, idRes, aSourceDS.GetTarget(newVersionInfo, idRes, true), true);
|
||||
targetDS.Assert(anon, minVersionRes, aSourceDS.GetTarget(newVersionInfo, minVersionRes, true), true);
|
||||
targetDS.Assert(anon, maxVersionRes, aSourceDS.GetTarget(newVersionInfo, maxVersionRes, true), true);
|
||||
targetDS.Assert(anon, idRes, aSourceDS.GetTarget(newVersionInfo, minVersionRes, true), true);
|
||||
targetDS.Assert(anon, idRes, aSourceDS.GetTarget(newVersionInfo, maxVersionRes, true), true);
|
||||
targetDS.Assert(targetRes, property, anon, true);
|
||||
}
|
||||
}
|
||||
@ -3041,16 +2919,6 @@ nsExtensionsDataSource.prototype = {
|
||||
var item = this._rdf.GetResource(getItemPrefix(aItemType) + aItemID);
|
||||
var isProfile = this.isProfileItem(aItemID);
|
||||
var ds = isProfile ? this._profileExtensions : this._appExtensions;
|
||||
|
||||
var resources = ["targetApplication", "requires"];
|
||||
for (var i = 0; i < resources.length; ++i) {
|
||||
var targetApps = ds.GetTargets(item, this._emR(resources[i]), true);
|
||||
while (targetApps.hasMoreElements()) {
|
||||
var targetApp = targetApps.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
|
||||
this._cleanResource(targetApp, ds);
|
||||
}
|
||||
}
|
||||
|
||||
this._cleanResource(item, ds);
|
||||
},
|
||||
|
||||
@ -3229,11 +3097,8 @@ nsExtensionsDataSource.prototype = {
|
||||
// XXXben hack for pre-configured classic.jar
|
||||
if ((!chromeDir.exists() || !chromeDir.directoryEntries.hasMoreElements()) &&
|
||||
aSource.EqualsNode(this._rdf.GetResource("urn:mozilla:theme:{972ce4c6-7e08-4474-a285-3208198ce6fd}")))
|
||||
#ifdef MOZ_THUNDERBIRD
|
||||
jarFile = getFile(KEY_APPDIR, ["chrome", "qute.jar"]); // Thunderbird packages the default theme into qute.jar not classic.jar.
|
||||
#else
|
||||
jarFile = getFile(KEY_APPDIR, ["chrome", "classic.jar"]);
|
||||
#endif
|
||||
|
||||
if (chromeDir.directoryEntries.hasMoreElements() || jarFile) {
|
||||
if (!jarFile)
|
||||
jarFile = chromeDir.directoryEntries.getNext().QueryInterface(Components.interfaces.nsIFile);
|
||||
|
||||
@ -44,14 +44,19 @@
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
title="&errors.title;"
|
||||
onload="init()"
|
||||
style="width: 25em;"
|
||||
style="width: 28em;"
|
||||
buttons="cancel">
|
||||
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
function init()
|
||||
{
|
||||
var items = window.arguments[0];
|
||||
var state = window.arguments[0].state;
|
||||
var brandShortName = document.getElementById("brandStrings").getString("brandShortName");
|
||||
var str = document.getElementById("updateStrings").getFormattedString(state + "ErrorDescription", [brandShortName]);
|
||||
document.getElementById("intro").appendChild(document.createTextNode(str));
|
||||
|
||||
var items = window.arguments[0].errors;
|
||||
var listbox = document.getElementById("extensions");
|
||||
for (var i = 0; i < items.length; ++i) {
|
||||
if (items[i].error) {
|
||||
@ -69,10 +74,11 @@
|
||||
</script>
|
||||
|
||||
<stringbundleset id="updateSet">
|
||||
<stringbundle id="brandStrings" src="chrome://global/locale/brand.properties"/>
|
||||
<stringbundle id="updateStrings" src="chrome://mozapps/locale/update/update.properties"/>
|
||||
</stringbundleset>
|
||||
|
||||
<label>&errors.intro.title;</label>
|
||||
<description id="intro"/>
|
||||
<separator/>
|
||||
<listbox id="extensions" rows="7"/>
|
||||
<separator/>
|
||||
|
||||
@ -150,6 +150,37 @@ var gUpdateWizard = {
|
||||
this._setUpButton("back", aBackButton, aBackButtonIsDisabled);
|
||||
this._setUpButton("next", aNextButton, aNextButtonIsDisabled);
|
||||
this._setUpButton("cancel", aCancelButton, aCancelButtonIsDisabled);
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Update Errors
|
||||
errorItems: [],
|
||||
errorOnApp: false,
|
||||
|
||||
showErrors: function (aState, aErrors)
|
||||
{
|
||||
openDialog("chrome://mozapps/content/update/errors.xul", "",
|
||||
"modal", { state: aState, errors: aErrors });
|
||||
},
|
||||
|
||||
showUpdateCheckErrors: function ()
|
||||
{
|
||||
var errors = [];
|
||||
for (var i = 0; i < this.errorItems.length; ++i)
|
||||
errors.push({ name: this.errorItems[i].name, error: true });
|
||||
|
||||
if (this.errorOnApp) {
|
||||
var brandShortName = document.getElementById("brandStrings").getString("brandShortName");
|
||||
errors.push({ name: brandShortName, error: true });
|
||||
}
|
||||
|
||||
this.showErrors("checking", errors);
|
||||
},
|
||||
|
||||
checkForErrors: function (aElementIDToShow)
|
||||
{
|
||||
if (this.errorOnGeneric || this.errorItems.length > 0 || this.errorOnApp)
|
||||
document.getElementById(aElementIDToShow).hidden = false;
|
||||
}
|
||||
};
|
||||
|
||||
@ -198,6 +229,8 @@ var gUpdatePage = {
|
||||
for (var i = 0; i < this._messages.length; ++i)
|
||||
os.addObserver(this, this._messages[i], false);
|
||||
|
||||
gUpdateWizard.errorItems = [];
|
||||
|
||||
var updates = Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIUpdateService);
|
||||
updates.checkForUpdatesInternal(gUpdateWizard.items, gUpdateWizard.items.length,
|
||||
@ -231,6 +264,18 @@ var gUpdatePage = {
|
||||
var progress = document.getElementById("checking.progress");
|
||||
progress.value = Math.ceil(this._completeCount / gUpdateWizard.itemsToUpdate.length) * 100;
|
||||
|
||||
break;
|
||||
case "Update:Extension:Item-Error":
|
||||
if (aSubject) {
|
||||
var item = aSubject.QueryInterface(Components.interfaces.nsIUpdateItem);
|
||||
gUpdateWizard.errorItems.push(item);
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < gUpdateWizard.items.length; ++i) {
|
||||
if (!gUpdateWizard.items[i].updateRDF)
|
||||
gUpdateWizard.errorItems.push(gUpdateWizard.items[i]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "Update:Extension:Ended":
|
||||
// If we were passed a set of extensions/themes/other to update, this
|
||||
@ -245,6 +290,9 @@ var gUpdatePage = {
|
||||
// extension and app updates have completed.
|
||||
canFinish = true;
|
||||
break;
|
||||
case "Update:App:Error":
|
||||
gUpdateWizard.errorOnApp = true;
|
||||
break;
|
||||
case "Update:App:Ended":
|
||||
// The "Updates Found" page of the update wizard needs to know if it there are app
|
||||
// updates so it can list them first.
|
||||
@ -317,6 +365,8 @@ var gFoundPage = {
|
||||
if (item.iconURL != "")
|
||||
updateitem.icon = item.iconURL;
|
||||
}
|
||||
|
||||
gUpdateWizard.checkForErrors("updateCheckErrorNotFound");
|
||||
},
|
||||
|
||||
onCommand: function (aEvent)
|
||||
@ -436,8 +486,7 @@ var gErrorsPage = {
|
||||
|
||||
onShowErrors: function ()
|
||||
{
|
||||
openDialog("chrome://mozapps/content/update/errors.xul", "",
|
||||
"modal", gInstallingPage._objs);
|
||||
gUpdateWizard.showErrors("install", gInstallingPage._objs);
|
||||
}
|
||||
};
|
||||
|
||||
@ -462,7 +511,7 @@ var gFinishedPage = {
|
||||
iR2.hidden = true;
|
||||
fEC.hidden = true;
|
||||
}
|
||||
|
||||
|
||||
if (gSourceEvent == nsIUpdateService.SOURCE_EVENT_MISMATCH) {
|
||||
document.getElementById("finishedMismatch").hidden = false;
|
||||
document.getElementById("incompatibleAlert").hidden = false;
|
||||
@ -486,6 +535,8 @@ var gNoUpdatesPage = {
|
||||
document.getElementById("mismatchFinishedEnableChecking").hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
gUpdateWizard.checkForErrors("updateCheckErrorNotFound");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -115,6 +115,13 @@
|
||||
oncommand="gUpdateWizard.shouldAutoCheck = this.checked;"/>
|
||||
</vbox>
|
||||
</vbox>
|
||||
<hbox id="updateCheckErrorNotFound" hidden="true" align="center">
|
||||
<description flex="1">
|
||||
&updateCheckError.description;
|
||||
</description>
|
||||
<button label="&updateCheckError.label;" accesskey="&updateCheckError.accesskey;"
|
||||
oncommand="gUpdateWizard.showUpdateCheckErrors();"/>
|
||||
</hbox>
|
||||
|
||||
</wizardpage>
|
||||
|
||||
@ -128,7 +135,14 @@
|
||||
oncommand="gFoundPage.onCommand(event);"/>
|
||||
|
||||
<label>&found.instructions.label;</label>
|
||||
|
||||
|
||||
<hbox id="updateCheckErrorFound" hidden="true" align="center">
|
||||
<description flex="1">
|
||||
&updateCheckError.description;
|
||||
</description>
|
||||
<button label="&updateCheckError.label;" accesskey="&updateCheckError.accesskey;"
|
||||
oncommand="gUpdateWizard.showUpdateCheckErrors();"/>
|
||||
</hbox>
|
||||
</wizardpage>
|
||||
|
||||
<wizardpage id="appupdate" pageid="appupdate"
|
||||
|
||||
@ -18,90 +18,25 @@
|
||||
<xul:label xbl:inherits="value=updateCount" flex="1" crop="right"/>
|
||||
</xul:hbox>
|
||||
</content>
|
||||
<implementation implements="nsIObserver, nsIAlertListener">
|
||||
<implementation implements="nsIAlertListener">
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.addObserver(this, "Update:Ended", false);
|
||||
this.refreshData("null");
|
||||
this.refreshData(null);
|
||||
]]>
|
||||
</constructor>
|
||||
<destructor>
|
||||
<![CDATA[
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.removeObserver(this, "Update:Ended");
|
||||
]]>
|
||||
</destructor>
|
||||
|
||||
<!-- nsIObserver -->
|
||||
<method name="observe">
|
||||
<parameter name="aSubject"/>
|
||||
<parameter name="aTopic"/>
|
||||
<parameter name="aData"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (aTopic == "Update:Ended")
|
||||
this.refreshData(Components.interfaces.nsIUpdateService.SOURCE_EVENT_BACKGROUND);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="refreshData">
|
||||
<parameter name="aSourceEvent"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
var updates = Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIUpdateService);
|
||||
this.severity = updates.updateSeverity;
|
||||
this.updateCount = updates.updateCount;
|
||||
#ifdef XP_WIN
|
||||
if (parseInt(aSourceEvent) == Components.interfaces.nsIUpdateService.SOURCE_EVENT_BACKGROUND)
|
||||
this._showUpdateInfo();
|
||||
#endif
|
||||
var updates = Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIUpdateService);
|
||||
this.severity = updates.updateSeverity;
|
||||
this.updateCount = updates.updateCount;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
#ifdef XP_WIN
|
||||
<method name="_showUpdateInfo">
|
||||
<body>
|
||||
<![CDATA[
|
||||
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
||||
.getService(Components.interfaces.nsIStringBundleService);
|
||||
var bundle = sbs.createBundle("chrome://mozapps/locale/update/update.properties");
|
||||
|
||||
var alertTitle = bundle.GetStringFromName("updatesAvailableTitle");
|
||||
var alertText = bundle.GetStringFromName("updatesAvailableText");
|
||||
|
||||
var alerts = Components.classes["@mozilla.org/alerts-service;1"]
|
||||
.getService(Components.interfaces.nsIAlertsService);
|
||||
alerts.showAlertNotification("chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png",
|
||||
alertTitle, alertText, true, "", this);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<!-- nsIAlertListener -->
|
||||
<method name="onAlertFinished">
|
||||
<parameter name="aCookie"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="onAlertClickCallback">
|
||||
<parameter name="aCookie"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
this.showUpdates();
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
#endif
|
||||
|
||||
<method name="showUpdates">
|
||||
<body>
|
||||
<![CDATA[
|
||||
|
||||
@ -59,3 +59,8 @@
|
||||
<!ENTITY errors.details.label "Details">
|
||||
<!ENTITY errors.details.accesskey "D">
|
||||
|
||||
<!ENTITY updateCheckError.description "&brandShortName; encountered problems when trying to find
|
||||
updates for some items.">
|
||||
<!ENTITY updateCheckError.label "Details">
|
||||
<!ENTITY updateCheckError.accesskey "D">
|
||||
|
||||
|
||||
@ -14,3 +14,7 @@ updatesAvailableText=Click Here to View
|
||||
downloadingPrefix=Downloading: %S
|
||||
installingPrefix=Installing: %S
|
||||
closeButton=Close
|
||||
|
||||
installErrorDescription=The following components could not be installed due to errors (the file could not be downloaded, was corrupt, or for some other reason).
|
||||
checkingErrorDescription=%S could not check for updates to the following components (either the update server(s) did not respond, or the update service(s) were not found).
|
||||
|
||||
|
||||
@ -102,5 +102,7 @@ interface nsIVersionChecker : nsISupports
|
||||
// equal if A == B
|
||||
// +ve if A is newer
|
||||
long compare(in string aVersionA, in string aVersionB);
|
||||
|
||||
boolean isValidVersion(in string aVersion);
|
||||
};
|
||||
|
||||
|
||||
@ -243,6 +243,14 @@ nsUpdateService.prototype = {
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.notifyObservers(null, "Update:App:Ended", "");
|
||||
},
|
||||
|
||||
datasourceError: function ()
|
||||
{
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.notifyObservers(null, "Update:App:Error", "");
|
||||
os.notifyObservers(null, "Update:App:Ended", "");
|
||||
},
|
||||
|
||||
get updateCount()
|
||||
{
|
||||
@ -347,6 +355,10 @@ nsUpdateObserver.prototype = {
|
||||
observe: function (aSubject, aTopic, aData)
|
||||
{
|
||||
switch (aTopic) {
|
||||
case "Update:Extension:Started":
|
||||
// Reset the count
|
||||
this._pref.setIntPref(PREF_UPDATE_EXTENSIONS_COUNT, 0);
|
||||
break;
|
||||
case "Update:Extension:Item-Ended":
|
||||
this._pref.setIntPref(PREF_UPDATE_EXTENSIONS_COUNT,
|
||||
this._pref.getIntPref(PREF_UPDATE_EXTENSIONS_COUNT) + 1);
|
||||
@ -363,15 +375,58 @@ nsUpdateObserver.prototype = {
|
||||
// The Inline Browser Update UI uses this notification to refresh its update
|
||||
// UI if necessary.
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.notifyObservers(null, "Update:Ended", this._sourceEvent.toString());
|
||||
|
||||
// Show update notification UI if:
|
||||
// We were updating any types and any item was found
|
||||
// We were updating extensions and an extension update was found.
|
||||
// We were updating app and an app update was found.
|
||||
var updatesAvailable = (((this._updateTypes == nsIUpdateItem.TYPE_EXTENSION) ||
|
||||
(this._updateTypes == nsIUpdateItem.TYPE_ANY)) &&
|
||||
this._pref.getIntPref(PREF_UPDATE_EXTENSIONS_COUNT) != 0);
|
||||
if (!updatesAvailable) {
|
||||
updatesAvailable = ((this._updateTypes == nsIUpdateItem.TYPE_APP) ||
|
||||
(this._updateTypes == nsIUpdateItem.TYPE_ANY)) &&
|
||||
this._pref.getBoolPref(PREF_UPDATE_APP_UPDATESAVAILABLE);
|
||||
}
|
||||
|
||||
if (updatesAvailable && this._sourceEvent == nsIUpdateService.SOURCE_EVENT_BACKGROUND) {
|
||||
var sbs = Components.classes["@mozilla.org/intl/stringbundle;1"]
|
||||
.getService(Components.interfaces.nsIStringBundleService);
|
||||
var bundle = sbs.createBundle("chrome://mozapps/locale/update/update.properties");
|
||||
|
||||
var alertTitle = bundle.GetStringFromName("updatesAvailableTitle");
|
||||
var alertText = bundle.GetStringFromName("updatesAvailableText");
|
||||
|
||||
var alerts = Components.classes["@mozilla.org/alerts-service;1"]
|
||||
.getService(Components.interfaces.nsIAlertsService);
|
||||
alerts.showAlertNotification("chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png",
|
||||
alertTitle, alertText, true, "", this);
|
||||
}
|
||||
|
||||
os.removeObserver(this, "Update:Extension:Item-Ended");
|
||||
os.removeObserver(this, "Update:Extension:Ended");
|
||||
os.removeObserver(this, "Update:App:Ended");
|
||||
|
||||
this._service.updating = false;
|
||||
}
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsIObserver
|
||||
|
||||
onAlertFinished: function ()
|
||||
{
|
||||
},
|
||||
|
||||
onAlertClickCallback: function (aCookie)
|
||||
{
|
||||
var updates = Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIUpdateService);
|
||||
updates.checkForUpdates([], 0, Components.interfaces.nsIUpdateItem.TYPE_ANY,
|
||||
Components.interfaces.nsIUpdateService.SOURCE_EVENT_USER,
|
||||
null);
|
||||
}
|
||||
};
|
||||
|
||||
@ -407,6 +462,8 @@ nsAppUpdateXMLRDFDSObserver.prototype =
|
||||
onError: function(aSink, aStatus, aErrorMsg)
|
||||
{
|
||||
aSink.removeXMLSinkObserver(this);
|
||||
|
||||
this._updateService.datasourceError();
|
||||
}
|
||||
}
|
||||
|
||||
@ -500,6 +557,24 @@ nsVersionChecker.prototype = {
|
||||
return 0;
|
||||
return integer;
|
||||
},
|
||||
|
||||
isValidVersion: function (aVersion)
|
||||
{
|
||||
var parts = aVersion.split(".");
|
||||
if (parts.length == 0)
|
||||
return false;
|
||||
for (var i = 0; i < parts.length; ++i) {
|
||||
var part = parts[i];
|
||||
if (i == parts.length - 1) {
|
||||
if (part.lastIndexOf("+") != -1)
|
||||
parts[i] = part.substr(0, part.length - 1);
|
||||
}
|
||||
var integer = parseInt(part);
|
||||
if (isNaN(integer))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// nsISupports
|
||||
|
||||
@ -3,3 +3,10 @@ installitem {
|
||||
display: -moz-box;
|
||||
}
|
||||
|
||||
.listbox {
|
||||
-moz-appearance: listbox;
|
||||
}
|
||||
|
||||
#itemList {
|
||||
margin: 10px 4px 10px 4px;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user