Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: lib/ui.js

Issue 11165026: Show notifications on startup (Closed)
Left Patch Set: Addressed issues Created July 19, 2013, 5:06 p.m.
Right Patch Set: Address remaining issue Created July 20, 2013, 10:53 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « lib/notification.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 }.bind(this)); 424 }.bind(this));
425 FilterNotifier.addListener(function(action) 425 FilterNotifier.addListener(function(action)
426 { 426 {
427 if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(actio n) || action == "load") 427 if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(actio n) || action == "load")
428 this.updateState(); 428 this.updateState();
429 }.bind(this)); 429 }.bind(this));
430 430
431 notificationTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); 431 notificationTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
432 notificationTimer.initWithCallback(this._showNextNotification.bind(this), 432 notificationTimer.initWithCallback(this._showNextNotification.bind(this),
433 3 * 60 * 1000, Ci.nsITimer.TYPE_ONE_SHOT) ; 433 3 * 60 * 1000, Ci.nsITimer.TYPE_ONE_SHOT) ;
434 onShutdown.add(function() notificationTimer.cancel()); 434 onShutdown.add(function() notificationTimer.cancel());
Wladimir Palant 2013/07/20 07:18:07 We need to verify that this doesn't cause an error
Felix Dahlke 2013/07/20 23:00:51 I haven't see us do that in other places, so it se
Wladimir Palant 2013/07/21 11:30:17 I other places we are using repeating timers, not
435 }, 435 },
436 436
437 /** 437 /**
438 * Will be set to true after the check whether first-run actions should run 438 * Will be set to true after the check whether first-run actions should run
439 * has been performed. 439 * has been performed.
440 * @type Boolean 440 * @type Boolean
441 */ 441 */
442 firstRunDone: false, 442 firstRunDone: false,
443 443
444 /** 444 /**
(...skipping 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 1984
1985 let links = window.document.querySelectorAll("#abp-notification-message a"); 1985 let links = window.document.querySelectorAll("#abp-notification-message a");
1986 for each (let link in links) 1986 for each (let link in links)
1987 { 1987 {
1988 let url = link.href; 1988 let url = link.href;
1989 let ui = this; 1989 let ui = this;
1990 link.onclick = function(event) 1990 link.onclick = function(event)
1991 { 1991 {
1992 event.preventDefault(); 1992 event.preventDefault();
1993 event.stopPropagation(); 1993 event.stopPropagation();
1994 if (!/^https?:\/\//.test(url))
1995 {
1996 Cu.reportError("Illegal link scheme in URL: " + url);
1997 return;
1998 }
Wladimir Palant 2013/07/20 07:18:07 The URL no longer comes from server so we can just
1999 ui.loadInBrowser(url, window); 1994 ui.loadInBrowser(url, window);
2000 }; 1995 };
2001 } 1996 }
2002 1997
2003 let panel = window.document.getElementById("abp-notification"); 1998 let panel = window.document.getElementById("abp-notification");
2004 panel.openPopup(button, "bottomcenter topcenter", 0, 0, false, false, null); 1999 panel.openPopup(button, "bottomcenter topcenter", 0, 0, false, false, null);
2005 } 2000 }
2006 }; 2001 };
2007 UI.onPopupShowing = UI.onPopupShowing.bind(UI); 2002 UI.onPopupShowing = UI.onPopupShowing.bind(UI);
2008 UI.onKeyPress = UI.onKeyPress.bind(UI); 2003 UI.onKeyPress = UI.onKeyPress.bind(UI);
(...skipping 22 matching lines...) Expand all
2031 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)], 2026 ["abp-command-contribute", "command", UI.openContributePage.bind(UI)],
2032 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)] 2027 ["abp-command-contribute-hide", "command", UI.hideContributeButton.bind(UI)]
2033 ]; 2028 ];
2034 2029
2035 onShutdown.add(function() 2030 onShutdown.add(function()
2036 { 2031 {
2037 for (let window in UI.applicationWindows) 2032 for (let window in UI.applicationWindows)
2038 if (UI.isBottombarOpen(window)) 2033 if (UI.isBottombarOpen(window))
2039 UI.toggleBottombar(window); 2034 UI.toggleBottombar(window);
2040 }); 2035 });
LEFTRIGHT

Powered by Google App Engine
This is Rietveld