From 4d18cbe728b8973388075cb7f982eb6a476ed4d2 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Wed, 22 Nov 2017 16:59:00 -0800 Subject: [PATCH] :wrench: BrowserView.fromWebContents() --- lib/browser/api/browser-view.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/browser/api/browser-view.js b/lib/browser/api/browser-view.js index 60023fef92b..fe693d27c0d 100644 --- a/lib/browser/api/browser-view.js +++ b/lib/browser/api/browser-view.js @@ -5,4 +5,12 @@ const {BrowserView} = process.atomBinding('browser_view') Object.setPrototypeOf(BrowserView.prototype, EventEmitter.prototype) +BrowserView.fromWebContents = (webContents) => { + for (const view of BrowserView.getAllViews()) { + if (view.webContents.equal(webContents)) return window + } + + return null +} + module.exports = BrowserView