2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-03-17 06:42:01 +03:00
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
2010-07-13 18:36:09 +04:00
|
|
|
const Cu = Components.utils;
|
2010-03-17 06:42:01 +03:00
|
|
|
|
2010-07-13 18:36:09 +04:00
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
2010-03-17 06:42:01 +03:00
|
|
|
|
2015-11-24 07:31:49 +03:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "AddonManagerPrivate",
|
2013-06-06 20:37:21 +04:00
|
|
|
"resource://gre/modules/AddonManager.jsm");
|
2010-03-17 06:42:01 +03:00
|
|
|
|
2013-06-06 20:37:21 +04:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "AddonRepository",
|
2014-01-08 08:14:08 +04:00
|
|
|
"resource://gre/modules/addons/AddonRepository.jsm");
|
2010-12-10 08:52:57 +03:00
|
|
|
|
2015-11-24 07:31:49 +03:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "GMPInstallManager",
|
|
|
|
"resource://gre/modules/GMPInstallManager.jsm");
|
|
|
|
|
2017-01-11 07:01:27 +03:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "EventDispatcher",
|
2015-11-24 07:31:49 +03:00
|
|
|
"resource://gre/modules/Messaging.jsm");
|
|
|
|
|
2013-08-27 16:50:22 +04:00
|
|
|
XPCOMUtils.defineLazyModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm");
|
2010-12-10 08:52:57 +03:00
|
|
|
|
2010-03-17 06:42:01 +03:00
|
|
|
function getPref(func, preference, defaultValue) {
|
|
|
|
try {
|
2010-07-13 18:36:09 +04:00
|
|
|
return Services.prefs[func](preference);
|
2017-08-01 18:43:56 +03:00
|
|
|
} catch (e) {}
|
2010-03-17 06:42:01 +03:00
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
// Add-on auto-update management service
|
|
|
|
// -----------------------------------------------------------------------
|
|
|
|
|
|
|
|
const PREF_ADDON_UPDATE_ENABLED = "extensions.autoupdate.enabled";
|
2015-11-24 07:31:49 +03:00
|
|
|
const PREF_ADDON_UPDATE_INTERVAL = "extensions.autoupdate.interval";
|
2010-03-17 06:42:01 +03:00
|
|
|
|
|
|
|
var gNeedsRestart = false;
|
|
|
|
|
|
|
|
function AddonUpdateService() {}
|
|
|
|
|
|
|
|
AddonUpdateService.prototype = {
|
|
|
|
classDescription: "Add-on auto-update management",
|
|
|
|
classID: Components.ID("{93c8824c-9b87-45ae-bc90-5b82a1e4d877}"),
|
2017-08-01 18:34:11 +03:00
|
|
|
|
2010-03-17 06:42:01 +03:00
|
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsITimerCallback]),
|
|
|
|
|
|
|
|
notify: function aus_notify(aTimer) {
|
|
|
|
if (aTimer && !getPref("getBoolPref", PREF_ADDON_UPDATE_ENABLED, true))
|
|
|
|
return;
|
|
|
|
|
|
|
|
// If we already auto-upgraded and installed new versions, ignore this check
|
|
|
|
if (gNeedsRestart)
|
|
|
|
return;
|
|
|
|
|
2015-11-24 07:31:49 +03:00
|
|
|
AddonManagerPrivate.backgroundUpdateCheck();
|
2015-11-24 07:31:49 +03:00
|
|
|
|
|
|
|
let gmp = new GMPInstallManager();
|
2017-06-19 13:32:37 +03:00
|
|
|
gmp.simpleCheckAndInstall().catch(() => {});
|
2015-11-24 07:31:49 +03:00
|
|
|
|
|
|
|
let interval = 1000 * getPref("getIntPref", PREF_ADDON_UPDATE_INTERVAL, 86400);
|
2017-01-11 07:01:27 +03:00
|
|
|
EventDispatcher.instance.sendRequest({
|
2015-11-24 07:31:49 +03:00
|
|
|
type: "Gecko:ScheduleRun",
|
|
|
|
action: "update-addons",
|
|
|
|
trigger: interval,
|
|
|
|
interval: interval,
|
|
|
|
});
|
2010-03-17 06:42:01 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-10-31 20:13:28 +04:00
|
|
|
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([AddonUpdateService]);
|
2010-03-17 06:42:01 +03:00
|
|
|
|