OLD | NEW |
1 <p>The downloads API allows you to programmatically initiate, monitor, | 1 <p>The downloads API allows you to programmatically initiate, monitor, |
2 manipulate, and search for downloads.</p> | 2 manipulate, and search for downloads.</p> |
3 | 3 |
4 <h2 id='manifest'>Manifest</h2> | 4 <h2 id='manifest'>Manifest</h2> |
5 | 5 |
6 <p> You must declare the 'downloads' permission in the <a | 6 <p> You must declare the 'downloads' permission in the <a |
7 href='manifest.html'>extension manifest</a> to use this API, along with <a | 7 href='manifest.html'>extension manifest</a> to use this API, along with <a |
8 href='manifest.html#permissions'>host permissions</a> for any hosts that you | 8 href='declare_permissions.html'>host permissions</a> for any hosts that you |
9 may pass to $ref:downloads.download.</p> | 9 may pass to $ref:downloads.download.</p> |
10 | 10 |
11 <pre>{ | 11 <pre>{ |
12 'name': 'My extension', | 12 'name': 'My extension', |
13 ... | 13 ... |
14 <b> 'permissions': [ | 14 <b> 'permissions': [ |
15 'downloads', | 15 'downloads', |
16 '*://*.google.com' | 16 '*://*.google.com' |
17 ]</b>, | 17 ]</b>, |
18 ... | 18 ... |
19 }</pre> | 19 }</pre> |
20 | 20 |
21 <p>If the URL's hostname is not specified in the permissions, then | 21 <p>If the URL's hostname is not specified in the permissions, then |
22 $ref:downloads.download will call its callback with a null | 22 $ref:downloads.download will call its callback with a null |
23 <code>downloadId</code> and set the | 23 <code>downloadId</code> and set the |
24 $ref:runtime.lastError | 24 $ref:runtime.lastError |
25 object to indicate that the extension does not have permission to access that | 25 object to indicate that the extension does not have permission to access that |
26 hostname.</p> | 26 hostname.</p> |
27 | 27 |
28 <h2 id='examples'>Examples</h2> | 28 <h2 id='examples'>Examples</h2> |
29 | 29 |
30 <p>You can find simple examples of using the downloads module in the <a | 30 <p>You can find simple examples of using the downloads module in the <a |
31 href='http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/d
ocs/examples/api/downloads/'>examples/api/downloads</a> | 31 href='http://src.chromium.org/viewvc/chrome/trunk/src/chrome/common/extensions/d
ocs/examples/api/downloads/'>examples/api/downloads</a> |
32 directory. For other examples and for help in viewing the source code, see <a | 32 directory. For other examples and for help in viewing the source code, see <a |
33 href='samples.html'>Samples</a>.</p> | 33 href='samples.html'>Samples</a>.</p> |
OLD | NEW |