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

Delta Between Two Patch Sets: ext/background.js

Issue 29418679: Issue 5042 - Adds handling for requests which are not associated with browser tab (Closed)
Left Patch Set: rebase Created May 30, 2017, 9:04 a.m.
Right Patch Set: fix whitespace, add comment abut null page, remove redundancies Created June 2, 2017, 5:01 a.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 | « no previous file | lib/devtools.js » ('j') | 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 <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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 if (url.protocol != "http:" && url.protocol != "https:" && 580 if (url.protocol != "http:" && url.protocol != "https:" &&
581 url.protocol != "ws:" && url.protocol != "wss:") 581 url.protocol != "ws:" && url.protocol != "wss:")
582 return; 582 return;
583 583
584 // We are looking for the frame that contains the element which 584 // We are looking for the frame that contains the element which
585 // has triggered this request. For most requests (e.g. images) we 585 // has triggered this request. For most requests (e.g. images) we
586 // can just use the request's frame ID, but for subdocument requests 586 // can just use the request's frame ID, but for subdocument requests
587 // (e.g. iframes) we must instead use the request's parent frame ID. 587 // (e.g. iframes) we must instead use the request's parent frame ID.
588 let {frameId, type} = details; 588 let {frameId, type} = details;
589 if (type == "sub_frame") 589 if (type == "sub_frame")
590 {
591 frameId = details.parentFrameId; 590 frameId = details.parentFrameId;
592 type = "SUBDOCUMENT";
Sebastian Noack 2017/05/30 11:10:48 We no longer map "sub_frame" to "SUBDOCUMENT" here
Jon Sonesen 2017/05/31 08:28:17 Acknowledged.
593 }
594 591
595 // Sometimes requests are not associated with a browser tab and 592 // Sometimes requests are not associated with a browser tab and
596 // in this case we want to still be able to view the url being called. 593 // in this case we want to still be able to view the url being called.
597 let frame = null; 594 let frame = null;
598 let page = null; 595 let page = null;
599 if (details.tabId != -1) 596 if (details.tabId != -1)
600 { 597 {
601 frame = ext.getFrame(details.tabId, frameId); 598 frame = ext.getFrame(details.tabId, frameId);
602 page = new Page({id: details.tabId}); 599 page = new Page({id: details.tabId});
603 } 600 }
604 601
605 if (ext.webRequest.onBeforeRequest._dispatch( 602 if (ext.webRequest.onBeforeRequest._dispatch(
606 url, type.toUpperCase(), page, frame).includes(false)) 603 url, type, page, frame).includes(false))
Sebastian Noack 2017/05/30 11:10:48 We no longer convert the type to upper case here.
Jon Sonesen 2017/05/31 08:28:17 Acknowledged.
607 return {cancel: true}; 604 return {cancel: true};
608 }, {urls: ["<all_urls>"]}, ["blocking"]); 605 }, {urls: ["<all_urls>"]}, ["blocking"]);
609 606
610 607
611 /* Message passing */ 608 /* Message passing */
612 609
613 chrome.runtime.onMessage.addListener((message, rawSender, sendResponse) => 610 chrome.runtime.onMessage.addListener((message, rawSender, sendResponse) =>
614 { 611 {
615 let sender = {}; 612 let sender = {};
616 613
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 ext.windows = { 733 ext.windows = {
737 create(createData, callback) 734 create(createData, callback)
738 { 735 {
739 chrome.windows.create(createData, createdWindow => 736 chrome.windows.create(createData, createdWindow =>
740 { 737 {
741 afterTabLoaded(callback)(createdWindow.tabs[0]); 738 afterTabLoaded(callback)(createdWindow.tabs[0]);
742 }); 739 });
743 } 740 }
744 }; 741 };
745 }()); 742 }());
LEFTRIGHT
« no previous file | lib/devtools.js » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld