Chromium Code Reviews| Index: docs/inter_extension_communication.md |
| diff --git a/docs/inter_extension_communication.md b/docs/inter_extension_communication.md |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..99ad50337ed2f8ec316d506ab3205c20dd6869ac |
| --- /dev/null |
| +++ b/docs/inter_extension_communication.md |
| @@ -0,0 +1,59 @@ |
| +# Status |
| + |
| +Proposal |
| + |
| +# Overview |
| + |
| +Proposed API for communication between different extensions. There are three parts, the actual APIs exposed to extensions, a change to the manifest to declare communication permissions, and a change to the event firing behavior |
|
Bons
2015/08/20 20:16:50
delete
|
| + |
| +Original proposal and discussion took place in this thread: |
| +http://groups.google.com/group/chromium-extensions/browse_thread/thread/c2667325d17d2b56 |
| + |
| + |
| +# API |
| + |
| +``` |
| +chrome.extension: |
| + |
| +// Open a channel to another extension with the provided ID. |
| +// If the ID is unspecified, the channel is opened to the calling |
| +// extension and a chrome.extension.onConnect event is fired. |
| +// Otherwise if no extension with the provided ID exists, nothing happens. |
| +// Otherwise the chrome.extension.onConnectExternal event is fired |
| +// to all components of the extension with the provided ID. |
| +// |
| +// The channel can optionally be named. This name will be sent along |
| +// with the onConnectExternal event |
| +Port connect([string ID], [{[string name]}]) |
| + |
| +// Fired when another extension opens a channel to this extension via |
| +// chrome.extension.connectExternal(). |
| +// If a channelName was provided, it is accessible via port.name. |
| +Event onConnectExternal(Object port) |
| +``` |
| +``` |
| +chrome.extension.Port: |
| + Object sender: |
| + Object tab; // if the sender were a tab |
| + String id; // ID of the sending extension. |
| +``` |
| + |
| +# Event behavior |
| + |
| +## Problem |
| + |
| +The order in which the scripts within different background pages are executed is not defined, which is entirely reasonable, but it means that doing the obvious thing: |
| +``` |
| +<script> |
| +var port = chrome.extension.connectExternal('abcdef..'); |
| +</script> |
| +``` |
| +would work unreliably depending on the exact order in which the background pages get loaded, the event handlers get registered, and the events are fired. |
| + |
| +A parallel issue exists for an extension that tries to open connections to itself using onConnect events |
| + |
| +## Proposed Solution |
| + |
| +The following language be added to the Events spec (http://dev.chromium.org/developers/design-documents/extensions/events ): |
| + |
| +Events for an extension are enqueued until the background page for an extension, if there is one, is loaded. |