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

Side by Side Diff: chrome/ext/background.js

Issue 6228201961422848: Issue 2064 - Configure indistinguishable request types in the abstraction layer (Closed)
Patch Set: Ignore MEDIA and FONT filters on Chrome Created March 2, 2015, 7:22 p.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 | « background.js ('k') | safari/ext/background.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 <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 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 ext.getFrame = function(tabId, frameId) 324 ext.getFrame = function(tabId, frameId)
325 { 325 {
326 return (framesOfTabs[tabId] || {})[frameId]; 326 return (framesOfTabs[tabId] || {})[frameId];
327 }; 327 };
328 328
329 ext.webRequest = { 329 ext.webRequest = {
330 onBeforeRequest: new ext._EventTarget(), 330 onBeforeRequest: new ext._EventTarget(),
331 handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged 331 handlerBehaviorChanged: chrome.webRequest.handlerBehaviorChanged
332 }; 332 };
333 333
334 // Since Chrome 38 requests of type 'object' (e.g. requests
335 // initiated by Flash) are mistakenly reported with the type 'other'.
336 // https://code.google.com/p/chromium/issues/detail?id=410382
337 if (parseInt(navigator.userAgent.match(/\bChrome\/(\d+)/)[1], 10) >= 38)
338 {
339 ext.webRequest.indistinguishableTypes = [
340 ["OTHER", "OBJECT", "OBJECT_SUBREQUEST"]
341 ];
342 }
343 else
344 {
345 ext.webRequest.indistinguishableTypes = [
346 ["OBJECT", "OBJECT_SUBREQUEST"],
347 ["OTHER", "MEDIA", "FONT"]
348 ];
349 }
350
334 chrome.tabs.query({}, function(tabs) 351 chrome.tabs.query({}, function(tabs)
335 { 352 {
336 tabs.forEach(function(tab) 353 tabs.forEach(function(tab)
337 { 354 {
338 chrome.webNavigation.getAllFrames({tabId: tab.id}, function(details) 355 chrome.webNavigation.getAllFrames({tabId: tab.id}, function(details)
339 { 356 {
340 if (details && details.length > 0) 357 if (details && details.length > 0)
341 { 358 {
342 var frames = framesOfTabs[tab.id] = Object.create(null); 359 var frames = framesOfTabs[tab.id] = Object.create(null);
343 360
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 else 414 else
398 { 415 {
399 frameId = details.frameId; 416 frameId = details.frameId;
400 requestType = details.type.toUpperCase(); 417 requestType = details.type.toUpperCase();
401 } 418 }
402 419
403 frame = frames[frameId] || frames[Object.keys(frames)[0]]; 420 frame = frames[frameId] || frames[Object.keys(frames)[0]];
404 421
405 if (frame) 422 if (frame)
406 { 423 {
407 // Since Chrome 38 requests of type 'object' (e.g. requests
408 // initiated by Flash) are mistakenly reported with the type 'other'.
409 // https://code.google.com/p/chromium/issues/detail?id=410382
410 if (requestType == "OTHER" && parseInt(navigator.userAgent.match(/\bCh rome\/(\d+)/)[1], 10) >= 38)
411 requestType = "OBJECT";
412
413 var results = ext.webRequest.onBeforeRequest._dispatch( 424 var results = ext.webRequest.onBeforeRequest._dispatch(
414 url, 425 url,
415 requestType, 426 requestType,
416 new Page({id: details.tabId}), 427 new Page({id: details.tabId}),
417 frame 428 frame
418 ); 429 );
419 430
420 if (results.indexOf(false) != -1) 431 if (results.indexOf(false) != -1)
421 return {cancel: true}; 432 return {cancel: true};
422 } 433 }
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 callback(new Page(tab)); 531 callback(new Page(tab));
521 } 532 }
522 else 533 else
523 { 534 {
524 ext.pages.open(optionsUrl, callback); 535 ext.pages.open(optionsUrl, callback);
525 } 536 }
526 }); 537 });
527 }); 538 });
528 }; 539 };
529 })(); 540 })();
OLDNEW
« no previous file with comments | « background.js ('k') | safari/ext/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld