-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.js
148 lines (123 loc) · 4.32 KB
/
bootstrap.js
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* See license.txt for terms of usage */
// ********************************************************************************************* //
// XPCOM
var {classes: Cc, interfaces: Ci, utils: Cu} = Components;
// ********************************************************************************************* //
// Constants
// Extension installation path. Set within startup callback.
var installPath;
// ********************************************************************************************* //
// Firefox Bootstrap API
function install(data, reason) {}
function uninstall(data, reason) {}
function startup(data, reason)
{
// Remember so, we can use later within firebugStartup callback.
installPath = data.installPath;
// Firebug extension start-up callback. Since extension load order isn't guaranteed
// the code needs to be ready for two alternatives:
// 1) Firebug is already loaded - good, let's just execute firebugStartup() callback
// that will ensure proper Firebug related initialization for this extension.
// 2) Firebug is not loaded yet - as soon as Firebug is loaded it'll execute this
// method automatially.
firebugStartup();
}
function shutdown(data, reason)
{
firebugShutdown();
}
function isFirebugLoaded()
{
try
{
// Import Firebug modules into this scope. It fails if Firebug isn't loaded yet.
Cu.import("resource://firebug/loader.js");
Cu.import("resource://firebug/prefLoader.js");
return true;
}
catch (e)
{
}
return true;
}
// ********************************************************************************************* //
// Firebug Bootstrap API
/**
* Executed by Firebug framework when Firebug is started. Since the order of Firebug
* and its bootstrapped extensions is not guaranteed this function is executed twice.
* 1) When Firebug is loaded
* 2) When this extension is loaded
*/
function firebugStartup()
{
// If Firebu isn't loade just bail out, Firebug will execute this method
// as soon as it loads.
if (!isFirebugLoaded())
return;
FirebugLoader.registerBootstrapScope(this);
// Load default preferences
PrefLoader.loadDefaultPrefs(installPath, "prefs.js");
}
/**
* Executed by Firefox when this extension shutdowns.
*/
function firebugShutdown()
{
try
{
FirebugLoader.unregisterBootstrapScope(this);
}
catch (e)
{
Cu.reportError(e);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
/**
* Executed by Firebug framework for every browser window. Use this function to append
* any new elements into the browser window (browser.xul). Don't forget to remove
* these elements in topWindowUnload.
*
* @param {Window} win The browser window
*/
function topWindowLoad(win)
{
// TODO: overlay global browser window
}
/**
* Executed by Firebug framework when this extension
* @param {Object} win
*/
function topWindowUnload(win)
{
// TODO: remove global browser window overlays
}
/**
* Entire Firebug UI is running inside an iframe (firebugFrame.xul). This function
* is executed by Firebug framework when the frame is loaded. This happens when
* the user requires Firebug for the first time (doesn't have to happen during the
* Firefox session at all)
*
* @param {Window} win The Firebug window
*/
function firebugFrameLoad(Firebug)
{
// Register trace listener the customizes trace logs coming from this extension
// * fireAccess; is unique prefix of all messages that should be customized.
// * DBG_FIREACCESS is a class name with style defined in the specified stylesheet.
Firebug.registerTracePrefix("fireAccess;", "DBG_FIREACCESS", true,
"chrome://fireaccess/skin/fireaccess.css");
// The registration process will automatically look for 'main' module and load it.
// The is the same what happens in a XUL overlay applied on:
// chrome://firebug/content/firebugOverlay.xul
var config = {id: "fireaccess@janodvarko.cz"};
Firebug.registerExtension("fireaccess", config);
}
function firebugFrameUnload(Firebug)
{
if (!Firebug.isInitialized)
return;
Firebug.unregisterExtension("fireaccess");
Firebug.unregisterTracePrefix("fireAccess;");
}
// ********************************************************************************************* //