Remove redundant getUrl handlers
This commit is contained in:
parent
573f83b65a
commit
4177b63726
@ -238,17 +238,6 @@ class DisplaySearch extends Display {
|
||||
}
|
||||
}
|
||||
|
||||
onRuntimeMessage({action, params}, sender, callback) {
|
||||
const handlers = DisplaySearch.runtimeMessageHandlers;
|
||||
if (hasOwn(handlers, action)) {
|
||||
const handler = handlers[action];
|
||||
const result = handler(this, params);
|
||||
callback(result);
|
||||
} else {
|
||||
return super.onRuntimeMessage({action, params}, sender, callback);
|
||||
}
|
||||
}
|
||||
|
||||
initClipboardMonitor() {
|
||||
// ignore copy from search page
|
||||
window.addEventListener('copy', () => {
|
||||
@ -380,12 +369,6 @@ class DisplaySearch extends Display {
|
||||
}
|
||||
}
|
||||
|
||||
DisplaySearch.runtimeMessageHandlers = {
|
||||
getUrl: () => {
|
||||
return {url: window.location.href};
|
||||
}
|
||||
};
|
||||
|
||||
DisplaySearch.onKeyDownIgnoreKeys = {
|
||||
'ANY_MOD': [
|
||||
'Tab', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'PageDown', 'PageUp', 'Home', 'End',
|
||||
|
@ -199,14 +199,11 @@ async function onOptionsUpdate({source}) {
|
||||
await formWrite(options);
|
||||
}
|
||||
|
||||
function onMessage({action, params}, sender, callback) {
|
||||
function onMessage({action, params}) {
|
||||
switch (action) {
|
||||
case 'optionsUpdate':
|
||||
onOptionsUpdate(params);
|
||||
break;
|
||||
case 'getUrl':
|
||||
callback({url: window.location.href});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,6 +201,5 @@ Frontend._windowMessageHandlers = new Map([
|
||||
|
||||
Frontend._runtimeMessageHandlers = new Map([
|
||||
['optionsUpdate', (self) => self.updateOptions()],
|
||||
['popupSetVisibleOverride', (self, {visible}) => self.popup.setVisibleOverride(visible)],
|
||||
['getUrl', () => ({url: window.location.href})]
|
||||
['popupSetVisibleOverride', (self, {visible}) => self.popup.setVisibleOverride(visible)]
|
||||
]);
|
||||
|
@ -225,3 +225,21 @@ class EventDispatcher {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Default message handlers
|
||||
*/
|
||||
|
||||
(() => {
|
||||
function onMessage({action}, sender, callback) {
|
||||
switch (action) {
|
||||
case 'getUrl':
|
||||
callback({url: window.location.href});
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
chrome.runtime.onMessage.addListener(onMessage);
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user