browsingData Permission
4 min readbrowsingData Permission
Overview
- Permission string:
"browsingData" - API exposed:
chrome.browsingData - Purpose: Remove browsing data (cache, cookies, history, downloads, passwords, localStorage, etc.) programmatically
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>
options.since— Timestamp in ms since epoch. Only clears data created after this time.dataToRemove— Object with boolean flags for each data type.
// 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
- Privacy/cleanup tools: One-click “clear all” functionality
- Selective clearing: Clear only cookies and cache for a specific time range
- Privacy mode toggle: Automatically clear data when extension is disabled
- Development tools: Clear site data during testing
- “Panic button” features: Quickly erase browsing data with a shortcut
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
- cookies.md — Read/write cookies (browsingData only removes them)
- history.md — Read browsing history
- downloads.md — Manage download history
- patterns/privacy-api.md — Privacy-focused API patterns
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.