Using chrome.browsingData.remove () in incognito mode

I have an extension that removes downloads made in Google Chrome using this line of code on my source page:

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

When the download is in a regular window, it works, however, when the download was made in the Chrome incognito window, it is not deleted. My extension is activated in incognito mode, and the background page is able to detect when the download on the incognito page is completed with:

 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 view data in incognito windows from a man page?

+5
source share
1 answer

The problem you are facing is that your extension works in spanning incognito mode . This means that the extension is performed under one process attached to the profile that installed the extension (that is, not an incognito window). In this situation, the chrome.downloads API fires the onChanged event to load in both incognito and regular profiles, but the chrome.browsingData API chrome.browsingData applies to the normal profile.

Instead, you want to use incognito split mode. This means that the extension is executed separately in each profile that uses it (that is, the incognito window receives its own current copy of the extension). This means that when you call the chrome.browsingData API chrome.browsingData it applies to the window in which the event was fired.

+4
source

All Articles