| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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 10 matching lines...) Expand all Loading... | |
| 21 | 21 |
| 22 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | 22 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
| 23 Cu.import("resource://gre/modules/Services.jsm"); | 23 Cu.import("resource://gre/modules/Services.jsm"); |
| 24 Cu.import("resource://gre/modules/AddonManager.jsm"); | 24 Cu.import("resource://gre/modules/AddonManager.jsm"); |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * Checks whether an application window is known and should get Adblock Plus | 27 * Checks whether an application window is known and should get Adblock Plus |
| 28 * user interface elements. | 28 * user interface elements. |
| 29 * @result Boolean | 29 * @result Boolean |
| 30 */ | 30 */ |
| 31 exports.isKnownWindow = function isKnownWindow(/**Window*/ window) false; | 31 exports.isKnownWindow = function isKnownWindow(/**Window*/ window) { |
|
Wladimir Palant
2014/05/15 07:12:38
(/**Window*/ window) => false?
| |
| 32 return false; | |
| 33 } | |
| 32 | 34 |
| 33 /** | 35 /** |
| 34 * HACK: In some applications the window finishes initialization during load | 36 * HACK: In some applications the window finishes initialization during load |
| 35 * event processing which makes an additional delay necessary. This flag | 37 * event processing which makes an additional delay necessary. This flag |
| 36 * indicates that. | 38 * indicates that. |
| 37 * @type Boolean | 39 * @type Boolean |
| 38 */ | 40 */ |
| 39 exports.delayInitialization = false; | 41 exports.delayInitialization = false; |
| 40 | 42 |
| 41 /** | 43 /** |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 let {application} = require("info"); | 259 let {application} = require("info"); |
| 258 switch (application) | 260 switch (application) |
| 259 { | 261 { |
| 260 case "firefox": | 262 case "firefox": |
| 261 { | 263 { |
| 262 exports.isKnownWindow = function ff_isKnownWindow(window) | 264 exports.isKnownWindow = function ff_isKnownWindow(window) |
| 263 { | 265 { |
| 264 return (window.document.documentElement.getAttribute("windowtype") == "nav igator:browser"); | 266 return (window.document.documentElement.getAttribute("windowtype") == "nav igator:browser"); |
| 265 }; | 267 }; |
| 266 | 268 |
| 267 exports.getBrowser = function ff_getBrowser(window) window.gBrowser; | 269 exports.getBrowser = function ff_getBrowser(window) { |
| 270 return window.gBrowser | |
| 271 }; | |
|
Wladimir Palant
2014/05/15 07:12:38
(window) => window.gBrowser?
| |
| 268 | 272 |
| 269 exports.addTab = function ff_addTab(window, url, event) | 273 exports.addTab = function ff_addTab(window, url, event) |
| 270 { | 274 { |
| 271 if (event) | 275 if (event) |
| 272 window.openNewTabWith(url, exports.getBrowser(window).contentDocument, n ull, event, false); | 276 window.openNewTabWith(url, exports.getBrowser(window).contentDocument, n ull, event, false); |
| 273 else | 277 else |
| 274 window.gBrowser.loadOneTab(url, {inBackground: false}); | 278 window.gBrowser.loadOneTab(url, {inBackground: false}); |
| 275 }; | 279 }; |
| 276 | 280 |
| 277 exports.contentContextMenu = "contentAreaContextMenu"; | 281 exports.contentContextMenu = "contentAreaContextMenu"; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 case "thunderbird": | 393 case "thunderbird": |
| 390 { | 394 { |
| 391 exports.isKnownWindow = function tb_isKnownWindow(window) | 395 exports.isKnownWindow = function tb_isKnownWindow(window) |
| 392 { | 396 { |
| 393 let type = window.document.documentElement.getAttribute("windowtype"); | 397 let type = window.document.documentElement.getAttribute("windowtype"); |
| 394 return (type == "mail:3pane" || type == "mail:messageWindow"); | 398 return (type == "mail:3pane" || type == "mail:messageWindow"); |
| 395 }; | 399 }; |
| 396 | 400 |
| 397 exports.delayInitialization = true; | 401 exports.delayInitialization = true; |
| 398 | 402 |
| 399 exports.getBrowser = function tb_getBrowser(window) window.getBrowser(); | 403 exports.getBrowser = function tb_getBrowser(window) { |
| 404 return window.getBrowser(); | |
| 405 } | |
|
Wladimir Palant
2014/05/15 07:12:38
(window) => window.getBrowser()?
| |
| 400 | 406 |
| 401 exports.addTab = function tb_addTab(window, url, event) | 407 exports.addTab = function tb_addTab(window, url, event) |
| 402 { | 408 { |
| 403 let tabmail = window.document.getElementById("tabmail"); | 409 let tabmail = window.document.getElementById("tabmail"); |
| 404 if (!tabmail) | 410 if (!tabmail) |
| 405 { | 411 { |
| 406 let wnd = Services.wm.getMostRecentWindow("mail:3pane"); | 412 let wnd = Services.wm.getMostRecentWindow("mail:3pane"); |
| 407 if (window) | 413 if (window) |
| 408 tabmail = wnd.document.getElementById("tabmail"); | 414 tabmail = wnd.document.getElementById("tabmail"); |
| 409 } | 415 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 listener.detach(); | 682 listener.detach(); |
| 677 this.listeners.delete(window); | 683 this.listeners.delete(window); |
| 678 } | 684 } |
| 679 }); | 685 }); |
| 680 | 686 |
| 681 break; | 687 break; |
| 682 } | 688 } |
| 683 | 689 |
| 684 case "fennec2": | 690 case "fennec2": |
| 685 { | 691 { |
| 686 exports.isKnownWindow = function fmn_isKnownWindow(/**Window*/ window) windo w.document.documentElement.id == "main-window"; | 692 exports.isKnownWindow = function fmn_isKnownWindow(/**Window*/ window) { |
| 693 return window.document.documentElement.id == "main-window"; | |
| 694 }; | |
| 687 | 695 |
| 688 exports.getBrowser = function fmn_getBrowser(window) window.BrowserApp.selec tedBrowser; | 696 exports.getBrowser = function fmn_getBrowser(window) { |
| 697 return window.BrowserApp.selectedBrowser; | |
| 698 }; | |
| 689 | 699 |
| 690 exports.addTab = function fmn_addTab(window, url, event) window.BrowserApp.a ddTab(url, {selected: true}); | 700 exports.addTab = function fmn_addTab(window, url, event) { |
| 701 return window.BrowserApp.addTab(url, {selected: true}); | |
| 702 }; | |
|
Wladimir Palant
2014/05/15 07:12:38
Use fat arrow expressions here?
| |
| 691 | 703 |
| 692 let BrowserChangeListener = function(window, callback) | 704 let BrowserChangeListener = function(window, callback) |
| 693 { | 705 { |
| 694 this.window = window; | 706 this.window = window; |
| 695 this.callback = callback; | 707 this.callback = callback; |
| 696 this.onSelect = this.onSelect.bind(this); | 708 this.onSelect = this.onSelect.bind(this); |
| 697 this.attach(); | 709 this.attach(); |
| 698 }; | 710 }; |
| 699 BrowserChangeListener.prototype = { | 711 BrowserChangeListener.prototype = { |
| 700 window: null, | 712 window: null, |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 939 event.state = {id: require("info").addonID}; | 951 event.state = {id: require("info").addonID}; |
| 940 browser._contentWindow.dispatchEvent(event); | 952 browser._contentWindow.dispatchEvent(event); |
| 941 }); | 953 }); |
| 942 }); | 954 }); |
| 943 }, true); | 955 }, true); |
| 944 }; | 956 }; |
| 945 | 957 |
| 946 break; | 958 break; |
| 947 } | 959 } |
| 948 } | 960 } |
| OLD | NEW |