Only add extensions to non-remote webContents

This commit is contained in:
Kevin Sawicki 2016-06-08 11:41:14 -07:00
parent c8c60dd313
commit 11e68ff932
3 changed files with 15 additions and 1 deletions

View file

@ -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)

View file

@ -59,6 +59,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
v8::Local<v8::ObjectTemplate> 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);

View file

@ -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
}