OLD | NEW |
1 <h1>Formats: Manifest Files</h1> | 1 <h1>Formats: Manifest Files</h1> |
2 | 2 |
3 | 3 |
4 <p> | 4 <p> |
5 Every extension, installable web app, and theme has a | 5 Every extension, installable web app, and theme has a |
6 <a href="http://www.json.org">JSON</a>-formatted manifest file, | 6 <a href="http://www.json.org">JSON</a>-formatted manifest file, |
7 named <code>manifest.json</code>, | 7 named <code>manifest.json</code>, |
8 that provides important information. | 8 that provides important information. |
9 </p> | 9 </p> |
10 | 10 |
11 <h2 id="overview"> Field summary </h2> | 11 <h2 id="overview"> Field summary </h2> |
12 | 12 |
13 <p> | 13 <p> |
14 The following code shows the supported manifest fields, | 14 The following code shows the supported manifest fields, |
15 with links to the page that discusses each field. | 15 with links to the page that discusses each field. |
16 The only fields that are always required | 16 The only fields that are always required |
17 are <b>name</b> and <b>version</b>. | 17 are <b>name</b> and <b>version</b>. |
18 </p> | 18 </p> |
19 | 19 |
20 <pre> | 20 {{+partials.manifest_example manifest_source:manifest_source}} |
21 { | |
22 <em>// Required</em> | |
23 "<a href="#name">name</a>": "<em>My Extension</em>", | |
24 "<a href="#version">version</a>": "<em>versionString</em>", | |
25 "<a href="#manifest_version">manifest_version</a>": 2, | |
26 {{?is_apps}} | |
27 "<a href="#app">app</a>": {...}, | |
28 {{/is_apps}} | |
29 | |
30 <em>// Recommended</em> | |
31 "<a href="#description">description</a>": "<em>A plain text description</em>", | |
32 "<a href="#icons">icons</a>": { ... }, | |
33 "<a href="#default_locale">default_locale</a>": "<em>en</em>", | |
34 {{^is_apps}} | |
35 | |
36 <em>// Pick one (or none)</em> | |
37 "<a href="browserAction.html">browser_action</a>": {...}, | |
38 "<a href="pageAction.html">page_action</a>": {...}, | |
39 "<a href="themes.html">theme</a>": {...}, | |
40 "<a href="#app">app</a>": {...}, | |
41 {{/is_apps}} | |
42 | |
43 <em>// Add any of these that you need</em> | |
44 "<a href="event_pages.html">background</a>": {"persistent": false, ...}, | |
45 "<a href="background_pages.html">background</a>": {"persistent": true, ...}, | |
46 {{^is_apps}} | |
47 "<a href="override.html">chrome_url_overrides</a>": {...}, | |
48 {{/is_apps}} | |
49 "<a href="content_scripts.html">content_scripts</a>": [...], | |
50 "<a href="contentSecurityPolicy.html">content_security_policy</a>": "<em>polic
yString</em>", | |
51 "<a href="fileBrowserHandler.html">file_browser_handlers</a>": [...], | |
52 "<a href="#file_handlers">file_handlers</a>": {...}, | |
53 "<a href="#homepage_url">homepage_url</a>": "http://<em>path/to/homepage</em>"
, | |
54 "<a href="#incognito">incognito</a>": "spanning" <em>or</em> "split", | |
55 "<a href="#key">key</a>": "<em>publicKey</em>", | |
56 "<a href="#minimum_chrome_version">minimum_chrome_version</a>": "<em>versionSt
ring</em>", | |
57 | |
58 "<a href="#nacl_modules">nacl_modules</a>": [...], | |
59 "<a href="#kiosk_enabled">kiosk_enabled</a>": true, | |
60 "<a href="#offline_enabled">offline_enabled</a>": true, | |
61 "<a href="omnibox.html">omnibox</a>": { "keyword": "<em>aString</em>" }, | |
62 {{^is_apps}} | |
63 "<a href="options.html">options_page</a>": "<em>aFile</em>.html", | |
64 {{/is_apps}} | |
65 "<a href="declare_permissions.html">permissions</a>": [...], | |
66 "<a href="npapi.html">plugins</a>": [...], | |
67 "<a href="#requirements">requirements</a>": {...}, | |
68 "<a href="autoupdate.html">update_url</a>": "http://<em>path/to/updateInfo</em
>.xml", | |
69 "<a href="#web_accessible_resources">web_accessible_resources</a>": [...], | |
70 "<a href="#sandbox">sandbox</a>": [...] | |
71 } | |
72 </pre> | |
73 | |
74 | |
75 <h2 id="field_details">Field details</h2> | |
76 | |
77 <p> | |
78 This section covers fields that aren't described in another page. | |
79 For a complete list of fields, | |
80 with links to where they're described in detail, | |
81 see the <a href="#overview">Field summary</a>. | |
82 </p> | |
83 | |
84 | |
85 <h3 id="app">app</h3> | |
86 | |
87 <p> | |
88 Used by <a href="../apps/app_lifecycle.html#eventpage">packaged apps</a> | |
89 to specify the app's background scripts. | |
90 Also used by <a href="https://developers.google.com/chrome/apps/docs/developers_
guide#live">hosted apps</a> | |
91 to specify the URLs that the app uses. | |
92 </p> | |
93 | |
94 <h3 id="default_locale">default_locale</h3> | |
95 | |
96 <p> | |
97 Specifies the subdirectory of <code>_locales</code> | |
98 that contains the default strings for this extension. | |
99 This field is <b>required</b> in extensions | |
100 that have a <code>_locales</code> directory; | |
101 it <b>must be absent</b> in extensions | |
102 that have no <code>_locales</code> directory. | |
103 For details, see | |
104 <a href="i18n.html">Internationalization</a>. | |
105 </p> | |
106 | |
107 <h3 id="description">description</h3> | |
108 | |
109 <p> | |
110 A plain text string | |
111 (no HTML or other formatting; | |
112 no more than 132 characters) | |
113 that describes the extension. | |
114 The description should be suitable for both | |
115 the browser's extension management UI | |
116 and the <a href="https://chrome.google.com/webstore">Chrome Web Store</a>. | |
117 You can specify locale-specific strings for this field; | |
118 see <a href="i18n.html">Internationalization</a> for details. | |
119 </p> | |
120 | |
121 <h3 id="file_handlers">file_handlers</h3> | |
122 | |
123 <p> | |
124 Used by <a href="../apps/app_lifecycle.html#eventpage">packaged apps</a> | |
125 to specify what types of files the app can handle. An app can have multiple <cod
e>file_handlers</code>, with each one having an identifier, a list of MIME types
and/or a list of file extensions that can be handled, and | |
126 a title. The app can handle a file if it either has a matching file extension or | |
127 has a matching MIME type. | |
128 You can use a wildcard <code>"*"</code> in <code>types</code> or | |
129 <code>extensions</code> to indicate that the app can handle any file type or | |
130 <code>"<em>type</em>/*"</code> in <code>types</code> to indicate that the app | |
131 can handle any file with a MIME type of <code><em>type</em></code>. | |
132 Here's an example of specifying file handlers: | |
133 </p> | |
134 | |
135 <pre> | |
136 "file_handlers": { | |
137 "text": { | |
138 "types": [ | |
139 "text/*" | |
140 ], | |
141 "title": "Text editor" | |
142 }, | |
143 "image": { | |
144 "types": [ | |
145 "image/png", | |
146 "image/jpeg" | |
147 ], | |
148 "extensions": [ | |
149 "tiff" | |
150 ] | |
151 "title": "Image editor" | |
152 }, | |
153 "any": { | |
154 "extensions": [ | |
155 "*" | |
156 ] | |
157 "title": "Any file type editor" | |
158 } | |
159 } | |
160 </pre> | |
161 | |
162 <p> | |
163 To handle files, apps also need to declare the $ref:fileSystem | |
164 permission. Apps can then be passed files in the $ref:app.runtime.onLaunched | |
165 event - either from the system | |
166 file manager (currently supported on ChromeOS only) or by providing | |
167 a path on the <a href="../apps/first_app.html#open">command line</a>. | |
168 </p> | |
169 | |
170 <h3 id="homepage_url">homepage_url</h3> | |
171 | |
172 <p> | |
173 The URL of the homepage for this extension. The extensions management page (chro
me://extensions) | |
174 will contain a link to this URL. This field is particularly useful if you | |
175 <a href="hosting.html">host the extension on your own site</a>. If you distribut
e your | |
176 extension using the <a href="https://chrome.google.com/webstore">Chrome Web Stor
e</a>, | |
177 the homepage URL defaults to the extension's own page. | |
178 </p> | |
179 | |
180 <h3 id="icons">icons</h3> | |
181 | |
182 <p> | |
183 One or more icons that represent the extension, app, or theme. | |
184 You should always provide a 128x128 icon; | |
185 it's used during installation and by the Chrome Web Store. | |
186 Extensions should also provide a 48x48 icon, | |
187 which is used in the extensions management page | |
188 (chrome://extensions). | |
189 You can also specify a 16x16 icon to be used as the favicon | |
190 for an extension's pages. | |
191 The 16x16 icon is also displayed in the experimental extension | |
192 <a href="infobars.html">infobar</a> | |
193 feature. | |
194 </p> | |
195 | |
196 <p> | |
197 Icons should generally be in PNG format, | |
198 because PNG has the best support for transparency. | |
199 They can, however, be in any format supported by WebKit, | |
200 including BMP, GIF, ICO, and JPEG. | |
201 Here's an example of specifying the icons: | |
202 </p> | |
203 | |
204 <pre> | |
205 "icons": { "16": "icon16.png", | |
206 "48": "icon48.png", | |
207 "128": "icon128.png" }, | |
208 </pre> | |
209 | |
210 <p class="note"> | |
211 You may provide icons of any other size you wish, and Chrome will attempt to use | |
212 the best size where appropriate. For example, Windows often requires 32-pixel | |
213 icons, and if the app includes a 32-pixel icon, Chrome will choose that instead | |
214 of shrinking a 48-pixel icon down. However, you should ensure that all of your | |
215 icons are square, or unexpected behavior may result. | |
216 </p> | |
217 | |
218 <p> | |
219 If you upload your extension, app, or theme using the | |
220 <a href="https://chrome.google.com/webstore/developer/dashboard">Chrome Develope
r Dashboard</a>, | |
221 you'll need to upload additional images, | |
222 including at least one screenshot of your extension. | |
223 For more information, | |
224 see the | |
225 <a href="http://code.google.com/chrome/webstore/">Chrome Web Store | |
226 developer documentation</a>. | |
227 </p> | |
228 | |
229 <h3 id="incognito">incognito</h3> | |
230 | |
231 <p> | |
232 Either "spanning" or "split", to specify how this extension will | |
233 behave if allowed to run in incognito mode. | |
234 </p> | |
235 | |
236 <p> | |
237 The default for extensions is "spanning", which means that the extension | |
238 will run in a single shared process. Any events or messages from an incognito | |
239 tab will be sent to the shared process, with an <em>incognito</em> flag | |
240 indicating where it came from. Because incognito tabs cannot use this shared | |
241 process, an extension using the "spanning" incognito mode will not be able to | |
242 load pages from its extension package into the main frame of an incognito tab. | |
243 </p> | |
244 | |
245 <p> | |
246 The default for installable web apps is "split", | |
247 which means that all app pages in | |
248 an incognito window will run in their own incognito process. If the app or exten
sion contains a background page, that will also run in the incognito process. | |
249 This incognito process runs along side the regular process, but has a separate | |
250 memory-only cookie store. Each process sees events and messages only from its | |
251 own context (for example, the incognito process will see only incognito tab upda
tes). | |
252 The processes are unable to communicate with each other. | |
253 </p> | |
254 | |
255 <p> | |
256 As a rule of thumb, if your extension or app needs to load a tab in an incognito
browser, use | |
257 <em>split</em> incognito behavior. If your extension or app needs to be logged | |
258 into a remote server or persist settings locally, use <em>spanning</em> | |
259 incognito behavior. | |
260 </p> | |
261 | |
262 <h3 id="key">key</h3> | |
263 | |
264 <p> | |
265 This value can be used to control | |
266 the unique ID of an extension, app, or theme when | |
267 it is loaded during development. | |
268 </p> | |
269 | |
270 <p class="note"> | |
271 <b>Note:</b> You don't usually need to | |
272 use this value. Instead, write your | |
273 code so that the key value doesn't matter | |
274 by using <a href="../extensions/overview.html#relative-urls">relative paths</a> | |
275 and $ref:runtime.getURL. | |
276 </p> | |
277 | |
278 <p> | |
279 To get a suitable key value, first | |
280 install your extension from a <code>.crx</code> file | |
281 (you may need to | |
282 <a href="https://chrome.google.com/webstore/developer/dashboard">upload your ext
ension</a> | |
283 or <a href="packaging.html">package it manually</a>). | |
284 Then, in your | |
285 <a href="http://www.chromium.org/user-experience/user-data-directory">user | |
286 data directory</a>, look in the file | |
287 <code>Default/Extensions/<em><extensionId></em>/<em><versionString><
/em>/manifest.json</code>. | |
288 You will see the key value filled in there. | |
289 </p> | |
290 | |
291 <h3 id="minimum_chrome_version">minimum_chrome_version</h3> | |
292 | |
293 <p> | |
294 The version of Chrome that your extension, app, or theme requires, if any. | |
295 The format for this string is the same as for the | |
296 <a href="#version">version</a> field. | |
297 | |
298 <h3 id="name">name</h3> | |
299 | |
300 <p> | |
301 A short, plain text string | |
302 (no more than 45 characters) | |
303 that identifies the extension. | |
304 The name is used in the install dialog, | |
305 extension management UI, | |
306 and the <a href="https://chrome.google.com/webstore">store</a>. | |
307 You can specify locale-specific strings for this field; | |
308 see <a href="i18n.html">Internationalization</a> for details. | |
309 </p> | |
310 | |
311 <h3 id="nacl_modules">nacl_modules</h3> | |
312 | |
313 <p> | |
314 One or more mappings from MIME types to the Native Client module | |
315 that handles each type. | |
316 For example, the bold code in the following snippet | |
317 registers a Native Client module as the content handler | |
318 for the OpenOffice spreadsheet MIME type. | |
319 </p> | |
320 | |
321 <pre> | |
322 { | |
323 "name": "Native Client OpenOffice Spreadsheet Viewer", | |
324 "version": "0.1", | |
325 "description": "Open OpenOffice spreadsheets, right in your browser.", | |
326 <b>"nacl_modules": [{ | |
327 "path": "OpenOfficeViewer.nmf", | |
328 "mime_type": "application/vnd.oasis.opendocument.spreadsheet" | |
329 }]</b> | |
330 } | |
331 </pre> | |
332 | |
333 <p> | |
334 The value of "path" is the location of a Native Client manifest | |
335 (a <code>.nmf</code> file) | |
336 within the extension directory. | |
337 For more information on Native Client and <code>.nmf</code> files, see the | |
338 <a href="http://code.google.com/chrome/nativeclient/docs/technical_overview.html
">Native Client Technical Overview</a>. | |
339 </p> | |
340 | |
341 <p> | |
342 Each MIME type can be associated with only one <code>.nmf</code> file, | |
343 but a single <code>.nmf</code> file might handle multiple MIME types. | |
344 The following example shows an extension | |
345 with two <code>.nmf</code> files | |
346 that handle three MIME types. | |
347 </p> | |
348 | |
349 <pre> | |
350 { | |
351 "name": "Spreadsheet Viewer", | |
352 "version": "0.1", | |
353 "description": "Open OpenOffice and Excel spreadsheets, right in your browser.
", | |
354 "nacl_modules": [{ | |
355 "path": "OpenOfficeViewer.nmf", | |
356 "mime_type": "application/vnd.oasis.opendocument.spreadsheet" | |
357 }, | |
358 { | |
359 "path": "OpenOfficeViewer.nmf", | |
360 "mime_type": "application/vnd.oasis.opendocument.spreadsheet-template" | |
361 }, | |
362 { | |
363 "path": "ExcelViewer.nmf", | |
364 "mime_type": "application/excel" | |
365 }] | |
366 } | |
367 </pre> | |
368 | |
369 <p class="note"> | |
370 <strong>Note:</strong> | |
371 You can use Native Client modules in extensions | |
372 without specifying "nacl_modules". | |
373 Use "nacl_modules" only if you want the browser | |
374 to use your Native Client module | |
375 to display a particular type of content. | |
376 </p> | |
377 | |
378 <h3 id="kiosk_enabled">kiosk_enabled</h3> | |
379 | |
380 <p> | |
381 Whether the packaged app is designed to expected to work in ChromeOS kiosk mode. | |
382 In kiosk mode, the platform app window will cover the entire surface of the | |
383 display (forced full screen). The kiosk-enabled apps are expected to be designed | |
384 with this constraint in mind. | |
385 </p> | |
386 | |
387 <h3 id="offline_enabled">offline_enabled</h3> | |
388 | |
389 <p> | |
390 Whether the app or extension is expected to work offline. When Chrome detects | |
391 that it is offline, apps with this field set to true will be highlighted | |
392 on the New Tab page. | |
393 </p> | |
394 | |
395 <h3 id="requirements">requirements</h3> | |
396 | |
397 <p> | |
398 Technologies required by the app or extension. | |
399 Hosting sites such as the Chrome Web Store may use this list | |
400 to dissuade users from installing apps or extensions | |
401 that will not work on their computer. | |
402 Supported requirements currently include "3D" and "plugins"; | |
403 additional requirements checks may be added in the future. | |
404 </p> | |
405 | |
406 <p> | |
407 The "3D" requirement denotes GPU hardware acceleration. | |
408 The "webgl" requirement refers to the | |
409 <a href="http://www.khronos.org/webgl/">WebGL API</a>. | |
410 For more information on Chrome 3D graphics support, | |
411 see the help article on | |
412 <a href="http://www.google.com/support/chrome/bin/answer.py?answer=1220892">WebG
L and 3D graphics</a>. | |
413 You can list the 3D-related features your app requires, | |
414 as demonstrated in the following example: | |
415 </p> | |
416 | |
417 <pre> | |
418 "requirements": { | |
419 "3D": { | |
420 "features": ["webgl"] | |
421 } | |
422 } | |
423 </pre> | |
424 | |
425 <p> | |
426 The "plugins" requirement indicates | |
427 if an app or extension requires NPAPI to run. | |
428 This requirement is enabled by default | |
429 when the manifest includes the | |
430 <a href="npapi.html">"plugins" field</a>. | |
431 For apps and extensions that still work when plugins aren't available, | |
432 you can disable this requirement | |
433 by setting NPAPI to false. | |
434 You can also enable this requirement manually, | |
435 by setting NPAPI to true, | |
436 as shown in this example: | |
437 </p> | |
438 | |
439 <pre> | |
440 "requirements": { | |
441 "plugins": { | |
442 "npapi": true | |
443 } | |
444 } | |
445 </pre> | |
446 | |
447 | |
448 <h3 id="version">version</h3> | |
449 | |
450 <p> | |
451 One to four dot-separated integers | |
452 identifying the version of this extension. | |
453 A couple of rules apply to the integers: | |
454 they must be between 0 and 65535, inclusive, | |
455 and non-zero integers can't start with 0. | |
456 For example, 99999 and 032 are both invalid. | |
457 </p> | |
458 | |
459 <p> | |
460 Here are some examples of valid versions: | |
461 </p> | |
462 | |
463 <ul> | |
464 <li> <code>"version": "1"</code> </li> | |
465 <li> <code>"version": "1.0"</code> </li> | |
466 <li> <code>"version": "2.10.2"</code> </li> | |
467 <li> <code>"version": "3.1.2.4567"</code> </li> | |
468 </ul> | |
469 | |
470 <p> | |
471 The autoupdate system compares versions | |
472 to determine whether an installed extension | |
473 needs to be updated. | |
474 If the published extension has a newer version string | |
475 than the installed extension, | |
476 then the extension is automatically updated. | |
477 </p> | |
478 | |
479 <p> | |
480 The comparison starts with the leftmost integers. | |
481 If those integers are equal, | |
482 the integers to the right are compared, | |
483 and so on. | |
484 For example, 1.2.0 is a newer version than 1.1.9.9999. | |
485 </p> | |
486 | |
487 <p> | |
488 A missing integer is equal to zero. | |
489 For example, 1.1.9.9999 is newer than 1.1. | |
490 </p> | |
491 | |
492 <p> | |
493 For more information, see | |
494 <a href="autoupdate.html">Autoupdating</a>. | |
495 </p> | |
496 | |
497 | |
498 | |
499 <h3 id="manifest_version">manifest_version</h3> | |
500 | |
501 <p> | |
502 One integer specifying the version of the manifest file format your package | |
503 requires. As of Chrome 18, developers <em>should</em> specify <code>2</code> | |
504 (without quotes) to use the format as described by this document: | |
505 </p> | |
506 | |
507 <pre>"manifest_version": 2</pre> | |
508 | |
509 <p> | |
510 Consider manifest version 1 <em>deprecated</em> as of Chrome 18. Version 2 is | |
511 not yet <em>required</em>, but we will, at some point in the not-too-distant | |
512 future, stop supporting packages using deprecated manifest versions. Extensions, | |
513 applications, and themes that aren't ready to make the jump to the new manifest | |
514 version in Chrome 18 can either explicitly specify version <code>1</code>, or | |
515 leave the key off entirely. | |
516 </p> | |
517 | |
518 <p> | |
519 The changes between version 1 and version 2 of the manifest file format are | |
520 described in detail in <a href="manifestVersion.html">the | |
521 <code>manifest_version</code> documentation.</a> | |
522 </p> | |
523 | |
524 <p class="caution"> | |
525 Setting <code>manifest_version</code> 2 in Chrome 17 or lower is not | |
526 recommended. If your extension needs to work in older versions of Chrome, | |
527 stick with version 1 for the moment. We'll give you ample warning before | |
528 version 1 stops working. | |
529 </p> | |
530 | |
531 <h3 id="web_accessible_resources">web_accessible_resources</h3> | |
532 | |
533 <p> | |
534 An array of strings specifying the paths (relative to the package root) of | |
535 packaged resources that are expected to be usable in the context of a web page. | |
536 For example, an extension that injects a content script with the intention of | |
537 building up some custom interface for <code>example.com</code> would whitelist | |
538 any resources that interface requires (images, icons, stylesheets, scripts, | |
539 etc.) as follows: | |
540 </p> | |
541 | |
542 <pre>{ | |
543 ... | |
544 "web_accessible_resources": [ | |
545 "images/my-awesome-image1.png", | |
546 "images/my-amazing-icon1.png", | |
547 "style/double-rainbow.css", | |
548 "script/double-rainbow.js" | |
549 ], | |
550 ... | |
551 }</pre> | |
552 | |
553 <p> | |
554 These resources would then be available in a webpage via the URL | |
555 <code>chrome-extension://[PACKAGE ID]/[PATH]</code>, which can be generated with | |
556 the $ref:runtime.getURL method. Whitelisted resources are served with appropriat
e | |
557 <a href="http://www.w3.org/TR/cors/">CORS</a> headers, so they're available via | |
558 mechanisms like XHR. | |
559 </p> | |
560 | |
561 <p> | |
562 Injected content scripts themselves do not need to be whitelisted. | |
563 </p> | |
564 | |
565 <p> | |
566 Prior to manifest version 2 all resources within an extension could be accessed | |
567 from any page on the web. This allowed a malicious website to | |
568 <a href="http://en.wikipedia.org/wiki/Device_fingerprint">fingerprint</a> the | |
569 extensions that a user has installed or exploit vulnerabilities (for example | |
570 <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">XSS bugs</a>)within | |
571 installed extensions. Limiting availability to only resources which are | |
572 explicitly intended to be web accessible serves to both minimize the available | |
573 attack surface and protect the privacy of users. | |
574 </p> | |
575 | |
576 <h4 id="availability">Default Availability</h4> | |
577 | |
578 <p> | |
579 Resources inside of packages using <a href="#manifest_version"><code>manifest_ve
rsion</code></a> | |
580 2 or above are <strong>blocked by default</strong>, and must be whitelisted | |
581 for use via this property. | |
582 </p> | |
583 | |
584 <p> | |
585 Resources inside of packages using <code>manifest_version</code> 1 are available | |
586 by default, but <em>if</em> you do set this property, then it will be treated as | |
587 a complete list of all whitelisted resources. Resources not listed will be | |
588 blocked. | |
589 </p> | |
590 | |
591 <h3 id="sandbox">sandbox</h3> | |
592 | |
593 <p> | |
594 Defines an collection of app or extension pages that are to be served | |
595 in a sandboxed unique origin, and optionally a Content Security Policy to use | |
596 with them. Being in a sandbox has two implications: | |
597 </p> | |
598 | |
599 <ol> | |
600 <li>A sandboxed page will not have access to extension or app APIs, or | |
601 direct access to non-sandboxed pages (it may communicate with them via | |
602 <code>postMessage()</code>).</li> | |
603 <li> | |
604 <p>A sandboxed page is not subject to the | |
605 <a href="../extensions/contentSecurityPolicy.html">Content Security Policy | |
606 (CSP)</a> used by the rest of the app or extension (it has its own separate | |
607 CSP value). This means that, for example, it can use inline script and | |
608 <code>eval</code>.</p> | |
609 | |
610 <p>For example, here's how to specify that two extension pages are to be | |
611 served in a sandbox with a custom CSP:</p> | |
612 | |
613 <pre>{ | |
614 ... | |
615 "sandbox": { | |
616 "pages": [ | |
617 "page1.html", | |
618 "directory/page2.html" | |
619 ] | |
620 <i>// content_security_policy is optional.</i> | |
621 "content_security_policy": | |
622 "sandbox allow-scripts; script-src https://www.google.com" | |
623 ], | |
624 ... | |
625 }</pre> | |
626 | |
627 <p> | |
628 If not specified, the default <code>content_security_policy</code> value is | |
629 <code>sandbox allow-scripts allow-forms</code>. You can specify your CSP | |
630 value to restrict the sandbox even further, but it must have the <code>sandbox
</code> | |
631 directive and may not have the <code>allow-same-origin</code> token (see | |
632 <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/the-ifram
e-element.html#attr-iframe-sandbox">the | |
633 HTML5 specification</a> for possible sandbox tokens). | |
634 </p> | |
635 </li> | |
636 </ol> | |
637 | |
638 <p> | |
639 Note that you only need to list pages that you expected to be loaded in | |
640 windows or frames. Resources used by sandboxed pages (e.g. stylesheets or | |
641 JavaScript source files) do not need to appear in the | |
642 <code>sandboxed_page</code> list, they will use the sandbox of the page | |
643 that embeds them. | |
644 </p> | |
645 | |
646 <p> | |
647 <a href="sandboxingEval.html">"Using eval in Chrome Extensions. Safely."</a> | |
648 goes into more detail about implementing a sandboxing workflow that enables use | |
649 of libraries that would otherwise have issues executing under extension's | |
650 <a href="../extensions/contentSecurityPolicy.html">default Content Security | |
651 Policy</a>. | |
652 </p> | |
653 | |
654 <p> | |
655 Sandboxed page may only be specified when using | |
656 <a href="#manifest_version"><code>manifest_version</code></a> 2 or above. | |
657 </p> | |
OLD | NEW |