diff options
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/index.js b/src/index.js index 91004aac7..63e6e3d0f 100644 --- a/src/index.js +++ b/src/index.js | |||
@@ -449,6 +449,36 @@ ipcMain.on('feature-basic-auth-cancel', () => { | |||
449 | authCallback = noop; | 449 | authCallback = noop; |
450 | }); | 450 | }); |
451 | 451 | ||
452 | // Handle synchronous messages from service webviews. | ||
453 | |||
454 | ipcMain.on('find-in-page', (e, text, options) => { | ||
455 | const { sender: webContents } = e; | ||
456 | if (webContents !== mainWindow.webContents && typeof (text) === 'string') { | ||
457 | const sanitizedOptions = {}; | ||
458 | for (const option of ['forward', 'findNext', 'matchCase']) { | ||
459 | if (option in options) { | ||
460 | sanitizedOptions[option] = !!options[option]; | ||
461 | } | ||
462 | } | ||
463 | const requestId = webContents.findInPage(text, sanitizedOptions); | ||
464 | debug('Find in page', text, options, requestId); | ||
465 | e.returnValue = requestId; | ||
466 | } else { | ||
467 | e.returnValue = null; | ||
468 | } | ||
469 | }); | ||
470 | |||
471 | ipcMain.on('stop-find-in-page', (e, action) => { | ||
472 | const { sender: webContents } = e; | ||
473 | if (webContents !== mainWindow.webContents) { | ||
474 | const validActions = ['clearSelection', 'keepSelection', 'activateSelection']; | ||
475 | if (validActions.includes(action)) { | ||
476 | webContents.stopFindInPage(action); | ||
477 | } | ||
478 | } | ||
479 | e.returnValue = null; | ||
480 | }); | ||
481 | |||
452 | // Quit when all windows are closed. | 482 | // Quit when all windows are closed. |
453 | app.on('window-all-closed', () => { | 483 | app.on('window-all-closed', () => { |
454 | // On OS X it is common for applications and their menu bar | 484 | // On OS X it is common for applications and their menu bar |