| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc.
Note: | |
| 2 1) The <head> information in this page is significant, should be uniform | |
| 3 across api docs and should be edited only with knowledge of the | |
| 4 templating mechanism. | |
| 5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a | |
| 6 browser, it will be re-generated from the template, json schema and | |
| 7 authored overview content. | |
| 8 4) The <body>.innerHTML is also generated by an offline step so that this | |
| 9 page may easily be indexed by search engines. | |
| 10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> | |
| 11 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
| 12 <link href="css/ApiRefStyles.css" rel="stylesheet" type="text/css"> | |
| 13 <link href="css/print.css" rel="stylesheet" type="text/css" media="print"> | |
| 14 <script type="text/javascript" src="../../../third_party/jstemplate/jstempla
te_compiled.js"> | |
| 15 </script> | |
| 16 <script type="text/javascript" src="../../../../third_party/json_minify/mini
fy-sans-regexp.js"> | |
| 17 </script> | |
| 18 <script type="text/javascript" src="js/api_page_generator.js"></script> | |
| 19 <script type="text/javascript" src="js/bootstrap.js"></script> | |
| 20 <script type="text/javascript" src="js/sidebar.js"></script> | |
| 21 <title>CRX Package Format - Google Chrome Extensions - Google Code</title></he
ad> | |
| 22 <body> <div id="devModeWarning" class="displayModeWarning"> | |
| 23 You are viewing extension docs in chrome via the 'file:' scheme: are you exp
ecting to see local changes when you refresh? You'll need run chrome with --allo
w-file-access-from-files. | |
| 24 </div> | |
| 25 <div id="branchWarning" class="displayModeWarning"> | |
| 26 <span>WARNING: This is the <span id="branchName">BETA</span> documentation. | |
| 27 It may not work with the stable release of Chrome.</span> | |
| 28 <select id="branchChooser"> | |
| 29 <option>Choose a different version... | |
| 30 </option><option value="">Stable | |
| 31 </option><option value="beta">Beta | |
| 32 </option><option value="dev">Dev | |
| 33 </option><option value="trunk">Trunk | |
| 34 </option></select> | |
| 35 </div> | |
| 36 <div id="unofficialWarning" class="displayModeWarning"> | |
| 37 <span>WARNING: This is unofficial documentation. It may not work with the | |
| 38 current release of Chrome.</span> | |
| 39 <button id="goToOfficialDocs">Go to the official docs</button> | |
| 40 </div> | |
| 41 <div id="gc-container" class="labs"> | |
| 42 <!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION --> | |
| 43 <!-- In particular, sub-templates that recurse, must be used by allowing | |
| 44 jstemplate to make a copy of the template in this section which | |
| 45 are not operated on by way of the jsskip="true" --> | |
| 46 <!-- /SUBTEMPLATES --> | |
| 47 <a id="top"></a> | |
| 48 <div id="skipto"> | |
| 49 <a href="#gc-pagecontent">Skip to page content</a> | |
| 50 <a href="#gc-toc">Skip to main navigation</a> | |
| 51 </div> | |
| 52 <!-- API HEADER --> | |
| 53 <table id="header" width="100%" cellspacing="0" border="0"> | |
| 54 <tbody><tr> | |
| 55 <td valign="middle"><a href="http://code.google.com/"><img src="images/c
ode_labs_logo.gif" height="43" width="161" alt="Google Code Labs" style="border:
0; margin:0;"></a></td> | |
| 56 <td valign="middle" width="100%" style="padding-left:0.6em;"> | |
| 57 <form action="http://www.google.com/cse" id="cse" style="margin-top:0.
5em"> | |
| 58 <div id="gsc-search-box"> | |
| 59 <input type="hidden" name="cx" value="002967670403910741006:61_cvz
fqtno"> | |
| 60 <input type="hidden" name="ie" value="UTF-8"> | |
| 61 <input type="text" name="q" value="" size="55"> | |
| 62 <input class="gsc-search-button" type="submit" name="sa" value="Se
arch"> | |
| 63 <br> | |
| 64 <span class="greytext">e.g. "page action" or "tabs"</span> | |
| 65 </div> | |
| 66 </form> | |
| 67 <script type="text/javascript" src="https://www.google.com/jsapi"></sc
ript> | |
| 68 <script type="text/javascript">google.load("elements", "1", {packages:
"transliteration"});</script> | |
| 69 <script type="text/javascript" src="https://www.google.com/coop/cse/t1
3n?form=cse&t13n_langs=en"></script> | |
| 70 <script type="text/javascript" src="https://www.google.com/coop/cse/br
and?form=cse&lang=en"></script> | |
| 71 </td> | |
| 72 </tr> | |
| 73 </tbody></table> | |
| 74 <div id="codesiteContent" class=""> | |
| 75 <a id="gc-topnav-anchor"></a> | |
| 76 <div id="gc-topnav"> | |
| 77 <h1>Google Chrome Extensions (<a href="http://code.google.com/labs/">Lab
s</a>)</h1> | |
| 78 <ul id="home" class="gc-topnav-tabs"> | |
| 79 <li id="home_link"> | |
| 80 <a href="index.html" title="Google Chrome Extensions home page">Home
</a> | |
| 81 </li> | |
| 82 <li id="docs_link"> | |
| 83 <a href="docs.html" title="Official Google Chrome Extensions documen
tation">Docs</a> | |
| 84 </li> | |
| 85 <li id="faq_link"> | |
| 86 <a href="faq.html" title="Answers to frequently asked questions abou
t Google Chrome Extensions">FAQ</a> | |
| 87 </li> | |
| 88 <li id="samples_link"> | |
| 89 <a href="samples.html" title="Sample extensions (with source code)">
Samples</a> | |
| 90 </li> | |
| 91 <li id="group_link"> | |
| 92 <a href="http://groups.google.com/a/chromium.org/group/chromium-exte
nsions" title="Google Chrome Extensions developer forum">Group</a> | |
| 93 </li> | |
| 94 <li id="so_link"> | |
| 95 <a href="http://stackoverflow.com/questions/tagged/google-chrome-ext
ension" title="[google-chrome-extension] tag on Stack Overflow">Questions?</a> | |
| 96 </li> | |
| 97 </ul> | |
| 98 </div> <!-- end gc-topnav --> | |
| 99 <div class="g-section g-tpl-170"> | |
| 100 <!-- SIDENAV --> | |
| 101 <div class="g-unit g-first" id="gc-toc"> | |
| 102 <ul> | |
| 103 <li><a href="getstarted.html">Getting Started</a></li> | |
| 104 <li><a href="overview.html">Overview</a></li> | |
| 105 <li><a href="whats_new.html">What's New?</a></li> | |
| 106 <li><h2><a href="devguide.html">Developer's Guide</a></h2> | |
| 107 <ul> | |
| 108 <li>Browser UI | |
| 109 <ul> | |
| 110 <li><a href="browserAction.html">Browser Actions</a></li> | |
| 111 <li><a href="contextMenus.html">Context Menus</a></li> | |
| 112 <li><a href="notifications.html">Desktop Notifications</a></li
> | |
| 113 <li><a href="omnibox.html">Omnibox</a></li> | |
| 114 <li><a href="options.html">Options Pages</a></li> | |
| 115 <li><a href="override.html">Override Pages</a></li> | |
| 116 <li><a href="pageAction.html">Page Actions</a></li> | |
| 117 </ul> | |
| 118 </li> | |
| 119 <li>Browser Interaction | |
| 120 <ul> | |
| 121 <li><a href="bookmarks.html">Bookmarks</a></li> | |
| 122 <li><a href="cookies.html">Cookies</a></li> | |
| 123 <li><a href="devtools.html">Developer Tools</a></li> | |
| 124 <li><a href="events.html">Events</a></li> | |
| 125 <li><a href="history.html">History</a></li> | |
| 126 <li><a href="management.html">Management</a></li> | |
| 127 <li><a href="tabs.html">Tabs</a></li> | |
| 128 <li><a href="windows.html">Windows</a></li> | |
| 129 </ul> | |
| 130 </li> | |
| 131 <li>Implementation | |
| 132 <ul> | |
| 133 <li><a href="a11y.html">Accessibility</a></li> | |
| 134 <li><a href="background_pages.html">Background Pages</a></li> | |
| 135 <li><a href="content_scripts.html">Content Scripts</a></li> | |
| 136 <li><a href="xhr.html">Cross-Origin XHR</a></li> | |
| 137 <li><a href="i18n.html">Internationalization</a></li> | |
| 138 <li><a href="messaging.html">Message Passing</a></li> | |
| 139 <li><a href="permissions.html">Optional Permissions</a></li> | |
| 140 <li><a href="npapi.html">NPAPI Plugins</a></li> | |
| 141 </ul> | |
| 142 </li> | |
| 143 <li>Finishing | |
| 144 <ul> | |
| 145 <li><a href="hosting.html">Hosting</a></li> | |
| 146 <li><a href="external_extensions.html">Other Deployment Option
s</a></li> | |
| 147 </ul> | |
| 148 </li> | |
| 149 </ul> | |
| 150 </li> | |
| 151 <li><h2><a href="apps.html">Packaged Apps</a></h2></li> | |
| 152 <li><h2><a href="tutorials.html">Tutorials</a></h2> | |
| 153 <ul> | |
| 154 <li><a href="tut_debugging.html">Debugging</a></li> | |
| 155 <li><a href="tut_analytics.html">Google Analytics</a></li> | |
| 156 <li><a href="tut_oauth.html">OAuth</a></li> | |
| 157 </ul> | |
| 158 </li> | |
| 159 <li><h2>Reference</h2> | |
| 160 <ul> | |
| 161 <li>Formats | |
| 162 <ul> | |
| 163 <li><a href="manifest.html">Manifest Files</a></li> | |
| 164 <li><a href="match_patterns.html">Match Patterns</a></li> | |
| 165 </ul> | |
| 166 </li> | |
| 167 <li><a href="permission_warnings.html">Permission Warnings</a></li
> | |
| 168 <li><a href="api_index.html">chrome.* APIs</a></li> | |
| 169 <li><a href="api_other.html">Other APIs</a></li> | |
| 170 </ul> | |
| 171 </li> | |
| 172 <li><h2><a href="samples.html">Samples</a></h2></li> | |
| 173 <div class="line"> </div> | |
| 174 <li><h2>More</h2> | |
| 175 <ul> | |
| 176 <li><a href="http://code.google.com/chrome/webstore/docs/index.htm
l">Chrome Web Store</a></li> | |
| 177 <li><a href="http://code.google.com/chrome/apps/docs/developers_gu
ide.html">Hosted Apps</a></li> | |
| 178 <li><a href="themes.html">Themes</a></li> | |
| 179 </ul> | |
| 180 </li> | |
| 181 </ul> | |
| 182 </div> | |
| 183 <script> | |
| 184 initToggles(); | |
| 185 </script> | |
| 186 <div class="g-unit" id="gc-pagecontent"> | |
| 187 <div id="pageTitle"> | |
| 188 <h1 class="page_title">CRX Package Format</h1> | |
| 189 </div> | |
| 190 <!-- TABLE OF CONTENTS --> | |
| 191 <div id="toc"> | |
| 192 <h2>Contents</h2> | |
| 193 <ol> | |
| 194 <li> | |
| 195 <a href="#H2-0">Package header</a> | |
| 196 <ol> | |
| 197 </ol> | |
| 198 </li><li> | |
| 199 <a href="#H2-1">Extension contents</a> | |
| 200 <ol> | |
| 201 </ol> | |
| 202 </li><li> | |
| 203 <a href="#H2-2">Example</a> | |
| 204 <ol> | |
| 205 </ol> | |
| 206 </li><li> | |
| 207 <a href="#scripts">Packaging scripts</a> | |
| 208 <ol> | |
| 209 <li> | |
| 210 <a href="#ruby">Ruby</a> | |
| 211 </li><li> | |
| 212 <a href="#H3-5">Bash</a> | |
| 213 </li> | |
| 214 </ol> | |
| 215 </li> | |
| 216 </ol> | |
| 217 </div> | |
| 218 <!-- /TABLE OF CONTENTS --> | |
| 219 <!-- Standard content lead-in for experimental API pages --> | |
| 220 <!-- STATIC CONTENT PLACEHOLDER --> | |
| 221 <div id="static"><div id="pageData-name" class="pageData">CRX Package Fo
rmat</div> | |
| 222 <div id="pageData-showTOC" class="pageData">true</div> | |
| 223 <p> | |
| 224 CRX files are ZIP files with a special header and the <code>.crx</code> file | |
| 225 extension. | |
| 226 </p> | |
| 227 <a name="H2-0"></a><h2>Package header</h2> | |
| 228 <p> | |
| 229 The header contains the author's public key and the extension's signature. | |
| 230 The signature is generated from the ZIP file using SHA-1 with the | |
| 231 author's private key. The header requires a little-endian byte ordering with | |
| 232 4-byte alignment. The following table describes the fields of | |
| 233 the <code>.crx</code> header in order: | |
| 234 </p> | |
| 235 <table> | |
| 236 <tbody><tr> | |
| 237 <th>Field</th><th>Type</th><th>Length</th><th>Value</th><th>Description</th> | |
| 238 </tr> | |
| 239 <tr> | |
| 240 <td><em>magic number</em></td><td>char[]</td><td>32 bits</td><td>Cr24</td> | |
| 241 <td> | |
| 242 Chrome requires this constant at the beginning of every <code>.crx</code> | |
| 243 package. | |
| 244 </td> | |
| 245 </tr> | |
| 246 <tr> | |
| 247 <td><em>version</em></td><td>unsigned int</td><td>32 bits</td><td>2</td
> | |
| 248 <td>The version of the <code>*.crx</code> file format used (currently 2).</t
d> | |
| 249 </tr> | |
| 250 <tr> | |
| 251 <td><em>public key length</em></td><td>unsigned int</td><td>32 bits</td
> | |
| 252 <td><i>pubkey.length</i></td> | |
| 253 <td> | |
| 254 The length of the RSA public key in <em>bytes</em>. | |
| 255 </td> | |
| 256 </tr> | |
| 257 <tr> | |
| 258 <td><em>signature length</em></td><td>unsigned int</td><td>32 bits</td> | |
| 259 <td><i>sig.length</i></td> | |
| 260 <td> | |
| 261 The length of the signature in <em>bytes</em>. | |
| 262 </td> | |
| 263 </tr> | |
| 264 <tr> | |
| 265 <td><em>public key</em></td><td>byte[]</td><td><i>pubkey.length</i></td> | |
| 266 <td><i>pubkey.contents</i></td> | |
| 267 <td> | |
| 268 The contents of the author's RSA public key, formatted as an X509 | |
| 269 SubjectPublicKeyInfo block. | |
| 270 </td> | |
| 271 </tr> | |
| 272 <tr> | |
| 273 <td><em>signature</em></td><td>byte[]</td><td><i>sig.length</i></td> | |
| 274 <td><i>sig.contents</i></td> | |
| 275 <td> | |
| 276 The signature of the ZIP content using the author's private key. The | |
| 277 signature is created using the RSA algorithm with the SHA-1 hash function. | |
| 278 </td> | |
| 279 </tr> | |
| 280 </tbody></table> | |
| 281 <a name="H2-1"></a><h2>Extension contents</h2> | |
| 282 <p> | |
| 283 The extension's ZIP file is appended to the <code>*.crx</code> package after the | |
| 284 header. This should be the same ZIP file that the signature in the header | |
| 285 was generated from. | |
| 286 </p> | |
| 287 <a name="H2-2"></a><h2>Example</h2> | |
| 288 <p> | |
| 289 The following is an example hex dump from the beginning of a <code>.crx</code> | |
| 290 file. | |
| 291 </p> | |
| 292 <pre>43 72 32 34 # "Cr24" -- the magic number | |
| 293 02 00 00 00 # 2 -- the crx format version number | |
| 294 A2 00 00 00 # 162 -- length of public key in bytes | |
| 295 80 00 00 00 # 128 -- length of signature in bytes | |
| 296 ........... # the contents of the public key | |
| 297 ........... # the contents of the signature | |
| 298 ........... # the contents of the zip file | |
| 299 </pre> | |
| 300 <h2 id="scripts">Packaging scripts</h2> | |
| 301 <p> | |
| 302 Members of the community have written the following scripts to package | |
| 303 <code>.crx</code> files. | |
| 304 </p> | |
| 305 <h3 id="ruby">Ruby</h3> | |
| 306 <blockquote> | |
| 307 <a href="http://github.com/Constellation/crxmake">github: crxmake</a> | |
| 308 </blockquote> | |
| 309 <a name="H3-5"></a><h3>Bash</h3> | |
| 310 <pre>#!/bin/bash -e | |
| 311 # | |
| 312 # Purpose: Pack a Chromium extension directory into crx format | |
| 313 if test $# -ne 2; then | |
| 314 echo "Usage: crxmake.sh <extension dir> <pem path>" | |
| 315 exit 1 | |
| 316 fi | |
| 317 dir=$1 | |
| 318 key=$2 | |
| 319 name=$(basename "$dir") | |
| 320 crx="$name.crx" | |
| 321 pub="$name.pub" | |
| 322 sig="$name.sig" | |
| 323 zip="$name.zip" | |
| 324 trap 'rm -f "$pub" "$sig" "$zip"' EXIT | |
| 325 # zip up the crx dir | |
| 326 cwd=$(pwd -P) | |
| 327 (cd "$dir" && zip -qr -9 -X "$cwd/$zip" .) | |
| 328 # signature | |
| 329 openssl sha1 -sha1 -binary -sign "$key" < "$zip" > "$sig" | |
| 330 # public key | |
| 331 openssl rsa -pubout -outform DER < "$key" > "$pub" 2>/dev/null | |
| 332 byte_swap () { | |
| 333 # Take "abcdefgh" and return it as "ghefcdab" | |
| 334 echo "${1:6:2}${1:4:2}${1:2:2}${1:0:2}" | |
| 335 } | |
| 336 crmagic_hex="4372 3234" # Cr24 | |
| 337 version_hex="0200 0000" # 2 | |
| 338 pub_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$pub" | awk '{print $5}'))) | |
| 339 sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}'))) | |
| 340 ( | |
| 341 echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p | |
| 342 cat "$pub" "$sig" "$zip" | |
| 343 ) > "$crx" | |
| 344 echo "Wrote $crx" | |
| 345 </pre> | |
| 346 </div> | |
| 347 <!-- API PAGE --> | |
| 348 <!-- /apiPage --> | |
| 349 </div> <!-- /gc-pagecontent --> | |
| 350 </div> <!-- /g-section --> | |
| 351 </div> <!-- /codesiteContent --> | |
| 352 <div id="gc-footer" --=""> | |
| 353 <div class="text"> | |
| 354 <p> | |
| 355 Except as otherwise <a href="http://code.google.com/policies.html#restrictions
">noted</a>, | |
| 356 the content of this page is licensed under the <a rel="license" href="http://c
reativecommons.org/licenses/by/3.0/">Creative Commons | |
| 357 Attribution 3.0 License</a>, and code samples are licensed under the | |
| 358 <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD Lic
ense</a>. | |
| 359 </p> | |
| 360 <p> | |
| 361 ©2011 Google | |
| 362 </p> | |
| 363 <!-- begin analytics --> | |
| 364 <script src="https://www.google-analytics.com/urchin.js" type="text/javascript">
</script> | |
| 365 <script src="https://www.google-analytics.com/ga.js" type="text/javascript"></sc
ript> | |
| 366 <script type="text/javascript"> | |
| 367 // chrome doc tracking | |
| 368 try { | |
| 369 var engdocs = _gat._getTracker("YT-10763712-2"); | |
| 370 engdocs._trackPageview(); | |
| 371 } catch(err) {} | |
| 372 // code.google.com site-wide tracking | |
| 373 try { | |
| 374 _uacct="UA-18071-1"; | |
| 375 _uanchor=1; | |
| 376 _uff=0; | |
| 377 urchinTracker(); | |
| 378 } | |
| 379 catch(e) {/* urchinTracker not available. */} | |
| 380 </script> | |
| 381 <!-- end analytics --> | |
| 382 </div> | |
| 383 </div> <!-- /gc-footer --> | |
| 384 </div> <!-- /gc-container --> | |
| 385 </body></html> | |
| OLD | NEW |