diff options
author | Kristian Monsen <kristianm@google.com> | 2011-07-26 12:15:06 +0100 |
---|---|---|
committer | Kristian Monsen <kristianm@google.com> | 2011-07-26 20:41:55 +0100 |
commit | 3dff810fe0cc4962a5fa554318e9bf8bc45f5274 (patch) | |
tree | a9fffa9ab7d061ab00538c18beb77403547378d0 /chrome/common/extensions/docs/static | |
parent | 67d814a5d5c8d7df4740db4d2d74d0a41f94bece (diff) | |
download | external_chromium-3dff810fe0cc4962a5fa554318e9bf8bc45f5274.zip external_chromium-3dff810fe0cc4962a5fa554318e9bf8bc45f5274.tar.gz external_chromium-3dff810fe0cc4962a5fa554318e9bf8bc45f5274.tar.bz2 |
Merge Chromium at 12.0.742.130: Initial merge by git
Fix for bug 5080607 Update external/chromium to latest revision
Change-Id: I5c98b0d2845fccca4cbcdcea506e8f1759ba5416
Diffstat (limited to 'chrome/common/extensions/docs/static')
-rw-r--r-- | chrome/common/extensions/docs/static/overview.html | 138 | ||||
-rw-r--r-- | chrome/common/extensions/docs/static/whats_new.html | 58 |
2 files changed, 170 insertions, 26 deletions
diff --git a/chrome/common/extensions/docs/static/overview.html b/chrome/common/extensions/docs/static/overview.html index dabc217..1da4f38 100644 --- a/chrome/common/extensions/docs/static/overview.html +++ b/chrome/common/extensions/docs/static/overview.html @@ -283,7 +283,7 @@ Here are some examples of extensions that usually An extension with a content script that doesn't use cross-origin XMLHttpRequests or localStorage, and that doesn't need to use - <a href="api_index.html">extension APIs</a>. + <a href="#apis">extension APIs</a>. </li> <li> An extension that has no UI except for an options page. @@ -305,7 +305,7 @@ Any extension can have an options page, which lets users customize how the extension works. Another type of special page is the override page. And finally, you can -use <a href="tabs.html#method-create"><code>chrome.tabs.create()</code></a> +use <a href="tabs.html#method-create">chrome.tabs.create()</a> or <code>window.open()</code> to display any other HTML files that are in the extension. </p> @@ -404,6 +404,140 @@ see <a href="content_scripts.html">Content Scripts</a>. </p> +<h2 id="apis"> Using the chrome.* APIs </h2> + +<p> +In addition to having access to all the APIs that web pages and apps can use, +extensions can also use Chrome-only APIs +(often called <em>chrome.* APIs</em>) +that allow tight integration with the browser. +For example, any extension or web app can use the +standard <code>window.open()</code> method to open a URL. +But if you want to specify which window that URL should be displayed in, +your extension can use the Chrome-only +<a href="tabs.html#method-create">chrome.tabs.create()</a> +method instead. +</p> + +<h3 id="sync"> Asynchronous vs. synchronous methods </h3> +<p> +Most methods in the chrome.* APIs are <b>asynchronous</b>: +they return immediately, without waiting for the operation to finish. +If you need to know the outcome of that operation, +then you pass a callback function into the method. +That callback is executed later (potentially <em>much</em> later), +sometime after the method returns. +Here's an example of the signature for an asynchronous method: +</p> + +<p> +<code> +chrome.tabs.create(object <em>createProperties</em>, function <em>callback</em>) +</code> +</p> + +<p> +Other chrome.* methods are <b>synchronous</b>. +Synchronous methods never have a callback +because they don't return until they've completed all their work. +Often, synchronous methods have a return type. +Consider the +<a href="extension.html#method-getBackgroundPage">chrome.extensions.getBackgroundPage()</a> method: +</p> + +<p> +<code> +DOMWindow chrome.extension.getBackgroundPage() +</code> +</p> + +<p> +This method has no callback and a return type of <code>DOMWindow</code> +because it synchronously returns the background page +and performs no other, asynchronous work. +</p> + + +<h3 id="sync-example"> Example: Using a callback </h3> + +<p> +Say you want to navigate +the user's currently selected tab to a new URL. +To do this, you need to get the current tab's ID +(using <a href="tabs.html#method-getSelected">chrome.tabs.getSelected()</a>) +and then make that tab go to the new URL +(using <a href="tabs.html#method-update">chrome.tabs.update()</a>). +</p> + +<p> +If <code>getSelected()</code> were synchronous, +you might write code like this: +</p> + +<pre> + <b>//THIS CODE DOESN'T WORK</b> +<span class="linenumber">1: </span>var tab = chrome.tabs.getSelected(null); <b>//WRONG!!!</b> +<span class="linenumber">2: </span>chrome.tabs.update(tab.id, {url:newUrl}); +<span class="linenumber">3: </span>someOtherFunction(); +</pre> + +<p> +That approach fails +because <code>getSelected()</code> is asynchronous. +It returns without waiting for its work to complete, +and it doesn't even return a value +(although some asynchronous methods do). +You can tell that <code>getSelected()</code> is asynchronous +by the <em>callback</em> parameter in its signature: + +<p> +<code> +chrome.tabs.getSelected(integer <em>windowId</em>, function <em>callback</em>) +</code> +</p> + +<p> +To fix the preceding code, +you must use that callback parameter. +The following code shows +how to define a callback function +that gets the results from <code>getSelected()</code> +(as a parameter named <code>tab</code>) +and calls <code>update()</code>. +</p> + +<pre> + <b>//THIS CODE WORKS</b> +<span class="linenumber">1: </span>chrome.tabs.getSelected(null, <b>function(tab) {</b> +<span class="linenumber">2: </span> chrome.tabs.update(tab.id, {url:newUrl}); +<span class="linenumber">3: </span><b>}</b>); +<span class="linenumber">4: </span>someOtherFunction(); +</pre> + +<p> +In this example, the lines are executed in the following order: 1, 4, 2. +The callback function specified to <code>getSelected</code> is called +(and line 2 executed) +only after information about the currently selected tab is available, +which is sometime after <code>getSelected()</code> returns. +Although <code>update()</code> is asynchronous, +this example doesn't use its callback parameter, +since we don't do anything about the results of the update. +</p> + + +<h3 id="chrome-more"> More details </h3> + +<p> +For more information, see the +<a href="api_index.html">chrome.* API docs</a> +and watch this video: +</p> + +<p> +<iframe title="YouTube video player" width="640" height="390" src="http://www.youtube.com/embed/bmxr75CV36A?rel=0" frameborder="0" allowfullscreen></iframe> +</p> + <h2 id="pageComm">Communication between pages </h2> <p> diff --git a/chrome/common/extensions/docs/static/whats_new.html b/chrome/common/extensions/docs/static/whats_new.html index 437e9cd..5c1bd6e 100644 --- a/chrome/common/extensions/docs/static/whats_new.html +++ b/chrome/common/extensions/docs/static/whats_new.html @@ -7,6 +7,7 @@ made in recent releases. </p> <ul> + <li> <a href="#12">Google Chrome 12</a> </li> <li> <a href="#11">Google Chrome 11</a> </li> <li> <a href="#10">Google Chrome 10</a> </li> <li> <a href="#9">Google Chrome 9</a> </li> @@ -16,6 +17,38 @@ made in recent releases. </ul> +<h2 id="12"> Google Chrome 12 </h2> + +<h4> Additions to existing APIs </h4> + <ul> + <li> Two new <code>chrome.extension</code> + methods—<a href="extension.html#method-isAllowedFileSchemeAccess">isAllowedFileSchemeAccess()</a> and + <a href="extension.html#method-isAllowedIncognitoAccess">isAllowedIncognitoAccess()</a>—let you + determine whether your extension has increased access, + which the user specifies using the extensions management page + (<b>chrome://extensions</b>). + </li> + <li> The <a href="windows.html#method-create">chrome.windows.create()</a> + method can now take a <code>focused</code> value. + Previously, all new windows had the keyboard focus; + now you can create windows without interrupting the user's typing. + </li> + <li> If the manifest specifies "experimental" permission, + your extension can specify "panel" as the value of + the <code>type</code> field in + the <a href="windows.html#method-create">chrome.windows.create()</a> + method + or the <a href="windows.html#type-Window">Window</a> type. + </li> + <li> The <a href="cookies.html#event-onChanged">onChanged</a> + event of <code>chrome.cookies</code> + now has a <code>cause</code> parameter. </li> + <li> The <code>chrome.contextMenus</code> + <a href="contextMenus.html#method-create">create()</a> and + <a href="contextMenus.html#method-update">update()</a> + methods now let you specify a context value of "frame". + </ul> + <h2 id="11"> Google Chrome 11 </h2> <h4> Changes to existing APIs </h4> @@ -66,7 +99,7 @@ made in recent releases. <h4> Additions to existing APIs </h4> <ul> <li> The <a href="windows.html#method-create">chrome.windows.create()</a> - method now has a <code>tabId</code> parameter. + method now has a <code>tabId</code> field. You can use it to move a tab or panel into a new window. <p class="note"> <b>Note:</b> @@ -88,9 +121,6 @@ made in recent releases. <li> The <a href="manifest.html#homepage_url">homepage_url</a> field lets you specify the extension or app's homepage. </li> </ul> -</h4> - -<!-- <h4> New experimental APIs </h4> --> <h4> Additions to existing APIs </h4> <ul> @@ -143,18 +173,6 @@ No API or manifest changes worth noting. </li> </ul> -<!-- -<h4> New experimental APIs </h4> - <ul> - <li> a change </li> - </ul> - -<h4> Additions to existing APIs </h4> - <ul> - <li> a change </li> - </ul> ---> - <h2 id="6">Google Chrome 6</h2> @@ -168,14 +186,6 @@ No API or manifest changes worth noting. machine's idle state changes. </li> </ul> -<h4> New experimental APIs </h4> - <ul> - <li>The <a href="experimental.omnibox.html">omnibox API</a> allows you to - add functionality to the browser's address bar. </li> - <li>The <a href="experimental.infobars.html">infobars API</a> allows you - to add a UI panel across the top of a tab. </li> - </ul> - <h4> Additions to existing APIs </h4> <ul> <li>The <a |