Event onBrowserClose for Google Chrome Extension?

后端 未结 5 1969
梦毁少年i
梦毁少年i 2020-11-27 19:08

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 u

5条回答
  •  甜味超标
    2020-11-27 19:47

    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.

提交回复
热议问题