OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); | 18 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
19 Cu.import("resource://gre/modules/Services.jsm"); | 19 Cu.import("resource://gre/modules/Services.jsm"); |
20 | 20 |
21 let {Utils} = require("utils"); | 21 let {Utils} = require("utils"); |
| 22 let {port} = require("messaging"); |
22 let {Prefs} = require("prefs"); | 23 let {Prefs} = require("prefs"); |
23 let {Policy} = require("contentPolicy"); | 24 let {Policy} = require("contentPolicy"); |
24 let {FilterStorage} = require("filterStorage"); | 25 let {FilterStorage} = require("filterStorage"); |
25 let {FilterNotifier} = require("filterNotifier"); | 26 let {FilterNotifier} = require("filterNotifier"); |
26 let {RequestNotifier} = require("requestNotifier"); | 27 let {RequestNotifier} = require("requestNotifier"); |
27 let {Filter} = require("filterClasses"); | 28 let {Filter} = require("filterClasses"); |
28 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub
scriptionClasses"); | 29 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub
scriptionClasses"); |
29 let {Synchronizer} = require("synchronizer"); | 30 let {Synchronizer} = require("synchronizer"); |
30 let {KeySelector} = require("keySelector"); | 31 let {KeySelector} = require("keySelector"); |
31 let {Notification} = require("notification"); | 32 let {Notification} = require("notification"); |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 || window.document.getElementById("abp-status"); | 439 || window.document.getElementById("abp-status"); |
439 if (!button) | 440 if (!button) |
440 return; | 441 return; |
441 | 442 |
442 this._showNotification(window, button, notification); | 443 this._showNotification(window, button, notification); |
443 }); | 444 }); |
444 | 445 |
445 // Add "anti-adblock messages" notification | 446 // Add "anti-adblock messages" notification |
446 initAntiAdblockNotification(); | 447 initAntiAdblockNotification(); |
447 | 448 |
448 // Frame script URL has to be randomized due to caching | |
449 // (see https://bugzilla.mozilla.org/show_bug.cgi?id=1051238) | |
450 let frameScript = "chrome://adblockplus/content/subscribeLinkHandler.js?" +
Math.random(); | |
451 | |
452 // Initialize subscribe link handling | 449 // Initialize subscribe link handling |
453 let callback = this.subscribeLinkClicked.bind(this); | 450 port.on("subscribeLinkClick", data => this.subscribeLinkClicked(data)); |
454 let messageManager = Cc["@mozilla.org/globalmessagemanager;1"] | |
455 .getService(Ci.nsIMessageListenerManager); | |
456 messageManager.loadFrameScript(frameScript, true); | |
457 messageManager.addMessageListener("AdblockPlus:SubscribeLink", callback); | |
458 onShutdown.add(() => { | |
459 messageManager.broadcastAsyncMessage("AdblockPlus:Shutdown", frameScript); | |
460 messageManager.removeDelayedFrameScript(frameScript); | |
461 messageManager.removeMessageListener("AdblockPlus:SubscribeLink", callback
); | |
462 }); | |
463 | 451 |
464 // Execute first-run actions if a window is open already, otherwise it | 452 // Execute first-run actions if a window is open already, otherwise it |
465 // will happen in applyToWindow() when a window is opened. | 453 // will happen in applyToWindow() when a window is opened. |
466 this.firstRunActions(this.currentWindow); | 454 this.firstRunActions(this.currentWindow); |
467 }, | 455 }, |
468 | 456 |
469 addToolbarButton: function() | 457 addToolbarButton: function() |
470 { | 458 { |
471 let {WindowObserver} = require("windowObserver"); | 459 let {WindowObserver} = require("windowObserver"); |
472 new WindowObserver(this); | 460 new WindowObserver(this); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
924 notifyUser(); | 912 notifyUser(); |
925 } | 913 } |
926 }, false); | 914 }, false); |
927 request.send(); | 915 request.send(); |
928 } | 916 } |
929 else | 917 else |
930 notifyUser(); | 918 notifyUser(); |
931 }, | 919 }, |
932 | 920 |
933 /** | 921 /** |
934 * Called whenever subscribeLinkHandler.js intercepts clicks on abp: links | 922 * Called whenever child/subscribeLinks module intercepts clicks on abp: links |
935 * as well as links to subscribe.adblockplus.org. | 923 * as well as links to subscribe.adblockplus.org. |
936 */ | 924 */ |
937 subscribeLinkClicked: function(message) | 925 subscribeLinkClicked: function({title, url, |
| 926 mainSubscriptionTitle, mainSubscriptionURL}) |
938 { | 927 { |
939 let {title, url, mainSubscriptionTitle, mainSubscriptionURL} = message.data; | |
940 if (!url) | 928 if (!url) |
941 return; | 929 return; |
942 | 930 |
943 // Default title to the URL | 931 // Default title to the URL |
944 if (!title) | 932 if (!title) |
945 title = url; | 933 title = url; |
946 | 934 |
947 // Main subscription needs both title and URL | 935 // Main subscription needs both title and URL |
948 if (mainSubscriptionTitle && !mainSubscriptionURL) | 936 if (mainSubscriptionTitle && !mainSubscriptionURL) |
949 mainSubscriptionTitle = null; | 937 mainSubscriptionTitle = null; |
(...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)], | 1892 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)], |
1905 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa
tegory.bind(Notification, "*", null)] | 1893 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa
tegory.bind(Notification, "*", null)] |
1906 ]; | 1894 ]; |
1907 | 1895 |
1908 onShutdown.add(function() | 1896 onShutdown.add(function() |
1909 { | 1897 { |
1910 for (let window of UI.applicationWindows) | 1898 for (let window of UI.applicationWindows) |
1911 if (UI.isBottombarOpen(window)) | 1899 if (UI.isBottombarOpen(window)) |
1912 UI.toggleBottombar(window); | 1900 UI.toggleBottombar(window); |
1913 }); | 1901 }); |
OLD | NEW |