Closed Bug 386810 Opened 17 years ago Closed 17 years ago

Move quit-application-granted notification to nsAppStartup::Quit

Categories

(Toolkit :: Startup and Profile System, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9alpha8

People

(Reporter: mwu, Assigned: mwu)

References

()

Details

Attachments

(1 file)

There's no need to force users to do the quit-application-granted notification before calling nsAppStartup::Quit. The quit function can do it itself.
Attachment #275672 - Flags: review?(benjamin)
Attachment #275672 - Flags: review?(benjamin) → review+
Checking in layout/tools/pageloader/quit.js;
/cvsroot/mozilla/layout/tools/pageloader/quit.js,v  <--  quit.js
new revision: 1.2; previous revision: 1.1
done
Checking in layout/tools/reftest/quit.js;
/cvsroot/mozilla/layout/tools/reftest/quit.js,v  <--  quit.js
new revision: 1.3; previous revision: 1.2
done
Checking in testing/mochitest/tests/SimpleTest/quit.js;
/cvsroot/mozilla/testing/mochitest/tests/SimpleTest/quit.js,v  <--  quit.js
new revision: 1.9; previous revision: 1.8
done
Checking in toolkit/components/startup/src/nsAppStartup.cpp;
/cvsroot/mozilla/toolkit/components/startup/src/nsAppStartup.cpp,v  <--  nsAppStartup.cpp
new revision: 1.17; previous revision: 1.16
done
Checking in toolkit/content/globalOverlay.js;
/cvsroot/mozilla/toolkit/content/globalOverlay.js,v  <--  globalOverlay.js
new revision: 1.34; previous revision: 1.33
done
Checking in toolkit/mozapps/extensions/content/extensions.js;
/cvsroot/mozilla/toolkit/mozapps/extensions/content/extensions.js,v  <--  extensions.js
new revision: 1.133; previous revision: 1.132
done
Checking in toolkit/mozapps/extensions/content/list.js;
/cvsroot/mozilla/toolkit/mozapps/extensions/content/list.js,v  <--  list.js
new revision: 1.12; previous revision: 1.11
done
Checking in toolkit/mozapps/update/content/updates.js;
/cvsroot/mozilla/toolkit/mozapps/update/content/updates.js,v  <--  updates.js
new revision: 1.75; previous revision: 1.74
done
Checking in toolkit/xre/MacApplicationDelegate.mm;
/cvsroot/mozilla/toolkit/xre/MacApplicationDelegate.mm,v  <--  MacApplicationDelegate.mm
new revision: 1.5; previous revision: 1.4
done
Checking in toolkit/xre/nsCommandLineServiceMac.cpp;
/cvsroot/mozilla/toolkit/xre/nsCommandLineServiceMac.cpp,v  <--  nsCommandLineServiceMac.cpp
new revision: 1.10; previous revision: 1.9
done
Checking in toolkit/xre/nsNativeAppSupportUnix.cpp;
/cvsroot/mozilla/toolkit/xre/nsNativeAppSupportUnix.cpp,v  <--  nsNativeAppSupportUnix.cpp
new revision: 1.3; previous revision: 1.2
done
Checking in toolkit/xre/nsNativeAppSupportWin.cpp;
/cvsroot/mozilla/toolkit/xre/nsNativeAppSupportWin.cpp,v  <--  nsNativeAppSupportWin.cpp
new revision: 1.32; previous revision: 1.31
done
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
After this check-in 'quit-application-granted' is not being fired on Windows XP when the 'X' button is clicked. My posts to the mozillazine forum have gone unanswered. Can anyone reading this reproduce my result?
Ravjot, you should file a new bug for your issue with as much detail as possible.
Digging around after Benjamin's suggestion I found this bug https://bugzilla.mozilla.org/show_bug.cgi?id=408805

Its pretty wack that I have to write a component for my extension just to observe this event. Is there anyway I can protest this code change?
No, the ordering of events is logical for a multi-window application.
So there is no Javascript way to observe for this event?
Yes there is, you just have to use a JS component and not a window.

It doesn't make much sense to have browser-window code observering this event... what happens if there are no browser windows open (e.g. just the download manager) and then the user quits? You wouldn't catch the quit event in that case either.
Ok so I have a component that I register using the following code:

var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
		    observerService.addObserver(this, "em-action-requested", false);
		    observerService.addObserver(this, "quit-application-granted", false);

But this code lives in my extension's js file. Do I need to load my js in the global scope (using somthing like:

var jsLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
                        .getService(Components.interfaces.mozIJSSubScriptLoader);        
        jsLoader.loadSubScript("uninstallObserver.js") and then registering it?


My component looks like this:

UninstallObserver : {
    	
	    _uninstall : false,
    	
	    observe:function(subject,topic,data)
	    {		
    	
		    if (topic == "em-action-requested") {
                /*set Uninstall flag - this._uninstall*/
			    }
		    }		
		    else if (topic == "quit-application-granted") {
				    //alert("QUIT!");
				    if (this._uninstall) {
					    /* uninstall stuff. */										
				    }
			    }
    		
	    },

	    register:function()
	    {
		    var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
		    observerService.addObserver(this, "em-action-requested", false);
		    observerService.addObserver(this, "quit-application-granted", false);
	    },

	    deregister:function()
	    {
		    var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
		    observerService.removeObserver(this,"em-action-requested");
		    observerService.removeObserver(this,"quit-application-granted");
	    }
    }

And register is called when my extension is loaded (using window.addEventListener("load", function() {obj.UninstallObserver.register() }, false);

The component is getting registered, because this code executes if I use the Restart Button on the add-ons windows.

My question is, how do I register this properly so it gets caught? From reading the code, I have no indication that I am in fact registering it to a browser-window, other than by virtue of it being a part of my extension's js code.

Please advise!

Thanks,

Rav
Component: XRE Startup → Startup and Profile System
QA Contact: xre.startup → startup
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: