From ae36081605372361458fb04fa8f46e22d72abfa3 Mon Sep 17 00:00:00 2001 From: Deathamns Date: Mon, 24 Nov 2014 20:00:27 +0100 Subject: [PATCH] Initial Firefox port (base, messaging, locales) --- platform/firefox/bootstrap.js | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 platform/firefox/bootstrap.js diff --git a/platform/firefox/bootstrap.js b/platform/firefox/bootstrap.js new file mode 100644 index 0000000..f9fae17 --- /dev/null +++ b/platform/firefox/bootstrap.js @@ -0,0 +1,46 @@ +/* global Services, APP_STARTUP, APP_SHUTDOWN */ +/* exported startup, shutdown, install, uninstall */ + +'use strict'; + +var bgProcess; +Components.utils['import']('resource://gre/modules/Services.jsm'); + +function startup(data, reason) { + bgProcess = function(ev) { + if (ev) { + this.removeEventListener('load', bgProcess); + } + + bgProcess = Services.appShell.hiddenDOMWindow.document; + bgProcess = bgProcess.documentElement.appendChild( + bgProcess.createElementNS('http://www.w3.org/1999/xhtml', 'iframe') + ); + bgProcess.setAttribute('src', 'chrome://ublock/content/background.html'); + }; + + if (reason === APP_STARTUP) { + Services.ww.registerNotification({ + observe: function(subject) { + Services.ww.unregisterNotification(this); + subject.addEventListener('load', bgProcess); + } + }); + } + else { + bgProcess(); + } +} + +function shutdown(data, reason) { + if (reason !== APP_SHUTDOWN) { + bgProcess.parentNode.removeChild(bgProcess); + } +} + +function install() { + // https://bugzil.la/719376 + Services.strings.flushBundles(); +} + +function uninstall() {} \ No newline at end of file