[bcc chromium-dev] On Thu, Jul 30, 2009 at 2:01 PM, Matt Perry <[email protected]> wrote:
> > > On Thu, Jul 30, 2009 at 10:44 AM, James Robinson <[email protected]>wrote: > >> On Tue, Jul 28, 2009 at 6:02 PM, Matt Perry <[email protected]>wrote: >> >>> Two suggestions (one I accidentally sent only to James): >>> >>> chrome.extension.Port: >>> >>> >>> // ID of the extension at the other side of this port. >>> String senderID; >>> >>> Port currently has a 'tab' property if the sender was a tab. Maybe we >>> should group these: >>> >>> chrome.extension.Port: >>> Object sender: >>> Object tab; // if the sender was a tab >>> String id; // ID of the sending extension. >>> >>> >>> chrome.extension: >>> >>> >>> >>> // Open a channel to another extension with the provided ID. >>> >>> >>> // 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 each time >>> >>> >>> >>> // the method is called. >>> >>> >>> // The channel can optionally be named. This name will be sent along >>> >>> >>> >>> // with the onConnectExternal event >>> >>> >>> Port connectExternal(string ID, [string channelName]) >>> >>> >>> >>> It makes more sense to me to have the API mirror the regular connect >>> event: >>> >>>> chrome.extension.connect(); // connects to my own extension >>> >>>> other = new chrome.Extension('abcef...'); >>> other.connect(); // connects to extension abcdef... >>> >>> >> The reason I shied away from this is that the behavior of the statement >> "new chrome.Extension('abdef...').connect()" is very different depending on >> if 'abcdef...' is the ID of the extension containing that code or a >> different one. >> > > How is it different? Sounds like a bug to me. > > It's also not clear from the documentation what an extension should expect >> to be able to do with the result of "new chrome.Extension('abcdef...'). >> According to >> http://dev.chromium.org/developers/design-documents/extensions/content-scripts >> the >> available APIs in addition to connect() are the onConnect event, which >> another extension should _not_ have access to, and getURL(path), which seems >> like it would just return chrome-extension://abcdef.../path. Based on that >> I don't see much value in exposing the new chrome.Extension('abcdef...') >> syntax for inter-extension interaction. >> > > The value is consistency. <extensionObject>.connect() is how you open a > port to that extension. It should be the same regardless of who you're > talking to. > In extension A with id 'aaaaa', the code: new chrome.Extension('aaaaa').connect() would fire an onConnect event at components of extension A. With the proposal, doing that same line of code in extension B with id 'bbbbb' an onConnectExternal event would be fired at components of extension A. The most consistent thing to do would be to use connect() and onConnect everywhere, but an extension needs to be aware of when a connection is coming from another component within the same extension and when it is coming from a different extension. Hence the connectExternal/onConnectExternal calls instead of reusing connect/onConnect. - James --~--~---------~--~----~------------~-------~--~----~ Chromium Developers mailing list: [email protected] View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev -~----------~----~----~----~------~----~------~--~---
