Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
138 /** | 138 /** |
139 * Maps windows to a list of progress listeners. | 139 * Maps windows to a list of progress listeners. |
140 */ | 140 */ |
141 let progressListeners = new WeakMap(); | 141 let progressListeners = new WeakMap(); |
142 | 142 |
143 /** | 143 /** |
144 * Makes sure that a function is called whenever the displayed browser location changes. | 144 * Makes sure that a function is called whenever the displayed browser location changes. |
145 */ | 145 */ |
146 exports.addBrowserLocationListener = function addBrowserLocationListener(/**Wind ow*/ window, /**Function*/ callback, /**Boolean*/ ignoreSameDoc) | 146 exports.addBrowserLocationListener = function addBrowserLocationListener(/**Wind ow*/ window, /**Function*/ callback, /**Boolean*/ ignoreSameDoc) |
147 { | 147 { |
148 _addBrowserLocationListener(window, callback, ignoreSameDoc); | |
149 }; | |
150 | |
151 function _addBrowserLocationListener(/**Window*/ window, /**Function*/ callback, /**Boolean*/ ignoreSameDoc) | |
152 { | |
153 let browser = (exports.getBrowser ? exports.getBrowser(window) : null); | 148 let browser = (exports.getBrowser ? exports.getBrowser(window) : null); |
154 if (browser) | 149 if (browser) |
155 { | 150 { |
156 let dummy = function() {}; | 151 let dummy = function() {}; |
157 let progressListener = | 152 let progressListener = |
158 { | 153 { |
159 callback: callback, | 154 callback: callback, |
160 onLocationChange: function(progress, request, uri, flags) | 155 onLocationChange: function(progress, request, uri, flags) |
161 { | 156 { |
162 if (!ignoreSameDoc || !flags || !(flags & Ci.nsIWebProgressListener.LOCA TION_CHANGE_SAME_DOCUMENT)) | 157 if (!ignoreSameDoc || !flags || !(flags & Ci.nsIWebProgressListener.LOCA TION_CHANGE_SAME_DOCUMENT)) |
163 this.callback(); | 158 this.callback(); |
164 }, | 159 }, |
165 onProgressChange: dummy, | 160 onProgressChange: dummy, |
166 onSecurityChange: dummy, | 161 onSecurityChange: dummy, |
167 onStateChange: dummy, | 162 onStateChange: dummy, |
168 onStatusChange: dummy, | 163 onStatusChange: dummy, |
169 QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, Ci.nsISu pportsWeakReference]) | 164 QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, Ci.nsISu pportsWeakReference]) |
170 }; | 165 }; |
171 browser.addProgressListener(progressListener); | 166 browser.addProgressListener(progressListener); |
172 | 167 |
173 if (progressListeners.has(window)) | 168 if (progressListeners.has(window)) |
174 progressListeners.get(window).push(progressListener); | 169 progressListeners.get(window).push(progressListener); |
175 else | 170 else |
176 progressListeners.set(window, [progressListener]); | 171 progressListeners.set(window, [progressListener]); |
177 } | 172 } |
178 } | 173 }; |
179 | 174 |
180 /** | 175 /** |
181 * Removes a location listener registered for a window. | 176 * Removes a location listener registered for a window. |
182 */ | 177 */ |
183 exports.removeBrowserLocationListener = function removeBrowserLocationListener(/ **Window*/ window, /**Function*/ callback) | 178 exports.removeBrowserLocationListener = function removeBrowserLocationListener(/ **Window*/ window, /**Function*/ callback) |
184 { | 179 { |
185 if (!progressListeners.has(window)) | 180 if (!progressListeners.has(window)) |
186 return; | 181 return; |
187 | 182 |
188 let browser = (exports.getBrowser ? exports.getBrowser(window) : null); | 183 let browser = (exports.getBrowser ? exports.getBrowser(window) : null); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 return null; | 353 return null; |
359 } | 354 } |
360 } | 355 } |
361 else | 356 else |
362 { | 357 { |
363 let browser = exports.getBrowser(window); | 358 let browser = exports.getBrowser(window); |
364 return (browser ? browser.currentURI : null); | 359 return (browser ? browser.currentURI : null); |
365 } | 360 } |
366 }; | 361 }; |
367 | 362 |
368 exports.addBrowserLocationListener = function addBrowserLocationListener(/** Window*/ window, /**Function*/ callback, /**Boolean*/ ignoreSameDoc) | 363 // for Seamonkey we have to ignore same document flag because of |
369 { | 364 // bug #1035171 (https://bugzilla.mozilla.org/show_bug.cgi?id=1035171) |
370 // for Seamonkey we have to ignore same document flag because of bug #1035 171 | 365 let origAddBrowserLocationListener = exports.addBrowserLocationListener; |
Wladimir Palant
2014/07/08 11:29:02
Please use a link, otherwise it won't be obvious w
saroyanm
2014/07/08 11:58:42
Done.
| |
371 _addBrowserLocationListener(window, callback, false); | 366 exports.addBrowserLocationListener = function sm_addBrowserLocationListener( window, callback, ignoreSameDoc) |
367 { | |
368 origAddBrowserLocationListener(window, callback, false); | |
372 }; | 369 }; |
Wladimir Palant
2014/07/08 11:29:02
Forcing the ignoreSameDoc parameter to be always f
saroyanm
2014/07/08 11:58:42
I like this :)
| |
373 | 370 |
374 exports.contentContextMenu = ["contentAreaContextMenu", "mailContext"]; | 371 exports.contentContextMenu = ["contentAreaContextMenu", "mailContext"]; |
375 | 372 |
376 exports.defaultToolbarPosition = { | 373 exports.defaultToolbarPosition = { |
377 parent: ["PersonalToolbar", "msgToolbar"], | 374 parent: ["PersonalToolbar", "msgToolbar"], |
378 before: ["bookmarks-button", "button-junk"] | 375 before: ["bookmarks-button", "button-junk"] |
379 }; | 376 }; |
380 | 377 |
381 exports.statusbarPosition = { | 378 exports.statusbarPosition = { |
382 parent: "status-bar" | 379 parent: "status-bar" |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
950 event.state = {id: require("info").addonID}; | 947 event.state = {id: require("info").addonID}; |
951 browser._contentWindow.dispatchEvent(event); | 948 browser._contentWindow.dispatchEvent(event); |
952 }); | 949 }); |
953 }); | 950 }); |
954 }, true); | 951 }, true); |
955 }; | 952 }; |
956 | 953 |
957 break; | 954 break; |
958 } | 955 } |
959 } | 956 } |
LEFT | RIGHT |