Skip to content

Commit

Permalink
Add External Message API to create new Temporary Containers
Browse files Browse the repository at this point in the history
Part of #50
  • Loading branch information
stoically committed Feb 11, 2018
1 parent bd29ab6 commit 02a9da3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class TemporaryContainers extends Emittery {
browser.tabs.onActivated.addListener(this.tabsOnActivated.bind(this));
browser.windows.onFocusChanged.addListener(this.windowsOnFocusChanged.bind(this));
browser.runtime.onMessage.addListener(this.runtimeOnMessage.bind(this));
browser.runtime.onMessageExternal.addListener(this.runtimeOnMessageExternal.bind(this));
browser.tabs.onCreated.addListener(this.tabsOnCreated.bind(this));
browser.tabs.onUpdated.addListener(this.tabsOnUpdated.bind(this));
browser.tabs.onRemoved.addListener(this.tabsOnRemoved.bind(this));
Expand Down Expand Up @@ -83,6 +84,21 @@ class TemporaryContainers extends Emittery {
}
}

async runtimeOnMessageExternal(message, sender) {
debug('[runtimeOnMessageExternal] got external message', message, sender);
switch (message.method) {
case 'createTabInTempContainer':
this.container.createTabInTempContainer({
url: message.url ? message.url : null,
active: typeof message.active === 'undefined' ? true : message.active,
deletesHistory: this.storage.local.preferences.deletesHistoryContainer === 'automatic' ? true : false
});
break;
default:
throw new Error('Unknown message.method');
}
}


browserActionOnClicked(tab, url) {
if (!this.storage.local.preferences.keyboardShortcuts.AltC) {
Expand Down

0 comments on commit 02a9da3

Please sign in to comment.