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