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: Rebase to current tip Created July 27, 2017, 9:45 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
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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 id: rawSender.frameId,
621 url: new URL(rawSender.url), 621 // In Edge requests from internal extension pages
622 // (protocol ms-browser-extension://) do no have a sender URL.
623 url: rawSender.url ? new URL(rawSender.url) : null,
622 get parent() 624 get parent()
623 { 625 {
624 let frames = framesOfTabs.get(rawSender.tab.id); 626 let frames = framesOfTabs.get(rawSender.tab.id);
625 627
626 if (!frames) 628 if (!frames)
627 return null; 629 return null;
628 630
629 let frame = frames.get(rawSender.frameId); 631 let frame = frames.get(rawSender.frameId);
630 if (frame) 632 if (frame)
631 return frame.parent || null; 633 return frame.parent || null;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 691 }
690 }); 692 });
691 }); 693 });
692 } 694 }
693 }; 695 };
694 } 696 }
695 else 697 else
696 { 698 {
697 // Edge does not yet support runtime.openOptionsPage (tested version 38) 699 // Edge does not yet support runtime.openOptionsPage (tested version 38)
698 // 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/
699 ext.showOptions = callback => 704 ext.showOptions = callback =>
700 { 705 {
701 chrome.windows.getLastFocused(win => 706 chrome.windows.getLastFocused(win =>
702 { 707 {
703 let optionsUrl = chrome.extension.getURL("options.html"); 708 let optionsUrl = "options.html";
704 let queryInfo = {url: optionsUrl}; 709 let queryInfo = {url: optionsUrl};
705 710
706 // 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
707 // correctly mimic the way in which Chrome opens extension options, 712 // correctly mimic the way in which Chrome opens extension options,
708 // we have to focus the options page in any other window. 713 // we have to focus the options page in any other window.
709 if (!win.incognito) 714 if (!win.incognito)
710 queryInfo.windowId = win.id; 715 queryInfo.windowId = win.id;
711 716
712 chrome.tabs.query(queryInfo, tabs => 717 chrome.tabs.query(queryInfo, tabs =>
713 { 718 {
(...skipping 20 matching lines...) Expand all
734 ext.windows = { 739 ext.windows = {
735 create(createData, callback) 740 create(createData, callback)
736 { 741 {
737 chrome.windows.create(createData, createdWindow => 742 chrome.windows.create(createData, createdWindow =>
738 { 743 {
739 afterTabLoaded(callback)(createdWindow.tabs[0]); 744 afterTabLoaded(callback)(createdWindow.tabs[0]);
740 }); 745 });
741 } 746 }
742 }; 747 };
743 }()); 748 }());
OLDNEW

Powered by Google App Engine
This is Rietveld