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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
var Cu = Components.utils;
var Ci = Components.interfaces;
var Cc = Components.classes;
var Cr = Components.results;
var Cm = Components.manager;
Cu.import("resource://gre/modules/Services.jsm");
var resource = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandler);
var styleSheetService = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);
var ios = Cc["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
var observer = null;
var consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
var windowListener = {
onOpenWindow: function(aWindow) {
if (!(aWindow.chromeFlags & Ci.nsIWebBrowserChrome.CHROME_PERSONAL_TOOLBAR)) {
let domWindow = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
domWindow.addEventListener("load", function() {
domWindow.removeEventListener("load", arguments.callee, false);
new UnityPrefs(domWindow);
}, false);
}
},
onCloseWindow: function(aWindow) {},
onWindowTitleChange: function(aWindow, aTitle) {}
};
function startup(params, reason) {
try {
var commandLineHandlerPath = params.installPath.clone();
commandLineHandlerPath.append('content');
commandLineHandlerPath.append('command-line-handler.manifest');
Cm.addBootstrappedManifestLocation(params.installPath);
var uri = ios.newURI("chrome://unity/skin/browser.css", null, null);
styleSheetService.loadAndRegisterSheet(uri, styleSheetService.USER_SHEET);
var path = params.installPath.clone();
path.append('content');
let alias = Services.io.newFileURI(path);
resource.setSubstitution("unity", alias);
var chromelessUrlpolicyPath = params.installPath.clone();
chromelessUrlpolicyPath.append('content');
chromelessUrlpolicyPath.append('chromeless-urlpolicy.manifest');
Cm.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(chromelessUrlpolicyPath);
Cm.QueryInterface(Ci.nsIComponentRegistrar).autoRegister(commandLineHandlerPath);
Cu.import("resource://unity/observer.js");
observer = new Observer();
observer.activate();
Cu.import("resource://unity/prefs.js");
Cu.import("resource://unity/chromeless.js");
wm.addListener(windowListener);
} catch (x) {dump(x);}
}
function shutdown(params, reason) {
Chromeless.deactivate();
wm.removeListener(windowListener);
Cu.unload("resource://unity/chromeless.js");
Cu.unload("resource://unity/prefs.js");
var manifest = params.installPath.clone();
manifest.append('content');
manifest.append('command-line-handler.manifest');
observer.deactivate();
observer = null;
Cu.unload("resource://unity/observer.js");
Cm.QueryInterface(Ci.nsIComponentRegistrar).autoUnregister(manifest);
var chromelessUrlpolicyPath = params.installPath.clone();
chromelessUrlpolicyPath.append('content');
chromelessUrlpolicyPath.append('chromeless-urlpolicy.manifest');
Cm.QueryInterface(Ci.nsIComponentRegistrar).autoUnregister(chromelessUrlpolicyPath);
resource.setSubstitution("unity", null);
var uri = ios.newURI("chrome://unity/skin/browser.css", null, null);
styleSheetService.unregisterSheet(uri, sss.USER_SHEET);
Cm.removeBootstrappedManifestLocation(params.installPath);
}
|