browsingData Permission

4 min read

browsingData Permission

Overview

This permission allows extensions to clear user browsing data without requiring the user to manually navigate to Chrome’s Clear Browsing Data dialog. It only provides removal capabilities — reading data requires separate permissions like history, cookies, or downloads.

Manifest Declaration

{
  "permissions": ["browsingData"]
}

User Warning: None — this permission does not trigger an install-time warning.

API Methods

General Removal

chrome.browsingData.remove(
  options: RemovalOptions,
  dataToRemove: DataToRemove
): Promise<void>
// Clear all data from the last hour
await chrome.browsingData.remove(
  { since: Date.now() - 3600000 },
  { cache: true, cookies: true, history: true }
);

Specific Removal Methods

chrome.browsingData.removeCache(options)
chrome.browsingData.removeCookies(options)
chrome.browsingData.removeDownloads(options)
chrome.browsingData.removeFormData(options)
chrome.browsingData.removeHistory(options)
chrome.browsingData.removeLocalStorage(options)
chrome.browsingData.removePasswords(options)

Settings

chrome.browsingData.settings(): Promise<Settings>

Returns { options, dataToRemove, dataRemovalPermitted } — the user’s Clear Browsing Data preferences and what the extension is permitted to clear.

Data Types

Property Description
appcache Application caches
cache HTTP cache
cacheStorage Service Worker caches
cookies Cookies
downloads Download history
fileSystems File system API data
formData Autofill form data
history Browsing history
indexedDB IndexedDB data
localStorage localStorage data
passwords Saved passwords
serviceWorkers Service worker registrations
webSQL WebSQL data

Options Object

interface RemovalOptions {
  since?: number;
  originTypes?: {
    unprotectedWeb?: boolean;  // default: true
    protectedWeb?: boolean;
    extension?: boolean;       // default: false
  };
}

Use Cases

Code Examples

Clear All Data from Last Hour

async function clearLastHour() {
  await chrome.browsingData.remove(
    { since: Date.now() - 3600000 },
    {
      cache: true, cookies: true, history: true,
      localStorage: true, formData: true, downloads: true,
      passwords: true, indexedDB: true, webSQL: true,
      fileSystems: true, serviceWorkers: true,
      cacheStorage: true, appcache: true
    }
  );
}

Clear Only Cookies and Cache

async function clearCookiesAndCache() {
  await chrome.browsingData.remove(
    { since: 0 },
    { cookies: true, cache: true }
  );
}

Check What User Permits to Clear

async function checkPermissions() {
  const settings = await chrome.browsingData.settings();
  console.log('Allowed to remove:', settings.dataRemovalPermitted);
  return settings.dataRemovalPermitted;
}

Cross-References

Frequently Asked Questions

How do I clear browsing data from a Chrome extension?

Use the chrome.browsingData API to clear various types of browsing data including cookies, cache, history, downloads, and local storage. Users must grant permission via the browsingData settings.

Can I selectively clear only cookies?

Yes, specify the dataTypes parameter with { “cookies”: true } to clear only cookies while preserving other data. —

Part of the Chrome Extension Guide by theluckystrike. Built at zovo.one.

No previous article
No next article