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

Side by Side Diff: ext/background.js

Issue 29458601: Issue 5315 - Add support for Microsoft Edge (Closed)
Patch Set: Future proof in case Edge supports OBJECT request interception Created June 28, 2017, 4:30 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 | « README.md ('k') | ext/popup.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-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 url: new URL(rawSender.url), 620 // In Edge requests from internal extension pages
621 // (protocol ms-browser-extension://) do no have a sender URL.
622 url: rawSender.url ? new URL(rawSender.url) : null,
621 get parent() 623 get parent()
622 { 624 {
623 let frames = framesOfTabs.get(rawSender.tab.id); 625 let frames = framesOfTabs.get(rawSender.tab.id);
624 626
625 if (!frames) 627 if (!frames)
626 return null; 628 return null;
627 629
628 let frame = frames.get(rawSender.frameId); 630 let frame = frames.get(rawSender.frameId);
629 if (frame) 631 if (frame)
630 return frame.parent || null; 632 return frame.parent || null;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 } 690 }
689 }); 691 });
690 }); 692 });
691 } 693 }
692 }; 694 };
693 } 695 }
694 else 696 else
695 { 697 {
696 // Edge does not yet support runtime.openOptionsPage (tested version 38) 698 // Edge does not yet support runtime.openOptionsPage (tested version 38)
697 // and so this workaround needs to stay for now. 699 // and so this workaround needs to stay for now.
700 // We are not using extension.getURL to get the absolute path here
701 // because of the Edge issue:
702 // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/1027 6332/
698 ext.showOptions = callback => 703 ext.showOptions = callback =>
699 { 704 {
700 chrome.windows.getLastFocused(win => 705 chrome.windows.getLastFocused(win =>
701 { 706 {
702 let optionsUrl = chrome.extension.getURL("options.html"); 707 let optionsUrl = "options.html";
703 let queryInfo = {url: optionsUrl}; 708 let queryInfo = {url: optionsUrl};
704 709
705 // extension pages can't be accessed in incognito windows. In order to 710 // extension pages can't be accessed in incognito windows. In order to
706 // correctly mimic the way in which Chrome opens extension options, 711 // correctly mimic the way in which Chrome opens extension options,
707 // we have to focus the options page in any other window. 712 // we have to focus the options page in any other window.
708 if (!win.incognito) 713 if (!win.incognito)
709 queryInfo.windowId = win.id; 714 queryInfo.windowId = win.id;
710 715
711 chrome.tabs.query(queryInfo, tabs => 716 chrome.tabs.query(queryInfo, tabs =>
712 { 717 {
(...skipping 20 matching lines...) Expand all
733 ext.windows = { 738 ext.windows = {
734 create(createData, callback) 739 create(createData, callback)
735 { 740 {
736 chrome.windows.create(createData, createdWindow => 741 chrome.windows.create(createData, createdWindow =>
737 { 742 {
738 afterTabLoaded(callback)(createdWindow.tabs[0]); 743 afterTabLoaded(callback)(createdWindow.tabs[0]);
739 }); 744 });
740 } 745 }
741 }; 746 };
742 }()); 747 }());
OLDNEW
« no previous file with comments | « README.md ('k') | ext/popup.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld