Index: chrome/common/extensions/docs/extensions/experimental.commands.html |
diff --git a/chrome/common/extensions/docs/extensions/pageCapture.html b/chrome/common/extensions/docs/extensions/experimental.commands.html |
similarity index 73% |
copy from chrome/common/extensions/docs/extensions/pageCapture.html |
copy to chrome/common/extensions/docs/extensions/experimental.commands.html |
index 66f432674beb2aa863988234653d36e28ea2e99f..5206d9f0992f55ed72658c0a62b56a89d53da8fd 100644 |
--- a/chrome/common/extensions/docs/extensions/pageCapture.html |
+++ b/chrome/common/extensions/docs/extensions/experimental.commands.html |
@@ -17,7 +17,7 @@ |
<script type="text/javascript" src="../js/api_page_generator.js"></script> |
<script type="text/javascript" src="../js/bootstrap.js"></script> |
<script type="text/javascript" src="../js/sidebar.js"></script> |
- <meta name="description" content="Documentation for the chrome.pageCapture module, which is part of the Google Chrome extension APIs."><title>chrome.pageCapture - Google Chrome Extensions - Google Code</title></head> |
+ <meta name="description" content="Documentation for the chrome.experimental.commands module, which is part of the Google Chrome extension APIs."><title>Commands - Google Chrome Extensions - Google Code</title></head> |
<body doc-family="extensions"> <link href="../css/ApiRefStyles.css" rel="stylesheet" type="text/css"> |
<link href="../css/prettify.css" rel="stylesheet" type="text/css"> |
<link href="../css/shared.css" rel="stylesheet" type="text/css"> |
@@ -188,7 +188,7 @@ |
</script> |
<div class="g-unit" id="gc-pagecontent"> |
<div id="pageTitle"> |
- <h1 class="page_title">chrome.pageCapture</h1> |
+ <h1 class="page_title">Commands</h1> |
</div> |
<!-- TABLE OF CONTENTS --> |
<div id="toc"> |
@@ -198,15 +198,19 @@ |
<a href="#manifest">Manifest</a> |
<ol> |
</ol> |
+ </li><li> |
+ <a href="#usage">Usage</a> |
+ <ol> |
+ </ol> |
</li> |
<li> |
- <a href="#apiReference">API reference: chrome.pageCapture</a> |
+ <a href="#apiReference">API reference: chrome.experimental.commands</a> |
<ol> |
<li> |
- <a href="#global-methods">Methods</a> |
+ <a href="#global-events">Events</a> |
<ol> |
<li> |
- <a href="#method-saveAsMHTML">saveAsMHTML</a> |
+ <a href="#event-onCommand">onCommand</a> |
</li> |
</ol> |
</li> |
@@ -217,169 +221,124 @@ |
<!-- /TABLE OF CONTENTS --> |
<!-- Standard content lead-in for experimental API pages --> |
<!-- STATIC CONTENT PLACEHOLDER --> |
- <div id="static"><!-- BEGIN AUTHORED CONTENT --> |
-<p> |
-The pageCapture API allows you to save a tab as MHTML. |
-</p> |
+ <div id="static"><div id="pageData-name" class="pageData">Commands</div> |
+<!-- BEGIN AUTHORED CONTENT --> |
<p> |
-MHTML is a <a href="http://tools.ietf.org/html/rfc2557">standard format</a> |
-supported by most browsers. It encapsulates in a single file a page and all |
-its resources (CSS files, images..). |
+The commands API allows you to add keyboard shortcuts that trigger actions in |
+your extension. An action can be opening the browser action or page action popup |
+or sending a command to the extension. |
</p> |
+<h2 id="manifest">Manifest</h2> |
<p> |
-Note that for security reasons a MHTML file can only be loaded from the file |
-system and that it can only be loaded in the main frame. |
+In addition to the "experimental" permission you must declare the "commands" |
+permission in your extension's manifest to use this API and set manifest_version |
+to (at least) 2. |
</p> |
-<h2 id="manifest">Manifest</h2> |
-<p>You must declare the "pageCapture" permission |
-in the <a href="manifest.html">extension manifest</a> |
-to use the history API. |
-For example:</p> |
<pre>{ |
"name": "My extension", |
... |
- <b>"permissions": [ |
- "pageCapture" |
+<b> "permissions": [ |
+ "experimental", |
+ "commands", |
]</b>, |
... |
}</pre> |
+<h2 id="usage">Usage</h2> |
+<p>The commands API allows you to define specific commands, and bind them to a |
+default key combination. Each command your extension accepts must be listed in |
+the manifest as an attribute of the 'commands' manifest key. Note: Combinations |
+that involve Ctrl+Alt are not permitted in order to avoid conflicts with the |
+AltGr key.</p> |
+<pre>{ |
+ "name": "My extension", |
+ ... |
+<b> "commands": { |
+ "toggle-feature-foo": { |
+ "suggested_key": { |
+ "default": "Ctrl+Shift+Y", |
+ "mac": "Command+Shift+Y" |
+ }, |
+ "description": "Toggle feature foo" |
+ }, |
+ "_execute_browser_action": { |
+ "suggested_key": { |
+ "windows": "Ctrl+Shift+Y", |
+ "mac": "Command+Shift+Y", |
+ "chromeos": "Ctrl+Shift+U", |
+ "linux": "Ctrl+Shift+J" |
+ } |
+ }, |
+ "_execute_page_action": { |
+ "suggested_key": { |
+ "default": "Ctrl+E" |
+ "windows": "Alt+P", |
+ "mac": "Option+P", |
+ } |
+ } |
+ }</b>, |
+ ... |
+}</pre> |
+<p>In your background page, you can bind a handler to each of the commands |
+defined in the manifest (except for '_execute_browser_action' and |
+'_execute_page_action') via onCommand.addListener. For example:</p> |
+<pre>chrome.experimental.commands.onCommand.addListener(function(command) { |
+ console.log('Command:', command); |
+}); |
+</pre> |
+<p>The '_execute_browser_action' and '_execute_page_action' commands are |
+reserved for the action of opening your extension's popups. They won't normally |
+generate events that you can handle. If you need to take action based on your |
+popup opening, consider listening for an 'onDomReady' event inside your popup's |
+code. |
+</p> |
<!-- END AUTHORED CONTENT --> |
</div> |
<!-- API PAGE --> |
<div class="apiPage"> |
<a name="apiReference"></a> |
- <h2>API reference: chrome.pageCapture</h2> |
+ <h2>API reference: chrome.experimental.commands</h2> |
<!-- PROPERTIES --> |
<!-- /apiGroup --> |
<!-- METHODS --> |
- <div id="methodsTemplate" class="apiGroup"> |
- <a name="global-methods"></a> |
- <h3>Methods</h3> |
- <!-- iterates over all functions --> |
+ <!-- /apiGroup --> |
+ <!-- EVENTS --> |
+ <div id="eventsTemplate" class="apiGroup"> |
+ <a name="global-events"></a> |
+ <h3>Events</h3> |
+ <!-- iterates over all events --> |
<div class="apiItem"> |
- <a name="method-saveAsMHTML"></a> <!-- method-anchor --> |
- <h4>saveAsMHTML</h4> |
+ <a name="event-onCommand"></a> |
+ <h4>onCommand</h4> |
<div class="summary"> |
- <!-- Note: intentionally longer 80 columns --> |
- <span>chrome.pageCapture.saveAsMHTML</span>(<span class="null"><span>object</span> |
- <var><span>details</span></var></span><span class="null"><span>, </span><span>function</span> |
- <var><span>callback</span></var></span>)</div> |
- <div class="description"> |
- <p>Saves the content of the tab with given id as MHTML.</p> |
- <!-- PARAMETERS --> |
- <h4>Parameters</h4> |
- <dl> |
- <div> |
- <div> |
- <dt> |
- <var>details</var> |
- <em> |
- <!-- TYPE --> |
- <div style="display:inline"> |
- ( |
- <span id="typeTemplate"> |
- <span> |
- <span>object</span> |
- </span> |
- </span> |
- ) |
- </div> |
- </em> |
- </dt> |
- <dd class="todo"> |
- Undocumented. |
- </dd> |
- <!-- OBJECT PROPERTIES --> |
- <dd> |
- <dl> |
- <div> |
- <div> |
- <dt> |
- <var>tabId</var> |
- <em> |
- <!-- TYPE --> |
- <div style="display:inline"> |
- ( |
- <span id="typeTemplate"> |
- <span> |
- <span>integer</span> |
- </span> |
- </span> |
- ) |
- </div> |
- </em> |
- </dt> |
- <dd>The id of the tab to save as MHTML.</dd> |
- <!-- OBJECT PROPERTIES --> |
- <!-- OBJECT METHODS --> |
- <!-- OBJECT EVENT FIELDS --> |
- <!-- FUNCTION PARAMETERS --> |
- </div> |
+ <!-- Note: intentionally longer 80 columns --> |
+ <span class="subdued">chrome.experimental.commands.</span><span>onCommand</span><span class="subdued">.addListener</span>(function(<span>string command</span>) <span class="subdued">{...}</span><span></span>); |
</div> |
- </dl> |
- </dd> |
- <!-- OBJECT METHODS --> |
- <!-- OBJECT EVENT FIELDS --> |
- <!-- FUNCTION PARAMETERS --> |
- </div> |
- </div><div> |
- <div> |
- <dt> |
- <var>callback</var> |
- <em> |
- <!-- TYPE --> |
- <div style="display:inline"> |
- ( |
- <span id="typeTemplate"> |
- <span> |
- <span>function</span> |
- </span> |
- </span> |
- ) |
- </div> |
- </em> |
- </dt> |
- <dd>Called when the MHTML has been generated.</dd> |
- <!-- OBJECT PROPERTIES --> |
- <!-- OBJECT METHODS --> |
- <!-- OBJECT EVENT FIELDS --> |
- <!-- FUNCTION PARAMETERS --> |
- </div> |
- </div> |
- </dl> |
- <!-- RETURNS --> |
- <dl> |
- </dl> |
- <!-- CALLBACK --> |
+ <div class="description"> |
+ <p>Fired when a registered command is activated using a keyboard shortcut.</p> |
+ <!-- LISTENER PARAMETERS --> |
<div> |
- <div> |
- <h4>Callback function</h4> |
- <p> |
- The <em>callback</em> parameter should specify a function |
- that looks like this: |
- </p> |
- <!-- Note: intentionally longer 80 columns --> |
- <pre>function(<span>binary mhtmlData</span>) <span class="subdued">{...}</span>;</pre> |
+ <h4>Listener parameters</h4> |
<dl> |
<div> |
<div> |
<dt> |
- <var>mhtmlData</var> |
+ <var>command</var> |
<em> |
<!-- TYPE --> |
<div style="display:inline"> |
( |
- <span class="optional">optional</span> |
<span id="typeTemplate"> |
<span> |
- <span>binary</span> |
+ <span>string</span> |
</span> |
</span> |
) |
</div> |
</em> |
</dt> |
- <dd>The MHTML data as a Blob.</dd> |
+ <dd class="todo"> |
+ Undocumented. |
+ </dd> |
<!-- OBJECT PROPERTIES --> |
<!-- OBJECT METHODS --> |
<!-- OBJECT EVENT FIELDS --> |
@@ -387,14 +346,15 @@ For example:</p> |
</div> |
</div> |
</dl> |
- </div> |
</div> |
- <!-- MIN_VERSION --> |
+ <!-- EXTRA PARAMETERS --> |
+ <!-- LISTENER RETURN VALUE --> |
+ <dl> |
+ </dl> |
</div> <!-- /description --> |
- </div> <!-- /apiItem --> |
- </div> <!-- /apiGroup --> |
- <!-- EVENTS --> |
- <!-- /apiGroup --> |
+ <!-- /description --> |
+ </div> <!-- /apiItem --> |
+ </div> <!-- /apiGroup --> |
<!-- TYPES --> |
<!-- /apiGroup --> |
</div> <!-- /apiPage --> |