Google Chrome 扩展程序的 onBrowserClose 事件? [英] Event onBrowserClose for Google Chrome Extension?

查看:35
本文介绍了Google Chrome 扩展程序的 onBrowserClose 事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 Google Chrome 开发一个扩展程序.我的后台脚本每次都在使用 XMPP API 的服务器上授权,并订阅 PubSub 节点.我需要在退出时取消订阅,否则虚拟订阅将保留在服务器上.Google Chrome 扩展 API 中是否有任何 onBrowserClose 事件?

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?

推荐答案

Chrome 扩展 API 中没有此类事件.

There is no such event in the Chrome Extension API.

然而,每次关闭窗口时都会触发一个 chrome.windows.onRemoved 事件.我想如果您关闭最后一个窗口,您可以检查此事件,但不幸的是,由于 Chrome 的异步特性,这不起作用.

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.

我尝试在 onRemoved 事件处理程序中运行一个简单的 AJAX 请求.AJAX 请求从未到达服务器,因为 Chrome 在运行事件之前已经关闭(或者只是忽略它).

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).

最后的答案是:不,目前你不能,据我所知.您可能希望在 http://crbug.com/30885 上为以下错误报告加星标,以便在更新时引起注意.

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.

这篇关于Google Chrome 扩展程序的 onBrowserClose 事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆