Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chrome/common/extensions/docs/templates/articles/tut_migration_to_manifest_v2.html

Issue 11035016: Merge 159156 - Extensions Docs Server: Fix headings with no IDs (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1271/src/
Patch Set: Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 version 1 support schedule</a>. 6 <a href="manifestVersion.html">manifest version 1 support 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 </ul> 116 </ul>
117 117
118 <h2 id="api-summary">Summary of API changes</h2> 118 <h2 id="api-summary">Summary of API changes</h2>
119 119
120 <p> 120 <p>
121 Manifest version 2 introduces a few changes 121 Manifest version 2 introduces a few changes
122 to the browser action and page action APIs, 122 to the browser action and page action APIs,
123 and replaces a few old APIs with newer ones. 123 and replaces a few old APIs with newer ones.
124 </p> 124 </p>
125 125
126 <h3>Changes to browser actions</h3> 126 <h3 id="browser_actions">Changes to browser actions</h3>
127 127
128 <p> 128 <p>
129 The browser actions API introduces some naming changes:</p> 129 The browser actions API introduces some naming changes:</p>
130 130
131 <ul> 131 <ul>
132 <li>The <code>browser_actions</code> and 132 <li>The <code>browser_actions</code> and
133 <code>chrome.browserActions</code> properties have been replaced 133 <code>chrome.browserActions</code> properties have been replaced
134 with their singular counterparts <code>browser_action</code> 134 with their singular counterparts <code>browser_action</code>
135 and <code>chrome.browserAction</code>.</li> 135 and <code>chrome.browserAction</code>.</li>
136 <li>Under the old <code>browser_actions</code> property, 136 <li>Under the old <code>browser_actions</code> property,
137 there were <code>icons</code>, <code>name</code>, and 137 there were <code>icons</code>, <code>name</code>, and
138 <code>popup</code> properties. 138 <code>popup</code> properties.
139 These have been replaced with:</li> 139 These have been replaced with:</li>
140 <ul> 140 <ul>
141 <li><code>default_icon</code> for the browser action badge icon</li> 141 <li><code>default_icon</code> for the browser action badge icon</li>
142 <li><code>default_name</code> for the text that appears in the tooltip when you hover over the badge</li> 142 <li><code>default_name</code> for the text that appears in the tooltip when you hover over the badge</li>
143 <li><code>default_popup</code> for the HTML page that represents the UI 143 <li><code>default_popup</code> for the HTML page that represents the UI
144 for the browser action (and this must now be a string, it cannot be an obj ect)</li> 144 for the browser action (and this must now be a string, it cannot be an obj ect)</li>
145 </ul> 145 </ul>
146 </ul> 146 </ul>
147 147
148 <h3>Changes to page actions</h3> 148 <h3 id="page_actions">Changes to page actions</h3>
149 149
150 <p>Similar to the changes for browser actions, 150 <p>Similar to the changes for browser actions,
151 the page actions API has also changed:</p> 151 the page actions API has also changed:</p>
152 <ul> 152 <ul>
153 <li>The <code>page_actions</code> and <code>chrome.pageActions</code> properti es 153 <li>The <code>page_actions</code> and <code>chrome.pageActions</code> properti es
154 have been replaced with their singular counterparts 154 have been replaced with their singular counterparts
155 <code>page_action</code> and <code>chrome.pageAction</code>.</li> 155 <code>page_action</code> and <code>chrome.pageAction</code>.</li>
156 <li>Under the old <code>page_actions</code> property, 156 <li>Under the old <code>page_actions</code> property,
157 there were <code>icons</code>, <code>name</code>, 157 there were <code>icons</code>, <code>name</code>,
158 and <code>popup</code> properties. 158 and <code>popup</code> properties.
159 These have been replaced with:</li> 159 These have been replaced with:</li>
160 <ul> 160 <ul>
161 <li><code>default_icon</code> for the page action badge icon</li> 161 <li><code>default_icon</code> for the page action badge icon</li>
162 <li><code>default_name</code> for the text 162 <li><code>default_name</code> for the text
163 that appears in the tooltip when you hover over the badge</li> 163 that appears in the tooltip when you hover over the badge</li>
164 <li><code>default_popup</code> for the HTML page 164 <li><code>default_popup</code> for the HTML page
165 that represents the UI for the page action 165 that represents the UI for the page action
166 (and this must now be a string, it cannot be an object)</li> 166 (and this must now be a string, it cannot be an object)</li>
167 </ul> 167 </ul>
168 </ul> 168 </ul>
169 169
170 <h3>Removed and changed APIs</h3> 170 <h3 id="removed_and_changed">Removed and changed APIs</h3>
171 171
172 <p> 172 <p>
173 A few extension APIs have been removed and replaced with new counterparts: 173 A few extension APIs have been removed and replaced with new counterparts:
174 </p> 174 </p>
175 175
176 <ul> 176 <ul>
177 <li>The <code>background_page</code> property has been replaced 177 <li>The <code>background_page</code> property has been replaced
178 by <a href="background_pages.html">background</a>.</li> 178 by <a href="background_pages.html">background</a>.</li>
179 <li>The <code>chrome.self</code> property has been removed, 179 <li>The <code>chrome.self</code> property has been removed,
180 use <code>chrome.extension</code>.</li> 180 use <code>chrome.extension</code>.</li>
181 <li>The <code>Port.tab</code> property has been replaced 181 <li>The <code>Port.tab</code> property has been replaced
182 with <code>Port.sender</code>.</li> 182 with <code>Port.sender</code>.</li>
183 <li>The <code>chrome.extension.getTabContentses()</code> and the 183 <li>The <code>chrome.extension.getTabContentses()</code> and the
184 <code>chrome.extension.getExtensionTabs()</code> APIs have been replaced 184 <code>chrome.extension.getExtensionTabs()</code> APIs have been replaced
185 by <code>chrome.extension.getViews( { “type” : “tab” } )</code>.</li> 185 by <code>chrome.extension.getViews( { “type” : “tab” } )</code>.</li>
186 </ul> 186 </ul>
187 187
188 <h2 id="security-summary">Summary of security changes</h2> 188 <h2 id="security-summary">Summary of security changes</h2>
189 189
190 <p> 190 <p>
191 There are a number of security-related changes 191 There are a number of security-related changes
192 that accompany the move from manifest version 1 to version 2. 192 that accompany the move from manifest version 1 to version 2.
193 Many of these changes stem from Chrome’s adoption of 193 Many of these changes stem from Chrome’s adoption of
194 <a href="contentSecurityPolicy.html#H3-1">Content Security Policy</a>; 194 <a href="contentSecurityPolicy.html#H3-1">Content Security Policy</a>;
195 you should read more about this policy to understand its implications. 195 you should read more about this policy to understand its implications.
196 </p> 196 </p>
197 197
198 <h3>Inline scripts and event handlers disallowed</h3> 198 <h3 id="inline_scripts">Inline scripts and event handlers disallowed</h3>
199 199
200 <p> 200 <p>
201 Due to the use of <a href="contentSecurityPolicy.html">Content Security Policy</ a>, 201 Due to the use of <a href="contentSecurityPolicy.html">Content Security Policy</ a>,
202 you can no longer use &lt;script> tags that are inline with the HTML content. 202 you can no longer use &lt;script> tags that are inline with the HTML content.
203 These must be moved to external JS files. 203 These must be moved to external JS files.
204 In addition, inline event handlers are also not supported. 204 In addition, inline event handlers are also not supported.
205 For example, suppose you had the following code in your extension: 205 For example, suppose you had the following code in your extension:
206 </p> 206 </p>
207 207
208 <pre> 208 <pre>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 window.addEventListener(“load”, initialize); 245 window.addEventListener(“load”, initialize);
246 ... 246 ...
247 document.getElementById(“button1”).addEventListener(“click”,handleClick); 247 document.getElementById(“button1”).addEventListener(“click”,handleClick);
248 </pre> 248 </pre>
249 249
250 <p> 250 <p>
251 This is a much cleaner way of separating 251 This is a much cleaner way of separating
252 your extension’s behavior from its user interface markup. 252 your extension’s behavior from its user interface markup.
253 </p> 253 </p>
254 254
255 <h3>Embedding content</h3> 255 <h3 id="embedding">Embedding content</h3>
256 256
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,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 <pre> 298 <pre>
299 { // manifest file 299 { // manifest file
300 ..., 300 ...,
301 "content_security_policy": "script-src 'self' 301 "content_security_policy": "script-src 'self'
302 <strong>https://ssl.google-analytics.com</strong>; object-src 'self'", 302 <strong>https://ssl.google-analytics.com</strong>; object-src 'self'",
303 ... 303 ...
304 } 304 }
305 </pre></li> 305 </pre></li>
306 </ol> 306 </ol>
307 307
308 <h3>Using dynamic script evaluation</h3> 308 <h3 id="using">Using dynamic script evaluation</h3>
309 309
310 <p> 310 <p>
311 Perhaps one of the biggest changes in the new manifest v2 scheme is 311 Perhaps one of the biggest changes in the new manifest v2 scheme is
312 that extensions can no longer use dynamic script evaluation techniques like 312 that extensions can no longer use dynamic script evaluation techniques like
313 <code>eval()</code> or new <code>Function()</code>, 313 <code>eval()</code> or new <code>Function()</code>,
314 or pass strings of JS code to functions 314 or pass strings of JS code to functions
315 that will cause an <code>eval()</code> to be used, 315 that will cause an <code>eval()</code> to be used,
316 like <code>setTimeout()</code>. 316 like <code>setTimeout()</code>.
317 In addition, certain commonly used JavaScript libraries, 317 In addition, certain commonly used JavaScript libraries,
318 such as Google Maps and certain templating libraries, 318 such as Google Maps and certain templating libraries,
(...skipping 30 matching lines...) Expand all
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698