feat: Upgrade to Chromium 71.0.3578.98 (#15966)
This commit is contained in:
parent
92ddfd0d4c
commit
52fe92d02e
204 changed files with 2291 additions and 1760 deletions
|
@ -1,7 +1,7 @@
|
|||
'use strict'
|
||||
|
||||
const ipcRenderer = require('@electron/internal/renderer/ipc-renderer-internal')
|
||||
const { WebViewImpl } = require('@electron/internal/renderer/web-view/web-view')
|
||||
const { WebViewImpl } = require('@electron/internal/renderer/web-view/web-view-impl')
|
||||
const webViewConstants = require('@electron/internal/renderer/web-view/web-view-constants')
|
||||
const errorUtils = require('@electron/internal/common/error-utils')
|
||||
|
||||
|
|
110
lib/renderer/web-view/web-view-element.js
Normal file
110
lib/renderer/web-view/web-view-element.js
Normal file
|
@ -0,0 +1,110 @@
|
|||
'use strict'
|
||||
|
||||
// When using context isolation, the WebViewElement and the custom element
|
||||
// methods have to be defined in the main world to be able to be registered.
|
||||
//
|
||||
// Note: The hidden values can only be read/set inside the same context, all
|
||||
// methods that access the "internal" hidden value must be put in this file.
|
||||
//
|
||||
// Note: This file could be loaded in the main world of contextIsolation page,
|
||||
// which runs in browserify environment instead of Node environment, all native
|
||||
// modules must be passed from outside, all included files must be plain JS.
|
||||
|
||||
const webViewConstants = require('@electron/internal/renderer/web-view/web-view-constants')
|
||||
|
||||
// Return a WebViewElement class that is defined in this context.
|
||||
const defineWebViewElement = (v8Util, webViewImpl) => {
|
||||
const { guestViewInternal, WebViewImpl } = webViewImpl
|
||||
return class WebViewElement extends HTMLElement {
|
||||
static get observedAttributes () {
|
||||
return [
|
||||
webViewConstants.ATTRIBUTE_PARTITION,
|
||||
webViewConstants.ATTRIBUTE_SRC,
|
||||
webViewConstants.ATTRIBUTE_HTTPREFERRER,
|
||||
webViewConstants.ATTRIBUTE_USERAGENT,
|
||||
webViewConstants.ATTRIBUTE_NODEINTEGRATION,
|
||||
webViewConstants.ATTRIBUTE_PLUGINS,
|
||||
webViewConstants.ATTRIBUTE_DISABLEWEBSECURITY,
|
||||
webViewConstants.ATTRIBUTE_ALLOWPOPUPS,
|
||||
webViewConstants.ATTRIBUTE_ENABLEREMOTEMODULE,
|
||||
webViewConstants.ATTRIBUTE_PRELOAD,
|
||||
webViewConstants.ATTRIBUTE_BLINKFEATURES,
|
||||
webViewConstants.ATTRIBUTE_DISABLEBLINKFEATURES,
|
||||
webViewConstants.ATTRIBUTE_WEBPREFERENCES
|
||||
]
|
||||
}
|
||||
|
||||
constructor () {
|
||||
super()
|
||||
v8Util.setHiddenValue(this, 'internal', new WebViewImpl(this))
|
||||
}
|
||||
|
||||
connectedCallback () {
|
||||
const internal = v8Util.getHiddenValue(this, 'internal')
|
||||
if (!internal) {
|
||||
return
|
||||
}
|
||||
if (!internal.elementAttached) {
|
||||
guestViewInternal.registerEvents(internal, internal.viewInstanceId)
|
||||
internal.elementAttached = true
|
||||
internal.attributes[webViewConstants.ATTRIBUTE_SRC].parse()
|
||||
}
|
||||
}
|
||||
|
||||
attributeChangedCallback (name, oldValue, newValue) {
|
||||
const internal = v8Util.getHiddenValue(this, 'internal')
|
||||
if (internal) {
|
||||
internal.handleWebviewAttributeMutation(name, oldValue, newValue)
|
||||
}
|
||||
}
|
||||
|
||||
disconnectedCallback () {
|
||||
const internal = v8Util.getHiddenValue(this, 'internal')
|
||||
if (!internal) {
|
||||
return
|
||||
}
|
||||
guestViewInternal.deregisterEvents(internal.viewInstanceId)
|
||||
internal.elementAttached = false
|
||||
this.internalInstanceId = 0
|
||||
internal.reset()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register <webview> custom element.
|
||||
const registerWebViewElement = (v8Util, webViewImpl) => {
|
||||
const WebViewElement = defineWebViewElement(v8Util, webViewImpl)
|
||||
|
||||
webViewImpl.setupMethods(WebViewElement)
|
||||
|
||||
// The customElements.define has to be called in a special scope.
|
||||
webViewImpl.webFrame.allowGuestViewElementDefinition(window, () => {
|
||||
window.customElements.define('webview', WebViewElement)
|
||||
window.WebView = WebViewElement
|
||||
|
||||
// Delete the callbacks so developers cannot call them and produce unexpected
|
||||
// behavior.
|
||||
delete WebViewElement.prototype.connectedCallback
|
||||
delete WebViewElement.prototype.disconnectedCallback
|
||||
delete WebViewElement.prototype.attributeChangedCallback
|
||||
|
||||
// Now that |observedAttributes| has been retrieved, we can hide it from
|
||||
// user code as well.
|
||||
delete WebViewElement.observedAttributes
|
||||
})
|
||||
}
|
||||
|
||||
// Prepare to register the <webview> element.
|
||||
const setupWebView = (v8Util, webViewImpl) => {
|
||||
const useCapture = true
|
||||
window.addEventListener('readystatechange', function listener (event) {
|
||||
if (document.readyState === 'loading') {
|
||||
return
|
||||
}
|
||||
webViewImpl.setupAttributes()
|
||||
registerWebViewElement(v8Util, webViewImpl)
|
||||
window.removeEventListener(event.type, listener, useCapture)
|
||||
}, useCapture)
|
||||
}
|
||||
|
||||
module.exports = { setupWebView }
|
|
@ -20,7 +20,6 @@ const getNextId = function () {
|
|||
class WebViewImpl {
|
||||
constructor (webviewNode) {
|
||||
this.webviewNode = webviewNode
|
||||
v8Util.setHiddenValue(this.webviewNode, 'internal', this)
|
||||
this.elementAttached = false
|
||||
this.beforeFirstNavigation = true
|
||||
this.hasFocus = false
|
||||
|
@ -197,38 +196,25 @@ class WebViewImpl {
|
|||
}
|
||||
}
|
||||
|
||||
// Registers <webview> custom element.
|
||||
const registerWebViewElement = (window) => {
|
||||
const proto = Object.create(window.HTMLObjectElement.prototype)
|
||||
proto.createdCallback = function () {
|
||||
return new WebViewImpl(this)
|
||||
}
|
||||
proto.attributeChangedCallback = function (name, oldValue, newValue) {
|
||||
const setupAttributes = () => {
|
||||
require('@electron/internal/renderer/web-view/web-view-attributes')
|
||||
}
|
||||
|
||||
const setupMethods = (WebViewElement) => {
|
||||
// WebContents associated with this webview.
|
||||
WebViewElement.prototype.getWebContents = function () {
|
||||
const { getRemote } = require('@electron/internal/renderer/remote')
|
||||
const getGuestWebContents = getRemote('getGuestWebContents')
|
||||
const internal = v8Util.getHiddenValue(this, 'internal')
|
||||
if (internal) {
|
||||
internal.handleWebviewAttributeMutation(name, oldValue, newValue)
|
||||
if (!internal.guestInstanceId) {
|
||||
internal.createGuestSync()
|
||||
}
|
||||
return getGuestWebContents(internal.guestInstanceId)
|
||||
}
|
||||
proto.detachedCallback = function () {
|
||||
const internal = v8Util.getHiddenValue(this, 'internal')
|
||||
if (!internal) {
|
||||
return
|
||||
}
|
||||
guestViewInternal.deregisterEvents(internal.viewInstanceId)
|
||||
internal.elementAttached = false
|
||||
this.internalInstanceId = 0
|
||||
internal.reset()
|
||||
}
|
||||
proto.attachedCallback = function () {
|
||||
const internal = v8Util.getHiddenValue(this, 'internal')
|
||||
if (!internal) {
|
||||
return
|
||||
}
|
||||
if (!internal.elementAttached) {
|
||||
guestViewInternal.registerEvents(internal, internal.viewInstanceId)
|
||||
internal.elementAttached = true
|
||||
internal.attributes[webViewConstants.ATTRIBUTE_SRC].parse()
|
||||
}
|
||||
|
||||
// Focusing the webview should move page focus to the underlying iframe.
|
||||
WebViewElement.prototype.focus = function () {
|
||||
this.contentWindow.focus()
|
||||
}
|
||||
|
||||
const getGuestInstanceId = function (self) {
|
||||
|
@ -251,7 +237,7 @@ const registerWebViewElement = (window) => {
|
|||
}
|
||||
}
|
||||
for (const method of syncMethods) {
|
||||
proto[method] = createBlockHandler(method)
|
||||
WebViewElement.prototype[method] = createBlockHandler(method)
|
||||
}
|
||||
|
||||
const createNonBlockHandler = function (method) {
|
||||
|
@ -269,48 +255,8 @@ const registerWebViewElement = (window) => {
|
|||
}
|
||||
}
|
||||
for (const method of asyncMethods) {
|
||||
proto[method] = createNonBlockHandler(method)
|
||||
WebViewElement.prototype[method] = createNonBlockHandler(method)
|
||||
}
|
||||
|
||||
// WebContents associated with this webview.
|
||||
proto.getWebContents = function () {
|
||||
const { getRemote } = require('@electron/internal/renderer/remote')
|
||||
const getGuestWebContents = getRemote('getGuestWebContents')
|
||||
const internal = v8Util.getHiddenValue(this, 'internal')
|
||||
if (!internal.guestInstanceId) {
|
||||
internal.createGuestSync()
|
||||
}
|
||||
return getGuestWebContents(internal.guestInstanceId)
|
||||
}
|
||||
|
||||
// Focusing the webview should move page focus to the underlying iframe.
|
||||
proto.focus = function () {
|
||||
this.contentWindow.focus()
|
||||
}
|
||||
|
||||
window.WebView = webFrame.registerEmbedderCustomElement(window, 'webview', {
|
||||
prototype: proto
|
||||
})
|
||||
|
||||
// Delete the callbacks so developers cannot call them and produce unexpected
|
||||
// behavior.
|
||||
delete proto.createdCallback
|
||||
delete proto.attachedCallback
|
||||
delete proto.detachedCallback
|
||||
delete proto.attributeChangedCallback
|
||||
}
|
||||
|
||||
const setupWebView = (window) => {
|
||||
require('@electron/internal/renderer/web-view/web-view-attributes')
|
||||
|
||||
const useCapture = true
|
||||
window.addEventListener('readystatechange', function listener (event) {
|
||||
if (document.readyState === 'loading') {
|
||||
return
|
||||
}
|
||||
registerWebViewElement(window)
|
||||
window.removeEventListener(event.type, listener, useCapture)
|
||||
}, useCapture)
|
||||
}
|
||||
|
||||
module.exports = { setupWebView, WebViewImpl }
|
||||
module.exports = { setupAttributes, setupMethods, guestViewInternal, webFrame, WebViewImpl }
|
Loading…
Add table
Add a link
Reference in a new issue