| 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-2015 Eyeo GmbH | 3  * Copyright (C) 2006-2015 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 412         for (let window of this.applicationWindows) | 412         for (let window of this.applicationWindows) | 
| 413           this.updateStatusbarIcon(window); | 413           this.updateStatusbarIcon(window); | 
| 414       } | 414       } | 
| 415     }.bind(this)); | 415     }.bind(this)); | 
| 416     FilterNotifier.addListener(function(action) | 416     FilterNotifier.addListener(function(action) | 
| 417     { | 417     { | 
| 418       if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(actio
      n) || action == "load") | 418       if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(actio
      n) || action == "load") | 
| 419         this.updateState(); | 419         this.updateState(); | 
| 420     }.bind(this)); | 420     }.bind(this)); | 
| 421 | 421 | 
| 422     notificationTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); | 422     Notification.addShowListener(notification => | 
| 423     notificationTimer.initWithCallback(this.showNextNotification.bind(this), | 423     { | 
| 424                                        3 * 60 * 1000, Ci.nsITimer.TYPE_ONE_SHOT)
      ; | 424       let window = this.currentWindow; | 
| 425     onShutdown.add(() => notificationTimer.cancel()); | 425       if (!window) | 
|  | 426         return; | 
|  | 427 | 
|  | 428       let button = window.document.getElementById("abp-toolbarbutton") | 
|  | 429           || window.document.getElementById("abp-status"); | 
|  | 430       if (!button) | 
|  | 431         return; | 
|  | 432 | 
|  | 433       this._showNotification(window, button, notification); | 
|  | 434     }); | 
| 426 | 435 | 
| 427     // Add "anti-adblock messages" notification | 436     // Add "anti-adblock messages" notification | 
| 428     initAntiAdblockNotification(); | 437     initAntiAdblockNotification(); | 
| 429 | 438 | 
| 430     let documentCreationObserver = { | 439     let documentCreationObserver = { | 
| 431       observe: function(subject, topic, data) | 440       observe: function(subject, topic, data) | 
| 432       { | 441       { | 
| 433         if (!(subject instanceof Ci.nsIDOMWindow)) | 442         if (!(subject instanceof Ci.nsIDOMWindow)) | 
| 434           return; | 443           return; | 
| 435 | 444 | 
| 436         this.showNextNotification(subject.location.href); | 445         Notification.showNext(subject.location.href); | 
| 437       }.bind(UI) | 446       }.bind(UI) | 
| 438     }; | 447     }; | 
| 439     Services.obs.addObserver(documentCreationObserver, "content-document-global-
      created", false); | 448     Services.obs.addObserver(documentCreationObserver, "content-document-global-
      created", false); | 
| 440     onShutdown.add(function() | 449     onShutdown.add(function() | 
| 441     { | 450     { | 
| 442       Services.obs.removeObserver(documentCreationObserver, "content-document-gl
      obal-created", false); | 451       Services.obs.removeObserver(documentCreationObserver, "content-document-gl
      obal-created", false); | 
| 443     }); | 452     }); | 
| 444 | 453 | 
| 445     // Execute first-run actions if a window is open already, otherwise it | 454     // Execute first-run actions if a window is open already, otherwise it | 
| 446     // will happen in applyToWindow() when a window is opened. | 455     // will happen in applyToWindow() when a window is opened. | 
| (...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1842     Prefs.hideContributeButton = true; | 1851     Prefs.hideContributeButton = true; | 
| 1843 | 1852 | 
| 1844     for (let id of ["abp-status-contributebutton", "abp-toolbar-contributebutton
      ", "abp-menuitem-contributebutton"]) | 1853     for (let id of ["abp-status-contributebutton", "abp-toolbar-contributebutton
      ", "abp-menuitem-contributebutton"]) | 
| 1845     { | 1854     { | 
| 1846       let button = window.document.getElementById(id); | 1855       let button = window.document.getElementById(id); | 
| 1847       if (button) | 1856       if (button) | 
| 1848         button.hidden = true; | 1857         button.hidden = true; | 
| 1849     } | 1858     } | 
| 1850   }, | 1859   }, | 
| 1851 | 1860 | 
| 1852   showNextNotification: function(url) |  | 
| 1853   { |  | 
| 1854     let window = this.currentWindow; |  | 
| 1855     if (!window) |  | 
| 1856       return; |  | 
| 1857 |  | 
| 1858     let button = window.document.getElementById("abp-toolbarbutton") |  | 
| 1859       || window.document.getElementById("abp-status"); |  | 
| 1860     if (!button) |  | 
| 1861       return; |  | 
| 1862 |  | 
| 1863     let notification = Notification.getNextToShow(url); |  | 
| 1864     if (!notification) |  | 
| 1865       return; |  | 
| 1866 |  | 
| 1867     this._showNotification(window, button, notification); |  | 
| 1868   }, |  | 
| 1869 |  | 
| 1870   _showNotification: function(window, button, notification) | 1861   _showNotification: function(window, button, notification) | 
| 1871   { | 1862   { | 
| 1872     let panel = window.document.getElementById("abp-notification"); | 1863     let panel = window.document.getElementById("abp-notification"); | 
| 1873     if (panel.state !== "closed") | 1864     if (panel.state !== "closed") | 
| 1874       return; | 1865       return; | 
| 1875 | 1866 | 
| 1876     function insertMessage(element, text, links) | 1867     function insertMessage(element, text, links) | 
| 1877     { | 1868     { | 
| 1878       let match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(text); | 1869       let match = /^(.*?)<(a|strong)>(.*?)<\/\2>(.*)$/.exec(text); | 
| 1879       if (!match) | 1870       if (!match) | 
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1925       { | 1916       { | 
| 1926         event.preventDefault(); | 1917         event.preventDefault(); | 
| 1927         event.stopPropagation(); | 1918         event.stopPropagation(); | 
| 1928         panel.hidePopup(); | 1919         panel.hidePopup(); | 
| 1929         Notification.triggerQuestionListeners(notification.id, approved) | 1920         Notification.triggerQuestionListeners(notification.id, approved) | 
| 1930         Notification.markAsShown(notification.id); | 1921         Notification.markAsShown(notification.id); | 
| 1931       } | 1922       } | 
| 1932       window.document.getElementById("abp-notification-yes").onclick = buttonHan
      dler.bind(null, true); | 1923       window.document.getElementById("abp-notification-yes").onclick = buttonHan
      dler.bind(null, true); | 
| 1933       window.document.getElementById("abp-notification-no").onclick = buttonHand
      ler.bind(null, false); | 1924       window.document.getElementById("abp-notification-no").onclick = buttonHand
      ler.bind(null, false); | 
| 1934     } | 1925     } | 
|  | 1926     else | 
|  | 1927       Notification.markAsShown(notification.id); | 
| 1935 | 1928 | 
| 1936     panel.setAttribute("class", "abp-" + notification.type); | 1929     panel.setAttribute("class", "abp-" + notification.type); | 
| 1937     panel.setAttribute("noautohide", notification.type === "question"); | 1930     panel.setAttribute("noautohide", notification.type === "question"); | 
| 1938     panel.openPopup(button, "bottomcenter topcenter", 0, 0, false, false, null); | 1931     panel.openPopup(button, "bottomcenter topcenter", 0, 0, false, false, null); | 
| 1939   } | 1932   } | 
| 1940 }; | 1933 }; | 
| 1941 UI.onPopupShowing = UI.onPopupShowing.bind(UI); | 1934 UI.onPopupShowing = UI.onPopupShowing.bind(UI); | 
| 1942 UI.onKeyPress = UI.onKeyPress.bind(UI); | 1935 UI.onKeyPress = UI.onKeyPress.bind(UI); | 
| 1943 UI.onIconClick = UI.onIconClick.bind(UI); | 1936 UI.onIconClick = UI.onIconClick.bind(UI); | 
| 1944 UI.init(); | 1937 UI.init(); | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 1963   ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 1956   ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], | 
| 1964   ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 1957   ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] | 
| 1965 ]; | 1958 ]; | 
| 1966 | 1959 | 
| 1967 onShutdown.add(function() | 1960 onShutdown.add(function() | 
| 1968 { | 1961 { | 
| 1969   for (let window of UI.applicationWindows) | 1962   for (let window of UI.applicationWindows) | 
| 1970     if (UI.isBottombarOpen(window)) | 1963     if (UI.isBottombarOpen(window)) | 
| 1971       UI.toggleBottombar(window); | 1964       UI.toggleBottombar(window); | 
| 1972 }); | 1965 }); | 
| OLD | NEW | 
|---|