OLD | NEW |
1 <h1>Tutorial: Migrate to Manifest V2</h1> | 1 <h1>Tutorial: Migrate to Manifest V2</h1> |
2 | 2 |
3 <p> | 3 <p> |
4 Manifest version 1 was deprecated in Chrome 18, | 4 Manifest version 1 was deprecated in Chrome 18, |
5 and support will be phased out according to the | 5 and support will be phased out according to the |
6 <a href="manifestVersion.html#manifest-v1-support-schedule">manifest version 1 s
upport schedule</a>. | 6 <a href="manifestVersion.html#manifest-v1-support-schedule">manifest version 1 s
upport schedule</a>. |
7 The changes from version 1 to version 2 | 7 The changes from version 1 to version 2 |
8 fall under two broad categories: | 8 fall under two broad categories: |
9 API changes and Security changes. | 9 API changes and Security changes. |
10 </p> | 10 </p> |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 <li>Are you using inline event handlers (like onclick, etc)?</li> | 76 <li>Are you using inline event handlers (like onclick, etc)?</li> |
77 <ul> | 77 <ul> |
78 <li>Remove them from the HTML code, | 78 <li>Remove them from the HTML code, |
79 move them into an external JS file and | 79 move them into an external JS file and |
80 use <code>addEventListener()</code> instead.</li> | 80 use <code>addEventListener()</code> instead.</li> |
81 </ul> | 81 </ul> |
82 <li>Does your extension inject content scripts into Web pages | 82 <li>Does your extension inject content scripts into Web pages |
83 that need to access resources (like images and scripts) | 83 that need to access resources (like images and scripts) |
84 that are contained in the extension’s package?</li> | 84 that are contained in the extension’s package?</li> |
85 <ul> | 85 <ul> |
86 <li>Define the <a href="manifest.html#web_accessible_resources">web_access
ible_resources</a> | 86 <li>Define the <a href="manifest/web_accessible_resources.html">web_access
ible_resources</a> |
87 property and list the resources | 87 property and list the resources |
88 (and optionally a separate Content Security Policy for those resources).
</li> | 88 (and optionally a separate Content Security Policy for those resources).
</li> |
89 </ul> | 89 </ul> |
90 <li>Does your extension embed external Web pages?</li> | 90 <li>Does your extension embed external Web pages?</li> |
91 <ul> | 91 <ul> |
92 <li>Define the <a href="manifest.html#sandbox">sandbox</a> property.</li> | 92 <li>Define the <a href="manifest/sandbox.html">sandbox</a> property.</li> |
93 </ul> | 93 </ul> |
94 <li>Is your code or library using <code>eval()</code>, new <code>Function()</c
ode>, | 94 <li>Is your code or library using <code>eval()</code>, new <code>Function()</c
ode>, |
95 <code>innerHTML</code>, <code>setTimeout()</code>, or otherwise passing stri
ngs | 95 <code>innerHTML</code>, <code>setTimeout()</code>, or otherwise passing stri
ngs |
96 of JS code that are dynamically evaluated?</li> | 96 of JS code that are dynamically evaluated?</li> |
97 <ul> | 97 <ul> |
98 <li>Use <code>JSON.parse()</code> | 98 <li>Use <code>JSON.parse()</code> |
99 if you’re parsing JSON code into an object.</li> | 99 if you’re parsing JSON code into an object.</li> |
100 <li>Use a CSP-friendly library, | 100 <li>Use a CSP-friendly library, |
101 for example, <a href="http://angularjs.org/">AngularJS</a>.</li> | 101 for example, <a href="http://angularjs.org/">AngularJS</a>.</li> |
102 <li>Create a sandbox entry in your manifest and | 102 <li>Create a sandbox entry in your manifest and |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 <p> | 257 <p> |
258 There are some scenarios where your extension might embed content | 258 There are some scenarios where your extension might embed content |
259 that can be used externally or come from an external source. | 259 that can be used externally or come from an external source. |
260 </p> | 260 </p> |
261 | 261 |
262 <p> | 262 <p> |
263 <strong>Extension content in web pages:</strong><br> | 263 <strong>Extension content in web pages:</strong><br> |
264 If your extension embeds resources (like images, script, CSS styles, etc) | 264 If your extension embeds resources (like images, script, CSS styles, etc) |
265 that are used in content scripts that are injected into web pages, | 265 that are used in content scripts that are injected into web pages, |
266 you need to use the | 266 you need to use the |
267 <a href="manifest.html#web_accessible_resources">web_accessible_resources</a> pr
operty | 267 <a href="manifest/web_accessible_resources.html">web_accessible_resources</a> pr
operty |
268 to whitelist these resources so that external Web pages can use them: | 268 to whitelist these resources so that external Web pages can use them: |
269 </p> | 269 </p> |
270 | 270 |
271 <pre> | 271 <pre> |
272 { // manifest file | 272 { // manifest file |
273 ... | 273 ... |
274 "<strong>web_accessible_resources</strong>": [ | 274 "<strong>web_accessible_resources</strong>": [ |
275 "images/image1.png", | 275 "images/image1.png", |
276 "script/myscript.js" | 276 "script/myscript.js" |
277 ], | 277 ], |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 For more information about using sandboxing to isolate unsafe code, | 349 For more information about using sandboxing to isolate unsafe code, |
350 read the <a href="sandboxingEval.html">sandboxing eval</a> article. | 350 read the <a href="sandboxingEval.html">sandboxing eval</a> article. |
351 You can learn more about Content Security Policy | 351 You can learn more about Content Security Policy |
352 by visiting our extensions-related tutorial and a | 352 by visiting our extensions-related tutorial and a |
353 <a href="http://www.html5rocks.com/en/tutorials/security/content-security-policy
/">good introduction on HTML5Rocks</a>. | 353 <a href="http://www.html5rocks.com/en/tutorials/security/content-security-policy
/">good introduction on HTML5Rocks</a>. |
354 </p> | 354 </p> |
355 | 355 |
356 | 356 |
357 | 357 |
358 | 358 |
OLD | NEW |