Action handler name disambiguation (#2018)

* Disambiguate PopupFactory action handlers

* Update HotkeyHandler action names

* Disambiguate Frontend action handlers

* Disambiguate Display action handlers

* Disambiguate PopupPreviewFrame action handlers

* Disambiguate Yomichan action handlers

* Disambiguate Frontend action handlers

* Disambiguate Display action handlers

* Disambiguate SearchDisplayController action handlers
This commit is contained in:
toasted-nutbread 2021-11-21 15:54:58 -05:00 committed by GitHub
parent 06e70c1cd8
commit 005f9658d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 96 additions and 96 deletions

View File

@ -92,9 +92,9 @@ class Frontend {
this._optionsContextOverride = null; this._optionsContextOverride = null;
this._runtimeMessageHandlers = new Map([ this._runtimeMessageHandlers = new Map([
['requestFrontendReadyBroadcast', {async: false, handler: this._onMessageRequestFrontendReadyBroadcast.bind(this)}], ['Frontend.requestReadyBroadcast', {async: false, handler: this._onMessageRequestFrontendReadyBroadcast.bind(this)}],
['setAllVisibleOverride', {async: true, handler: this._onApiSetAllVisibleOverride.bind(this)}], ['Frontend.setAllVisibleOverride', {async: true, handler: this._onApiSetAllVisibleOverride.bind(this)}],
['clearAllVisibleOverride', {async: true, handler: this._onApiClearAllVisibleOverride.bind(this)}] ['Frontend.clearAllVisibleOverride', {async: true, handler: this._onApiClearAllVisibleOverride.bind(this)}]
]); ]);
this._hotkeyHandler.registerActions([ this._hotkeyHandler.registerActions([
@ -159,11 +159,11 @@ class Frontend {
this._textScanner.on('searched', this._onSearched.bind(this)); this._textScanner.on('searched', this._onSearched.bind(this));
yomichan.crossFrame.registerHandlers([ yomichan.crossFrame.registerHandlers([
['closePopup', {async: false, handler: this._onApiClosePopup.bind(this)}], ['Frontend.closePopup', {async: false, handler: this._onApiClosePopup.bind(this)}],
['copySelection', {async: false, handler: this._onApiCopySelection.bind(this)}], ['Frontend.copySelection', {async: false, handler: this._onApiCopySelection.bind(this)}],
['getSelectionText', {async: false, handler: this._onApiGetSelectionText.bind(this)}], ['Frontend.getSelectionText', {async: false, handler: this._onApiGetSelectionText.bind(this)}],
['getPopupInfo', {async: false, handler: this._onApiGetPopupInfo.bind(this)}], ['Frontend.getPopupInfo', {async: false, handler: this._onApiGetPopupInfo.bind(this)}],
['getPageInfo', {async: false, handler: this._onApiGetPageInfo.bind(this)}] ['Frontend.getPageInfo', {async: false, handler: this._onApiGetPageInfo.bind(this)}]
]); ]);
this._updateContentScale(); this._updateContentScale();
@ -509,7 +509,7 @@ class Frontend {
return await this._getDefaultPopup(); return await this._getDefaultPopup();
} }
const {popupId} = await yomichan.crossFrame.invoke(targetFrameId, 'getPopupInfo'); const {popupId} = await yomichan.crossFrame.invoke(targetFrameId, 'Frontend.getPopupInfo');
if (popupId === null) { if (popupId === null) {
return null; return null;
} }
@ -702,7 +702,7 @@ class Frontend {
} }
chrome.runtime.onMessage.addListener(onMessage); chrome.runtime.onMessage.addListener(onMessage);
yomichan.api.broadcastTab('requestFrontendReadyBroadcast', {frameId: this._frameId}); yomichan.api.broadcastTab('Frontend.requestReadyBroadcast', {frameId: this._frameId});
}); });
} }
@ -728,7 +728,7 @@ class Frontend {
let documentTitle = document.title; let documentTitle = document.title;
if (this._useProxyPopup) { if (this._useProxyPopup) {
try { try {
({url, documentTitle} = await yomichan.crossFrame.invoke(this._parentFrameId, 'getPageInfo', {})); ({url, documentTitle} = await yomichan.crossFrame.invoke(this._parentFrameId, 'Frontend.getPageInfo', {}));
} catch (e) { } catch (e) {
// NOP // NOP
} }

View File

@ -43,21 +43,21 @@ class PopupFactory {
prepare() { prepare() {
this._frameOffsetForwarder.prepare(); this._frameOffsetForwarder.prepare();
yomichan.crossFrame.registerHandlers([ yomichan.crossFrame.registerHandlers([
['getOrCreatePopup', {async: true, handler: this._onApiGetOrCreatePopup.bind(this)}], ['PopupFactory.getOrCreatePopup', {async: true, handler: this._onApiGetOrCreatePopup.bind(this)}],
['setOptionsContext', {async: true, handler: this._onApiSetOptionsContext.bind(this)}], ['PopupFactory.setOptionsContext', {async: true, handler: this._onApiSetOptionsContext.bind(this)}],
['hide', {async: false, handler: this._onApiHide.bind(this)}], ['PopupFactory.hide', {async: false, handler: this._onApiHide.bind(this)}],
['isVisible', {async: true, handler: this._onApiIsVisibleAsync.bind(this)}], ['PopupFactory.isVisible', {async: true, handler: this._onApiIsVisibleAsync.bind(this)}],
['setVisibleOverride', {async: true, handler: this._onApiSetVisibleOverride.bind(this)}], ['PopupFactory.setVisibleOverride', {async: true, handler: this._onApiSetVisibleOverride.bind(this)}],
['clearVisibleOverride', {async: true, handler: this._onApiClearVisibleOverride.bind(this)}], ['PopupFactory.clearVisibleOverride', {async: true, handler: this._onApiClearVisibleOverride.bind(this)}],
['containsPoint', {async: true, handler: this._onApiContainsPoint.bind(this)}], ['PopupFactory.containsPoint', {async: true, handler: this._onApiContainsPoint.bind(this)}],
['showContent', {async: true, handler: this._onApiShowContent.bind(this)}], ['PopupFactory.showContent', {async: true, handler: this._onApiShowContent.bind(this)}],
['setCustomCss', {async: false, handler: this._onApiSetCustomCss.bind(this)}], ['PopupFactory.setCustomCss', {async: false, handler: this._onApiSetCustomCss.bind(this)}],
['clearAutoPlayTimer', {async: false, handler: this._onApiClearAutoPlayTimer.bind(this)}], ['PopupFactory.clearAutoPlayTimer', {async: false, handler: this._onApiClearAutoPlayTimer.bind(this)}],
['setContentScale', {async: false, handler: this._onApiSetContentScale.bind(this)}], ['PopupFactory.setContentScale', {async: false, handler: this._onApiSetContentScale.bind(this)}],
['updateTheme', {async: false, handler: this._onApiUpdateTheme.bind(this)}], ['PopupFactory.updateTheme', {async: false, handler: this._onApiUpdateTheme.bind(this)}],
['setCustomOuterCss', {async: false, handler: this._onApiSetCustomOuterCss.bind(this)}], ['PopupFactory.setCustomOuterCss', {async: false, handler: this._onApiSetCustomOuterCss.bind(this)}],
['popup.getFrameSize', {async: true, handler: this._onApiGetFrameSize.bind(this)}], ['PopupFactory.getFrameSize', {async: true, handler: this._onApiGetFrameSize.bind(this)}],
['popup.setFrameSize', {async: true, handler: this._onApiSetFrameSize.bind(this)}] ['PopupFactory.setFrameSize', {async: true, handler: this._onApiSetFrameSize.bind(this)}]
]); ]);
} }
@ -149,7 +149,7 @@ class PopupFactory {
throw new Error('Invalid frameId'); throw new Error('Invalid frameId');
} }
const useFrameOffsetForwarder = (parentPopupId === null); const useFrameOffsetForwarder = (parentPopupId === null);
({id, depth, frameId} = await yomichan.crossFrame.invoke(frameId, 'getOrCreatePopup', { ({id, depth, frameId} = await yomichan.crossFrame.invoke(frameId, 'PopupFactory.getOrCreatePopup', {
id, id,
parentPopupId, parentPopupId,
frameId, frameId,

View File

@ -129,7 +129,7 @@ class PopupProxy extends EventDispatcher {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
setOptionsContext(optionsContext) { setOptionsContext(optionsContext) {
return this._invokeSafe('setOptionsContext', {id: this._id, optionsContext}); return this._invokeSafe('PopupFactory.setOptionsContext', {id: this._id, optionsContext});
} }
/** /**
@ -138,7 +138,7 @@ class PopupProxy extends EventDispatcher {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
hide(changeFocus) { hide(changeFocus) {
return this._invokeSafe('hide', {id: this._id, changeFocus}); return this._invokeSafe('PopupFactory.hide', {id: this._id, changeFocus});
} }
/** /**
@ -146,7 +146,7 @@ class PopupProxy extends EventDispatcher {
* @returns {Promise<boolean>} `true` if the popup is visible, `false` otherwise. * @returns {Promise<boolean>} `true` if the popup is visible, `false` otherwise.
*/ */
isVisible() { isVisible() {
return this._invokeSafe('isVisible', {id: this._id}, false); return this._invokeSafe('PopupFactory.isVisible', {id: this._id}, false);
} }
/** /**
@ -157,7 +157,7 @@ class PopupProxy extends EventDispatcher {
* or null if the override wasn't assigned. * or null if the override wasn't assigned.
*/ */
setVisibleOverride(value, priority) { setVisibleOverride(value, priority) {
return this._invokeSafe('setVisibleOverride', {id: this._id, value, priority}, null); return this._invokeSafe('PopupFactory.setVisibleOverride', {id: this._id, value, priority}, null);
} }
/** /**
@ -166,7 +166,7 @@ class PopupProxy extends EventDispatcher {
* @returns {Promise<boolean>} `true` if the override existed and was removed, `false` otherwise. * @returns {Promise<boolean>} `true` if the override existed and was removed, `false` otherwise.
*/ */
clearVisibleOverride(token) { clearVisibleOverride(token) {
return this._invokeSafe('clearVisibleOverride', {id: this._id, token}, false); return this._invokeSafe('PopupFactory.clearVisibleOverride', {id: this._id, token}, false);
} }
/** /**
@ -180,7 +180,7 @@ class PopupProxy extends EventDispatcher {
await this._updateFrameOffset(); await this._updateFrameOffset();
[x, y] = this._applyFrameOffset(x, y); [x, y] = this._applyFrameOffset(x, y);
} }
return await this._invokeSafe('containsPoint', {id: this._id, x, y}, false); return await this._invokeSafe('PopupFactory.containsPoint', {id: this._id, x, y}, false);
} }
/** /**
@ -195,7 +195,7 @@ class PopupProxy extends EventDispatcher {
await this._updateFrameOffset(); await this._updateFrameOffset();
[elementRect.x, elementRect.y] = this._applyFrameOffset(elementRect.x, elementRect.y); [elementRect.x, elementRect.y] = this._applyFrameOffset(elementRect.x, elementRect.y);
} }
return await this._invokeSafe('showContent', {id: this._id, details, displayDetails}); return await this._invokeSafe('PopupFactory.showContent', {id: this._id, details, displayDetails});
} }
/** /**
@ -204,7 +204,7 @@ class PopupProxy extends EventDispatcher {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
setCustomCss(css) { setCustomCss(css) {
return this._invokeSafe('setCustomCss', {id: this._id, css}); return this._invokeSafe('PopupFactory.setCustomCss', {id: this._id, css});
} }
/** /**
@ -212,7 +212,7 @@ class PopupProxy extends EventDispatcher {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
clearAutoPlayTimer() { clearAutoPlayTimer() {
return this._invokeSafe('clearAutoPlayTimer', {id: this._id}); return this._invokeSafe('PopupFactory.clearAutoPlayTimer', {id: this._id});
} }
/** /**
@ -221,7 +221,7 @@ class PopupProxy extends EventDispatcher {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
setContentScale(scale) { setContentScale(scale) {
return this._invokeSafe('setContentScale', {id: this._id, scale}); return this._invokeSafe('PopupFactory.setContentScale', {id: this._id, scale});
} }
/** /**
@ -238,7 +238,7 @@ class PopupProxy extends EventDispatcher {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
updateTheme() { updateTheme() {
return this._invokeSafe('updateTheme', {id: this._id}); return this._invokeSafe('PopupFactory.updateTheme', {id: this._id});
} }
/** /**
@ -249,7 +249,7 @@ class PopupProxy extends EventDispatcher {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
setCustomOuterCss(css, useWebExtensionApi) { setCustomOuterCss(css, useWebExtensionApi) {
return this._invokeSafe('setCustomOuterCss', {id: this._id, css, useWebExtensionApi}); return this._invokeSafe('PopupFactory.setCustomOuterCss', {id: this._id, css, useWebExtensionApi});
} }
/** /**
@ -266,7 +266,7 @@ class PopupProxy extends EventDispatcher {
* @returns {Promise<{width: number, height: number, valid: boolean}>} The size and whether or not it is valid. * @returns {Promise<{width: number, height: number, valid: boolean}>} The size and whether or not it is valid.
*/ */
getFrameSize() { getFrameSize() {
return this._invokeSafe('popup.getFrameSize', {id: this._id}, {width: 0, height: 0, valid: false}); return this._invokeSafe('PopupFactory.getFrameSize', {id: this._id}, {width: 0, height: 0, valid: false});
} }
/** /**
@ -276,7 +276,7 @@ class PopupProxy extends EventDispatcher {
* @returns {Promise<boolean>} `true` if the size assignment was successful, `false` otherwise. * @returns {Promise<boolean>} `true` if the size assignment was successful, `false` otherwise.
*/ */
setFrameSize(width, height) { setFrameSize(width, height) {
return this._invokeSafe('popup.setFrameSize', {id: this._id, width, height}); return this._invokeSafe('PopupFactory.setFrameSize', {id: this._id, width, height});
} }
// Private // Private

View File

@ -117,7 +117,7 @@ class PopupWindow extends EventDispatcher {
* @returns {Promise<void>} * @returns {Promise<void>}
*/ */
setOptionsContext(optionsContext) { setOptionsContext(optionsContext) {
return this._invoke(false, 'setOptionsContext', {id: this._id, optionsContext}); return this._invoke(false, 'Display.setOptionsContext', {id: this._id, optionsContext});
} }
/** /**
@ -174,7 +174,7 @@ class PopupWindow extends EventDispatcher {
*/ */
async showContent(_details, displayDetails) { async showContent(_details, displayDetails) {
if (displayDetails === null) { return; } if (displayDetails === null) { return; }
await this._invoke(true, 'setContent', {id: this._id, details: displayDetails}); await this._invoke(true, 'Display.setContent', {id: this._id, details: displayDetails});
} }
/** /**
@ -182,14 +182,14 @@ class PopupWindow extends EventDispatcher {
* @param {string} css The CSS rules. * @param {string} css The CSS rules.
*/ */
setCustomCss(css) { setCustomCss(css) {
return this._invoke(false, 'setCustomCss', {id: this._id, css}); return this._invoke(false, 'Display.setCustomCss', {id: this._id, css});
} }
/** /**
* Stops the audio auto-play timer, if one has started. * Stops the audio auto-play timer, if one has started.
*/ */
clearAutoPlayTimer() { clearAutoPlayTimer() {
return this._invoke(false, 'clearAutoPlayTimer', {id: this._id}); return this._invoke(false, 'Display.clearAutoPlayTimer', {id: this._id});
} }
/** /**

View File

@ -161,7 +161,7 @@ class Popup extends EventDispatcher {
*/ */
async setOptionsContext(optionsContext) { async setOptionsContext(optionsContext) {
await this._setOptionsContext(optionsContext); await this._setOptionsContext(optionsContext);
await this._invokeSafe('setOptionsContext', {optionsContext}); await this._invokeSafe('Display.setOptionsContext', {optionsContext});
} }
/** /**
@ -245,7 +245,7 @@ class Popup extends EventDispatcher {
} }
if (displayDetails !== null) { if (displayDetails !== null) {
this._invokeSafe('setContent', {details: displayDetails}); this._invokeSafe('Display.setContent', {details: displayDetails});
} }
} }
@ -254,14 +254,14 @@ class Popup extends EventDispatcher {
* @param {string} css The CSS rules. * @param {string} css The CSS rules.
*/ */
setCustomCss(css) { setCustomCss(css) {
this._invokeSafe('setCustomCss', {css}); this._invokeSafe('Display.setCustomCss', {css});
} }
/** /**
* Stops the audio auto-play timer, if one has started. * Stops the audio auto-play timer, if one has started.
*/ */
clearAutoPlayTimer() { clearAutoPlayTimer() {
this._invokeSafe('clearAutoPlayTimer'); this._invokeSafe('Display.clearAutoPlayTimer');
} }
/** /**
@ -271,7 +271,7 @@ class Popup extends EventDispatcher {
setContentScale(scale) { setContentScale(scale) {
this._contentScale = scale; this._contentScale = scale;
this._frame.style.fontSize = `${scale}px`; this._frame.style.fontSize = `${scale}px`;
this._invokeSafe('setContentScale', {scale}); this._invokeSafe('Display.setContentScale', {scale});
} }
/** /**
@ -411,7 +411,7 @@ class Popup extends EventDispatcher {
await frameClient.connect(this._frame, this._targetOrigin, this._frameId, setupFrame); await frameClient.connect(this._frame, this._targetOrigin, this._frameId, setupFrame);
// Configure // Configure
await this._invokeSafe('configure', { await this._invokeSafe('Display.configure', {
depth: this._depth, depth: this._depth,
parentPopupId: this._id, parentPopupId: this._id,
parentFrameId: this._frameId, parentFrameId: this._frameId,
@ -569,7 +569,7 @@ class Popup extends EventDispatcher {
if (this._visibleValue === value) { return; } if (this._visibleValue === value) { return; }
this._visibleValue = value; this._visibleValue = value;
this._frame.style.setProperty('visibility', value ? 'visible' : 'hidden', 'important'); this._frame.style.setProperty('visibility', value ? 'visible' : 'hidden', 'important');
this._invokeSafe('visibilityChanged', {value}); this._invokeSafe('Display.visibilityChanged', {value});
} }
_focusParent() { _focusParent() {
@ -627,7 +627,7 @@ class Popup extends EventDispatcher {
} }
_onExtensionUnloaded() { _onExtensionUnloaded() {
this._invokeWindow('extensionUnloaded'); this._invokeWindow('Display.extensionUnloaded');
} }
_getFrameParentElement() { _getFrameParentElement() {

View File

@ -227,8 +227,8 @@ class Backend {
this._clipboardMonitor.on('change', this._onClipboardTextChange.bind(this)); this._clipboardMonitor.on('change', this._onClipboardTextChange.bind(this));
this._sendMessageAllTabsIgnoreResponse('backendReady', {}); this._sendMessageAllTabsIgnoreResponse('Yomichan.backendReady', {});
this._sendMessageIgnoreResponse({action: 'backendReady', params: {}}); this._sendMessageIgnoreResponse({action: 'Yomichan.backendReady', params: {}});
} catch (e) { } catch (e) {
log.error(e); log.error(e);
throw e; throw e;
@ -367,7 +367,7 @@ class Backend {
} }
_onZoomChange({tabId, oldZoomFactor, newZoomFactor}) { _onZoomChange({tabId, oldZoomFactor, newZoomFactor}) {
this._sendMessageTabIgnoreResponse(tabId, {action: 'zoomChanged', params: {oldZoomFactor, newZoomFactor}}); this._sendMessageTabIgnoreResponse(tabId, {action: 'Yomichan.zoomChanged', params: {oldZoomFactor, newZoomFactor}});
} }
_onPermissionsChanged() { _onPermissionsChanged() {
@ -383,7 +383,7 @@ class Backend {
_onApiRequestBackendReadySignal(_params, sender) { _onApiRequestBackendReadySignal(_params, sender) {
// tab ID isn't set in background (e.g. browser_action) // tab ID isn't set in background (e.g. browser_action)
const data = {action: 'backendReady', params: {}}; const data = {action: 'Yomichan.backendReady', params: {}};
if (typeof sender.tab === 'undefined') { if (typeof sender.tab === 'undefined') {
this._sendMessageIgnoreResponse(data); this._sendMessageIgnoreResponse(data);
return false; return false;
@ -895,7 +895,7 @@ class Backend {
await this._sendMessageTabPromise( await this._sendMessageTabPromise(
tab.id, tab.id,
{action: 'setMode', params: {mode: 'popup'}}, {action: 'SearchDisplayController.setMode', params: {mode: 'popup'}},
{frameId: 0} {frameId: 0}
); );
@ -909,7 +909,7 @@ class Backend {
try { try {
const mode = await this._sendMessageTabPromise( const mode = await this._sendMessageTabPromise(
tab.id, tab.id,
{action: 'getMode', params: {}}, {action: 'SearchDisplayController.getMode', params: {}},
{frameId: 0} {frameId: 0}
); );
return mode === 'popup'; return mode === 'popup';
@ -969,7 +969,7 @@ class Backend {
_updateSearchQuery(tabId, text, animate) { _updateSearchQuery(tabId, text, animate) {
return this._sendMessageTabPromise( return this._sendMessageTabPromise(
tabId, tabId,
{action: 'updateSearchQuery', params: {text, animate}}, {action: 'SearchDisplayController.updateSearchQuery', params: {text, animate}},
{frameId: 0} {frameId: 0}
); );
} }
@ -991,7 +991,7 @@ class Backend {
this._clipboardMonitor.stop(); this._clipboardMonitor.stop();
} }
this._sendMessageAllTabsIgnoreResponse('optionsUpdated', {source}); this._sendMessageAllTabsIgnoreResponse('Yomichan.optionsUpdated', {source});
} }
_getOptionsFull(useSchema=false) { _getOptionsFull(useSchema=false) {
@ -1425,7 +1425,7 @@ class Backend {
try { try {
const {url} = await this._sendMessageTabPromise( const {url} = await this._sendMessageTabPromise(
tabId, tabId,
{action: 'getUrl', params: {}}, {action: 'Yomichan.getUrl', params: {}},
{frameId: 0} {frameId: 0}
); );
if (typeof url === 'string') { if (typeof url === 'string') {
@ -1582,7 +1582,7 @@ class Backend {
chrome.runtime.onMessage.addListener(onMessage); chrome.runtime.onMessage.addListener(onMessage);
this._sendMessageTabPromise(tabId, {action: 'isReady'}, {frameId}) this._sendMessageTabPromise(tabId, {action: 'Yomichan.isReady'}, {frameId})
.then( .then(
(value) => { (value) => {
if (!value) { return; } if (!value) { return; }
@ -1685,7 +1685,7 @@ class Backend {
let token = null; let token = null;
try { try {
if (typeof tabId === 'number' && typeof frameId === 'number') { if (typeof tabId === 'number' && typeof frameId === 'number') {
const action = 'setAllVisibleOverride'; const action = 'Frontend.setAllVisibleOverride';
const params = {value: false, priority: 0, awaitFrame: true}; const params = {value: false, priority: 0, awaitFrame: true};
token = await this._sendMessageTabPromise(tabId, {action, params}, {frameId}); token = await this._sendMessageTabPromise(tabId, {action, params}, {frameId});
} }
@ -1702,7 +1702,7 @@ class Backend {
}); });
} finally { } finally {
if (token !== null) { if (token !== null) {
const action = 'clearAllVisibleOverride'; const action = 'Frontend.clearAllVisibleOverride';
const params = {token}; const params = {token};
try { try {
await this._sendMessageTabPromise(tabId, {action, params}, {frameId}); await this._sendMessageTabPromise(tabId, {action, params}, {frameId});
@ -1946,7 +1946,7 @@ class Backend {
_triggerDatabaseUpdated(type, cause) { _triggerDatabaseUpdated(type, cause) {
this._translator.clearDatabaseCaches(); this._translator.clearDatabaseCaches();
this._sendMessageAllTabsIgnoreResponse('databaseUpdated', {type, cause}); this._sendMessageAllTabsIgnoreResponse('Yomichan.databaseUpdated', {type, cause});
} }
async _saveOptions(source) { async _saveOptions(source) {

View File

@ -64,7 +64,7 @@ class DisplayAudio {
['playAudioFromSource', this._onHotkeyActionPlayAudioFromSource.bind(this)] ['playAudioFromSource', this._onHotkeyActionPlayAudioFromSource.bind(this)]
]); ]);
this._display.registerDirectMessageHandlers([ this._display.registerDirectMessageHandlers([
['clearAutoPlayTimer', {async: false, handler: this._onMessageClearAutoPlayTimer.bind(this)}] ['Display.clearAutoPlayTimer', {async: false, handler: this._onMessageClearAutoPlayTimer.bind(this)}]
]); ]);
this._display.on('optionsUpdated', this._onOptionsUpdated.bind(this)); this._display.on('optionsUpdated', this._onOptionsUpdated.bind(this));
this._display.on('contentClear', this._onContentClear.bind(this)); this._display.on('contentClear', this._onContentClear.bind(this));

View File

@ -128,7 +128,7 @@ class DisplayResizer {
const {parentPopupId} = this._display; const {parentPopupId} = this._display;
if (parentPopupId === null) { return; } if (parentPopupId === null) { return; }
const size = await this._display.invokeParentFrame('popup.getFrameSize', {id: parentPopupId}); const size = await this._display.invokeParentFrame('PopupFactory.getFrameSize', {id: parentPopupId});
if (this._token !== token) { return; } if (this._token !== token) { return; }
this._startSize = size; this._startSize = size;
} }
@ -158,7 +158,7 @@ class DisplayResizer {
height += y - this._startOffset.y; height += y - this._startOffset.y;
width = Math.max(Math.max(0, handleSize.width), width); width = Math.max(Math.max(0, handleSize.width), width);
height = Math.max(Math.max(0, handleSize.height), height); height = Math.max(Math.max(0, handleSize.height), height);
await this._display.invokeParentFrame('popup.setFrameSize', {id: parentPopupId, width, height}); await this._display.invokeParentFrame('PopupFactory.setFrameSize', {id: parentPopupId, width, height});
} }
_getTouch(touchList, identifier) { _getTouch(touchList, identifier) {

View File

@ -128,15 +128,15 @@ class Display extends EventDispatcher {
['previousEntryDifferentDictionary', () => { this._focusEntryWithDifferentDictionary(-1, true); }] ['previousEntryDifferentDictionary', () => { this._focusEntryWithDifferentDictionary(-1, true); }]
]); ]);
this.registerDirectMessageHandlers([ this.registerDirectMessageHandlers([
['setOptionsContext', {async: false, handler: this._onMessageSetOptionsContext.bind(this)}], ['Display.setOptionsContext', {async: false, handler: this._onMessageSetOptionsContext.bind(this)}],
['setContent', {async: false, handler: this._onMessageSetContent.bind(this)}], ['Display.setContent', {async: false, handler: this._onMessageSetContent.bind(this)}],
['setCustomCss', {async: false, handler: this._onMessageSetCustomCss.bind(this)}], ['Display.setCustomCss', {async: false, handler: this._onMessageSetCustomCss.bind(this)}],
['setContentScale', {async: false, handler: this._onMessageSetContentScale.bind(this)}], ['Display.setContentScale', {async: false, handler: this._onMessageSetContentScale.bind(this)}],
['configure', {async: true, handler: this._onMessageConfigure.bind(this)}], ['Display.configure', {async: true, handler: this._onMessageConfigure.bind(this)}],
['visibilityChanged', {async: false, handler: this._onMessageVisibilityChanged.bind(this)}] ['Display.visibilityChanged', {async: false, handler: this._onMessageVisibilityChanged.bind(this)}]
]); ]);
this.registerWindowMessageHandlers([ this.registerWindowMessageHandlers([
['extensionUnloaded', {async: false, handler: this._onMessageExtensionUnloaded.bind(this)}] ['Display.extensionUnloaded', {async: false, handler: this._onMessageExtensionUnloaded.bind(this)}]
]); ]);
} }
@ -393,7 +393,7 @@ class Display extends EventDispatcher {
close() { close() {
switch (this._pageType) { switch (this._pageType) {
case 'popup': case 'popup':
this.invokeContentOrigin('closePopup'); this.invokeContentOrigin('Frontend.closePopup');
break; break;
case 'search': case 'search':
this._closeTab(); this._closeTab();
@ -1359,7 +1359,7 @@ class Display extends EventDispatcher {
{ {
let text; let text;
try { try {
text = await this.invokeContentOrigin('getSelectionText'); text = await this.invokeContentOrigin('Frontend.getSelectionText');
} catch (e) { } catch (e) {
break; break;
} }
@ -1367,7 +1367,7 @@ class Display extends EventDispatcher {
} }
break; break;
default: default:
await this.invokeContentOrigin('copySelection'); await this.invokeContentOrigin('Frontend.copySelection');
break; break;
} }
} }

View File

@ -64,9 +64,9 @@ class SearchDisplayController {
['focusSearchBox', this._onActionFocusSearchBox.bind(this)] ['focusSearchBox', this._onActionFocusSearchBox.bind(this)]
]); ]);
this._registerMessageHandlers([ this._registerMessageHandlers([
['getMode', {async: false, handler: this._onMessageGetMode.bind(this)}], ['SearchDisplayController.getMode', {async: false, handler: this._onMessageGetMode.bind(this)}],
['setMode', {async: false, handler: this._onMessageSetMode.bind(this)}], ['SearchDisplayController.setMode', {async: false, handler: this._onMessageSetMode.bind(this)}],
['updateSearchQuery', {async: false, handler: this._onExternalSearchUpdate.bind(this)}] ['SearchDisplayController.updateSearchQuery', {async: false, handler: this._onExternalSearchUpdate.bind(this)}]
]); ]);
this._updateClipboardMonitorEnabled(); this._updateClipboardMonitorEnabled();

View File

@ -43,7 +43,7 @@ class HotkeyHandler extends EventDispatcher {
this._isPrepared = true; this._isPrepared = true;
this._updateEventHandlers(); this._updateEventHandlers();
yomichan.crossFrame.registerHandlers([ yomichan.crossFrame.registerHandlers([
['hotkeyHandler.forwardHotkey', {async: false, handler: this._onMessageForwardHotkey.bind(this)}] ['HotkeyHandler.forwardHotkey', {async: false, handler: this._onMessageForwardHotkey.bind(this)}]
]); ]);
} }

View File

@ -52,16 +52,16 @@ class PopupPreviewController {
} }
_onCustomCssChange() { _onCustomCssChange() {
this._invoke('setCustomCss', {css: this._customCss.value}); this._invoke('PopupPreviewFrame.setCustomCss', {css: this._customCss.value});
} }
_onCustomOuterCssChange() { _onCustomOuterCssChange() {
this._invoke('setCustomOuterCss', {css: this._customOuterCss.value}); this._invoke('PopupPreviewFrame.setCustomOuterCss', {css: this._customOuterCss.value});
} }
_onOptionsContextChange() { _onOptionsContextChange() {
const optionsContext = this._settingsController.getOptionsContext(); const optionsContext = this._settingsController.getOptionsContext();
this._invoke('updateOptionsContext', {optionsContext}); this._invoke('PopupPreviewFrame.updateOptionsContext', {optionsContext});
} }
_invoke(action, params) { _invoke(action, params) {

View File

@ -38,10 +38,10 @@ class PopupPreviewFrame {
this._targetOrigin = chrome.runtime.getURL('/').replace(/\/$/, ''); this._targetOrigin = chrome.runtime.getURL('/').replace(/\/$/, '');
this._windowMessageHandlers = new Map([ this._windowMessageHandlers = new Map([
['setText', this._onSetText.bind(this)], ['PopupPreviewFrame.setText', this._onSetText.bind(this)],
['setCustomCss', this._setCustomCss.bind(this)], ['PopupPreviewFrame.setCustomCss', this._setCustomCss.bind(this)],
['setCustomOuterCss', this._setCustomOuterCss.bind(this)], ['PopupPreviewFrame.setCustomOuterCss', this._setCustomOuterCss.bind(this)],
['updateOptionsContext', this._updateOptionsContext.bind(this)] ['PopupPreviewFrame.updateOptionsContext', this._updateOptionsContext.bind(this)]
]); ]);
} }

View File

@ -74,12 +74,12 @@ class Yomichan extends EventDispatcher {
this._isBackendReadyPromiseResolve = resolve; this._isBackendReadyPromiseResolve = resolve;
this._messageHandlers = new Map([ this._messageHandlers = new Map([
['isReady', {async: false, handler: this._onMessageIsReady.bind(this)}], ['Yomichan.isReady', {async: false, handler: this._onMessageIsReady.bind(this)}],
['backendReady', {async: false, handler: this._onMessageBackendReady.bind(this)}], ['Yomichan.backendReady', {async: false, handler: this._onMessageBackendReady.bind(this)}],
['getUrl', {async: false, handler: this._onMessageGetUrl.bind(this)}], ['Yomichan.getUrl', {async: false, handler: this._onMessageGetUrl.bind(this)}],
['optionsUpdated', {async: false, handler: this._onMessageOptionsUpdated.bind(this)}], ['Yomichan.optionsUpdated', {async: false, handler: this._onMessageOptionsUpdated.bind(this)}],
['databaseUpdated', {async: false, handler: this._onMessageDatabaseUpdated.bind(this)}], ['Yomichan.databaseUpdated', {async: false, handler: this._onMessageDatabaseUpdated.bind(this)}],
['zoomChanged', {async: false, handler: this._onMessageZoomChanged.bind(this)}] ['Yomichan.zoomChanged', {async: false, handler: this._onMessageZoomChanged.bind(this)}]
]); ]);
} }