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

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

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

Powered by Google App Engine
This is Rietveld 408576698