summaryrefslogtreecommitdiff
path: root/platform/firefox/bootstrap.js
blob: 9cac5344ad8de0b414d8d9cd1e6e49f198f4a3f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* global Services, APP_STARTUP, APP_SHUTDOWN */
/* exported startup, shutdown, install, uninstall */

'use strict';

Components.utils['import']('resource://gre/modules/Services.jsm');

var bgProcess;

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);
    }
}

// https://bugzil.la/719376
function install() Services.strings.flushBundles();

function uninstall() {}