Unify receiver selector launching and allow switching to app media type

This commit is contained in:
hensm
2020-01-14 02:56:53 +00:00
parent a23ae9efa8
commit d4f71e7dcf
4 changed files with 52 additions and 47 deletions

View File

@@ -65,12 +65,7 @@ function initBrowserAction () {
* top-level frame.
*/
browser.browserAction.onClicked.addListener(async tab => {
const currentShim = ShimManager.getShim(tab.id);
const selection = await ReceiverSelectorManager.getSelection(
ReceiverSelectorMediaType.Tab
, getMediaTypesForPageUrl(tab.url)
& ~ReceiverSelectorMediaType.App
, currentShim.requestedAppId);
const selection = await ReceiverSelectorManager.getSelection(tab.id);
if (selection) {
loadSender({
@@ -161,11 +156,8 @@ async function initMenus () {
switch (info.menuItemId) {
case menuIdMediaCast: {
const currentShim = ShimManager.getShim(tab.id, info.frameId);
const selection = await ReceiverSelectorManager.getSelection(
ReceiverSelectorMediaType.App
, availableMediaTypes
, currentShim.requestedAppId);
tab.id, info.frameId);
// Selection cancelled
if (!selection) {
@@ -204,11 +196,8 @@ async function initMenus () {
}
case menuIdMirroringCast: {
const currentShim = ShimManager.getShim(tab.id, info.frameId);
const selection = await ReceiverSelectorManager.getSelection(
ReceiverSelectorMediaType.Tab
, availableMediaTypes & ~ReceiverSelectorMediaType.App
, currentShim.requestedAppId);
tab.id, info.frameId);
loadSender({
tabId: tab.id