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

Delta Between Two Patch Sets: ext/background.js

Issue 29458601: Issue 5315 - Add support for Microsoft Edge (Closed)
Left Patch Set: Handle webRequest.ResourceType (#5321) and RTCPeerConnection.generateCertificate, address comments Created June 15, 2017, 11:18 a.m.
Right Patch Set: Cosmetic changes Created July 28, 2017, 11:02 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 | « README.md ('k') | ext/common.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 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 chrome.runtime.onMessage.addListener((message, rawSender, sendResponse) => 610 chrome.runtime.onMessage.addListener((message, rawSender, sendResponse) =>
611 { 611 {
612 let sender = {}; 612 let sender = {};
613 613
614 // Add "page" and "frame" if the message was sent by a content script. 614 // Add "page" and "frame" if the message was sent by a content script.
615 // If sent by popup or the background page itself, there is no "tab". 615 // If sent by popup or the background page itself, there is no "tab".
616 if ("tab" in rawSender) 616 if ("tab" in rawSender)
617 { 617 {
618 sender.page = new Page(rawSender.tab); 618 sender.page = new Page(rawSender.tab);
619 sender.frame = { 619 sender.frame = {
620 id: rawSender.frameId,
620 // In Edge requests from internal extension pages 621 // In Edge requests from internal extension pages
621 // (protocol ms-browser-extension://) do no have a sender URL. 622 // (protocol ms-browser-extension://) do no have a sender URL.
622 url: rawSender.url ? new URL(rawSender.url) : null, 623 url: rawSender.url ? new URL(rawSender.url) : null,
623 get parent() 624 get parent()
624 { 625 {
625 let frames = framesOfTabs.get(rawSender.tab.id); 626 let frames = framesOfTabs.get(rawSender.tab.id);
626 627
627 if (!frames) 628 if (!frames)
628 return null; 629 return null;
629 630
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 691 }
691 }); 692 });
692 }); 693 });
693 } 694 }
694 }; 695 };
695 } 696 }
696 else 697 else
697 { 698 {
698 // Edge does not yet support runtime.openOptionsPage (tested version 38) 699 // Edge does not yet support runtime.openOptionsPage (tested version 38)
699 // and so this workaround needs to stay for now. 700 // and so this workaround needs to stay for now.
701 // We are not using extension.getURL to get the absolute path here
702 // because of the Edge issue:
703 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/1027 6332/
700 ext.showOptions = callback => 704 ext.showOptions = callback =>
701 { 705 {
702 chrome.windows.getLastFocused(win => 706 chrome.windows.getLastFocused(win =>
703 { 707 {
704 // NOTE: we expect this else branch to run only on Edge.
705 // We are not using extension.getURL here because of the Edge issue:
706 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/ 10276332/
707 let optionsUrl = "options.html"; 708 let optionsUrl = "options.html";
708 let queryInfo = {url: optionsUrl}; 709 let queryInfo = {url: optionsUrl};
709 710
710 // extension pages can't be accessed in incognito windows. In order to 711 // extension pages can't be accessed in incognito windows. In order to
711 // correctly mimic the way in which Chrome opens extension options, 712 // correctly mimic the way in which Chrome opens extension options,
712 // we have to focus the options page in any other window. 713 // we have to focus the options page in any other window.
713 if (!win.incognito) 714 if (!win.incognito)
714 queryInfo.windowId = win.id; 715 queryInfo.windowId = win.id;
715 716
716 chrome.tabs.query(queryInfo, tabs => 717 chrome.tabs.query(queryInfo, tabs =>
(...skipping 21 matching lines...) Expand all
738 ext.windows = { 739 ext.windows = {
739 create(createData, callback) 740 create(createData, callback)
740 { 741 {
741 chrome.windows.create(createData, createdWindow => 742 chrome.windows.create(createData, createdWindow =>
742 { 743 {
743 afterTabLoaded(callback)(createdWindow.tabs[0]); 744 afterTabLoaded(callback)(createdWindow.tabs[0]);
744 }); 745 });
745 } 746 }
746 }; 747 };
747 }()); 748 }());
LEFTRIGHT

Powered by Google App Engine
This is Rietveld