Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 // Extensions like Tab Mix Plus will try to recompile our handlers and fail | 5 // Extensions like Tab Mix Plus will try to recompile our handlers and fail |
6 // badly - they manage to replace our handler but the recompiled version | 6 // badly - they manage to replace our handler but the recompiled version |
7 // won't work because the closure is missing its variables. We replace | 7 // won't work because the closure is missing its variables. We replace |
8 // toString() function to prevent this kind of recompiling on earlier stages | 8 // toString() function to prevent this kind of recompiling on earlier stages |
9 // (produce a syntax error but still leave the source code viewable). | 9 // (produce a syntax error but still leave the source code viewable). |
10 function doNotRecompile() | 10 function doNotRecompile() |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 urlbar.handleCommand.toString = doNotRecompile; | 53 urlbar.handleCommand.toString = doNotRecompile; |
54 } | 54 } |
55 }; | 55 }; |
56 | 56 |
57 exports.removeFromWindow = function(window) | 57 exports.removeFromWindow = function(window) |
58 { | 58 { |
59 let urlbar = exports.getURLBar(window); | 59 let urlbar = exports.getURLBar(window); |
60 if (urlbar && urlbar.handleCommand && "urlfixerOldHandler" in urlbar.handl eCommand) | 60 if (urlbar && urlbar.handleCommand && "urlfixerOldHandler" in urlbar.handl eCommand) |
61 urlbar.handleCommand = urlbar.handleCommand.urlfixerOldHandler; | 61 urlbar.handleCommand = urlbar.handleCommand.urlfixerOldHandler; |
62 }; | 62 }; |
63 | |
64 exports.openInfobar = function(window, id, message, buttons, persistence) | |
65 { | |
66 let browser = exports.getBrowser(window); | |
67 let infobar = browser.getNotificationBox(); | |
68 let notif = infobar.getNotificationWithValue(id); | |
Wladimir Palant
2012/09/28 09:29:34
As mentioned before - you don't need to save chara
| |
69 | |
70 if (notif) | |
71 { | |
72 infobar.removeNotification(notif); | |
73 } | |
74 | |
75 notif = infobar.appendNotification( | |
76 message, | |
77 id, | |
78 require("info").addonRoot + "icon64.png", | |
79 infobar.PRIORITY_INFO_HIGH, | |
80 buttons | |
81 ); | |
82 notif.persistence = persistence; | |
83 }; | |
84 | |
85 exports.loadURI = function(uri) | |
86 { | |
87 exports.getBrowser(Services.wm.getMostRecentWindow("navigator:browser")).l oadURI(uri); | |
Wladimir Palant
2012/09/28 09:29:34
This will load the address in *some* browser windo
| |
88 }; | |
63 | 89 |
64 break; | 90 break; |
65 } | 91 } |
66 case "seamonkey": | 92 case "seamonkey": |
67 { | 93 { |
68 // SeaMonkey | 94 // SeaMonkey |
69 exports.isKnownWindow = function(window) window.document.documentElement.get Attribute("windowtype") == "navigator:browser"; | 95 exports.isKnownWindow = function(window) window.document.documentElement.get Attribute("windowtype") == "navigator:browser"; |
70 | 96 |
71 exports.getURLBar = function(window) "gURLBar" in window ? window.gURLBar : null; | 97 exports.getURLBar = function(window) "gURLBar" in window ? window.gURLBar : null; |
72 | 98 |
(...skipping 26 matching lines...) Expand all Loading... | |
99 window.handleURLBarCommand.urlfixerOldHandler = oldHandler; | 125 window.handleURLBarCommand.urlfixerOldHandler = oldHandler; |
100 window.handleURLBarCommand.toString = doNotRecompile; | 126 window.handleURLBarCommand.toString = doNotRecompile; |
101 } | 127 } |
102 }; | 128 }; |
103 | 129 |
104 exports.removeFromWindow = function(window) | 130 exports.removeFromWindow = function(window) |
105 { | 131 { |
106 if (window.handleURLBarCommand && "urlfixerOldHandler" in window.handleURL BarCommand) | 132 if (window.handleURLBarCommand && "urlfixerOldHandler" in window.handleURL BarCommand) |
107 window.handleURLBarCommand = window.handleURLBarCommand.urlfixerOldHandl er; | 133 window.handleURLBarCommand = window.handleURLBarCommand.urlfixerOldHandl er; |
108 }; | 134 }; |
135 | |
136 exports.openInfobar = function(window, id, message, buttons, persistence) | |
137 { | |
138 let browser = exports.getBrowser(window); | |
139 let infobar = browser.getNotificationBox(); | |
140 let notif = infobar.getNotificationWithValue(id); | |
141 | |
142 if (notif) | |
143 { | |
144 infobar.removeNotification(notif); | |
145 } | |
146 | |
147 notif = infobar.appendNotification( | |
148 message, | |
149 id, | |
150 require("info").addonRoot + "icon64.png", | |
151 infobar.PRIORITY_INFO_HIGH, | |
152 buttons | |
153 ); | |
154 notif.persistence = persistence; | |
155 }; | |
156 | |
157 exports.loadURI = function(uri) | |
158 { | |
159 exports.getBrowser(Services.wm.getMostRecentWindow("navigator:browser")).l oadURI(uri); | |
160 }; | |
109 | 161 |
110 break; | 162 break; |
111 } | 163 } |
112 case "fennec": | 164 case "fennec": |
113 { | 165 { |
114 // XUL Fennec | 166 // XUL Fennec |
115 exports.isKnownWindow = function(window) window.document.documentElement.get Attribute("windowtype") == "navigator:browser"; | 167 exports.isKnownWindow = function(window) window.document.documentElement.get Attribute("windowtype") == "navigator:browser"; |
116 | 168 |
117 exports.getURLBar = function(window) null; | 169 exports.getURLBar = function(window) null; |
118 | 170 |
(...skipping 26 matching lines...) Expand all Loading... | |
145 window.BrowserUI.goToURI.urlfixerOldHandler = oldHandler; | 197 window.BrowserUI.goToURI.urlfixerOldHandler = oldHandler; |
146 window.BrowserUI.goToURI.toString = doNotRecompile; | 198 window.BrowserUI.goToURI.toString = doNotRecompile; |
147 } | 199 } |
148 }; | 200 }; |
149 | 201 |
150 exports.removeFromWindow = function(window) | 202 exports.removeFromWindow = function(window) |
151 { | 203 { |
152 if ("BrowserUI" in window && window.BrowserUI.goToURI && "urlfixerOldHandl er" in window.BrowserUI.goToURI) | 204 if ("BrowserUI" in window && window.BrowserUI.goToURI && "urlfixerOldHandl er" in window.BrowserUI.goToURI) |
153 window.BrowserUI.goToURI = window.BrowserUI.goToURI.urlfixerOldHandler; | 205 window.BrowserUI.goToURI = window.BrowserUI.goToURI.urlfixerOldHandler; |
154 }; | 206 }; |
207 | |
208 exports.openInfobar = function() | |
209 { | |
210 // TODO: Implement infobar | |
211 }; | |
212 | |
213 exports.loadURI = function(window, uri) | |
214 { | |
215 // TODO: Implement infobar | |
216 }; | |
155 | 217 |
156 break; | 218 break; |
157 } | 219 } |
158 case "fennec2": | 220 case "fennec2": |
159 { | 221 { |
160 // Native Fennec | 222 // Native Fennec |
161 exports.isKnownWindow = function(window) window.document.documentElement.get Attribute("windowtype") == "navigator:browser"; | 223 exports.isKnownWindow = function(window) window.document.documentElement.get Attribute("windowtype") == "navigator:browser"; |
162 | 224 |
163 exports.getURLBar = function(window) null; | 225 exports.getURLBar = function(window) null; |
164 | 226 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
219 window.BrowserApp.observe.urlfixerOldHandler = oldHandler; | 281 window.BrowserApp.observe.urlfixerOldHandler = oldHandler; |
220 window.BrowserApp.observe.toString = doNotRecompile; | 282 window.BrowserApp.observe.toString = doNotRecompile; |
221 } | 283 } |
222 }; | 284 }; |
223 | 285 |
224 exports.removeFromWindow = function(window) | 286 exports.removeFromWindow = function(window) |
225 { | 287 { |
226 if ("BrowserApp" in window && window.BrowserApp.observe && "urlfixerOldHan dler" in window.BrowserApp.observe) | 288 if ("BrowserApp" in window && window.BrowserApp.observe && "urlfixerOldHan dler" in window.BrowserApp.observe) |
227 window.BrowserApp.observe = window.BrowserApp.observe.urlfixerOldHandler ; | 289 window.BrowserApp.observe = window.BrowserApp.observe.urlfixerOldHandler ; |
228 }; | 290 }; |
291 | |
292 exports.openInfobar = function(window, id, message, buttons, persistence) | |
293 { | |
294 if ("BrowserApp" in window && "selectedTab" in window.BrowserApp) | |
295 { | |
296 window.NativeWindow.doorhanger.show(message, id, buttons, window.Browser App.selectedTab.id, | |
297 { | |
298 persistence: persistence | |
299 } | |
300 ); | |
301 } | |
302 }; | |
303 | |
304 exports.loadURI = function(uri) | |
305 { | |
306 let window = Services.wm.getMostRecentWindow("navigator:browser"); | |
307 if ("BrowserApp" in window && "loadURI" in window.BrowserApp) | |
308 window.BrowserApp.loadURI(uri); | |
309 }; | |
229 | 310 |
230 break; | 311 break; |
231 } | 312 } |
232 default: | 313 default: |
233 { | 314 { |
234 exports.isKnownWindow = function(window) false; | 315 exports.isKnownWindow = function(window) false; |
235 break; | 316 break; |
236 } | 317 } |
237 } | 318 } |
OLD | NEW |