mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Firefox: remove unloading from vAPI
This commit is contained in:
parent
e0f214961d
commit
3522f0414d
@ -59,7 +59,7 @@ vAPI.app.restart = function() {
|
|||||||
// List of things that needs to be destroyed when disabling the extension
|
// List of things that needs to be destroyed when disabling the extension
|
||||||
// Only functions should be added to it
|
// Only functions should be added to it
|
||||||
|
|
||||||
vAPI.unload = [];
|
cleanupTasks = [];
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ var SQLite = {
|
|||||||
'(name TEXT PRIMARY KEY NOT NULL, value TEXT);'
|
'(name TEXT PRIMARY KEY NOT NULL, value TEXT);'
|
||||||
);
|
);
|
||||||
|
|
||||||
vAPI.unload.push(function() {
|
cleanupTasks.push(function() {
|
||||||
// VACUUM somewhere else, instead on unload?
|
// VACUUM somewhere else, instead on unload?
|
||||||
SQLite.run('VACUUM');
|
SQLite.run('VACUUM');
|
||||||
SQLite.db.asyncClose();
|
SQLite.db.asyncClose();
|
||||||
@ -334,7 +334,7 @@ vAPI.tabs.registerListeners = function() {
|
|||||||
|
|
||||||
Services.ww.registerNotification(windowWatcher);
|
Services.ww.registerNotification(windowWatcher);
|
||||||
|
|
||||||
vAPI.unload.push(function() {
|
cleanupTasks.push(function() {
|
||||||
Services.ww.unregisterNotification(windowWatcher);
|
Services.ww.unregisterNotification(windowWatcher);
|
||||||
|
|
||||||
for ( var win of vAPI.tabs.getWindows() ) {
|
for ( var win of vAPI.tabs.getWindows() ) {
|
||||||
@ -743,7 +743,7 @@ vAPI.messaging.setup = function(defaultHandler) {
|
|||||||
|
|
||||||
this.globalMessageManager.loadFrameScript(this.frameScript, true);
|
this.globalMessageManager.loadFrameScript(this.frameScript, true);
|
||||||
|
|
||||||
vAPI.unload.push(function() {
|
cleanupTasks.push(function() {
|
||||||
var gmm = vAPI.messaging.globalMessageManager;
|
var gmm = vAPI.messaging.globalMessageManager;
|
||||||
|
|
||||||
gmm.removeDelayedFrameScript(vAPI.messaging.frameScript);
|
gmm.removeDelayedFrameScript(vAPI.messaging.frameScript);
|
||||||
@ -966,12 +966,12 @@ var httpObserver = {
|
|||||||
|
|
||||||
var sourceTabId = null;
|
var sourceTabId = null;
|
||||||
|
|
||||||
// popup candidate (only for main_frame type)
|
// Popup candidate (only for main_frame type)
|
||||||
if ( lastRequest.openerURL ) {
|
if ( lastRequest.openerURL ) {
|
||||||
for ( var tab of vAPI.tabs.getAll() ) {
|
for ( var tab of vAPI.tabs.getAll() ) {
|
||||||
var tabURI = tab.linkedBrowser.currentURI;
|
var tabURI = tab.linkedBrowser.currentURI;
|
||||||
|
|
||||||
// not the best approach
|
// Not the best approach
|
||||||
if ( tabURI.spec === this.lastRequest.openerURL ) {
|
if ( tabURI.spec === this.lastRequest.openerURL ) {
|
||||||
sourceTabId = vAPI.tabs.getTabId(tab);
|
sourceTabId = vAPI.tabs.getTabId(tab);
|
||||||
break;
|
break;
|
||||||
@ -988,7 +988,7 @@ var httpObserver = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if request is not handled we may use the data in on-modify-request
|
// If request is not handled we may use the data in on-modify-request
|
||||||
if ( channel instanceof Ci.nsIWritablePropertyBag ) {
|
if ( channel instanceof Ci.nsIWritablePropertyBag ) {
|
||||||
channel.setProperty(
|
channel.setProperty(
|
||||||
location.host + 'reqdata',
|
location.host + 'reqdata',
|
||||||
@ -1040,7 +1040,7 @@ var httpObserver = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// carry the data on in case of multiple redirects
|
// Carry the data on in case of multiple redirects
|
||||||
if ( newChannel instanceof Ci.nsIWritablePropertyBag ) {
|
if ( newChannel instanceof Ci.nsIWritablePropertyBag ) {
|
||||||
newChannel.setProperty(location.host + 'reqdata', channelData);
|
newChannel.setProperty(location.host + 'reqdata', channelData);
|
||||||
}
|
}
|
||||||
@ -1096,7 +1096,7 @@ vAPI.net.registerListeners = function() {
|
|||||||
|
|
||||||
httpObserver.register();
|
httpObserver.register();
|
||||||
|
|
||||||
vAPI.unload.push(function() {
|
cleanupTasks.push(function() {
|
||||||
vAPI.messaging.globalMessageManager.removeMessageListener(
|
vAPI.messaging.globalMessageManager.removeMessageListener(
|
||||||
shouldLoadListenerMessageName,
|
shouldLoadListenerMessageName,
|
||||||
shouldLoadListener
|
shouldLoadListener
|
||||||
@ -1171,7 +1171,7 @@ vAPI.toolbarButton.init = function() {
|
|||||||
this.closePopup
|
this.closePopup
|
||||||
);
|
);
|
||||||
|
|
||||||
vAPI.unload.push(function() {
|
cleanupTasks.push(function() {
|
||||||
CustomizableUI.destroyWidget(this.id);
|
CustomizableUI.destroyWidget(this.id);
|
||||||
vAPI.messaging.globalMessageManager.removeMessageListener(
|
vAPI.messaging.globalMessageManager.removeMessageListener(
|
||||||
location.host + ':closePopup',
|
location.host + ':closePopup',
|
||||||
@ -1457,8 +1457,8 @@ vAPI.onLoadAllCompleted = function() {};
|
|||||||
// clean up when the extension is disabled
|
// clean up when the extension is disabled
|
||||||
|
|
||||||
window.addEventListener('unload', function() {
|
window.addEventListener('unload', function() {
|
||||||
for ( var unload of vAPI.unload ) {
|
for ( var cleanup of cleanupTasks ) {
|
||||||
unload();
|
cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
// frameModule needs to be cleared too
|
// frameModule needs to be cleared too
|
||||||
|
Loading…
Reference in New Issue
Block a user