diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 2c8e0a51c494..fd7f0ae70541 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -744,6 +744,14 @@ int WebContents::GetID() const { return web_contents()->GetRenderProcessHost()->GetID(); } +std::string WebContents::GetType() const { + switch (type_) { + case BROWSER_WINDOW: return "window"; + case WEB_VIEW: return "webview"; + case REMOTE: return "remote"; + } +} + bool WebContents::Equal(const WebContents* web_contents) const { return GetID() == web_contents->GetID(); } @@ -1287,6 +1295,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate, .SetMethod("endFrameSubscription", &WebContents::EndFrameSubscription) .SetMethod("setSize", &WebContents::SetSize) .SetMethod("isGuest", &WebContents::IsGuest) + .SetMethod("getType", &WebContents::GetType) .SetMethod("getWebPreferences", &WebContents::GetWebPreferences) .SetMethod("getOwnerBrowserWindow", &WebContents::GetOwnerBrowserWindow) .SetMethod("hasServiceWorker", &WebContents::HasServiceWorker) diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index f8e6710a5c58..13c6ce5a7b2c 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -59,6 +59,7 @@ class WebContents : public mate::TrackableObject, v8::Local prototype); int GetID() const; + std::string GetType() const; bool Equal(const WebContents* web_contents) const; void LoadURL(const GURL& url, const mate::Dictionary& options); void DownloadURL(const GURL& url); diff --git a/lib/browser/chrome-extension.js b/lib/browser/chrome-extension.js index bb89c22e2551..da4504a6b7f6 100644 --- a/lib/browser/chrome-extension.js +++ b/lib/browser/chrome-extension.js @@ -223,6 +223,8 @@ const loadDevToolsExtensions = function (win, manifests) { } webContents.on('web-contents-created', function (webContents) { + if (webContents.getType() === 'remote') return + hookWindowForTabEvents(webContents) webContents.on('devtools-opened', function () { loadDevToolsExtensions(webContents, objectValues(manifestMap)) @@ -304,7 +306,9 @@ app.once('ready', function () { const manifest = getManifestFromPath(srcDirectory) if (manifest) { for (const webContents of getAllWebContents()) { - loadDevToolsExtensions(webContents, [manifest]) + if (webContents.getType() !== 'remote') { + loadDevToolsExtensions(webContents, [manifest]) + } } return manifest.name }