summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkathyw@google.com <kathyw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-24 20:33:29 +0000
committerkathyw@google.com <kathyw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-24 20:33:29 +0000
commit3462401ddb4fab9efbf63d528026473ca07e8828 (patch)
treeb69e89085a7d127b39266964036af8a6cf6377d1
parent95e0fc47e4a0a5dcc7899118c3f2ea49df5a4bbe (diff)
downloadchromium_src-3462401ddb4fab9efbf63d528026473ca07e8828.zip
chromium_src-3462401ddb4fab9efbf63d528026473ca07e8828.tar.gz
chromium_src-3462401ddb4fab9efbf63d528026473ca07e8828.tar.bz2
Another draft of the overview, now with figures. Made related changes to the background pages and content scripts pages.
Review URL: http://codereview.chromium.org/225023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27121 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xchrome/common/extensions/docs/background_pages.html14
-rwxr-xr-xchrome/common/extensions/docs/content_scripts.html13
-rw-r--r--chrome/common/extensions/docs/images/arch-1.gifbin0 -> 3513 bytes
-rw-r--r--chrome/common/extensions/docs/images/arch-2.gifbin0 -> 5244 bytes
-rw-r--r--chrome/common/extensions/docs/images/arch-3.gifbin0 -> 6433 bytes
-rw-r--r--chrome/common/extensions/docs/images/arch-cs.gifbin0 -> 6295 bytes
-rwxr-xr-xchrome/common/extensions/docs/overview.html277
-rwxr-xr-xchrome/common/extensions/docs/static/background_pages.html14
-rw-r--r--chrome/common/extensions/docs/static/content_scripts.html13
-rwxr-xr-xchrome/common/extensions/docs/static/overview.html276
10 files changed, 243 insertions, 364 deletions
diff --git a/chrome/common/extensions/docs/background_pages.html b/chrome/common/extensions/docs/background_pages.html
index 84101a3..e47f59c 100755
--- a/chrome/common/extensions/docs/background_pages.html
+++ b/chrome/common/extensions/docs/background_pages.html
@@ -224,7 +224,19 @@ The background page is similar to a toolstrip,
in that it is an HTML page that runs in the extension process.
The difference is that the background page exists
for the lifetime of your extension,
-and only one instance of it at a time is active.</p>
+and only one instance of it at a time is active.
+</p>
+
+<p>
+In a typical extension with a background page,
+the UI —
+toolstrips, page actions, and so on —
+is implemented with dumb views.
+When the view needs some state,
+it requests the state from the background page.
+When the background page notices a state change,
+the background page tells the views to update.
+</p>
<h2 id="manifest">Manifest</h2>
diff --git a/chrome/common/extensions/docs/content_scripts.html b/chrome/common/extensions/docs/content_scripts.html
index 2972f75..59abed9 100755
--- a/chrome/common/extensions/docs/content_scripts.html
+++ b/chrome/common/extensions/docs/content_scripts.html
@@ -225,7 +225,7 @@
<div id="pageData-showTOC" class="pageData">true</div>
<p>
-Content Scripts are JavaScript files that run in the context of web pages.
+Content scripts are JavaScript files that run in the context of web pages.
By using the standard
<a href="http://www.w3.org/TR/DOM-Level-2-HTML/">Document
Object Model</a> (DOM),
@@ -245,20 +245,23 @@ Here are some examples of what content scripts can do:
<p>
However, content scripts have some limitations.
-They <b>cannot use</b>:
+They <b>cannot</b>:
</p>
<ul>
<li>
- chrome.* APIs
+ Use chrome.* APIs
(except for parts of
<a href="extension.html"><code>chrome.extension</code></a>)
</li>
<li>
- variables or functions defined by their extension's pages
+ Use variables or functions defined by their extension's pages
</li>
<li>
- variables or functions defined by web pages or by other content scripts
+ Use variables or functions defined by web pages or by other content scripts
+ </li>
+ <li>
+ Make cross-site XMLHttpRequests
</li>
</ul>
diff --git a/chrome/common/extensions/docs/images/arch-1.gif b/chrome/common/extensions/docs/images/arch-1.gif
new file mode 100644
index 0000000..d67519b
--- /dev/null
+++ b/chrome/common/extensions/docs/images/arch-1.gif
Binary files differ
diff --git a/chrome/common/extensions/docs/images/arch-2.gif b/chrome/common/extensions/docs/images/arch-2.gif
new file mode 100644
index 0000000..0a2b406
--- /dev/null
+++ b/chrome/common/extensions/docs/images/arch-2.gif
Binary files differ
diff --git a/chrome/common/extensions/docs/images/arch-3.gif b/chrome/common/extensions/docs/images/arch-3.gif
new file mode 100644
index 0000000..69816ed
--- /dev/null
+++ b/chrome/common/extensions/docs/images/arch-3.gif
Binary files differ
diff --git a/chrome/common/extensions/docs/images/arch-cs.gif b/chrome/common/extensions/docs/images/arch-cs.gif
new file mode 100644
index 0000000..26d0633
--- /dev/null
+++ b/chrome/common/extensions/docs/images/arch-cs.gif
Binary files differ
diff --git a/chrome/common/extensions/docs/overview.html b/chrome/common/extensions/docs/overview.html
index d41e749..e7c1d61 100755
--- a/chrome/common/extensions/docs/overview.html
+++ b/chrome/common/extensions/docs/overview.html
@@ -167,7 +167,7 @@
</li>
</ol>
</li><li jsinstance="3">
- <a href="#H2-7">Communication </a>
+ <a href="#H2-7">Communication between pages </a>
<ol>
<li jsinstance="*0" style="display: none; ">
<a>h3Name</a>
@@ -229,14 +229,12 @@
<div id="pageData-showTOC" class="pageData">true</div>
<p>
-Please read this page;
-it has vital information about the extension architecture.
-If you get bored or restless,
-take a break!
-We suggest bouncing between this page
-and tutorials
-such as <a href="getstarted.html">Getting Started</a>
-and <a href="tut_debugging.html">Debugging</a>.
+Read this page!
+It has vital information about the extension architecture.
+Once you've finished this page
+and the
+<a href="getstarted.html">Getting Started</a> tutorial,
+you'll be all set to start writing extensions.
</p>
@@ -246,30 +244,34 @@ and <a href="tut_debugging.html">Debugging</a>.
An extension is a zipped bundle of files —
HTML, CSS, JavaScript, images, and anything else you need —
that adds functionality to the Google Chrome browser.
-Because an extension is just a special kind of web page,
-it can use all the APIs
+Extensions are essentially web pages,
+and they can use all the APIs
that the browser provides
-to web pages and apps,
-from XMLHttpRequest to JSON to localStorage.
+to web pages,
+from XMLHttpRequest to JSON to HTML5 local storage.
</p>
<p>
-Extensions can add UI to Google Chrome,
+Many extensions add UI to Google Chrome,
in the form of
<a href="toolstrip.html">toolstrips</a> (toolbar additions)
-and <a href="pageActions.html">page actions</a>
+or <a href="pageActions.html">page actions</a>
(clickable badges in the address bar).
Extensions can also interact programmatically
with browser features such as
<a href="bookmarks.html">bookmarks</a>
and <a href="tabs.html">tabs</a>.
+To interact with web pages or servers,
+extensions can use
+<a href="content_scripts.html">content scripts</a> or
+<a href="xhr.html">cross-origin XMLHttpRequests</a>.
</p>
<p>
-To find a complete list of extension features,
+See the <a href="devguide.html">Developer's Guide</a>
+for a complete list of extension features,
with implementation details
-for each one,
-see the <a href="devguide.html">Developer's Guide</a>.
+for each one.
</p>
@@ -283,14 +285,15 @@ Each extension has the following files:
<li>A <b>manifest file</b></li>
<li>One or more <b>HTML files</b> (unless the extension is a theme)</li>
<li><em>Optional:</em> One or more <b>JavaScript files</b></li>
- <li><em>Optional:</em> Any other files your extension needs — for example, image files</li>
+ <li><em>Optional:</em> Any other files your extension needs —
+ for example, image files</li>
</ul>
<p>
While you're working on your extension,
you put all these files into a single folder.
When you distribute your extension,
-the contents of the folder are packaged into a special zipfile
+the contents of the folder are packaged into a special ZIP file
that has a <code>.crx</code> suffix,
as described in <a href="packaging.html">Packaging</a>.
</p>
@@ -309,7 +312,7 @@ a file named <code>myimage.png</code>
that's in a subfolder named <code>images</code>.
</p>
-<pre>&lt;img <b>src="images/myimage.png"</b> style="width:auto; height:auto"&gt;
+<pre>&lt;img <b>src="images/myimage.png"</b>&gt;
</pre>
<p>
@@ -331,69 +334,10 @@ under the extension's top folder;
it's the same as the relative URL.
</p>
-<p>
-For example, assume your extension has
-the ID <b>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</b>
-and the files shown in the following figure:
-</p>
-
-<pre><span class="tbd">[PENDING: someday this will be a real figure]</span>
-toolstrip.html
-styles.css
-images:
- myimage.png
- ...
-other:
- more.html
- morestyles.css
- ...
-</pre>
-
-<p>
-Here's a table that shows the relative and absolute URLs of these files.
-Keep in mind that the relative URL is the same no matter where you're using it —
-the relative URL of <code>myimage.png</code> is
-<b>images/myimage.png</b>,
-no matter whether it's being used by
-<code>toolstrip.html</code> or <code>other/more.html</code>.
-</p>
-
-<table>
-<tbody><tr>
- <th> File </th>
- <th> Relative URL </th>
- <th> Absolute URL </th>
-</tr>
-<tr>
- <td> toolstrip.html </td>
- <td> toolstrip.html </td>
- <td> chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/toolstrip.html </td>
-</tr>
-<tr>
- <td> styles.css </td>
- <td> styles.css </td>
- <td> chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/styles.css </td>
-</tr>
-<tr>
- <td> myimage.png </td>
- <td> images/myimage.png </td>
- <td> chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/images/myimage.png </td>
-</tr>
-<tr>
- <td> more.html </td>
- <td> other/more.html </td>
- <td> chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/other/more.html </td>
-</tr>
-<tr>
- <td> morestyles.css </td>
- <td> other/morestyles.css </td>
- <td> chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/other/morestyles.css </td>
-</tr>
-</tbody></table>
-
-<p class="tbd">
-[PENDING: Mention/reflect/link to
-<a href="http://dev.chromium.org/developers/design-documents/extensions/i18n">internationalization</a>]
+<p class="comment">
+[PENDING: Should mention/reflect/link to
+<a href="http://dev.chromium.org/developers/design-documents/extensions/i18n">internationalization</a>
+when it's ready.]
</p>
@@ -425,65 +369,61 @@ For details, see
<h2 id="arch">Architecture</h2>
<p>
-The following pictures shows the web pages associated with a typical extension
-(in this case, a simple toolstrip).
-The first figure shows what an extension might look like
+Remember that extensions are essentially web pages.
+The following figure shows what
+a simple extension with a toolstrip
+might look like
when there's a single browser window.
+The toolstrip (T1) is at the bottom of the window.
+The HTML and JavaScript code for T1
+is in a web page
+(<code>toolstrip.html</code>).
</p>
-<p class="tbd"> [PENDING: image goes here] </p>
+<img src="images/arch-1.gif">
<p>
-The next figure shows that all the code in the extension's main HTML file
-is duplicated each time you create a new window.
-In other words, each window has its own widgets for the extension,
-which means each window adds another web page for that extension.
+Each time the user creates a new window,
+the browser creates new toolstrips, page actions, and so on.
+Each new bit of UI gets its own web page,
+which means that toolstrips (for example)
+that are in different windows can have different states.
+In the following figure,
+the two toolstrips (T1 and T2)
+are associated with two separate web pages,
+both of which contain code from <code>toolstrip.html</code>.
+This means that although both toolstrips use the same code,
+one can be blue while the other is green.
</p>
-<p class="tbd"> [PENDING: image goes here] </p>
+<img src="images/arch-2.gif">
+
+
+<h3 id="background">The background page</h3>
<p>
-To more easily coordinate all these web pages and to avoid duplication,
-you should design your extension
-so that most of the code —
-especially the state of the extension —
-is in a <em>background page</em>,
-as shown in the following figure.
+If your extension's web pages need to communicate
+or otherwise share information —
+for example, if a browser event
+can affect more than just one window's toolstrip —
+the extension can use a background page.
+The following figure shows a background page
+(<code>background.html</code>)
+that controls
+the toolstrips in an extension.
</p>
-<p class="tbd"> [PENDING: image goes here] </p>
+<img src="images/arch-3.gif">
-
-<h3 id="background">The background page</h3>
<p>
-Any non-trivial extension can (and probably should)
-have a background page.
The background page is an invisible page
-where you put the main logic of the extension.
+where you can put the main logic of the extension.
The extension's other pages should have
only the code that's necessary
to show the state of the extension
and to get input from the user.</p>
<p>
-An extension's background page exists
-before any of the extension's other pages exist.
-It continues to exist as long as the browser is running
-and the extension is installed,
-even if other pages and windows go away.
-</p>
-
-<p>
-Your extension's UI —
-its toolstrips, page actions, and so on —
-should be dumb views.
-When the view needs some state,
-it should request it from the background page.
-When the background page notices some state change,
-it should update all the views.
-</p>
-
-<p>
For more information, see
<a href="background_pages.html">Background Pages</a>.
</p>
@@ -491,18 +431,31 @@ For more information, see
<h3 id="contentScripts">Content scripts</h3>
<p>
-If you want your extension to interact with web pages,
-you need a content script.
+If your extension needs to interact with web pages,
+then it needs a <em>content script</em>.
Content scripts are JavaScript files that run in the context of web pages.
-By using the standard Document Object Model (DOM),
-they can read details of the web pages the browser visits,
+Using the standard
+<a href="http://www.w3.org/TR/DOM-Level-2-HTML/">Document Object Model</a>
+(DOM),
+content scripts can read details of the web pages the browser visits,
and they can make changes to the pages.
</p>
+<p>
+In the following figure,
+the content script
+can read and modify
+the DOM for the web page displayed in Window 1.
+If the toolstrip's UI needs to change
+to reflect the web page's contents,
+the content script can request that change
+by sending a message to the parent extension.
+</p>
+
+<img src="images/arch-cs.gif">
+
<p class="comment">
-[PENDING: add an architectural figure here,
-showing the extension's pages, a web page, and the content script
-interacting with the web page. explain the figure.]
+[PENDING: Add overview of message passing.]
</p>
<p>
@@ -511,64 +464,36 @@ see <a href="content_scripts.html">Content Scripts</a>.
</p>
-<a name="H2-7"></a><h2>Communication </h2>
+<a name="H2-7"></a><h2>Communication between pages </h2>
<p>
-Two kinds of communication happen within an extension:
+The HTML pages within an extension often need to communicate.
+An example is when the background page tells
+UI pages (such as toolstrips)
+to update their appearance.
+Because all of an extension's pages
+execute in same process on the same thread,
+the pages can make direct function calls to each other.
</p>
-<ul>
- <li>
- Communication <b>between pages</b> in the extension.
- <br>
- For example, sometimes the background page
- needs to update all the UI pages
- to reflect a change in the extension's state.
- </li>
- <li>
- Communication <b>between content scripts and the extension</b>.
- <br>
- For example,
- <span class="tbd">[PENDING: typical use case goes here]</span>.
- See <a href="content_scripts.html">Content Scripts</a>
- for information about this type of communication.
- </li>
-</ul>
-
<p>
-Here are some keys to communication between an extension's pages:
+To find pages in the extension, use
+<a href="extension.html"><code>chrome.extension</code></a>
+methods such as
+<code>getViews()</code>,
+<code>getBackgroundPage()</code>,
+and <code>getToolstrips()</code>.
+Once a page has a reference to other pages within the extension,
+the first page can invoke functions on the other pages.
+It can even manipulate their DOMs.
</p>
-<ul>
- <li>
- All the extension's pages execute in same process,
- on the same thread.
- </li>
- <li>
- Extension pages can use
- <a href="extension.html"><code>chrome.extension</code></a>
- methods such as
- <code>getViews()</code>,
- <code>getBackgroundPage()</code>,
- and <code>getToolstrips()</code>
- to get access to the extension's pages.
- </li>
- <li>
- Once you have references to an extension's pages,
- you can manipulate the DOM for each page.
- </li>
- <li>
- You can also make direct function calls to the pages,
- as shown in the following example.
- </li>
-</ul>
-
<p>
Here's an example of
communication between toolstrips and the background page.
</p>
-<pre>//In background_page.html:
+<pre>//In background.html:
function updateUI(checked) {
var toolstrips = chrome.extension.getToolstrips();
for (var i in toolstrips) {
diff --git a/chrome/common/extensions/docs/static/background_pages.html b/chrome/common/extensions/docs/static/background_pages.html
index 426dbf7..78bf836 100755
--- a/chrome/common/extensions/docs/static/background_pages.html
+++ b/chrome/common/extensions/docs/static/background_pages.html
@@ -15,7 +15,19 @@ The background page is similar to a toolstrip,
in that it is an HTML page that runs in the extension process.
The difference is that the background page exists
for the lifetime of your extension,
-and only one instance of it at a time is active.</p>
+and only one instance of it at a time is active.
+</p>
+
+<p>
+In a typical extension with a background page,
+the UI &mdash;
+toolstrips, page actions, and so on &mdash;
+is implemented with dumb views.
+When the view needs some state,
+it requests the state from the background page.
+When the background page notices a state change,
+the background page tells the views to update.
+</p>
<h2 id="manifest">Manifest</h2>
diff --git a/chrome/common/extensions/docs/static/content_scripts.html b/chrome/common/extensions/docs/static/content_scripts.html
index dc5a9ba..bbbfeb3 100644
--- a/chrome/common/extensions/docs/static/content_scripts.html
+++ b/chrome/common/extensions/docs/static/content_scripts.html
@@ -2,7 +2,7 @@
<div id="pageData-showTOC" class="pageData">true</div>
<p>
-Content Scripts are JavaScript files that run in the context of web pages.
+Content scripts are JavaScript files that run in the context of web pages.
By using the standard
<a href="http://www.w3.org/TR/DOM-Level-2-HTML/">Document
Object Model</a> (DOM),
@@ -22,20 +22,23 @@ Here are some examples of what content scripts can do:
<p>
However, content scripts have some limitations.
-They <b>cannot use</b>:
+They <b>cannot</b>:
</p>
<ul>
<li>
- chrome.* APIs
+ Use chrome.* APIs
(except for parts of
<a href="extension.html"><code>chrome.extension</code></a>)
</li>
<li>
- variables or functions defined by their extension's pages
+ Use variables or functions defined by their extension's pages
</li>
<li>
- variables or functions defined by web pages or by other content scripts
+ Use variables or functions defined by web pages or by other content scripts
+ </li>
+ <li>
+ Make cross-site XMLHttpRequests
</li>
</ul>
diff --git a/chrome/common/extensions/docs/static/overview.html b/chrome/common/extensions/docs/static/overview.html
index f9b8741..7020deb 100755
--- a/chrome/common/extensions/docs/static/overview.html
+++ b/chrome/common/extensions/docs/static/overview.html
@@ -2,14 +2,12 @@
<div id="pageData-showTOC" class="pageData">true</div>
<p>
-Please read this page;
-it has vital information about the extension architecture.
-If you get bored or restless,
-take a break!
-We suggest bouncing between this page
-and tutorials
-such as <a href="getstarted.html">Getting Started</a>
-and <a href="tut_debugging.html">Debugging</a>.
+Read this page!
+It has vital information about the extension architecture.
+Once you've finished this page
+and the
+<a href="getstarted.html">Getting Started</a> tutorial,
+you'll be all set to start writing extensions.
</p>
@@ -19,30 +17,34 @@ and <a href="tut_debugging.html">Debugging</a>.
An extension is a zipped bundle of files &mdash;
HTML, CSS, JavaScript, images, and anything else you need &mdash;
that adds functionality to the Google Chrome browser.
-Because an extension is just a special kind of web page,
-it can use all the APIs
+Extensions are essentially web pages,
+and they can use all the APIs
that the browser provides
-to web pages and apps,
-from XMLHttpRequest to JSON to localStorage.
+to web pages,
+from XMLHttpRequest to JSON to HTML5 local storage.
</p>
<p>
-Extensions can add UI to Google Chrome,
+Many extensions add UI to Google Chrome,
in the form of
<a href="toolstrip.html">toolstrips</a> (toolbar additions)
-and <a href="pageActions.html">page actions</a>
+or <a href="pageActions.html">page actions</a>
(clickable badges in the address bar).
Extensions can also interact programmatically
with browser features such as
<a href="bookmarks.html">bookmarks</a>
and <a href="tabs.html">tabs</a>.
+To interact with web pages or servers,
+extensions can use
+<a href="content_scripts.html">content scripts</a> or
+<a href="xhr.html">cross-origin XMLHttpRequests</a>.
</p>
<p>
-To find a complete list of extension features,
+See the <a href="devguide.html">Developer's Guide</a>
+for a complete list of extension features,
with implementation details
-for each one,
-see the <a href="devguide.html">Developer's Guide</a>.
+for each one.
</p>
@@ -56,14 +58,15 @@ Each extension has the following files:
<li>A <b>manifest file</b></li>
<li>One or more <b>HTML files</b> (unless the extension is a theme)</li>
<li><em>Optional:</em> One or more <b>JavaScript files</b></li>
- <li><em>Optional:</em> Any other files your extension needs &mdash; for example, image files</li>
+ <li><em>Optional:</em> Any other files your extension needs &mdash;
+ for example, image files</li>
</ul>
<p>
While you're working on your extension,
you put all these files into a single folder.
When you distribute your extension,
-the contents of the folder are packaged into a special zipfile
+the contents of the folder are packaged into a special ZIP file
that has a <code>.crx</code> suffix,
as described in <a href="packaging.html">Packaging</a>.
</p>
@@ -83,7 +86,7 @@ that's in a subfolder named <code>images</code>.
</p>
<pre>
-&lt;img <b>src="images/myimage.png"</b> style="width:auto; height:auto">
+&lt;img <b>src="images/myimage.png"</b>>
</pre>
<p>
@@ -105,70 +108,10 @@ under the extension's top folder;
it's the same as the relative URL.
</p>
-<p>
-For example, assume your extension has
-the ID <b>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</b>
-and the files shown in the following figure:
-</p>
-
-<pre>
-<span class="tbd">[PENDING: someday this will be a real figure]</span>
-toolstrip.html
-styles.css
-images:
- myimage.png
- ...
-other:
- more.html
- morestyles.css
- ...
-</pre>
-
-<p>
-Here's a table that shows the relative and absolute URLs of these files.
-Keep in mind that the relative URL is the same no matter where you're using it &mdash;
-the relative URL of <code>myimage.png</code> is
-<b>images/myimage.png</b>,
-no matter whether it's being used by
-<code>toolstrip.html</code> or <code>other/more.html</code>.
-</p>
-
-<table>
-<tr>
- <th> File </th>
- <th> Relative URL </th>
- <th> Absolute URL </th>
-</tr>
-<tr>
- <td> toolstrip.html </td>
- <td> toolstrip.html </td>
- <td> chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/toolstrip.html </td>
-</tr>
-<tr>
- <td> styles.css </td>
- <td> styles.css </td>
- <td> chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/styles.css </td>
-</tr>
-<tr>
- <td> myimage.png </td>
- <td> images/myimage.png </td>
- <td> chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/images/myimage.png </td>
-</tr>
-<tr>
- <td> more.html </td>
- <td> other/more.html </td>
- <td> chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/other/more.html </td>
-</tr>
-<tr>
- <td> morestyles.css </td>
- <td> other/morestyles.css </td>
- <td> chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/other/morestyles.css </td>
-</tr>
-</table>
-
-<p class="tbd">
-[PENDING: Mention/reflect/link to
-<a href="http://dev.chromium.org/developers/design-documents/extensions/i18n">internationalization</a>]
+<p class="comment">
+[PENDING: Should mention/reflect/link to
+<a href="http://dev.chromium.org/developers/design-documents/extensions/i18n">internationalization</a>
+when it's ready.]
</p>
@@ -201,65 +144,61 @@ For details, see
<h2 id="arch">Architecture</h2>
<p>
-The following pictures shows the web pages associated with a typical extension
-(in this case, a simple toolstrip).
-The first figure shows what an extension might look like
+Remember that extensions are essentially web pages.
+The following figure shows what
+a simple extension with a toolstrip
+might look like
when there's a single browser window.
+The toolstrip (T1) is at the bottom of the window.
+The HTML and JavaScript code for T1
+is in a web page
+(<code>toolstrip.html</code>).
</p>
-<p class="tbd"> [PENDING: image goes here] </p>
+<img src="images/arch-1.gif">
<p>
-The next figure shows that all the code in the extension's main HTML file
-is duplicated each time you create a new window.
-In other words, each window has its own widgets for the extension,
-which means each window adds another web page for that extension.
+Each time the user creates a new window,
+the browser creates new toolstrips, page actions, and so on.
+Each new bit of UI gets its own web page,
+which means that toolstrips (for example)
+that are in different windows can have different states.
+In the following figure,
+the two toolstrips (T1 and T2)
+are associated with two separate web pages,
+both of which contain code from <code>toolstrip.html</code>.
+This means that although both toolstrips use the same code,
+one can be blue while the other is green.
</p>
-<p class="tbd"> [PENDING: image goes here] </p>
+<img src="images/arch-2.gif">
+
+
+<h3 id="background">The background page</h3>
<p>
-To more easily coordinate all these web pages and to avoid duplication,
-you should design your extension
-so that most of the code &mdash;
-especially the state of the extension &mdash;
-is in a <em>background page</em>,
-as shown in the following figure.
+If your extension's web pages need to communicate
+or otherwise share information &mdash;
+for example, if a browser event
+can affect more than just one window's toolstrip &mdash;
+the extension can use a background page.
+The following figure shows a background page
+(<code>background.html</code>)
+that controls
+the toolstrips in an extension.
</p>
-<p class="tbd"> [PENDING: image goes here] </p>
+<img src="images/arch-3.gif">
-
-<h3 id="background">The background page</h3>
<p>
-Any non-trivial extension can (and probably should)
-have a background page.
The background page is an invisible page
-where you put the main logic of the extension.
+where you can put the main logic of the extension.
The extension's other pages should have
only the code that's necessary
to show the state of the extension
and to get input from the user.</p>
<p>
-An extension's background page exists
-before any of the extension's other pages exist.
-It continues to exist as long as the browser is running
-and the extension is installed,
-even if other pages and windows go away.
-</p>
-
-<p>
-Your extension's UI &mdash;
-its toolstrips, page actions, and so on &mdash;
-should be dumb views.
-When the view needs some state,
-it should request it from the background page.
-When the background page notices some state change,
-it should update all the views.
-</p>
-
-<p>
For more information, see
<a href="background_pages.html">Background Pages</a>.
</p>
@@ -267,18 +206,31 @@ For more information, see
<h3 id="contentScripts">Content scripts</h3>
<p>
-If you want your extension to interact with web pages,
-you need a content script.
+If your extension needs to interact with web pages,
+then it needs a <em>content script</em>.
Content scripts are JavaScript files that run in the context of web pages.
-By using the standard Document Object Model (DOM),
-they can read details of the web pages the browser visits,
+Using the standard
+<a href="http://www.w3.org/TR/DOM-Level-2-HTML/">Document Object Model</a>
+(DOM),
+content scripts can read details of the web pages the browser visits,
and they can make changes to the pages.
</p>
+<p>
+In the following figure,
+the content script
+can read and modify
+the DOM for the web page displayed in Window 1.
+If the toolstrip's UI needs to change
+to reflect the web page's contents,
+the content script can request that change
+by sending a message to the parent extension.
+</p>
+
+<img src="images/arch-cs.gif">
+
<p class="comment">
-[PENDING: add an architectural figure here,
-showing the extension's pages, a web page, and the content script
-interacting with the web page. explain the figure.]
+[PENDING: Add overview of message passing.]
</p>
<p>
@@ -287,65 +239,37 @@ see <a href="content_scripts.html">Content Scripts</a>.
</p>
-<h2>Communication </h2>
+<h2>Communication between pages </h2>
<p>
-Two kinds of communication happen within an extension:
+The HTML pages within an extension often need to communicate.
+An example is when the background page tells
+UI pages (such as toolstrips)
+to update their appearance.
+Because all of an extension's pages
+execute in same process on the same thread,
+the pages can make direct function calls to each other.
</p>
-<ul>
- <li>
- Communication <b>between pages</b> in the extension.
- <br />
- For example, sometimes the background page
- needs to update all the UI pages
- to reflect a change in the extension's state.
- </li>
- <li>
- Communication <b>between content scripts and the extension</b>.
- <br />
- For example,
- <span class="tbd">[PENDING: typical use case goes here]</span>.
- See <a href="content_scripts.html">Content Scripts</a>
- for information about this type of communication.
- </li>
-</ul>
-
<p>
-Here are some keys to communication between an extension's pages:
+To find pages in the extension, use
+<a href="extension.html"><code>chrome.extension</code></a>
+methods such as
+<code>getViews()</code>,
+<code>getBackgroundPage()</code>,
+and <code>getToolstrips()</code>.
+Once a page has a reference to other pages within the extension,
+the first page can invoke functions on the other pages.
+It can even manipulate their DOMs.
</p>
-<ul>
- <li>
- All the extension's pages execute in same process,
- on the same thread.
- </li>
- <li>
- Extension pages can use
- <a href="extension.html"><code>chrome.extension</code></a>
- methods such as
- <code>getViews()</code>,
- <code>getBackgroundPage()</code>,
- and <code>getToolstrips()</code>
- to get access to the extension's pages.
- </li>
- <li>
- Once you have references to an extension's pages,
- you can manipulate the DOM for each page.
- </li>
- <li>
- You can also make direct function calls to the pages,
- as shown in the following example.
- </li>
-</ul>
-
<p>
Here's an example of
communication between toolstrips and the background page.
</p>
<pre>
-//In background_page.html:
+//In background.html:
function updateUI(checked) {
var toolstrips = chrome.extension.getToolstrips();
for (var i in toolstrips) {