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

Side by Side Diff: background.js

Issue 8792018: Topic 11477 - Whitelisting doesn`t deal with frames correctly (Closed)
Patch Set: Created Nov. 6, 2012, 11:05 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 | webrequest.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 the Adblock Plus extension, 2 * This file is part of the Adblock Plus extension,
3 * Copyright (C) 2006-2012 Eyeo GmbH 3 * Copyright (C) 2006-2012 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 if ("experimental" in localStorage) 80 if ("experimental" in localStorage)
81 delete localStorage.experimental; 81 delete localStorage.experimental;
82 } 82 }
83 83
84 // Upgrade options before we do anything else. 84 // Upgrade options before we do anything else.
85 setDefaultOptions(); 85 setDefaultOptions();
86 86
87 /** 87 /**
88 * Checks whether a page is whitelisted. 88 * Checks whether a page is whitelisted.
89 * @param {String} url 89 * @param {String} url
90 * @param {String} [parentUrl] URL of the parent frame
90 * @param {String} [type] content type to be checked, default is "DOCUMENT" 91 * @param {String} [type] content type to be checked, default is "DOCUMENT"
91 * @return {Filter} filter that matched the URL or null if not whitelisted 92 * @return {Filter} filter that matched the URL or null if not whitelisted
92 */ 93 */
93 function isWhitelisted(url, type) 94 function isWhitelisted(url, parentUrl, type)
94 { 95 {
95 // Ignore fragment identifier 96 // Ignore fragment identifier
96 var index = url.indexOf("#"); 97 var index = url.indexOf("#");
97 if (index >= 0) 98 if (index >= 0)
98 url = url.substring(0, index); 99 url = url.substring(0, index);
99 100
100 var result = defaultMatcher.matchesAny(url, type || "DOCUMENT", extractHostFro mURL(url), false); 101 var result = defaultMatcher.matchesAny(url, type || "DOCUMENT", extractHostFro mURL(parentUrl || url), false);
101 return (result instanceof WhitelistFilter ? result : null); 102 return (result instanceof WhitelistFilter ? result : null);
102 } 103 }
103 104
104 // Adds or removes page action icon according to options. 105 // Adds or removes page action icon according to options.
105 function refreshIconAndContextMenu(tab) 106 function refreshIconAndContextMenu(tab)
106 { 107 {
107 // The tab could have been closed by the time this function is called 108 // The tab could have been closed by the time this function is called
108 if(!tab) 109 if(!tab)
109 return; 110 return;
110 111
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 refreshIconAndContextMenu(windows[i].tabs[j]); 597 refreshIconAndContextMenu(windows[i].tabs[j]);
597 }); 598 });
598 599
599 // Update icon if a tab changes location 600 // Update icon if a tab changes location
600 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) 601 chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab)
601 { 602 {
602 chrome.tabs.sendRequest(tabId, {reqtype: "clickhide-deactivate"}) 603 chrome.tabs.sendRequest(tabId, {reqtype: "clickhide-deactivate"})
603 if(changeInfo.status == "loading") 604 if(changeInfo.status == "loading")
604 refreshIconAndContextMenu(tab); 605 refreshIconAndContextMenu(tab);
605 }); 606 });
OLDNEW
« no previous file with comments | « no previous file | webrequest.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld