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

Delta Between Two Patch Sets: ext/background.js

Issue 29417597: Issue 5161 - Use maps and sets where appropriate (Closed) Base URL: https://hg.adblockplus.org/adblockpluschrome/
Left Patch Set: Rebased Created May 20, 2017, 5:44 p.m.
Right Patch Set: Minor unrelated changes Created May 21, 2017, 10:15 p.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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 tabs.forEach(tab => 544 tabs.forEach(tab =>
545 { 545 {
546 chrome.webNavigation.getAllFrames({tabId: tab.id}, details => 546 chrome.webNavigation.getAllFrames({tabId: tab.id}, details =>
547 { 547 {
548 if (details && details.length > 0) 548 if (details && details.length > 0)
549 { 549 {
550 let frames = new Map(); 550 let frames = new Map();
551 framesOfTabs.set(tab.id, frames); 551 framesOfTabs.set(tab.id, frames);
552 552
553 for (let detail of details) 553 for (let detail of details)
554 frames.set(detail.frameId, {url: new URL(detail.url)});
555
556 for (let detail of details)
557 { 554 {
558 let {parentFrameId} = detail; 555 let frame = {url: new URL(detail.url)};
559 556 frames.set(detail.frameId, frame);
560 if (parentFrameId != -1) 557
561 frames.get(detail.frameId).parent = frames.get(parentFrameId); 558 if (detail.parentFrameId != -1)
559 frame.parent = frames.get(detail.parentFrameId);
562 } 560 }
563 } 561 }
564 }); 562 });
565 }); 563 });
566 }); 564 });
567 565
568 chrome.webRequest.onBeforeRequest.addListener(details => 566 chrome.webRequest.onBeforeRequest.addListener(details =>
569 { 567 {
570 // The high-level code isn't interested in requests that aren't 568 // The high-level code isn't interested in requests that aren't
571 // related to a tab or requests loading a top-level document, 569 // related to a tab or requests loading a top-level document,
(...skipping 10 matching lines...) Expand all
582 if (url.protocol != "http:" && url.protocol != "https:" && 580 if (url.protocol != "http:" && url.protocol != "https:" &&
583 url.protocol != "ws:" && url.protocol != "wss:") 581 url.protocol != "ws:" && url.protocol != "wss:")
584 return; 582 return;
585 583
586 // We are looking for the frame that contains the element which 584 // We are looking for the frame that contains the element which
587 // has triggered this request. For most requests (e.g. images) we 585 // has triggered this request. For most requests (e.g. images) we
588 // 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
589 // (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.
590 let {frameId, type} = details; 588 let {frameId, type} = details;
591 if (type == "sub_frame") 589 if (type == "sub_frame")
592 {
593 frameId = details.parentFrameId; 590 frameId = details.parentFrameId;
594 type = "SUBDOCUMENT";
595 }
596 591
597 let frame = ext.getFrame(details.tabId, frameId); 592 let frame = ext.getFrame(details.tabId, frameId);
598 if (frame) 593 if (frame)
599 { 594 {
600 let results = ext.webRequest.onBeforeRequest._dispatch( 595 let results = ext.webRequest.onBeforeRequest._dispatch(
601 url, type.toUpperCase(), new Page({id: details.tabId}), frame 596 url, type, new Page({id: details.tabId}), frame
602 ); 597 );
603 598
604 if (results.indexOf(false) != -1) 599 if (results.indexOf(false) != -1)
605 return {cancel: true}; 600 return {cancel: true};
606 } 601 }
607 }, {urls: ["<all_urls>"]}, ["blocking"]); 602 }, {urls: ["<all_urls>"]}, ["blocking"]);
608 603
609 604
610 /* Message passing */ 605 /* Message passing */
611 606
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 ext.windows = { 730 ext.windows = {
736 create(createData, callback) 731 create(createData, callback)
737 { 732 {
738 chrome.windows.create(createData, createdWindow => 733 chrome.windows.create(createData, createdWindow =>
739 { 734 {
740 afterTabLoaded(callback)(createdWindow.tabs[0]); 735 afterTabLoaded(callback)(createdWindow.tabs[0]);
741 }); 736 });
742 } 737 }
743 }; 738 };
744 }()); 739 }());
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