在隐身模式下使用chrome.browsingData.remove() [英] Using chrome.browsingData.remove() in incognito mode

查看:290
本文介绍了在隐身模式下使用chrome.browsingData.remove()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个扩展程序,可在后台页面中使用以下代码删除在Google Chrome浏览器中进行的下载:

I have an extension removing the downloads made in Google Chrome using this line of code in my background page:

chrome.browsingData.remove({ "since": 0 }, { "downloads": true });

在正常窗口中进行下载时,它可以工作,但是在隐身的Chrome窗口中进行下载时,则不会将其删除.我的扩展程序在隐身模式下被激活,后台页面能够使用以下命令检测隐身页面中的下载何时完成:

When a download is in a normal window it works however when a download has been made in an incognito Chrome window it is not removed. My extension is activated in incognito mode and the background page is able to detect when a download in the incognito page has been completed using:

chrome.downloads.onChanged.addListener(function(download) {
    if (download.state && download.state.current == "complete") {
        // The code here is fired even if the download has been completed in incognito mode
    }
}

是否可以从后台页面删除隐身窗口中的浏览数据?

Is there a way to remove the browsing data in incognito windows from a background page?

推荐答案

您面临的问题是您的扩展程序正在

The problem you're facing is that your extension is running in spanning incognito mode. This means that the extension runs under a single process attached to the profile that installed the extension (i.e. not the incognito window). In this situation, the chrome.downloads API fires the onChanged event for downloads in both incognito and normal profiles, but the chrome.browsingData API only applies to the normal profile.

相反,您想使用split隐身模式.这意味着该扩展程序会在使用该扩展程序的每个配置文件中单独运行(即,隐身窗口会获得自己的扩展程序运行副本).这意味着,当您调用chrome.browsingData API时,它将应用于触发事件的窗口.

Instead, you want to use split incognito mode. This means that the extension runs separately in each profile that uses it (i.e. the incognito window gets its own running copy of the extension). This means that when you call the chrome.browsingData API, it applies to the window that fired the event.

这篇关于在隐身模式下使用chrome.browsingData.remove()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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