Add-on SDK Contrent script and Components.classes

Hi.
I’m working on port of XPCOM addon to Addon SDK and to be e10s compliant.


Addon creates global jsPrinSetup object in page script window context, which allow page scripts to perform some printer setting tasks.
If I’m on right way there is recommended most of this calls to be processed from content script parts of add-on.
But unfortunately I can’t use Components.classes in content scripts (may be this is privileged ).
How I can port the following old XPCOM code to add-on SDK?

// aWindow as unsafeWindow
var printSettingsService = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
.getService(Components.interfaces.nsIPrintSettingsService);
var printSettings = printSettingsService.newPrintSettings;
// do changes in print settings
printSettings.headerStrLeft = ‘foo’;
// other adjustements
var WebBrowserPrint = aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
webBrowserPrint.print(printSettings);

You can ether use frame scripts instead of content scripts (not in the SDK, IMHO a mess to work with) or you change your API to be asynchronous and sue self.port from the content script to request the actions in your background/main script.

Which is best in point of view of future perspective, because in near future XPCOM will be dropped?
Add-on SDK, Bootstrapped add-on (with frame script) ?
I get the impression that all will be moved to Webextensions, but till now there is lack of functionality to realize our add-on.
"There are currently several toolsets for developing Firefox add-ons, but WebExtensions will become the standard by the end of 2017. The rest are expected to be deprecated over the same period of time."
Is it case to port from XPCOM to Addon SDK or wait WebExtensions to be enhanced and try to port to them?

WebExtensions are definitely the way to go.

Mozilla is planning to gradually expose all the stuff needed to implement more advanced add-ons as WebExtensions.

You can propose addditional API by implementing an WebExtensions Experiment and submitting it for review on bugzilla:

https://wiki.mozilla.org/WebExtensions/Experiments
https://github.com/aswan/webext-experiment-hello