OLD | NEW |
---|---|
(Empty) | |
1 # Status | |
2 | |
3 Proposal | |
4 | |
5 # Overview | |
6 | |
7 Proposed API for communication between different extensions. There are three pa rts, 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
| |
8 | |
9 Original proposal and discussion took place in this thread: | |
10 http://groups.google.com/group/chromium-extensions/browse_thread/thread/c2667325 d17d2b56 | |
11 | |
12 | |
13 # API | |
14 | |
15 ``` | |
16 chrome.extension: | |
17 | |
18 // Open a channel to another extension with the provided ID. | |
19 // If the ID is unspecified, the channel is opened to the calling | |
20 // extension and a chrome.extension.onConnect event is fired. | |
21 // Otherwise if no extension with the provided ID exists, nothing happens. | |
22 // Otherwise the chrome.extension.onConnectExternal event is fired | |
23 // to all components of the extension with the provided ID. | |
24 // | |
25 // The channel can optionally be named. This name will be sent along | |
26 // with the onConnectExternal event | |
27 Port connect([string ID], [{[string name]}]) | |
28 | |
29 // Fired when another extension opens a channel to this extension via | |
30 // chrome.extension.connectExternal(). | |
31 // If a channelName was provided, it is accessible via port.name. | |
32 Event onConnectExternal(Object port) | |
33 ``` | |
34 ``` | |
35 chrome.extension.Port: | |
36 Object sender: | |
37 Object tab; // if the sender were a tab | |
38 String id; // ID of the sending extension. | |
39 ``` | |
40 | |
41 # Event behavior | |
42 | |
43 ## Problem | |
44 | |
45 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: | |
46 ``` | |
47 <script> | |
48 var port = chrome.extension.connectExternal('abcdef..'); | |
49 </script> | |
50 ``` | |
51 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. | |
52 | |
53 A parallel issue exists for an extension that tries to open connections to itsel f using onConnect events | |
54 | |
55 ## Proposed Solution | |
56 | |
57 The following language be added to the Events spec (http://dev.chromium.org/deve lopers/design-documents/extensions/events ): | |
58 | |
59 Events for an extension are enqueued until the background page for an extension, if there is one, is loaded. | |
OLD | NEW |