Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2351)

Unified Diff: chrome/common/extensions/docs/extension.html

Issue 9965005: Deprecate chrome.extension.sendRequest in favor of sendMessage, with a safer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/common/extensions/api/tabs.json ('k') | chrome/common/extensions/docs/samples.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/common/extensions/docs/extension.html
diff --git a/chrome/common/extensions/docs/extension.html b/chrome/common/extensions/docs/extension.html
index ffa83c060457106ac89a7abeecd12b49e49f1640..05ce5b6faed65e40b1cee6c9222470366c4b7aac 100644
--- a/chrome/common/extensions/docs/extension.html
+++ b/chrome/common/extensions/docs/extension.html
@@ -225,6 +225,8 @@
</li><li>
<a href="#method-isAllowedIncognitoAccess">isAllowedIncognitoAccess</a>
</li><li>
+ <a href="#method-sendMessage">sendMessage</a>
+ </li><li>
<a href="#method-sendRequest">sendRequest</a>
</li><li>
<a href="#method-setUpdateUrlData">setUpdateUrlData</a>
@@ -239,6 +241,10 @@
</li><li>
<a href="#event-onConnectExternal">onConnectExternal</a>
</li><li>
+ <a href="#event-onMessage">onMessage</a>
+ </li><li>
+ <a href="#event-onMessageExternal">onMessageExternal</a>
+ </li><li>
<a href="#event-onRequest">onRequest</a>
</li><li>
<a href="#event-onRequestExternal">onRequestExternal</a>
@@ -959,6 +965,171 @@ For details, see
</p>
</div> <!-- /description -->
</div><div class="apiItem">
+ <a name="method-sendMessage"></a> <!-- method-anchor -->
+ <h4>sendMessage</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span>chrome.extension.sendMessage</span>(<span class="optional"><span>string</span>
+ <var><span>extensionId</span></var></span><span class="null"><span>, </span><span>any</span>
+ <var><span>message</span></var></span><span class="optional"><span>, </span><span>function</span>
+ <var><span>responseCallback</span></var></span>)</div>
+ <div class="description">
+ <p>Sends a single message to other listeners within the extension. Similar to chrome.extension.connect, but only sends a single message with an optional response. The <a href="extension.html#event-onMessage">chrome.extension.onMessage</a> event is fired in each page of the extension.</p>
+ <!-- PARAMETERS -->
+ <h4>Parameters</h4>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>extensionId</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>string</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>The extension ID of the extension you want to connect to. If omitted, default is your own extension.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>message</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>any</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>responseCallback</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>function</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ <dd>
+ <div>
+ <h5>Parameters</h5>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>response</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>any</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>The JSON response object sent by the handler of the message. If an error occurs while connecting to the extension, the callback will be called with no arguments and <a href="extension.html#property-lastError">chrome.extension.lastError</a> will be set to the error message.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </div>
+ </dd>
+ </div>
+ </div>
+ </dl>
+ <!-- RETURNS -->
+ <dl>
+ </dl>
+ <!-- CALLBACK -->
+ <div>
+ <div>
+ <h4>Callback function</h4>
+ <p>
+ If you specify the <em>callback</em> parameter, it should
+ specify a function that looks like this:
+ </p>
+ <!-- Note: intentionally longer 80 columns -->
+ <pre>function(<span>any response</span>) <span class="subdued">{...}</span>;</pre>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <var>response</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>any</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>The JSON response object sent by the handler of the message. If an error occurs while connecting to the extension, the callback will be called with no arguments and <a href="extension.html#property-lastError">chrome.extension.lastError</a> will be set to the error message.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </div>
+ </div>
+ <!-- MIN_VERSION -->
+ </div> <!-- /description -->
+ </div><div class="apiItem">
<a name="method-sendRequest"></a> <!-- method-anchor -->
<h4>sendRequest</h4>
<div class="summary">
@@ -968,7 +1139,7 @@ For details, see
<var><span>request</span></var></span><span class="optional"><span>, </span><span>function</span>
<var><span>responseCallback</span></var></span>)</div>
<div class="description">
- <p>Sends a single request to other listeners within the extension. Similar to chrome.extension.connect, but only sends a single request with an optional response. The <a href="extension.html#event-onRequest">chrome.extension.onRequest</a> event is fired in each page of the extension.</p>
+ <p>Deprecated: Please use sendMessage.</p>
<!-- PARAMETERS -->
<h4>Parameters</h4>
<dl>
@@ -1268,6 +1439,300 @@ For details, see
</dl>
</div> <!-- /description -->
</div><div class="apiItem">
+ <a name="event-onMessage"></a>
+ <h4>onMessage</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span class="subdued">chrome.extension.</span><span>onMessage</span><span class="subdued">.addListener</span>(function(<span>object details</span>) <span class="subdued">{...}</span><span></span>);
+ </div>
+ <div class="description">
+ <p>Fired when a message is sent from either an extension process or a content script.</p>
+ <!-- LISTENER PARAMETERS -->
+ <div>
+ <h4>Listener 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>message</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>any</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>The message sent by the calling script.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>sender</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <a href="extension.html#type-MessageSender">MessageSender</a>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>sendResponse</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>function</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one <code>onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code>sendResponse</code> is called).</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </dd>
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </div>
+ <!-- EXTRA PARAMETERS -->
+ <!-- LISTENER RETURN VALUE -->
+ <h4>Listener returns</h4>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>boolean</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Return true from the event listener if you wish to call <code>sendResponse</code> after the event listener returns.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </div> <!-- /description -->
+ </div><div class="apiItem">
+ <a name="event-onMessageExternal"></a>
+ <h4>onMessageExternal</h4>
+ <div class="summary">
+ <!-- Note: intentionally longer 80 columns -->
+ <span class="subdued">chrome.extension.</span><span>onMessageExternal</span><span class="subdued">.addListener</span>(function(<span>object details</span>) <span class="subdued">{...}</span><span></span>);
+ </div>
+ <div class="description">
+ <p>Fired when a message is sent from another extension.</p>
+ <!-- LISTENER PARAMETERS -->
+ <div>
+ <h4>Listener 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>message</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>any</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>The message sent by the calling script.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>sender</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <a href="extension.html#type-MessageSender">MessageSender</a>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd class="todo">
+ Undocumented.
+ </dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div><div>
+ <div>
+ <dt>
+ <var>sendResponse</var>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span id="typeTemplate">
+ <span>
+ <span>function</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Function to call (at most once) when you have a response. The argument should be any JSON-ifiable object. If you have more than one <code>onMessage</code> listener in the same document, then only one may send a response. This function becomes invalid when the event listener returns, unless you return true from the event listener to indicate you wish to send a response asynchronously (this will keep the message channel open to the other end until <code>sendResponse</code> is called).</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </dd>
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </div>
+ <!-- EXTRA PARAMETERS -->
+ <!-- LISTENER RETURN VALUE -->
+ <h4>Listener returns</h4>
+ <dl>
+ <div>
+ <div>
+ <dt>
+ <em>
+ <!-- TYPE -->
+ <div style="display:inline">
+ (
+ <span class="optional">optional</span>
+ <span id="typeTemplate">
+ <span>
+ <span>boolean</span>
+ </span>
+ </span>
+ )
+ </div>
+ </em>
+ </dt>
+ <dd>Return true from the event listener if you wish to call <code>sendResponse</code> after the event listener returns.</dd>
+ <!-- OBJECT PROPERTIES -->
+ <!-- OBJECT METHODS -->
+ <!-- OBJECT EVENT FIELDS -->
+ <!-- FUNCTION PARAMETERS -->
+ </div>
+ </div>
+ </dl>
+ </div> <!-- /description -->
+ </div><div class="apiItem">
<a name="event-onRequest"></a>
<h4>onRequest</h4>
<div class="summary">
@@ -1275,7 +1740,7 @@ For details, see
<span class="subdued">chrome.extension.</span><span>onRequest</span><span class="subdued">.addListener</span>(function(<span>any request, MessageSender sender, function sendResponse</span>) <span class="subdued">{...}</span><span></span>);
</div>
<div class="description">
- <p>Fired when a request is sent from either an extension process or a content script.</p>
+ <p>Deprecated: please use onMessage.</p>
<!-- LISTENER PARAMETERS -->
<div>
<h4>Listener parameters</h4>
@@ -1367,7 +1832,7 @@ For details, see
<span class="subdued">chrome.extension.</span><span>onRequestExternal</span><span class="subdued">.addListener</span>(function(<span>any request, MessageSender sender, function sendResponse</span>) <span class="subdued">{...}</span><span></span>);
</div>
<div class="description">
- <p>Fired when a request is sent from another extension.</p>
+ <p>Deprecated: please use onMessageExternal.</p>
<!-- LISTENER PARAMETERS -->
<div>
<h4>Listener parameters</h4>
« no previous file with comments | « chrome/common/extensions/api/tabs.json ('k') | chrome/common/extensions/docs/samples.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698