зеркало из https://github.com/mozilla/pjs.git
more smartupdate work.
This commit is contained in:
Родитель
942c71b10d
Коммит
dcf4b2d8ef
|
@ -166,9 +166,10 @@ function openDeviceManager()
|
|||
|
||||
function checkForUpdates()
|
||||
{
|
||||
// XXXben - check for "all types" and the app itself here.
|
||||
var em = Components.classes["@mozilla.org/extensions/manager;1"]
|
||||
.getService(Components.interfaces.nsIExtensionManager);
|
||||
em.update([], 0, Components.interfaces.nsIExtensionManager.UPDATE_TYPE_USERINVOKED);
|
||||
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,
|
||||
window);
|
||||
}
|
||||
|
||||
|
|
|
@ -371,7 +371,8 @@ var gExtensionsViewController = {
|
|||
var updates = Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIUpdateService);
|
||||
updates.checkForUpdates(items, items.length, nsIUpdateItem.TYPE_EXTENSION,
|
||||
Components.interfaces.nsIUpdateService.SOURCE_EVENT_USER);
|
||||
Components.interfaces.nsIUpdateService.SOURCE_EVENT_USER,
|
||||
window);
|
||||
},
|
||||
|
||||
cmd_uninstall: function ()
|
||||
|
|
|
@ -123,6 +123,8 @@ function nsExtensionManager()
|
|||
|
||||
nsExtensionManager.prototype = {
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// nsIObserver
|
||||
observe: function (aSubject, aTopic, aData)
|
||||
{
|
||||
|
@ -153,8 +155,11 @@ nsExtensionManager.prototype = {
|
|||
// Now disable the extension so it won't hurt anything.
|
||||
this.disableExtension(items[i].id);
|
||||
}
|
||||
this.update(items, items.length,
|
||||
Components.interfaces.nsIExtensionManager.UPDATE_TYPE_MISMATCH);
|
||||
var updates = Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIUpdateService);
|
||||
updates.checkForUpdates(items, items.length, Components.interfaces.nsIUpdateItem.TYPE_ADDON,
|
||||
Components.interfaces.nsIExtensionManager.SOURCE_EVENT_MISMATCH,
|
||||
null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
const nsIUpdateItem = Components.interfaces.nsIUpdateItem;
|
||||
const nsIUpdateService = Components.interfaces.nsIUpdateService;
|
||||
const nsIExtensionManager = Components.interfaces.nsIExtensionManager;
|
||||
|
||||
const PREF_APP_ID = "app.id";
|
||||
const PREF_UPDATE_APP_UPDATESAVAILABLE = "update.app.updatesAvailable";
|
||||
|
@ -61,6 +62,8 @@ var gUpdateWizard = {
|
|||
shouldSuggestAutoChecking: false,
|
||||
shouldAutoCheck: false,
|
||||
|
||||
updatingApp: false,
|
||||
|
||||
init: function ()
|
||||
{
|
||||
gUpdateTypes = window.arguments[0];
|
||||
|
@ -93,6 +96,34 @@ var gUpdateWizard = {
|
|||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
pref.setBoolPref("update.extensions.enabled", this.shouldAutoCheck);
|
||||
}
|
||||
|
||||
if (this.updatingApp) {
|
||||
var updates = Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIUpdateService);
|
||||
# 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/standard-url;1"]
|
||||
.createInstance(Components.interfaces.nsIURI);
|
||||
uri.spec = updates.appUpdateURL;
|
||||
|
||||
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 = updates.appUpdateURL;
|
||||
ary.AppendElement(url);
|
||||
ww.openWindow(null, "chrome://browser/content/browser.xul",
|
||||
"_blank", "chrome,all,dialog=no", ary);
|
||||
#endif
|
||||
}
|
||||
},
|
||||
|
||||
_setUpButton: function (aButtonID, aButtonKey, aDisabled)
|
||||
|
@ -168,7 +199,8 @@ var gUpdatePage = {
|
|||
|
||||
var updates = Components.classes["@mozilla.org/updates/update-service;1"]
|
||||
.getService(Components.interfaces.nsIUpdateService);
|
||||
updates.checkForUpdatesInternal(gUpdateWizard.items, gUpdateWizard.items.length, gUpdateTypes);
|
||||
updates.checkForUpdatesInternal(gUpdateWizard.items, gUpdateWizard.items.length,
|
||||
gUpdateTypes, gSourceEvent);
|
||||
|
||||
this._updateState = nsIUpdateService.UPDATED_NONE;
|
||||
},
|
||||
|
@ -273,6 +305,7 @@ var gFoundPage = {
|
|||
this._appUpdateExists = true;
|
||||
this._appSelected = true;
|
||||
this._appItem = updateitem;
|
||||
document.getElementById("found").setAttribute("next", "appupdate");
|
||||
}
|
||||
else {
|
||||
updateitem.checked = !this._appUpdateExists;
|
||||
|
@ -293,9 +326,11 @@ var gFoundPage = {
|
|||
var nonAppItem = this._nonAppItems[i];
|
||||
nonAppItem.checked = !aEvent.target.checked;
|
||||
}
|
||||
document.getElementById("found").setAttribute("next", "appupdate");
|
||||
}
|
||||
else {
|
||||
this._appItem.checked = false;
|
||||
document.getElementById("found").setAttribute("next", "installing");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,6 +347,18 @@ var gFoundPage = {
|
|||
}
|
||||
};
|
||||
|
||||
var gAppUpdatePage = {
|
||||
onPageShow: function ()
|
||||
{
|
||||
gUpdateWizard.setButtonLabels(null, true,
|
||||
null, true,
|
||||
null, true);
|
||||
gUpdateWizard.updatingApp = true;
|
||||
|
||||
document.documentElement.getButton("finish").focus();
|
||||
}
|
||||
};
|
||||
|
||||
var gInstallingPage = {
|
||||
onPageShow: function ()
|
||||
{
|
||||
|
@ -355,7 +402,7 @@ var gFinishedPage = {
|
|||
fEC.hidden = true;
|
||||
}
|
||||
|
||||
if (gSourceEvent == nsIUpdateService.SOURCE_EVENT_MISMATCH) {
|
||||
if (gSourceEvent == nsIExtensionManager.SOURCE_EVENT_MISMATCH) {
|
||||
document.getElementById("finishedMismatch").hidden = false;
|
||||
document.getElementById("incompatibleAlert").hidden = false;
|
||||
}
|
||||
|
|
|
@ -113,6 +113,20 @@
|
|||
|
||||
</wizardpage>
|
||||
|
||||
<wizardpage id="appupdate" pageid="appupdate"
|
||||
label="&appupdate.title;"
|
||||
onpageshow="gAppUpdatePage.onPageShow();">
|
||||
|
||||
<hbox>
|
||||
<label flex="1">&appupdate.intro.label;</label>
|
||||
<separator/>
|
||||
<image src="chrome://mozapps/skin/update/icon32.png"/>
|
||||
</hbox>
|
||||
|
||||
<separator/>
|
||||
|
||||
</wizardpage>
|
||||
|
||||
<wizardpage id="installing" pageid="installing" next="finished"
|
||||
label="&installing.title;"
|
||||
onpageshow="gInstallingPage.onPageShow();">
|
||||
|
|
|
@ -48,7 +48,8 @@
|
|||
this.updateCount = updates.updateCount;
|
||||
|
||||
#ifdef XP_WIN
|
||||
this._showUpdateInfo();
|
||||
if (parseInt(aData) == Components.interfaces.nsIUpdateService.SOURCE_EVENT_BACKGROUND)
|
||||
this._showUpdateInfo();
|
||||
#endif
|
||||
}
|
||||
]]>
|
||||
|
@ -99,7 +100,8 @@
|
|||
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);
|
||||
Components.interfaces.nsIUpdateService.SOURCE_EVENT_USER,
|
||||
window);
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
|
|
@ -49,3 +49,11 @@
|
|||
<!ENTITY finished.mismatch.label "Click Finish to continue starting &brandShortName;.">
|
||||
|
||||
<!ENTITY appInfo.label "This update must be installed separately from any others.">
|
||||
|
||||
<!ENTITY appupdate.title "&brandShortName; Update">
|
||||
<!ENTITY appupdate.intro.label "&brandShortName; Update will now close and take you to the
|
||||
web site where you can download the latest version of
|
||||
&brandShortName;.">
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMWindowInternal;
|
||||
|
||||
[scriptable, uuid(37648f86-0f77-4007-929e-673a75d5438f)]
|
||||
interface nsIUpdateItem : nsISupports
|
||||
{
|
||||
|
@ -50,9 +52,11 @@ interface nsIUpdateItem : nsISupports
|
|||
|
||||
const unsigned short TYPE_ANY = 0x01;
|
||||
const unsigned short TYPE_APP = 0x02;
|
||||
const unsigned short TYPE_EXTENSION = 0x04;
|
||||
const unsigned short TYPE_THEME = 0x08;
|
||||
const unsigned short TYPE_LOCALE = 0x10;
|
||||
const unsigned short TYPE_ADDON = 0x04;
|
||||
|
||||
const unsigned short TYPE_EXTENSION = 0x08;
|
||||
const unsigned short TYPE_THEME = 0x10;
|
||||
const unsigned short TYPE_LOCALE = 0x20;
|
||||
|
||||
readonly attribute long type;
|
||||
|
||||
|
@ -74,10 +78,12 @@ interface nsIUpdateService : nsISupports
|
|||
void checkForUpdates([array, size_is(aItemCount)] in nsIUpdateItem aItems,
|
||||
in unsigned long aItemCount,
|
||||
in unsigned short aUpdateTypes,
|
||||
in unsigned short aSourceEvent);
|
||||
in unsigned short aSourceEvent,
|
||||
in nsIDOMWindowInternal aParentWindow);
|
||||
void checkForUpdatesInternal([array, size_is(aItemCount)] in nsIUpdateItem aItems,
|
||||
in unsigned long aItemCount,
|
||||
in unsigned short aUpdateTypes);
|
||||
in unsigned short aUpdateTypes,
|
||||
in unsigned short aSourceEvent);
|
||||
|
||||
readonly attribute long updateCount;
|
||||
readonly attribute unsigned short updateSeverity;
|
||||
|
|
|
@ -67,7 +67,7 @@ function nsBackgroundUpdateService()
|
|||
nsBackgroundUpdateService.prototype = {
|
||||
_timer: null,
|
||||
_pref: null,
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// nsIUpdateService
|
||||
watchForUpdates: function ()
|
||||
|
@ -83,15 +83,17 @@ nsBackgroundUpdateService.prototype = {
|
|||
var interval = this._pref.getIntPref(PREF_UPDATE_INTERVAL);
|
||||
var lastUpdateTime = this._pref.getIntPref(PREF_UPDATE_LASTUPDATEDATE);
|
||||
var timeSinceLastCheck = Date.UTC() - lastUpdateTime;
|
||||
this.checkForUpdatesInternal([], 0, nsIUpdateItem.TYPE_ANY); /// XXXben
|
||||
this.checkForUpdatesInternal([], 0, nsIUpdateItem.TYPE_ANY,
|
||||
nsIUpdateService.SOURCE_EVENT_BACKGROUND); /// XXXben
|
||||
|
||||
if (timeSinceLastCheck > interval)
|
||||
this.checkForUpdatesInternal([], 0, nsIUpdateItem.TYPE_ANY);
|
||||
this.checkForUpdatesInternal([], 0, nsIUpdateItem.TYPE_ANY,
|
||||
nsIUpdateService.SOURCE_EVENT_BACKGROUND);
|
||||
else
|
||||
this._makeTimer(interval - timeSinceLastCheck);
|
||||
},
|
||||
|
||||
checkForUpdates: function (aItems, aItemCount, aUpdateTypes, aSourceEvent)
|
||||
checkForUpdates: function (aItems, aItemCount, aUpdateTypes, aSourceEvent, aParentWindow)
|
||||
{
|
||||
switch (aSourceEvent) {
|
||||
case Components.interfaces.nsIExtensionManager.SOURCE_EVENT_MISMATCH:
|
||||
|
@ -110,7 +112,7 @@ nsBackgroundUpdateService.prototype = {
|
|||
ary.AppendElement(sourceEvent);
|
||||
for (var i = 0; i < aItems.length; ++i)
|
||||
ary.AppendElement(aItems[i]);
|
||||
ww.openWindow(null, "chrome://mozapps/content/update/update.xul",
|
||||
ww.openWindow(aParentWindow, "chrome://mozapps/content/update/update.xul",
|
||||
"", "chrome,modal,centerscreen", ary);
|
||||
break;
|
||||
case nsIUpdateService.SOURCE_EVENT_BACKGROUND:
|
||||
|
@ -127,18 +129,17 @@ nsBackgroundUpdateService.prototype = {
|
|||
}
|
||||
},
|
||||
|
||||
checkForUpdatesInternal: function (aItems, aItemCount, aUpdateTypes)
|
||||
checkForUpdatesInternal: function (aItems, aItemCount, aUpdateTypes, aSourceEvent)
|
||||
{
|
||||
// Listen for notifications sent out by the app updater (implemented here) and the
|
||||
// extension updater (implemented in nsExtensionItemUpdater)
|
||||
var updateObserver = new nsUpdateObserver(aUpdateTypes, aSourceEvent);
|
||||
var os = Components.classes["@mozilla.org/observer-service;1"]
|
||||
.getService(Components.interfaces.nsIObserverService);
|
||||
os.addObserver(this, "Update:Extension:Item-Ended", false);
|
||||
os.addObserver(this, "Update:Extension:Ended", false);
|
||||
os.addObserver(this, "Update:App:Ended", false);
|
||||
os.addObserver(updateObserver, "Update:Extension:Item-Ended", false);
|
||||
os.addObserver(updateObserver, "Update:Extension:Ended", false);
|
||||
os.addObserver(updateObserver, "Update:App:Ended", false);
|
||||
|
||||
this._updateState = 0;
|
||||
|
||||
var appUpdatesEnabled = this._pref.getBoolPref(PREF_UPDATE_APP_ENABLED);
|
||||
var extUpdatesEnabled = this._pref.getBoolPref(PREF_UPDATE_EXTENSIONS_ENABLED);
|
||||
|
||||
|
@ -176,65 +177,28 @@ nsBackgroundUpdateService.prototype = {
|
|||
|
||||
get appUpdateVersion()
|
||||
{
|
||||
return this._pref.getComplexValue(PREF_UPDATE_APP_UPDATEVERSION, Components.interfaces.nsISupportsString).data;
|
||||
return this._pref.getComplexValue(PREF_UPDATE_APP_UPDATEVERSION,
|
||||
Components.interfaces.nsISupportsString).data;
|
||||
},
|
||||
|
||||
get appUpdateDescription()
|
||||
{
|
||||
return this._pref.getComplexValue(PREF_UPDATE_APP_UPDATEDESCRIPTION, Components.interfaces.nsISupportsString).data;
|
||||
return this._pref.getComplexValue(PREF_UPDATE_APP_UPDATEDESCRIPTION,
|
||||
Components.interfaces.nsISupportsString).data;
|
||||
},
|
||||
|
||||
get appUpdateURL()
|
||||
{
|
||||
return this._pref.getComplexValue(PREF_UPDATE_APP_UPDATEURL, Components.interfaces.nsISupportsString).data;
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// nsIObserver
|
||||
_updateState: 0,
|
||||
get _doneUpdating()
|
||||
{
|
||||
var test = 0;
|
||||
if (this._pref.getBoolPref(PREF_UPDATE_APP_ENABLED))
|
||||
test |= UPDATED_APP;
|
||||
if (this._pref.getBoolPref(PREF_UPDATE_EXTENSIONS_ENABLED))
|
||||
test |= UPDATED_EXTENSIONS;
|
||||
return (this._updateState & test) == test;
|
||||
},
|
||||
|
||||
observe: function (aSubject, aTopic, aData)
|
||||
{
|
||||
switch (aTopic) {
|
||||
case "Update:Extension:Item-Ended":
|
||||
this._pref.setIntPref(PREF_UPDATE_EXTENSIONS_COUNT,
|
||||
this._pref.getIntPref(PREF_UPDATE_EXTENSIONS_COUNT) + 1);
|
||||
break;
|
||||
case "Update:Extension:Ended":
|
||||
this._updateState |= UPDATED_EXTENSIONS;
|
||||
break;
|
||||
case "Update:App:Ended":
|
||||
this._updateState |= UPDATED_APP;
|
||||
break;
|
||||
}
|
||||
|
||||
if (this._doneUpdating) {
|
||||
// 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);
|
||||
os.notifyObservers(null, "Update:Ended", "");
|
||||
|
||||
os.removeObserver(this, "Update:Extension:Item-Ended");
|
||||
os.removeObserver(this, "Update:Extension:Ended");
|
||||
os.removeObserver(this, "Update:App:Ended");
|
||||
}
|
||||
return this._pref.getComplexValue(PREF_UPDATE_APP_UPDATEURL,
|
||||
Components.interfaces.nsISupportsString).data;
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// nsITimerCallback
|
||||
notify: function (aTimer)
|
||||
{
|
||||
this.checkForUpdatesNow();
|
||||
this.checkForUpdatesInternal([], 0, nsIUpdateItem.TYPE_ANY,
|
||||
nsIUpdateService.SOURCE_EVENT_BACKGROUND);
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -261,6 +225,66 @@ nsBackgroundUpdateService.prototype = {
|
|||
}
|
||||
};
|
||||
|
||||
function nsUpdateObserver(aUpdateTypes, aSourceEvent)
|
||||
{
|
||||
this._pref = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch);
|
||||
this._updateTypes = aUpdateTypes;
|
||||
this._sourceEvent = aSourceEvent;
|
||||
}
|
||||
|
||||
nsUpdateObserver.prototype = {
|
||||
_updateTypes: 0,
|
||||
_sourceEvent: 0,
|
||||
_updateState: 0,
|
||||
get _doneUpdating()
|
||||
{
|
||||
var test = 0;
|
||||
var updatingApp = this._updateTypes == nsIUpdateItem.TYPE_ANY ||
|
||||
this._updateTypes == nsIUpdateItem.TYPE_APP;
|
||||
var updatingExt = this._updateTypes != nsIUpdateItem.TYPE_APP;
|
||||
|
||||
if (this._pref.getBoolPref(PREF_UPDATE_APP_ENABLED) &&
|
||||
updatingApp)
|
||||
test |= UPDATED_APP;
|
||||
if (this._pref.getBoolPref(PREF_UPDATE_EXTENSIONS_ENABLED) &&
|
||||
updatingExt)
|
||||
test |= UPDATED_EXTENSIONS;
|
||||
|
||||
return (this._updateState & test) == test;
|
||||
},
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// nsIObserver
|
||||
observe: function (aSubject, aTopic, aData)
|
||||
{
|
||||
switch (aTopic) {
|
||||
case "Update:Extension:Item-Ended":
|
||||
this._pref.setIntPref(PREF_UPDATE_EXTENSIONS_COUNT,
|
||||
this._pref.getIntPref(PREF_UPDATE_EXTENSIONS_COUNT) + 1);
|
||||
break;
|
||||
case "Update:Extension:Ended":
|
||||
this._updateState |= UPDATED_EXTENSIONS;
|
||||
break;
|
||||
case "Update:App:Ended":
|
||||
this._updateState |= UPDATED_APP;
|
||||
break;
|
||||
}
|
||||
|
||||
if (this._doneUpdating) {
|
||||
// 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);
|
||||
os.notifyObservers(null, "Update:Ended", this._sourceEvent.toString());
|
||||
|
||||
os.removeObserver(this, "Update:Extension:Item-Ended");
|
||||
os.removeObserver(this, "Update:Extension:Ended");
|
||||
os.removeObserver(this, "Update:App:Ended");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function nsAppUpdateXMLRDFDSObserver(aUpdateService)
|
||||
{
|
||||
this._updateService = aUpdateService;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<!-- 0 = low (extension/theme updates),
|
||||
1 = medium (app minor version),
|
||||
2 = high (major version) -->
|
||||
<NC:severity>0</NC:severity>
|
||||
<NC:severity>2</NC:severity>
|
||||
|
||||
<!-- URL to send users to to download this update -->
|
||||
<NC:URL>http://www.mozilla.org/products/firefox/</NC:URL>
|
||||
|
|
Загрузка…
Ссылка в новой задаче