chore: remove deprecated <webview>.getWebContents() (#20986)
This commit is contained in:
parent
145ecb85c2
commit
093f2dd4a6
14 changed files with 26 additions and 137 deletions
|
@ -1,6 +1,5 @@
|
|||
import { webFrame, IpcMessageEvent } from 'electron'
|
||||
import { ipcRendererInternal } from '@electron/internal/renderer/ipc-renderer-internal'
|
||||
import * as ipcRendererUtils from '@electron/internal/renderer/ipc-renderer-internal-utils'
|
||||
|
||||
import { WebViewImpl } from '@electron/internal/renderer/web-view/web-view-impl'
|
||||
|
||||
|
@ -96,10 +95,6 @@ export function createGuest (params: Record<string, any>): Promise<number> {
|
|||
return ipcRendererInternal.invoke('ELECTRON_GUEST_VIEW_MANAGER_CREATE_GUEST', params)
|
||||
}
|
||||
|
||||
export function createGuestSync (params: Record<string, any>): number {
|
||||
return ipcRendererUtils.invokeSync('ELECTRON_GUEST_VIEW_MANAGER_CREATE_GUEST', params)
|
||||
}
|
||||
|
||||
export function attachGuest (
|
||||
elementInstanceId: number, guestInstanceId: number, params: Record<string, any>, contentWindow: Window
|
||||
) {
|
||||
|
@ -113,6 +108,5 @@ export function attachGuest (
|
|||
export const guestViewInternalModule = {
|
||||
deregisterEvents,
|
||||
createGuest,
|
||||
createGuestSync,
|
||||
attachGuest
|
||||
}
|
||||
|
|
|
@ -115,11 +115,6 @@ export class WebViewImpl {
|
|||
})
|
||||
}
|
||||
|
||||
createGuestSync () {
|
||||
this.beforeFirstNavigation = false
|
||||
this.attachGuestInstance(guestViewInternal.createGuestSync(this.buildParams()))
|
||||
}
|
||||
|
||||
dispatchEvent (webViewEvent: Electron.Event) {
|
||||
this.webviewNode.dispatchEvent(webViewEvent)
|
||||
}
|
||||
|
@ -224,26 +219,6 @@ export const setupMethods = (WebViewElement: typeof ElectronInternal.WebViewElem
|
|||
return internal.guestInstanceId
|
||||
}
|
||||
|
||||
// WebContents associated with this webview.
|
||||
WebViewElement.prototype.getWebContents = function () {
|
||||
const remote = electron.remote as Electron.RemoteInternal
|
||||
if (!remote) {
|
||||
throw new Error('getGuestWebContents requires remote, which is not enabled')
|
||||
}
|
||||
const internal = v8Util.getHiddenValue<WebViewImpl>(this, 'internal')
|
||||
if (!internal.guestInstanceId) {
|
||||
internal.createGuestSync()
|
||||
}
|
||||
|
||||
return remote.getGuestWebContents(internal.guestInstanceId!)
|
||||
}
|
||||
|
||||
WebViewElement.prototype.getWebContents = electron.deprecate.moveAPI(
|
||||
WebViewElement.prototype.getWebContents,
|
||||
'webview.getWebContents()',
|
||||
'remote.webContents.fromId(webview.getWebContentsId())'
|
||||
) as any
|
||||
|
||||
// Focusing the webview should move page focus to the underlying iframe.
|
||||
WebViewElement.prototype.focus = function () {
|
||||
this.contentWindow.focus()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue