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

Delta Between Two Patch Sets: webrequest.js

Issue 5464830253203456: Refactored the abstraction layer to address prerendered pages on Safari caused by leaky abstraction (Closed)
Left Patch Set: Created Feb. 22, 2014, 10:45 a.m.
Right Patch Set: Addressed comments Created April 11, 2014, 2:47 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « stats.js ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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-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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 var FilterNotifier = require("filterNotifier").FilterNotifier; 18 var FilterNotifier = require("filterNotifier").FilterNotifier;
19 var platform = require("info").platform;
19 20
20 var onFilterChangeTimeout = null; 21 var onFilterChangeTimeout = null;
21 function onFilterChange() 22 function onFilterChange()
22 { 23 {
23 onFilterChangeTimeout = null; 24 onFilterChangeTimeout = null;
24 ext.webRequest.handlerBehaviorChanged(); 25 ext.webRequest.handlerBehaviorChanged();
25 } 26 }
26 27
27 var importantNotifications = { 28 var importantNotifications = {
28 'filter.added': true, 29 'filter.added': true,
(...skipping 23 matching lines...) Expand all
52 return true; 53 return true;
53 54
54 var docDomain = extractHostFromURL(frame.url); 55 var docDomain = extractHostFromURL(frame.url);
55 var filter = defaultMatcher.matchesAny( 56 var filter = defaultMatcher.matchesAny(
56 url, 57 url,
57 type == "sub_frame" ? "SUBDOCUMENT" : type.toUpperCase(), 58 type == "sub_frame" ? "SUBDOCUMENT" : type.toUpperCase(),
58 docDomain, 59 docDomain,
59 isThirdParty(extractHostFromURL(url), docDomain) 60 isThirdParty(extractHostFromURL(url), docDomain)
60 ); 61 );
61 62
63 // We can't listen to onHeadersReceived in Safari so we need to
64 // check for notifications here
65 if (platform != "chromium" && type == "sub_frame")
66 {
67 var notificationToShow = Notification.getNextToShow(url);
68 if (notificationToShow)
69 showNotification(notificationToShow);
70 }
71
62 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page); 72 FilterNotifier.triggerListeners("filter.hitCount", filter, 0, 0, page);
63 return !(filter instanceof BlockingFilter); 73 return !(filter instanceof BlockingFilter);
64 } 74 }
65 75
66 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest); 76 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest);
67 77
68 if (require("info").platform == "chromium") 78 if (platform == "chromium")
69 { 79 {
70 function onHeadersReceived(details) 80 function onHeadersReceived(details)
71 { 81 {
72 if (details.tabId == -1) 82 if (details.tabId == -1)
73 return; 83 return;
74 84
75 if (details.type != "main_frame" && details.type != "sub_frame") 85 if (details.type != "main_frame" && details.type != "sub_frame")
76 return; 86 return;
77 87
78 var page = new ext.Page({id: details.tabId}); 88 var page = new ext.Page({id: details.tabId});
79 var frame = new ext.Frame({frameId: details.frameId, tabId: details.tabId}); 89 var frame = new ext.Frame({frameId: details.frameId, tabId: details.tabId});
80 90
81 if (frame.url != details.url) 91 if (frame.url != details.url)
82 return; 92 return;
83 93
84 for (var i = 0; i < details.responseHeaders.length; i++) 94 for (var i = 0; i < details.responseHeaders.length; i++)
85 { 95 {
86 var header = details.responseHeaders[i]; 96 var header = details.responseHeaders[i];
87 if (header.name.toLowerCase() == "x-adblock-key" && header.value) 97 if (header.name.toLowerCase() == "x-adblock-key" && header.value)
88 processKeyException(header.value, page, frame); 98 processKeyException(header.value, page, frame);
89 } 99 }
100
101 var notificationToShow = Notification.getNextToShow(details.url);
102 if (notificationToShow)
103 showNotification(notificationToShow);
90 } 104 }
91 105
92 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["<a ll_urls>"]}, ["responseHeaders"]); 106 chrome.webRequest.onHeadersReceived.addListener(onHeadersReceived, {urls: ["<a ll_urls>"]}, ["responseHeaders"]);
93 } 107 }
LEFTRIGHT
« stats.js ('k') | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld