| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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-2015 Eyeo GmbH | 3 * Copyright (C) 2006-2015 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 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 onBeforeRequest: new ext._EventTarget(), | 347 onBeforeRequest: new ext._EventTarget(), |
| 348 handlerBehaviorChanged: function() | 348 handlerBehaviorChanged: function() |
| 349 { | 349 { |
| 350 // Defer handlerBehaviorChanged() until navigation occurs. | 350 // Defer handlerBehaviorChanged() until navigation occurs. |
| 351 // There wouldn't be any visible effect when calling it earlier, | 351 // There wouldn't be any visible effect when calling it earlier, |
| 352 // but it's an expensive operation and that way we avoid to call | 352 // but it's an expensive operation and that way we avoid to call |
| 353 // it multiple times, if multiple filters are added/removed. | 353 // it multiple times, if multiple filters are added/removed. |
| 354 var onBeforeNavigate = chrome.webNavigation.onBeforeNavigate; | 354 var onBeforeNavigate = chrome.webNavigation.onBeforeNavigate; |
| 355 if (!onBeforeNavigate.hasListener(propagateHandlerBehaviorChange)) | 355 if (!onBeforeNavigate.hasListener(propagateHandlerBehaviorChange)) |
| 356 onBeforeNavigate.addListener(propagateHandlerBehaviorChange); | 356 onBeforeNavigate.addListener(propagateHandlerBehaviorChange); |
| 357 }, | |
| 358 getIndistinguishableTypes: function() | |
| 359 { | |
| 360 // Chrome 38-48 mistakenly reports requests of type `object` | |
| 361 // (e.g. requests initiated by Flash) with the type `other`. | |
| 362 // https://code.google.com/p/chromium/issues/detail?id=410382 | |
| 363 var match = navigator.userAgent.match(/\bChrome\/(\d+)/); | |
|
kzar
2015/12/23 14:43:20
We already parse the application name and version
Sebastian Noack
2015/12/23 14:46:56
adblockplus.js (including the info module) depends
kzar
2015/12/23 14:56:42
Acknowledged.
| |
| 364 if (match) | |
| 365 { | |
| 366 var version = parseInt(match[1], 10); | |
| 367 if (version >= 38 && version <= 48) | |
| 368 return [["OTHER", "OBJECT", "OBJECT_SUBREQUEST"]]; | |
| 369 } | |
| 370 | |
| 371 // Before Chrome 49, requests of the type `font` and `ping` | |
| 372 // have been reported with the type `other`. | |
| 373 // https://code.google.com/p/chromium/issues/detail?id=410382 | |
| 374 var otherTypes = ["OTHER", "MEDIA"]; | |
| 375 if (!("FONT" in chrome.webRequest.ResourceType)) | |
| 376 otherTypes.push("FONT"); | |
| 377 if (!("PING" in chrome.webRequest.ResourceType)) | |
| 378 otherTypes.push("PING"); | |
| 379 | |
| 380 return [["OBJECT", "OBJECT_SUBREQUEST"], otherTypes]; | |
|
Wladimir Palant
2015/12/23 12:50:51
This logic is very hard to follow, and I'm not rea
Sebastian Noack
2015/12/23 13:08:43
This won't work. If the workaround for Chrome 38-4
| |
| 357 } | 381 } |
| 358 }; | 382 }; |
| 359 | 383 |
| 360 // Since Chrome 38 requests of type 'object' (e.g. requests | |
| 361 // initiated by Flash) are mistakenly reported with the type 'other'. | |
| 362 // https://code.google.com/p/chromium/issues/detail?id=410382 | |
| 363 var match = navigator.userAgent.match(/\bChrome\/(\d+)/); | |
| 364 if (match && parseInt(match[1], 10) >= 38) | |
| 365 { | |
| 366 ext.webRequest.indistinguishableTypes = [ | |
| 367 ["OTHER", "OBJECT", "OBJECT_SUBREQUEST"] | |
| 368 ]; | |
| 369 } | |
| 370 else | |
| 371 { | |
| 372 ext.webRequest.indistinguishableTypes = [ | |
| 373 ["OBJECT", "OBJECT_SUBREQUEST"], | |
| 374 ["OTHER", "MEDIA", "FONT"] | |
| 375 ]; | |
| 376 } | |
| 377 | |
| 378 chrome.tabs.query({}, function(tabs) | 384 chrome.tabs.query({}, function(tabs) |
| 379 { | 385 { |
| 380 tabs.forEach(function(tab) | 386 tabs.forEach(function(tab) |
| 381 { | 387 { |
| 382 chrome.webNavigation.getAllFrames({tabId: tab.id}, function(details) | 388 chrome.webNavigation.getAllFrames({tabId: tab.id}, function(details) |
| 383 { | 389 { |
| 384 if (details && details.length > 0) | 390 if (details && details.length > 0) |
| 385 { | 391 { |
| 386 var frames = framesOfTabs[tab.id] = Object.create(null); | 392 var frames = framesOfTabs[tab.id] = Object.create(null); |
| 387 | 393 |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 562 callback(new Page(tab)); | 568 callback(new Page(tab)); |
| 563 } | 569 } |
| 564 else | 570 else |
| 565 { | 571 { |
| 566 ext.pages.open(optionsUrl, callback); | 572 ext.pages.open(optionsUrl, callback); |
| 567 } | 573 } |
| 568 }); | 574 }); |
| 569 }); | 575 }); |
| 570 }; | 576 }; |
| 571 })(); | 577 })(); |
| OLD | NEW |