| 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-2013 Eyeo GmbH | 3 * Copyright (C) 2006-2013 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 11 matching lines...) Expand all Loading... | |
| 22 let {Prefs} = require("prefs"); | 22 let {Prefs} = require("prefs"); |
| 23 let {Policy} = require("contentPolicy"); | 23 let {Policy} = require("contentPolicy"); |
| 24 let {FilterListener} = require("filterListener"); | 24 let {FilterListener} = require("filterListener"); |
| 25 let {FilterStorage} = require("filterStorage"); | 25 let {FilterStorage} = require("filterStorage"); |
| 26 let {FilterNotifier} = require("filterNotifier"); | 26 let {FilterNotifier} = require("filterNotifier"); |
| 27 let {RequestNotifier} = require("requestNotifier"); | 27 let {RequestNotifier} = require("requestNotifier"); |
| 28 let {Filter} = require("filterClasses"); | 28 let {Filter} = require("filterClasses"); |
| 29 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub scriptionClasses"); | 29 let {Subscription, SpecialSubscription, DownloadableSubscription} = require("sub scriptionClasses"); |
| 30 let {Synchronizer} = require("synchronizer"); | 30 let {Synchronizer} = require("synchronizer"); |
| 31 let {KeySelector} = require("keySelector"); | 31 let {KeySelector} = require("keySelector"); |
| 32 let {Notification} = require("notification"); | |
| 32 | 33 |
| 33 /** | 34 /** |
| 34 * Filter corresponding with "disable on site" menu item (set in fillIconMent()) . | 35 * Filter corresponding with "disable on site" menu item (set in fillIconMent()) . |
| 35 * @type Filter | 36 * @type Filter |
| 36 */ | 37 */ |
| 37 let siteWhitelist = null; | 38 let siteWhitelist = null; |
| 38 /** | 39 /** |
| 39 * Filter corresponding with "disable on site" menu item (set in fillIconMenu()) . | 40 * Filter corresponding with "disable on site" menu item (set in fillIconMenu()) . |
| 40 * @type Filter | 41 * @type Filter |
| 41 */ | 42 */ |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 { | 414 { |
| 414 for (let window in this.applicationWindows) | 415 for (let window in this.applicationWindows) |
| 415 this.updateStatusbarIcon(window); | 416 this.updateStatusbarIcon(window); |
| 416 } | 417 } |
| 417 }.bind(this)); | 418 }.bind(this)); |
| 418 FilterNotifier.addListener(function(action) | 419 FilterNotifier.addListener(function(action) |
| 419 { | 420 { |
| 420 if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(actio n) || action == "load") | 421 if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(actio n) || action == "load") |
| 421 this.updateState(); | 422 this.updateState(); |
| 422 }.bind(this)); | 423 }.bind(this)); |
| 424 | |
| 425 let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); | |
|
Wladimir Palant
2013/07/19 15:17:52
Sure, we do:
onShutdown.add(function() timer.ca
Felix Dahlke
2013/07/19 17:07:01
Done.
| |
| 426 timer.initWithCallback(function() | |
| 427 { | |
| 428 let notificationToShow = Notification.getNextToShow(); | |
| 429 if (notificationToShow) | |
| 430 this._showNotification(notificationToShow); | |
| 431 }.bind(this), 3 * 60 * 1000, Ci.nsITimer.TYPE_ONE_SHOT); | |
| 423 }, | 432 }, |
| 424 | 433 |
| 425 /** | 434 /** |
| 426 * Will be set to true after the check whether first-run actions should run | 435 * Will be set to true after the check whether first-run actions should run |
| 427 * has been performed. | 436 * has been performed. |
| 428 * @type Boolean | 437 * @type Boolean |
| 429 */ | 438 */ |
| 430 firstRunDone: false, | 439 firstRunDone: false, |
| 431 | 440 |
| 432 /** | 441 /** |
| (...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1907 hideContributeButton: function(/**Window*/ window) | 1916 hideContributeButton: function(/**Window*/ window) |
| 1908 { | 1917 { |
| 1909 Prefs.hideContributeButton = true; | 1918 Prefs.hideContributeButton = true; |
| 1910 | 1919 |
| 1911 for each (let id in ["abp-status-contributebutton", "abp-toolbar-contributeb utton", "abp-menuitem-contributebutton"]) | 1920 for each (let id in ["abp-status-contributebutton", "abp-toolbar-contributeb utton", "abp-menuitem-contributebutton"]) |
| 1912 { | 1921 { |
| 1913 let button = window.document.getElementById(id); | 1922 let button = window.document.getElementById(id); |
| 1914 if (button) | 1923 if (button) |
| 1915 button.hidden = true; | 1924 button.hidden = true; |
| 1916 } | 1925 } |
| 1926 }, | |
| 1927 | |
| 1928 _showNotification: function(notification) | |
| 1929 { | |
| 1930 let window = null; | |
| 1931 for (window in this.applicationWindows) | |
| 1932 break; | |
| 1933 | |
| 1934 if (!window) | |
| 1935 return; | |
|
Wladimir Palant
2013/07/19 15:17:52
We already marked the notification as shown at thi
Felix Dahlke
2013/07/19 17:07:01
Done.
| |
| 1936 | |
| 1937 let button = window.document.getElementById("abp-toolbarbutton") | |
| 1938 || window.document.getElementById("abp-status"); | |
| 1939 if (!button) | |
| 1940 return; | |
| 1941 | |
| 1942 let texts = Notification.getLocalizedTexts(notification); | |
| 1943 let titleElement = window.document.getElementById("abp-notification-title"); | |
| 1944 titleElement.setAttribute("value", texts.title); | |
| 1945 let messageElement = window.document.getElementById("abp-notification-messag e"); | |
| 1946 let message = texts.message.replace(/<(\/?)a(.*?)>/g, "<$1html:a$2>"); | |
| 1947 messageElement.innerHTML = message; | |
| 1948 | |
| 1949 let links = window.document.querySelectorAll("#abp-notification-message a"); | |
| 1950 for each (let link in links) | |
| 1951 { | |
| 1952 let url = link.href; | |
| 1953 let ui = this; | |
| 1954 link.onclick = function(event) | |
| 1955 { | |
| 1956 event.preventDefault(); | |
| 1957 event.stopPropagation(); | |
| 1958 ui.loadInBrowser(url, window); | |
| 1959 }; | |
| 1960 } | |
| 1961 | |
| 1962 let panel = window.document.getElementById("abp-notification"); | |
| 1963 panel.openPopup(button, "bottomcenter topcenter", 0, 0, false, false, null); | |
| 1917 } | 1964 } |
| 1918 }; | 1965 }; |
| 1919 UI.onPopupShowing = UI.onPopupShowing.bind(UI); | 1966 UI.onPopupShowing = UI.onPopupShowing.bind(UI); |
| 1920 UI.onKeyPress = UI.onKeyPress.bind(UI); | 1967 UI.onKeyPress = UI.onKeyPress.bind(UI); |
| 1921 UI.onIconClick = UI.onIconClick.bind(UI); | 1968 UI.onIconClick = UI.onIconClick.bind(UI); |
| 1922 UI.onToolbarCustomization = UI.onToolbarCustomization.bind(UI); | 1969 UI.onToolbarCustomization = UI.onToolbarCustomization.bind(UI); |
| 1923 UI.init(); | 1970 UI.init(); |
| 1924 | 1971 |
| 1925 /** | 1972 /** |
| 1926 * List of event handers to be registered for each window. For each event | 1973 * List of event handers to be registered for each window. For each event |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1943 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1990 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], |
| 1944 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1991 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] |
| 1945 ]; | 1992 ]; |
| 1946 | 1993 |
| 1947 onShutdown.add(function() | 1994 onShutdown.add(function() |
| 1948 { | 1995 { |
| 1949 for (let window in UI.applicationWindows) | 1996 for (let window in UI.applicationWindows) |
| 1950 if (UI.isBottombarOpen(window)) | 1997 if (UI.isBottombarOpen(window)) |
| 1951 UI.toggleBottombar(window); | 1998 UI.toggleBottombar(window); |
| 1952 }); | 1999 }); |
| OLD | NEW |