-
-
Save Gozala/3864791 to your computer and use it in GitHub Desktop.
content script apis ideas
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Content scripts will be able to require modules, only | |
| // high level ones that are E10S friendly and can do | |
| // everything via data that is serialize. | |
| $(function() { | |
| // what we have now | |
| self.on('event-name', function(data) { | |
| // ... something | |
| }); | |
| self.port.emit('something'); | |
| // instead, (re)implementing APIs or providing new globals | |
| // we just expose modules to a content scripts. | |
| var notify = require('sdk/notifications') | |
| addon.notify({ | |
| title: 'foo', | |
| text: 'bar', | |
| data: 'baz baz', | |
| onClick: function() { | |
| // called if notification is clicked | |
| } | |
| }); | |
| var Panel = require('sdk/panel').Panel; | |
| var panel = Panel({ | |
| // .... | |
| }); | |
| panel.show(); | |
| var request = require('sdk/request').request; | |
| request({ | |
| url: 'http://something.ca', | |
| // ... | |
| onComplete: function(response) { | |
| // response data is brought back serialized. | |
| } | |
| }) | |
| /* | |
| * the 'require' case, perhaps we have an abstract 'bridge' | |
| * protocol that a module can implement, which handles communication? | |
| */ | |
| self.require('notifications').notify({ | |
| title: 'foo', | |
| text: 'bar', | |
| data: 'baz baz', | |
| onClick: function() {} | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment