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

Side by Side Diff: background.js

Issue 5739851907334144: Update browser actions everytime filters are loaded or saved (Closed)
Patch Set: Created Feb. 24, 2014, 4:17 p.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 | popup.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 <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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 var addonVersion = require("info").addonVersion; 56 var addonVersion = require("info").addonVersion;
57 var prevVersion = localStorage.currentVersion; 57 var prevVersion = localStorage.currentVersion;
58 if (prevVersion != addonVersion) 58 if (prevVersion != addonVersion)
59 { 59 {
60 isFirstRun = !prevVersion; 60 isFirstRun = !prevVersion;
61 localStorage.currentVersion = addonVersion; 61 localStorage.currentVersion = addonVersion;
62 if (!importingOldData) 62 if (!importingOldData)
63 addSubscription(prevVersion); 63 addSubscription(prevVersion);
64 } 64 }
65 } 65 }
66
67 // update browser actions when whitelisting might have changed,
68 // due to loading filters or saving filter changes
69 if (action == "load" || action == "save")
70 {
71 ext.windows.getAll(function(windows)
72 {
73 for (var i = 0; i < windows.length; i++)
74 {
75 windows[i].getAllTabs(function(tabs)
76 {
77 tabs.forEach(refreshIconAndContextMenu);
78 });
79 }
80 });
81 }
66 }); 82 });
67 83
68 // Special-case domains for which we cannot use style-based hiding rules. 84 // Special-case domains for which we cannot use style-based hiding rules.
69 // See http://crbug.com/68705. 85 // See http://crbug.com/68705.
70 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; 86 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"];
71 87
72 function removeDeprecatedOptions() 88 function removeDeprecatedOptions()
73 { 89 {
74 var deprecatedOptions = ["specialCaseYouTube", "experimental", "disableInlineT extAds"]; 90 var deprecatedOptions = ["specialCaseYouTube", "experimental", "disableInlineT extAds"];
75 deprecatedOptions.forEach(function(option) 91 deprecatedOptions.forEach(function(option)
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 // sendResponse asynchronously 410 // sendResponse asynchronously
395 return true; 411 return true;
396 } 412 }
397 break; 413 break;
398 default: 414 default:
399 sendResponse({}); 415 sendResponse({});
400 break; 416 break;
401 } 417 }
402 }); 418 });
403 419
404 // Show icon as browser action for all tabs that already exist
405 ext.windows.getAll(function(windows)
406 {
407 for (var i = 0; i < windows.length; i++)
408 {
409 windows[i].getAllTabs(function(tabs)
410 {
411 tabs.forEach(refreshIconAndContextMenu);
412 });
413 }
414 });
415
416 // Update icon if a tab changes location 420 // Update icon if a tab changes location
417 ext.tabs.onLoading.addListener(function(tab) 421 ext.tabs.onLoading.addListener(function(tab)
418 { 422 {
419 tab.sendMessage({type: "clickhide-deactivate"}); 423 tab.sendMessage({type: "clickhide-deactivate"});
420 refreshIconAndContextMenu(tab); 424 refreshIconAndContextMenu(tab);
421 }); 425 });
422 426
423 setTimeout(function() 427 setTimeout(function()
424 { 428 {
425 var notificationToShow = Notification.getNextToShow(); 429 var notificationToShow = Notification.getNextToShow();
426 if (notificationToShow) 430 if (notificationToShow)
427 showNotification(notificationToShow); 431 showNotification(notificationToShow);
428 }, 3 * 60 * 1000); 432 }, 3 * 60 * 1000);
OLDNEW
« no previous file with comments | « no previous file | popup.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld