Left: | ||
Right: |
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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 // Frame script URL has to be randomized due to caching |
449 // (see https://bugzilla.mozilla.org/show_bug.cgi?id=1051238) | 450 // (see https://bugzilla.mozilla.org/show_bug.cgi?id=1051238) |
450 let frameScript = "chrome://adblockplus/content/subscribeLinkHandler.js?" + Math.random(); | 451 let frameScript = "chrome://adblockplus/content/subscribeLinkHandler.js?" + Math.random(); |
Erik
2016/04/06 03:11:41
should this line not be removed too?
Wladimir Palant
2016/04/18 15:38:40
Done.
| |
451 | 452 |
452 // Initialize subscribe link handling | 453 // Initialize subscribe link handling |
453 let callback = this.subscribeLinkClicked.bind(this); | 454 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 | 455 |
464 // Execute first-run actions if a window is open already, otherwise it | 456 // Execute first-run actions if a window is open already, otherwise it |
465 // will happen in applyToWindow() when a window is opened. | 457 // will happen in applyToWindow() when a window is opened. |
466 this.firstRunActions(this.currentWindow); | 458 this.firstRunActions(this.currentWindow); |
467 }, | 459 }, |
468 | 460 |
469 addToolbarButton: function() | 461 addToolbarButton: function() |
470 { | 462 { |
471 let {WindowObserver} = require("windowObserver"); | 463 let {WindowObserver} = require("windowObserver"); |
472 new WindowObserver(this); | 464 new WindowObserver(this); |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
924 notifyUser(); | 916 notifyUser(); |
925 } | 917 } |
926 }, false); | 918 }, false); |
927 request.send(); | 919 request.send(); |
928 } | 920 } |
929 else | 921 else |
930 notifyUser(); | 922 notifyUser(); |
931 }, | 923 }, |
932 | 924 |
933 /** | 925 /** |
934 * Called whenever subscribeLinkHandler.js intercepts clicks on abp: links | 926 * Called whenever child/subscribeLinks module intercepts clicks on abp: links |
935 * as well as links to subscribe.adblockplus.org. | 927 * as well as links to subscribe.adblockplus.org. |
936 */ | 928 */ |
937 subscribeLinkClicked: function(message) | 929 subscribeLinkClicked: function({title, url, |
930 mainSubscriptionTitle, mainSubscriptionURL}) | |
938 { | 931 { |
939 let {title, url, mainSubscriptionTitle, mainSubscriptionURL} = message.data; | |
940 if (!url) | 932 if (!url) |
941 return; | 933 return; |
942 | 934 |
943 // Default title to the URL | 935 // Default title to the URL |
944 if (!title) | 936 if (!title) |
945 title = url; | 937 title = url; |
946 | 938 |
947 // Main subscription needs both title and URL | 939 // Main subscription needs both title and URL |
948 if (mainSubscriptionTitle && !mainSubscriptionURL) | 940 if (mainSubscriptionTitle && !mainSubscriptionURL) |
949 mainSubscriptionTitle = null; | 941 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)], | 1896 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)], |
1905 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa tegory.bind(Notification, "*", null)] | 1897 ["abp-command-toggleshownotifications", "command", Notification.toggleIgnoreCa tegory.bind(Notification, "*", null)] |
1906 ]; | 1898 ]; |
1907 | 1899 |
1908 onShutdown.add(function() | 1900 onShutdown.add(function() |
1909 { | 1901 { |
1910 for (let window of UI.applicationWindows) | 1902 for (let window of UI.applicationWindows) |
1911 if (UI.isBottombarOpen(window)) | 1903 if (UI.isBottombarOpen(window)) |
1912 UI.toggleBottombar(window); | 1904 UI.toggleBottombar(window); |
1913 }); | 1905 }); |
OLD | NEW |