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

Side by Side Diff: ext/background.js

Issue 29421712: Issue 5184 - Support Firefox-specific webRequest types (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Patch Set: Created April 25, 2017, 4:25 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 | « no previous file | 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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 483
484 chrome.windows.onFocusChanged.addListener(windowId => 484 chrome.windows.onFocusChanged.addListener(windowId =>
485 { 485 {
486 if (windowId != chrome.windows.WINDOW_ID_NONE) 486 if (windowId != chrome.windows.WINDOW_ID_NONE)
487 updateContextMenu(); 487 updateContextMenu();
488 }); 488 });
489 489
490 490
491 /* Web requests */ 491 /* Web requests */
492 492
493 const resourceTypeMap = Object.freeze(Object.assign(Object.create(null),
494 {
495 web_manifest: "OTHER",
496 xml_dtd: "OTHER",
497 xslt: "OTHER",
498 imageset: "IMAGE",
499 beacon: "PING"
500 }
501 ));
502
493 let framesOfTabs = Object.create(null); 503 let framesOfTabs = Object.create(null);
494 504
495 ext.getFrame = (tabId, frameId) => 505 ext.getFrame = (tabId, frameId) =>
496 { 506 {
497 return (framesOfTabs[tabId] || {})[frameId]; 507 return (framesOfTabs[tabId] || {})[frameId];
498 }; 508 };
499 509
500 let handlerBehaviorChangedQuota = 510 let handlerBehaviorChangedQuota =
501 chrome.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES; 511 chrome.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES;
502 512
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 let {frameId, type} = details; 596 let {frameId, type} = details;
587 if (type == "sub_frame") 597 if (type == "sub_frame")
588 { 598 {
589 frameId = details.parentFrameId; 599 frameId = details.parentFrameId;
590 type = "SUBDOCUMENT"; 600 type = "SUBDOCUMENT";
591 } 601 }
592 602
593 let frame = ext.getFrame(details.tabId, frameId); 603 let frame = ext.getFrame(details.tabId, frameId);
594 if (frame) 604 if (frame)
595 { 605 {
606 type = resourceTypeMap[type] || type.toUpperCase();
607
596 let results = ext.webRequest.onBeforeRequest._dispatch( 608 let results = ext.webRequest.onBeforeRequest._dispatch(
597 url, type.toUpperCase(), new Page({id: details.tabId}), frame 609 url, type, new Page({id: details.tabId}), frame
598 ); 610 );
599 611
600 if (results.indexOf(false) != -1) 612 if (results.indexOf(false) != -1)
601 return {cancel: true}; 613 return {cancel: true};
602 } 614 }
603 }, {urls: ["<all_urls>"]}, ["blocking"]); 615 }, {urls: ["<all_urls>"]}, ["blocking"]);
604 616
605 617
606 /* Message passing */ 618 /* Message passing */
607 619
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 ext.windows = { 743 ext.windows = {
732 create(createData, callback) 744 create(createData, callback)
733 { 745 {
734 chrome.windows.create(createData, createdWindow => 746 chrome.windows.create(createData, createdWindow =>
735 { 747 {
736 afterTabLoaded(callback)(createdWindow.tabs[0]); 748 afterTabLoaded(callback)(createdWindow.tabs[0]);
737 }); 749 });
738 } 750 }
739 }; 751 };
740 }()); 752 }());
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld