Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(129)

Side by Side Diff: chrome/common/extensions/docs/static/browsingData.html

Issue 9424036: Move `browsingData` extension API out of experimental. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebuilt docs. Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <div id="pageData-name" class="pageData">BrowsingData API</div> 1 <div id="pageData-name" class="pageData">BrowsingData API</div>
2 2
3 <!-- BEGIN AUTHORED CONTENT --> 3 <!-- BEGIN AUTHORED CONTENT -->
4 <p id="classSummary"> 4 <p id="classSummary">
5 Use the <code>chrome.experimental.browsingData</code> module to remove 5 Use the <code>chrome.browsingData</code> module to remove browsing data from a
6 browsing data from a user's local profile. This module is still experimental. 6 user's local profile.
7 For more information regarding the usage of experimental APIs, see the
8 <a href="experimental.html">chrome.experimental.* APIs</a> page.
9 </p> 7 </p>
10 8
11 <h2 id="manifest">Manifest</h2> 9 <h2 id="manifest">Manifest</h2>
12 10
13 <p> 11 <p>
14 You must declare the "clear" permission in the 12 You must declare the "clear" permission in the
15 <a href="manifest.html">extension manifest</a> to use this API. As the API is 13 <a href="manifest.html">extension manifest</a> to use this API.
16 still experimental, you must declare the "experimental" permisson as well.
17 </p> 14 </p>
18 15
19 <pre>{ 16 <pre>{
20 "name": "My extension", 17 "name": "My extension",
21 ... 18 ...
22 <b>"permissions": [ 19 <b>"permissions": [
23 "browsingData", 20 "browsingData",
24 "experimental"
25 ]</b>, 21 ]</b>,
26 ... 22 ...
27 }</pre> 23 }</pre>
28 24
29 <h2 id="usage">Usage</h2> 25 <h2 id="usage">Usage</h2>
30 26
31 <p> 27 <p>
32 The simplest use-case for this API is a a time-based mechanism for clearing a 28 The simplest use-case for this API is a a time-based mechanism for clearing a
33 user's browsing data. Your code should provide a timestamp which indicates the 29 user's browsing data. Your code should provide a timestamp which indicates the
34 historical date after which the user's browsing data should be removed. This 30 historical date after which the user's browsing data should be removed. This
35 timestamp is formatted as the number of milliseconds since the Unix epoch 31 timestamp is formatted as the number of milliseconds since the Unix epoch
36 (which can be retrieved from a JavaScript <code>Date</code> object via the 32 (which can be retrieved from a JavaScript <code>Date</code> object via the
37 <code>getTime</code> method). 33 <code>getTime</code> method).
38 </p> 34 </p>
39 35
40 <p> 36 <p>
41 For example, to clear all of a user's browsing data from the last week, you 37 For example, to clear all of a user's browsing data from the last week, you
42 might write code as follows: 38 might write code as follows:
43 </p> 39 </p>
44 40
45 <pre>var callback = function () { 41 <pre>var callback = function () {
46 // Do something clever here once data has been removed. 42 // Do something clever here once data has been removed.
47 }; 43 };
48 44
49 var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7; 45 var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7;
50 var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek; 46 var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek;
51 chrome.experimental.browsingData.remove({ 47 chrome.browsingData.remove({
52 "since": oneWeekAgo 48 "since": oneWeekAgo
53 }, { 49 }, {
54 "appcache": true, 50 "appcache": true,
55 "cache": true, 51 "cache": true,
56 "cookies": true, 52 "cookies": true,
57 "downloads": true, 53 "downloads": true,
58 "fileSystems": true, 54 "fileSystems": true,
59 "formData": true, 55 "formData": true,
60 "history": true, 56 "history": true,
61 "indexedDB": true, 57 "indexedDB": true,
62 "localStorage": true, 58 "localStorage": true,
63 "pluginData": true, 59 "pluginData": true,
64 "passwords": true, 60 "passwords": true,
65 "webSQL": true 61 "webSQL": true
66 }, callback);</pre> 62 }, callback);</pre>
67 63
68 <p> 64 <p>
69 The <code>chrome.experimental.browsingData.remove</code> method allows you to 65 The <code>chrome.browsingData.remove</code> method allows you to remove
70 remove various types of browsing data with a single call, and will be much 66 various types of browsing data with a single call, and will be much faster
71 faster than calling multiple more specific methods. If, however, you only 67 than calling multiple more specific methods. If, however, you only want to
72 want to clear one specific type of browsing data (cookies, for example), the 68 clear one specific type of browsing data (cookies, for example), the more
73 more granular methods offer a readable alternative to a call filled with JSON. 69 granular methods offer a readable alternative to a call filled with JSON.
74 </p> 70 </p>
75 71
76 <pre>var callback = function () { 72 <pre>var callback = function () {
77 // Do something clever here once data has been removed. 73 // Do something clever here once data has been removed.
78 }; 74 };
79 75
80 var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7; 76 var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7;
81 var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek; 77 var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek;
82 chrome.experimental.browsingData.removeCookies({ 78 chrome.browsingData.removeCookies({
83 "since": oneWeekAgo 79 "since": oneWeekAgo
84 }, callback);</pre> 80 }, callback);</pre>
85 81
86 <p class="caution"> 82 <p class="caution">
87 <strong>Important</strong>: Removing browsing data involves a good deal of 83 <strong>Important</strong>: Removing browsing data involves a good deal of
88 heavy lifting in the background, and can take <em>tens of seconds</em> to 84 heavy lifting in the background, and can take <em>tens of seconds</em> to
89 complete, depending on a user's profile. You should use the callback mechanism 85 complete, depending on a user's profile. You should use the callback mechanism
90 to keep your users up to date on the removal's status. 86 to keep your users up to date on the removal's status.
91 </p> 87 </p>
92 88
93 <h2 id="samples">Examples</h2> 89 <h2 id="samples">Examples</h2>
94 <p> 90 <p>
95 Samples for the <code>browsingData</code> API are available 91 Samples for the <code>browsingData</code> API are available
96 <a href="http://code.google.com/chrome/extensions/trunk/samples.html#chrome.ex perimental.browsingData">on the samples page</a>. 92 <a href="http://code.google.com/chrome/extensions/trunk/samples.html#chrome.br owsingData">on the samples page</a>.
97 </p> 93 </p>
98 94
99 <!-- END AUTHORED CONTENT --> 95 <!-- END AUTHORED CONTENT -->
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/samples.json ('k') | chrome/common/extensions/docs/static/experimental.browsingData.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698