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

Side by Side Diff: background.js

Issue 5196306347720704: Issue 1965 - Simplified and fixed missing image for icon animation (Closed)
Patch Set: Rebased and addressed comment Created Feb. 12, 2015, 11:15 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | lib/icon.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 23 matching lines...) Expand all
34 this.isFrameWhitelisted = isFrameWhitelisted; 34 this.isFrameWhitelisted = isFrameWhitelisted;
35 this.processKey = processKey; 35 this.processKey = processKey;
36 this.getKey = getKey; 36 this.getKey = getKey;
37 } 37 }
38 with(require("url")) 38 with(require("url"))
39 { 39 {
40 this.stringifyURL = stringifyURL; 40 this.stringifyURL = stringifyURL;
41 this.isThirdParty = isThirdParty; 41 this.isThirdParty = isThirdParty;
42 this.extractHostFromFrame = extractHostFromFrame; 42 this.extractHostFromFrame = extractHostFromFrame;
43 } 43 }
44 with(require("icon"))
45 {
46 this.updateIcon = updateIcon;
47 this.startIconAnimation = startIconAnimation;
48 this.stopIconAnimation = stopIconAnimation;
49 }
44 var FilterStorage = require("filterStorage").FilterStorage; 50 var FilterStorage = require("filterStorage").FilterStorage;
45 var ElemHide = require("elemHide").ElemHide; 51 var ElemHide = require("elemHide").ElemHide;
46 var defaultMatcher = require("matcher").defaultMatcher; 52 var defaultMatcher = require("matcher").defaultMatcher;
47 var Prefs = require("prefs").Prefs; 53 var Prefs = require("prefs").Prefs;
48 var Synchronizer = require("synchronizer").Synchronizer; 54 var Synchronizer = require("synchronizer").Synchronizer;
49 var Utils = require("utils").Utils; 55 var Utils = require("utils").Utils;
50 var NotificationStorage = require("notification").Notification; 56 var NotificationStorage = require("notification").Notification;
51 var initAntiAdblockNotification = require("antiadblockInit").initAntiAdblockNoti fication; 57 var initAntiAdblockNotification = require("antiadblockInit").initAntiAdblockNoti fication;
52 var parseFilters = require("filterValidation").parseFilters; 58 var parseFilters = require("filterValidation").parseFilters;
53 59
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 onclick: function(page) 133 onclick: function(page)
128 { 134 {
129 page.sendMessage({type: "clickhide-new-filter"}); 135 page.sendMessage({type: "clickhide-new-filter"});
130 } 136 }
131 }; 137 };
132 138
133 // Adds or removes browser action icon according to options. 139 // Adds or removes browser action icon according to options.
134 function refreshIconAndContextMenu(page) 140 function refreshIconAndContextMenu(page)
135 { 141 {
136 var whitelisted = isPageWhitelisted(page); 142 var whitelisted = isPageWhitelisted(page);
137 143 updateIcon(page, whitelisted);
138 var iconFilename;
139 if (whitelisted && require("info").platform != "safari")
140 // There is no grayscale version of the icon for whitelisted pages
141 // when using Safari, because icons are grayscale already and icons
142 // aren't per page in Safari.
143 iconFilename = "icons/abp-$size-whitelisted.png";
144 else
145 iconFilename = "icons/abp-$size.png";
146
147 page.browserAction.setIcon(iconFilename);
148 iconAnimation.registerPage(page, iconFilename);
149 144
150 // show or hide the context menu entry dependent on whether 145 // show or hide the context menu entry dependent on whether
151 // adblocking is active on that page 146 // adblocking is active on that page
152 page.contextMenus.removeAll(); 147 page.contextMenus.removeAll();
153
154 if (Prefs.shouldShowBlockElementMenu && !whitelisted && htmlPages.has(page)) 148 if (Prefs.shouldShowBlockElementMenu && !whitelisted && htmlPages.has(page))
155 page.contextMenus.create(contextMenuItem); 149 page.contextMenus.create(contextMenuItem);
156 } 150 }
157 151
158 function refreshIconAndContextMenuForAllPages() 152 function refreshIconAndContextMenuForAllPages()
159 { 153 {
160 ext.pages.query({}, function(pages) 154 ext.pages.query({}, function(pages)
161 { 155 {
162 pages.forEach(refreshIconAndContextMenu); 156 pages.forEach(refreshIconAndContextMenu);
163 }); 157 });
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 if (name == "shouldShowBlockElementMenu") 263 if (name == "shouldShowBlockElementMenu")
270 refreshIconAndContextMenuForAllPages(); 264 refreshIconAndContextMenuForAllPages();
271 }); 265 });
272 266
273 function prepareNotificationIconAndPopup() 267 function prepareNotificationIconAndPopup()
274 { 268 {
275 var animateIcon = (activeNotification.type !== "question"); 269 var animateIcon = (activeNotification.type !== "question");
276 activeNotification.onClicked = function() 270 activeNotification.onClicked = function()
277 { 271 {
278 if (animateIcon) 272 if (animateIcon)
279 iconAnimation.stop(); 273 stopIconAnimation();
280 notificationClosed(); 274 notificationClosed();
281 }; 275 };
282 if (animateIcon) 276 if (animateIcon)
283 iconAnimation.update(activeNotification.type); 277 startIconAnimation(activeNotification.type);
284 } 278 }
285 279
286 function openNotificationLinks() 280 function openNotificationLinks()
287 { 281 {
288 if (activeNotification.links) 282 if (activeNotification.links)
289 { 283 {
290 activeNotification.links.forEach(function(link) 284 activeNotification.links.forEach(function(link)
291 { 285 {
292 ext.windows.getLastFocused(function(win) 286 ext.windows.getLastFocused(function(win)
293 { 287 {
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 page.sendMessage({type: "clickhide-deactivate"}); 577 page.sendMessage({type: "clickhide-deactivate"});
584 refreshIconAndContextMenu(page); 578 refreshIconAndContextMenu(page);
585 }); 579 });
586 580
587 setTimeout(function() 581 setTimeout(function()
588 { 582 {
589 var notificationToShow = NotificationStorage.getNextToShow(); 583 var notificationToShow = NotificationStorage.getNextToShow();
590 if (notificationToShow) 584 if (notificationToShow)
591 showNotification(notificationToShow); 585 showNotification(notificationToShow);
592 }, 3 * 60 * 1000); 586 }, 3 * 60 * 1000);
OLDNEW
« no previous file with comments | « no previous file | lib/icon.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld