devguide.html revision 4a5e2dc747d50c653511c68ccb2cfbfb740bd5a7
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>Developer's Guide - 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 <!-- FUNCTION PARAMETERS --> 85 <dd> 86 <div></div> 87 </dd> 88 89 </div> <!-- /VALUE --> 90 91 <div id="functionParametersTemplate"> 92 <h5>Parameters</h5> 93 <dl> 94 <div> 95 <div> 96 </div> 97 </div> 98 </dl> 99 </div> 100 </div> <!-- /SUBTEMPLATES --> 101 102 <a id="top"></a> 103 <div id="skipto"> 104 <a href="#gc-pagecontent">Skip to page content</a> 105 <a href="#gc-toc">Skip to main navigation</a> 106 </div> 107 <!-- API HEADER --> 108 <table id="header" width="100%" cellspacing="0" border="0"> 109 <tbody><tr> 110 <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> 111 <td valign="middle" width="100%" style="padding-left:0.6em;"> 112 <form action="http://www.google.com/cse" id="cse" style="margin-top:0.5em"> 113 <div id="gsc-search-box"> 114 <input type="hidden" name="cx" value="002967670403910741006:61_cvzfqtno"> 115 <input type="hidden" name="ie" value="UTF-8"> 116 <input type="text" name="q" value="" size="55"> 117 <input class="gsc-search-button" type="submit" name="sa" value="Search"> 118 <br> 119 <span class="greytext">e.g. "page action" or "tabs"</span> 120 </div> 121 </form> 122 123 <script type="text/javascript" src="http://www.google.com/jsapi"></script> 124 <script type="text/javascript">google.load("elements", "1", {packages: "transliteration"});</script> 125 <script type="text/javascript" src="http://www.google.com/coop/cse/t13n?form=cse&t13n_langs=en"></script> 126 <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse&lang=en"></script> 127 </td> 128 </tr> 129 </tbody></table> 130 131 <div id="codesiteContent" class=""> 132 133 <a id="gc-topnav-anchor"></a> 134 <div id="gc-topnav"> 135 <h1>Google Chrome Extensions (<a href="http://code.google.com/labs/">Labs</a>)</h1> 136 <ul id="home" class="gc-topnav-tabs"> 137 <li id="home_link"> 138 <a href="index.html" title="Google Chrome Extensions home page">Home</a> 139 </li> 140 <li id="docs_link"> 141 <a href="docs.html" title="Official Google Chrome Extensions documentation">Docs</a> 142 </li> 143 <li id="faq_link"> 144 <a href="faq.html" title="Answers to frequently asked questions about Google Chrome Extensions">FAQ</a> 145 </li> 146 <li id="samples_link"> 147 <a href="samples.html" title="Sample extensions (with source code)">Samples</a> 148 </li> 149 <li id="group_link"> 150 <a href="http://groups.google.com/a/chromium.org/group/chromium-extensions" title="Google Chrome Extensions developer forum">Group</a> 151 </li> 152 </ul> 153 </div> <!-- end gc-topnav --> 154 155 <div class="g-section g-tpl-170"> 156 <!-- SIDENAV --> 157 <div class="g-unit g-first" id="gc-toc"> 158 <ul> 159 <li><a href="getstarted.html">Getting Started</a></li> 160 <li><a href="overview.html">Overview</a></li> 161 <li><a href="whats_new.html">What's New?</a></li> 162 <li><h2><a href="devguide.html">Developer's Guide</a></h2> 163 <ul> 164 <li>Browser UI 165 <ul> 166 <li><a href="browserAction.html">Browser Actions</a></li> 167 <li><a href="contextMenus.html">Context Menus</a></li> 168 <li><a href="notifications.html">Desktop Notifications</a></li> 169 <li><a href="options.html">Options Pages</a></li> 170 <li><a href="override.html">Override Pages</a></li> 171 <li><a href="pageAction.html">Page Actions</a></li> 172 <li><a href="themes.html">Themes</a></li> 173 </ul> 174 </li> 175 <li>Browser Interaction 176 <ul> 177 <li><a href="bookmarks.html">Bookmarks</a></li> 178 <li><a href="cookies.html">Cookies</a></li> 179 <li><a href="events.html">Events</a></li> 180 <li><a href="history.html">History</a></li> 181 <li><a href="management.html">Management</a></li> 182 <li><a href="tabs.html">Tabs</a></li> 183 <li><a href="windows.html">Windows</a></li> 184 </ul> 185 </li> 186 <li>Implementation 187 <ul> 188 <li><a href="a11y.html">Accessibility</a></li> 189 <li><a href="background_pages.html">Background Pages</a></li> 190 <li><a href="content_scripts.html">Content Scripts</a></li> 191 <li><a href="xhr.html">Cross-Origin XHR</a></li> 192 <li><a href="idle.html">Idle</a></li> 193 <li><a href="i18n.html">Internationalization</a></li> 194 <li><a href="messaging.html">Message Passing</a></li> 195 <li><a href="npapi.html">NPAPI Plugins</a></li> 196 </ul> 197 </li> 198 <li>Finishing 199 <ul> 200 <li><a href="hosting.html">Hosting</a></li> 201 <li><a href="external_extensions.html">Other Deployment Options</a></li> 202 </ul> 203 </li> 204 </ul> 205 </li> 206 <li><h2><a href="tutorials.html">Tutorials</a></h2> 207 <ul> 208 <li><a href="tut_debugging.html">Debugging</a></li> 209 <li><a href="tut_analytics.html">Google Analytics</a></li> 210 <li><a href="tut_oauth.html">OAuth</a></li> 211 </ul> 212 </li> 213 <li><h2>Reference</h2> 214 <ul> 215 <li>Formats 216 <ul> 217 <li><a href="manifest.html">Manifest Files</a></li> 218 <li><a href="match_patterns.html">Match Patterns</a></li> 219 <!-- <li>Packages (.crx)</li> --> 220 </ul> 221 </li> 222 <li><a href="api_index.html">chrome.* APIs</a></li> 223 <li><a href="api_other.html">Other APIs</a></li> 224 </ul> 225 </li> 226 <li><h2><a href="samples.html">Samples</a></h2></li> 227 <div class="line"> </div> 228 <li><h2>More</h2> 229 <ul> 230 <li><a href="http://code.google.com/chrome/webstore/docs/index.html">Chrome Web Store</a></li> 231 <li><a href="http://code.google.com/chrome/apps/docs/developers_guide.html">Installable Web Apps</a></li> 232 <li><a href="themes.html">Themes</a></li> 233 </ul> 234 </li> 235 </ul> 236 </div> 237 <script> 238 initToggles(); 239 </script> 240 241 <div class="g-unit" id="gc-pagecontent"> 242 <div id="pageTitle"> 243 <h1 class="page_title">Developer's Guide</h1> 244 </div> 245 <!-- TABLE OF CONTENTS --> 246 <div id="toc" style="display: none; "> 247 <h2>Contents</h2> 248 <ol> 249 <li> 250 <a>h2Name</a> 251 <ol> 252 <li> 253 <a>h3Name</a> 254 </li> 255 </ol> 256 </li> 257 <li> 258 <a href="#apiReference">API reference</a> 259 <ol> 260 <li> 261 <a href="#properties">Properties</a> 262 <ol> 263 <li> 264 <a href="#property-anchor">propertyName</a> 265 </li> 266 </ol> 267 </li> 268 <li> 269 <a href="#methods">Methods</a> 270 <ol> 271 <li> 272 <a href="#method-anchor">methodName</a> 273 </li> 274 </ol> 275 </li> 276 <li> 277 <a href="#events">Events</a> 278 <ol> 279 <li> 280 <a href="#event-anchor">eventName</a> 281 </li> 282 </ol> 283 </li> 284 <li> 285 <a href="#types">Types</a> 286 <ol> 287 <li> 288 <a href="#id-anchor">id</a> 289 </li> 290 </ol> 291 </li> 292 </ol> 293 </li> 294 </ol> 295 </div> 296 <!-- /TABLE OF CONTENTS --> 297 298 <!-- Standard content lead-in for experimental API pages --> 299 <p id="classSummary" style="display: none; "> 300 For information on how to use experimental APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page. 301 </p> 302 303 <!-- STATIC CONTENT PLACEHOLDER --> 304 <div id="static"><div id="pageData-name" class="pageData">Developer's Guide</div> 305 306<p> 307These pages assume you've completed 308the <a href="getstarted.html">Getting Started</a> tutorial 309and <a href="overview.html">Overview</a>. 310</p> 311 312<table class="columns"> 313 <tbody><tr> 314 <td colspan="2"><h4>Changing the Google Chrome chrome</h4></td> 315 </tr> 316 <tr> 317 <td colspan="2"> </td> 318 </tr> 319 <tr> 320 <td> <a href="browserAction.html">Browser Actions</a> </td> 321 <td> Add icons to the toolbar </td> 322 </tr> 323 <tr> 324 <td> <a href="notifications.html">Desktop Notifications</a> </td> 325 <td> Notify users of important events </td> 326 </tr> 327 <tr> 328 <td> <a href="options.html">Options Pages</a> </td> 329 <td> Let users customize your extension </td> 330 </tr> 331 <tr> 332 <td> <a href="override.html">Override Pages</a> </td> 333 <td> Implement your own version of standard browser pages 334 such as the New Tab page</td> 335 </tr> 336 <tr> 337 <td> <a href="pageAction.html">Page Actions</a> </td> 338 <td> Add temporary icons inside the address bar </td> 339 </tr> 340 <tr> 341 <td> <a href="themes.html">Themes</a> </td> 342 <td> Change the overall appearance of the browser </td> 343 </tr> 344 345 <tr> 346 <td colspan="2"><h4>Interacting with Google Chrome in other ways</h4></td> 347 </tr> 348 <tr> 349 <td colspan="2"> </td> 350 </tr> 351 <tr> 352 <td> <a href="bookmarks.html">Bookmarks</a> </td> 353 <td> Create, organize, and otherwise manipulate the user's bookmarks </td> 354 </tr> 355 <tr> 356 <td> <a href="cookies.html">Cookies</a> </td> 357 <td> Explore and modify the browser's cookie system </td> 358 </tr> 359 <tr> 360 <td> <a href="events.html">Events</a> </td> 361 <td> Detect when something interesting happens </td> 362 </tr> 363 <tr> 364 <td> <a href="history.html">History</a> </td> 365 <td> Interact with the browser's record of visited pages </td> 366 </tr> 367 <tr> 368 <td> <a href="tabs.html">Tabs</a> </td> 369 <td> Create, modify, and rearrange tabs in the browser </td> 370 </tr> 371 <tr> 372 <td> <a href="windows.html">Windows</a> </td> 373 <td> Create, modify, and rearrange windows in the browser </td> 374 </tr> 375 376 <tr> 377 <td colspan="2"><h4>Implementing the innards of your extension</h4></td> 378 </tr> 379 <tr> 380 <td colspan="2"> </td> 381 </tr> 382 <tr> 383 <td> <a href="a11y.html">Accessibility (a11y)</a> </td> 384 <td> Make your extension accessible to people with disabilities </td> 385 </tr> 386 <tr> 387 <td> <a href="background_pages.html">Background Pages</a> </td> 388 <td> Put all the common code for your extension in a single place </td> 389 </tr> 390 <tr> 391 <td> <a href="content_scripts.html">Content Scripts</a> </td> 392 <td> Run JavaScript code in the context of web pages </td> 393 </tr> 394 <tr> 395 <td> <a href="xhr.html">Cross-Origin XHR</a> </td> 396 <td> Use XMLHttpRequest to send and receive data from remote servers </td> 397 </tr> 398 <tr> 399 <td> <a href="i18n.html">Internationalization</a> </td> 400 <td> Deal with language and locale </td> 401 </tr> 402 <tr> 403 <td> <a href="messaging.html">Message Passing</a> </td> 404 <td> Communicate from a content script to its parent extension, 405 or vice versa</td> 406 </tr> 407 <tr> 408 <td> <a href="npapi.html">NPAPI Plugins</a> </td> 409 <td> Load native binary code </td> 410 </tr> 411 412 <tr> 413 <td colspan="2"><h4>Finishing and distributing your extension</h4></td> 414 </tr> 415 <tr> 416 <td colspan="2"> </td> 417 </tr> 418 <tr> 419 <td> <a href="autoupdate.html">Autoupdating</a> </td> 420 <td> Update extensions automatically </td> 421 </tr> 422 <tr> 423 <td> <a href="hosting.html">Hosting</a> </td> 424 <td> Host extensions in the Extensions Gallery or on your own servers </td> 425 </tr> 426 <tr> 427 <td> <a href="external_extensions.html">Other Deployment Options</a> </td> 428 <td> Distribute extensions on your network or with other software </td> 429 </tr> 430 <tr> 431 <td> <a href="packaging.html">Packaging</a> </td> 432 <td> Create a <code>.crx</code> file so you can distribute your extension </td> 433 </tr> 434</tbody></table> 435 436</div> 437 438 <!-- API PAGE --> 439 <div class="apiPage" style="display: none; "> 440 <a name="apiReference"></a> 441 <h2>API reference: chrome.apiname </h2> 442 443 <!-- PROPERTIES --> 444 <div class="apiGroup"> 445 <a name="properties"></a> 446 <h3 id="properties">Properties</h3> 447 448 <div> 449 <a></a> 450 <h4>getLastError</h4> 451 <div class="summary"> 452 <!-- Note: intentionally longer 80 columns --> 453 <span>chrome.extension</span><span>lastError</span> 454 </div> 455 <div> 456 </div> 457 </div> 458 459 </div> <!-- /apiGroup --> 460 461 <!-- METHODS --> 462 <div class="apiGroup" id="methods"> 463 <a name="methods"></a> 464 <h3>Methods</h3> 465 466 <!-- iterates over all functions --> 467 <div class="apiItem"> 468 <a></a> <!-- method-anchor --> 469 <h4>method name</h4> 470 471 <div class="summary"><span>void</span> 472 <!-- Note: intentionally longer 80 columns --> 473 <span>chrome.module.methodName</span>(<span><span>, </span><span></span> 474 <var><span></span></var></span>)</div> 475 476 <div class="description"> 477 <p class="todo">Undocumented.</p> 478 <p> 479 A description from the json schema def of the function goes here. 480 </p> 481 482 <!-- PARAMETERS --> 483 <h4>Parameters</h4> 484 <dl> 485 <div> 486 <div> 487 </div> 488 </div> 489 </dl> 490 491 <!-- RETURNS --> 492 <h4>Returns</h4> 493 <dl> 494 <div> 495 <div> 496 </div> 497 </div> 498 </dl> 499 500 <!-- CALLBACK --> 501 <div> 502 <div> 503 <h4>Callback function</h4> 504 <p> 505 The callback <em>parameter</em> should specify a function 506 that looks like this: 507 </p> 508 <p> 509 If you specify the <em>callback</em> parameter, it should 510 specify a function that looks like this: 511 </p> 512 513 <!-- Note: intentionally longer 80 columns --> 514 <pre>function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span>;</pre> 515 <dl> 516 <div> 517 <div> 518 </div> 519 </div> 520 </dl> 521 </div> 522 </div> 523 524 <!-- MIN_VERSION --> 525 <p> 526 This function was added in version <b><span></span></b>. 527 If you require this function, the manifest key 528 <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> 529 can ensure that your extension won't be run in an earlier browser version. 530 </p> 531 </div> <!-- /description --> 532 533 </div> <!-- /apiItem --> 534 535 </div> <!-- /apiGroup --> 536 537 <!-- EVENTS --> 538 <div class="apiGroup"> 539 <a name="events"></a> 540 <h3 id="events">Events</h3> 541 542 <!-- iterates over all events --> 543 <div class="apiItem"> 544 <a></a> 545 <h4>event name</h4> 546 547 <div class="summary"> 548 <!-- Note: intentionally longer 80 columns --> 549 <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>); 550 </div> 551 552 <div class="description"> 553 <p class="todo">Undocumented.</p> 554 <p> 555 A description from the json schema def of the event goes here. 556 </p> 557 558 <!-- PARAMETERS --> 559 <h4>Parameters</h4> 560 <dl> 561 <div> 562 <div> 563 </div> 564 </div> 565 </dl> 566 567 </div> <!-- /decription --> 568 569 </div> <!-- /apiItem --> 570 571 </div> <!-- /apiGroup --> 572 573 <!-- TYPES --> 574 <div class="apiGroup"> 575 <a name="types"></a> 576 <h3 id="types">Types</h3> 577 578 <!-- iterates over all types --> 579 <div class="apiItem"> 580 <a></a> 581 <h4>type name</h4> 582 583 <div> 584 </div> 585 586 </div> <!-- /apiItem --> 587 588 </div> <!-- /apiGroup --> 589 590 </div> <!-- /apiPage --> 591 </div> <!-- /gc-pagecontent --> 592 </div> <!-- /g-section --> 593 </div> <!-- /codesiteContent --> 594 <div id="gc-footer" --=""> 595 <div class="text"> 596 <p> 597 Except as otherwise <a href="http://code.google.com/policies.html#restrictions">noted</a>, 598 the content of this page is licensed under the <a rel="license" href="http://creativecommons.org/licenses/by/3.0/">Creative Commons 599 Attribution 3.0 License</a>, and code samples are licensed under the 600 <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD License</a>. 601 </p> 602 <p> 603 ©2010 Google 604 </p> 605 606<!-- begin analytics --> 607<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script> 608<script src="http://www.google-analytics.com/ga.js" type="text/javascript"></script> 609 610<script type="text/javascript"> 611 // chrome doc tracking 612 try { 613 var engdocs = _gat._getTracker("YT-10763712-2"); 614 engdocs._trackPageview(); 615 } catch(err) {} 616 617 // code.google.com site-wide tracking 618 try { 619 _uacct="UA-18071-1"; 620 _uanchor=1; 621 _uff=0; 622 urchinTracker(); 623 } 624 catch(e) {/* urchinTracker not available. */} 625</script> 626<!-- end analytics --> 627 </div> 628 </div> <!-- /gc-footer --> 629 </div> <!-- /gc-container --> 630</body></html> 631