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

Side by Side Diff: chrome/common/extensions/docs/server2/templates/intros/browsingData.html

Issue 10832042: Extensions Docs Server: Doc conversion script (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: everything but svn stuff Created 8 years, 4 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 <!-- BEGIN AUTHORED CONTENT -->
2 <p id="classSummary"> 1 <p id="classSummary">
3 Use the <code>chrome.browsingData</code> module to remove browsing data from a 2 Use the <code>chrome.browsingData</code> module to remove browsing data from a
4 user's local profile. 3 user's local profile.
5 </p> 4 </p>
5
6 <h2 id="manifest">Manifest</h2> 6 <h2 id="manifest">Manifest</h2>
7
7 <p> 8 <p>
8 You must declare the "browsingData" permission in the 9 You must declare the "browsingData" permission in the
9 <a href="manifest.html">extension manifest</a> to use this API. 10 <a href="manifest.html">extension manifest</a> to use this API.
10 </p> 11 </p>
12
11 <pre>{ 13 <pre>{
12 "name": "My extension", 14 "name": "My extension",
13 ... 15 ...
14 <b>"permissions": [ 16 <b>"permissions": [
15 "browsingData", 17 "browsingData",
16 ]</b>, 18 ]</b>,
17 ... 19 ...
18 }</pre> 20 }</pre>
21
19 <h2 id="usage">Usage</h2> 22 <h2 id="usage">Usage</h2>
23
20 <p> 24 <p>
21 The simplest use-case for this API is a a time-based mechanism for clearing a 25 The simplest use-case for this API is a a time-based mechanism for clearing a
22 user's browsing data. Your code should provide a timestamp which indicates the 26 user's browsing data. Your code should provide a timestamp which indicates the
23 historical date after which the user's browsing data should be removed. This 27 historical date after which the user's browsing data should be removed. This
24 timestamp is formatted as the number of milliseconds since the Unix epoch 28 timestamp is formatted as the number of milliseconds since the Unix epoch
25 (which can be retrieved from a JavaScript <code>Date</code> object via the 29 (which can be retrieved from a JavaScript <code>Date</code> object via the
26 <code>getTime</code> method). 30 <code>getTime</code> method).
27 </p> 31 </p>
32
28 <p> 33 <p>
29 For example, to clear all of a user's browsing data from the last week, you 34 For example, to clear all of a user's browsing data from the last week, you
30 might write code as follows: 35 might write code as follows:
31 </p> 36 </p>
37
32 <pre>var callback = function () { 38 <pre>var callback = function () {
33 // Do something clever here once data has been removed. 39 // Do something clever here once data has been removed.
34 }; 40 };
41
35 var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7; 42 var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7;
36 var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek; 43 var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek;
37 chrome.browsingData.remove({ 44 chrome.browsingData.remove({
38 "since": oneWeekAgo 45 "since": oneWeekAgo
39 }, { 46 }, {
40 "appcache": true, 47 "appcache": true,
41 "cache": true, 48 "cache": true,
42 "cookies": true, 49 "cookies": true,
43 "downloads": true, 50 "downloads": true,
44 "fileSystems": true, 51 "fileSystems": true,
45 "formData": true, 52 "formData": true,
46 "history": true, 53 "history": true,
47 "indexedDB": true, 54 "indexedDB": true,
48 "localStorage": true, 55 "localStorage": true,
49 "pluginData": true, 56 "pluginData": true,
50 "passwords": true, 57 "passwords": true,
51 "webSQL": true 58 "webSQL": true
52 }, callback);</pre> 59 }, callback);</pre>
60
53 <p> 61 <p>
54 The <code>chrome.browsingData.remove</code> method allows you to remove 62 The <code>chrome.browsingData.remove</code> method allows you to remove
55 various types of browsing data with a single call, and will be much faster 63 various types of browsing data with a single call, and will be much faster
56 than calling multiple more specific methods. If, however, you only want to 64 than calling multiple more specific methods. If, however, you only want to
57 clear one specific type of browsing data (cookies, for example), the more 65 clear one specific type of browsing data (cookies, for example), the more
58 granular methods offer a readable alternative to a call filled with JSON. 66 granular methods offer a readable alternative to a call filled with JSON.
59 </p> 67 </p>
68
60 <pre>var callback = function () { 69 <pre>var callback = function () {
61 // Do something clever here once data has been removed. 70 // Do something clever here once data has been removed.
62 }; 71 };
72
63 var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7; 73 var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7;
64 var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek; 74 var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek;
65 chrome.browsingData.removeCookies({ 75 chrome.browsingData.removeCookies({
66 "since": oneWeekAgo 76 "since": oneWeekAgo
67 }, callback);</pre> 77 }, callback);</pre>
78
68 <p class="caution"> 79 <p class="caution">
69 <strong>Important</strong>: Removing browsing data involves a good deal of 80 <strong>Important</strong>: Removing browsing data involves a good deal of
70 heavy lifting in the background, and can take <em>tens of seconds</em> to 81 heavy lifting in the background, and can take <em>tens of seconds</em> to
71 complete, depending on a user's profile. You should use the callback mechanism 82 complete, depending on a user's profile. You should use the callback mechanism
72 to keep your users up to date on the removal's status. 83 to keep your users up to date on the removal's status.
73 </p> 84 </p>
85
74 <h2 id="origin_types">Origin Types</h2> 86 <h2 id="origin_types">Origin Types</h2>
87
75 <p> 88 <p>
76 Adding an <code>originType</code> property to the API's options object allows 89 Adding an <code>originType</code> property to the API's options object allows
77 you to specify which types of origins ought to be effected. Currently, origins 90 you to specify which types of origins ought to be effected. Currently, origins
78 are divided into three categories: 91 are divided into three categories:
79 </p> 92 </p>
80 <ul> 93 <ul>
81 <li> 94 <li>
82 <code>unprotectedWeb</code> covers the general case of websites that users 95 <code>unprotectedWeb</code> covers the general case of websites that users
83 visit without taking any special action. If you don't specify an 96 visit without taking any special action. If you don't specify an
84 <code>originType</code>, the API defaults to removing data from unprotected 97 <code>originType</code>, the API defaults to removing data from unprotected
(...skipping 15 matching lines...) Expand all
100 something you should be very careful about. 113 something you should be very careful about.
101 </li> 114 </li>
102 </ul> 115 </ul>
103 <p> 116 <p>
104 We could adjust the previous example to remove only data from protected 117 We could adjust the previous example to remove only data from protected
105 websites as follows: 118 websites as follows:
106 </p> 119 </p>
107 <pre>var callback = function () { 120 <pre>var callback = function () {
108 // Do something clever here once data has been removed. 121 // Do something clever here once data has been removed.
109 }; 122 };
123
110 var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7; 124 var millisecondsPerWeek = 1000 * 60 * 60 * 24 * 7;
111 var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek; 125 var oneWeekAgo = (new Date()).getTime() - millisecondsPerWeek;
112 chrome.browsingData.remove({ 126 chrome.browsingData.remove({
113 "since": oneWeekAgo, 127 "since": oneWeekAgo,
114 <b>"originType": { 128 <b>"originType": {
115 "protectedWeb": true 129 "protectedWeb": true
116 }</b> 130 }</b>
117 }, { 131 }, {
118 "appcache": true, 132 "appcache": true,
119 "cache": true, 133 "cache": true,
120 "cookies": true, 134 "cookies": true,
121 "downloads": true, 135 "downloads": true,
122 "fileSystems": true, 136 "fileSystems": true,
123 "formData": true, 137 "formData": true,
124 "history": true, 138 "history": true,
125 "indexedDB": true, 139 "indexedDB": true,
126 "localStorage": true, 140 "localStorage": true,
127 "pluginData": true, 141 "pluginData": true,
128 "passwords": true, 142 "passwords": true,
129 "webSQL": true 143 "webSQL": true
130 }, callback);</pre> 144 }, callback);</pre>
145
131 <p class="caution"> 146 <p class="caution">
132 <strong>Seriously</strong>: Be careful with <code>protectedWeb</code> and 147 <strong>Seriously</strong>: Be careful with <code>protectedWeb</code> and
133 <code>extension</code>. These are destructive operations that your users 148 <code>extension</code>. These are destructive operations that your users
134 will write angry email about if they're not well-informed about what to 149 will write angry email about if they're not well-informed about what to
135 expect when your extension removes data on their behalf. 150 expect when your extension removes data on their behalf.
136 </p> 151 </p>
152
137 <h2 id="samples">Examples</h2> 153 <h2 id="samples">Examples</h2>
138 <p> 154 <p>
139 Samples for the <code>browsingData</code> API are available 155 Samples for the <code>browsingData</code> API are available
140 <a href="http://code.google.com/chrome/extensions/trunk/samples.html#chrome.br owsingData">on the samples page</a>. 156 <a href="http://code.google.com/chrome/extensions/trunk/samples.html#chrome.br owsingData">on the samples page</a>.
141 </p> 157 </p>
142 <!-- END AUTHORED CONTENT -->
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698