summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
authorkathyw@google.com <kathyw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 16:23:33 +0000
committerkathyw@google.com <kathyw@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-01 16:23:33 +0000
commiteb69319dce6cce15d4339f3be8ccebd208938648 (patch)
tree2cba8a94a6503acd357987e9900282a6d459d2c9 /chrome/common
parentea7c4fb4adfef2d9d0d5ebc394b8428b8804dd9f (diff)
downloadchromium_src-eb69319dce6cce15d4339f3be8ccebd208938648.zip
chromium_src-eb69319dce6cce15d4339f3be8ccebd208938648.tar.gz
chromium_src-eb69319dce6cce15d4339f3be8ccebd208938648.tar.bz2
Move events info from dev.chromium.org to the dev doc.
Updated, added an example, and added more explanatory text. TBR=aa, rafaelw Review URL: http://codereview.chromium.org/183029 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25037 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rwxr-xr-xchrome/common/extensions/docs/events.html34
-rw-r--r--chrome/common/extensions/docs/static/events.html49
-rwxr-xr-xchrome/common/extensions/docs/template/api_template.html2
3 files changed, 84 insertions, 1 deletions
diff --git a/chrome/common/extensions/docs/events.html b/chrome/common/extensions/docs/events.html
new file mode 100755
index 0000000..ff45494
--- /dev/null
+++ b/chrome/common/extensions/docs/events.html
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<!-- This page is a placeholder for generated extensions api doc. Note:
+ 1) The <head> information in this page is significant, should be uniform
+ across api docs and should be edited only with knowledge of the
+ templating mechanism.
+ 2) The <body> tag *must* retain id="body"
+ 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a
+ browser, it will be re-generated from the template, json schema and
+ authored overview content.
+ 4) The <body>.innerHTML is also generated by an offline step so that this
+ page may easily be indexed by search engines.
+
+ TODO(rafaelw): Abstract this into a "pageshell" that becomes the single
+ version of page template shell and the "instance" pages (bookmarks.html,
+ etc...) can be generated with a build step.
+-->
+<!-- <html> must retain id="template -->
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <!-- <head> data is significant and loads the needed libraries and styles -->
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <title jscontent="getPageTitle()">pageTitle</title>
+ <link href="css/ApiRefStyles.css" rel="stylesheet" type="text/css">
+ <script type="text/javascript"
+ src="../../../third_party/jstemplate/jstemplate_compiled.js">
+ </script>
+ <script type="text/javascript" src="js/api_page_generator.js"></script>
+ <script type="text/javascript" src="js/bootstrap.js"></script>
+ </head>
+ <!-- <body> content is completely generated. Do not edit, as it will be
+ and rewritten. -->
+ <body>
+ </body>
+</html>
diff --git a/chrome/common/extensions/docs/static/events.html b/chrome/common/extensions/docs/static/events.html
new file mode 100644
index 0000000..bb9757f
--- /dev/null
+++ b/chrome/common/extensions/docs/static/events.html
@@ -0,0 +1,49 @@
+<p>
+An <code>Event</code> is an object
+that allows you to be notified
+when something interesting happens.
+Here's an example of using the
+<code>chrome.tabs.onCreated</code> event
+to be notified whenever there's a new tab:
+</p>
+
+<pre>
+chrome.tabs.onCreated.<b>addListener(function(</b>tab<b>) {</b>
+ appendToLog('tabs.onCreated --'
+ + ' window: ' + tab.windowId
+ + ' tab: ' + tab.id
+ + ' index: ' + tab.index
+ + ' url: ' + tab.url);
+<b>});</b>
+</pre>
+
+<p>
+As the example shows,
+you register for notification using <code>addListener()</code>.
+The argument to <code>addListener()</code>
+is always a function that you define to handle the event,
+but the parameters to the function depend on
+which event you're handling.
+Checking the documentation for
+<a href="tabs.html#event-onCreated"><code>chrome.tabs.onCreated</code></a>,
+you can see that the function has a single parameter:
+a <a href="tabs.html#type-Tab">Tab</a> object
+that has details about the newly created tab.
+</p>
+
+<h2>
+Methods
+</h2>
+
+<p>
+You can invoke the following methods on any <code>Event</code> object:
+</p>
+
+<pre>
+void addListener(function callback(...))
+void removeListener(function callback(...))
+bool hasListener(function callback(...))
+</pre>
+
+<p class="comment">
+[PENDING: explain removeListener and hasListener]
diff --git a/chrome/common/extensions/docs/template/api_template.html b/chrome/common/extensions/docs/template/api_template.html
index 69db03c..3b8d731 100755
--- a/chrome/common/extensions/docs/template/api_template.html
+++ b/chrome/common/extensions/docs/template/api_template.html
@@ -35,7 +35,7 @@
<li><a href="pageActions.html">Page Actions</a></li>
<li><a href="background_pages.html">Background Pages</a></li>
<li><a href="content_scripts.html">Content Scripts</a></li>
- <li>Events</li>
+ <li><a href="events.html">Events</a></li>
<li><a href="tabs.html">Tabs</a></li>
<li><a href="windows.html">Windows</a></li>
<li><a href="bookmarks.html">Bookmarks</a></li>