Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0 License, and code samples are licensed under the BSD License.
©2011 Google
Use the chrome.experimental.clear
module to remove browsing data
from a user's local profile. This module is still experimental. For more
information regarding the usage of experimental APIs, see the
chrome.experimental.* APIs page.
You must declare the "clear" permission in the extension manifest to use this API. As the API is still experimental, you must declare the "experimental" permisson as well.
{ "name": "My extension", ... "permissions": [ "clear", "experimental" ], ... }
This API provides a time-based mechanism for clearing a user's browsing data.
Your code should provide a timestamp which indicates the historical date after
which the user's browsing data should be removed. This timestamp is formatted
as the number of milliseconds since the Unix epoch (which can be retrieved
from a JavaScript Date
object via the getTime
method).
For example, to clear all of a user's browsing data from the last week, you might write code as follows:
var callback = function () { // Do something clever here once data has been removed. }; var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7; var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek; chrome.experimental.clear.browsingData(oneWeekAgo, { "appcache": true, "cache": true, "cookies": true, "downloads": true, "fileSystems": true, "formData": true, "history": true, "indexedDB": true, "localStorage": true, "pluginData": true, "passwords": true, "webSQL": true }, callback);
The chrome.experimental.clear.browsingData
method allows you to
remove various types of browsing data with a single call, and will be much
faster than calling multiple more specific methods. If, however, you only
want to clear one specific type of browsing data (cookies, for example), the
more granular methods offer a readable alternative to a call filled with JSON.
var callback = function () { // Do something clever here once data has been removed. }; var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7; var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek; chrome.experimental.clear.cookies(oneWeekAgo, callback);
Important: Removing browsing data involves a good deal of heavy lifting in the background, and can take tens of seconds to complete, depending on a user's profile. You should use the callback mechanism to keep your users up to date on the removal's status.
Samples for the clear
API are available
on the samples page.
Clears websites' appcache data.
If you specify the callback parameter, it should specify a function that looks like this:
function() {...};
Clears various types of browsing data stored in a user's profile.
false
).If you specify the callback parameter, it should specify a function that looks like this:
function() {...};
Clears the browser's cache.
If you specify the callback parameter, it should specify a function that looks like this:
function() {...};
Clears the browser's cookies modified within a particular timeframe.
If you specify the callback parameter, it should specify a function that looks like this:
function() {...};
Clears the browser's list of downloaded files (not the downloaded files themselves).
If you specify the callback parameter, it should specify a function that looks like this:
function() {...};
Clears websites' file system data.
If you specify the callback parameter, it should specify a function that looks like this:
function() {...};
Clears the browser's stored form data (autofill).
If you specify the callback parameter, it should specify a function that looks like this:
function() {...};
Clears the browser's history.
If you specify the callback parameter, it should specify a function that looks like this:
function() {...};
Clears websites' IndexedDB data.
If you specify the callback parameter, it should specify a function that looks like this:
function() {...};
Clears websites' local storage data.
If you specify the callback parameter, it should specify a function that looks like this:
function() {...};
Clears the browser's stored passwords.
If you specify the callback parameter, it should specify a function that looks like this:
function() {...};
Clears plugins' data.
If you specify the callback parameter, it should specify a function that looks like this:
function() {...};
Clears websites' WebSQL data.
If you specify the callback parameter, it should specify a function that looks like this:
function() {...};