| Left: | ||
| Right: | 
| LEFT | RIGHT | 
|---|---|
| 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 547 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 interval = 10000; | 558 interval = 10000; | 
| 559 } | 559 } | 
| 560 iconAnimationTimer = setTimeout(animationStep, interval); | 560 iconAnimationTimer = setTimeout(animationStep, interval); | 
| 561 } | 561 } | 
| 562 animationStep(); | 562 animationStep(); | 
| 563 }); | 563 }); | 
| 564 } | 564 } | 
| 565 | 565 | 
| 566 function prepareNotificationIconAndPopup() | 566 function prepareNotificationIconAndPopup() | 
| 567 { | 567 { | 
| 568 function refreshAll(tabs) | |
| 569 { | |
| 570 tabs.forEach(refreshIconAndContextMenu); | |
| 571 } | |
| 572 | |
| 573 activeNotification.onClicked = function() | 568 activeNotification.onClicked = function() | 
| 574 { | 569 { | 
| 570 var tab = animatedIconTab; | |
| 575 stopIconAnimation(); | 571 stopIconAnimation(); | 
| 576 activeNotification = null; | 572 activeNotification = null; | 
| 577 chrome.tabs.query(null, refreshAll); | 573 refreshIconAndContextMenu(tab); | 
| 578 }; | 574 }; | 
| 579 | 575 | 
| 580 chrome.tabs.query({active: true, currentWindow: true}, refreshAll); | 576 chrome.windows.getLastFocused({populate: true}, function(window) | 
| 
 
Felix Dahlke
2013/07/23 10:38:08
I just noticed that I still use currentWindow here
 
Felix Dahlke
2013/07/23 11:24:57
Done. Note that this was incorrect anyway, the cur
 
 | |
| 577 { | |
| 578 chrome.tabs.query({active: true, windowId: window.id}, function(tabs) | |
| 579 { | |
| 580 tabs.forEach(refreshIconAndContextMenu); | |
| 581 }); | |
| 582 }); | |
| 581 } | 583 } | 
| 582 | 584 | 
| 583 function showNotification(notification) | 585 function showNotification(notification) | 
| 584 { | 586 { | 
| 585 activeNotification = notification; | 587 activeNotification = notification; | 
| 586 | 588 | 
| 587 if (activeNotification.severity === "critical") | 589 if (activeNotification.severity === "critical") | 
| 588 { | 590 { | 
| 589 var notification = webkitNotifications.createHTMLNotification("notification. html"); | 591 var notification = webkitNotifications.createHTMLNotification("notification. html"); | 
| 590 notification.show(); | 592 notification.show(); | 
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 728 { | 730 { | 
| 729 chrome.tabs.sendRequest(tabId, {reqtype: "clickhide-deactivate"}) | 731 chrome.tabs.sendRequest(tabId, {reqtype: "clickhide-deactivate"}) | 
| 730 if(changeInfo.status == "loading") | 732 if(changeInfo.status == "loading") | 
| 731 refreshIconAndContextMenu(tab); | 733 refreshIconAndContextMenu(tab); | 
| 732 }); | 734 }); | 
| 733 | 735 | 
| 734 // Refresh icon when switching tabs or windows | 736 // Refresh icon when switching tabs or windows | 
| 735 chrome.tabs.onActivated.addListener(function(activeInfo) | 737 chrome.tabs.onActivated.addListener(function(activeInfo) | 
| 736 { | 738 { | 
| 737 refreshIconAndContextMenu(animatedIconTab); | 739 refreshIconAndContextMenu(animatedIconTab); | 
| 738 chrome.tabs.get(activeInfo.tabId, function(tab) | 740 chrome.tabs.get(activeInfo.tabId, refreshIconAndContextMenu); | 
| 739 { | |
| 740 refreshIconAndContextMenu(tab); | |
| 741 }); | |
| 742 }); | 741 }); | 
| 743 chrome.windows.onFocusChanged.addListener(function(windowId) | 742 chrome.windows.onFocusChanged.addListener(function(windowId) | 
| 744 { | 743 { | 
| 745 refreshIconAndContextMenu(animatedIconTab); | 744 refreshIconAndContextMenu(animatedIconTab); | 
| 746 chrome.tabs.query({active: true, windowId: windowId}, function(tabs) | 745 chrome.tabs.query({active: true, windowId: windowId}, function(tabs) | 
| 747 { | 746 { | 
| 748 refreshIconAndContextMenu(tabs[0]); | 747 tabs.forEach(refreshIconAndContextMenu); | 
| 749 }); | 748 }); | 
| 750 }); | 749 }); | 
| 751 | 750 | 
| 752 setTimeout(function() | 751 setTimeout(function() | 
| 753 { | 752 { | 
| 754 var notificationToShow = Notification.getNextToShow(); | 753 var notificationToShow = Notification.getNextToShow(); | 
| 755 if (notificationToShow) | 754 if (notificationToShow) | 
| 756 showNotification(notificationToShow); | 755 showNotification(notificationToShow); | 
| 757 }, 3 * 60 * 1000); | 756 }, 3 * 60 * 1000); | 
| LEFT | RIGHT |