• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/jstemplate_compiled.js">
15    </script>
16    <script type="text/javascript" src="js/api_page_generator.js"></script>
17    <script type="text/javascript" src="js/bootstrap.js"></script>
18    <script type="text/javascript" src="js/sidebar.js"></script>
19  <title>CRX Package Format - Google Chrome Extensions - Google Code</title></head>
20  <body>  <div id="gc-container" class="labs">
21      <div id="devModeWarning">
22        You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files.
23      </div>
24      <!-- SUBTEMPLATES: DO NOT MOVE FROM THIS LOCATION -->
25      <!-- In particular, sub-templates that recurse, must be used by allowing
26           jstemplate to make a copy of the template in this section which
27           are not operated on by way of the jsskip="true" -->
28      <div style="display:none">
29
30        <!-- VALUE -->
31        <div id="valueTemplate">
32          <dt>
33            <var>paramName</var>
34              <em>
35
36                <!-- TYPE -->
37                <div style="display:inline">
38                  (
39                    <span class="optional">optional</span>
40                    <span class="enum">enumerated</span>
41                    <span id="typeTemplate">
42                      <span>
43                        <a> Type</a>
44                      </span>
45                      <span>
46                        <span>
47                          array of <span><span></span></span>
48                        </span>
49                        <span>paramType</span>
50                        <span></span>
51                      </span>
52                    </span>
53                  )
54                </div>
55
56              </em>
57          </dt>
58          <dd class="todo">
59            Undocumented.
60          </dd>
61          <dd>
62            Description of this parameter from the json schema.
63          </dd>
64          <dd>
65            This parameter was added in version
66            <b><span></span></b>.
67            You must omit this parameter in earlier versions,
68            and you may omit it in any version.  If you require this
69            parameter, the manifest key
70            <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
71            can ensure that your extension won't be run in an earlier browser version.
72          </dd>
73
74          <!-- OBJECT PROPERTIES -->
75          <dd>
76            <dl>
77              <div>
78                <div>
79                </div>
80              </div>
81            </dl>
82          </dd>
83
84          <!-- OBJECT METHODS -->
85          <dd>
86            <div></div>
87          </dd>
88
89          <!-- OBJECT EVENT FIELDS -->
90          <dd>
91            <div></div>
92          </dd>
93
94          <!-- FUNCTION PARAMETERS -->
95          <dd>
96            <div></div>
97          </dd>
98
99        </div> <!-- /VALUE -->
100
101        <div id="functionParametersTemplate">
102          <h5>Parameters</h5>
103          <dl>
104            <div>
105              <div>
106              </div>
107            </div>
108          </dl>
109        </div>
110      </div> <!-- /SUBTEMPLATES -->
111
112  <a id="top"></a>
113    <div id="skipto">
114      <a href="#gc-pagecontent">Skip to page content</a>
115      <a href="#gc-toc">Skip to main navigation</a>
116    </div>
117    <!-- API HEADER -->
118    <table id="header" width="100%" cellspacing="0" border="0">
119      <tbody><tr>
120        <td valign="middle"><a href="http://code.google.com/"><img src="images/code_labs_logo.gif" height="43" width="161" alt="Google Code Labs" style="border:0; margin:0;"></a></td>
121        <td valign="middle" width="100%" style="padding-left:0.6em;">
122          <form action="http://www.google.com/cse" id="cse" style="margin-top:0.5em">
123            <div id="gsc-search-box">
124              <input type="hidden" name="cx" value="002967670403910741006:61_cvzfqtno">
125              <input type="hidden" name="ie" value="UTF-8">
126              <input type="text" name="q" value="" size="55">
127              <input class="gsc-search-button" type="submit" name="sa" value="Search">
128              <br>
129              <span class="greytext">e.g. "page action" or "tabs"</span>
130            </div>
131          </form>
132
133          <script type="text/javascript" src="http://www.google.com/jsapi"></script>
134          <script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script>
135          <script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse&amp;t13n_langs=en"></script>
136          <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse&amp;lang=en"></script>
137        </td>
138      </tr>
139    </tbody></table>
140
141    <div id="codesiteContent" class="">
142
143      <a id="gc-topnav-anchor"></a>
144      <div id="gc-topnav">
145        <h1>Google Chrome Extensions (<a href="http://code.google.com/labs/">Labs</a>)</h1>
146        <ul id="home" class="gc-topnav-tabs">
147          <li id="home_link">
148            <a href="index.html" title="Google Chrome Extensions home page">Home</a>
149          </li>
150          <li id="docs_link">
151            <a href="docs.html" title="Official Google Chrome Extensions documentation">Docs</a>
152          </li>
153          <li id="faq_link">
154            <a href="faq.html" title="Answers to frequently asked questions about Google Chrome Extensions">FAQ</a>
155          </li>
156          <li id="samples_link">
157            <a href="samples.html" title="Sample extensions (with source code)">Samples</a>
158          </li>
159          <li id="group_link">
160            <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions" title="Google Chrome Extensions developer forum">Group</a>
161          </li>
162        </ul>
163      </div> <!-- end gc-topnav -->
164
165    <div class="g-section g-tpl-170">
166      <!-- SIDENAV -->
167      <div class="g-unit g-first" id="gc-toc">
168        <ul>
169          <li><a href="getstarted.html">Getting Started</a></li>
170          <li><a href="overview.html">Overview</a></li>
171          <li><a href="whats_new.html">What's New?</a></li>
172          <li><h2><a href="devguide.html">Developer's Guide</a></h2>
173            <ul>
174              <li>Browser UI
175                <ul>
176                  <li><a href="browserAction.html">Browser Actions</a></li>
177                  <li><a href="contextMenus.html">Context Menus</a></li>
178                  <li><a href="notifications.html">Desktop Notifications</a></li>
179                  <li><a href="omnibox.html">Omnibox</a></li>
180                  <li><a href="options.html">Options Pages</a></li>
181                  <li><a href="override.html">Override Pages</a></li>
182                  <li><a href="pageAction.html">Page Actions</a></li>
183                </ul>
184              </li>
185              <li>Browser Interaction
186                <ul>
187                  <li><a href="bookmarks.html">Bookmarks</a></li>
188                  <li><a href="cookies.html">Cookies</a></li>
189                  <li><a href="events.html">Events</a></li>
190                  <li><a href="history.html">History</a></li>
191                  <li><a href="management.html">Management</a></li>
192                  <li><a href="tabs.html">Tabs</a></li>
193                  <li><a href="windows.html">Windows</a></li>
194                </ul>
195              </li>
196              <li>Implementation
197                <ul>
198                  <li><a href="a11y.html">Accessibility</a></li>
199                  <li><a href="background_pages.html">Background Pages</a></li>
200                  <li><a href="content_scripts.html">Content Scripts</a></li>
201                  <li><a href="xhr.html">Cross-Origin XHR</a></li>
202                  <li><a href="idle.html">Idle</a></li>
203                  <li><a href="i18n.html">Internationalization</a></li>
204                  <li><a href="messaging.html">Message Passing</a></li>
205                  <li><a href="npapi.html">NPAPI Plugins</a></li>
206                </ul>
207              </li>
208              <li>Finishing
209                <ul>
210                  <li><a href="hosting.html">Hosting</a></li>
211                  <li><a href="external_extensions.html">Other Deployment Options</a></li>
212                </ul>
213              </li>
214            </ul>
215          </li>
216          <li><h2><a href="apps.html">Packaged Apps</a></h2></li>
217          <li><h2><a href="tutorials.html">Tutorials</a></h2>
218            <ul>
219              <li><a href="tut_debugging.html">Debugging</a></li>
220              <li><a href="tut_analytics.html">Google Analytics</a></li>
221              <li><a href="tut_oauth.html">OAuth</a></li>
222            </ul>
223          </li>
224          <li><h2>Reference</h2>
225            <ul>
226              <li>Formats
227                <ul>
228                  <li><a href="manifest.html">Manifest Files</a></li>
229                  <li><a href="match_patterns.html">Match Patterns</a></li>
230                </ul>
231              </li>
232              <li><a href="permission_warnings.html">Permission Warnings</a></li>
233              <li><a href="api_index.html">chrome.* APIs</a></li>
234              <li><a href="api_other.html">Other APIs</a></li>
235            </ul>
236          </li>
237          <li><h2><a href="samples.html">Samples</a></h2></li>
238          <div class="line"> </div>
239          <li><h2>More</h2>
240            <ul>
241              <li><a href="http://code.google.com/chrome/webstore/docs/index.html">Chrome Web Store</a></li>
242              <li><a href="http://code.google.com/chrome/apps/docs/developers_guide.html">Hosted Apps</a></li>
243              <li><a href="themes.html">Themes</a></li>
244            </ul>
245          </li>
246        </ul>
247      </div>
248      <script>
249        initToggles();
250      </script>
251
252    <div class="g-unit" id="gc-pagecontent">
253      <div id="pageTitle">
254        <h1 class="page_title">CRX Package Format</h1>
255      </div>
256        <!-- TABLE OF CONTENTS -->
257        <div id="toc">
258          <h2>Contents</h2>
259          <ol>
260            <li>
261              <a href="#H2-0">Package header</a>
262              <ol>
263                <li style="display: none; ">
264                  <a>h3Name</a>
265                </li>
266              </ol>
267            </li><li>
268              <a href="#H2-1">Extension contents</a>
269              <ol>
270                <li style="display: none; ">
271                  <a>h3Name</a>
272                </li>
273              </ol>
274            </li><li>
275              <a href="#H2-2">Example</a>
276              <ol>
277                <li style="display: none; ">
278                  <a>h3Name</a>
279                </li>
280              </ol>
281            </li><li>
282              <a href="#scripts">Packaging scripts</a>
283              <ol>
284                <li>
285                  <a href="#ruby">Ruby</a>
286                </li><li>
287                  <a href="#H3-5">Bash</a>
288                </li>
289              </ol>
290            </li>
291              <li style="display: none; ">
292                <a href="#apiReference">API reference</a>
293                <ol>
294                  <li>
295                    <a href="#properties">Properties</a>
296                    <ol>
297                      <li>
298                        <a href="#property-anchor">propertyName</a>
299                      </li>
300                    </ol>
301                  </li>
302                  <li>
303                    <a>Methods</a>
304                    <ol>
305                      <li>
306                        <a href="#method-anchor">methodName</a>
307                      </li>
308                    </ol>
309                  </li>
310                  <li>
311                    <a>Events</a>
312                    <ol>
313                      <li>
314                        <a href="#event-anchor">eventName</a>
315                      </li>
316                    </ol>
317                  </li>
318                  <li>
319                    <a href="#types">Types</a>
320                    <ol>
321                      <li>
322                        <a href="#id-anchor">id</a>
323                      </li>
324                    </ol>
325                  </li>
326                </ol>
327              </li>
328          </ol>
329        </div>
330        <!-- /TABLE OF CONTENTS -->
331
332        <!-- Standard content lead-in for experimental API pages -->
333        <p id="classSummary" style="display: none; ">
334          For information on how to use experimental APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page.
335        </p>
336
337        <!-- STATIC CONTENT PLACEHOLDER -->
338        <div id="static"><div id="pageData-name" class="pageData">CRX Package Format</div>
339<div id="pageData-showTOC" class="pageData">true</div>
340
341<p>
342CRX files are ZIP files with a special header and the <code>.crx</code> file
343extension.
344</p>
345
346<a name="H2-0"></a><h2>Package header</h2>
347
348<p>
349The header contains the author's public key and the extension's signature.
350The signature is generated from the ZIP file using SHA-1 with the
351author's private key. The header requires a little-endian byte ordering with
3524-byte alignment. The following table describes the fields of
353the <code>.crx</code> header in order:
354</p>
355
356<table>
357  <tbody><tr>
358    <th>Field</th><th>Type</th><th>Length</th><th>Value</th><th>Description</th>
359  </tr>
360  <tr>
361    <td><em>magic number</em></td><td>char[]</td><td>32 bits</td><td>Cr24</td>
362    <td>
363      Chrome requires this constant at the beginning of every <code>.crx</code>
364      package.
365    </td>
366  </tr>
367  <tr>
368    <td><em>version</em></td><td>unsigned&nbsp;int</td><td>32 bits</td><td>2</td>
369    <td>The version of the <code>*.crx</code> file format used (currently 2).</td>
370  </tr>
371  <tr>
372    <td><em>public key length</em></td><td>unsigned&nbsp;int</td><td>32 bits</td>
373    <td><i>pubkey.length</i></td>
374    <td>
375      The length of the RSA public key in <em>bytes</em>.
376    </td>
377  </tr>
378  <tr>
379    <td><em>signature length</em></td><td>unsigned&nbsp;int</td><td>32 bits</td>
380    <td><i>sig.length</i></td>
381    <td>
382      The length of the signature in <em>bytes</em>.
383    </td>
384  </tr>
385  <tr>
386    <td><em>public key</em></td><td>byte[]</td><td><i>pubkey.length</i></td>
387    <td><i>pubkey.contents</i></td>
388    <td>
389      The contents of the author's RSA public key, formatted as an X509
390      SubjectPublicKeyInfo block.
391    </td>
392  </tr>
393  <tr>
394    <td><em>signature</em></td><td>byte[]</td><td><i>sig.length</i></td>
395    <td><i>sig.contents</i></td>
396    <td>
397      The signature of the ZIP content using the author's private key. The
398      signature is created using the RSA algorithm with the SHA-1 hash function.
399    </td>
400  </tr>
401</tbody></table>
402
403<a name="H2-1"></a><h2>Extension contents</h2>
404
405<p>
406The extension's ZIP file is appended to the <code>*.crx</code> package after the
407header. This should be the same ZIP file that the signature in the header
408was generated from.
409</p>
410
411<a name="H2-2"></a><h2>Example</h2>
412
413<p>
414The following is an example hex dump from the beginning of a <code>.crx</code>
415file.
416</p>
417
418<pre>43 72 32 34   # "Cr24" -- the magic number
41902 00 00 00   # 2 -- the crx format version number
420A2 00 00 00   # 162 -- length of public key in bytes
42180 00 00 00   # 128 -- length of signature in bytes
422...........   # the contents of the public key
423...........   # the contents of the signature
424...........   # the contents of the zip file
425
426</pre>
427
428<h2 id="scripts">Packaging scripts</h2>
429<p>
430Members of the community have written the following scripts to package
431<code>.crx</code> files.
432</p>
433
434<h3 id="ruby">Ruby</h3>
435<blockquote>
436<a href="http://github.com/Constellation/crxmake">github: crxmake</a>
437</blockquote>
438
439<a name="H3-5"></a><h3>Bash</h3>
440<pre>#!/bin/bash -e
441#
442# Purpose: Pack a Chromium extension directory into crx format
443
444if test $# -ne 2; then
445  echo "Usage: crxmake.sh &lt;extension dir&gt; &lt;pem path&gt;"
446  exit 1
447fi
448
449dir=$1
450key=$2
451name=$(basename "$dir")
452crx="$name.crx"
453pub="$name.pub"
454sig="$name.sig"
455zip="$name.zip"
456trap 'rm -f "$pub" "$sig" "$zip"' EXIT
457
458# zip up the crx dir
459cwd=$(pwd -P)
460(cd "$dir" &amp;&amp; zip -qr -9 -X "$cwd/$zip" .)
461
462# signature
463openssl sha1 -sha1 -binary -sign "$key" &lt; "$zip" &gt; "$sig"
464
465# public key
466openssl rsa -pubout -outform DER &lt; "$key" &gt; "$pub" 2&gt;/dev/null
467
468byte_swap () {
469  # Take "abcdefgh" and return it as "ghefcdab"
470  echo "${1:6:2}${1:4:2}${1:2:2}${1:0:2}"
471}
472
473crmagic_hex="4372 3234" # Cr24
474version_hex="0200 0000" # 2
475pub_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$pub" | awk '{print $5}')))
476sig_len_hex=$(byte_swap $(printf '%08x\n' $(ls -l "$sig" | awk '{print $5}')))
477(
478  echo "$crmagic_hex $version_hex $pub_len_hex $sig_len_hex" | xxd -r -p
479  cat "$pub" "$sig" "$zip"
480) &gt; "$crx"
481echo "Wrote $crx"
482</pre>
483
484</div>
485
486        <!-- API PAGE -->
487        <div class="apiPage" style="display: none; ">
488        <a name="apiReference"></a>
489        <h2>API reference: chrome.apiname </h2>
490
491          <!-- PROPERTIES -->
492          <div class="apiGroup">
493            <a name="properties"></a>
494            <h3 id="properties">Properties</h3>
495
496            <div>
497              <a></a>
498              <h4>getLastError</h4>
499              <div class="summary">
500                <!-- Note: intentionally longer 80 columns -->
501                <span>chrome.extension</span><span>lastError</span>
502              </div>
503              <div>
504              </div>
505            </div>
506
507          </div> <!-- /apiGroup -->
508
509          <!-- METHODS -->
510          <div id="methodsTemplate" class="apiGroup">
511            <a></a>
512            <h3>Methods</h3>
513
514            <!-- iterates over all functions -->
515            <div class="apiItem">
516              <a></a> <!-- method-anchor -->
517              <h4>method name</h4>
518
519              <div class="summary"><span>void</span>
520                  <!-- Note: intentionally longer 80 columns -->
521                  <span>chrome.module.methodName</span>(<span><span>, </span><span></span>
522                      <var><span></span></var></span>)</div>
523
524              <div class="description">
525                <p class="todo">Undocumented.</p>
526                <p>
527                  A description from the json schema def of the function goes here.
528                </p>
529
530                <!-- PARAMETERS -->
531                <h4>Parameters</h4>
532                <dl>
533                  <div>
534                    <div>
535                    </div>
536                  </div>
537                </dl>
538
539                <!-- RETURNS -->
540                <h4>Returns</h4>
541                <dl>
542                  <div>
543                    <div>
544                    </div>
545                  </div>
546                </dl>
547
548                <!-- CALLBACK -->
549                <div>
550                  <div>
551                  <h4>Callback function</h4>
552                  <p>
553                    The callback <em>parameter</em> should specify a function
554                    that looks like this:
555                  </p>
556                  <p>
557                    If you specify the <em>callback</em> parameter, it should
558                    specify a function that looks like this:
559                  </p>
560
561                  <!-- Note: intentionally longer 80 columns -->
562                  <pre>function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span>;</pre>
563                  <dl>
564                    <div>
565                      <div>
566                      </div>
567                    </div>
568                  </dl>
569                  </div>
570                </div>
571
572                <!-- MIN_VERSION -->
573                <p>
574                  This function was added in version <b><span></span></b>.
575                  If you require this function, the manifest key
576                  <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a>
577                  can ensure that your extension won't be run in an earlier browser version.
578                </p>
579              </div> <!-- /description -->
580
581            </div>  <!-- /apiItem -->
582
583          </div>  <!-- /apiGroup -->
584
585          <!-- EVENTS -->
586          <div id="eventsTemplate" class="apiGroup">
587            <a></a>
588            <h3>Events</h3>
589            <!-- iterates over all events -->
590            <div class="apiItem">
591              <a></a>
592              <h4>event name</h4>
593
594              <div class="summary">
595                <!-- Note: intentionally longer 80 columns -->
596                <span class="subdued">chrome.bookmarks</span><span>onEvent</span><span class="subdued">.addListener</span>(function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span>);
597              </div>
598
599              <div class="description">
600                <p class="todo">Undocumented.</p>
601                <p>
602                  A description from the json schema def of the event goes here.
603                </p>
604
605                <!-- PARAMETERS -->
606                <div>
607                  <h4>Parameters</h4>
608                  <dl>
609                    <div>
610                      <div>
611                      </div>
612                    </div>
613                  </dl>
614                </div>
615              </div> <!-- /decription -->
616
617            </div> <!-- /apiItem -->
618
619          </div> <!-- /apiGroup -->
620
621          <!-- TYPES -->
622          <div class="apiGroup">
623            <a name="types"></a>
624            <h3 id="types">Types</h3>
625
626            <!-- iterates over all types -->
627            <div class="apiItem">
628              <a></a>
629              <h4>type name</h4>
630
631              <div>
632              </div>
633
634            </div> <!-- /apiItem -->
635
636          </div> <!-- /apiGroup -->
637
638        </div> <!-- /apiPage -->
639      </div> <!-- /gc-pagecontent -->
640    </div> <!-- /g-section -->
641  </div> <!-- /codesiteContent -->
642    <div id="gc-footer" --="">
643      <div class="text">
644  <p>
645  Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>,
646  the content of this page is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons
647  Attribution 3.0 License</a>, and code samples are licensed under the
648  <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD License</a>.
649  </p>
650  <p>
651  ©2011 Google
652  </p>
653
654<!-- begin analytics -->
655<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>
656<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script>
657
658<script type="text/javascript">
659  // chrome doc tracking
660  try {
661    var engdocs = _gat._getTracker("YT-10763712-2");
662    engdocs._trackPageview();
663  } catch(err) {}
664
665  // code.google.com site-wide tracking
666  try {
667    _uacct="UA-18071-1";
668    _uanchor=1;
669    _uff=0;
670    urchinTracker();
671  }
672  catch(e) {/* urchinTracker not available. */}
673</script>
674<!-- end analytics -->
675      </div>
676    </div> <!-- /gc-footer -->
677  </div> <!-- /gc-container -->
678</body></html>
679