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

Side by Side Diff: webrequest.js

Issue 29338481: Issue 3705 - Don't rely on info.platform when checking for availability of the chrome.* API (Closed)
Patch Set: Created March 17, 2016, 6:54 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 | « lib/prefs.js ('k') | no next file » | 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-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 setTimeout(onBeforeRequestAsync, 0, page, urlString, 84 setTimeout(onBeforeRequestAsync, 0, page, urlString,
85 type, docDomain, 85 type, docDomain,
86 thirdParty, key, 86 thirdParty, key,
87 specificOnly, filter); 87 specificOnly, filter);
88 88
89 return !(filter instanceof BlockingFilter); 89 return !(filter instanceof BlockingFilter);
90 } 90 }
91 91
92 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest); 92 ext.webRequest.onBeforeRequest.addListener(onBeforeRequest);
93 93
94 if (platform == "chromium") 94 if (typeof chrome == "object")
95 { 95 {
96 function onHeadersReceived(details) 96 function onHeadersReceived(details)
97 { 97 {
98 var page = new ext.Page({id: details.tabId}); 98 var page = new ext.Page({id: details.tabId});
99 var frame = ext.getFrame(details.tabId, details.frameId); 99 var frame = ext.getFrame(details.tabId, details.frameId);
100 100
101 if (!frame || frame.url.href != details.url) 101 if (!frame || frame.url.href != details.url)
102 return; 102 return;
103 103
104 for (var i = 0; i < details.responseHeaders.length; i++) 104 for (var i = 0; i < details.responseHeaders.length; i++)
105 { 105 {
106 var header = details.responseHeaders[i]; 106 var header = details.responseHeaders[i];
107 if (header.name.toLowerCase() == "x-adblock-key" && header.value) 107 if (header.name.toLowerCase() == "x-adblock-key" && header.value)
108 processKey(header.value, page, frame); 108 processKey(header.value, page, frame);
109 } 109 }
110 } 110 }
111 111
112 chrome.webRequest.onHeadersReceived.addListener( 112 chrome.webRequest.onHeadersReceived.addListener(
113 onHeadersReceived, 113 onHeadersReceived,
114 { 114 {
115 urls: ["http://*/*", "https://*/*"], 115 urls: ["http://*/*", "https://*/*"],
116 types: ["main_frame", "sub_frame"] 116 types: ["main_frame", "sub_frame"]
117 }, 117 },
118 ["responseHeaders"] 118 ["responseHeaders"]
119 ); 119 );
120 } 120 }
OLDNEW
« no previous file with comments | « lib/prefs.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld