New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable DevTools extensions in webviews #5913

Merged
merged 13 commits into from Jun 9, 2016

Conversation

Projects
None yet
2 participants
@kevinsawicki
Contributor

kevinsawicki commented Jun 7, 2016

Load registered extensions in the devtools for a <webview> when opened.

Closes #896

for (const win of BrowserWindow.getAllWindows()) {
loadDevToolsExtensions(win, [manifest])
for (const webContents of getAllWebContents()) {
loadDevToolsExtensions(webContents, [manifest])

This comment has been minimized.

@zcbenz

zcbenz Jun 8, 2016

Contributor

This will also load devtools extensions for the WebContents of devtools.

}
})
exports.loadDevToolsExtensions = function (webContents) {

This comment has been minimized.

@zcbenz

zcbenz Jun 8, 2016

Contributor

There is already a function named loadDevToolsExtensions, probably use a new name for this one?

@@ -155,6 +156,10 @@ var createGuest = function (embedder, params) {
guest.on('size-changed', function (_, ...args) {
embedder.send.apply(embedder, ['ELECTRON_GUEST_VIEW_INTERNAL_SIZE_CHANGED-' + guest.viewInstanceId].concat(args))
})
// Enable DevTools extensions in guest view
ChromeExtension.loadDevToolsExtensions(guest)

This comment has been minimized.

@zcbenz

zcbenz Jun 8, 2016

Contributor

We can probably add an API for webContents for hooking WebContents creations and load DevTools Extensions there, instead of injecting this code everywhere:

const {webContents} = require('electron')
webContents.on('web-contents-created', function (event, newWebContents) {
  if (newWebContents.getType() !== 'devtools')
    // ...
})
switch (type_) {
case BROWSER_WINDOW: return "window";
case WEB_VIEW: return "webview";
case REMOTE: return "remote";

This comment has been minimized.

@kevinsawicki

kevinsawicki Jun 8, 2016

Contributor

@zcbenz We should never add extensions for any "remote" webContents right? It looked like REMOTE was used in this file to return early from devtools related methods.

@zcbenz

This comment has been minimized.

Contributor

zcbenz commented Jun 9, 2016

👍

@zcbenz zcbenz merged commit 20372f0 into master Jun 9, 2016

9 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
electron-linux-arm Build #3398208 succeeded in 44s
Details
electron-linux-ia32 Build #3398209 succeeded in 38s
Details
electron-linux-x64 Build #3398210 succeeded in 120s
Details
electron-mas-x64 Build #1452 succeeded in 5 min 54 sec
Details
electron-osx-x64 Build #1456 succeeded in 6 min 55 sec
Details
electron-win-ia32 Build #453 succeeded in 6 min 12 sec
Details
electron-win-x64 Build #450 succeeded in 6 min 3 sec
Details

@zcbenz zcbenz deleted the webview-devtools-extensions branch Jun 9, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment