Merge branch 'master' into native-window-open
This commit is contained in:
commit
8dff29185b
141 changed files with 2393 additions and 748 deletions
8
lib/browser/api/browser-view.js
Normal file
8
lib/browser/api/browser-view.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
'use strict'
|
||||
|
||||
const {EventEmitter} = require('events')
|
||||
const {BrowserView} = process.atomBinding('browser_view')
|
||||
|
||||
Object.setPrototypeOf(BrowserView.prototype, EventEmitter.prototype)
|
||||
|
||||
module.exports = BrowserView
|
|
@ -280,6 +280,27 @@ module.exports = {
|
|||
|
||||
showErrorBox: function (...args) {
|
||||
return binding.showErrorBox(...args)
|
||||
},
|
||||
|
||||
showCertificateTrustDialog: function (...args) {
|
||||
let [window, options, callback] = parseArgs(...args)
|
||||
|
||||
if (options == null || typeof options !== 'object') {
|
||||
throw new TypeError('options must be an object')
|
||||
}
|
||||
|
||||
let {certificate, message} = options
|
||||
if (certificate == null || typeof certificate !== 'object') {
|
||||
throw new TypeError('certificate must be an object')
|
||||
}
|
||||
|
||||
if (message == null) {
|
||||
message = ''
|
||||
} else if (typeof message !== 'string') {
|
||||
throw new TypeError('message must be a string')
|
||||
}
|
||||
|
||||
return binding.showCertificateTrustDialog(window, certificate, message, callback)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
module.exports = [
|
||||
{name: 'app', file: 'app'},
|
||||
{name: 'autoUpdater', file: 'auto-updater'},
|
||||
{name: 'BrowserView', file: 'browser-view'},
|
||||
{name: 'BrowserWindow', file: 'browser-window'},
|
||||
{name: 'contentTracing', file: 'content-tracing'},
|
||||
{name: 'dialog', file: 'dialog'},
|
||||
|
|
|
@ -20,22 +20,37 @@ class TouchBar extends EventEmitter {
|
|||
touchBar._addToWindow(window)
|
||||
}
|
||||
|
||||
constructor (items) {
|
||||
constructor (options) {
|
||||
super()
|
||||
|
||||
if (options == null) {
|
||||
throw new Error('Must specify options object as first argument')
|
||||
}
|
||||
|
||||
let {items, escapeItem} = options
|
||||
|
||||
// FIXME Support array as first argument, remove in 2.0
|
||||
if (Array.isArray(options)) {
|
||||
items = options
|
||||
escapeItem = null
|
||||
}
|
||||
|
||||
if (!Array.isArray(items)) {
|
||||
throw new Error('Must specify items array as first argument')
|
||||
items = []
|
||||
}
|
||||
|
||||
this.changeListener = (item) => {
|
||||
this.emit('change', item.id, item.type)
|
||||
}
|
||||
|
||||
this.windowListeners = {}
|
||||
this.items = {}
|
||||
this.ordereredItems = []
|
||||
this.escapeItem = escapeItem
|
||||
|
||||
const registerItem = (item) => {
|
||||
this.items[item.id] = item
|
||||
item.on('change', () => {
|
||||
this.emit('change', item.id, item.type)
|
||||
})
|
||||
item.on('change', this.changeListener)
|
||||
if (item.child instanceof TouchBar) {
|
||||
item.child.ordereredItems.forEach(registerItem)
|
||||
}
|
||||
|
@ -49,6 +64,24 @@ class TouchBar extends EventEmitter {
|
|||
})
|
||||
}
|
||||
|
||||
set escapeItem (item) {
|
||||
if (item != null && !(item instanceof TouchBarItem)) {
|
||||
throw new Error('Escape item must be an instance of TouchBarItem')
|
||||
}
|
||||
if (this.escapeItem != null) {
|
||||
this.escapeItem.removeListener('change', this.changeListener)
|
||||
}
|
||||
this._escapeItem = item
|
||||
if (this.escapeItem != null) {
|
||||
this.escapeItem.on('change', this.changeListener)
|
||||
}
|
||||
this.emit('escape-item-change', item)
|
||||
}
|
||||
|
||||
get escapeItem () {
|
||||
return this._escapeItem
|
||||
}
|
||||
|
||||
_addToWindow (window) {
|
||||
const {id} = window
|
||||
|
||||
|
@ -62,8 +95,16 @@ class TouchBar extends EventEmitter {
|
|||
}
|
||||
this.on('change', changeListener)
|
||||
|
||||
const escapeItemListener = (item) => {
|
||||
window._setEscapeTouchBarItem(item != null ? item : {})
|
||||
}
|
||||
this.on('escape-item-change', escapeItemListener)
|
||||
|
||||
const interactionListener = (event, itemID, details) => {
|
||||
const item = this.items[itemID]
|
||||
let item = this.items[itemID]
|
||||
if (item == null && this.escapeItem != null && this.escapeItem.id === itemID) {
|
||||
item = this.escapeItem
|
||||
}
|
||||
if (item != null && item.onInteraction != null) {
|
||||
item.onInteraction(details)
|
||||
}
|
||||
|
@ -72,6 +113,7 @@ class TouchBar extends EventEmitter {
|
|||
|
||||
const removeListeners = () => {
|
||||
this.removeListener('change', changeListener)
|
||||
this.removeListener('escape-item-change', escapeItemListener)
|
||||
window.removeListener('-touch-bar-interaction', interactionListener)
|
||||
window.removeListener('closed', removeListeners)
|
||||
window._touchBar = null
|
||||
|
@ -81,6 +123,7 @@ class TouchBar extends EventEmitter {
|
|||
this.windowListeners[id] = removeListeners
|
||||
|
||||
window._setTouchBarItems(this.ordereredItems)
|
||||
escapeItemListener(this.escapeItem)
|
||||
}
|
||||
|
||||
_removeFromWindow (window) {
|
||||
|
@ -104,7 +147,7 @@ class TouchBarItem extends EventEmitter {
|
|||
},
|
||||
set: function (value) {
|
||||
this[privateName] = value
|
||||
this.emit('change')
|
||||
this.emit('change', this)
|
||||
},
|
||||
enumerable: true
|
||||
})
|
||||
|
@ -180,6 +223,10 @@ TouchBar.TouchBarPopover = class TouchBarPopover extends TouchBarItem {
|
|||
if (!(this.child instanceof TouchBar)) {
|
||||
this.child = new TouchBar(this.child)
|
||||
}
|
||||
this.child.ordereredItems.forEach((item) => {
|
||||
item._popover = item._popover || []
|
||||
if (!item._popover.includes(this.id)) item._popover.push(this.id)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -360,15 +360,16 @@ ipcMain.on('ELECTRON_BROWSER_MEMBER_CALL', function (event, id, method, args) {
|
|||
}
|
||||
})
|
||||
|
||||
ipcMain.on('ELECTRON_BROWSER_MEMBER_SET', function (event, id, name, value) {
|
||||
ipcMain.on('ELECTRON_BROWSER_MEMBER_SET', function (event, id, name, args) {
|
||||
try {
|
||||
args = unwrapArgs(event.sender, args)
|
||||
let obj = objectsRegistry.get(id)
|
||||
|
||||
if (obj == null) {
|
||||
throwRPCError(`Cannot set property '${name}' on missing remote object ${id}`)
|
||||
}
|
||||
|
||||
obj[name] = value
|
||||
obj[name] = args[0]
|
||||
event.returnValue = null
|
||||
} catch (error) {
|
||||
event.returnValue = exceptionToMeta(error)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue