Skip to content

Commit

Permalink
feat: make remote.getGuestWebContents() public
Browse files Browse the repository at this point in the history
  • Loading branch information
miniak committed Oct 24, 2019
1 parent e196a39 commit 811cc0e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/api/app.md
Expand Up @@ -493,7 +493,7 @@ Returns:
* `webContents` [WebContents](web-contents.md)
* `guestWebContents` [WebContents](web-contents.md)

Emitted when `<webview>.getWebContents()` is called in the renderer process of `webContents`.
Emitted when `remote.getGuestWebContents()` is called in the renderer process of `webContents`.
Calling `event.preventDefault()` will prevent the object from being returned.
Custom value can be returned by setting `event.returnValue`.

Expand Down
8 changes: 7 additions & 1 deletion docs/api/remote.md
Expand Up @@ -188,7 +188,13 @@ consequences.

### `remote.getCurrentWebContents()`

Returns [`WebContents`](web-contents.md) - The web contents of this web page.
Returns [`WebContents`](web-contents.md) - The WebContents of this web page.

### `remote.getGuestWebContents(webContentsId)`

* `webContentsId` Number

Returns [`WebContents`](web-contents.md) - The WebContents of a `<webview>` with `webContentsId`.

### `remote.getGlobal(name)`

Expand Down
8 changes: 5 additions & 3 deletions docs/api/web-contents.md
Expand Up @@ -806,7 +806,7 @@ Returns:
* `event` IpcMainEvent
* `guestWebContents` [WebContents](web-contents.md)

Emitted when `<webview>.getWebContents()` is called in the renderer process.
Emitted when `remote.getGuestWebContents()` is called in the renderer process.
Calling `event.preventDefault()` will prevent the object from being returned.
Custom value can be returned by setting `event.returnValue`.

Expand Down Expand Up @@ -1390,11 +1390,13 @@ An example of showing devtools in a `<webview>` tag:
<webview id="browser" src="https://github.com"></webview>
<webview id="devtools"></webview>
<script>
const { remote } = require('electron')
const browserView = document.getElementById('browser')
const devtoolsView = document.getElementById('devtools')
browserView.addEventListener('dom-ready', () => {
const browser = browserView.getWebContents()
browser.setDevToolsWebContents(devtoolsView.getWebContents())
const browser = remote.getGuestWebContents(browserView.getWebContentsId())
const devtools = remote.getGuestWebContents(devtoolsView.getWebContentsId())
browser.setDevToolsWebContents(devtools)
browser.openDevTools()
})
</script>
Expand Down
4 changes: 2 additions & 2 deletions docs/api/webview-tag.md
Expand Up @@ -648,9 +648,9 @@ Sets the maximum and minimum layout-based (i.e. non-visual) zoom level.

Shows pop-up dictionary that searches the selected word on the page.

### `<webview>.getWebContents()`
### `<webview>.getWebContents()` _(Deprecated)_

Returns [`WebContents`](web-contents.md) - The web contents associated with
Returns [`WebContents`](web-contents.md) - The WebContents associated with
this `webview`.

It depends on the [`remote`](remote.md) module,
Expand Down

0 comments on commit 811cc0e

Please sign in to comment.