Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event onBrowserClose for Google Chrome Extension?

Tags:

I am developing an extension for Google Chrome. My background script, everytime, authorizes on a server that uses the XMPP API, and subscribes for a PubSub node. I need to unsubscribe on the exit, otherwise the dummy subscriptions will remain on the server. Is There any onBrowserClose event in the Google Chrome Extension APIs?

like image 844
simple Avatar asked Aug 02 '10 18:08

simple


1 Answers

There is no such event in the Chrome Extension API.

There is however a chrome.windows.onRemoved event that fires each time a window closes. I figured you could check in this event if you closed the last window, but unfortunately due to the asynchronous nature of Chrome this doesn't work.

What I tried was running a simple AJAX request in the onRemoved event handler. The AJAX request never got to the server, as Chrome had already closed before running the event (or just disregarded it).

Making the final answer be: No, currently you can't, as far as I know. You might want to star the following bug report at http://crbug.com/30885 to get noticed on updates.

like image 166
aolde Avatar answered Sep 20 '22 14:09

aolde