mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 11:38:16 +00:00
unify selection between background update and foreground update, move nsIUpdateItem to Extension Manager
This commit is contained in:
parent
a1a115ee47
commit
ac57e65f73
@ -415,6 +415,90 @@ interface nsIExtensionItemUpdater : nsISupports
|
||||
readonly attribute unsigned long updateTypes;
|
||||
};
|
||||
|
||||
/**
|
||||
* An item managed by the Extension System. Contains metadata that describes
|
||||
* the item.
|
||||
* XXXben work in progress, the name of this interface will change after the
|
||||
* update system is complete, probably to nsIAddon
|
||||
*/
|
||||
[scriptable, uuid(415edb0a-4f2d-485c-9e10-f262b065ab33)]
|
||||
interface nsIUpdateItem : nsISupports
|
||||
{
|
||||
/**
|
||||
* The GUID of the item.
|
||||
*/
|
||||
readonly attribute AString id;
|
||||
|
||||
/**
|
||||
* The Version of the item, in FVF format.
|
||||
*/
|
||||
readonly attribute AString version;
|
||||
|
||||
/**
|
||||
* The minimum version of the application that this item works with,
|
||||
* in FVF format.
|
||||
*/
|
||||
readonly attribute AString minAppVersion;
|
||||
|
||||
/**
|
||||
* The maximum version of the application that this item works with,
|
||||
* in FVF format.
|
||||
*/
|
||||
readonly attribute AString maxAppVersion;
|
||||
|
||||
/**
|
||||
* The name of the Install Location where this item is installed.
|
||||
*/
|
||||
readonly attribute AString installLocationKey;
|
||||
|
||||
/**
|
||||
* The name of this item.
|
||||
*/
|
||||
readonly attribute AString name;
|
||||
|
||||
/**
|
||||
* The URL of the XPI where this item can be downloaded.
|
||||
*/
|
||||
readonly attribute AString xpiURL;
|
||||
|
||||
/**
|
||||
* The URL of the icon that can be shown for this item.
|
||||
*/
|
||||
readonly attribute AString iconURL;
|
||||
|
||||
/**
|
||||
* The URL of the update RDF file for this item.
|
||||
*/
|
||||
readonly attribute AString updateRDF;
|
||||
|
||||
const unsigned long TYPE_APP = 0x01;
|
||||
const unsigned long TYPE_EXTENSION = 0x02;
|
||||
const unsigned long TYPE_THEME = 0x04;
|
||||
const unsigned long TYPE_LOCALE = 0x08;
|
||||
const unsigned long TYPE_PLUGIN = 0x10;
|
||||
const unsigned long TYPE_ADDON = TYPE_EXTENSION + TYPE_THEME + TYPE_LOCALE + TYPE_PLUGIN;
|
||||
const unsigned long TYPE_ANY = TYPE_APP + TYPE_ADDON;
|
||||
|
||||
/**
|
||||
* The type of this item.
|
||||
*/
|
||||
readonly attribute long type;
|
||||
|
||||
/**
|
||||
* Initializes this Item object.
|
||||
*/
|
||||
void init(in AString id, in AString version,
|
||||
in AString installLocationKey, in AString minAppVersion,
|
||||
in AString maxAppVersion, in AString name,
|
||||
in AString downloadURL, in AString iconURL,
|
||||
in AString updateURL, in long type);
|
||||
|
||||
/**
|
||||
* Returns a JS Object source representing an nsIUpdateItem.
|
||||
*/
|
||||
readonly attribute AString objectSource;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
/**
|
||||
* Install Location Key for Application-Global Items
|
||||
|
@ -6050,6 +6050,67 @@ ExtensionsDataSource.prototype = {
|
||||
}
|
||||
};
|
||||
|
||||
function UpdateItem () {
|
||||
}
|
||||
UpdateItem.prototype = {
|
||||
/**
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
init: function(id, version, installLocationKey, minAppVersion, maxAppVersion,
|
||||
name, downloadURL, iconURL, updateURL, type) {
|
||||
this._id = id;
|
||||
this._version = version;
|
||||
this._installLocationKey = installLocationKey;
|
||||
this._minAppVersion = minAppVersion;
|
||||
this._maxAppVersion = maxAppVersion;
|
||||
this._name = name;
|
||||
this._downloadURL = downloadURL;
|
||||
this._iconURL = iconURL;
|
||||
this._updateURL = updateURL;
|
||||
this._type = type;
|
||||
},
|
||||
|
||||
/**
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
get id() { return this._id; },
|
||||
get version() { return this._version; },
|
||||
get installLocationKey(){ return this._installLocationKey;},
|
||||
get minAppVersion() { return this._minAppVersion; },
|
||||
get maxAppVersion() { return this._maxAppVersion; },
|
||||
get name() { return this._name; },
|
||||
get xpiURL() { return this._downloadURL; },
|
||||
get iconURL() { return this._iconURL },
|
||||
get updateRDF() { return this._updateURL; },
|
||||
get type() { return this._type; },
|
||||
|
||||
/**
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
get objectSource() {
|
||||
return { id : this._id,
|
||||
version : this._version,
|
||||
installLocationKey : this._installLocationKey,
|
||||
minAppVersion : this._minAppVersion,
|
||||
maxAppVersion : this._maxAppVersion,
|
||||
name : this._name,
|
||||
xpiURL : this._downloadURL,
|
||||
iconURL : this._iconURL,
|
||||
updateRDF : this._updateURL,
|
||||
type : this._type
|
||||
}.toSource();
|
||||
},
|
||||
|
||||
/**
|
||||
* See nsISupports.idl
|
||||
*/
|
||||
QueryInterface: function(iid) {
|
||||
if (!iid.equals(Components.interfaces.nsIUpdateItem) &&
|
||||
!iid.equals(Components.interfaces.nsISupports))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
var gModule = {
|
||||
registerSelf: function(componentManager, fileSpec, location, type) {
|
||||
@ -6096,6 +6157,11 @@ var gModule = {
|
||||
contractID : ExtensionManager.prototype.contractID,
|
||||
className : ExtensionManager.prototype.classDescription,
|
||||
factory : #1#(ExtensionManager)
|
||||
},
|
||||
item: { CID : Components.ID("{F3294B1C-89F4-46F8-98A0-44E1EAE92518}"),
|
||||
contractID : "@mozilla.org/updates/item;1",
|
||||
className : "Update Item",
|
||||
factory : #1#(UpdateItem)
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -11,7 +11,7 @@ function LOG(string) {
|
||||
}
|
||||
|
||||
var gUpdates = {
|
||||
updates: null,
|
||||
update: null,
|
||||
onClose: function() {
|
||||
var objects = {
|
||||
checking: gCheckingPage,
|
||||
@ -21,6 +21,13 @@ var gUpdates = {
|
||||
if ("onClose" in objects[pageid])
|
||||
objects[pageid].onClose();
|
||||
},
|
||||
|
||||
onLoad: function() {
|
||||
if (window.arguments[0]) {
|
||||
this.update = window.arguments[0];
|
||||
document.documentElement.advance();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var gCheckingPage = {
|
||||
@ -65,7 +72,9 @@ var gCheckingPage = {
|
||||
* See nsIUpdateCheckListener.idl
|
||||
*/
|
||||
onCheckComplete: function(updates, updateCount) {
|
||||
gUpdates.updates = updates;
|
||||
var aus = Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIApplicationUpdateService);
|
||||
gUpdate.update = aus.selectUpdate(updates);
|
||||
document.documentElement.advance();
|
||||
},
|
||||
|
||||
|
@ -52,7 +52,8 @@
|
||||
title="&updateWizard.title;"
|
||||
windowtype="Update:Wizard" style="width: 36em;"
|
||||
onwizardfinished="gUpdates.onFinish();"
|
||||
onclose="return gUpdates.onClose();">
|
||||
onclose="return gUpdates.onClose();"
|
||||
onload="gUpdates.onLoad();>
|
||||
|
||||
<script type="application/x-javascript" src="chrome://mozapps/content/update/updates.js"/>
|
||||
|
||||
|
@ -172,94 +172,22 @@ interface nsIApplicationUpdateService : nsISupports
|
||||
*/
|
||||
void removeDownloadListener(in nsIRequestObserver listener);
|
||||
|
||||
/**
|
||||
* Selects the best update to install from a list of available updates.
|
||||
* @param updates
|
||||
* An array of updates that are available
|
||||
* @param updateCount
|
||||
* The length of the |updates| array
|
||||
*/
|
||||
nsIUpdate selectUpdate([array, size_is(updateCount)] in nsIUpdate updates,
|
||||
in unsigned long updateCount);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void downloadUpdate(in nsIUpdate update);
|
||||
};
|
||||
|
||||
/**
|
||||
* An item managed by the Extension or Software Update System. Contains
|
||||
* metadata that describes the item.
|
||||
*/
|
||||
[scriptable, uuid(415edb0a-4f2d-485c-9e10-f262b065ab33)]
|
||||
interface nsIUpdateItem : nsISupports
|
||||
{
|
||||
/**
|
||||
* The GUID of the item.
|
||||
*/
|
||||
readonly attribute AString id;
|
||||
|
||||
/**
|
||||
* The Version of the item, in FVF format.
|
||||
*/
|
||||
readonly attribute AString version;
|
||||
|
||||
/**
|
||||
* The minimum version of the application that this item works with,
|
||||
* in FVF format.
|
||||
*/
|
||||
readonly attribute AString minAppVersion;
|
||||
|
||||
/**
|
||||
* The maximum version of the application that this item works with,
|
||||
* in FVF format.
|
||||
*/
|
||||
readonly attribute AString maxAppVersion;
|
||||
|
||||
/**
|
||||
* The name of the Install Location where this item is installed.
|
||||
*/
|
||||
readonly attribute AString installLocationKey;
|
||||
|
||||
/**
|
||||
* The name of this item.
|
||||
*/
|
||||
readonly attribute AString name;
|
||||
|
||||
/**
|
||||
* The URL of the XPI where this item can be downloaded.
|
||||
*/
|
||||
readonly attribute AString xpiURL;
|
||||
|
||||
/**
|
||||
* The URL of the icon that can be shown for this item.
|
||||
*/
|
||||
readonly attribute AString iconURL;
|
||||
|
||||
/**
|
||||
* The URL of the update RDF file for this item.
|
||||
*/
|
||||
readonly attribute AString updateRDF;
|
||||
|
||||
const unsigned long TYPE_APP = 0x01;
|
||||
const unsigned long TYPE_EXTENSION = 0x02;
|
||||
const unsigned long TYPE_THEME = 0x04;
|
||||
const unsigned long TYPE_LOCALE = 0x08;
|
||||
const unsigned long TYPE_PLUGIN = 0x10;
|
||||
const unsigned long TYPE_ADDON = TYPE_EXTENSION + TYPE_THEME + TYPE_LOCALE + TYPE_PLUGIN;
|
||||
const unsigned long TYPE_ANY = TYPE_APP + TYPE_ADDON;
|
||||
|
||||
/**
|
||||
* The type of this item.
|
||||
*/
|
||||
readonly attribute long type;
|
||||
|
||||
/**
|
||||
* Initializes this Item object.
|
||||
*/
|
||||
void init(in AString id, in AString version,
|
||||
in AString installLocationKey, in AString minAppVersion,
|
||||
in AString maxAppVersion, in AString name,
|
||||
in AString downloadURL, in AString iconURL,
|
||||
in AString updateURL, in long type);
|
||||
|
||||
/**
|
||||
* Returns a JS Object source representing an nsIUpdateItem.
|
||||
*/
|
||||
readonly attribute AString objectSource;
|
||||
};
|
||||
|
||||
[scriptable, uuid(22d35700-5765-42e1-914b-a0da7c911a8c)]
|
||||
interface nsIVersionChecker : nsISupports
|
||||
{
|
||||
|
@ -99,7 +99,7 @@ var gConsole = null;
|
||||
* The string to write to the error console..
|
||||
*/
|
||||
function LOG(string) {
|
||||
// dump("*** " + string + "\n");
|
||||
dump("*** " + string + "\n");
|
||||
gConsole.logStringMessage(string);
|
||||
}
|
||||
|
||||
@ -406,7 +406,7 @@ UpdateService.prototype = {
|
||||
var listener = {
|
||||
onProgress: function() { },
|
||||
onCheckComplete: function(updates, updateCount) {
|
||||
self._selectUpdate(updates);
|
||||
self._selectAndInstallUpdate(updates);
|
||||
},
|
||||
onError: function() { },
|
||||
}
|
||||
@ -457,15 +457,14 @@ UpdateService.prototype = {
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine which of the specified updates should be installed and
|
||||
* begin the download/installation process, optionally prompting the
|
||||
* user for permission if required.
|
||||
* Determine which of the specified updates should be installed.
|
||||
* @param updates
|
||||
* An array of available updates
|
||||
*/
|
||||
_selectUpdate: function(updates) {
|
||||
selectUpdate: function(updates) {
|
||||
if (updates.length == 0) {
|
||||
// XXXben erk
|
||||
return null;
|
||||
}
|
||||
|
||||
// Choose the newest of the available minor and major updates.
|
||||
@ -483,9 +482,20 @@ UpdateService.prototype = {
|
||||
|
||||
// If there's a major update, always try and fetch that one first,
|
||||
// otherwise fall back to the newest minor update.
|
||||
var update = newestMajor || newestMinor;
|
||||
return newestMajor || newestMinor;
|
||||
},
|
||||
|
||||
/**
|
||||
* Determine which of the specified updates should be installed and
|
||||
* begin the download/installation process, optionally prompting the
|
||||
* user for permission if required.
|
||||
* @param updates
|
||||
* An array of available updates
|
||||
*/
|
||||
_selectAndInstallUpdate: function(updates) {
|
||||
var update = this.selectUpdate(updates);
|
||||
if (this._shouldPrompt(update)) {
|
||||
LOG("_selectUpdate: need to prompt user before continuing...");
|
||||
LOG("_selectAndInstallUpdate: need to prompt user before continuing...");
|
||||
var prompter =
|
||||
Components.classes["@mozilla.org/updates/update-prompt;1"].
|
||||
createInstance(Components.interfaces.nsIUpdatePrompt);
|
||||
@ -1061,68 +1071,6 @@ Verifier.prototype = {
|
||||
|
||||
};
|
||||
|
||||
function UpdateItem () {
|
||||
}
|
||||
UpdateItem.prototype = {
|
||||
/**
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
init: function(id, version, installLocationKey, minAppVersion, maxAppVersion,
|
||||
name, downloadURL, iconURL, updateURL, type) {
|
||||
this._id = id;
|
||||
this._version = version;
|
||||
this._installLocationKey = installLocationKey;
|
||||
this._minAppVersion = minAppVersion;
|
||||
this._maxAppVersion = maxAppVersion;
|
||||
this._name = name;
|
||||
this._downloadURL = downloadURL;
|
||||
this._iconURL = iconURL;
|
||||
this._updateURL = updateURL;
|
||||
this._type = type;
|
||||
},
|
||||
|
||||
/**
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
get id() { return this._id; },
|
||||
get version() { return this._version; },
|
||||
get installLocationKey(){ return this._installLocationKey;},
|
||||
get minAppVersion() { return this._minAppVersion; },
|
||||
get maxAppVersion() { return this._maxAppVersion; },
|
||||
get name() { return this._name; },
|
||||
get xpiURL() { return this._downloadURL; },
|
||||
get iconURL() { return this._iconURL },
|
||||
get updateRDF() { return this._updateURL; },
|
||||
get type() { return this._type; },
|
||||
|
||||
/**
|
||||
* See nsIUpdateService.idl
|
||||
*/
|
||||
get objectSource() {
|
||||
return { id : this._id,
|
||||
version : this._version,
|
||||
installLocationKey : this._installLocationKey,
|
||||
minAppVersion : this._minAppVersion,
|
||||
maxAppVersion : this._maxAppVersion,
|
||||
name : this._name,
|
||||
xpiURL : this._downloadURL,
|
||||
iconURL : this._iconURL,
|
||||
updateRDF : this._updateURL,
|
||||
type : this._type
|
||||
}.toSource();
|
||||
},
|
||||
|
||||
/**
|
||||
* See nsISupports.idl
|
||||
*/
|
||||
QueryInterface: function(iid) {
|
||||
if (!iid.equals(Components.interfaces.nsIUpdateItem) &&
|
||||
!iid.equals(Components.interfaces.nsISupports))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
function Version(aMajor, aMinor, aRelease, aBuild, aPlus)
|
||||
{
|
||||
this.major = aMajor || 0;
|
||||
@ -1266,16 +1214,10 @@ var gModule = {
|
||||
contractID : "@mozilla.org/updates/version-checker;1",
|
||||
className : "Version Checker",
|
||||
factory : #1#(VersionChecker)
|
||||
},
|
||||
item: { CID : Components.ID("{F3294B1C-89F4-46F8-98A0-44E1EAE92518}"),
|
||||
contractID : "@mozilla.org/updates/item;1",
|
||||
className : "Update Item",
|
||||
factory : #1#(UpdateItem)
|
||||
}
|
||||
},
|
||||
|
||||
canUnload: function (aComponentManager)
|
||||
{
|
||||
canUnload: function(componentManager) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user