| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ | 16 */ |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * @fileOverview Various application-specific functions. | 19 * @fileOverview Various application-specific functions. |
| 20 */ | 20 */ |
| 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 | 24 |
| 25 /** | 25 /** |
| 26 * Checks whether an application window is known and should get Adblock Plus | 26 * Checks whether an application window is known and should get Adblock Plus |
| 27 * user interface elements. | 27 * user interface elements. |
| 28 * @result Boolean | 28 * @result Boolean |
| 29 */ | 29 */ |
| 30 exports.isKnownWindow = function isKnownWindow(/**Window*/ window) false; | 30 exports.isKnownWindow = function isKnownWindow(/**Window*/ window) |
| 31 { |
| 32 return false; |
| 33 } |
| 31 | 34 |
| 32 /** | 35 /** |
| 33 * HACK: In some applications the window finishes initialization during load | 36 * HACK: In some applications the window finishes initialization during load |
| 34 * event processing which makes an additional delay necessary. This flag | 37 * event processing which makes an additional delay necessary. This flag |
| 35 * indicates that. | 38 * indicates that. |
| 36 * @type Boolean | 39 * @type Boolean |
| 37 */ | 40 */ |
| 38 exports.delayInitialization = false; | 41 exports.delayInitialization = false; |
| 39 | 42 |
| 40 /** | 43 /** |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 let {application} = require("info"); | 259 let {application} = require("info"); |
| 257 switch (application) | 260 switch (application) |
| 258 { | 261 { |
| 259 case "firefox": | 262 case "firefox": |
| 260 { | 263 { |
| 261 exports.isKnownWindow = function ff_isKnownWindow(window) | 264 exports.isKnownWindow = function ff_isKnownWindow(window) |
| 262 { | 265 { |
| 263 return (window.document.documentElement.getAttribute("windowtype") == "nav
igator:browser"); | 266 return (window.document.documentElement.getAttribute("windowtype") == "nav
igator:browser"); |
| 264 }; | 267 }; |
| 265 | 268 |
| 266 exports.getBrowser = function ff_getBrowser(window) window.gBrowser; | 269 exports.getBrowser = function ff_getBrowser(window) { |
| 270 return window.gBrowser |
| 271 }; |
| 267 | 272 |
| 268 exports.addTab = function ff_addTab(window, url, event) | 273 exports.addTab = function ff_addTab(window, url, event) |
| 269 { | 274 { |
| 270 if (event) | 275 if (event) |
| 271 window.openNewTabWith(url, exports.getBrowser(window).contentDocument, n
ull, event, false); | 276 window.openNewTabWith(url, exports.getBrowser(window).contentDocument, n
ull, event, false); |
| 272 else | 277 else |
| 273 window.gBrowser.loadOneTab(url, {inBackground: false}); | 278 window.gBrowser.loadOneTab(url, {inBackground: false}); |
| 274 }; | 279 }; |
| 275 | 280 |
| 276 exports.contentContextMenu = "contentAreaContextMenu"; | 281 exports.contentContextMenu = "contentAreaContextMenu"; |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 case "thunderbird": | 393 case "thunderbird": |
| 389 { | 394 { |
| 390 exports.isKnownWindow = function tb_isKnownWindow(window) | 395 exports.isKnownWindow = function tb_isKnownWindow(window) |
| 391 { | 396 { |
| 392 let type = window.document.documentElement.getAttribute("windowtype"); | 397 let type = window.document.documentElement.getAttribute("windowtype"); |
| 393 return (type == "mail:3pane" || type == "mail:messageWindow"); | 398 return (type == "mail:3pane" || type == "mail:messageWindow"); |
| 394 }; | 399 }; |
| 395 | 400 |
| 396 exports.delayInitialization = true; | 401 exports.delayInitialization = true; |
| 397 | 402 |
| 398 exports.getBrowser = function tb_getBrowser(window) window.getBrowser(); | 403 exports.getBrowser = function tb_getBrowser(window) { |
| 404 return window.getBrowser(); |
| 405 } |
| 399 | 406 |
| 400 exports.addTab = function tb_addTab(window, url, event) | 407 exports.addTab = function tb_addTab(window, url, event) |
| 401 { | 408 { |
| 402 let tabmail = window.document.getElementById("tabmail"); | 409 let tabmail = window.document.getElementById("tabmail"); |
| 403 if (!tabmail) | 410 if (!tabmail) |
| 404 { | 411 { |
| 405 let wnd = Services.wm.getMostRecentWindow("mail:3pane"); | 412 let wnd = Services.wm.getMostRecentWindow("mail:3pane"); |
| 406 if (window) | 413 if (window) |
| 407 tabmail = wnd.document.getElementById("tabmail"); | 414 tabmail = wnd.document.getElementById("tabmail"); |
| 408 } | 415 } |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 675 listener.detach(); | 682 listener.detach(); |
| 676 this.listeners.delete(window); | 683 this.listeners.delete(window); |
| 677 } | 684 } |
| 678 }); | 685 }); |
| 679 | 686 |
| 680 break; | 687 break; |
| 681 } | 688 } |
| 682 | 689 |
| 683 case "fennec2": | 690 case "fennec2": |
| 684 { | 691 { |
| 685 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 }; |
| 686 | 695 |
| 687 exports.getBrowser = function fmn_getBrowser(window) window.BrowserApp.selec
tedBrowser; | 696 exports.getBrowser = function fmn_getBrowser(window) { |
| 697 return window.BrowserApp.selectedBrowser; |
| 698 }; |
| 688 | 699 |
| 689 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 }; |
| 690 | 703 |
| 691 let BrowserChangeListener = function(window, callback) | 704 let BrowserChangeListener = function(window, callback) |
| 692 { | 705 { |
| 693 this.window = window; | 706 this.window = window; |
| 694 this.callback = callback; | 707 this.callback = callback; |
| 695 this.onSelect = this.onSelect.bind(this); | 708 this.onSelect = this.onSelect.bind(this); |
| 696 this.attach(); | 709 this.attach(); |
| 697 }; | 710 }; |
| 698 BrowserChangeListener.prototype = { | 711 BrowserChangeListener.prototype = { |
| 699 window: null, | 712 window: null, |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 { | 926 { |
| 914 let dialogTitle = this.overlay.attributes.subscriptionDialogTitle; | 927 let dialogTitle = this.overlay.attributes.subscriptionDialogTitle; |
| 915 let dialogMessage = this.overlay.attributes.subscriptionDialogMessage.repl
ace(/\?1\?/, title).replace(/\?2\?/, url); | 928 let dialogMessage = this.overlay.attributes.subscriptionDialogMessage.repl
ace(/\?1\?/, title).replace(/\?2\?/, url); |
| 916 if (Utils.confirm(window, dialogMessage, dialogTitle)) | 929 if (Utils.confirm(window, dialogMessage, dialogTitle)) |
| 917 this.setSubscription(url, title); | 930 this.setSubscription(url, title); |
| 918 }; | 931 }; |
| 919 | 932 |
| 920 break; | 933 break; |
| 921 } | 934 } |
| 922 } | 935 } |
| OLD | NEW |