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

Side by Side Diff: background.js

Issue 4840054052618240: Issue 1428 - Disable "Block Element" on non-HTML pages (Closed)
Patch Set: Removed outdated comment Created Sept. 26, 2014, 10:21 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 | include.postload.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-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // update browser actions when whitelisting might have changed, 85 // update browser actions when whitelisting might have changed,
86 // due to loading filters or saving filter changes 86 // due to loading filters or saving filter changes
87 if (action == "load" || action == "save") 87 if (action == "load" || action == "save")
88 refreshIconAndContextMenuForAllPages(); 88 refreshIconAndContextMenuForAllPages();
89 }); 89 });
90 90
91 // Special-case domains for which we cannot use style-based hiding rules. 91 // Special-case domains for which we cannot use style-based hiding rules.
92 // See http://crbug.com/68705. 92 // See http://crbug.com/68705.
93 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"]; 93 var noStyleRulesHosts = ["mail.google.com", "mail.yahoo.com", "www.google.com"];
94 94
95 var htmlPages = new ext.PageMap();
96
95 function removeDeprecatedOptions() 97 function removeDeprecatedOptions()
96 { 98 {
97 var deprecatedOptions = ["specialCaseYouTube", "experimental", "disableInlineT extAds"]; 99 var deprecatedOptions = ["specialCaseYouTube", "experimental", "disableInlineT extAds"];
98 deprecatedOptions.forEach(function(option) 100 deprecatedOptions.forEach(function(option)
99 { 101 {
100 if (option in ext.storage) 102 if (option in ext.storage)
101 delete ext.storage[option]; 103 delete ext.storage[option];
102 }); 104 });
103 } 105 }
104 106
(...skipping 26 matching lines...) Expand all
131 else 133 else
132 iconFilename = "icons/abp-$size.png"; 134 iconFilename = "icons/abp-$size.png";
133 135
134 page.browserAction.setIcon(iconFilename); 136 page.browserAction.setIcon(iconFilename);
135 iconAnimation.registerPage(page, iconFilename); 137 iconAnimation.registerPage(page, iconFilename);
136 138
137 // show or hide the context menu entry dependent on whether 139 // show or hide the context menu entry dependent on whether
138 // adblocking is active on that page 140 // adblocking is active on that page
139 page.contextMenus.removeAll(); 141 page.contextMenus.removeAll();
140 142
141 if (Prefs.shouldShowBlockElementMenu && !whitelisted && /^https?:/.test(page.u rl)) 143 if (Prefs.shouldShowBlockElementMenu && !whitelisted && htmlPages.has(page))
142 page.contextMenus.create(contextMenuItem); 144 page.contextMenus.create(contextMenuItem);
143 } 145 }
144 146
145 function refreshIconAndContextMenuForAllPages() 147 function refreshIconAndContextMenuForAllPages()
146 { 148 {
147 ext.pages.query({}, function(pages) 149 ext.pages.query({}, function(pages)
148 { 150 {
149 pages.forEach(refreshIconAndContextMenu); 151 pages.forEach(refreshIconAndContextMenu);
150 }); 152 });
151 } 153 }
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 break; 555 break;
554 case "add-subscription": 556 case "add-subscription":
555 openOptions(function(page) 557 openOptions(function(page)
556 { 558 {
557 page.sendMessage(msg); 559 page.sendMessage(msg);
558 }); 560 });
559 break; 561 break;
560 case "add-sitekey": 562 case "add-sitekey":
561 processKey(msg.token, sender.page, sender.frame); 563 processKey(msg.token, sender.page, sender.frame);
562 break; 564 break;
565 case "report-html-page":
566 htmlPages.set(sender.page, null);
567 refreshIconAndContextMenu(sender.page);
568 break;
563 case "forward": 569 case "forward":
564 if (sender.page) 570 if (sender.page)
565 { 571 {
566 sender.page.sendMessage(msg.payload, sendResponse); 572 sender.page.sendMessage(msg.payload, sendResponse);
567 // Return true to indicate that we want to call 573 // Return true to indicate that we want to call
568 // sendResponse asynchronously 574 // sendResponse asynchronously
569 return true; 575 return true;
570 } 576 }
571 break; 577 break;
572 default: 578 default:
573 sendResponse({}); 579 sendResponse({});
574 break; 580 break;
575 } 581 }
576 }); 582 });
577 583
578 // update icon when page changes location 584 // update icon when page changes location
579 ext.pages.onLoading.addListener(function(page) 585 ext.pages.onLoading.addListener(function(page)
580 { 586 {
581 page.sendMessage({type: "clickhide-deactivate"}); 587 page.sendMessage({type: "clickhide-deactivate"});
582 refreshIconAndContextMenu(page); 588 refreshIconAndContextMenu(page);
583 }); 589 });
584 590
585 setTimeout(function() 591 setTimeout(function()
586 { 592 {
587 var notificationToShow = Notification.getNextToShow(); 593 var notificationToShow = Notification.getNextToShow();
588 if (notificationToShow) 594 if (notificationToShow)
589 showNotification(notificationToShow); 595 showNotification(notificationToShow);
590 }, 3 * 60 * 1000); 596 }, 3 * 60 * 1000);
OLDNEW
« no previous file with comments | « no previous file | include.postload.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld