- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / common / extensions / docs / templates / articles / manifest / web_accessible_resources.html
1 <h1 id="web_accessible_resources">Manifest - Web Accessible Resources</h1>
2
3 <p>
4 An array of strings specifying the paths (relative to the package root) of
5 packaged resources that are expected to be usable in the context of a web page.
6 For example, an extension that injects a content script with the intention of
7 building up some custom interface for <code>example.com</code> would whitelist
8 any resources that interface requires (images, icons, stylesheets, scripts,
9 etc.) as follows:
10 </p>
11
12 <pre data-filename="manifest.json">
13 {
14   ...
15   "web_accessible_resources": [
16     "images/my-awesome-image1.png",
17     "images/my-amazing-icon1.png",
18     "style/double-rainbow.css",
19     "script/double-rainbow.js"
20   ],
21   ...
22 }
23 </pre>
24
25 <p>
26 These resources would then be available in a webpage via the URL
27 <code>chrome-extension://[PACKAGE ID]/[PATH]</code>, which can be generated with
28 the <a href="http://developer.chrome.com/extensions/extension.html#method-getURL">extension.getURL</a> method. Whitelisted resources are served with appropriate
29 <a href="http://www.w3.org/TR/cors/">CORS</a> headers, so they're available via
30 mechanisms like XHR.
31 </p>
32
33 <p>
34 Injected content scripts themselves do not need to be whitelisted.
35 </p>
36
37 <p>
38 Prior to manifest version 2 all resources within an extension could be accessed
39 from any page on the web. This allowed a malicious website to
40 <a href="http://en.wikipedia.org/wiki/Device_fingerprint">fingerprint</a> the
41 extensions that a user has installed or exploit vulnerabilities (for example
42 <a href="http://en.wikipedia.org/wiki/Cross-site_scripting">XSS bugs</a>)within
43 installed extensions. Limiting availability to only resources which are
44 explicitly intended to be web accessible serves to both minimize the available
45 attack surface and protect the privacy of users.
46 </p>
47
48 <h2 id="availability">Default Availability</h2>
49
50 <p>
51 Resources inside of packages using <a href="http://developer.chrome.com/extensions/manifest.html#manifest_version"><code>manifest_version</code></a>
52 2 or above are <strong>blocked by default</strong>, and must be whitelisted
53 for use via this property.
54 </p>
55
56 <p>
57 Resources inside of packages using <code>manifest_version</code> 1 are available
58 by default, but <em>if</em> you do set this property, then it will be treated as
59 a complete list of all whitelisted resources. Resources not listed will be
60 blocked.
61 </p>