diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-09 18:13:27 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-09 18:13:27 +0000 |
commit | ea4d0790da2db4aae00e07af25feffd7e3857377 (patch) | |
tree | 44af49f6bd1432124069d2bba095ac49f9fc2af3 /chrome/common | |
parent | 76624fdeda4c8409a6bfd8a5f48de00dbceb0760 (diff) | |
download | chromium_src-ea4d0790da2db4aae00e07af25feffd7e3857377.zip chromium_src-ea4d0790da2db4aae00e07af25feffd7e3857377.tar.gz chromium_src-ea4d0790da2db4aae00e07af25feffd7e3857377.tar.bz2 |
Implement chrome.extension.connectExternal and fix various API inconsistencies.
BUG=23583
BUG=17910
TEST=no
Review URL: http://codereview.chromium.org/262016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28565 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rwxr-xr-x | chrome/common/extensions/api/extension_api.json | 19 | ||||
-rwxr-xr-x | chrome/common/extensions/docs/extension.html | 197 | ||||
-rw-r--r-- | chrome/common/render_messages_internal.h | 5 |
3 files changed, 213 insertions, 8 deletions
diff --git a/chrome/common/extensions/api/extension_api.json b/chrome/common/extensions/api/extension_api.json index 4ad7e46..5fe4d22 100755 --- a/chrome/common/extensions/api/extension_api.json +++ b/chrome/common/extensions/api/extension_api.json @@ -11,7 +11,15 @@ "onDisconnect": {"type": "object"}, "onMessage": {"type": "object"}, "postMessage": {"type": "function"}, - "tab": {"$ref": "Tab", "optional": true, "description":"This property will <b>only</b> be present on ports passed to onConnect listeners when the connection was opened from a tab or content script."} + "sender": { + "type": "object", + "optional": true, + "description": "This property will <b>only</b> be present on ports passed to onConnect/onConnectExternal listeners.", + "properties": { + "tab": {"$ref": "Tab", "optional": true, "description":"This property will <b>only</b> be present when the connection was opened from a tab or content script."}, + "id": {"type": "string", "description": "The extension ID of the extension that opened the connection."} + } + } } } ], @@ -31,6 +39,7 @@ "type": "function", "description": "Attempts to connect to other listeners within the extension (listeners may be toolstrips or the extension's background page). This is primarily useful for content scripts connecting to their extension processes. Extensions may connect to content scripts embedded in tabs via <a href='broken'><var>chrome.tabs.connectToTab</var></a>.", "parameters": [ + {"type": "string", "name": "extensionId", "optional": true, "description": "The extension ID of the extension you want to connect to. If omitted, default is your own extension."}, { "type": "object", "name": "connectInfo", @@ -116,6 +125,14 @@ "parameters": [ {"$ref": "Port", "name": "port"} ] + }, + { + "name": "onConnectExternal", + "type": "function", + "description": "Fired when a connection is made from another extension.", + "parameters": [ + {"$ref": "Port", "name": "port"} + ] } ] }, diff --git a/chrome/common/extensions/docs/extension.html b/chrome/common/extensions/docs/extension.html index 150f4dc..67acf9d 100755 --- a/chrome/common/extensions/docs/extension.html +++ b/chrome/common/extensions/docs/extension.html @@ -182,8 +182,10 @@ <li> <a href="#events">Events</a> <ol> - <li jsinstance="*0"> + <li jsinstance="0"> <a href="#event-onConnect">onConnect</a> + </li><li jsinstance="*1"> + <a href="#event-onConnectExternal">onConnectExternal</a> </li> </ol> </li> @@ -351,7 +353,8 @@ For details, see <div class="summary"><span>Port</span> <!-- Note: intentionally longer 80 columns --> - <span>chrome.extension.connect</span>(<span jsinstance="*0" class="optional"><span style="display: none; ">, </span><span>object</span> + <span>chrome.extension.connect</span>(<span jsinstance="0" class="optional"><span style="display: none; ">, </span><span>string</span> + <var><span>extensionId</span></var></span><span jsinstance="*1" class="optional"><span>, </span><span>object</span> <var><span>connectInfo</span></var></span>)</div> <div class="description"> @@ -361,7 +364,48 @@ For details, see <!-- PARAMETERS --> <h4>Parameters</h4> <dl> - <div jsinstance="*0"> + <div jsinstance="0"> + <div> + <dt> + <var>extensionId</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>string</span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>The extension ID of the extension you want to connect to. If omitted, default is your own extension.</dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + </div> + </div><div jsinstance="*1"> <div> <dt> <var>connectInfo</var> @@ -1129,7 +1173,7 @@ For details, see <h3 id="events">Events</h3> <!-- iterates over all events --> - <div class="apiItem" jsinstance="*0"> + <div class="apiItem" jsinstance="0"> <a name="event-onConnect"></a> <h4>onConnect</h4> @@ -1193,6 +1237,70 @@ For details, see </div> <!-- /decription --> + </div><div class="apiItem" jsinstance="*1"> + <a name="event-onConnectExternal"></a> + <h4>onConnectExternal</h4> + + <div class="summary"> + <!-- Note: intentionally longer 80 columns --> + <span class="subdued">chrome.extension.</span><span>onConnectExternal</span><span class="subdued">.addListener</span>(function(<span>Port port</span>) <span class="subdued">{...}</span>); + </div> + + <div class="description"> + <p class="todo" style="display: none; ">Undocumented.</p> + <p>Fired when a connection is made from another extension.</p> + + <!-- PARAMETERS --> + <h4>Parameters</h4> + <dl> + <div jsinstance="*0"> + <div> + <dt> + <var>port</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional" style="display: none; ">optional</span> + <span id="typeTemplate"> + <span> + <a href="extension.html#type-Port">Port</a> + </span> + <span style="display: none; "> + <span> + array of <span><span></span></span> + </span> + <span>paramType</span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo"> + Undocumented. + </dd> + <dd style="display: none; "> + Description of this parameter from the json schema. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + </div> + </div> + </dl> + + </div> <!-- /decription --> + </div> <!-- /apiItem --> </div> <!-- /apiGroup --> @@ -1415,6 +1523,40 @@ For details, see </div><div jsinstance="*4"> <div> <dt> + <var>sender</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>object</span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>This property will <b>only</b> be present on ports passed to onConnect/onConnectExternal listeners.</dd> + + <!-- OBJECT PROPERTIES --> + <dd> + <dl> + <div jsinstance="0"> + <div> + <dt> <var>tab</var> <em> @@ -1441,7 +1583,48 @@ For details, see <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>This property will <b>only</b> be present on ports passed to onConnect listeners when the connection was opened from a tab or content script.</dd> + <dd>This property will <b>only</b> be present when the connection was opened from a tab or content script.</dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + </div> + </div><div jsinstance="*1"> + <div> + <dt> + <var>id</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional" style="display: none; ">optional</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>string</span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>The extension ID of the extension that opened the connection.</dd> <!-- OBJECT PROPERTIES --> <dd style="display: none; "> @@ -1457,6 +1640,10 @@ For details, see </dl> </dd> </div> + </div> + </dl> + </dd> + </div> </div> <!-- /apiItem --> diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index 5884888..7fff1dd 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -1723,9 +1723,10 @@ IPC_BEGIN_MESSAGES(ViewHost) // the given ID. This always returns a valid port ID which can be used for // sending messages. If an error occurred, the opener will be notified // asynchronously. - IPC_SYNC_MESSAGE_CONTROL3_1(ViewHostMsg_OpenChannelToExtension, + IPC_SYNC_MESSAGE_CONTROL4_1(ViewHostMsg_OpenChannelToExtension, int /* routing_id */, - std::string /* extension_id */, + std::string /* source_extension_id */, + std::string /* target_extension_id */, std::string /* channel_name */, int /* port_id */) |