sha
stringlengths
40
40
author
stringclasses
155 values
date
stringlengths
19
19
commit_message
stringlengths
24
9.22k
git_diff
stringlengths
110
332k
type
stringclasses
9 values
905aad9cb6007c2e0ff4897ec64f0c9967f63ee2
David Sanders
2023-06-05 15:26:26
chore: type check JS in docs (#38423) * build(deps): update @electron/lint-roller * chore: type check JS in docs * docs: add @ts-check and @ts-expect-error to code blocks * chore: fix type check errors in docs * chore: add ts-type to blocks
diff --git a/docs/api/app.md b/docs/api/app.md index fd0823c27f..35b6da350e 100755 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -971,7 +971,7 @@ app.setJumpList([ title: 'Tool A', program: process.execPath, args: '--run-tool-a', - icon: process.execPath, + iconPath: process.execPath, iconIndex: 0, description: 'Runs Tool A' }, @@ -980,7 +980,7 @@ app.setJumpList([ title: 'Tool B', program: process.execPath, args: '--run-tool-b', - icon: process.execPath, + iconPath: process.execPath, iconIndex: 0, description: 'Runs Tool B' } @@ -1418,8 +1418,8 @@ const fs = require('fs') let filepath let bookmark -dialog.showOpenDialog(null, { securityScopedBookmarks: true }, (filepaths, bookmarks) => { - filepath = filepaths[0] +dialog.showOpenDialog(null, { securityScopedBookmarks: true }).then(({ filePaths, bookmarks }) => { + filepath = filePaths[0] bookmark = bookmarks[0] fs.readFileSync(filepath) }) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 0816cd1018..d1a36589ae 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -104,6 +104,7 @@ window, you have to set both `parent` and `modal` options: ```javascript const { BrowserWindow } = require('electron') +const top = new BrowserWindow() const child = new BrowserWindow({ parent: top, modal: true, show: false }) child.loadURL('https://github.com') child.once('ready-to-show', () => { @@ -597,7 +598,7 @@ On Linux the setter is a no-op, although the getter returns `true`. A `boolean` property that determines whether the window is excluded from the application’s Windows menu. `false` by default. -```js +```js @ts-expect-error=[11] const win = new BrowserWindow({ height: 600, width: 600 }) const template = [ @@ -1200,6 +1201,9 @@ Node's [`url.format`](https://nodejs.org/api/url.html#url_url_format_urlobject) method: ```javascript +const { BrowserWindow } = require('electron') +const win = new BrowserWindow() + const url = require('url').format({ protocol: 'file', slashes: true, @@ -1213,6 +1217,9 @@ You can load a URL using a `POST` request with URL-encoded data by doing the following: ```javascript +const { BrowserWindow } = require('electron') +const win = new BrowserWindow() + win.loadURL('http://localhost:8000/post', { postData: [{ type: 'rawData', diff --git a/docs/api/client-request.md b/docs/api/client-request.md index 1ba3ec8932..3bbbe6ced4 100644 --- a/docs/api/client-request.md +++ b/docs/api/client-request.md @@ -104,7 +104,7 @@ The `callback` function is expected to be called back with user credentials: * `username` string * `password` string -```javascript +```javascript @ts-type={request:Electron.ClientRequest} request.on('login', (authInfo, callback) => { callback('username', 'password') }) @@ -113,7 +113,7 @@ request.on('login', (authInfo, callback) => { Providing empty credentials will cancel the request and report an authentication error on the response object: -```javascript +```javascript @ts-type={request:Electron.ClientRequest} request.on('response', (response) => { console.log(`STATUS: ${response.statusCode}`) response.on('error', (error) => { diff --git a/docs/api/clipboard.md b/docs/api/clipboard.md index b0602c40d3..ea5345f071 100644 --- a/docs/api/clipboard.md +++ b/docs/api/clipboard.md @@ -148,10 +148,7 @@ clipboard. ```js const { clipboard } = require('electron') -clipboard.writeBookmark({ - text: 'https://electronjs.org', - bookmark: 'Electron Homepage' -}) +clipboard.writeBookmark('Electron Homepage', 'https://electronjs.org') ``` ### `clipboard.readFindText()` _macOS_ diff --git a/docs/api/context-bridge.md b/docs/api/context-bridge.md index 738de98bb6..b2921aff72 100644 --- a/docs/api/context-bridge.md +++ b/docs/api/context-bridge.md @@ -18,7 +18,7 @@ contextBridge.exposeInMainWorld( ) ``` -```javascript +```javascript @ts-nocheck // Renderer (Main World) window.electron.doThing() @@ -104,7 +104,7 @@ contextBridge.exposeInIsolatedWorld( ) ``` -```javascript +```javascript @ts-nocheck // Renderer (In isolated world id1004) window.electron.doThing() diff --git a/docs/api/desktop-capturer.md b/docs/api/desktop-capturer.md index 96c1b6cd0f..32b881516a 100644 --- a/docs/api/desktop-capturer.md +++ b/docs/api/desktop-capturer.md @@ -10,7 +10,9 @@ title is `Electron`: ```javascript // In the main process. -const { desktopCapturer } = require('electron') +const { BrowserWindow, desktopCapturer } = require('electron') + +const mainWindow = new BrowserWindow() desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources => { for (const source of sources) { @@ -22,7 +24,7 @@ desktopCapturer.getSources({ types: ['window', 'screen'] }).then(async sources = }) ``` -```javascript +```javascript @ts-nocheck // In the preload script. const { ipcRenderer } = require('electron') diff --git a/docs/api/dialog.md b/docs/api/dialog.md index 04960ed2dc..7d1879c340 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -72,7 +72,7 @@ and a directory selector, so if you set `properties` to `['openFile', 'openDirectory']` on these platforms, a directory selector will be shown. -```js +```js @ts-type={mainWindow:Electron.BrowserWindow} dialog.showOpenDialogSync(mainWindow, { properties: ['openFile', 'openDirectory'] }) @@ -139,7 +139,7 @@ and a directory selector, so if you set `properties` to `['openFile', 'openDirectory']` on these platforms, a directory selector will be shown. -```js +```js @ts-type={mainWindow:Electron.BrowserWindow} dialog.showOpenDialog(mainWindow, { properties: ['openFile', 'openDirectory'] }).then(result => { diff --git a/docs/api/incoming-message.md b/docs/api/incoming-message.md index 92b9dec58f..904b4bfe12 100644 --- a/docs/api/incoming-message.md +++ b/docs/api/incoming-message.md @@ -89,7 +89,7 @@ tuples. So, the even-numbered offsets are key values, and the odd-numbered offsets are the associated values. Header names are not lowercased, and duplicates are not merged. -```javascript +```javascript @ts-type={response:Electron.IncomingMessage} // Prints something like: // // [ 'user-agent', @@ -100,5 +100,5 @@ duplicates are not merged. // '127.0.0.1:8000', // 'ACCEPT', // '*/*' ] -console.log(request.rawHeaders) +console.log(response.rawHeaders) ``` diff --git a/docs/api/ipc-main.md b/docs/api/ipc-main.md index 2b42afe283..3b3e14e7cd 100644 --- a/docs/api/ipc-main.md +++ b/docs/api/ipc-main.md @@ -83,14 +83,14 @@ If `listener` returns a Promise, the eventual result of the promise will be returned as a reply to the remote caller. Otherwise, the return value of the listener will be used as the value of the reply. -```js title='Main Process' +```js title='Main Process' @ts-type={somePromise:(...args:unknown[])=>Promise<unknown>} ipcMain.handle('my-invokable-ipc', async (event, ...args) => { const result = await somePromise(...args) return result }) ``` -```js title='Renderer Process' +```js title='Renderer Process' @ts-type={arg1:unknown} @ts-type={arg2:unknown} async () => { const result = await ipcRenderer.invoke('my-invokable-ipc', arg1, arg2) // ... diff --git a/docs/api/ipc-renderer.md b/docs/api/ipc-renderer.md index 3045eba639..29dd5ff79c 100644 --- a/docs/api/ipc-renderer.md +++ b/docs/api/ipc-renderer.md @@ -101,7 +101,7 @@ The main process should listen for `channel` with For example: -```javascript +```javascript @ts-type={someArgument:unknown} @ts-type={doSomeWork:(arg:unknown)=>Promise<unknown>} // Renderer process ipcRenderer.invoke('some-name', someArgument).then((result) => { // ... diff --git a/docs/api/menu.md b/docs/api/menu.md index 735fefce7e..93c794ec94 100644 --- a/docs/api/menu.md +++ b/docs/api/menu.md @@ -147,7 +147,7 @@ can have a submenu. An example of creating the application menu with the simple template API: -```javascript +```javascript @ts-expect-error=[107] const { app, Menu } = require('electron') const isMac = process.platform === 'darwin' @@ -267,7 +267,7 @@ menu on behalf of the renderer. Below is an example of showing a menu when the user right clicks the page: -```js +```js @ts-expect-error=[21] // renderer window.addEventListener('contextmenu', (e) => { e.preventDefault() @@ -289,7 +289,7 @@ ipcMain.on('show-context-menu', (event) => { { label: 'Menu Item 2', type: 'checkbox', checked: true } ] const menu = Menu.buildFromTemplate(template) - menu.popup(BrowserWindow.fromWebContents(event.sender)) + menu.popup({ window: BrowserWindow.fromWebContents(event.sender) }) }) ``` diff --git a/docs/api/message-channel-main.md b/docs/api/message-channel-main.md index 670cda868f..18339848db 100644 --- a/docs/api/message-channel-main.md +++ b/docs/api/message-channel-main.md @@ -17,7 +17,8 @@ Example: ```js // Main process -const { MessageChannelMain } = require('electron') +const { BrowserWindow, MessageChannelMain } = require('electron') +const w = new BrowserWindow() const { port1, port2 } = new MessageChannelMain() w.webContents.postMessage('port', null, [port2]) port1.postMessage({ some: 'message' }) @@ -26,9 +27,9 @@ port1.postMessage({ some: 'message' }) const { ipcRenderer } = require('electron') ipcRenderer.on('port', (e) => { // e.ports is a list of ports sent along with this message - e.ports[0].on('message', (messageEvent) => { + e.ports[0].onmessage = (messageEvent) => { console.log(messageEvent.data) - }) + } }) ``` diff --git a/docs/api/net-log.md b/docs/api/net-log.md index fec5f3d144..db16c11193 100644 --- a/docs/api/net-log.md +++ b/docs/api/net-log.md @@ -5,7 +5,7 @@ Process: [Main](../glossary.md#main-process) ```javascript -const { netLog } = require('electron') +const { app, netLog } = require('electron') app.whenReady().then(async () => { await netLog.startLogging('/path/to/net-log') diff --git a/docs/api/protocol.md b/docs/api/protocol.md index 4ca6b5ebb0..e5d726f79c 100644 --- a/docs/api/protocol.md +++ b/docs/api/protocol.md @@ -32,7 +32,7 @@ To have your custom protocol work in combination with a custom session, you need to register it to that session explicitly. ```javascript -const { session, app, protocol } = require('electron') +const { app, BrowserWindow, net, protocol, session } = require('electron') const path = require('path') const url = require('url') @@ -41,11 +41,11 @@ app.whenReady().then(() => { const ses = session.fromPartition(partition) ses.protocol.handle('atom', (request) => { - const path = request.url.slice('atom://'.length) - return net.fetch(url.pathToFileURL(path.join(__dirname, path))) + const filePath = request.url.slice('atom://'.length) + return net.fetch(url.pathToFileURL(path.join(__dirname, filePath)).toString()) }) - mainWindow = new BrowserWindow({ webPreferences: { partition } }) + const mainWindow = new BrowserWindow({ webPreferences: { partition } }) }) ``` @@ -121,9 +121,9 @@ Either a `Response` or a `Promise<Response>` can be returned. Example: ```js -import { app, protocol } from 'electron' -import { join } from 'path' -import { pathToFileURL } from 'url' +const { app, net, protocol } = require('electron') +const { join } = require('path') +const { pathToFileURL } = require('url') protocol.registerSchemesAsPrivileged([ { @@ -131,7 +131,7 @@ protocol.registerSchemesAsPrivileged([ privileges: { standard: true, secure: true, - supportsFetchAPI: true + supportFetchAPI: true } } ]) @@ -147,7 +147,7 @@ app.whenReady().then(() => { } // NB, this does not check for paths that escape the bundle, e.g. // app://bundle/../../secret_file.txt - return net.fetch(pathToFileURL(join(__dirname, pathname))) + return net.fetch(pathToFileURL(join(__dirname, pathname)).toString()) } else if (host === 'api') { return net.fetch('https://api.my-server.com/' + pathname, { method: req.method, diff --git a/docs/api/session.md b/docs/api/session.md index 334a2a4e4d..e999a5207b 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -98,7 +98,7 @@ Emitted when Electron is about to download `item` in `webContents`. Calling `event.preventDefault()` will cancel the download and `item` will not be available from next tick of the process. -```javascript +```javascript @ts-expect-error=[4] const { session } = require('electron') session.defaultSession.on('will-download', (event, item, webContents) => { event.preventDefault() @@ -214,7 +214,7 @@ cancel the request. Additionally, permissioning on `navigator.hid` can be further managed by using [`ses.setPermissionCheckHandler(handler)`](#sessetpermissioncheckhandlerhandler) and [`ses.setDevicePermissionHandler(handler)`](#sessetdevicepermissionhandlerhandler). -```javascript +```javascript @ts-type={fetchGrantedDevices:()=>(Array<Electron.DevicePermissionHandlerHandlerDetails['device']>)} const { app, BrowserWindow } = require('electron') let win = null @@ -253,7 +253,7 @@ app.whenReady().then(() => { win.webContents.session.on('select-hid-device', (event, details, callback) => { event.preventDefault() const selectedDevice = details.deviceList.find((device) => { - return device.vendorId === '9025' && device.productId === '67' + return device.vendorId === 9025 && device.productId === 67 }) callback(selectedDevice?.deviceId) }) @@ -320,7 +320,7 @@ cancel the request. Additionally, permissioning on `navigator.serial` can be managed by using [ses.setPermissionCheckHandler(handler)](#sessetpermissioncheckhandlerhandler) with the `serial` permission. -```javascript +```javascript @ts-type={fetchGrantedDevices:()=>(Array<Electron.DevicePermissionHandlerHandlerDetails['device']>)} const { app, BrowserWindow } = require('electron') let win = null @@ -463,7 +463,7 @@ cancel the request. Additionally, permissioning on `navigator.usb` can be further managed by using [`ses.setPermissionCheckHandler(handler)`](#sessetpermissioncheckhandlerhandler) and [`ses.setDevicePermissionHandler(handler)`](#sessetdevicepermissionhandlerhandler). -```javascript +```javascript @ts-type={fetchGrantedDevices:()=>(Array<Electron.DevicePermissionHandlerHandlerDetails['device']>)} @ts-type={updateGrantedDevices:(devices:Array<Electron.DevicePermissionHandlerHandlerDetails['device']>)=>void} const { app, BrowserWindow } = require('electron') let win = null @@ -502,7 +502,7 @@ app.whenReady().then(() => { win.webContents.session.on('select-usb-device', (event, details, callback) => { event.preventDefault() const selectedDevice = details.deviceList.find((device) => { - return device.vendorId === '9025' && device.productId === '67' + return device.vendorId === 9025 && device.productId === 67 }) if (selectedDevice) { // Optionally, add this to the persisted devices (updateGrantedDevices needs to be implemented by developer to persist permissions) @@ -755,15 +755,17 @@ Sets download saving directory. By default, the download directory will be the Emulates network with the given configuration for the `session`. ```javascript +const win = new BrowserWindow() + // To emulate a GPRS connection with 50kbps throughput and 500 ms latency. -window.webContents.session.enableNetworkEmulation({ +win.webContents.session.enableNetworkEmulation({ latency: 500, downloadThroughput: 6400, uploadThroughput: 6400 }) // To emulate a network outage. -window.webContents.session.enableNetworkEmulation({ offline: true }) +win.webContents.session.enableNetworkEmulation({ offline: true }) ``` #### `ses.preconnect(options)` @@ -1036,7 +1038,7 @@ Additionally, the default behavior of Electron is to store granted device permis If longer term storage is needed, a developer can store granted device permissions (eg when handling the `select-hid-device` event) and then read from that storage with `setDevicePermissionHandler`. -```javascript +```javascript @ts-type={fetchGrantedDevices:()=>(Array<Electron.DevicePermissionHandlerHandlerDetails['device']>)} const { app, BrowserWindow } = require('electron') let win = null @@ -1084,9 +1086,9 @@ app.whenReady().then(() => { win.webContents.session.on('select-hid-device', (event, details, callback) => { event.preventDefault() const selectedDevice = details.deviceList.find((device) => { - return device.vendorId === '9025' && device.productId === '67' + return device.vendorId === 9025 && device.productId === 67 }) - callback(selectedPort?.deviceId) + callback(selectedDevice?.deviceId) }) }) ``` @@ -1174,31 +1176,31 @@ macOS does not require a handler because macOS handles the pairing automatically. To clear the handler, call `setBluetoothPairingHandler(null)`. ```javascript - -const { app, BrowserWindow, ipcMain, session } = require('electron') - -let bluetoothPinCallback = null +const { app, BrowserWindow, session } = require('electron') +const path = require('path') function createWindow () { + let bluetoothPinCallback = null + const mainWindow = new BrowserWindow({ webPreferences: { preload: path.join(__dirname, 'preload.js') } }) -} -// Listen for an IPC message from the renderer to get the response for the Bluetooth pairing. -ipcMain.on('bluetooth-pairing-response', (event, response) => { - bluetoothPinCallback(response) -}) + mainWindow.webContents.session.setBluetoothPairingHandler((details, callback) => { + bluetoothPinCallback = callback + // Send a IPC message to the renderer to prompt the user to confirm the pairing. + // Note that this will require logic in the renderer to handle this message and + // display a prompt to the user. + mainWindow.webContents.send('bluetooth-pairing-request', details) + }) -mainWindow.webContents.session.setBluetoothPairingHandler((details, callback) => { - bluetoothPinCallback = callback - // Send a IPC message to the renderer to prompt the user to confirm the pairing. - // Note that this will require logic in the renderer to handle this message and - // display a prompt to the user. - mainWindow.webContents.send('bluetooth-pairing-request', details) -}) + // Listen for an IPC message from the renderer to get the response for the Bluetooth pairing. + mainWindow.webContents.ipc.on('bluetooth-pairing-response', (event, response) => { + bluetoothPinCallback(response) + }) +} app.whenReady().then(() => { createWindow() diff --git a/docs/api/touch-bar.md b/docs/api/touch-bar.md index 10bf400ab4..7cbcc83ddd 100644 --- a/docs/api/touch-bar.md +++ b/docs/api/touch-bar.md @@ -87,12 +87,12 @@ const { TouchBarLabel, TouchBarButton, TouchBarSpacer } = TouchBar let spinning = false // Reel labels -const reel1 = new TouchBarLabel() -const reel2 = new TouchBarLabel() -const reel3 = new TouchBarLabel() +const reel1 = new TouchBarLabel({ label: '' }) +const reel2 = new TouchBarLabel({ label: '' }) +const reel3 = new TouchBarLabel({ label: '' }) // Spin result label -const result = new TouchBarLabel() +const result = new TouchBarLabel({ label: '' }) // Spin button const spin = new TouchBarButton({ diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 43e1a522c6..abcbac0ef1 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -98,7 +98,7 @@ async function lookupTargetId (browserWindow) { await wc.debugger.attach('1.3') const { targetInfo } = await wc.debugger.sendCommand('Target.getTargetInfo') const { targetId } = targetInfo - const targetWebContents = await webContents.fromDevToolsTargetId(targetId) + const targetWebContents = await wc.fromDevToolsTargetId(targetId) } ``` @@ -1020,9 +1020,9 @@ e.g. the `http://` or `file://`. If the load should bypass http cache then use the `pragma` header to achieve it. ```javascript -const { webContents } = require('electron') +const win = new BrowserWindow() const options = { extraHeaders: 'pragma: no-cache\n' } -webContents.loadURL('https://github.com', options) +win.webContents.loadURL('https://github.com', options) ``` #### `contents.loadFile(filePath[, options])` @@ -1052,6 +1052,7 @@ an app structure like this: Would require code like this ```js +const win = new BrowserWindow() win.loadFile('src/index.html') ``` @@ -1188,7 +1189,9 @@ when this process is unstable or unusable, for instance in order to recover from the `unresponsive` event. ```js -contents.on('unresponsive', async () => { +const win = new BrowserWindow() + +win.webContents.on('unresponsive', async () => { const { response } = await dialog.showMessageBox({ message: 'App X has become unresponsive', title: 'Do you want to try forcefully reloading the app?', @@ -1196,8 +1199,8 @@ contents.on('unresponsive', async () => { cancelId: 1 }) if (response === 0) { - contents.forcefullyCrashRenderer() - contents.reload() + win.webContents.forcefullyCrashRenderer() + win.webContents.reload() } }) ``` @@ -1224,8 +1227,9 @@ Injects CSS into the current web page and returns a unique key for the inserted stylesheet. ```js -contents.on('did-finish-load', () => { - contents.insertCSS('html, body { background-color: #f00; }') +const win = new BrowserWindow() +win.webContents.on('did-finish-load', () => { + win.webContents.insertCSS('html, body { background-color: #f00; }') }) ``` @@ -1239,9 +1243,11 @@ Removes the inserted CSS from the current web page. The stylesheet is identified by its key, which is returned from `contents.insertCSS(css)`. ```js -contents.on('did-finish-load', async () => { - const key = await contents.insertCSS('html, body { background-color: #f00; }') - contents.removeInsertedCSS(key) +const win = new BrowserWindow() + +win.webContents.on('did-finish-load', async () => { + const key = await win.webContents.insertCSS('html, body { background-color: #f00; }') + win.webContents.removeInsertedCSS(key) }) ``` @@ -1262,7 +1268,9 @@ this limitation. Code execution will be suspended until web page stop loading. ```js -contents.executeJavaScript('fetch("https://jsonplaceholder.typicode.com/users/1").then(resp => resp.json())', true) +const win = new BrowserWindow() + +win.webContents.executeJavaScript('fetch("https://jsonplaceholder.typicode.com/users/1").then(resp => resp.json())', true) .then((result) => { console.log(result) // Will be the JSON object from the fetch call }) @@ -1373,7 +1381,8 @@ Sets the maximum and minimum pinch-to-zoom level. > **NOTE**: Visual zoom is disabled by default in Electron. To re-enable it, call: > > ```js -> contents.setVisualZoomLevelLimits(1, 3) +> const win = new BrowserWindow() +> win.webContents.setVisualZoomLevelLimits(1, 3) > ``` #### `contents.undo()` @@ -1508,12 +1517,12 @@ can be obtained by subscribing to [`found-in-page`](web-contents.md#event-found- Stops any `findInPage` request for the `webContents` with the provided `action`. ```javascript -const { webContents } = require('electron') -webContents.on('found-in-page', (event, result) => { - if (result.finalUpdate) webContents.stopFindInPage('clearSelection') +const win = new BrowserWindow() +win.webContents.on('found-in-page', (event, result) => { + if (result.finalUpdate) win.webContents.stopFindInPage('clearSelection') }) -const requestId = webContents.findInPage('api') +const requestId = win.webContents.findInPage('api') console.log(requestId) ``` @@ -1593,6 +1602,7 @@ Use `page-break-before: always;` CSS style to force to print to a new page. Example usage: ```js +const win = new BrowserWindow() const options = { silent: true, deviceName: 'My-Printer', @@ -1889,8 +1899,9 @@ For example: ```js // Main process +const win = new BrowserWindow() const { port1, port2 } = new MessageChannelMain() -webContents.postMessage('port', { message: 'hello' }, [port1]) +win.webContents.postMessage('port', { message: 'hello' }, [port1]) // Renderer process ipcRenderer.on('port', (e, msg) => { diff --git a/docs/api/web-frame-main.md b/docs/api/web-frame-main.md index 34033a8564..53a5f1f8b6 100644 --- a/docs/api/web-frame-main.md +++ b/docs/api/web-frame-main.md @@ -128,8 +128,9 @@ For example: ```js // Main process +const win = new BrowserWindow() const { port1, port2 } = new MessageChannelMain() -webContents.mainFrame.postMessage('port', { message: 'hello' }, [port1]) +win.webContents.mainFrame.postMessage('port', { message: 'hello' }, [port1]) // Renderer process ipcRenderer.on('port', (e, msg) => { diff --git a/docs/api/web-frame.md b/docs/api/web-frame.md index 06bf313547..db4ec1c31a 100644 --- a/docs/api/web-frame.md +++ b/docs/api/web-frame.md @@ -96,13 +96,12 @@ with an array of misspelt words when complete. An example of using [node-spellchecker][spellchecker] as provider: -```javascript +```javascript @ts-expect-error=[2,6] const { webFrame } = require('electron') const spellChecker = require('spellchecker') webFrame.setSpellCheckProvider('en-US', { spellCheck (words, callback) { setTimeout(() => { - const spellchecker = require('spellchecker') const misspelled = words.filter(x => spellchecker.isMisspelled(x)) callback(misspelled) }, 0) diff --git a/docs/api/webview-tag.md b/docs/api/webview-tag.md index bc81fa8ed6..4a71c998f5 100644 --- a/docs/api/webview-tag.md +++ b/docs/api/webview-tag.md @@ -255,7 +255,7 @@ The `webview` tag has the following methods: **Example** -```javascript +```javascript @ts-expect-error=[3] const webview = document.querySelector('webview') webview.addEventListener('dom-ready', () => { webview.openDevTools() @@ -799,7 +799,7 @@ Fired when the guest window logs a console message. The following example code forwards all log messages to the embedder's console without regard for log level or other properties. -```javascript +```javascript @ts-expect-error=[3] const webview = document.querySelector('webview') webview.addEventListener('console-message', (e) => { console.log('Guest page logged a message:', e.message) @@ -820,7 +820,7 @@ Returns: Fired when a result is available for [`webview.findInPage`](#webviewfindinpagetext-options) request. -```javascript +```javascript @ts-expect-error=[3,6] const webview = document.querySelector('webview') webview.addEventListener('found-in-page', (e) => { webview.stopFindInPage('keepSelection') @@ -945,7 +945,7 @@ Fired when the guest page attempts to close itself. The following example code navigates the `webview` to `about:blank` when the guest attempts to close itself. -```javascript +```javascript @ts-expect-error=[3] const webview = document.querySelector('webview') webview.addEventListener('close', () => { webview.src = 'about:blank' @@ -965,7 +965,7 @@ Fired when the guest page has sent an asynchronous message to embedder page. With `sendToHost` method and `ipc-message` event you can communicate between guest page and embedder page: -```javascript +```javascript @ts-expect-error=[4,7] // In embedder page. const webview = document.querySelector('webview') webview.addEventListener('ipc-message', (event) => { diff --git a/docs/tutorial/asar-archives.md b/docs/tutorial/asar-archives.md index 23b987f42e..d010bc9603 100644 --- a/docs/tutorial/asar-archives.md +++ b/docs/tutorial/asar-archives.md @@ -55,7 +55,7 @@ fs.readdirSync('/path/to/example.asar') Use a module from the archive: -```javascript +```javascript @ts-nocheck require('./path/to/example.asar/dir/module.js') ``` diff --git a/docs/tutorial/asar-integrity.md b/docs/tutorial/asar-integrity.md index 63320cea31..2bbf3ec840 100644 --- a/docs/tutorial/asar-integrity.md +++ b/docs/tutorial/asar-integrity.md @@ -40,7 +40,7 @@ Valid `algorithm` values are currently `SHA256` only. The `hash` is a hash of t ASAR integrity checking is currently disabled by default and can be enabled by toggling a fuse. See [Electron Fuses](fuses.md) for more information on what Electron Fuses are and how they work. When enabling this fuse you typically also want to enable the `onlyLoadAppFromAsar` fuse otherwise the validity checking can be bypassed via the Electron app code search path. -```js +```js @ts-nocheck require('@electron/fuses').flipFuses( // E.g. /a/b/Foo.app pathToPackagedApp, diff --git a/docs/tutorial/automated-testing.md b/docs/tutorial/automated-testing.md index bb80b00365..650d5ca882 100644 --- a/docs/tutorial/automated-testing.md +++ b/docs/tutorial/automated-testing.md @@ -90,7 +90,7 @@ Usage of `selenium-webdriver` with Electron is the same as with normal websites, except that you have to manually specify how to connect ChromeDriver and where to find the binary of your Electron app: -```js title='test.js' +```js title='test.js' @ts-expect-error=[1] const webdriver = require('selenium-webdriver') const driver = new webdriver.Builder() // The "9515" is the port opened by ChromeDriver. @@ -155,7 +155,7 @@ Playwright launches your app in development mode through the `_electron.launch` To point this API to your Electron app, you can pass the path to your main process entry point (here, it is `main.js`). -```js {5} +```js {5} @ts-nocheck const { _electron: electron } = require('playwright') const { test } = require('@playwright/test') @@ -169,7 +169,7 @@ test('launch app', async () => { After that, you will access to an instance of Playwright's `ElectronApp` class. This is a powerful class that has access to main process modules for example: -```js {6-11} +```js {6-11} @ts-nocheck const { _electron: electron } = require('playwright') const { test } = require('@playwright/test') @@ -189,7 +189,7 @@ test('get isPackaged', async () => { It can also create individual [Page][playwright-page] objects from Electron BrowserWindow instances. For example, to grab the first BrowserWindow and save a screenshot: -```js {6-7} +```js {6-7} @ts-nocheck const { _electron: electron } = require('playwright') const { test } = require('@playwright/test') @@ -205,7 +205,7 @@ test('save screenshot', async () => { Putting all this together using the PlayWright Test runner, let's create a `example.spec.js` test file with a single test and assertion: -```js title='example.spec.js' +```js title='example.spec.js' @ts-nocheck const { _electron: electron } = require('playwright') const { test, expect } = require('@playwright/test') @@ -259,7 +259,7 @@ expose custom methods to your test suite. To create a custom driver, we'll use Node.js' [`child_process`](https://nodejs.org/api/child_process.html) API. The test suite will spawn the Electron process, then establish a simple messaging protocol: -```js title='testDriver.js' +```js title='testDriver.js' @ts-nocheck const childProcess = require('child_process') const electronPath = require('electron') @@ -296,7 +296,7 @@ For convenience, you may want to wrap `appProcess` in a driver object that provi high-level functions. Here is an example of how you can do this. Let's start by creating a `TestDriver` class: -```js title='testDriver.js' +```js title='testDriver.js' @ts-nocheck class TestDriver { constructor ({ path, args, env }) { this.rpcCalls = [] @@ -378,7 +378,7 @@ framework of your choosing. The following example uses [`ava`](https://www.npmjs.com/package/ava), but other popular choices like Jest or Mocha would work as well: -```js title='test.js' +```js title='test.js' @ts-nocheck const test = require('ava') const electronPath = require('electron') const { TestDriver } = require('./testDriver') diff --git a/docs/tutorial/code-signing.md b/docs/tutorial/code-signing.md index d52267ad9e..e4ac634260 100644 --- a/docs/tutorial/code-signing.md +++ b/docs/tutorial/code-signing.md @@ -67,7 +67,7 @@ are likely using [`electron-packager`][], which includes [`@electron/osx-sign`][ If you're using Packager's API, you can pass [in configuration that both signs and notarizes your application](https://electron.github.io/electron-packager/main/interfaces/electronpackager.options.html). -```js +```js @ts-nocheck const packager = require('electron-packager') packager({ @@ -116,7 +116,7 @@ Electron app. This is the tool used under the hood by Electron Forge's `electron-winstaller` directly, use the `certificateFile` and `certificatePassword` configuration options when creating your installer. -```js {10-11} +```js {10-11} @ts-nocheck const electronInstaller = require('electron-winstaller') // NB: Use this syntax within an async function, Node does not have support for // top-level await as of Node 12. @@ -146,7 +146,7 @@ If you're not using Electron Forge and want to use `electron-wix-msi` directly, `certificateFile` and `certificatePassword` configuration options or pass in parameters directly to [SignTool.exe][] with the `signWithParams` option. -```js {12-13} +```js {12-13} @ts-nocheck import { MSICreator } from 'electron-wix-msi' // Step 1: Instantiate the MSICreator diff --git a/docs/tutorial/context-isolation.md b/docs/tutorial/context-isolation.md index c68c62faca..5615d4d9b3 100644 --- a/docs/tutorial/context-isolation.md +++ b/docs/tutorial/context-isolation.md @@ -16,7 +16,7 @@ Context isolation has been enabled by default since Electron 12, and it is a rec Exposing APIs from your preload script to a loaded website in the renderer process is a common use-case. With context isolation disabled, your preload script would share a common global `window` object with the renderer. You could then attach arbitrary properties to a preload script: -```javascript title='preload.js' +```javascript title='preload.js' @ts-nocheck // preload with contextIsolation disabled window.myAPI = { doAThing: () => {} @@ -25,7 +25,7 @@ window.myAPI = { The `doAThing()` function could then be used directly in the renderer process: -```javascript title='renderer.js' +```javascript title='renderer.js' @ts-nocheck // use the exposed API in the renderer window.myAPI.doAThing() ``` @@ -43,7 +43,7 @@ contextBridge.exposeInMainWorld('myAPI', { }) ``` -```javascript title='renderer.js' +```javascript title='renderer.js' @ts-nocheck // use the exposed API in the renderer window.myAPI.doAThing() ``` @@ -98,7 +98,7 @@ declare global { Doing so will ensure that the TypeScript compiler will know about the `electronAPI` property on your global `window` object when writing scripts in your renderer process: -```typescript title='renderer.ts' +```typescript title='renderer.ts' @ts-nocheck window.electronAPI.loadPreferences() ``` diff --git a/docs/tutorial/dark-mode.md b/docs/tutorial/dark-mode.md index 0e53d42e02..73134fcb95 100644 --- a/docs/tutorial/dark-mode.md +++ b/docs/tutorial/dark-mode.md @@ -116,7 +116,7 @@ Now the renderer process can communicate with the main process securely and perf The `renderer.js` file is responsible for controlling the `<button>` functionality. -```js title='renderer.js' +```js title='renderer.js' @ts-expect-error=[2,7] document.getElementById('toggle-dark-mode').addEventListener('click', async () => { const isDarkMode = await window.darkMode.toggle() document.getElementById('theme-source').innerHTML = isDarkMode ? 'Dark' : 'Light' diff --git a/docs/tutorial/fuses.md b/docs/tutorial/fuses.md index d933a841c4..ed39e7b267 100644 --- a/docs/tutorial/fuses.md +++ b/docs/tutorial/fuses.md @@ -67,7 +67,7 @@ The loadBrowserProcessSpecificV8Snapshot fuse changes which V8 snapshot file is We've made a handy module, [`@electron/fuses`](https://npmjs.com/package/@electron/fuses), to make flipping these fuses easy. Check out the README of that module for more details on usage and potential error cases. -```js +```js @ts-nocheck require('@electron/fuses').flipFuses( // Path to electron require('electron'), diff --git a/docs/tutorial/installation.md b/docs/tutorial/installation.md index be604a73c3..3b8dc06567 100644 --- a/docs/tutorial/installation.md +++ b/docs/tutorial/installation.md @@ -66,7 +66,7 @@ You can use environment variables to override the base URL, the path at which to look for Electron binaries, and the binary filename. The URL used by `@electron/get` is composed as follows: -```javascript +```javascript @ts-nocheck url = ELECTRON_MIRROR + ELECTRON_CUSTOM_DIR + '/' + ELECTRON_CUSTOM_FILENAME ``` diff --git a/docs/tutorial/ipc.md b/docs/tutorial/ipc.md index 5fa02aae70..2111382c31 100644 --- a/docs/tutorial/ipc.md +++ b/docs/tutorial/ipc.md @@ -138,7 +138,7 @@ To make these elements interactive, we'll be adding a few lines of code in the i `renderer.js` file that leverages the `window.electronAPI` functionality exposed from the preload script: -```javascript title='renderer.js (Renderer Process)' +```javascript title='renderer.js (Renderer Process)' @ts-expect-error=[4,5] const setButton = document.getElementById('btn') const titleInput = document.getElementById('title') setButton.addEventListener('click', () => { @@ -182,13 +182,13 @@ provided to the renderer process. Please refer to ::: ```javascript {6-13,25} title='main.js (Main Process)' -const { BrowserWindow, dialog, ipcMain } = require('electron') +const { app, BrowserWindow, dialog, ipcMain } = require('electron') const path = require('path') // ... async function handleFileOpen () { - const { canceled, filePaths } = await dialog.showOpenDialog() + const { canceled, filePaths } = await dialog.showOpenDialog({}) if (!canceled) { return filePaths[0] } @@ -203,7 +203,7 @@ function createWindow () { mainWindow.loadFile('index.html') } -app.whenReady(() => { +app.whenReady().then(() => { ipcMain.handle('dialog:openFile', handleFileOpen) createWindow() }) @@ -263,7 +263,7 @@ The UI consists of a single `#btn` button element that will be used to trigger o a `#filePath` element that will be used to display the path of the selected file. Making these pieces work will take a few lines of code in the renderer process script: -```javascript title='renderer.js (Renderer Process)' +```javascript title='renderer.js (Renderer Process)' @ts-expect-error=[5] const btn = document.getElementById('btn') const filePathElement = document.getElementById('filePath') @@ -412,7 +412,7 @@ function createWindow () { For the purposes of the tutorial, it's important to note that the `click` handler sends a message (either `1` or `-1`) to the renderer process through the `update-counter` channel. -```javascript +```javascript @ts-nocheck click: () => mainWindow.webContents.send('update-counter', -1) ``` @@ -486,7 +486,7 @@ To tie it all together, we'll create an interface in the loaded HTML file that c Finally, to make the values update in the HTML document, we'll add a few lines of DOM manipulation so that the value of the `#counter` element is updated whenever we fire an `update-counter` event. -```javascript title='renderer.js (Renderer Process)' +```javascript title='renderer.js (Renderer Process)' @ts-nocheck const counter = document.getElementById('counter') window.electronAPI.onUpdateCounter((_event, value) => { @@ -509,7 +509,7 @@ We can demonstrate this with slight modifications to the code from the previous renderer process, use the `event` parameter to send a reply back to the main process through the `counter-value` channel. -```javascript title='renderer.js (Renderer Process)' +```javascript title='renderer.js (Renderer Process)' @ts-nocheck const counter = document.getElementById('counter') window.electronAPI.onUpdateCounter((event, value) => { diff --git a/docs/tutorial/keyboard-shortcuts.md b/docs/tutorial/keyboard-shortcuts.md index 52197637e0..a9b329683d 100644 --- a/docs/tutorial/keyboard-shortcuts.md +++ b/docs/tutorial/keyboard-shortcuts.md @@ -56,7 +56,7 @@ Starting with a working application from the [Quick Start Guide](quick-start.md), update the `main.js` file with the following lines: -```javascript fiddle='docs/fiddles/features/keyboard-shortcuts/global' +```javascript fiddle='docs/fiddles/features/keyboard-shortcuts/global' @ts-type={createWindow:()=>void} const { app, globalShortcut } = require('electron') app.whenReady().then(() => { @@ -131,7 +131,7 @@ If you don't want to do manual shortcut parsing, there are libraries that do advanced key detection, such as [mousetrap][]. Below are examples of usage of the `mousetrap` running in the Renderer process: -```js +```js @ts-nocheck Mousetrap.bind('4', () => { console.log('4') }) Mousetrap.bind('?', () => { console.log('show shortcuts!') }) Mousetrap.bind('esc', () => { console.log('escape') }, 'keyup') diff --git a/docs/tutorial/launch-app-from-url-in-another-app.md b/docs/tutorial/launch-app-from-url-in-another-app.md index 7ed98d3454..4fe2212d04 100644 --- a/docs/tutorial/launch-app-from-url-in-another-app.md +++ b/docs/tutorial/launch-app-from-url-in-another-app.md @@ -45,6 +45,8 @@ if (process.defaultApp) { We will now define the function in charge of creating our browser window and load our application's `index.html` file. ```javascript +let mainWindow + const createWindow = () => { // Create the browser window. mainWindow = new BrowserWindow({ @@ -65,7 +67,7 @@ This code will be different in Windows compared to MacOS and Linux. This is due #### Windows code: -```javascript +```javascript @ts-type={mainWindow:Electron.BrowserWindow} @ts-type={createWindow:()=>void} const gotTheLock = app.requestSingleInstanceLock() if (!gotTheLock) { @@ -91,7 +93,7 @@ if (!gotTheLock) { #### MacOS and Linux code: -```javascript +```javascript @ts-type={createWindow:()=>void} // This method will be called when Electron has finished // initialization and is ready to create browser windows. // Some APIs can only be used after this event occurs. @@ -166,7 +168,7 @@ If you're using Electron Packager's API, adding support for protocol handlers is Electron Forge is handled, except `protocols` is part of the Packager options passed to the `packager` function. -```javascript +```javascript @ts-nocheck const packager = require('electron-packager') packager({ diff --git a/docs/tutorial/message-ports.md b/docs/tutorial/message-ports.md index 73ec5f6f9b..54ac0f9fa1 100644 --- a/docs/tutorial/message-ports.md +++ b/docs/tutorial/message-ports.md @@ -126,7 +126,7 @@ app.whenReady().then(async () => { Then, in your preload scripts you receive the port through IPC and set up the listeners. -```js title='preloadMain.js and preloadSecondary.js (Preload scripts)' +```js title='preloadMain.js and preloadSecondary.js (Preload scripts)' @ts-nocheck const { ipcRenderer } = require('electron') ipcRenderer.on('port', e => { @@ -148,7 +148,7 @@ That means window.electronMessagePort is globally available and you can call `postMessage` on it from anywhere in your app to send a message to the other renderer. -```js title='renderer.js (Renderer Process)' +```js title='renderer.js (Renderer Process)' @ts-nocheck // elsewhere in your code to send a message to the other renderers message handler window.electronMessagePort.postmessage('ping') ``` @@ -181,7 +181,7 @@ app.whenReady().then(async () => { // We can't use ipcMain.handle() here, because the reply needs to transfer a // MessagePort. // Listen for message sent from the top-level frame - mainWindow.webContents.mainFrame.on('request-worker-channel', (event) => { + mainWindow.webContents.mainFrame.ipc.on('request-worker-channel', (event) => { // Create a new channel ... const { port1, port2 } = new MessageChannelMain() // ... send one end to the worker ... @@ -245,7 +245,7 @@ Electron's built-in IPC methods only support two modes: fire-and-forget can implement a "response stream", where a single request responds with a stream of data. -```js title='renderer.js (Renderer Process)' +```js title='renderer.js (Renderer Process)' @ts-expect-error=[18] const makeStreamingRequest = (element, callback) => { // MessageChannels are lightweight--it's cheap to create a new one for each // request. diff --git a/docs/tutorial/multithreading.md b/docs/tutorial/multithreading.md index d42350e2c7..5a078fd191 100644 --- a/docs/tutorial/multithreading.md +++ b/docs/tutorial/multithreading.md @@ -42,7 +42,7 @@ safe. The only way to load a native module safely for now, is to make sure the app loads no native modules after the Web Workers get started. -```javascript +```javascript @ts-expect-error=[1] process.dlopen = () => { throw new Error('Load native module is not safe') } diff --git a/docs/tutorial/native-file-drag-drop.md b/docs/tutorial/native-file-drag-drop.md index c8dba82c8d..aa987e1e9b 100644 --- a/docs/tutorial/native-file-drag-drop.md +++ b/docs/tutorial/native-file-drag-drop.md @@ -22,6 +22,7 @@ In `preload.js` use the [`contextBridge`][] to inject a method `window.electron. ```js const { contextBridge, ipcRenderer } = require('electron') +const path = require('path') contextBridge.exposeInMainWorld('electron', { startDrag: (fileName) => { @@ -43,7 +44,7 @@ Add a draggable element to `index.html`, and reference your renderer script: In `renderer.js` set up the renderer process to handle drag events by calling the method you added via the [`contextBridge`][] above. -```javascript +```javascript @ts-expect-error=[3] document.getElementById('drag').ondragstart = (event) => { event.preventDefault() window.electron.startDrag('drag-and-drop.md') diff --git a/docs/tutorial/performance.md b/docs/tutorial/performance.md index 6e0910461c..974663ab50 100644 --- a/docs/tutorial/performance.md +++ b/docs/tutorial/performance.md @@ -173,7 +173,7 @@ in the fictitious `.foo` format. In order to do that, it relies on the equally fictitious `foo-parser` module. In traditional Node.js development, you might write code that eagerly loads dependencies: -```js title='parser.js' +```js title='parser.js' @ts-expect-error=[2] const fs = require('fs') const fooParser = require('foo-parser') @@ -196,7 +196,7 @@ In the above example, we're doing a lot of work that's being executed as soon as the file is loaded. Do we need to get parsed files right away? Could we do this work a little later, when `getParsedFiles()` is actually called? -```js title='parser.js' +```js title='parser.js' @ts-expect-error=[20] // "fs" is likely already being loaded, so the `require()` call is cheap const fs = require('fs') @@ -205,7 +205,7 @@ class Parser { // Touch the disk as soon as `getFiles` is called, not sooner. // Also, ensure that we're not blocking other operations by using // the asynchronous version. - this.files = this.files || await fs.readdir('.') + this.files = this.files || await fs.promises.readdir('.') return this.files } diff --git a/docs/tutorial/process-model.md b/docs/tutorial/process-model.md index b6f5b0fce0..06c56e02d3 100644 --- a/docs/tutorial/process-model.md +++ b/docs/tutorial/process-model.md @@ -175,13 +175,13 @@ Although preload scripts share a `window` global with the renderer they're attac you cannot directly attach any variables from the preload script to `window` because of the [`contextIsolation`][context-isolation] default. -```js title='preload.js' +```js title='preload.js' @ts-nocheck window.myAPI = { desktop: true } ``` -```js title='renderer.js' +```js title='renderer.js' @ts-nocheck console.log(window.myAPI) // => undefined ``` @@ -200,7 +200,7 @@ contextBridge.exposeInMainWorld('myAPI', { }) ``` -```js title='renderer.js' +```js title='renderer.js' @ts-nocheck console.log(window.myAPI) // => { desktop: true } ``` diff --git a/docs/tutorial/quick-start.md b/docs/tutorial/quick-start.md index f74c570faa..762b098acf 100644 --- a/docs/tutorial/quick-start.md +++ b/docs/tutorial/quick-start.md @@ -182,7 +182,7 @@ In Electron, browser windows can only be created after the `app` module's [`app.whenReady()`][app-when-ready] API. Call `createWindow()` after `whenReady()` resolves its Promise. -```js +```js @ts-type={createWindow:()=>void} app.whenReady().then(() => { createWindow() }) @@ -239,7 +239,7 @@ from within your existing `whenReady()` callback. [activate]: ../api/app.md#event-activate-macos -```js +```js @ts-type={createWindow:()=>void} app.whenReady().then(() => { createWindow() @@ -290,6 +290,7 @@ To attach this script to your renderer process, pass in the path to your preload to the `webPreferences.preload` option in your existing `BrowserWindow` constructor. ```js +const { app, BrowserWindow } = require('electron') // include the Node.js 'path' module at the top of your file const path = require('path') diff --git a/docs/tutorial/security.md b/docs/tutorial/security.md index c9d26c4fb3..e277c722ae 100644 --- a/docs/tutorial/security.md +++ b/docs/tutorial/security.md @@ -141,7 +141,7 @@ like `HTTP`. Similarly, we recommend the use of `WSS` over `WS`, `FTPS` over #### How? -```js title='main.js (Main Process)' +```js title='main.js (Main Process)' @ts-type={browserWindow:Electron.BrowserWindow} // Bad browserWindow.loadURL('http://example.com') @@ -278,7 +278,7 @@ security-conscious developers might want to assume the very opposite. ```js title='main.js (Main Process)' const { session } = require('electron') -const URL = require('url').URL +const { URL } = require('url') session .fromPartition('some-partition') @@ -608,7 +608,8 @@ sometimes be fooled - a `startsWith('https://example.com')` test would let `https://example.com.attacker.com` through. ```js title='main.js (Main Process)' -const URL = require('url').URL +const { URL } = require('url') +const { app } = require('electron') app.on('web-contents-created', (event, contents) => { contents.on('will-navigate', (event, navigationUrl) => { @@ -647,8 +648,8 @@ receive, amongst other parameters, the `url` the window was requested to open and the options used to create it. We recommend that you register a handler to monitor the creation of windows, and deny any unexpected window creation. -```js title='main.js (Main Process)' -const { shell } = require('electron') +```js title='main.js (Main Process)' @ts-type={isSafeForExternalOpen:(url:string)=>boolean} +const { app, shell } = require('electron') app.on('web-contents-created', (event, contents) => { contents.setWindowOpenHandler(({ url }) => { @@ -683,7 +684,7 @@ leveraged to execute arbitrary commands. #### How? -```js title='main.js (Main Process)' +```js title='main.js (Main Process)' @ts-type={USER_CONTROLLED_DATA_HERE:string} // Bad const { shell } = require('electron') shell.openExternal(USER_CONTROLLED_DATA_HERE) @@ -739,7 +740,7 @@ You should be validating the `sender` of **all** IPC messages by default. #### How? -```js title='main.js (Main Process)' +```js title='main.js (Main Process)' @ts-type={getSecrets:()=>unknown} // Bad ipcMain.handle('get-secrets', () => { return getSecrets() diff --git a/docs/tutorial/snapcraft.md b/docs/tutorial/snapcraft.md index 3df6ac506e..09e7a7830c 100644 --- a/docs/tutorial/snapcraft.md +++ b/docs/tutorial/snapcraft.md @@ -72,7 +72,7 @@ npx electron-installer-snap --src=out/myappname-linux-x64 If you have an existing build pipeline, you can use `electron-installer-snap` programmatically. For more information, see the [Snapcraft API docs][snapcraft-syntax]. -```js +```js @ts-nocheck const snap = require('electron-installer-snap') snap(options) diff --git a/docs/tutorial/spellchecker.md b/docs/tutorial/spellchecker.md index 4854d6515a..2df7b409ec 100644 --- a/docs/tutorial/spellchecker.md +++ b/docs/tutorial/spellchecker.md @@ -20,12 +20,12 @@ On macOS as we use the native APIs there is no way to set the language that the For Windows and Linux there are a few Electron APIs you should use to set the languages for the spellchecker. -```js +```js @ts-type={myWindow:Electron.BrowserWindow} // Sets the spellchecker to check English US and French -myWindow.session.setSpellCheckerLanguages(['en-US', 'fr']) +myWindow.webContents.session.setSpellCheckerLanguages(['en-US', 'fr']) // An array of all available language codes -const possibleLanguages = myWindow.session.availableSpellCheckerLanguages +const possibleLanguages = myWindow.webContents.session.availableSpellCheckerLanguages ``` By default the spellchecker will enable the language matching the current OS locale. @@ -35,7 +35,7 @@ By default the spellchecker will enable the language matching the current OS loc All the required information to generate a context menu is provided in the [`context-menu`](../api/web-contents.md#event-context-menu) event on each `webContents` instance. A small example of how to make a context menu with this information is provided below. -```js +```js @ts-type={myWindow:Electron.BrowserWindow} const { Menu, MenuItem } = require('electron') myWindow.webContents.on('context-menu', (event, params) => { @@ -45,7 +45,7 @@ myWindow.webContents.on('context-menu', (event, params) => { for (const suggestion of params.dictionarySuggestions) { menu.append(new MenuItem({ label: suggestion, - click: () => mainWindow.webContents.replaceMisspelling(suggestion) + click: () => myWindow.webContents.replaceMisspelling(suggestion) })) } @@ -54,7 +54,7 @@ myWindow.webContents.on('context-menu', (event, params) => { menu.append( new MenuItem({ label: 'Add to dictionary', - click: () => mainWindow.webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord) + click: () => myWindow.webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord) }) ) } @@ -67,8 +67,8 @@ myWindow.webContents.on('context-menu', (event, params) => { Although the spellchecker itself does not send any typings, words or user input to Google services the hunspell dictionary files are downloaded from a Google CDN by default. If you want to avoid this you can provide an alternative URL to download the dictionaries from. -```js -myWindow.session.setSpellCheckerDictionaryDownloadURL('https://example.com/dictionaries/') +```js @ts-type={myWindow:Electron.BrowserWindow} +myWindow.webContents.session.setSpellCheckerDictionaryDownloadURL('https://example.com/dictionaries/') ``` Check out the docs for [`session.setSpellCheckerDictionaryDownloadURL`](../api/session.md#sessetspellcheckerdictionarydownloadurlurl) for more information on where to get the dictionary files from and how you need to host them. diff --git a/docs/tutorial/tray.md b/docs/tutorial/tray.md index efa7e2e7a2..28f92adfec 100644 --- a/docs/tutorial/tray.md +++ b/docs/tutorial/tray.md @@ -51,7 +51,7 @@ app.whenReady().then(() => { Great! Now we can start attaching a context menu to our Tray, like so: -```js +```js @ts-expect-error=[8] const contextMenu = Menu.buildFromTemplate([ { label: 'Item1', type: 'radio' }, { label: 'Item2', type: 'radio' }, @@ -68,7 +68,7 @@ To read more about constructing native menus, click Finally, let's give our tray a tooltip and a title. -```js +```js @ts-type={tray:Electron.Tray} tray.setToolTip('This is my application') tray.setTitle('This is my title') ``` diff --git a/docs/tutorial/tutorial-2-first-app.md b/docs/tutorial/tutorial-2-first-app.md index 4046f6059d..8f0fd17977 100644 --- a/docs/tutorial/tutorial-2-first-app.md +++ b/docs/tutorial/tutorial-2-first-app.md @@ -256,7 +256,7 @@ const createWindow = () => { ### Calling your function when the app is ready -```js title='main.js (Lines 12-14)' +```js title='main.js (Lines 12-14)' @ts-type={createWindow:()=>void} app.whenReady().then(() => { createWindow() }) @@ -336,7 +336,7 @@ Because windows cannot be created before the `ready` event, you should only list `activate` events after your app is initialized. Do this by only listening for activate events inside your existing `whenReady()` callback. -```js +```js @ts-type={createWindow:()=>void} app.whenReady().then(() => { createWindow() diff --git a/docs/tutorial/tutorial-3-preload.md b/docs/tutorial/tutorial-3-preload.md index 263bab3b77..7f87fe2da0 100644 --- a/docs/tutorial/tutorial-3-preload.md +++ b/docs/tutorial/tutorial-3-preload.md @@ -118,7 +118,7 @@ information in the window. This variable can be accessed via `window.versions` o `versions`. Create a `renderer.js` script that uses the [`document.getElementById`][] DOM API to replace the displayed text for the HTML element with `info` as its `id` property. -```js title="renderer.js" +```js title="renderer.js" @ts-nocheck const information = document.getElementById('info') information.innerText = `This app is using Chrome (v${versions.chrome()}), Node.js (v${versions.node()}), and Electron (v${versions.electron()})` ``` @@ -225,7 +225,7 @@ app.whenReady().then(() => { Once you have the sender and receiver set up, you can now send messages from the renderer to the main process through the `'ping'` channel you just defined. -```js title='renderer.js' +```js title='renderer.js' @ts-expect-error=[2] const func = async () => { const response = await window.versions.ping() console.log(response) // prints out 'pong' diff --git a/docs/tutorial/tutorial-6-publishing-updating.md b/docs/tutorial/tutorial-6-publishing-updating.md index d280339d47..bb099bef9b 100644 --- a/docs/tutorial/tutorial-6-publishing-updating.md +++ b/docs/tutorial/tutorial-6-publishing-updating.md @@ -188,7 +188,7 @@ npm install update-electron-app Then, import the module and call it immediately in the main process. -```js title='main.js' +```js title='main.js' @ts-nocheck require('update-electron-app')() ``` diff --git a/docs/tutorial/updates.md b/docs/tutorial/updates.md index fce4357805..eed2a0261e 100644 --- a/docs/tutorial/updates.md +++ b/docs/tutorial/updates.md @@ -32,7 +32,7 @@ npm install update-electron-app Then, invoke the updater from your app's main process file: -```js title="main.js" +```js title="main.js" @ts-nocheck require('update-electron-app')() ``` @@ -113,7 +113,7 @@ Now that you've configured the basic update mechanism for your application, you need to ensure that the user will get notified when there's an update. This can be achieved using the [autoUpdater API events](../api/auto-updater.md#events): -```javascript title="main.js" +```javascript title="main.js" @ts-expect-error=[11] autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { const dialogOpts = { type: 'info', diff --git a/docs/tutorial/window-customization.md b/docs/tutorial/window-customization.md index 3c1ce9269d..6f32158811 100644 --- a/docs/tutorial/window-customization.md +++ b/docs/tutorial/window-customization.md @@ -196,9 +196,9 @@ const win = new BrowserWindow({ } }) -ipcMain.on('set-ignore-mouse-events', (event, ...args) => { +ipcMain.on('set-ignore-mouse-events', (event, ignore, options) => { const win = BrowserWindow.fromWebContents(event.sender) - win.setIgnoreMouseEvents(...args) + win.setIgnoreMouseEvents(ignore, options) }) ``` diff --git a/docs/tutorial/windows-taskbar.md b/docs/tutorial/windows-taskbar.md index 2a995fbb0a..450acd271e 100644 --- a/docs/tutorial/windows-taskbar.md +++ b/docs/tutorial/windows-taskbar.md @@ -125,7 +125,7 @@ Starting with a working application from the following lines: ```javascript -const { BrowserWindow } = require('electron') +const { BrowserWindow, nativeImage } = require('electron') const path = require('path') const win = new BrowserWindow() @@ -133,11 +133,11 @@ const win = new BrowserWindow() win.setThumbarButtons([ { tooltip: 'button1', - icon: path.join(__dirname, 'button1.png'), + icon: nativeImage.createFromPath(path.join(__dirname, 'button1.png')), click () { console.log('button1 clicked') } }, { tooltip: 'button2', - icon: path.join(__dirname, 'button2.png'), + icon: nativeImage.createFromPath(path.join(__dirname, 'button2.png')), flags: ['enabled', 'dismissonclick'], click () { console.log('button2 clicked.') } } @@ -189,11 +189,11 @@ Starting with a working application from the following lines: ```javascript -const { BrowserWindow } = require('electron') +const { BrowserWindow, nativeImage } = require('electron') const win = new BrowserWindow() -win.setOverlayIcon('path/to/overlay.png', 'Description for overlay') +win.setOverlayIcon(nativeImage.createFromPath('path/to/overlay.png'), 'Description for overlay') ``` [msdn-icon-overlay]: https://learn.microsoft.com/en-us/windows/win32/shell/taskbar-extensions#icon-overlays diff --git a/package.json b/package.json index ad85adabfe..e835f7d52e 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "@electron/docs-parser": "^1.1.0", "@electron/fiddle-core": "^1.0.4", "@electron/github-app-auth": "^2.0.0", - "@electron/lint-roller": "^1.2.1", + "@electron/lint-roller": "^1.5.0", "@electron/typescript-definitions": "^8.14.0", "@octokit/rest": "^19.0.7", "@primer/octicons": "^10.0.0", @@ -30,6 +30,7 @@ "@types/stream-json": "^1.5.1", "@types/temp": "^0.8.34", "@types/uuid": "^3.4.6", + "@types/w3c-web-serial": "^1.0.3", "@types/webpack": "^5.28.0", "@types/webpack-env": "^1.17.0", "@typescript-eslint/eslint-plugin": "^5.59.7", @@ -87,10 +88,11 @@ "lint:objc": "node ./script/lint.js --objc", "lint:py": "node ./script/lint.js --py", "lint:gn": "node ./script/lint.js --gn", - "lint:docs": "remark docs -qf && npm run lint:js-in-markdown && npm run create-typescript-definitions && npm run lint:docs-fiddles && npm run lint:docs-relative-links && npm run lint:markdownlint", + "lint:docs": "remark docs -qf && npm run lint:js-in-markdown && npm run create-typescript-definitions && npm run lint:ts-check-js-in-markdown && npm run lint:docs-fiddles && npm run lint:docs-relative-links && npm run lint:markdownlint", "lint:docs-fiddles": "standard \"docs/fiddles/**/*.js\"", "lint:docs-relative-links": "electron-lint-markdown-links --root docs \"**/*.md\"", "lint:markdownlint": "electron-markdownlint \"*.md\" \"docs/**/*.md\"", + "lint:ts-check-js-in-markdown": "electron-lint-markdown-ts-check --root docs \"**/*.md\" --ignore \"breaking-changes.md\"", "lint:js-in-markdown": "electron-lint-markdown-standard --root docs \"**/*.md\"", "create-api-json": "node script/create-api-json.js", "create-typescript-definitions": "npm run create-api-json && electron-typescript-definitions --api=electron-api.json && node spec/ts-smoke/runner.js", diff --git a/yarn.lock b/yarn.lock index ccfcb6e743..d95a8b2971 100644 --- a/yarn.lock +++ b/yarn.lock @@ -194,10 +194,10 @@ "@octokit/auth-app" "^4.0.13" "@octokit/rest" "^19.0.11" -"@electron/lint-roller@^1.2.1": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@electron/lint-roller/-/lint-roller-1.2.1.tgz#9f9d99b0a8975646e0a0131ab1b21a2ec62e80d8" - integrity sha512-w9PelpTBX8ClAv2iVa8fYqK77dnN0zWiHW98Utf8D83nmxkCMQNrKdRupSyiuIttbic1Nao8FhTScppmzOz0gw== +"@electron/lint-roller@^1.5.0": + version "1.5.0" + resolved "https://registry.yarnpkg.com/@electron/lint-roller/-/lint-roller-1.5.0.tgz#9b743979e1b03327e475fa696bb781eb2ea05ef2" + integrity sha512-205UxwJEx8zv5wLwPq4wMA0OYrJ7d1GuqOhPav0Uy2HWe4K+DZbSP50safCvZCSpI6Op3DMo79tp5i8VppuPWA== dependencies: "@dsanders11/vscode-markdown-languageservice" "^0.3.0" glob "^8.1.0" @@ -206,6 +206,7 @@ mdast-util-from-markdown "^1.3.0" minimist "^1.2.8" node-fetch "^2.6.9" + rimraf "^4.4.1" standard "^17.0.0" unist-util-visit "^4.1.2" vscode-languageserver "^8.1.0" @@ -1066,6 +1067,11 @@ dependencies: "@types/node" "*" +"@types/w3c-web-serial@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@types/w3c-web-serial/-/w3c-web-serial-1.0.3.tgz#9fd5e8542f74e464bb1715b384b5c0dcbf2fb2c3" + integrity sha512-R4J/OjqKAUFQoXVIkaUTfzb/sl6hLh/ZhDTfowJTRMa7LhgEmI/jXV4zsL1u8HpNa853BxwNmDIr0pauizzwSQ== + "@types/webpack-env@^1.17.0": version "1.17.0" resolved "https://registry.yarnpkg.com/@types/webpack-env/-/webpack-env-1.17.0.tgz#f99ce359f1bfd87da90cc4a57cab0a18f34a48d0" @@ -3156,6 +3162,16 @@ glob@^8.1.0: minimatch "^5.0.1" once "^1.3.0" +glob@^9.2.0: + version "9.3.5" + resolved "https://registry.yarnpkg.com/glob/-/glob-9.3.5.tgz#ca2ed8ca452781a3009685607fdf025a899dfe21" + integrity sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q== + dependencies: + fs.realpath "^1.0.0" + minimatch "^8.0.2" + minipass "^4.2.4" + path-scurry "^1.6.1" + glob@~8.0.3: version "8.0.3" resolved "https://registry.yarnpkg.com/glob/-/glob-8.0.3.tgz#415c6eb2deed9e502c68fa44a272e6da6eeca42e" @@ -4078,7 +4094,7 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" -lru-cache@^9.0.0: +lru-cache@^9.0.0, lru-cache@^9.1.1: version "9.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-9.1.1.tgz#c58a93de58630b688de39ad04ef02ef26f1902f1" integrity sha512-65/Jky17UwSb0BuB9V+MyDpsOtXKmYwzhyl+cOa9XUiI4uV2Ouy/2voFP3+al0BjZbJgMBD8FojMpAf+Z+qn4A== @@ -4514,6 +4530,13 @@ minimatch@^5.0.1: dependencies: brace-expansion "^2.0.1" +minimatch@^8.0.2: + version "8.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-8.0.4.tgz#847c1b25c014d4e9a7f68aaf63dedd668a626229" + integrity sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA== + dependencies: + brace-expansion "^2.0.1" + minimatch@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.2.tgz#0939d7d6f0898acbd1508abe534d1929368a8fff" @@ -4543,6 +4566,16 @@ minipass@^4.0.0: resolved "https://registry.yarnpkg.com/minipass/-/minipass-4.0.1.tgz#2b9408c6e81bb8b338d600fb3685e375a370a057" integrity sha512-V9esFpNbK0arbN3fm2sxDKqMYgIp7XtVdE4Esj+PE4Qaaxdg1wIw48ITQIOn1sc8xXSmUviVL3cyjMqPlrVkiA== +minipass@^4.2.4: + version "4.2.8" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-4.2.8.tgz#f0010f64393ecfc1d1ccb5f582bcaf45f48e1a3a" + integrity sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ== + +"minipass@^5.0.0 || ^6.0.2": + version "6.0.2" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-6.0.2.tgz#542844b6c4ce95b202c0995b0a471f1229de4c81" + integrity sha512-MzWSV5nYVT7mVyWCwn2o7JH13w2TBRmmSqSRCKzTw+lmft9X4z+3wjvs06Tzijo5z4W/kahUCDpRXTF+ZrmF/w== + minizlib@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931" @@ -4933,6 +4966,14 @@ path-parse@^1.0.6, path-parse@^1.0.7: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.7.tgz#fbc114b60ca42b30d9daf5858e4bd68bbedb6735" integrity sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw== +path-scurry@^1.6.1: + version "1.9.2" + resolved "https://registry.yarnpkg.com/path-scurry/-/path-scurry-1.9.2.tgz#90f9d296ac5e37e608028e28a447b11d385b3f63" + integrity sha512-qSDLy2aGFPm8i4rsbHd4MNyTcrzHFsLQykrtbuGRknZZCBBVXSv2tSCDN2Cg6Rt/GFRw8GoW9y9Ecw5rIPG1sg== + dependencies: + lru-cache "^9.1.1" + minipass "^5.0.0 || ^6.0.2" + [email protected]: version "0.1.7" resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c" @@ -5830,6 +5871,13 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" +rimraf@^4.4.1: + version "4.4.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-4.4.1.tgz#bd33364f67021c5b79e93d7f4fa0568c7c21b755" + integrity sha512-Gk8NlF062+T9CqNGn6h4tls3k6T1+/nXdOcSZVikNVtlRdYpA7wRJJMoXmuvOnLW844rPjdQ7JgXCYM6PPC/og== + dependencies: + glob "^9.2.0" + rimraf@~2.2.6: version "2.2.8" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582"
chore
76f7bbb0a8db04c002293b2753f24146518737b5
Jeremy Rose
2024-04-08 10:30:23
fix: move BrowserWindow's WebContentsView to be a child of rootview (#41256)
diff --git a/shell/browser/api/electron_api_browser_window.cc b/shell/browser/api/electron_api_browser_window.cc index 106af4a6ac..acbbd88cb4 100644 --- a/shell/browser/api/electron_api_browser_window.cc +++ b/shell/browser/api/electron_api_browser_window.cc @@ -77,6 +77,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args, WebContentsView::Create(isolate, web_preferences); DCHECK(web_contents_view.get()); window_->AddDraggableRegionProvider(web_contents_view.get()); + web_contents_view_.Reset(isolate, web_contents_view.ToV8()); // Save a reference of the WebContents. gin::Handle<WebContents> web_contents = @@ -92,7 +93,14 @@ BrowserWindow::BrowserWindow(gin::Arguments* args, InitWithArgs(args); // Install the content view after BaseWindow's JS code is initialized. - SetContentView(gin::CreateHandle<View>(isolate, web_contents_view.get())); + // The WebContentsView is added a sibling of BaseWindow's contentView (before + // it in the paint order) so that any views added to BrowserWindow's + // contentView will be painted on top of the BrowserWindow's WebContentsView. + // See https://github.com/electron/electron/pull/41256. + // Note that |GetContentsView|, confusingly, does not refer to the same thing + // as |BaseWindow::GetContentView|. + window()->GetContentsView()->AddChildViewAt(web_contents_view->view(), 0); + window()->GetContentsView()->DeprecatedLayoutImmediately(); // Init window after everything has been setup. window()->InitFromOptions(options); diff --git a/shell/browser/api/electron_api_browser_window.h b/shell/browser/api/electron_api_browser_window.h index e5d580138f..df9f9754ce 100644 --- a/shell/browser/api/electron_api_browser_window.h +++ b/shell/browser/api/electron_api_browser_window.h @@ -95,6 +95,7 @@ class BrowserWindow : public BaseWindow, base::CancelableRepeatingClosure window_unresponsive_closure_; v8::Global<v8::Value> web_contents_; + v8::Global<v8::Value> web_contents_view_; base::WeakPtr<api::WebContents> api_web_contents_; base::WeakPtrFactory<BrowserWindow> weak_factory_{this}; diff --git a/shell/browser/api/frame_subscriber.cc b/shell/browser/api/frame_subscriber.cc index 358ce6e116..cdb65c7667 100644 --- a/shell/browser/api/frame_subscriber.cc +++ b/shell/browser/api/frame_subscriber.cc @@ -42,6 +42,7 @@ void FrameSubscriber::AttachToHost(content::RenderWidgetHost* host) { // Create and configure the video capturer. gfx::Size size = GetRenderViewSize(); + DCHECK(!size.IsEmpty()); video_capturer_ = host_->GetView()->CreateVideoCapturer(); video_capturer_->SetResolutionConstraints(size, size, true); video_capturer_->SetAutoThrottlingEnabled(false); diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 86dbfc1e9c..0528acdada 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -469,12 +469,12 @@ void NativeWindowViews::SetGTKDarkThemeEnabled(bool use_dark_theme) { void NativeWindowViews::SetContentView(views::View* view) { if (content_view()) { - root_view_.RemoveChildView(content_view()); + root_view_.GetMainView()->RemoveChildView(content_view()); } set_content_view(view); focused_view_ = view; - root_view_.AddChildView(content_view()); - root_view_.DeprecatedLayoutImmediately(); + root_view_.GetMainView()->AddChildView(content_view()); + root_view_.GetMainView()->DeprecatedLayoutImmediately(); } void NativeWindowViews::Close() { @@ -1664,7 +1664,7 @@ std::u16string NativeWindowViews::GetWindowTitle() const { } views::View* NativeWindowViews::GetContentsView() { - return &root_view_; + return root_view_.GetMainView(); } bool NativeWindowViews::ShouldDescendIntoChildForEventHandling( @@ -1674,7 +1674,7 @@ bool NativeWindowViews::ShouldDescendIntoChildForEventHandling( } views::ClientView* NativeWindowViews::CreateClientView(views::Widget* widget) { - return new NativeWindowClientView{widget, GetContentsView(), this}; + return new NativeWindowClientView{widget, &root_view_, this}; } std::unique_ptr<views::NonClientFrameView> diff --git a/shell/browser/ui/views/root_view.cc b/shell/browser/ui/views/root_view.cc index 273f96f48b..b0f59e994b 100644 --- a/shell/browser/ui/views/root_view.cc +++ b/shell/browser/ui/views/root_view.cc @@ -9,18 +9,12 @@ #include "content/public/common/input/native_web_keyboard_event.h" #include "shell/browser/native_window.h" #include "shell/browser/ui/views/menu_bar.h" +#include "ui/views/layout/box_layout.h" namespace electron { namespace { -// The menu bar height in pixels. -#if BUILDFLAG(IS_WIN) -const int kMenuBarHeight = 20; -#else -const int kMenuBarHeight = 25; -#endif - bool IsAltKey(const content::NativeWebKeyboardEvent& event) { return event.windows_key_code == ui::VKEY_MENU; } @@ -41,6 +35,12 @@ RootView::RootView(NativeWindow* window) : window_(window), last_focused_view_tracker_(std::make_unique<views::ViewTracker>()) { set_owned_by_client(); + views::BoxLayout* layout = + SetLayoutManager(std::make_unique<views::BoxLayout>( + views::BoxLayout::Orientation::kVertical)); + main_view_ = AddChildView(std::make_unique<views::View>()); + main_view_->SetUseDefaultFillLayout(true); + layout->SetFlexForView(main_view_, 1); } RootView::~RootView() = default; @@ -77,7 +77,7 @@ bool RootView::HasMenu() const { } int RootView::GetMenuBarHeight() const { - return kMenuBarHeight; + return menu_bar_ ? menu_bar_->GetPreferredSize().height() : 0; } void RootView::SetAutoHideMenuBar(bool auto_hide) { @@ -90,10 +90,8 @@ void RootView::SetMenuBarVisibility(bool visible) { menu_bar_visible_ = visible; if (visible) { - DCHECK_EQ(children().size(), 1ul); - AddChildView(menu_bar_.get()); + AddChildViewAt(menu_bar_.get(), 0); } else { - DCHECK_EQ(children().size(), 2ul); RemoveChildView(menu_bar_.get()); } @@ -166,21 +164,6 @@ void RootView::ResetAltState() { menu_bar_alt_pressed_ = false; } -void RootView::Layout(PassKey) { - if (!window_->content_view()) // Not ready yet. - return; - - const auto menu_bar_bounds = - menu_bar_visible_ ? gfx::Rect(0, 0, size().width(), kMenuBarHeight) - : gfx::Rect(); - if (menu_bar_) - menu_bar_->SetBoundsRect(menu_bar_bounds); - - window_->content_view()->SetBoundsRect( - gfx::Rect(0, menu_bar_visible_ ? menu_bar_bounds.bottom() : 0, - size().width(), size().height() - menu_bar_bounds.height())); -} - gfx::Size RootView::GetMinimumSize() const { return window_->GetMinimumSize(); } diff --git a/shell/browser/ui/views/root_view.h b/shell/browser/ui/views/root_view.h index 7aa52a22c1..5f27e23c60 100644 --- a/shell/browser/ui/views/root_view.h +++ b/shell/browser/ui/views/root_view.h @@ -46,8 +46,9 @@ class RootView : public views::View { void RegisterAcceleratorsWithFocusManager(ElectronMenuModel* menu_model); void UnregisterAcceleratorsWithFocusManager(); + views::View* GetMainView() { return main_view_; } + // views::View: - void Layout(PassKey) override; gfx::Size GetMinimumSize() const override; gfx::Size GetMaximumSize() const override; bool AcceleratorPressed(const ui::Accelerator& accelerator) override; @@ -62,6 +63,9 @@ class RootView : public views::View { bool menu_bar_visible_ = false; bool menu_bar_alt_pressed_ = false; + // Main view area. + raw_ptr<views::View> main_view_; + // Map from accelerator to menu item's command id. accelerator_util::AcceleratorTable accelerator_table_; diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index 1ed5d2f480..64c794163f 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -31,7 +31,7 @@ const isScaleFactorRounding = () => { const expectBoundsEqual = (actual: any, expected: any) => { if (!isScaleFactorRounding()) { - expect(expected).to.deep.equal(actual); + expect(actual).to.deep.equal(expected); } else if (Array.isArray(actual)) { expect(actual[0]).to.be.closeTo(expected[0], 1); expect(actual[1]).to.be.closeTo(expected[1], 1);
fix
7ed3c7a359c78c725ba02eaf5edd28968e356a32
Milan Burda
2023-03-20 15:26:42
chore: remove unnecessary casting to base::Value (#37591) Co-authored-by: Milan Burda <[email protected]>
diff --git a/shell/browser/api/electron_api_debugger.cc b/shell/browser/api/electron_api_debugger.cc index 0a9e88630a..0aaa71a289 100755 --- a/shell/browser/api/electron_api_debugger.cc +++ b/shell/browser/api/electron_api_debugger.cc @@ -153,7 +153,7 @@ v8::Local<v8::Promise> Debugger::SendCommand(gin::Arguments* args) { request.Set("id", request_id); request.Set("method", method); if (!command_params.empty()) { - request.Set("params", base::Value(std::move(command_params))); + request.Set("params", std::move(command_params)); } if (!session_id.empty()) { @@ -161,7 +161,7 @@ v8::Local<v8::Promise> Debugger::SendCommand(gin::Arguments* args) { } std::string json_args; - base::JSONWriter::Write(base::Value(std::move(request)), &json_args); + base::JSONWriter::Write(request, &json_args); agent_host_->DispatchProtocolMessage( this, base::as_bytes(base::make_span(json_args))); diff --git a/shell/browser/api/electron_api_web_request.cc b/shell/browser/api/electron_api_web_request.cc index 428b9d8aa5..0e3b4ae622 100644 --- a/shell/browser/api/electron_api_web_request.cc +++ b/shell/browser/api/electron_api_web_request.cc @@ -159,8 +159,7 @@ v8::Local<v8::Value> HttpResponseHeadersToV8( values->Append(base::Value(value)); } } - return gin::ConvertToV8(v8::Isolate::GetCurrent(), - base::Value(std::move(response_headers))); + return gin::ConvertToV8(v8::Isolate::GetCurrent(), response_headers); } // Overloaded by multiple types to fill the |details| object. diff --git a/shell/browser/ui/inspectable_web_contents.cc b/shell/browser/ui/inspectable_web_contents.cc index 6a0afd12e9..5549a6ff0e 100644 --- a/shell/browser/ui/inspectable_web_contents.cc +++ b/shell/browser/ui/inspectable_web_contents.cc @@ -623,7 +623,7 @@ void InspectableWebContents::AddDevToolsExtensionsToClient() { extension_info.Set("exposeExperimentalAPIs", extension->permissions_data()->HasAPIPermission( extensions::mojom::APIPermissionID::kExperimental)); - results.Append(base::Value(std::move(extension_info))); + results.Append(std::move(extension_info)); } CallClientFunction("DevToolsAPI", "addExtensions", diff --git a/shell/browser/ui/webui/accessibility_ui.cc b/shell/browser/ui/webui/accessibility_ui.cc index b5b9de2d5e..e086ce289f 100644 --- a/shell/browser/ui/webui/accessibility_ui.cc +++ b/shell/browser/ui/webui/accessibility_ui.cc @@ -282,7 +282,7 @@ void HandleAccessibilityRequestCallback( descriptor.Set(kNative, is_native_enabled); descriptor.Set(kWeb, is_web_enabled); descriptor.Set(kLabelImages, are_accessibility_image_labels_enabled); - rvh_list.Append(base::Value(std::move(descriptor))); + rvh_list.Append(std::move(descriptor)); } data.Set(kPagesField, std::move(rvh_list)); @@ -295,7 +295,7 @@ void HandleAccessibilityRequestCallback( data.Set(kBrowsersField, std::move(window_list)); std::string json_string; - base::JSONWriter::Write(base::Value(std::move(data)), &json_string); + base::JSONWriter::Write(data, &json_string); std::move(callback).Run( base::MakeRefCounted<base::RefCountedString>(std::move(json_string))); diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc index 687d7610a8..fe63063c3b 100644 --- a/shell/common/gin_converters/net_converter.cc +++ b/shell/common/gin_converters/net_converter.cc @@ -166,7 +166,7 @@ v8::Local<v8::Value> Converter<net::HttpResponseHeaders*>::ToV8( values->Append(value); } } - return ConvertToV8(isolate, base::Value(std::move(response_headers))); + return ConvertToV8(isolate, response_headers); } bool Converter<net::HttpResponseHeaders*>::FromV8(
chore
ff60fe25c112f2cdfc0cc104656243b19df0ba88
John Kleinschmidt
2023-02-11 13:28:28
ci: update appveyor build agent (#37211) ci update appveyor image
diff --git a/appveyor-bake.yml b/appveyor-bake.yml index ad457feb7e..fbee3f1ad4 100644 --- a/appveyor-bake.yml +++ b/appveyor-bake.yml @@ -6,7 +6,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-110.0.5451.0 +image: e-111.0.5560.0-2 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default @@ -16,22 +16,58 @@ environment: GOMA_FALLBACK_ON_AUTH_FAILURE: true DEPOT_TOOLS_WIN_TOOLCHAIN: 0 PYTHONIOENCODING: UTF-8 -# Uncomment these lines and set APPVEYOR_RDP_PASSWORD in project settings to enable RDP before bake begins -# install: -# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) + +# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019) +# init: +# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) +# - appveyor version +# - ps: $ErrorActionPreference = 'Stop' +# - ps: 'Write-Host "OS Build: $((Get-CimInstance Win32_OperatingSystem).BuildNumber)"' + +# clone_folder: '%USERPROFILE%\image-bake-scripts' + +# clone_script: +# - ps: Invoke-WebRequest "https://github.com/appveyor/build-images/archive/1f90d94e74c8243c909a09b994e527584dfcb838.zip" -OutFile "$env:temp\scripts.zip" +# - ps: Expand-Archive -Path "$env:temp\scripts.zip" -DestinationPath "$env:temp\scripts" -Force +# - ps: Copy-Item -Path "$env:temp\scripts\build-images-1f90d94e74c8243c909a09b994e527584dfcb838\scripts\Windows\*" -Destination $env:APPVEYOR_BUILD_FOLDER -Recurse + build_script: - # Uncomment/change the following line if the hard drive/partition size needs to change - # - ps: Resize-Partition -DriveLetter C -Size (256GB) # ensure initial partition size +# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019) + # - ps: .\init_server.ps1 + # - ps: .\extend_system_volume.ps1 + + # # Restart VM + # - ps: Start-Sleep -s 5; Restart-Computer + # - ps: Start-Sleep -s 5 + + # - appveyor version + # - ps: .\install_path_utils.ps1 + # - ps: .\install_powershell_core.ps1 + # - ps: .\install_powershell_get.ps1 + # - ps: .\install_7zip.ps1 + # - ps: .\install_chocolatey.ps1 + # - ps: .\install_webpi.ps1 + # - ps: .\install_nuget.ps1 + # - ps: .\install_pstools.ps1 + + # - ps: .\install_git.ps1 + # - ps: .\install_git_lfs.ps1 + + # # Restart VM + # - ps: Start-Sleep -s 5; Restart-Computer + # - ps: Start-Sleep -s 5 +# END LINES FOR COMPLETELY NEW IMAGE + - git config --global core.longpaths true - - cd .. - ps: >- - if (-not (Test-Path -Path .\src)) { - New-Item -Path .\src -ItemType Directory + if (-not (Test-Path -Path C:\projects\src)) { + New-Item -Path C:\projects\src -ItemType Directory } - - ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - cd C:\projects\ + - git clone -q --branch=%APPVEYOR_REPO_BRANCH% https://github.com/electron/electron.git C:\projects\src\electron + - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git - ps: $env:PATH="$pwd\depot_tools;$env:PATH" - update_depot_tools.bat - - ps: Move-Item $env:APPVEYOR_BUILD_FOLDER -Destination src\electron # Uncomment the following line if windows deps change # - src\electron\script\setup-win-for-dev.bat - >- @@ -47,20 +83,25 @@ build_script: - ps: cd ..\.. - gclient sync --with_branch_heads --with_tags --nohooks - ps: regsvr32 /s "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\DIA SDK\bin\amd64\msdia140.dll" - - ps: | - $env:appveyor_user = "appveyor" - - $env:appveyor_password = [Guid]::NewGuid().ToString('B') - Set-LocalUser -Name $env:appveyor_user -Password (ConvertTo-SecureString -AsPlainText $env:appveyor_password -Force) -PasswordNeverExpires:$true +# The following lines are needed when baking from a completely new image (eg MicrosoftWindowsServer:WindowsServer:2019-Datacenter:latest via image: base-windows-server2019) + # # Restart VM + # - ps: Start-Sleep -s 5; Restart-Computer + # - ps: Start-Sleep -s 5 - iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/build-images/master/scripts/Windows/enable_autologon.ps1')) + # - cd %USERPROFILE%\image-bake-scripts + # - appveyor version + # - ps: .\optimize_dotnet_runtime.ps1 + # - ps: .\disable_windows_background_services.ps1 + # - ps: .\enforce_windows_firewall.ps1 + # - ps: .\cleanup_windows.ps1 +# END LINES FOR COMPLETELY NEW IMAGE on_image_bake: - ps: >- echo "Baking image: $env:APPVEYOR_BAKE_IMAGE at dir $PWD" - - ps: Remove-Item -Recurse -Force $pwd\depot_tools - - ps: Remove-Item -Recurse -Force $pwd\src\electron + - ps: Remove-Item -Recurse -Force C:\projects\depot_tools + - ps: Remove-Item -Recurse -Force C:\projects\src\electron # Uncomment these lines and set APPVEYOR_RDP_PASSWORD in project settings to enable RDP after bake is done -#on_finish: -# - ps: >- -# $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) \ No newline at end of file +# # on_finish: +# - ps: >- +# $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) \ No newline at end of file diff --git a/appveyor-woa.yml b/appveyor-woa.yml index ecbc60be69..7c72640d60 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-111.0.5518.0 +image: e-111.0.5560.0-2 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default @@ -82,7 +82,7 @@ for: if (Test-Path -Path "$pwd\build-tools") { Remove-Item -Recurse -Force $pwd\build-tools } - - ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git - ps: $env:PATH="$pwd\depot_tools;$env:PATH" - ps: >- if (Test-Path -Path "$pwd\src\electron") { diff --git a/appveyor.yml b/appveyor.yml index 4295d20641..0c382f344a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-111.0.5560.0 +image: e-111.0.5560.0-2 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default @@ -80,7 +80,7 @@ for: if (Test-Path -Path "$pwd\build-tools") { Remove-Item -Recurse -Force $pwd\build-tools } - - ps: git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git - ps: $env:PATH="$pwd\depot_tools;$env:PATH" - ps: >- if (Test-Path -Path "$pwd\src\electron") { diff --git a/script/prepare-appveyor.js b/script/prepare-appveyor.js index 36f35f3b96..210aec54c7 100644 --- a/script/prepare-appveyor.js +++ b/script/prepare-appveyor.js @@ -14,8 +14,8 @@ const ROLLER_BRANCH_PATTERN = /^roller\/chromium$/; const DEFAULT_BUILD_CLOUD_ID = '1598'; const DEFAULT_BUILD_CLOUD = 'electronhq-16-core'; -const DEFAULT_BAKE_BASE_IMAGE = 'e-110.0.5451.0'; -const DEFAULT_BUILD_IMAGE = 'e-110.0.5451.0'; +const DEFAULT_BAKE_BASE_IMAGE = 'e-111.0.5560.0-2'; +const DEFAULT_BUILD_IMAGE = 'e-111.0.5560.0-2'; const appveyorBakeJob = 'electron-bake-image'; const appVeyorJobs = {
ci
040e9a027a1448f8f7643a363bfd78ba803a40c3
John Kleinschmidt
2023-07-06 16:13:20
build: disable unneeded depot_tools update on Windows CI (#39011) build: disable unneeded depot_tools update
diff --git a/appveyor-woa.yml b/appveyor-woa.yml index b949b6fbe4..d1f0d3be19 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -85,6 +85,8 @@ for: Remove-Item -Recurse -Force $pwd\build-tools } - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - ps: New-Item -Name depot_tools\.disable_auto_update -ItemType File + - depot_tools\bootstrap\win_tools.bat - ps: $env:PATH="$pwd\depot_tools;$env:PATH" - ps: >- if (Test-Path -Path "$pwd\src\electron") { diff --git a/appveyor.yml b/appveyor.yml index 33e459ad06..98f10f5425 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -83,6 +83,8 @@ for: Remove-Item -Recurse -Force $pwd\build-tools } - git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git + - ps: New-Item -Name depot_tools\.disable_auto_update -ItemType File + - depot_tools\bootstrap\win_tools.bat - ps: $env:PATH="$pwd\depot_tools;$env:PATH" - ps: >- if (Test-Path -Path "$pwd\src\electron") {
build
9aa73abe781ae5da01ac50e9165330722806d1d9
Cheng Zhao
2023-12-06 11:22:41
feat: enable code cache for custom protocols (#40544)
diff --git a/docs/api/protocol.md b/docs/api/protocol.md index 9b093fc890..1a9b446a20 100644 --- a/docs/api/protocol.md +++ b/docs/api/protocol.md @@ -61,8 +61,9 @@ The `protocol` module has the following methods: module gets emitted and can be called only once. Registers the `scheme` as standard, secure, bypasses content security policy for -resources, allows registering ServiceWorker, supports fetch API, and streaming -video/audio. Specify a privilege with the value of `true` to enable the capability. +resources, allows registering ServiceWorker, supports fetch API, streaming +video/audio, and V8 code cache. Specify a privilege with the value of `true` to +enable the capability. An example of registering a privileged scheme, that bypasses Content Security Policy: diff --git a/docs/api/session.md b/docs/api/session.md index f8f4367d6e..1a48b44d5a 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -1356,6 +1356,10 @@ registered. Sets the directory to store the generated JS [code cache](https://v8.dev/blog/code-caching-for-devs) for this session. The directory is not required to be created by the user before this call, the runtime will create if it does not exist otherwise will use the existing directory. If directory cannot be created, then code cache will not be used and all operations related to code cache will fail silently inside the runtime. By default, the directory will be `Code Cache` under the respective user data folder. +Note that by default code cache is only enabled for http(s) URLs, to enable code +cache for custom protocols, `codeCache: true` and `standard: true` must be +specified when registering the protocol. + #### `ses.clearCodeCaches(options)` * `options` Object diff --git a/docs/api/structures/custom-scheme.md b/docs/api/structures/custom-scheme.md index 402a17506a..3476ede7a4 100644 --- a/docs/api/structures/custom-scheme.md +++ b/docs/api/structures/custom-scheme.md @@ -9,3 +9,5 @@ * `supportFetchAPI` boolean (optional) - Default false. * `corsEnabled` boolean (optional) - Default false. * `stream` boolean (optional) - Default false. + * `codeCache` boolean (optional) - Enable V8 code cache for the scheme, only + works when `standard` is also set to true. Default false. diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 9831b3005d..ac0e9c6e6c 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -128,3 +128,4 @@ feat_allow_passing_of_objecttemplate_to_objecttemplatebuilder.patch chore_remove_check_is_test_on_script_injection_tracker.patch fix_restore_original_resize_performance_on_macos.patch fix_font_flooding_in_dev_tools.patch +feat_allow_code_cache_in_custom_schemes.patch diff --git a/patches/chromium/feat_allow_code_cache_in_custom_schemes.patch b/patches/chromium/feat_allow_code_cache_in_custom_schemes.patch new file mode 100644 index 0000000000..182b5fbce3 --- /dev/null +++ b/patches/chromium/feat_allow_code_cache_in_custom_schemes.patch @@ -0,0 +1,395 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cheng Zhao <[email protected]> +Date: Thu, 26 Oct 2023 11:07:47 +0900 +Subject: Enable V8 code cache for custom schemes + +Add a new category in ContentClient::AddAdditionalSchemes which allows +embedders to make custom schemes allow V8 code cache. + +Chromium CL: https://chromium-review.googlesource.com/c/chromium/src/+/5019665 + +diff --git a/content/browser/code_cache/generated_code_cache.cc b/content/browser/code_cache/generated_code_cache.cc +index 65ac47b199b3f6d37fe78495eeb3d3598c4add8d..5230bf2cf1387ca73b34e0be2e0cffecd46a3653 100644 +--- a/content/browser/code_cache/generated_code_cache.cc ++++ b/content/browser/code_cache/generated_code_cache.cc +@@ -6,6 +6,7 @@ + + #include <iostream> + ++#include "base/containers/contains.h" + #include "base/feature_list.h" + #include "base/functional/bind.h" + #include "base/functional/callback_helpers.h" +@@ -24,6 +25,7 @@ + #include "net/base/url_util.h" + #include "net/http/http_cache.h" + #include "url/gurl.h" ++#include "url/url_util.h" + + using storage::BigIOBuffer; + +@@ -46,24 +48,37 @@ void CheckValidKeys(const GURL& resource_url, + GeneratedCodeCache::CodeCacheType cache_type) { + // If the resource url is invalid don't cache the code. + DCHECK(resource_url.is_valid()); ++ bool resource_url_allows_code_cache = ++ base::Contains(url::GetCodeCacheSchemes(), resource_url.scheme()); + bool resource_url_is_chrome_or_chrome_untrusted = + resource_url.SchemeIs(content::kChromeUIScheme) || + resource_url.SchemeIs(content::kChromeUIUntrustedScheme); + DCHECK(resource_url.SchemeIsHTTPOrHTTPS() || ++ resource_url_allows_code_cache || + resource_url_is_chrome_or_chrome_untrusted); + +- // |origin_lock| should be either empty or should have +- // Http/Https/chrome/chrome-untrusted schemes and it should not be a URL with +- // opaque origin. Empty origin_locks are allowed when the renderer is not +- // locked to an origin. ++ // |origin_lock| should be either empty or should have code cache allowed ++ // schemes (http/https/chrome/chrome-untrusted or other custom schemes added ++ // by url::AddCodeCacheScheme), and it should not be a URL with opaque ++ // origin. Empty origin_locks are allowed when the renderer is not locked to ++ // an origin. ++ bool origin_lock_allows_code_cache = ++ base::Contains(url::GetCodeCacheSchemes(), origin_lock.scheme()); + bool origin_lock_is_chrome_or_chrome_untrusted = + origin_lock.SchemeIs(content::kChromeUIScheme) || + origin_lock.SchemeIs(content::kChromeUIUntrustedScheme); + DCHECK(origin_lock.is_empty() || + ((origin_lock.SchemeIsHTTPOrHTTPS() || ++ origin_lock_allows_code_cache || + origin_lock_is_chrome_or_chrome_untrusted) && + !url::Origin::Create(origin_lock).opaque())); + ++ // The custom schemes share the cache type with http(s). ++ if (origin_lock_allows_code_cache || resource_url_allows_code_cache) { ++ DCHECK(cache_type == GeneratedCodeCache::kJavaScript || ++ cache_type == GeneratedCodeCache::kWebAssembly); ++ } ++ + // The chrome and chrome-untrusted schemes are only used with the WebUI + // code cache type. + DCHECK_EQ(origin_lock_is_chrome_or_chrome_untrusted, +diff --git a/content/browser/code_cache/generated_code_cache.h b/content/browser/code_cache/generated_code_cache.h +index f5c5ff2c89489257003dfe3284ee9de9f517c99b..fdd2e2483171c4d43963590200817dac27d22cf9 100644 +--- a/content/browser/code_cache/generated_code_cache.h ++++ b/content/browser/code_cache/generated_code_cache.h +@@ -52,12 +52,14 @@ class CONTENT_EXPORT GeneratedCodeCache { + // Cache type. Used for collecting statistics for JS and Wasm in separate + // buckets. + enum CodeCacheType { +- // JavaScript from http(s) pages. ++ // JavaScript from pages of http(s) schemes or custom schemes registered by ++ // url::AddCodeCacheScheme. + kJavaScript, + +- // WebAssembly from http(s) pages. This cache allows more total size and +- // more size per item than the JavaScript cache, since some +- // WebAssembly programs are very large. ++ // WebAssembly from pages of http(s) schemes or custom schemes registered by ++ // url::AddCodeCacheScheme. This cache allows more total size and more size ++ // per item than the JavaScript cache, since some WebAssembly programs are ++ // very large. + kWebAssembly, + + // JavaScript from chrome and chrome-untrusted pages. The resource URLs are +diff --git a/content/browser/code_cache/generated_code_cache_browsertest.cc b/content/browser/code_cache/generated_code_cache_browsertest.cc +index 672b9bb14cd493b05d1e27019cda30c5269bf46f..f4093315dea8feb4184adbfd4c398768a6fb197d 100644 +--- a/content/browser/code_cache/generated_code_cache_browsertest.cc ++++ b/content/browser/code_cache/generated_code_cache_browsertest.cc +@@ -2,21 +2,32 @@ + // Use of this source code is governed by a BSD-style license that can be + // found in the LICENSE file. + ++#include "base/test/test_future.h" + #include "base/test/metrics/histogram_tester.h" + #include "base/test/scoped_feature_list.h" + #include "base/test/test_future.h" ++#include "components/services/storage/storage_service_impl.h" + #include "content/browser/code_cache/generated_code_cache.h" ++#include "content/browser/code_cache/generated_code_cache_context.h" ++#include "content/browser/storage_partition_impl.h" ++#include "content/common/url_schemes.h" ++#include "content/public/browser/browser_thread.h" + #include "content/public/test/browser_test.h" + #include "content/public/test/content_browser_test.h" + #include "content/public/test/content_browser_test_utils.h" ++#include "content/public/test/test_browser_context.h" + #include "content/shell/browser/shell.h" ++#include "content/test/test_content_client.h" + #include "net/dns/mock_host_resolver.h" + #include "third_party/blink/public/common/features.h" ++#include "url/url_util.h" + + namespace content { + + namespace { + ++const std::string kCodeCacheScheme = "test-code-cache"; ++ + bool SupportsSharedWorker() { + #if BUILDFLAG(IS_ANDROID) + // SharedWorkers are not enabled on Android. https://crbug.com/154571 +@@ -427,4 +438,80 @@ IN_PROC_BROWSER_TEST_P(CodeCacheBrowserTest, + } + } + ++class CodeCacheInCustomSchemeBrowserTest : public ContentBrowserTest { ++ public: ++ CodeCacheInCustomSchemeBrowserTest() { ++ SetContentClient(&test_content_client_); ++ ReRegisterContentSchemesForTests(); ++ } ++ ++ private: ++ class CustomSchemeContentClient : public TestContentClient { ++ public: ++ void AddAdditionalSchemes(Schemes* schemes) override { ++ schemes->standard_schemes.push_back(kCodeCacheScheme); ++ schemes->code_cache_schemes.push_back(kCodeCacheScheme); ++ } ++ }; ++ ++ CustomSchemeContentClient test_content_client_; ++ url::ScopedSchemeRegistryForTests scheme_registry_; ++}; ++ ++IN_PROC_BROWSER_TEST_F(CodeCacheInCustomSchemeBrowserTest, ++ AllowedCustomSchemeCanGenerateCodeCache) { ++ // Create browser context and get code cache context. ++ base::ScopedAllowBlockingForTesting allow_blocking; ++ TestBrowserContext browser_context; ++ StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>( ++ browser_context.GetDefaultStoragePartition()); ++ scoped_refptr<GeneratedCodeCacheContext> context = ++ partition->GetGeneratedCodeCacheContext(); ++ EXPECT_NE(context, nullptr); ++ ++ GURL url(kCodeCacheScheme + "://host4/script.js"); ++ GURL origin(kCodeCacheScheme + "://host1:1/"); ++ ASSERT_TRUE(url.is_valid()); ++ ASSERT_TRUE(origin.is_valid()); ++ std::string data("SomeData"); ++ ++ // Add a code cache entry for the custom scheme. ++ base::test::TestFuture<void> add_entry_future; ++ GeneratedCodeCacheContext::RunOrPostTask( ++ context.get(), FROM_HERE, ++ base::BindOnce([](scoped_refptr<GeneratedCodeCacheContext> context, ++ const GURL& url, ++ const GURL& origin, ++ const std::string& data, ++ base::OnceClosure callback) { ++ context->generated_js_code_cache()->WriteEntry( ++ url, origin, net::NetworkIsolationKey(), ++ base::Time::Now(), std::vector<uint8_t>(data.begin(), data.end())); ++ content::GetUIThreadTaskRunner({})->PostTask( ++ FROM_HERE, std::move(callback)); ++ }, context, url, origin, data, add_entry_future.GetCallback())); ++ ASSERT_TRUE(add_entry_future.Wait()); ++ ++ // Get the code cache entry. ++ base::test::TestFuture<std::string> get_entry_future; ++ GeneratedCodeCacheContext::RunOrPostTask( ++ context.get(), FROM_HERE, ++ base::BindOnce([](scoped_refptr<GeneratedCodeCacheContext> context, ++ const GURL& url, ++ const GURL& origin, ++ base::OnceCallback<void(std::string)> callback) { ++ context->generated_js_code_cache()->FetchEntry( ++ url, origin, net::NetworkIsolationKey(), ++ base::BindOnce([](base::OnceCallback<void(std::string)> callback, ++ const base::Time& response_time, ++ mojo_base::BigBuffer buffer) { ++ std::string data(buffer.data(), buffer.data() + buffer.size()); ++ content::GetUIThreadTaskRunner({})->PostTask( ++ FROM_HERE, base::BindOnce(std::move(callback), data)); ++ }, std::move(callback))); ++ }, context, url, origin, get_entry_future.GetCallback())); ++ ASSERT_TRUE(get_entry_future.Wait()); ++ ASSERT_EQ(data, get_entry_future.Get<0>()); ++} ++ + } // namespace content +diff --git a/content/browser/renderer_host/code_cache_host_impl.cc b/content/browser/renderer_host/code_cache_host_impl.cc +index 6b9e5065dc570b506c4c2606d536319d98684e12..9d1f337b9c9890b6b7afda40bf2f829ff2a25bfd 100644 +--- a/content/browser/renderer_host/code_cache_host_impl.cc ++++ b/content/browser/renderer_host/code_cache_host_impl.cc +@@ -6,6 +6,7 @@ + + #include <utility> + ++#include "base/containers/contains.h" + #include "base/functional/bind.h" + #include "base/functional/callback_helpers.h" + #include "base/metrics/histogram_functions.h" +@@ -28,6 +29,7 @@ + #include "third_party/blink/public/common/cache_storage/cache_storage_utils.h" + #include "url/gurl.h" + #include "url/origin.h" ++#include "url/url_util.h" + + using blink::mojom::CacheStorageError; + +@@ -40,6 +42,11 @@ enum class Operation { + kWrite, + }; + ++bool ProcessLockURLIsCodeCacheScheme(const ProcessLock& process_lock) { ++ return base::Contains(url::GetCodeCacheSchemes(), ++ process_lock.lock_url().scheme()); ++} ++ + bool CheckSecurityForAccessingCodeCacheData(const GURL& resource_url, + int render_process_id, + Operation operation) { +@@ -47,11 +54,12 @@ bool CheckSecurityForAccessingCodeCacheData(const GURL& resource_url, + ChildProcessSecurityPolicyImpl::GetInstance()->GetProcessLock( + render_process_id); + +- // Code caching is only allowed for http(s) and chrome/chrome-untrusted +- // scripts. Furthermore, there is no way for http(s) pages to load chrome or +- // chrome-untrusted scripts, so any http(s) page attempting to store data +- // about a chrome or chrome-untrusted script would be an indication of +- // suspicious activity. ++ // Code caching is only allowed for scripts from open-web (http/https and ++ // custom schemes registered with url::AddCodeCacheScheme) and ++ // chrome/chrome-untrusted schemes. Furthermore, there is no way for ++ // open-web pages to load chrome or chrome-untrusted scripts, so any ++ // open-web page attempting to store data about a chrome or ++ // chrome-untrusted script would be an indication of suspicious activity. + if (resource_url.SchemeIs(content::kChromeUIScheme) || + resource_url.SchemeIs(content::kChromeUIUntrustedScheme)) { + if (!process_lock.is_locked_to_site()) { +@@ -60,9 +68,10 @@ bool CheckSecurityForAccessingCodeCacheData(const GURL& resource_url, + return false; + } + if (process_lock.matches_scheme(url::kHttpScheme) || +- process_lock.matches_scheme(url::kHttpsScheme)) { ++ process_lock.matches_scheme(url::kHttpsScheme) || ++ ProcessLockURLIsCodeCacheScheme(process_lock)) { + if (operation == Operation::kWrite) { +- mojo::ReportBadMessage("HTTP(S) pages cannot cache WebUI code"); ++ mojo::ReportBadMessage("Open-web pages cannot cache WebUI code"); + } + return false; + } +@@ -72,7 +81,16 @@ bool CheckSecurityForAccessingCodeCacheData(const GURL& resource_url, + return process_lock.matches_scheme(content::kChromeUIScheme) || + process_lock.matches_scheme(content::kChromeUIUntrustedScheme); + } +- if (resource_url.SchemeIsHTTPOrHTTPS()) { ++ if (base::Contains(url::GetCodeCacheSchemes(), resource_url.scheme()) && ++ (process_lock.matches_scheme(url::kHttpScheme) || ++ process_lock.matches_scheme(url::kHttpsScheme))) { ++ // While custom schemes registered with url::AddCodeCacheScheme are ++ // considered as open-web pages, we still do not trust http(s) pages ++ // loading resources from custom schemes. ++ return false; ++ } ++ if (resource_url.SchemeIsHTTPOrHTTPS() || ++ base::Contains(url::GetCodeCacheSchemes(), resource_url.scheme())) { + if (process_lock.matches_scheme(content::kChromeUIScheme) || + process_lock.matches_scheme(content::kChromeUIUntrustedScheme)) { + // It is possible for WebUI pages to include open-web content, but such +@@ -136,15 +154,17 @@ absl::optional<GURL> GetSecondaryKeyForCodeCache(const GURL& resource_url, + return absl::nullopt; + + // Case 3: process_lock_url is used to enfore site-isolation in code caches. +- // Http/https/chrome schemes are safe to be used as a secondary key. Other +- // schemes could be enabled if they are known to be safe and if it is +- // required to cache code from those origins. ++ // Code cache enabled schemes (http/https/chrome/chrome-untrusted and custom ++ // schemes registered with url::AddCodeCacheScheme) are safe to be used as a ++ // secondary key. Other schemes could be enabled if they are known to be safe ++ // and if it is required to cache code from those origins. + // + // file:// URLs will have a "file:" process lock and would thus share a + // cache across all file:// URLs. That would likely be ok for security, but + // since this case is not performance sensitive we will keep things simple and +- // limit the cache to http/https/chrome/chrome-untrusted processes. +- if (process_lock.matches_scheme(url::kHttpScheme) || ++ // limit the cache to processes of code cache enabled schemes. ++ if (ProcessLockURLIsCodeCacheScheme(process_lock) || ++ process_lock.matches_scheme(url::kHttpScheme) || + process_lock.matches_scheme(url::kHttpsScheme) || + process_lock.matches_scheme(content::kChromeUIScheme) || + process_lock.matches_scheme(content::kChromeUIUntrustedScheme)) { +diff --git a/content/common/url_schemes.cc b/content/common/url_schemes.cc +index ce9644d33fe83379127b01bf9a2b1c4badc3bc7c..532b14e013b9b65ba390f09e8bb8934bb278a0d8 100644 +--- a/content/common/url_schemes.cc ++++ b/content/common/url_schemes.cc +@@ -98,6 +98,9 @@ void RegisterContentSchemes(bool should_lock_registry) { + for (auto& scheme : schemes.empty_document_schemes) + url::AddEmptyDocumentScheme(scheme.c_str()); + ++ for (auto& scheme : schemes.code_cache_schemes) ++ url::AddCodeCacheScheme(scheme.c_str()); ++ + #if BUILDFLAG(IS_ANDROID) + if (schemes.allow_non_standard_schemes_in_origins) + url::EnableNonStandardSchemesForAndroidWebView(); +diff --git a/content/public/common/content_client.h b/content/public/common/content_client.h +index 5d1484651fb8c3e03337665d3d5342ba51df3154..d4432a660d6c5a5e937dedabb7e4b71b87c9504b 100644 +--- a/content/public/common/content_client.h ++++ b/content/public/common/content_client.h +@@ -139,6 +139,9 @@ class CONTENT_EXPORT ContentClient { + // Registers a URL scheme as strictly empty documents, allowing them to + // commit synchronously. + std::vector<std::string> empty_document_schemes; ++ // Registers a URL scheme whose js and wasm scripts have V8 code cache ++ // enabled. ++ std::vector<std::string> code_cache_schemes; + // Registers a URL scheme as extension scheme. + std::vector<std::string> extension_schemes; + // Registers a URL scheme with a predefined default custom handler. +diff --git a/url/url_util.cc b/url/url_util.cc +index 9258cfcfada47aafe6ba20c648187947fec72372..a1834e543d27d46265af0c2133acac79b6c840e2 100644 +--- a/url/url_util.cc ++++ b/url/url_util.cc +@@ -114,6 +114,9 @@ struct SchemeRegistry { + kAboutScheme, + }; + ++ // Embedder schemes that have V8 code cache enabled in js and wasm scripts. ++ std::vector<std::string> code_cache_schemes = {}; ++ + // Schemes with a predefined default custom handler. + std::vector<SchemeWithHandler> predefined_handler_schemes; + +@@ -659,6 +662,15 @@ const std::vector<std::string>& GetEmptyDocumentSchemes() { + return GetSchemeRegistry().empty_document_schemes; + } + ++void AddCodeCacheScheme(const char* new_scheme) { ++ DoAddScheme(new_scheme, ++ &GetSchemeRegistryWithoutLocking()->code_cache_schemes); ++} ++ ++const std::vector<std::string>& GetCodeCacheSchemes() { ++ return GetSchemeRegistry().code_cache_schemes; ++} ++ + void AddPredefinedHandlerScheme(const char* new_scheme, const char* handler) { + DoAddSchemeWithHandler( + new_scheme, handler, +diff --git a/url/url_util.h b/url/url_util.h +index 8c94c7a4f6d5f653d326199e5b43452f969911d4..40dcdf9d680f9d345c09426da48b37f288234244 100644 +--- a/url/url_util.h ++++ b/url/url_util.h +@@ -115,6 +115,15 @@ COMPONENT_EXPORT(URL) const std::vector<std::string>& GetCSPBypassingSchemes(); + COMPONENT_EXPORT(URL) void AddEmptyDocumentScheme(const char* new_scheme); + COMPONENT_EXPORT(URL) const std::vector<std::string>& GetEmptyDocumentSchemes(); + ++// Adds an application-defined scheme to the list of schemes that have V8 code ++// cache enabled for the js and wasm scripts. ++// The WebUI schemes (chrome/chrome-untrusted) do not belong to this list, as ++// they are treated as a separate cache type for security purpose. ++// The http(s) schemes do not belong to this list neither, they always have V8 ++// code cache enabled and can not load scripts from schemes in this list. ++COMPONENT_EXPORT(URL) void AddCodeCacheScheme(const char* new_scheme); ++COMPONENT_EXPORT(URL) const std::vector<std::string>& GetCodeCacheSchemes(); ++ + // Adds a scheme with a predefined default handler. + // + // This pair of strings must be normalized protocol handler parameters as diff --git a/shell/browser/api/electron_api_protocol.cc b/shell/browser/api/electron_api_protocol.cc index 444964e79a..24f2cf1e17 100644 --- a/shell/browser/api/electron_api_protocol.cc +++ b/shell/browser/api/electron_api_protocol.cc @@ -32,6 +32,9 @@ std::vector<std::string> g_standard_schemes; // List of registered custom streaming schemes. std::vector<std::string> g_streaming_schemes; +// Schemes that support V8 code cache. +std::vector<std::string> g_code_cache_schemes; + struct SchemeOptions { bool standard = false; bool secure = false; @@ -40,6 +43,7 @@ struct SchemeOptions { bool supportFetchAPI = false; bool corsEnabled = false; bool stream = false; + bool codeCache = false; }; struct CustomScheme { @@ -71,6 +75,7 @@ struct Converter<CustomScheme> { opt.Get("supportFetchAPI", &(out->options.supportFetchAPI)); opt.Get("corsEnabled", &(out->options.corsEnabled)); opt.Get("stream", &(out->options.stream)); + opt.Get("codeCache", &(out->options.codeCache)); } return true; } @@ -82,10 +87,14 @@ namespace electron::api { gin::WrapperInfo Protocol::kWrapperInfo = {gin::kEmbedderNativeGin}; -std::vector<std::string> GetStandardSchemes() { +const std::vector<std::string>& GetStandardSchemes() { return g_standard_schemes; } +const std::vector<std::string>& GetCodeCacheSchemes() { + return g_code_cache_schemes; +} + void AddServiceWorkerScheme(const std::string& scheme) { // There is no API to add service worker scheme, but there is an API to // return const reference to the schemes vector. @@ -104,6 +113,15 @@ void RegisterSchemesAsPrivileged(gin_helper::ErrorThrower thrower, return; } + for (const auto& custom_scheme : custom_schemes) { + if (custom_scheme.options.codeCache && !custom_scheme.options.standard) { + thrower.ThrowError( + "Code cache can only be enabled when the custom scheme is registered " + "as standard scheme."); + return; + } + } + std::vector<std::string> secure_schemes, cspbypassing_schemes, fetch_schemes, service_worker_schemes, cors_schemes; for (const auto& custom_scheme : custom_schemes) { @@ -137,10 +155,16 @@ void RegisterSchemesAsPrivileged(gin_helper::ErrorThrower thrower, if (custom_scheme.options.stream) { g_streaming_schemes.push_back(custom_scheme.scheme); } + if (custom_scheme.options.codeCache) { + g_code_cache_schemes.push_back(custom_scheme.scheme); + url::AddCodeCacheScheme(custom_scheme.scheme.c_str()); + } } const auto AppendSchemesToCmdLine = [](const char* switch_name, std::vector<std::string> schemes) { + if (schemes.empty()) + return; // Add the schemes to command line switches, so child processes can also // register them. base::CommandLine::ForCurrentProcess()->AppendSwitchASCII( @@ -158,6 +182,8 @@ void RegisterSchemesAsPrivileged(gin_helper::ErrorThrower thrower, g_standard_schemes); AppendSchemesToCmdLine(electron::switches::kStreamingSchemes, g_streaming_schemes); + AppendSchemesToCmdLine(electron::switches::kCodeCacheSchemes, + g_code_cache_schemes); } namespace { diff --git a/shell/browser/api/electron_api_protocol.h b/shell/browser/api/electron_api_protocol.h index 8fc493473b..7db7b66c3c 100644 --- a/shell/browser/api/electron_api_protocol.h +++ b/shell/browser/api/electron_api_protocol.h @@ -22,7 +22,8 @@ class ProtocolRegistry; namespace api { -std::vector<std::string> GetStandardSchemes(); +const std::vector<std::string>& GetStandardSchemes(); +const std::vector<std::string>& GetCodeCacheSchemes(); void AddServiceWorkerScheme(const std::string& scheme); diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index 93d227241e..c4d514fe0d 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -526,7 +526,8 @@ void ElectronBrowserClient::AppendExtraCommandLineSwitches( switches::kStandardSchemes, switches::kEnableSandbox, switches::kSecureSchemes, switches::kBypassCSPSchemes, switches::kCORSSchemes, switches::kFetchSchemes, - switches::kServiceWorkerSchemes, switches::kStreamingSchemes}; + switches::kServiceWorkerSchemes, switches::kStreamingSchemes, + switches::kCodeCacheSchemes}; command_line->CopySwitchesFrom(*base::CommandLine::ForCurrentProcess(), kCommonSwitchNames); if (process_type == ::switches::kUtilityProcess || @@ -694,7 +695,7 @@ ElectronBrowserClient::CreateWindowForVideoPictureInPicture( void ElectronBrowserClient::GetAdditionalAllowedSchemesForFileSystem( std::vector<std::string>* additional_schemes) { - auto schemes_list = api::GetStandardSchemes(); + const auto& schemes_list = api::GetStandardSchemes(); if (!schemes_list.empty()) additional_schemes->insert(additional_schemes->end(), schemes_list.begin(), schemes_list.end()); diff --git a/shell/common/options_switches.cc b/shell/common/options_switches.cc index 4f1ec42cad..f353e23b25 100644 --- a/shell/common/options_switches.cc +++ b/shell/common/options_switches.cc @@ -227,6 +227,9 @@ const char kCORSSchemes[] = "cors-schemes"; // Register schemes as streaming responses. const char kStreamingSchemes[] = "streaming-schemes"; +// Register schemes as supporting V8 code cache. +const char kCodeCacheSchemes[] = "code-cache-schemes"; + // The browser process app model ID const char kAppUserModelId[] = "app-user-model-id"; diff --git a/shell/common/options_switches.h b/shell/common/options_switches.h index c529b7d02d..bb7936a3b1 100644 --- a/shell/common/options_switches.h +++ b/shell/common/options_switches.h @@ -113,6 +113,7 @@ extern const char kBypassCSPSchemes[]; extern const char kFetchSchemes[]; extern const char kCORSSchemes[]; extern const char kStreamingSchemes[]; +extern const char kCodeCacheSchemes[]; extern const char kAppUserModelId[]; extern const char kAppPath[]; diff --git a/shell/renderer/renderer_client_base.cc b/shell/renderer/renderer_client_base.cc index e811b66805..81e25bf3b9 100644 --- a/shell/renderer/renderer_client_base.cc +++ b/shell/renderer/renderer_client_base.cc @@ -276,6 +276,13 @@ void RendererClientBase::RenderThreadStarted() { blink::SchemeRegistry::RegisterURLSchemeAsBypassingContentSecurityPolicy( WTF::String::FromUTF8(scheme.data(), scheme.length())); + std::vector<std::string> code_cache_schemes_list = + ParseSchemesCLISwitch(command_line, switches::kCodeCacheSchemes); + for (const auto& scheme : code_cache_schemes_list) { + blink::WebSecurityPolicy::RegisterURLSchemeAsCodeCacheWithHashing( + blink::WebString::FromASCII(scheme)); + } + // Allow file scheme to handle service worker by default. // FIXME(zcbenz): Can this be moved elsewhere? if (electron::fuses::IsGrantFileProtocolExtraPrivilegesEnabled()) { diff --git a/spec/api-protocol-spec.ts b/spec/api-protocol-spec.ts index 6e3659034a..19ba61de12 100644 --- a/spec/api-protocol-spec.ts +++ b/spec/api-protocol-spec.ts @@ -1090,6 +1090,33 @@ describe('protocol module', () => { } }); + describe('protocol.registerSchemesAsPrivileged codeCache', function () { + const temp = require('temp').track(); + const appPath = path.join(fixturesPath, 'apps', 'refresh-page'); + + let w: BrowserWindow; + let codeCachePath: string; + beforeEach(async () => { + w = new BrowserWindow({ show: false }); + codeCachePath = temp.path(); + }); + + afterEach(async () => { + await closeWindow(w); + w = null as unknown as BrowserWindow; + }); + + it('code cache in custom protocol is disabled by default', async () => { + ChildProcess.spawnSync(process.execPath, [appPath, 'false', codeCachePath]); + expect(fs.readdirSync(path.join(codeCachePath, 'js')).length).to.equal(2); + }); + + it('codeCache:true enables codeCache in custom protocol', async () => { + ChildProcess.spawnSync(process.execPath, [appPath, 'true', codeCachePath]); + expect(fs.readdirSync(path.join(codeCachePath, 'js')).length).to.above(2); + }); + }); + describe('handle', () => { afterEach(closeAllWindows); diff --git a/spec/fixtures/apps/refresh-page/main.html b/spec/fixtures/apps/refresh-page/main.html new file mode 100644 index 0000000000..5aceb68b7b --- /dev/null +++ b/spec/fixtures/apps/refresh-page/main.html @@ -0,0 +1,9 @@ +<html> +<body> + <!-- Use mocha which has a large enough js file --> + <script src="mocha.js"></script> + <script> + mocha.setup('bdd'); + </script> +</body> +</html> diff --git a/spec/fixtures/apps/refresh-page/main.js b/spec/fixtures/apps/refresh-page/main.js new file mode 100644 index 0000000000..f4ada26db3 --- /dev/null +++ b/spec/fixtures/apps/refresh-page/main.js @@ -0,0 +1,38 @@ +const path = require('node:path'); +const { once } = require('node:events'); +const { pathToFileURL } = require('node:url'); +const { BrowserWindow, app, protocol, net, session } = require('electron'); + +if (process.argv.length < 4) { + console.error('Must pass allow_code_cache code_cache_dir'); + process.exit(1); +} + +protocol.registerSchemesAsPrivileged([ + { + scheme: 'atom', + privileges: { + standard: true, + codeCache: process.argv[2] === 'true' + } + } +]); + +app.once('ready', async () => { + const codeCachePath = process.argv[3]; + session.defaultSession.setCodeCachePath(codeCachePath); + + protocol.handle('atom', (request) => { + let { pathname } = new URL(request.url); + if (pathname === '/mocha.js') { pathname = path.resolve(__dirname, '../../../node_modules/mocha/mocha.js'); } else { pathname = path.join(__dirname, pathname); } + return net.fetch(pathToFileURL(pathname).toString()); + }); + + const win = new BrowserWindow({ show: false }); + win.loadURL('atom://host/main.html'); + await once(win.webContents, 'did-finish-load'); + // Reload to generate code cache. + win.reload(); + await once(win.webContents, 'did-finish-load'); + app.exit(); +}); diff --git a/spec/fixtures/apps/refresh-page/package.json b/spec/fixtures/apps/refresh-page/package.json new file mode 100644 index 0000000000..0d7231e0ec --- /dev/null +++ b/spec/fixtures/apps/refresh-page/package.json @@ -0,0 +1,4 @@ +{ + "name": "electron-test-refresh-page", + "main": "main.js" +}
feat
9ac4787325052393fee96e4be787936dfd4bc000
github-actions[bot]
2023-05-15 10:53:38
build: update appveyor image to latest version (#38257) Co-authored-by: jkleinsc <[email protected]>
diff --git a/appveyor-woa.yml b/appveyor-woa.yml index 09e96d5776..31b18560c2 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-114.0.5719.0 +image: e-115.0.5760.0 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default diff --git a/appveyor.yml b/appveyor.yml index 24d13665d2..b0642ddc7f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-114.0.5719.0 +image: e-115.0.5760.0 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default
build
57920e7747f09627f99ed5c27457339aa7c3fe57
John Kleinschmidt
2024-10-24 20:47:17
test: deflake flaky tests on linux (#44383)
diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index 15c36e707a..74affcf5bd 100755 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -942,12 +942,11 @@ describe('BrowserWindow module', () => { 'did-frame-navigate', 'did-navigate' ]; - const allEvents = Promise.all(navigationEvents.map(event => + const allEvents = Promise.all(expectedEventOrder.map(event => once(w.webContents, event).then(() => firedEvents.push(event)) )); - const timeout = setTimeout(1000); w.loadURL(url); - await Promise.race([allEvents, timeout]); + await allEvents; expect(firedEvents).to.deep.equal(expectedEventOrder); }); diff --git a/spec/crash-spec.ts b/spec/crash-spec.ts index ff8489b050..253537b43b 100644 --- a/spec/crash-spec.ts +++ b/spec/crash-spec.ts @@ -4,7 +4,7 @@ import * as cp from 'node:child_process'; import * as fs from 'node:fs'; import * as path from 'node:path'; -import { ifit } from './lib/spec-helpers'; +import { ifit, waitUntil } from './lib/spec-helpers'; const fixturePath = path.resolve(__dirname, 'fixtures', 'crash-cases'); @@ -57,11 +57,11 @@ const shouldRunCase = (crashCase: string) => { }; describe('crash cases', () => { - afterEach(() => { + afterEach(async () => { for (const child of children) { child.kill(); } - expect(children).to.have.lengthOf(0, 'all child processes should have exited cleanly'); + await waitUntil(() => (children.length === 0)); children.length = 0; }); const cases = fs.readdirSync(fixturePath);
test
2a81b2aea32f29a31a5fffb88e3800cd5246752c
David Sanders
2023-06-09 04:41:23
build: move uploadIndexJson to just before publishRelease (#38659) * build: move uploadIndexJson to just before publishRelease * chore: move uploadNodeShasums as well
diff --git a/script/release/release.js b/script/release/release.js index 63f22dd8dd..efa9b0a073 100755 --- a/script/release/release.js +++ b/script/release/release.js @@ -354,14 +354,18 @@ async function makeRelease (releaseToValidate) { await validateReleaseAssets(release, true); } else { let draftRelease = await getDraftRelease(); - uploadNodeShasums(); - uploadIndexJson(); - await createReleaseShasums(draftRelease); // Fetch latest version of release before verifying draftRelease = await getDraftRelease(pkgVersion, true); await validateReleaseAssets(draftRelease); + // index.json goes live once uploaded so do these uploads as + // late as possible to reduce the chances it contains a release + // which fails to publish. It has to be done before the final + // publish to ensure there aren't published releases not contained + // in index.json, which causes other problems in downstream projects + uploadNodeShasums(); + uploadIndexJson(); await publishRelease(draftRelease); console.log(`${pass} SUCCESS!!! Release has been published. Please run ` + '"npm run publish-to-npm" to publish release to npm.');
build
2390706030be57a45932fae803717cd0633401c8
Charles Kerr
2024-08-26 09:58:32
refactor: prefer std::ranges over begin() and end() (#43464)
diff --git a/shell/app/electron_main_win.cc b/shell/app/electron_main_win.cc index 75eee069a7..d6e035775d 100644 --- a/shell/app/electron_main_win.cc +++ b/shell/app/electron_main_win.cc @@ -165,7 +165,7 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t* cmd, int) { base::AtExitManager atexit_manager; base::i18n::InitializeICU(); auto ret = electron::NodeMain(argv.size(), argv.data()); - std::for_each(argv.begin(), argv.end(), free); + std::ranges::for_each(argv, free); return ret; } diff --git a/shell/browser/api/electron_api_global_shortcut.cc b/shell/browser/api/electron_api_global_shortcut.cc index ebd59b2716..f4e0079322 100644 --- a/shell/browser/api/electron_api_global_shortcut.cc +++ b/shell/browser/api/electron_api_global_shortcut.cc @@ -34,11 +34,9 @@ bool RegisteringMediaKeyForUntrustedClient(const ui::Accelerator& accelerator) { bool MapHasMediaKeys( const std::map<ui::Accelerator, base::RepeatingClosure>& accelerator_map) { - auto media_key = std::find_if( - accelerator_map.begin(), accelerator_map.end(), - [](const auto& ac) { return Command::IsMediaKey(ac.first); }); - - return media_key != accelerator_map.end(); + return std::ranges::any_of(accelerator_map, [](const auto& ac) { + return Command::IsMediaKey(ac.first); + }); } #endif diff --git a/shell/browser/api/electron_api_session.cc b/shell/browser/api/electron_api_session.cc index 4cd44224fe..1791955b07 100644 --- a/shell/browser/api/electron_api_session.cc +++ b/shell/browser/api/electron_api_session.cc @@ -455,8 +455,7 @@ struct Converter<network::mojom::SSLConfigPtr> { !options.Get("disabledCipherSuites", &(*out)->disabled_cipher_suites)) { return false; } - std::sort((*out)->disabled_cipher_suites.begin(), - (*out)->disabled_cipher_suites.end()); + std::ranges::sort((*out)->disabled_cipher_suites); // TODO(nornagon): also support other SSLConfig properties? return true; diff --git a/shell/browser/hid/hid_chooser_controller.cc b/shell/browser/hid/hid_chooser_controller.cc index 1904b5a2f4..8b7c2f31fd 100644 --- a/shell/browser/hid/hid_chooser_controller.cc +++ b/shell/browser/hid/hid_chooser_controller.cc @@ -49,11 +49,11 @@ bool FilterMatch(const blink::mojom::HidDeviceFilterPtr& filter, if (filter->usage) { if (filter->usage->is_page()) { const uint16_t usage_page = filter->usage->get_page(); - auto find_it = - std::find_if(device.collections.begin(), device.collections.end(), - [=](const device::mojom::HidCollectionInfoPtr& c) { - return usage_page == c->usage->usage_page; - }); + auto find_it = std::ranges::find_if( + device.collections, + [=](const device::mojom::HidCollectionInfoPtr& c) { + return usage_page == c->usage->usage_page; + }); if (find_it == device.collections.end()) return false; } else if (filter->usage->is_usage_and_page()) { diff --git a/shell/browser/notifications/notification_presenter.cc b/shell/browser/notifications/notification_presenter.cc index 0bfb5c049c..16ac82a368 100644 --- a/shell/browser/notifications/notification_presenter.cc +++ b/shell/browser/notifications/notification_presenter.cc @@ -38,10 +38,10 @@ void NotificationPresenter::RemoveNotification(Notification* notification) { void NotificationPresenter::CloseNotificationWithId( const std::string& notification_id) { - auto it = std::find_if(notifications_.begin(), notifications_.end(), - [&notification_id](const Notification* n) { - return n->notification_id() == notification_id; - }); + auto it = std::ranges::find_if( + notifications_, [&notification_id](const Notification* n) { + return n->notification_id() == notification_id; + }); if (it != notifications_.end()) { Notification* notification = (*it); notification->Dismiss(); diff --git a/shell/browser/serial/serial_chooser_controller.cc b/shell/browser/serial/serial_chooser_controller.cc index 01ae104044..99c7ae1681 100644 --- a/shell/browser/serial/serial_chooser_controller.cc +++ b/shell/browser/serial/serial_chooser_controller.cc @@ -177,10 +177,9 @@ void SerialChooserController::OnDeviceChosen(const std::string& port_id) { if (port_id.empty()) { RunCallback(/*port=*/nullptr); } else { - const auto it = - std::find_if(ports_.begin(), ports_.end(), [&port_id](const auto& ptr) { - return ptr->token.ToString() == port_id; - }); + const auto it = std::ranges::find_if(ports_, [&port_id](const auto& ptr) { + return ptr->token.ToString() == port_id; + }); if (it != ports_.end()) { auto* rfh = content::RenderFrameHost::FromID(render_frame_host_id_); chooser_context_->GrantPortPermission(origin_, *it->get(), rfh); @@ -194,10 +193,9 @@ void SerialChooserController::OnDeviceChosen(const std::string& port_id) { void SerialChooserController::OnGetDevices( std::vector<device::mojom::SerialPortInfoPtr> ports) { // Sort ports by file paths. - std::sort(ports.begin(), ports.end(), - [](const auto& port1, const auto& port2) { - return port1->path.BaseName() < port2->path.BaseName(); - }); + std::ranges::sort(ports, [](const auto& port1, const auto& port2) { + return port1->path.BaseName() < port2->path.BaseName(); + }); for (auto& port : ports) { if (DisplayDevice(*port)) diff --git a/shell/browser/ui/views/client_frame_view_linux.cc b/shell/browser/ui/views/client_frame_view_linux.cc index 4a7b4c0c0d..8ade35e425 100644 --- a/shell/browser/ui/views/client_frame_view_linux.cc +++ b/shell/browser/ui/views/client_frame_view_linux.cc @@ -409,15 +409,15 @@ void ClientFrameViewLinux::LayoutButtonsOnSide( frame_buttons = trailing_frame_buttons_; // We always lay buttons out going from the edge towards the center, but // they are given to us as left-to-right, so reverse them. - std::reverse(frame_buttons.begin(), frame_buttons.end()); + std::ranges::reverse(frame_buttons); break; default: NOTREACHED(); } for (views::FrameButton frame_button : frame_buttons) { - auto* button = std::find_if( - nav_buttons_.begin(), nav_buttons_.end(), [&](const NavButton& test) { + auto* button = + std::ranges::find_if(nav_buttons_, [&](const NavButton& test) { return test.type != skip_type && test.frame_button == frame_button; }); CHECK(button != nav_buttons_.end()) diff --git a/shell/browser/ui/win/notify_icon_host.cc b/shell/browser/ui/win/notify_icon_host.cc index dd46755ba2..2d0263472a 100644 --- a/shell/browser/ui/win/notify_icon_host.cc +++ b/shell/browser/ui/win/notify_icon_host.cc @@ -211,8 +211,7 @@ NotifyIcon* NotifyIconHost::CreateNotifyIcon(std::optional<UUID> guid) { } void NotifyIconHost::Remove(NotifyIcon* icon) { - NotifyIcons::iterator i( - std::find(notify_icons_.begin(), notify_icons_.end(), icon)); + const auto i = std::ranges::find(notify_icons_, icon); if (i == notify_icons_.end()) { NOTREACHED(); @@ -241,11 +240,7 @@ LRESULT CALLBACK NotifyIconHost::WndProc(HWND hwnd, LPARAM lparam) { if (message == taskbar_created_message_) { // We need to reset all of our icons because the taskbar went away. - for (NotifyIcons::const_iterator i(notify_icons_.begin()); - i != notify_icons_.end(); ++i) { - auto* win_icon = static_cast<NotifyIcon*>(*i); - win_icon->ResetIcon(); - } + std::ranges::for_each(notify_icons_, [](auto* icon) { icon->ResetIcon(); }); return TRUE; } else if (message == kNotifyIconMessage) { NotifyIcon* win_icon = nullptr; diff --git a/shell/browser/window_list.cc b/shell/browser/window_list.cc index 226ce76e3c..9768b7e70e 100644 --- a/shell/browser/window_list.cc +++ b/shell/browser/window_list.cc @@ -85,7 +85,7 @@ void WindowList::CloseAllWindows() { std::vector<base::WeakPtr<NativeWindow>> weak_windows = ConvertToWeakPtrVector(GetInstance()->windows_); #if BUILDFLAG(IS_MAC) - std::reverse(weak_windows.begin(), weak_windows.end()); + std::ranges::reverse(weak_windows); #endif for (const auto& window : weak_windows) { if (window && !window->IsClosed()) diff --git a/shell/common/crash_keys.cc b/shell/common/crash_keys.cc index dff146194e..ccd8ff5cfb 100644 --- a/shell/common/crash_keys.cc +++ b/shell/common/crash_keys.cc @@ -67,7 +67,7 @@ void SetCrashKey(const std::string& key, const std::string& value) { auto& crash_key_names = GetExtraCrashKeyNames(); - auto iter = std::find(crash_key_names.begin(), crash_key_names.end(), key); + auto iter = std::ranges::find(crash_key_names, key); if (iter == crash_key_names.end()) { crash_key_names.emplace_back(key); GetExtraCrashKeys().emplace_back(crash_key_names.back().c_str()); @@ -79,7 +79,7 @@ void SetCrashKey(const std::string& key, const std::string& value) { void ClearCrashKey(const std::string& key) { const auto& crash_key_names = GetExtraCrashKeyNames(); - auto iter = std::find(crash_key_names.begin(), crash_key_names.end(), key); + auto iter = std::ranges::find(crash_key_names, key); if (iter != crash_key_names.end()) { GetExtraCrashKeys()[iter - crash_key_names.begin()].Clear(); } diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index fb1326d95d..fd77be2990 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -800,8 +800,8 @@ std::shared_ptr<node::Environment> NodeBindings::CreateEnvironment( #if BUILDFLAG(IS_WIN) auto& electron_args = ElectronCommandLine::argv(); std::vector<std::string> args(electron_args.size()); - std::transform(electron_args.cbegin(), electron_args.cend(), args.begin(), - [](auto& a) { return base::WideToUTF8(a); }); + std::ranges::transform(electron_args, args.begin(), + [](auto& a) { return base::WideToUTF8(a); }); #else auto args = ElectronCommandLine::argv(); #endif
refactor
8be4ae4babc88f94577463ba89902f3f680882ad
John Kleinschmidt
2024-10-31 15:03:28
build: handle out of disk space on source cache (#44490) * build: handle out of disk space on source cache * build: add cron job to free up source cache disk space
diff --git a/.github/actions/checkout/action.yml b/.github/actions/checkout/action.yml index 869c6b32c5..d205787128 100644 --- a/.github/actions/checkout/action.yml +++ b/.github/actions/checkout/action.yml @@ -57,13 +57,26 @@ runs: cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar echo "Using cache key: $DEPSHASH" echo "Checking for cache in: $cache_path" - if [ ! -f "$cache_path" ]; then + if [ ! -f "$cache_path" ] || [ `du $cache_path | cut -f1` = "0" ]; then echo "cache_exists=false" >> $GITHUB_OUTPUT echo "Cache Does Not Exist for $DEPSHASH" else echo "cache_exists=true" >> $GITHUB_OUTPUT echo "Cache Already Exists for $DEPSHASH, Skipping.." fi + - name: Check cross instance cache disk space + if: steps.check-cache.outputs.cache_exists == 'false' + shell: bash + run: | + # if there is less than 20 GB free space then creating the cache might fail so exit early + freespace=`df -m /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'` + freespace_human=`df -h /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'` + if [ $freespace -le 20000 ]; then + echo "The cross mount cache has $freespace_human free space which is not enough - exiting" + exit 1 + else + echo "The cross mount cache has $freespace_human free space - continuing" + fi - name: Gclient Sync if: steps.check-cache.outputs.cache_exists == 'false' shell: bash diff --git a/.github/actions/restore-cache-aks/action.yml b/.github/actions/restore-cache-aks/action.yml index eccbb5ebfc..70c67f1d1c 100644 --- a/.github/actions/restore-cache-aks/action.yml +++ b/.github/actions/restore-cache-aks/action.yml @@ -17,6 +17,11 @@ runs: fi echo "Persisted cache is $(du -sh $cache_path | cut -f1)" + if [ `du $cache_path | cut -f1` = "0" ]; then + echo "Cache is empty - exiting" + exit 1 + fi + mkdir temp-cache tar -xf $cache_path -C temp-cache echo "Unzipped cache is $(du -sh temp-cache/src | cut -f1)" diff --git a/.github/actions/restore-cache-azcopy/action.yml b/.github/actions/restore-cache-azcopy/action.yml index d41014b755..562fbc6f43 100644 --- a/.github/actions/restore-cache-azcopy/action.yml +++ b/.github/actions/restore-cache-azcopy/action.yml @@ -44,6 +44,11 @@ runs: shell: bash run: | echo "Downloaded cache is $(du -sh $DEPSHASH.tar | cut -f1)" + if [ `du $DEPSHASH.tar | cut -f1` = "0" ]; then + echo "Cache is empty - exiting" + exit 1 + fi + mkdir temp-cache tar -xf $DEPSHASH.tar -C temp-cache echo "Unzipped cache is $(du -sh temp-cache/src | cut -f1)" diff --git a/.github/workflows/clean-src-cache.yml b/.github/workflows/clean-src-cache.yml new file mode 100644 index 0000000000..73af458ba7 --- /dev/null +++ b/.github/workflows/clean-src-cache.yml @@ -0,0 +1,21 @@ +name: Clean Source Cache + +on: + schedule: + - cron: "0 0 * * SUN" # Run at midnight every Sunday + +jobs: + clean-src-cache: + runs-on: electron-arc-linux-amd64-32core + container: + image: ghcr.io/electron/build:bc2f48b2415a670de18d13605b1cf0eb5fdbaae1 + options: --user root + volumes: + - /mnt/cross-instance-cache:/mnt/cross-instance-cache + steps: + - name: Cleanup Source Cache + shell: bash + run: | + df -h /mnt/cross-instance-cache + find /mnt/cross-instance-cache -type f -mtime +30 -delete + df -h /mnt/cross-instance-cache
build
8d382b9c60b4c94af6b4aa12bd1c9e776a9cc4cb
Milan Burda
2023-02-06 16:54:47
chore: remove deprecated capturer count APIs (#37075) chore: remove deprecated incrementCapturerCount() / decrementCapturerCount() Co-authored-by: Milan Burda <[email protected]>
diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 54f69ecb94..695f588552 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -1367,31 +1367,6 @@ If you would like the page to stay hidden, you should ensure that `stayHidden` i Returns `boolean` - Whether this page is being captured. It returns true when the capturer count is large then 0. -#### `contents.incrementCapturerCount([size, stayHidden, stayAwake])` _Deprecated_ - -* `size` [Size](structures/size.md) (optional) - The preferred size for the capturer. -* `stayHidden` boolean (optional) - Keep the page hidden instead of visible. -* `stayAwake` boolean (optional) - Keep the system awake instead of allowing it to sleep. - -Increase the capturer count by one. The page is considered visible when its browser window is -hidden and the capturer count is non-zero. If you would like the page to stay hidden, you should ensure that `stayHidden` is set to true. - -This also affects the Page Visibility API. - -**Deprecated:** This API's functionality is now handled automatically within `contents.capturePage()`. See [breaking changes](../breaking-changes.md). - -#### `contents.decrementCapturerCount([stayHidden, stayAwake])` _Deprecated_ - -* `stayHidden` boolean (optional) - Keep the page in hidden state instead of visible. -* `stayAwake` boolean (optional) - Keep the system awake instead of allowing it to sleep. - -Decrease the capturer count by one. The page will be set to hidden or occluded state when its -browser window is hidden or occluded and the capturer count reaches zero. If you want to -decrease the hidden capturer count instead you should set `stayHidden` to true. - -**Deprecated:** This API's functionality is now handled automatically within `contents.capturePage()`. -See [breaking changes](../breaking-changes.md). - #### `contents.getPrinters()` _Deprecated_ Get the system printer list. diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index f1291e0efd..51accc979d 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -3234,47 +3234,6 @@ v8::Local<v8::Promise> WebContents::CapturePage(gin::Arguments* args) { return handle; } -// TODO(codebytere): remove in Electron v23. -void WebContents::IncrementCapturerCount(gin::Arguments* args) { - EmitWarning(node::Environment::GetCurrent(args->isolate()), - "webContents.incrementCapturerCount() is deprecated and will be " - "removed in v23", - "electron"); - - gfx::Size size; - bool stay_hidden = false; - bool stay_awake = false; - - // get size arguments if they exist - args->GetNext(&size); - // get stayHidden arguments if they exist - args->GetNext(&stay_hidden); - // get stayAwake arguments if they exist - args->GetNext(&stay_awake); - - std::ignore = web_contents() - ->IncrementCapturerCount(size, stay_hidden, stay_awake) - .Release(); -} - -// TODO(codebytere): remove in Electron v23. -void WebContents::DecrementCapturerCount(gin::Arguments* args) { - EmitWarning(node::Environment::GetCurrent(args->isolate()), - "webContents.decrementCapturerCount() is deprecated and will be " - "removed in v23", - "electron"); - - bool stay_hidden = false; - bool stay_awake = false; - - // get stayHidden arguments if they exist - args->GetNext(&stay_hidden); - // get stayAwake arguments if they exist - args->GetNext(&stay_awake); - - web_contents()->DecrementCapturerCount(stay_hidden, stay_awake); -} - bool WebContents::IsBeingCaptured() { return web_contents()->IsBeingCaptured(); } @@ -4103,8 +4062,6 @@ v8::Local<v8::ObjectTemplate> WebContents::FillObjectTemplate( .SetMethod("setEmbedder", &WebContents::SetEmbedder) .SetMethod("setDevToolsWebContents", &WebContents::SetDevToolsWebContents) .SetMethod("getNativeView", &WebContents::GetNativeView) - .SetMethod("incrementCapturerCount", &WebContents::IncrementCapturerCount) - .SetMethod("decrementCapturerCount", &WebContents::DecrementCapturerCount) .SetMethod("isBeingCaptured", &WebContents::IsBeingCaptured) .SetMethod("setWebRTCIPHandlingPolicy", &WebContents::SetWebRTCIPHandlingPolicy) diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index 944a986d39..03415966ad 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -215,8 +215,6 @@ class WebContents : public ExclusiveAccessContext, void SetEmbedder(const WebContents* embedder); void SetDevToolsWebContents(const WebContents* devtools); v8::Local<v8::Value> GetNativeView(v8::Isolate* isolate) const; - void IncrementCapturerCount(gin::Arguments* args); - void DecrementCapturerCount(gin::Arguments* args); bool IsBeingCaptured(); void HandleNewRenderFrame(content::RenderFrameHost* render_frame_host); diff --git a/spec/api-browser-view-spec.ts b/spec/api-browser-view-spec.ts index 47557c233c..09a5a3f450 100644 --- a/spec/api-browser-view-spec.ts +++ b/spec/api-browser-view-spec.ts @@ -398,28 +398,8 @@ describe('BrowserView module', () => { }); await view.webContents.loadFile(path.join(fixtures, 'pages', 'a.html')); - view.webContents.incrementCapturerCount(); const image = await view.webContents.capturePage(); expect(image.isEmpty()).to.equal(false); }); - - it('should increase the capturer count', () => { - view = new BrowserView({ - webPreferences: { - backgroundThrottling: false - } - }); - w.setBrowserView(view); - view.setBounds({ - ...w.getBounds(), - x: 0, - y: 0 - }); - - view.webContents.incrementCapturerCount(); - expect(view.webContents.isBeingCaptured()).to.be.true(); - view.webContents.decrementCapturerCount(); - expect(view.webContents.isBeingCaptured()).to.be.false(); - }); }); }); diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index e169b045c1..ca5bcadd65 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -1790,7 +1790,6 @@ describe('BrowserWindow module', () => { w.loadFile(path.join(fixtures, 'pages', 'a.html')); await emittedOnce(w, 'ready-to-show'); - w.webContents.incrementCapturerCount(); const image = await w.capturePage(); expect(image.isEmpty()).to.equal(false); }); @@ -1808,14 +1807,6 @@ describe('BrowserWindow module', () => { // Values can be 0,2,3,4, or 6. We want 6, which is RGB + Alpha expect(imgBuffer[25]).to.equal(6); }); - - it('should increase the capturer count', () => { - const w = new BrowserWindow({ show: false }); - w.webContents.incrementCapturerCount(); - expect(w.webContents.isBeingCaptured()).to.be.true(); - w.webContents.decrementCapturerCount(); - expect(w.webContents.isBeingCaptured()).to.be.false(); - }); }); describe('BrowserWindow.setProgressBar(progress)', () => {
chore
5718ea4e1e5ce61cf80fb42509fcc18c5b1e9544
Charles Kerr
2024-09-09 12:14:40
fix: out-of-scope Local handle in node::CallbackScope (#43622) refactor: use an EscapableHandleScope
diff --git a/shell/common/gin_helper/event_emitter_caller.cc b/shell/common/gin_helper/event_emitter_caller.cc index 124a300cb4..0c7b055194 100644 --- a/shell/common/gin_helper/event_emitter_caller.cc +++ b/shell/common/gin_helper/event_emitter_caller.cc @@ -13,15 +13,14 @@ v8::Local<v8::Value> CallMethodWithArgs(v8::Isolate* isolate, v8::Local<v8::Object> obj, const char* method, ValueVector* args) { - // An active node::Environment is required for node::MakeCallback. - std::unique_ptr<node::CallbackScope> callback_scope; - if (node::Environment::GetCurrent(isolate)) { - v8::HandleScope handle_scope(isolate); - callback_scope = std::make_unique<node::CallbackScope>( - isolate, v8::Object::New(isolate), node::async_context{0, 0}); - } else { - return v8::Boolean::New(isolate, false); - } + v8::EscapableHandleScope handle_scope{isolate}; + + // CallbackScope and MakeCallback both require an active node::Environment + if (!node::Environment::GetCurrent(isolate)) + return handle_scope.Escape(v8::Boolean::New(isolate, false)); + + node::CallbackScope callback_scope{isolate, v8::Object::New(isolate), + node::async_context{0, 0}}; // Perform microtask checkpoint after running JavaScript. gin_helper::MicrotasksScope microtasks_scope{ @@ -36,11 +35,10 @@ v8::Local<v8::Value> CallMethodWithArgs(v8::Isolate* isolate, // of MakeCallback will be empty and therefore ToLocal will be false, in this // case we need to return "false" as that indicates that the event emitter did // not handle the event - v8::Local<v8::Value> localRet; - if (ret.ToLocal(&localRet)) - return localRet; + if (v8::Local<v8::Value> localRet; ret.ToLocal(&localRet)) + return handle_scope.Escape(localRet); - return v8::Boolean::New(isolate, false); + return handle_scope.Escape(v8::Boolean::New(isolate, false)); } } // namespace gin_helper::internal
fix
135c542555dc14af9cc0e21a9f741a380fdec706
Guo Hao (Andrew) Lay
2024-01-18 12:00:49
feat: Windows integrity check (#40504) * Add Windows integrity check feature into Electron Co-authored-by: Weiyun Dai <[email protected]> * Add integrity checker header file to sources Co-authored-by: Weiyun Dai <[email protected]> * Moved integrity checker after checking command line args Co-authored-by: Weiyun Dai <[email protected]> * Revert previous Windows integrity check commits (2379a60, 331cf3c, a3c47ec) Co-authored-by: guohaolay <[email protected]> * Implement asar header integrity for Windows platform. Co-authored-by: guohaolay <[email protected]> * Fix Archive::RelativePath() on Windows platform. Co-authored-by: guohaolay <[email protected]> * Address comments. * Address Windows integrity check PR comments. * Update absl::optional to std::optional. * Fix spelling. --------- Co-authored-by: Weiyun Dai <[email protected]> Co-authored-by: Weiyun Dai <[email protected]> Co-authored-by: Weiyun Dai <[email protected]>
diff --git a/BUILD.gn b/BUILD.gn index 33a25aa3dc..bd8b3afda1 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -660,6 +660,7 @@ source_set("electron_lib") { } if (is_win) { libs += [ "dwmapi.lib" ] + sources += [ "shell/common/asar/archive_win.cc" ] deps += [ "//components/crash/core/app:crash_export_thunks", "//ui/native_theme:native_theme_browser", diff --git a/shell/common/asar/archive.cc b/shell/common/asar/archive.cc index 35a2c1c54d..51fc12cc6d 100644 --- a/shell/common/asar/archive.cc +++ b/shell/common/asar/archive.cc @@ -239,7 +239,7 @@ bool Archive::Init() { return false; } -#if BUILDFLAG(IS_MAC) +#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN) // Validate header signature if required and possible if (electron::fuses::IsEmbeddedAsarIntegrityValidationEnabled() && RelativePath().has_value()) { @@ -276,7 +276,7 @@ bool Archive::Init() { return true; } -#if !BUILDFLAG(IS_MAC) +#if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_WIN) std::optional<IntegrityPayload> Archive::HeaderIntegrity() const { return std::nullopt; } diff --git a/shell/common/asar/archive_win.cc b/shell/common/asar/archive_win.cc new file mode 100644 index 0000000000..df637bb6ca --- /dev/null +++ b/shell/common/asar/archive_win.cc @@ -0,0 +1,166 @@ +// Copyright 2023 Slack Technologies, Inc. +// Contributors: Weiyun Dai (https://github.com/WeiyunD/), Andrew Lay +// (https://github.com/guohaolay) Use of this source code is governed by the MIT +// license that can be found in the LICENSE file. + +#include "shell/common/asar/archive.h" + +#include <algorithm> +#include <sstream> + +#include "base/base_paths.h" +#include "base/json/json_reader.h" +#include "base/logging.h" +#include "base/no_destructor.h" +#include "base/path_service.h" +#include "base/strings/string_util.h" +#include "base/strings/string_util_win.h" +#include "base/strings/utf_string_conversions.h" +#include "shell/common/asar/asar_util.h" + +namespace asar { + +const wchar_t kIntegrityCheckResourceType[] = L"Integrity"; +const wchar_t kIntegrityCheckResourceItem[] = L"ElectronAsar"; + +std::optional<base::FilePath> Archive::RelativePath() const { + base::FilePath exe_path; + if (!base::PathService::Get(base::FILE_EXE, &exe_path)) { + LOG(FATAL) << "Couldn't get exe file path"; + return std::nullopt; + } + + base::FilePath relative_path; + if (!exe_path.DirName().AppendRelativePath(path_, &relative_path)) { + return std::nullopt; + } + + return relative_path; +} + +std::optional<std::unordered_map<std::string, IntegrityPayload>> +LoadIntegrityConfigCache() { + static base::NoDestructor< + std::optional<std::unordered_map<std::string, IntegrityPayload>>> + integrity_config_cache; + + // Skip loading if cache is already loaded + if (integrity_config_cache->has_value()) { + return *integrity_config_cache; + } + + // Init cache + *integrity_config_cache = std::unordered_map<std::string, IntegrityPayload>(); + + // Load integrity config from exe resource + HMODULE module_handle = ::GetModuleHandle(NULL); + + HRSRC resource = ::FindResource(module_handle, kIntegrityCheckResourceItem, + kIntegrityCheckResourceType); + if (!resource) { + PLOG(FATAL) << "FindResource failed."; + return *integrity_config_cache; + } + + HGLOBAL rcData = ::LoadResource(module_handle, resource); + if (!rcData) { + PLOG(FATAL) << "LoadResource failed."; + return *integrity_config_cache; + } + + auto* res_data = static_cast<const char*>(::LockResource(rcData)); + int res_size = SizeofResource(module_handle, resource); + + if (!res_data) { + PLOG(FATAL) << "Failed to integrity config from exe resource."; + return *integrity_config_cache; + } + + if (!res_size) { + PLOG(FATAL) << "Unexpected empty integrity config from exe resource."; + return *integrity_config_cache; + } + + // Parse integrity config payload + std::string integrity_config_payload = std::string(res_data, res_size); + std::optional<base::Value> root = + base::JSONReader::Read(integrity_config_payload); + + if (!root.has_value()) { + LOG(FATAL) << "Invalid integrity config: NOT a valid JSON."; + return *integrity_config_cache; + } + + const base::Value::List* file_configs = root.value().GetIfList(); + if (!file_configs) { + LOG(FATAL) << "Invalid integrity config: NOT a list."; + return *integrity_config_cache; + } + + // Parse each individual file integrity config + for (size_t i = 0; i < file_configs->size(); i++) { + // Skip invalid file configs + const base::Value::Dict* ele_dict = (*file_configs)[i].GetIfDict(); + if (!ele_dict) { + LOG(WARNING) << "Skip config " << i << ": NOT a valid dict"; + continue; + } + + const std::string* file = ele_dict->FindString("file"); + if (!file || file->empty()) { + LOG(WARNING) << "Skip config " << i << ": Invalid file"; + continue; + } + + const std::string* alg = ele_dict->FindString("alg"); + if (!alg || base::ToLowerASCII(*alg) != "sha256") { + LOG(WARNING) << "Skip config " << i << ": Invalid alg"; + continue; + } + + const std::string* value = ele_dict->FindString("value"); + if (!value || value->empty()) { + LOG(WARNING) << "Skip config " << i << ": Invalid hash value"; + continue; + } + + // Add valid file config into cache + IntegrityPayload header_integrity; + header_integrity.algorithm = HashAlgorithm::kSHA256; + header_integrity.hash = base::ToLowerASCII(*value); + + integrity_config_cache->value()[base::ToLowerASCII(*file)] = + std::move(header_integrity); + } + + return *integrity_config_cache; +} + +std::optional<IntegrityPayload> Archive::HeaderIntegrity() const { + std::optional<base::FilePath> relative_path = RelativePath(); + // Callers should have already asserted this + CHECK(relative_path.has_value()); + + // Load integrity config from exe resource + std::optional<std::unordered_map<std::string, IntegrityPayload>> + integrity_config = LoadIntegrityConfigCache(); + if (!integrity_config.has_value()) { + LOG(WARNING) << "Failed to integrity config from exe resource."; + return std::nullopt; + } + + // Convert Window rel path to UTF8 lower case + std::string rel_path_utf8 = base::WideToUTF8(relative_path.value().value()); + rel_path_utf8 = base::ToLowerASCII(rel_path_utf8); + + // Find file integrity config + auto iter = integrity_config.value().find(rel_path_utf8); + if (iter == integrity_config.value().end()) { + LOG(FATAL) << "Failed to find file integrity info for " << rel_path_utf8; + return std::nullopt; + } + + return iter->second; +} + +} // namespace asar
feat
e138f5f915653966c3ec5779c9e4952cc08401bb
David Sanders
2023-05-17 10:33:30
docs: fix typing of message box type value (#38336) * docs: fix typing of dialog type value * test: add smoke tests * test: update test
diff --git a/docs/api/dialog.md b/docs/api/dialog.md index bc536e15ba..04960ed2dc 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -223,10 +223,10 @@ expanding and collapsing the dialog. * `browserWindow` [BrowserWindow](browser-window.md) (optional) * `options` Object * `message` string - Content of the message box. - * `type` string (optional) - Can be `"none"`, `"info"`, `"error"`, `"question"` or - `"warning"`. On Windows, `"question"` displays the same icon as `"info"`, unless - you set an icon using the `"icon"` option. On macOS, both `"warning"` and - `"error"` display the same warning icon. + * `type` string (optional) - Can be `none`, `info`, `error`, `question` or + `warning`. On Windows, `question` displays the same icon as `info`, unless + you set an icon using the `icon` option. On macOS, both `warning` and + `error` display the same warning icon. * `buttons` string[]&#32;(optional) - Array of texts for buttons. On Windows, an empty array will result in one button labeled "OK". * `defaultId` Integer (optional) - Index of the button in the buttons array which will @@ -266,10 +266,10 @@ If `browserWindow` is not shown dialog will not be attached to it. In such case * `browserWindow` [BrowserWindow](browser-window.md) (optional) * `options` Object * `message` string - Content of the message box. - * `type` string (optional) - Can be `"none"`, `"info"`, `"error"`, `"question"` or - `"warning"`. On Windows, `"question"` displays the same icon as `"info"`, unless - you set an icon using the `"icon"` option. On macOS, both `"warning"` and - `"error"` display the same warning icon. + * `type` string (optional) - Can be `none`, `info`, `error`, `question` or + `warning`. On Windows, `question` displays the same icon as `info`, unless + you set an icon using the `icon` option. On macOS, both `warning` and + `error` display the same warning icon. * `buttons` string[]&#32;(optional) - Array of texts for buttons. On Windows, an empty array will result in one button labeled "OK". * `defaultId` Integer (optional) - Index of the button in the buttons array which will diff --git a/spec/api-dialog-spec.ts b/spec/api-dialog-spec.ts index 2230b2f7fa..72cb18573f 100644 --- a/spec/api-dialog-spec.ts +++ b/spec/api-dialog-spec.ts @@ -97,7 +97,7 @@ describe('dialog module', () => { it('throws errors when the options are invalid', () => { expect(() => { - dialog.showMessageBox(undefined as any, { type: 'not-a-valid-type', message: '' }); + dialog.showMessageBox(undefined as any, { type: 'not-a-valid-type' as any, message: '' }); }).to.throw(/Invalid message box type/); expect(() => { diff --git a/spec/ts-smoke/electron/main.ts b/spec/ts-smoke/electron/main.ts index 9dfe9e819f..dba7fb3414 100644 --- a/spec/ts-smoke/electron/main.ts +++ b/spec/ts-smoke/electron/main.ts @@ -503,6 +503,24 @@ dialog.showOpenDialog(win3, { console.log(ret); }); +// variants without browserWindow +dialog.showMessageBox({ message: 'test', type: 'warning' }); +dialog.showMessageBoxSync({ message: 'test', type: 'error' }); + +// @ts-expect-error Invalid type value +dialog.showMessageBox({ message: 'test', type: 'foo' }); +// @ts-expect-error Invalid type value +dialog.showMessageBoxSync({ message: 'test', type: 'foo' }); + +// variants with browserWindow +dialog.showMessageBox(win3, { message: 'test', type: 'question' }); +dialog.showMessageBoxSync(win3, { message: 'test', type: 'info' }); + +// @ts-expect-error Invalid type value +dialog.showMessageBox(win3, { message: 'test', type: 'foo' }); +// @ts-expect-error Invalid type value +dialog.showMessageBoxSync(win3, { message: 'test', type: 'foo' }); + // desktopCapturer // https://github.com/electron/electron/blob/main/docs/api/desktop-capturer.md
docs
83666ddc3613b4633ace754bfbd32020e6dc4aba
Shelley Vohr
2025-01-20 11:05:15
fix: page scaling in silent mode printing (#45218)
diff --git a/patches/chromium/printing.patch b/patches/chromium/printing.patch index bb269b291f..2eba900d8a 100644 --- a/patches/chromium/printing.patch +++ b/patches/chromium/printing.patch @@ -653,7 +653,7 @@ index 6809c4576c71bc1e1a6ad4e0a37707272a9a10f4..3aad10424a6a31dab2ca393d00149ec6 PrintingFailed(int32 cookie, PrintFailureReason reason); diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc -index 18a8d64167b66d0de67c0c89779af90814b827c6..33079deee8720a447e2b4e1f3601542b59e1cf16 100644 +index 18a8d64167b66d0de67c0c89779af90814b827c6..52b95469f0392fbb108bef3f6d5ea0f8a81410fd 100644 --- a/components/printing/renderer/print_render_frame_helper.cc +++ b/components/printing/renderer/print_render_frame_helper.cc @@ -52,6 +52,7 @@ @@ -771,7 +771,7 @@ index 18a8d64167b66d0de67c0c89779af90814b827c6..33079deee8720a447e2b4e1f3601542b // Check if `this` is still valid. if (!self) return; -@@ -2359,29 +2374,37 @@ void PrintRenderFrameHelper::IPCProcessed() { +@@ -2359,29 +2374,43 @@ void PrintRenderFrameHelper::IPCProcessed() { } bool PrintRenderFrameHelper::InitPrintSettings(blink::WebLocalFrame* frame, @@ -803,10 +803,18 @@ index 18a8d64167b66d0de67c0c89779af90814b827c6..33079deee8720a447e2b4e1f3601542b bool center_on_paper = !IsPrintingPdfFrame(frame, node); - settings.params->print_scaling_option = -+ settings->params->print_scaling_option = - center_on_paper ? mojom::PrintScalingOption::kCenterShrinkToFitPaper - : mojom::PrintScalingOption::kSourceSize; +- center_on_paper ? mojom::PrintScalingOption::kCenterShrinkToFitPaper +- : mojom::PrintScalingOption::kSourceSize; - RecordDebugEvent(settings.params->printed_doc_type == ++ bool silent = new_settings.FindBool("silent").value_or(false); ++ if (silent) { ++ settings->params->print_scaling_option = mojom::PrintScalingOption::kFitToPrintableArea; ++ } else { ++ settings->params->print_scaling_option = ++ center_on_paper ? mojom::PrintScalingOption::kCenterShrinkToFitPaper ++ : mojom::PrintScalingOption::kSourceSize; ++ } ++ + RecordDebugEvent(settings->params->printed_doc_type == mojom::SkiaDocumentType::kMSKP ? DebugEvent::kSetPrintSettings5
fix
09190085c0d1d6acdbb83833afab8c1fe8177ba0
Milan Burda
2023-08-21 03:43:41
refactor: add gin_helper::Dictionary::CreateEmpty() helper (#39547)
diff --git a/shell/app/node_main.cc b/shell/app/node_main.cc index e03d35cf90..93af42efde 100644 --- a/shell/app/node_main.cc +++ b/shell/app/node_main.cc @@ -222,7 +222,7 @@ int NodeMain(int argc, char* argv[]) { process.SetMethod("crash", &ElectronBindings::Crash); // Setup process.crashReporter in child node processes - gin_helper::Dictionary reporter = gin::Dictionary::CreateEmpty(isolate); + auto reporter = gin_helper::Dictionary::CreateEmpty(isolate); reporter.SetMethod("getParameters", &GetParameters); #if IS_MAS_BUILD() reporter.SetMethod("addExtraParameter", &SetCrashKeyStub); diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index 52e7fb8c01..415ed4efc6 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -202,7 +202,7 @@ struct Converter<JumpListItem> { static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, const JumpListItem& val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("type", val.type); switch (val.type) { @@ -338,7 +338,7 @@ struct Converter<Browser::LaunchItem> { static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, Browser::LaunchItem val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("name", val.name); dict.Set("path", val.path); dict.Set("args", val.args); @@ -371,7 +371,7 @@ struct Converter<Browser::LoginItemSettings> { static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, Browser::LoginItemSettings val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("openAtLogin", val.open_at_login); dict.Set("openAsHidden", val.open_as_hidden); dict.Set("restoreState", val.restore_state); @@ -1263,7 +1263,7 @@ v8::Local<v8::Value> App::GetJumpListSettings() { } v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("minItems", min_items); dict.Set("removedItems", gin::ConvertToV8(isolate, removed_items)); return dict.GetHandle(); @@ -1344,8 +1344,8 @@ std::vector<gin_helper::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) { int processor_count = base::SysInfo::NumberOfProcessors(); for (const auto& process_metric : app_metrics_) { - gin_helper::Dictionary pid_dict = gin::Dictionary::CreateEmpty(isolate); - gin_helper::Dictionary cpu_dict = gin::Dictionary::CreateEmpty(isolate); + auto pid_dict = gin_helper::Dictionary::CreateEmpty(isolate); + auto cpu_dict = gin_helper::Dictionary::CreateEmpty(isolate); pid_dict.SetHidden("simple", true); cpu_dict.SetHidden("simple", true); @@ -1382,7 +1382,7 @@ std::vector<gin_helper::Dictionary> App::GetAppMetrics(v8::Isolate* isolate) { #if !BUILDFLAG(IS_LINUX) auto memory_info = process_metric.second->GetMemoryInfo(); - gin_helper::Dictionary memory_dict = gin::Dictionary::CreateEmpty(isolate); + auto memory_dict = gin_helper::Dictionary::CreateEmpty(isolate); memory_dict.SetHidden("simple", true); memory_dict.Set("workingSetSize", static_cast<double>(memory_info.working_set_size >> 10)); @@ -1534,7 +1534,7 @@ v8::Local<v8::Value> App::GetDockAPI(v8::Isolate* isolate) { // Initialize the Dock API, the methods are bound to "dock" which exists // for the lifetime of "app" auto browser = base::Unretained(Browser::Get()); - gin_helper::Dictionary dock_obj = gin::Dictionary::CreateEmpty(isolate); + auto dock_obj = gin_helper::Dictionary::CreateEmpty(isolate); dock_obj.SetMethod("bounce", &DockBounce); dock_obj.SetMethod( "cancelBounce", diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc index 57841dd41d..22dbf3825a 100644 --- a/shell/browser/api/electron_api_base_window.cc +++ b/shell/browser/api/electron_api_base_window.cc @@ -212,7 +212,7 @@ void BaseWindow::OnWindowWillResize(const gfx::Rect& new_bounds, bool* prevent_default) { v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope handle_scope(isolate); - gin_helper::Dictionary info = gin::Dictionary::CreateEmpty(isolate); + auto info = gin::Dictionary::CreateEmpty(isolate); info.Set("edge", edge); if (Emit("will-resize", new_bounds, info)) { diff --git a/shell/browser/api/electron_api_browser_window.cc b/shell/browser/api/electron_api_browser_window.cc index 02a3aa0cdd..f699aa8273 100644 --- a/shell/browser/api/electron_api_browser_window.cc +++ b/shell/browser/api/electron_api_browser_window.cc @@ -39,8 +39,7 @@ BrowserWindow::BrowserWindow(gin::Arguments* args, : BaseWindow(args->isolate(), options) { // Use options.webPreferences in WebContents. v8::Isolate* isolate = args->isolate(); - gin_helper::Dictionary web_preferences = - gin::Dictionary::CreateEmpty(isolate); + auto web_preferences = gin_helper::Dictionary::CreateEmpty(isolate); options.Get(options::kWebPreferences, &web_preferences); bool transparent = false; diff --git a/shell/browser/api/electron_api_desktop_capturer.cc b/shell/browser/api/electron_api_desktop_capturer.cc index 74530402e9..43bc87cf67 100644 --- a/shell/browser/api/electron_api_desktop_capturer.cc +++ b/shell/browser/api/electron_api_desktop_capturer.cc @@ -151,7 +151,7 @@ struct Converter<electron::api::DesktopCapturer::Source> { static v8::Local<v8::Value> ToV8( v8::Isolate* isolate, const electron::api::DesktopCapturer::Source& source) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); content::DesktopMediaID id = source.media_list_source.id; dict.Set("name", base::UTF16ToUTF8(source.media_list_source.name)); dict.Set("id", id.ToString()); diff --git a/shell/browser/api/electron_api_dialog.cc b/shell/browser/api/electron_api_dialog.cc index 7540834752..4ce5edca3e 100644 --- a/shell/browser/api/electron_api_dialog.cc +++ b/shell/browser/api/electron_api_dialog.cc @@ -29,7 +29,7 @@ void ResolvePromiseObject(gin_helper::Promise<gin_helper::Dictionary> promise, bool checkbox_checked) { v8::Isolate* isolate = promise.isolate(); v8::HandleScope handle_scope(isolate); - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("response", result); dict.Set("checkboxChecked", checkbox_checked); diff --git a/shell/browser/api/electron_api_in_app_purchase.cc b/shell/browser/api/electron_api_in_app_purchase.cc index 5256174045..5d93a3564f 100644 --- a/shell/browser/api/electron_api_in_app_purchase.cc +++ b/shell/browser/api/electron_api_in_app_purchase.cc @@ -20,7 +20,7 @@ struct Converter<in_app_purchase::PaymentDiscount> { static v8::Local<v8::Value> ToV8( v8::Isolate* isolate, const in_app_purchase::PaymentDiscount& paymentDiscount) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("identifier", paymentDiscount.identifier); dict.Set("keyIdentifier", paymentDiscount.keyIdentifier); @@ -35,7 +35,7 @@ template <> struct Converter<in_app_purchase::Payment> { static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, const in_app_purchase::Payment& payment) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("productIdentifier", payment.productIdentifier); dict.Set("quantity", payment.quantity); @@ -51,7 +51,7 @@ template <> struct Converter<in_app_purchase::Transaction> { static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, const in_app_purchase::Transaction& val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("transactionIdentifier", val.transactionIdentifier); dict.Set("transactionDate", val.transactionDate); @@ -71,7 +71,7 @@ struct Converter<in_app_purchase::ProductSubscriptionPeriod> { v8::Isolate* isolate, const in_app_purchase::ProductSubscriptionPeriod& productSubscriptionPeriod) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("numberOfUnits", productSubscriptionPeriod.numberOfUnits); dict.Set("unit", productSubscriptionPeriod.unit); @@ -84,7 +84,7 @@ struct Converter<in_app_purchase::ProductDiscount> { static v8::Local<v8::Value> ToV8( v8::Isolate* isolate, const in_app_purchase::ProductDiscount& productDiscount) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("identifier", productDiscount.identifier); dict.Set("type", productDiscount.type); @@ -104,7 +104,7 @@ template <> struct Converter<in_app_purchase::Product> { static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, const in_app_purchase::Product& val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("productIdentifier", val.productIdentifier); dict.Set("localizedDescription", val.localizedDescription); diff --git a/shell/browser/api/electron_api_notification.cc b/shell/browser/api/electron_api_notification.cc index 76f4cc3c4e..0b3e574f6e 100644 --- a/shell/browser/api/electron_api_notification.cc +++ b/shell/browser/api/electron_api_notification.cc @@ -36,7 +36,7 @@ struct Converter<electron::NotificationAction> { static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, electron::NotificationAction val) { - gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin::Dictionary::CreateEmpty(isolate); dict.Set("text", val.text); dict.Set("type", val.type); return ConvertToV8(isolate, dict); diff --git a/shell/browser/api/electron_api_printing.cc b/shell/browser/api/electron_api_printing.cc index 61101cefcf..195ac01bb6 100644 --- a/shell/browser/api/electron_api_printing.cc +++ b/shell/browser/api/electron_api_printing.cc @@ -24,7 +24,7 @@ template <> struct Converter<printing::PrinterBasicInfo> { static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, const printing::PrinterBasicInfo& val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("name", val.printer_name); dict.Set("displayName", val.display_name); dict.Set("description", val.printer_description); diff --git a/shell/browser/api/electron_api_system_preferences.cc b/shell/browser/api/electron_api_system_preferences.cc index e199cf30e8..ccbe9db827 100644 --- a/shell/browser/api/electron_api_system_preferences.cc +++ b/shell/browser/api/electron_api_system_preferences.cc @@ -35,7 +35,7 @@ SystemPreferences::~SystemPreferences() = default; v8::Local<v8::Value> SystemPreferences::GetAnimationSettings( v8::Isolate* isolate) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("shouldRenderRichAnimation", gfx::Animation::ShouldRenderRichAnimation()); diff --git a/shell/browser/api/electron_api_url_loader.cc b/shell/browser/api/electron_api_url_loader.cc index 0944a4dfd5..021909625d 100644 --- a/shell/browser/api/electron_api_url_loader.cc +++ b/shell/browser/api/electron_api_url_loader.cc @@ -50,7 +50,7 @@ struct Converter<network::mojom::HttpRawHeaderPairPtr> { static v8::Local<v8::Value> ToV8( v8::Isolate* isolate, const network::mojom::HttpRawHeaderPairPtr& pair) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("key", pair->key); dict.Set("value", pair->value); return dict.GetHandle(); @@ -709,7 +709,7 @@ void SimpleURLLoaderWrapper::OnResponseStarted( const network::mojom::URLResponseHead& response_head) { v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope scope(isolate); - gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin::Dictionary::CreateEmpty(isolate); dict.Set("statusCode", response_head.headers->response_code()); dict.Set("statusMessage", response_head.headers->GetStatusText()); dict.Set("httpVersion", response_head.headers->GetHttpVersion()); diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 069b777856..8e7db50616 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -1504,7 +1504,7 @@ void WebContents::FindReply(content::WebContents* web_contents, v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); v8::HandleScope handle_scope(isolate); - gin_helper::Dictionary result = gin::Dictionary::CreateEmpty(isolate); + auto result = gin_helper::Dictionary::CreateEmpty(isolate); result.Set("requestId", request_id); result.Set("matches", number_of_matches); result.Set("selectionArea", selection_rect); diff --git a/shell/browser/browser_mac.mm b/shell/browser/browser_mac.mm index 7fd2fc3ad4..34c972cf93 100644 --- a/shell/browser/browser_mac.mm +++ b/shell/browser/browser_mac.mm @@ -105,7 +105,7 @@ v8::Local<v8::Promise> Browser::GetApplicationInfoForProtocol( const GURL& url) { gin_helper::Promise<gin_helper::Dictionary> promise(isolate); v8::Local<v8::Promise> handle = promise.GetHandle(); - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); NSString* ns_app_path = GetAppPathForProtocol(url); diff --git a/shell/browser/browser_win.cc b/shell/browser/browser_win.cc index 2a72e070f4..8fcb7abab8 100644 --- a/shell/browser/browser_win.cc +++ b/shell/browser/browser_win.cc @@ -113,8 +113,7 @@ void OnIconDataAvailable(const base::FilePath& app_path, gfx::Image icon) { if (!icon.IsEmpty()) { v8::HandleScope scope(promise.isolate()); - gin_helper::Dictionary dict = - gin::Dictionary::CreateEmpty(promise.isolate()); + auto dict = gin_helper::Dictionary::CreateEmpty(promise.isolate()); dict.Set("path", app_path); dict.Set("name", app_display_name); @@ -270,7 +269,7 @@ void GetFileIcon(const base::FilePath& path, gfx::Image* icon = icon_manager->LookupIconFromFilepath(normalized_path, icon_size, 1.0f); if (icon) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("icon", *icon); dict.Set("name", app_display_name); dict.Set("path", normalized_path); diff --git a/shell/browser/lib/bluetooth_chooser.cc b/shell/browser/lib/bluetooth_chooser.cc index 2bd9310679..0c8708a91a 100644 --- a/shell/browser/lib/bluetooth_chooser.cc +++ b/shell/browser/lib/bluetooth_chooser.cc @@ -14,7 +14,7 @@ struct Converter<electron::BluetoothChooser::DeviceInfo> { static v8::Local<v8::Value> ToV8( v8::Isolate* isolate, const electron::BluetoothChooser::DeviceInfo& val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("deviceName", val.device_name); dict.Set("deviceId", val.device_id); return gin::ConvertToV8(isolate, dict); diff --git a/shell/browser/serial/serial_chooser_controller.cc b/shell/browser/serial/serial_chooser_controller.cc index f15722b223..66a8ea034e 100644 --- a/shell/browser/serial/serial_chooser_controller.cc +++ b/shell/browser/serial/serial_chooser_controller.cc @@ -26,7 +26,7 @@ struct Converter<device::mojom::SerialPortInfoPtr> { static v8::Local<v8::Value> ToV8( v8::Isolate* isolate, const device::mojom::SerialPortInfoPtr& port) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("portId", port->token.ToString()); dict.Set("portName", port->path.BaseName().LossyDisplayName()); if (port->display_name && !port->display_name->empty()) { diff --git a/shell/common/api/electron_api_asar.cc b/shell/common/api/electron_api_asar.cc index e3932e1eaa..f0adf8b53a 100644 --- a/shell/common/api/electron_api_asar.cc +++ b/shell/common/api/electron_api_asar.cc @@ -215,7 +215,7 @@ static void SplitPath(const v8::FunctionCallbackInfo<v8::Value>& args) { return; } - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); base::FilePath asar_path, file_path; if (asar::GetAsarArchivePath(path, &asar_path, &file_path, true)) { dict.Set("isAsar", true); diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc index 9cb7b396ea..d9a4916ee0 100644 --- a/shell/common/api/electron_api_native_image.cc +++ b/shell/common/api/electron_api_native_image.cc @@ -643,7 +643,7 @@ void Initialize(v8::Local<v8::Object> exports, void* priv) { v8::Isolate* isolate = context->GetIsolate(); gin_helper::Dictionary dict(isolate, exports); - gin_helper::Dictionary native_image = gin::Dictionary::CreateEmpty(isolate); + auto native_image = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("nativeImage", native_image); native_image.SetMethod("createEmpty", &NativeImage::CreateEmpty); diff --git a/shell/common/api/electron_bindings.cc b/shell/common/api/electron_bindings.cc index b1f9ac3f11..7651548d3d 100644 --- a/shell/common/api/electron_bindings.cc +++ b/shell/common/api/electron_bindings.cc @@ -139,7 +139,7 @@ v8::Local<v8::Value> ElectronBindings::GetHeapStatistics(v8::Isolate* isolate) { v8::HeapStatistics v8_heap_stats; isolate->GetHeapStatistics(&v8_heap_stats); - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("totalHeapSize", static_cast<double>(v8_heap_stats.total_heap_size() >> 10)); @@ -184,7 +184,7 @@ v8::Local<v8::Value> ElectronBindings::GetSystemMemoryInfo( return v8::Undefined(isolate); } - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("total", mem_info.total); @@ -235,7 +235,7 @@ v8::Local<v8::Value> ElectronBindings::GetBlinkMemoryInfo( auto allocated = blink::ProcessHeap::TotalAllocatedObjectSize(); auto total = blink::ProcessHeap::TotalAllocatedSpace(); - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("allocated", static_cast<double>(allocated >> 10)); dict.Set("total", static_cast<double>(total >> 10)); @@ -266,7 +266,7 @@ void ElectronBindings::DidReceiveMemoryDump( for (const memory_instrumentation::GlobalMemoryDump::ProcessDump& dump : global_dump->process_dumps()) { if (target_pid == dump.pid()) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); const auto& osdump = dump.os_dump(); #if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_WIN) dict.Set("residentSet", osdump.resident_set_kb); @@ -288,7 +288,7 @@ void ElectronBindings::DidReceiveMemoryDump( v8::Local<v8::Value> ElectronBindings::GetCPUUsage( base::ProcessMetrics* metrics, v8::Isolate* isolate) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); int processor_count = base::SysInfo::NumberOfProcessors(); dict.Set("percentCPUUsage", @@ -309,7 +309,7 @@ v8::Local<v8::Value> ElectronBindings::GetCPUUsage( v8::Local<v8::Value> ElectronBindings::GetIOCounters(v8::Isolate* isolate) { auto metrics = base::ProcessMetrics::CreateCurrentProcessMetrics(); base::IoCounters io_counters; - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); if (metrics->GetIOCounters(&io_counters)) { diff --git a/shell/common/gin_converters/blink_converter.cc b/shell/common/gin_converters/blink_converter.cc index 75054b1b55..0c42a4ae01 100644 --- a/shell/common/gin_converters/blink_converter.cc +++ b/shell/common/gin_converters/blink_converter.cc @@ -311,7 +311,7 @@ int GetKeyLocationCode(const blink::WebInputEvent& key) { v8::Local<v8::Value> Converter<blink::WebKeyboardEvent>::ToV8( v8::Isolate* isolate, const blink::WebKeyboardEvent& in) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("type", in.GetType()); dict.Set("key", ui::KeycodeConverter::DomKeyToKeyString(in.dom_key)); @@ -468,7 +468,7 @@ Converter<blink::mojom::ContextMenuDataInputFieldType>::ToV8( } v8::Local<v8::Value> EditFlagsToV8(v8::Isolate* isolate, int editFlags) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("canUndo", !!(editFlags & blink::ContextMenuDataEditFlags::kCanUndo)); dict.Set("canRedo", @@ -497,7 +497,7 @@ v8::Local<v8::Value> EditFlagsToV8(v8::Isolate* isolate, int editFlags) { } v8::Local<v8::Value> MediaFlagsToV8(v8::Isolate* isolate, int mediaFlags) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("inError", !!(mediaFlags & blink::ContextMenuData::kMediaInError)); dict.Set("isPaused", !!(mediaFlags & blink::ContextMenuData::kMediaPaused)); dict.Set("isMuted", !!(mediaFlags & blink::ContextMenuData::kMediaMuted)); @@ -522,7 +522,7 @@ v8::Local<v8::Value> MediaFlagsToV8(v8::Isolate* isolate, int mediaFlags) { v8::Local<v8::Value> Converter<blink::WebCacheResourceTypeStat>::ToV8( v8::Isolate* isolate, const blink::WebCacheResourceTypeStat& stat) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("count", static_cast<uint32_t>(stat.count)); dict.Set("size", static_cast<double>(stat.size)); dict.Set("liveSize", static_cast<double>(stat.decoded_size)); @@ -532,7 +532,7 @@ v8::Local<v8::Value> Converter<blink::WebCacheResourceTypeStat>::ToV8( v8::Local<v8::Value> Converter<blink::WebCacheResourceTypeStats>::ToV8( v8::Isolate* isolate, const blink::WebCacheResourceTypeStats& stats) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("images", stats.images); dict.Set("scripts", stats.scripts); dict.Set("cssStyleSheets", stats.css_style_sheets); @@ -565,7 +565,7 @@ bool Converter<network::mojom::ReferrerPolicy>::FromV8( v8::Local<v8::Value> Converter<blink::mojom::Referrer>::ToV8( v8::Isolate* isolate, const blink::mojom::Referrer& val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("url", ConvertToV8(isolate, val.url)); dict.Set("policy", ConvertToV8(isolate, val.policy)); return gin::ConvertToV8(isolate, dict); diff --git a/shell/common/gin_converters/content_converter.cc b/shell/common/gin_converters/content_converter.cc index 3da666f188..5e357a7b42 100644 --- a/shell/common/gin_converters/content_converter.cc +++ b/shell/common/gin_converters/content_converter.cc @@ -125,7 +125,7 @@ v8::Local<v8::Value> Converter<ContextMenuParamsWithRenderFrameHost>::ToV8( const ContextMenuParamsWithRenderFrameHost& val) { const auto& params = val.first; content::RenderFrameHost* render_frame_host = val.second; - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetGetter("frame", render_frame_host, v8::DontEnum); dict.Set("x", params.x); dict.Set("y", params.y); @@ -309,7 +309,7 @@ bool Converter<content::WebContents*>::FromV8(v8::Isolate* isolate, v8::Local<v8::Value> Converter<content::Referrer>::ToV8( v8::Isolate* isolate, const content::Referrer& val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("url", ConvertToV8(isolate, val.url)); dict.Set("policy", ConvertToV8(isolate, val.policy)); return gin::ConvertToV8(isolate, dict); diff --git a/shell/common/gin_converters/file_dialog_converter.cc b/shell/common/gin_converters/file_dialog_converter.cc index 2f12c71a18..f1a0d11fff 100644 --- a/shell/common/gin_converters/file_dialog_converter.cc +++ b/shell/common/gin_converters/file_dialog_converter.cc @@ -27,7 +27,7 @@ bool Converter<file_dialog::Filter>::FromV8(v8::Isolate* isolate, v8::Local<v8::Value> Converter<file_dialog::Filter>::ToV8( v8::Isolate* isolate, const file_dialog::Filter& in) { - gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin::Dictionary::CreateEmpty(isolate); dict.Set("name", in.first); dict.Set("extensions", in.second); @@ -58,7 +58,7 @@ bool Converter<file_dialog::DialogSettings>::FromV8( v8::Local<v8::Value> Converter<file_dialog::DialogSettings>::ToV8( v8::Isolate* isolate, const file_dialog::DialogSettings& in) { - gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin::Dictionary::CreateEmpty(isolate); dict.Set("window", electron::api::BrowserWindow::From(isolate, in.parent_window)); diff --git a/shell/common/gin_converters/gfx_converter.cc b/shell/common/gin_converters/gfx_converter.cc index a52d90bb8b..eff8a735d7 100644 --- a/shell/common/gin_converters/gfx_converter.cc +++ b/shell/common/gin_converters/gfx_converter.cc @@ -17,7 +17,7 @@ namespace gin { v8::Local<v8::Value> Converter<gfx::Point>::ToV8(v8::Isolate* isolate, const gfx::Point& val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("x", val.x()); dict.Set("y", val.y()); @@ -40,7 +40,7 @@ bool Converter<gfx::Point>::FromV8(v8::Isolate* isolate, v8::Local<v8::Value> Converter<gfx::PointF>::ToV8(v8::Isolate* isolate, const gfx::PointF& val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("x", val.x()); dict.Set("y", val.y()); @@ -62,7 +62,7 @@ bool Converter<gfx::PointF>::FromV8(v8::Isolate* isolate, v8::Local<v8::Value> Converter<gfx::Size>::ToV8(v8::Isolate* isolate, const gfx::Size& val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("width", val.width()); dict.Set("height", val.height()); @@ -84,7 +84,7 @@ bool Converter<gfx::Size>::FromV8(v8::Isolate* isolate, v8::Local<v8::Value> Converter<gfx::Rect>::ToV8(v8::Isolate* isolate, const gfx::Rect& val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("x", val.x()); dict.Set("y", val.y()); @@ -141,7 +141,7 @@ struct Converter<display::Display::TouchSupport> { v8::Local<v8::Value> Converter<display::Display>::ToV8( v8::Isolate* isolate, const display::Display& val) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("id", val.id()); dict.Set("label", val.label()); diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc index be1bc50416..c477bff4d3 100644 --- a/shell/common/gin_converters/net_converter.cc +++ b/shell/common/gin_converters/net_converter.cc @@ -59,7 +59,7 @@ bool CertFromData(const std::string& data, v8::Local<v8::Value> Converter<net::AuthChallengeInfo>::ToV8( v8::Isolate* isolate, const net::AuthChallengeInfo& val) { - gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin::Dictionary::CreateEmpty(isolate); dict.Set("isProxy", val.is_proxy); dict.Set("scheme", val.scheme); dict.Set("host", val.challenger.host()); @@ -610,7 +610,7 @@ bool Converter<scoped_refptr<network::ResourceRequestBody>>::FromV8( v8::Local<v8::Value> Converter<network::ResourceRequest>::ToV8( v8::Isolate* isolate, const network::ResourceRequest& val) { - gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin::Dictionary::CreateEmpty(isolate); dict.Set("method", val.method); dict.Set("url", val.url.spec()); dict.Set("referrer", val.referrer.spec()); @@ -624,7 +624,7 @@ v8::Local<v8::Value> Converter<network::ResourceRequest>::ToV8( v8::Local<v8::Value> Converter<electron::VerifyRequestParams>::ToV8( v8::Isolate* isolate, electron::VerifyRequestParams val) { - gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin::Dictionary::CreateEmpty(isolate); dict.Set("hostname", val.hostname); dict.Set("certificate", val.certificate); dict.Set("validatedCertificate", val.validated_certificate); @@ -638,7 +638,7 @@ v8::Local<v8::Value> Converter<electron::VerifyRequestParams>::ToV8( v8::Local<v8::Value> Converter<net::HttpVersion>::ToV8( v8::Isolate* isolate, const net::HttpVersion& val) { - gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin::Dictionary::CreateEmpty(isolate); dict.Set("major", static_cast<uint32_t>(val.major_value())); dict.Set("minor", static_cast<uint32_t>(val.minor_value())); return ConvertToV8(isolate, dict); @@ -648,7 +648,7 @@ v8::Local<v8::Value> Converter<net::HttpVersion>::ToV8( v8::Local<v8::Value> Converter<net::RedirectInfo>::ToV8( v8::Isolate* isolate, const net::RedirectInfo& val) { - gin::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin::Dictionary::CreateEmpty(isolate); dict.Set("statusCode", val.status_code); dict.Set("newMethod", val.new_method); diff --git a/shell/common/gin_converters/serial_port_info_converter.h b/shell/common/gin_converters/serial_port_info_converter.h index c772967112..26a4b81190 100644 --- a/shell/common/gin_converters/serial_port_info_converter.h +++ b/shell/common/gin_converters/serial_port_info_converter.h @@ -16,7 +16,7 @@ struct Converter<device::mojom::SerialPortInfoPtr> { static v8::Local<v8::Value> ToV8( v8::Isolate* isolate, const device::mojom::SerialPortInfoPtr& port) { - gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate); + auto dict = gin_helper::Dictionary::CreateEmpty(isolate); dict.Set("portId", port->token.ToString()); dict.Set("portName", port->path.BaseName().LossyDisplayName()); if (port->display_name && !port->display_name->empty()) diff --git a/shell/common/gin_helper/callback.cc b/shell/common/gin_helper/callback.cc index fe2d46bd04..94f33493e2 100644 --- a/shell/common/gin_helper/callback.cc +++ b/shell/common/gin_helper/callback.cc @@ -126,7 +126,7 @@ v8::Local<v8::Value> CreateFunctionFromTranslater(v8::Isolate* isolate, v8::Local<v8::FunctionTemplate>::New(isolate, g_call_translater); auto* holder = new TranslaterHolder(isolate); holder->translater = translater; - gin::Dictionary state = gin::Dictionary::CreateEmpty(isolate); + auto state = gin::Dictionary::CreateEmpty(isolate); if (one_time) state.Set("oneTime", true); auto context = isolate->GetCurrentContext(); diff --git a/shell/common/gin_helper/dictionary.h b/shell/common/gin_helper/dictionary.h index 9d3fd527c3..dbf7a9c33e 100644 --- a/shell/common/gin_helper/dictionary.h +++ b/shell/common/gin_helper/dictionary.h @@ -31,6 +31,10 @@ class Dictionary : public gin::Dictionary { Dictionary(const gin::Dictionary& dict) // NOLINT(runtime/explicit) : gin::Dictionary(dict) {} + static Dictionary CreateEmpty(v8::Isolate* isolate) { + return gin::Dictionary::CreateEmpty(isolate); + } + // Differences from the Get method in gin::Dictionary: // 1. This is a const method; // 2. It checks whether the key exists before reading; diff --git a/shell/renderer/electron_sandboxed_renderer_client.cc b/shell/renderer/electron_sandboxed_renderer_client.cc index 9a6fa489c0..1cef120592 100644 --- a/shell/renderer/electron_sandboxed_renderer_client.cc +++ b/shell/renderer/electron_sandboxed_renderer_client.cc @@ -137,7 +137,7 @@ void ElectronSandboxedRendererClient::InitializeBindings( b.SetMethod("get", GetBinding); b.SetMethod("createPreloadScript", CreatePreloadScript); - gin_helper::Dictionary process = gin::Dictionary::CreateEmpty(isolate); + auto process = gin_helper::Dictionary::CreateEmpty(isolate); b.Set("process", process); ElectronBindings::BindProcess(isolate, &process, metrics_.get()); diff --git a/shell/renderer/renderer_client_base.cc b/shell/renderer/renderer_client_base.cc index e5309b3989..b80ba7a487 100644 --- a/shell/renderer/renderer_client_base.cc +++ b/shell/renderer/renderer_client_base.cc @@ -596,7 +596,7 @@ void RendererClientBase::SetupMainWorldOverrides( v8::HandleScope handle_scope(isolate); v8::Context::Scope context_scope(context); - gin_helper::Dictionary isolated_api = gin::Dictionary::CreateEmpty(isolate); + auto isolated_api = gin_helper::Dictionary::CreateEmpty(isolate); isolated_api.SetMethod("allowGuestViewElementDefinition", &AllowGuestViewElementDefinition); isolated_api.SetMethod("setIsWebView", &SetIsWebView);
refactor
3dd7e46291b8177524055d91e1764b0c9a6bf38a
Charles Kerr
2024-09-12 10:56:15
refactor: avoid minor code repetition in native_image.cc (#43689) chore: delegate handle creation in NativeImage::Resize() chore: delegate handle creation in NativeImage::Crop() chore: delegate handle creation in NativeImage::CreateEmpty()
diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc index cd8b8643a5..de9efadaea 100644 --- a/shell/common/api/electron_api_native_image.cc +++ b/shell/common/api/electron_api_native_image.cc @@ -374,18 +374,15 @@ gin::Handle<NativeImage> NativeImage::Resize(gin::Arguments* args, else if (quality && *quality == "better") method = skia::ImageOperations::ResizeMethod::RESIZE_BETTER; - gfx::ImageSkia resized = gfx::ImageSkiaOperations::CreateResizedImage( - image_.AsImageSkia(), method, size); - return gin::CreateHandle( - args->isolate(), new NativeImage(args->isolate(), gfx::Image(resized))); + return Create(args->isolate(), + gfx::Image{gfx::ImageSkiaOperations::CreateResizedImage( + image_.AsImageSkia(), method, size)}); } gin::Handle<NativeImage> NativeImage::Crop(v8::Isolate* isolate, const gfx::Rect& rect) { - gfx::ImageSkia cropped = - gfx::ImageSkiaOperations::ExtractSubset(image_.AsImageSkia(), rect); - return gin::CreateHandle(isolate, - new NativeImage(isolate, gfx::Image(cropped))); + return Create(isolate, gfx::Image{gfx::ImageSkiaOperations::ExtractSubset( + image_.AsImageSkia(), rect)}); } void NativeImage::AddRepresentation(const gin_helper::Dictionary& options) { @@ -437,7 +434,7 @@ bool NativeImage::IsTemplateImage() { // static gin::Handle<NativeImage> NativeImage::CreateEmpty(v8::Isolate* isolate) { - return gin::CreateHandle(isolate, new NativeImage(isolate, gfx::Image())); + return Create(isolate, gfx::Image{}); } // static
refactor
7e9eb9e3f1ea4ee73c01e1d1860e2069ee0034d0
Charles Kerr
2024-07-29 12:43:28
perf: avoid duplicate calculations in gin_helper::Dictionary getters (#43073) * perf: cache the dictionary handle * refactor: prefer result.IsJust() over !result.IsNothing() for consistency * refactor: prefer maybe.FromMaybe() over maybe.IsJust() && maybe.FromJust() the inlined code is simpler * refactor: simplify Get() impl * refactor: add private helper Dictionary::MakeKey() refactor: add private helper Dictionary::MakeHiddenKey()
diff --git a/shell/common/gin_helper/dictionary.h b/shell/common/gin_helper/dictionary.h index be0e9fae72..e51ddd623a 100644 --- a/shell/common/gin_helper/dictionary.h +++ b/shell/common/gin_helper/dictionary.h @@ -42,16 +42,16 @@ class Dictionary : public gin::Dictionary { // 3. It accepts arbitrary type of key. template <typename K, typename V> bool Get(const K& key, V* out) const { + v8::Isolate* const iso = isolate(); + v8::Local<v8::Object> handle = GetHandle(); + v8::Local<v8::Context> context = iso->GetCurrentContext(); + v8::Local<v8::Value> v8_key = gin::ConvertToV8(iso, key); + v8::Local<v8::Value> value; // Check for existence before getting, otherwise this method will always // returns true when T == v8::Local<v8::Value>. - v8::Local<v8::Context> context = isolate()->GetCurrentContext(); - v8::Local<v8::Value> v8_key = gin::ConvertToV8(isolate(), key); - v8::Local<v8::Value> value; - v8::Maybe<bool> result = GetHandle()->Has(context, v8_key); - if (result.IsJust() && result.FromJust() && - GetHandle()->Get(context, v8_key).ToLocal(&value)) - return gin::ConvertFromV8(isolate(), value, out); - return false; + return handle->Has(context, v8_key).FromMaybe(false) && + handle->Get(context, v8_key).ToLocal(&value) && + gin::ConvertFromV8(iso, value, out); } // Differences from the Set method in gin::Dictionary: @@ -64,7 +64,7 @@ class Dictionary : public gin::Dictionary { v8::Maybe<bool> result = GetHandle()->Set(isolate()->GetCurrentContext(), gin::ConvertToV8(isolate(), key), v8_value); - return !result.IsNothing() && result.FromJust(); + return result.FromMaybe(false); } // Like normal Get but put result in an std::optional. @@ -81,28 +81,27 @@ class Dictionary : public gin::Dictionary { template <typename T> bool GetHidden(std::string_view key, T* out) const { - v8::Local<v8::Context> context = isolate()->GetCurrentContext(); - v8::Local<v8::Private> privateKey = - v8::Private::ForApi(isolate(), gin::StringToV8(isolate(), key)); + v8::Isolate* const iso = isolate(); + v8::Local<v8::Object> handle = GetHandle(); + v8::Local<v8::Context> context = iso->GetCurrentContext(); + v8::Local<v8::Private> privateKey = MakeHiddenKey(key); v8::Local<v8::Value> value; - v8::Maybe<bool> result = GetHandle()->HasPrivate(context, privateKey); - if (result.IsJust() && result.FromJust() && - GetHandle()->GetPrivate(context, privateKey).ToLocal(&value)) - return gin::ConvertFromV8(isolate(), value, out); - return false; + return handle->HasPrivate(context, privateKey).FromMaybe(false) && + handle->GetPrivate(context, privateKey).ToLocal(&value) && + gin::ConvertFromV8(iso, value, out); } template <typename T> bool SetHidden(std::string_view key, T val) { + v8::Isolate* const iso = isolate(); v8::Local<v8::Value> v8_value; - if (!gin::TryConvertToV8(isolate(), val, &v8_value)) + if (!gin::TryConvertToV8(iso, val, &v8_value)) return false; - v8::Local<v8::Context> context = isolate()->GetCurrentContext(); - v8::Local<v8::Private> privateKey = - v8::Private::ForApi(isolate(), gin::StringToV8(isolate(), key)); + v8::Local<v8::Context> context = iso->GetCurrentContext(); + v8::Local<v8::Private> privateKey = MakeHiddenKey(key); v8::Maybe<bool> result = GetHandle()->SetPrivate(context, privateKey, v8_value); - return !result.IsNothing() && result.FromJust(); + return result.FromMaybe(false); } template <typename T> @@ -110,7 +109,7 @@ class Dictionary : public gin::Dictionary { auto context = isolate()->GetCurrentContext(); auto templ = CallbackTraits<T>::CreateTemplate(isolate(), callback); return GetHandle() - ->Set(context, gin::StringToV8(isolate(), key), + ->Set(context, MakeKey(key), templ->GetFunction(context).ToLocalChecked()) .ToChecked(); } @@ -130,7 +129,7 @@ class Dictionary : public gin::Dictionary { return GetHandle() ->SetNativeDataProperty( - context, gin::StringToV8(isolate(), key), + context, MakeKey(key), [](v8::Local<v8::Name> property_name, const v8::PropertyCallbackInfo<v8::Value>& info) { AccessorValue<V> acc_value; @@ -153,9 +152,8 @@ class Dictionary : public gin::Dictionary { if (!gin::TryConvertToV8(isolate(), val, &v8_value)) return false; v8::Maybe<bool> result = GetHandle()->DefineOwnProperty( - isolate()->GetCurrentContext(), gin::StringToV8(isolate(), key), - v8_value, v8::ReadOnly); - return !result.IsNothing() && result.FromJust(); + isolate()->GetCurrentContext(), MakeKey(key), v8_value, v8::ReadOnly); + return result.FromMaybe(false); } // Note: If we plan to add more Set methods, consider adding an option instead @@ -166,22 +164,21 @@ class Dictionary : public gin::Dictionary { if (!gin::TryConvertToV8(isolate(), val, &v8_value)) return false; v8::Maybe<bool> result = GetHandle()->DefineOwnProperty( - isolate()->GetCurrentContext(), gin::StringToV8(isolate(), key), - v8_value, + isolate()->GetCurrentContext(), MakeKey(key), v8_value, static_cast<v8::PropertyAttribute>(v8::ReadOnly | v8::DontDelete)); - return !result.IsNothing() && result.FromJust(); + return result.FromMaybe(false); } bool Has(std::string_view key) const { - v8::Maybe<bool> result = GetHandle()->Has(isolate()->GetCurrentContext(), - gin::StringToV8(isolate(), key)); - return !result.IsNothing() && result.FromJust(); + v8::Maybe<bool> result = + GetHandle()->Has(isolate()->GetCurrentContext(), MakeKey(key)); + return result.FromMaybe(false); } bool Delete(std::string_view key) { - v8::Maybe<bool> result = GetHandle()->Delete( - isolate()->GetCurrentContext(), gin::StringToV8(isolate(), key)); - return !result.IsNothing() && result.FromJust(); + v8::Maybe<bool> result = + GetHandle()->Delete(isolate()->GetCurrentContext(), MakeKey(key)); + return result.FromMaybe(false); } bool IsEmpty() const { return isolate() == nullptr || GetHandle().IsEmpty(); } @@ -194,6 +191,16 @@ class Dictionary : public gin::Dictionary { private: // DO NOT ADD ANY DATA MEMBER. + + [[nodiscard]] v8::Local<v8::String> MakeKey( + const std::string_view key) const { + return gin::StringToV8(isolate(), key); + } + + [[nodiscard]] v8::Local<v8::Private> MakeHiddenKey( + const std::string_view key) const { + return v8::Private::ForApi(isolate(), MakeKey(key)); + } }; } // namespace gin_helper diff --git a/shell/common/gin_helper/persistent_dictionary.h b/shell/common/gin_helper/persistent_dictionary.h index 87d0dc46c5..7bb41835fd 100644 --- a/shell/common/gin_helper/persistent_dictionary.h +++ b/shell/common/gin_helper/persistent_dictionary.h @@ -32,14 +32,13 @@ class PersistentDictionary { template <typename K, typename V> bool Get(const K& key, V* out) const { + const auto handle = GetHandle(); v8::Local<v8::Context> context = isolate_->GetCurrentContext(); v8::Local<v8::Value> v8_key = gin::ConvertToV8(isolate_, key); v8::Local<v8::Value> value; - v8::Maybe<bool> result = GetHandle()->Has(context, v8_key); - if (result.IsJust() && result.FromJust() && - GetHandle()->Get(context, v8_key).ToLocal(&value)) - return gin::ConvertFromV8(isolate_, value, out); - return false; + return handle->Has(context, v8_key).FromMaybe(false) && + handle->Get(context, v8_key).ToLocal(&value) && + gin::ConvertFromV8(isolate_, value, out); } private:
perf
bee5d94886c91f7d5ca3e1cab9a4d2cdfac8d268
Robo
2023-08-15 19:19:45
feat: support dns-result-order Node.js cli flag (#39376) * feat: support dns-result-order Node.js cli flag * chore: update docs Co-authored-by: Erick Zhao <[email protected]> * chore: remove patch --------- Co-authored-by: Erick Zhao <[email protected]>
diff --git a/docs/api/command-line-switches.md b/docs/api/command-line-switches.md index ee5e746420..fd63da4f1c 100644 --- a/docs/api/command-line-switches.md +++ b/docs/api/command-line-switches.md @@ -291,6 +291,15 @@ Print stack traces for deprecations. Print stack traces for process warnings (including deprecations). +### `--dns-result-order=order` + +Set the default value of the `verbatim` parameter in the Node.js [`dns.lookup()`](https://nodejs.org/api/dns.html#dnslookuphostname-options-callback) and [`dnsPromises.lookup()`](https://nodejs.org/api/dns.html#dnspromiseslookuphostname-options) functions. The value could be: + +* `ipv4first`: sets default `verbatim` `false`. +* `verbatim`: sets default `verbatim` `true`. + +The default is `verbatim` and `dns.setDefaultResultOrder()` have higher priority than `--dns-result-order`. + [app]: app.md [append-switch]: command-line.md#commandlineappendswitchswitch-value [debugging-main-process]: ../tutorial/debugging-main-process.md diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 63a99e30e9..766d043059 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -244,9 +244,13 @@ bool IsAllowedOption(base::StringPiece option) { }); // This should be aligned with what's possible to set via the process object. - static constexpr auto options = base::MakeFixedFlatSet<base::StringPiece>( - {"--trace-warnings", "--trace-deprecation", "--throw-deprecation", - "--no-deprecation"}); + static constexpr auto options = base::MakeFixedFlatSet<base::StringPiece>({ + "--trace-warnings", + "--trace-deprecation", + "--throw-deprecation", + "--no-deprecation", + "--dns-result-order", + }); if (debug_options.contains(option)) return electron::fuses::IsNodeCliInspectEnabled(); diff --git a/spec/api-utility-process-spec.ts b/spec/api-utility-process-spec.ts index 2afaeca61e..278fbfba62 100644 --- a/spec/api-utility-process-spec.ts +++ b/spec/api-utility-process-spec.ts @@ -257,6 +257,30 @@ describe('utilityProcess module', () => { child.stdout!.on('data', listener); }); + it('supports changing dns verbatim with --dns-result-order', (done) => { + const child = utilityProcess.fork(path.join(fixturesPath, 'dns-result-order.js'), [], { + stdio: 'pipe', + execArgv: ['--dns-result-order=ipv4first'] + }); + + let output = ''; + const cleanup = () => { + child.stderr!.removeListener('data', listener); + child.stdout!.removeListener('data', listener); + child.once('exit', () => { done(); }); + child.kill(); + }; + + const listener = (data: Buffer) => { + output += data; + expect(output.trim()).to.contain('ipv4first', 'default verbatim should be ipv4first'); + cleanup(); + }; + + child.stderr!.on('data', listener); + child.stdout!.on('data', listener); + }); + ifit(process.platform !== 'win32')('supports redirecting stdout to parent process', async () => { const result = 'Output from utility process'; const appProcess = childProcess.spawn(process.execPath, [path.join(fixturesPath, 'inherit-stdout'), `--payload=${result}`]); diff --git a/spec/fixtures/api/utility-process/dns-result-order.js b/spec/fixtures/api/utility-process/dns-result-order.js new file mode 100644 index 0000000000..74d1219003 --- /dev/null +++ b/spec/fixtures/api/utility-process/dns-result-order.js @@ -0,0 +1,3 @@ +const dns = require('node:dns'); +console.log(dns.getDefaultResultOrder()); +process.exit(0);
feat
2e1f803f374a1d262be21b3b4e355698e1753daa
Mikołaj Sawicki
2023-03-28 16:53:20
docs: updated package.json content and electron version in build first app guide (#37554) * Docs: updated package.json content and electron version in build first app guide * docs: removed caret from electron version
diff --git a/docs/tutorial/tutorial-2-first-app.md b/docs/tutorial/tutorial-2-first-app.md index ff2dd5e03b..85d483bee8 100644 --- a/docs/tutorial/tutorial-2-first-app.md +++ b/docs/tutorial/tutorial-2-first-app.md @@ -81,10 +81,13 @@ the exact dependency versions to install. "version": "1.0.0", "description": "Hello World!", "main": "main.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, "author": "Jane Doe", "license": "MIT", "devDependencies": { - "electron": "19.0.0" + "electron": "23.1.3" } } ``` @@ -137,13 +140,14 @@ script in the current directory and run it in dev mode. "version": "1.0.0", "description": "Hello World!", "main": "main.js", - "author": "Jane Doe", - "license": "MIT", "scripts": { - "start": "electron ." + "start": "electron .", + "test": "echo \"Error: no test specified\" && exit 1" }, + "author": "Jane Doe", + "license": "MIT", "devDependencies": { - "electron": "^19.0.0" + "electron": "23.1.3" } } ```
docs
0a064cece99b266262a6fd69ca62933c9e56313a
Robo
2023-09-07 17:14:01
fix: devtools allow restoring saved dock state on Windows (#39734) * fix: devtools allow restoring saved dock state on Windows * chore: address feedback
diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 5a84cfe718..bcd8e40373 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -2667,14 +2667,6 @@ void WebContents::OpenDevTools(gin::Arguments* args) { state = "detach"; } -#if BUILDFLAG(IS_WIN) - auto* win = static_cast<NativeWindowViews*>(owner_window()); - // Force a detached state when WCO is enabled to match Chrome - // behavior and prevent occlusion of DevTools. - if (win && win->IsWindowControlsOverlayEnabled()) - state = "detach"; -#endif - bool activate = true; std::string title; if (args && args->Length() == 1) { diff --git a/shell/browser/browser_mac.mm b/shell/browser/browser_mac.mm index 88a6b4dd06..86f74bf623 100644 --- a/shell/browser/browser_mac.mm +++ b/shell/browser/browser_mac.mm @@ -40,13 +40,6 @@ namespace electron { namespace { -bool IsAppRTL() { - const std::string& locale = g_browser_process->GetApplicationLocale(); - base::i18n::TextDirection text_direction = - base::i18n::GetTextDirectionForLocaleInStartUp(locale.c_str()); - return text_direction == base::i18n::RIGHT_TO_LEFT; -} - NSString* GetAppPathForProtocol(const GURL& url) { NSURL* ns_url = [NSURL URLWithString:base::SysUTF8ToNSString(url.possibly_invalid_spec())]; diff --git a/shell/browser/ui/inspectable_web_contents.cc b/shell/browser/ui/inspectable_web_contents.cc index c718ab3249..6d1129d3af 100644 --- a/shell/browser/ui/inspectable_web_contents.cc +++ b/shell/browser/ui/inspectable_web_contents.cc @@ -44,11 +44,13 @@ #include "services/network/public/cpp/simple_url_loader_stream_consumer.h" #include "services/network/public/cpp/wrapper_shared_url_loader_factory.h" #include "shell/browser/api/electron_api_web_contents.h" +#include "shell/browser/native_window_views.h" #include "shell/browser/net/asar/asar_url_loader_factory.h" #include "shell/browser/protocol_registry.h" #include "shell/browser/ui/inspectable_web_contents_delegate.h" #include "shell/browser/ui/inspectable_web_contents_view.h" #include "shell/browser/ui/inspectable_web_contents_view_delegate.h" +#include "shell/common/application_info.h" #include "shell/common/platform_util.h" #include "third_party/blink/public/common/logging/logging_utils.h" #include "third_party/blink/public/common/page/page_zoom.h" @@ -585,6 +587,23 @@ void InspectableWebContents::LoadCompleted() { prefs.FindString("currentDockState"); base::RemoveChars(*current_dock_state, "\"", &dock_state_); } +#if BUILDFLAG(IS_WIN) + auto* api_web_contents = api::WebContents::From(GetWebContents()); + if (api_web_contents) { + auto* win = + static_cast<NativeWindowViews*>(api_web_contents->owner_window()); + // When WCO is enabled, undock the devtools if the current dock + // position overlaps with the position of window controls to avoid + // broken layout. + if (win && win->IsWindowControlsOverlayEnabled()) { + if (IsAppRTL() && dock_state_ == "left") { + dock_state_ = "undocked"; + } else if (dock_state_ == "right") { + dock_state_ = "undocked"; + } + } + } +#endif std::u16string javascript = base::UTF8ToUTF16( "UI.DockController.instance().setDockSide(\"" + dock_state_ + "\");"); GetDevToolsWebContents()->GetPrimaryMainFrame()->ExecuteJavaScript( diff --git a/shell/common/application_info.cc b/shell/common/application_info.cc index 1af2aa3776..c1a1f0f763 100644 --- a/shell/common/application_info.cc +++ b/shell/common/application_info.cc @@ -4,8 +4,10 @@ #include "shell/common/application_info.h" +#include "base/i18n/rtl.h" #include "base/no_destructor.h" #include "base/strings/stringprintf.h" +#include "chrome/browser/browser_process.h" #include "chrome/common/chrome_version.h" #include "content/public/common/user_agent.h" #include "electron/electron_version.h" @@ -47,4 +49,11 @@ std::string GetApplicationUserAgent() { return content::BuildUserAgentFromProduct(user_agent); } +bool IsAppRTL() { + const std::string& locale = g_browser_process->GetApplicationLocale(); + base::i18n::TextDirection text_direction = + base::i18n::GetTextDirectionForLocaleInStartUp(locale.c_str()); + return text_direction == base::i18n::RIGHT_TO_LEFT; +} + } // namespace electron diff --git a/shell/common/application_info.h b/shell/common/application_info.h index f541e88c17..622c98a056 100644 --- a/shell/common/application_info.h +++ b/shell/common/application_info.h @@ -25,6 +25,8 @@ std::string GetApplicationVersion(); // Returns the user agent of Electron. std::string GetApplicationUserAgent(); +bool IsAppRTL(); + #if BUILDFLAG(IS_WIN) PCWSTR GetRawAppUserModelID(); bool GetAppUserModelID(ScopedHString* app_id);
fix
7e312c81cabeed74fbd4586685cc151e3841a9e6
Shelley Vohr
2023-10-10 17:13:07
test: make capturePage color matching timeouts consistent (#40158)
diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index b9519f8d6c..2fb6cb0008 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -6357,7 +6357,7 @@ describe('BrowserWindow module', () => { foregroundWindow.loadFile(path.join(__dirname, 'fixtures', 'pages', 'css-transparent.html')); await once(ipcMain, 'set-transparent'); - await setTimeout(); + await setTimeout(1000); const screenCapture = await captureScreen(); const centerColor = getPixelColor(screenCapture, { x: display.size.width / 2, @@ -6380,7 +6380,7 @@ describe('BrowserWindow module', () => { await once(window, 'show'); await window.webContents.loadURL('data:text/html,<head><meta name="color-scheme" content="dark"></head>'); - await setTimeout(500); + await setTimeout(1000); const screenCapture = await captureScreen(); const centerColor = getPixelColor(screenCapture, { x: display.size.width / 2, @@ -6410,6 +6410,7 @@ describe('BrowserWindow module', () => { w.loadURL('about:blank'); await once(w, 'ready-to-show'); + await setTimeout(1000); const screenCapture = await captureScreen(); const centerColor = getPixelColor(screenCapture, { x: display.size.width / 2,
test
7921fec7612c0565c4cc4076ae9e83568c39269a
Shelley Vohr
2022-10-20 11:30:40
refactor: enable OOPIF printing to PDF (#36051)
diff --git a/chromium_src/BUILD.gn b/chromium_src/BUILD.gn index ee856f777d..dd3b5f7ed8 100644 --- a/chromium_src/BUILD.gn +++ b/chromium_src/BUILD.gn @@ -232,6 +232,8 @@ static_library("chrome") { "//chrome/browser/printing/printing_service.h", "//components/printing/browser/print_to_pdf/pdf_print_job.cc", "//components/printing/browser/print_to_pdf/pdf_print_job.h", + "//components/printing/browser/print_to_pdf/pdf_print_result.cc", + "//components/printing/browser/print_to_pdf/pdf_print_result.h", "//components/printing/browser/print_to_pdf/pdf_print_utils.cc", "//components/printing/browser/print_to_pdf/pdf_print_utils.h", ] diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index f9dd705037..675372b7f3 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -172,6 +172,7 @@ #if BUILDFLAG(ENABLE_PRINTING) #include "chrome/browser/printing/print_view_manager_base.h" #include "components/printing/browser/print_manager_utils.h" +#include "components/printing/browser/print_to_pdf/pdf_print_result.h" #include "components/printing/browser/print_to_pdf/pdf_print_utils.h" #include "printing/backend/print_backend.h" // nogncheck #include "printing/mojom/print.mojom.h" // nogncheck @@ -2902,12 +2903,12 @@ v8::Local<v8::Promise> WebContents::PrintToPDF(const base::Value& settings) { void WebContents::OnPDFCreated( gin_helper::Promise<v8::Local<v8::Value>> promise, - PrintViewManagerElectron::PrintResult print_result, + print_to_pdf::PdfPrintResult print_result, scoped_refptr<base::RefCountedMemory> data) { - if (print_result != PrintViewManagerElectron::PrintResult::kPrintSuccess) { + if (print_result != print_to_pdf::PdfPrintResult::kPrintSuccess) { promise.RejectWithErrorMessage( "Failed to generate PDF: " + - PrintViewManagerElectron::PrintResultToString(print_result)); + print_to_pdf::PdfPrintResultToString(print_result)); return; } diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index 79f1182672..e838d0a325 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -46,6 +46,7 @@ #include "ui/gfx/image/image.h" #if BUILDFLAG(ENABLE_PRINTING) +#include "components/printing/browser/print_to_pdf/pdf_print_result.h" #include "shell/browser/printing/print_view_manager_electron.h" #endif @@ -227,7 +228,7 @@ class WebContents : public ExclusiveAccessContext, // Print current page as PDF. v8::Local<v8::Promise> PrintToPDF(const base::Value& settings); void OnPDFCreated(gin_helper::Promise<v8::Local<v8::Value>> promise, - PrintViewManagerElectron::PrintResult print_result, + print_to_pdf::PdfPrintResult print_result, scoped_refptr<base::RefCountedMemory> data); #endif diff --git a/shell/browser/printing/print_view_manager_electron.cc b/shell/browser/printing/print_view_manager_electron.cc index 3b0fb78348..fbb646cd9f 100644 --- a/shell/browser/printing/print_view_manager_electron.cc +++ b/shell/browser/printing/print_view_manager_electron.cc @@ -60,124 +60,36 @@ void PrintViewManagerElectron::BindPrintManagerHost( print_manager->BindReceiver(std::move(receiver), rfh); } -// static -std::string PrintViewManagerElectron::PrintResultToString(PrintResult result) { - switch (result) { - case kPrintSuccess: - return std::string(); // no error message - case kPrintFailure: - return "Printing failed"; - case kInvalidPrinterSettings: - return "Show invalid printer settings error"; - case kInvalidMemoryHandle: - return "Invalid memory handle"; - case kMetafileMapError: - return "Map to shared memory error"; - case kMetafileInvalidHeader: - return "Invalid metafile header"; - case kMetafileGetDataError: - return "Get data from metafile error"; - case kSimultaneousPrintActive: - return "The previous printing job hasn't finished"; - case kPageRangeSyntaxError: - return "Page range syntax error"; - case kPageRangeInvalidRange: - return "Page range is invalid (start > end)"; - case kPageCountExceeded: - return "Page range exceeds page count"; - case kPrintingInProgress: - return "Page is already being printed"; - default: - NOTREACHED(); - return "Unknown PrintResult"; - } +void PrintViewManagerElectron::DidPrintToPdf( + int cookie, + PrintToPdfCallback callback, + print_to_pdf::PdfPrintResult result, + scoped_refptr<base::RefCountedMemory> memory) { + base::Erase(pdf_jobs_, cookie); + std::move(callback).Run(result, memory); } void PrintViewManagerElectron::PrintToPdf( content::RenderFrameHost* rfh, const std::string& page_ranges, printing::mojom::PrintPagesParamsPtr print_pages_params, - PrintToPDFCallback callback) { - DCHECK(callback); - - if (callback_) { - std::move(callback).Run(kSimultaneousPrintActive, - base::MakeRefCounted<base::RefCountedString>()); - return; - } - - if (!rfh->IsRenderFrameLive()) { - std::move(callback).Run(kPrintFailure, - base::MakeRefCounted<base::RefCountedString>()); - return; - } - - absl::variant<printing::PageRanges, print_to_pdf::PdfPrintResult> - parsed_ranges = print_to_pdf::TextPageRangesToPageRanges(page_ranges); - if (absl::holds_alternative<print_to_pdf::PdfPrintResult>(parsed_ranges)) { - DCHECK_NE(absl::get<print_to_pdf::PdfPrintResult>(parsed_ranges), - print_to_pdf::PdfPrintResult::kPrintSuccess); - std::move(callback).Run( - static_cast<PrintResult>( - absl::get<print_to_pdf::PdfPrintResult>(parsed_ranges)), - base::MakeRefCounted<base::RefCountedString>()); - return; - } - - printing_rfh_ = rfh; - print_pages_params->pages = absl::get<printing::PageRanges>(parsed_ranges); - headless_jobs_.emplace_back(print_pages_params->params->document_cookie); - callback_ = std::move(callback); - - // There is no need for a weak pointer here since the mojo proxy is held - // in the base class. If we're gone, mojo will discard the callback. - GetPrintRenderFrame(rfh)->PrintWithParams( + PrintToPdfCallback callback) { + // Store cookie in order to track job uniqueness and differentiate + // between regular and headless print jobs. + int cookie = print_pages_params->params->document_cookie; + pdf_jobs_.emplace_back(cookie); + + print_to_pdf::PdfPrintJob::StartJob( + web_contents(), rfh, GetPrintRenderFrame(rfh), page_ranges, std::move(print_pages_params), - base::BindOnce(&PrintViewManagerElectron::OnDidPrintWithParams, - base::Unretained(this))); -} - -void PrintViewManagerElectron::OnDidPrintWithParams( - printing::mojom::PrintWithParamsResultPtr result) { - if (result->is_failure_reason()) { - switch (result->get_failure_reason()) { - case printing::mojom::PrintFailureReason::kGeneralFailure: - FailJob(kPrintFailure); - return; - case printing::mojom::PrintFailureReason::kInvalidPageRange: - FailJob(kPageCountExceeded); - return; - case printing::mojom::PrintFailureReason::kPrintingInProgress: - FailJob(kPrintingInProgress); - return; - } - } - - printing::mojom::DidPrintDocumentParamsPtr& params = result->get_params(); - - auto& content = *params->content; - if (!content.metafile_data_region.IsValid()) { - FailJob(kInvalidMemoryHandle); - return; - } - - base::ReadOnlySharedMemoryMapping map = content.metafile_data_region.Map(); - if (!map.IsValid()) { - FailJob(kMetafileMapError); - return; - } - - std::string data = - std::string(static_cast<const char*>(map.memory()), map.size()); - std::move(callback_).Run(kPrintSuccess, - base::RefCountedString::TakeString(&data)); - base::Erase(headless_jobs_, params->document_cookie); - Reset(); + base::BindOnce(&PrintViewManagerElectron::DidPrintToPdf, + weak_factory_.GetWeakPtr(), cookie, std::move(callback))); } void PrintViewManagerElectron::GetDefaultPrintSettings( GetDefaultPrintSettingsCallback callback) { - if (printing_rfh_) { + // This isn't ideal, but we're not able to access the document cookie here. + if (pdf_jobs_.size() > 0) { LOG(ERROR) << "Scripted print is not supported"; std::move(callback).Run(printing::mojom::PrintParams::New()); } else { @@ -188,9 +100,8 @@ void PrintViewManagerElectron::GetDefaultPrintSettings( void PrintViewManagerElectron::ScriptedPrint( printing::mojom::ScriptedPrintParamsPtr params, ScriptedPrintCallback callback) { - auto entry = - std::find(headless_jobs_.begin(), headless_jobs_.end(), params->cookie); - if (entry == headless_jobs_.end()) { + auto entry = std::find(pdf_jobs_.begin(), pdf_jobs_.end(), params->cookie); + if (entry == pdf_jobs_.end()) { PrintViewManagerBase::ScriptedPrint(std::move(params), std::move(callback)); return; } @@ -201,22 +112,13 @@ void PrintViewManagerElectron::ScriptedPrint( std::move(callback).Run(std::move(default_param), /*cancelled*/ false); } -void PrintViewManagerElectron::ShowInvalidPrinterSettingsError() { - if (headless_jobs_.size() == 0) { - PrintViewManagerBase::ShowInvalidPrinterSettingsError(); - return; - } - - FailJob(kInvalidPrinterSettings); -} - #if BUILDFLAG(ENABLE_PRINT_PREVIEW) void PrintViewManagerElectron::UpdatePrintSettings( int32_t cookie, base::Value::Dict job_settings, UpdatePrintSettingsCallback callback) { - auto entry = std::find(headless_jobs_.begin(), headless_jobs_.end(), cookie); - if (entry == headless_jobs_.end()) { + auto entry = std::find(pdf_jobs_.begin(), pdf_jobs_.end(), cookie); + if (entry == pdf_jobs_.end()) { PrintViewManagerBase::UpdatePrintSettings(cookie, std::move(job_settings), std::move(callback)); return; @@ -247,40 +149,14 @@ void PrintViewManagerElectron::CheckForCancel(int32_t preview_ui_id, } #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) -void PrintViewManagerElectron::RenderFrameDeleted( - content::RenderFrameHost* render_frame_host) { - PrintViewManagerBase::RenderFrameDeleted(render_frame_host); - - if (printing_rfh_ != render_frame_host) - return; - - FailJob(kPrintFailure); -} - void PrintViewManagerElectron::DidGetPrintedPagesCount(int32_t cookie, uint32_t number_pages) { - auto entry = std::find(headless_jobs_.begin(), headless_jobs_.end(), cookie); - if (entry == headless_jobs_.end()) { + auto entry = std::find(pdf_jobs_.begin(), pdf_jobs_.end(), cookie); + if (entry == pdf_jobs_.end()) { PrintViewManagerBase::DidGetPrintedPagesCount(cookie, number_pages); } } -void PrintViewManagerElectron::Reset() { - printing_rfh_ = nullptr; - callback_.Reset(); - data_.clear(); -} - -void PrintViewManagerElectron::FailJob(PrintResult result) { - DCHECK_NE(result, kPrintSuccess); - if (callback_) { - std::move(callback_).Run(result, - base::MakeRefCounted<base::RefCountedString>()); - } - - Reset(); -} - WEB_CONTENTS_USER_DATA_KEY_IMPL(PrintViewManagerElectron); } // namespace electron diff --git a/shell/browser/printing/print_view_manager_electron.h b/shell/browser/printing/print_view_manager_electron.h index a0b7eb28e6..115c07fa39 100644 --- a/shell/browser/printing/print_view_manager_electron.h +++ b/shell/browser/printing/print_view_manager_electron.h @@ -13,6 +13,7 @@ #include "base/memory/ref_counted_memory.h" #include "build/build_config.h" #include "chrome/browser/printing/print_view_manager_base.h" +#include "components/printing/browser/print_to_pdf/pdf_print_job.h" #include "components/printing/common/print.mojom.h" #include "content/public/browser/render_frame_host.h" #include "content/public/browser/web_contents_observer.h" @@ -21,29 +22,12 @@ namespace electron { +using PrintToPdfCallback = print_to_pdf::PdfPrintJob::PrintToPdfCallback; + class PrintViewManagerElectron : public printing::PrintViewManagerBase, public content::WebContentsUserData<PrintViewManagerElectron> { public: - enum PrintResult { - kPrintSuccess, - kPrintFailure, - kInvalidPrinterSettings, - kInvalidMemoryHandle, - kMetafileMapError, - kMetafileInvalidHeader, - kMetafileGetDataError, - kSimultaneousPrintActive, - kPageRangeSyntaxError, - kPageRangeInvalidRange, - kPageCountExceeded, - kPrintingInProgress - }; - - using PrintToPDFCallback = - base::OnceCallback<void(PrintResult, - scoped_refptr<base::RefCountedMemory>)>; - ~PrintViewManagerElectron() override; PrintViewManagerElectron(const PrintViewManagerElectron&) = delete; @@ -54,30 +38,26 @@ class PrintViewManagerElectron receiver, content::RenderFrameHost* rfh); - static std::string PrintResultToString(PrintResult result); - + void DidPrintToPdf(int cookie, + PrintToPdfCallback callback, + print_to_pdf::PdfPrintResult result, + scoped_refptr<base::RefCountedMemory> memory); void PrintToPdf(content::RenderFrameHost* rfh, const std::string& page_ranges, printing::mojom::PrintPagesParamsPtr print_page_params, - PrintToPDFCallback callback); + PrintToPdfCallback callback); private: friend class content::WebContentsUserData<PrintViewManagerElectron>; explicit PrintViewManagerElectron(content::WebContents* web_contents); - void OnDidPrintWithParams(printing::mojom::PrintWithParamsResultPtr result); - - // WebContentsObserver overrides (via PrintManager): - void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; - // printing::mojom::PrintManagerHost: void DidGetPrintedPagesCount(int32_t cookie, uint32_t number_pages) override; void GetDefaultPrintSettings( GetDefaultPrintSettingsCallback callback) override; void ScriptedPrint(printing::mojom::ScriptedPrintParamsPtr params, ScriptedPrintCallback callback) override; - void ShowInvalidPrinterSettingsError() override; #if BUILDFLAG(ENABLE_PRINT_PREVIEW) void UpdatePrintSettings(int32_t cookie, base::Value::Dict job_settings, @@ -91,14 +71,9 @@ class PrintViewManagerElectron int32_t request_id, CheckForCancelCallback callback) override; #endif + std::vector<int32_t> pdf_jobs_; - void FailJob(PrintResult result); - void Reset(); - - raw_ptr<content::RenderFrameHost> printing_rfh_ = nullptr; - PrintToPDFCallback callback_; - std::string data_; - std::vector<int32_t> headless_jobs_; + base::WeakPtrFactory<PrintViewManagerElectron> weak_factory_{this}; WEB_CONTENTS_USER_DATA_KEY_DECL(); };
refactor
46a74d1086baead0f0963edf810bb4d301aee04a
Erick Zhao
2022-11-11 11:42:27
docs: update tutorials for Forge 6 (#36313) docs: update tutorial for Forge 6
diff --git a/docs/tutorial/code-signing.md b/docs/tutorial/code-signing.md index 06fae1eaf7..0bb18aaf56 100644 --- a/docs/tutorial/code-signing.md +++ b/docs/tutorial/code-signing.md @@ -52,15 +52,17 @@ ways to get your application signed and notarized. If you're using Electron's favorite build tool, getting your application signed and notarized requires a few additions to your configuration. [Forge](https://electronforge.io) is a collection of the official Electron tools, using [`electron-packager`], -[`electron-osx-sign`], and [`electron-notarize`] under the hood. +[`@electron/osx-sign`], and [`@electron/notarize`] under the hood. -Detailed instructions on how to configure your application can be found in the [Electron Forge Code Signing Tutorial](https://www.electronforge.io/guides/code-signing/code-signing-macos). +Detailed instructions on how to configure your application can be found in the +[Signing macOS Apps](https://www.electronforge.io/guides/code-signing/code-signing-macos) guide in +the Electron Forge docs. ### Using Electron Packager If you're not using an integrated build pipeline like Forge, you -are likely using [`electron-packager`], which includes [`electron-osx-sign`] and -[`electron-notarize`]. +are likely using [`electron-packager`], which includes [`@electron/osx-sign`] and +[`@electron/notarize`]. If you're using Packager's API, you can pass [in configuration that both signs and notarizes your application](https://electron.github.io/electron-packager/main/interfaces/electronpackager.options.html). @@ -70,13 +72,7 @@ const packager = require('electron-packager') packager({ dir: '/path/to/my/app', - osxSign: { - identity: 'Developer ID Application: Felix Rieseberg (LT94ZKYDCJ)', - 'hardened-runtime': true, - entitlements: 'entitlements.plist', - 'entitlements-inherit': 'entitlements.plist', - 'signature-flags': 'library' - }, + osxSign: {}, osxNotarize: { appleId: '[email protected]', appleIdPassword: 'my-apple-id-password' @@ -84,26 +80,6 @@ packager({ }) ``` -The `entitlements.plist` file referenced here needs the following macOS-specific entitlements -to assure the Apple security mechanisms that your app is doing these things -without meaning any harm: - -```xml title="entitlements.plist" -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> -<plist version="1.0"> - <dict> - <key>com.apple.security.cs.allow-jit</key> - <true/> - <key>com.apple.security.cs.debugger</key> - <true/> - </dict> -</plist> -``` - -Up until Electron 12, the `com.apple.security.cs.allow-unsigned-executable-memory` entitlement was required -as well. However, it should not be used anymore if it can be avoided. - ### Signing Mac App Store applications See the [Mac App Store Guide]. @@ -213,15 +189,14 @@ can find [its documentation here](https://www.electron.build/code-signing). See the [Windows Store Guide]. [apple developer program]: https://developer.apple.com/programs/ -[`electron-builder`]: https://github.com/electron-userland/electron-builder -[`electron-forge`]: https://github.com/electron-userland/electron-forge -[`electron-osx-sign`]: https://github.com/electron-userland/electron-osx-sign +[`electron-forge`]: https://github.com/electron/forge +[`@electron/osx-sign`]: https://github.com/electron/osx-sign [`electron-packager`]: https://github.com/electron/electron-packager -[`electron-notarize`]: https://github.com/electron/electron-notarize +[`@electron/notarize`]: https://github.com/electron/notarize [`electron-winstaller`]: https://github.com/electron/windows-installer -[`electron-wix-msi`]: https://github.com/felixrieseberg/electron-wix-msi +[`electron-wix-msi`]: https://github.com/electron-userland/electron-wix-msi [xcode]: https://developer.apple.com/xcode -[signing certificates]: https://github.com/electron/electron-osx-sign/wiki/1.-Getting-Started#certificates +[signing certificates]: https://developer.apple.com/support/certificates/ [mac app store guide]: ./mac-app-store-submission-guide.md [windows store guide]: ./windows-store-guide.md [maker-squirrel]: https://www.electronforge.io/config/makers/squirrel.windows diff --git a/docs/tutorial/mac-app-store-submission-guide.md b/docs/tutorial/mac-app-store-submission-guide.md index 79b087dd98..004f204c9e 100644 --- a/docs/tutorial/mac-app-store-submission-guide.md +++ b/docs/tutorial/mac-app-store-submission-guide.md @@ -11,7 +11,7 @@ This guide provides information on: To sign Electron apps, the following tools must be installed first: * Xcode 11 or above. -* The [electron-osx-sign][electron-osx-sign] npm module. +* The [@electron/osx-sign] npm module. You also have to register an Apple Developer account and join the [Apple Developer Program][developer-program]. @@ -103,7 +103,7 @@ Apps submitted to the Mac App Store must run under Apple's the App Sandbox. The standard darwin build of Electron will fail to launch when run under App Sandbox. -When signing the app with `electron-osx-sign`, it will automatically add the +When signing the app with `@electron/osx-sign`, it will automatically add the necessary entitlements to your app's entitlements, but if you are using custom entitlements, you must ensure App Sandbox capacity is added: @@ -120,7 +120,7 @@ entitlements, you must ensure App Sandbox capacity is added: #### Extra steps without `electron-osx-sign` -If you are signing your app without using `electron-osx-sign`, you must ensure +If you are signing your app without using `@electron/osx-sign`, you must ensure the app bundle's entitlements have at least following keys: ```xml @@ -170,22 +170,22 @@ your Apple Developer account's Team ID as its value: </plist> ``` -When using `electron-osx-sign` the `ElectronTeamID` key will be added +When using `@electron/osx-sign` the `ElectronTeamID` key will be added automatically by extracting the Team ID from the certificate's name. You may -need to manually add this key if `electron-osx-sign` could not find the correct +need to manually add this key if `@electron/osx-sign` could not find the correct Team ID. ### Sign apps for development To sign an app that can run on your development machine, you must sign it with the "Apple Development" certificate and pass the provisioning profile to -`electron-osx-sign`. +`@electron/osx-sign`. ```bash electron-osx-sign YourApp.app --identity='Apple Development' --provisioning-profile=/path/to/yourapp.provisionprofile ``` -If you are signing without `electron-osx-sign`, you must place the provisioning +If you are signing without `@electron/osx-sign`, you must place the provisioning profile to `YourApp.app/Contents/embedded.provisionprofile`. The signed app can only run on the machines that registered by the provisioning @@ -213,7 +213,7 @@ use App Sandbox. electron-osx-sign YourApp.app --identity='Developer ID Application' --no-gatekeeper-assess ``` -By passing `--no-gatekeeper-assess`, the `electron-osx-sign` will skip the macOS +By passing `--no-gatekeeper-assess`, `@electron/osx-sign` will skip the macOS GateKeeper check as your app usually has not been notarized yet by this step. <!-- TODO(zcbenz): Add a chapter about App Notarization --> @@ -341,7 +341,7 @@ Electron uses following cryptographic algorithms: * RIPEMD - [ISO/IEC 10118-3](https://webstore.ansi.org/RecordDetail.aspx?sku=ISO%2FIEC%2010118-3:2004) [developer-program]: https://developer.apple.com/support/compare-memberships/ -[electron-osx-sign]: https://github.com/electron/electron-osx-sign +[@electron/osx-sign]: https://github.com/electron/electron-osx-sign [app-sandboxing]: https://developer.apple.com/app-sandboxing/ [app-notarization]: https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution [submitting-your-app]: https://developer.apple.com/library/mac/documentation/IDEs/Conceptual/AppDistributionGuide/SubmittingYourApp/SubmittingYourApp.html diff --git a/docs/tutorial/tutorial-1-prerequisites.md b/docs/tutorial/tutorial-1-prerequisites.md index 164811fc4e..c3bfd8f864 100644 --- a/docs/tutorial/tutorial-1-prerequisites.md +++ b/docs/tutorial/tutorial-1-prerequisites.md @@ -26,6 +26,15 @@ work on Windows, macOS, and Linux with a single JavaScript codebase. This tutorial will guide you through the process of developing a desktop application with Electron and distributing it to end users. +## Goals + +This tutorial starts by guiding you through the process of piecing together +a minimal Electron application from scratch, then teaches you how to +package and distribute it to users using Electron Forge. + +If you prefer to get a project started with a single-command boilerplate, we recommend you start +with Electron Forge's [`create-electron-app`](https://www.electronforge.io/) command. + ## Assumptions Electron is a native wrapper layer for web apps and is run in a Node.js environment. diff --git a/docs/tutorial/tutorial-5-packaging.md b/docs/tutorial/tutorial-5-packaging.md index 032511145e..d803035675 100644 --- a/docs/tutorial/tutorial-5-packaging.md +++ b/docs/tutorial/tutorial-5-packaging.md @@ -70,10 +70,9 @@ the [Electron Forge CLI documentation]. ::: You should also notice that your package.json now has a few more packages installed -under your `devDependencies`, and contains an added `config.forge` field with an array -of makers configured. **Makers** are Forge plugins that create distributables from -your source code. You should see multiple makers in the pre-populated configuration, -one for each target platform. +under `devDependencies`, and a new `forge.config.js` file that exports a configuration +object. You should see multiple makers (packages that generate distributable app bundles) in the +pre-populated configuration, one for each target platform. ### Creating a distributable @@ -111,13 +110,14 @@ Electron Forge can be configured to create distributables in different OS-specif ::: -:::tip Creating and Adding Application Icons +:::tip Creating and adding application icons -Setting custom application icons requires a few additions to your config. Check out [Forge's icon tutorial] for more information. +Setting custom application icons requires a few additions to your config. +Check out [Forge's icon tutorial] for more information. ::: -:::note Packaging without Electron Forge +:::info Packaging without Electron Forge If you want to manually package your code, or if you're just interested understanding the mechanics behind packaging an Electron app, check out the full [Application Packaging] @@ -136,64 +136,51 @@ Code signing is a security technology that you use to certify that a desktop app created by a known source. Windows and macOS have their own OS-specific code signing systems that will make it difficult for users to download or launch unsigned applications. -If you already have code signing certificates for Windows and macOS, you can set your -credentials in your Forge configuration. Otherwise, please refer to the full -[Code Signing] documentation to learn how to purchase a certificate and for more information -on the desktop app code signing process. - On macOS, code signing is done at the app packaging level. On Windows, distributable installers -are signed instead. +are signed instead. If you already have code signing certificates for Windows and macOS, you can set +your credentials in your Forge configuration. + +:::info + +For more information on code signing, check out the +[Signing macOS Apps](https://www.electronforge.io/guides/code-signing) guide in the Forge docs. + +::: <Tabs> <TabItem value="macos" label="macOS" default> -```json title='package.json' {6-18} -{ - //... - "config": { - "forge": { - //... - "packagerConfig": { - "osxSign": { - "identity": "Developer ID Application: Felix Rieseberg (LT94ZKYDCJ)", - "hardened-runtime": true, - "entitlements": "entitlements.plist", - "entitlements-inherit": "entitlements.plist", - "signature-flags": "library" - }, - "osxNotarize": { - "appleId": "[email protected]", - "appleIdPassword": "this-is-a-secret" - } - } - //... +```js title='forge.config.js' +module.exports = { + packagerConfig: { + osxSign: {}, + //... + osxNotarize: { + tool: 'notarytool', + appleId: process.env.APPLE_ID, + appleIdPassword: process.env.APPLE_PASSWORD, + teamId: process.env.APPLE_TEAM_ID, } + //... } - //... } ``` </TabItem> <TabItem value="windows" label="Windows"> -```json title='package.json' {6-14} -{ +```js title='forge.config.js' +module.exports = { //... - "config": { - "forge": { - //... - "makers": [ - { - "name": "@electron-forge/maker-squirrel", - "config": { - "certificateFile": "./cert.pfx", - "certificatePassword": "this-is-a-secret" - } - } - ] - //... - } - } + makers: [ + { + name: '@electron-forge/maker-squirrel', + config: { + certificateFile: './cert.pfx', + certificatePassword: process.env.CERTIFICATE_PASSWORD, + }, + }, + ], //... } ``` @@ -214,13 +201,12 @@ information. [`@electron/osx-sign`]: https://github.com/electron/osx-sign [application packaging]: ./application-distribution.md -[code signing]: ./code-signing.md [`electron-packager`]: https://github.com/electron/electron-packager [`electron-winstaller`]: https://github.com/electron/windows-installer [electron forge]: https://www.electronforge.io [electron forge cli documentation]: https://www.electronforge.io/cli#commands [makers]: https://www.electronforge.io/config/makers -[Forge's icon tutorial]: https://www.electronforge.io/guides/create-and-add-icons +[forge's icon tutorial]: https://www.electronforge.io/guides/create-and-add-icons <!-- Tutorial links --> diff --git a/docs/tutorial/tutorial-6-publishing-updating.md b/docs/tutorial/tutorial-6-publishing-updating.md index dc0fdc31f2..4adfb434bd 100644 --- a/docs/tutorial/tutorial-6-publishing-updating.md +++ b/docs/tutorial/tutorial-6-publishing-updating.md @@ -78,27 +78,21 @@ Once you have it installed, you need to set it up in your Forge configuration. A full list of options is documented in the Forge's [`PublisherGitHubConfig`] API docs. -```json title='package.json' {6-16} -{ - //... - "config": { - "forge": { - "publishers": [ - { - "name": "@electron-forge/publisher-github", - "config": { - "repository": { - "owner": "github-user-name", - "name": "github-repo-name" - }, - "prerelease": false, - "draft": true - } - } - ] - } - } - //... +```js title='forge.config.js' +module.exports = { + publishers: [ + { + name: '@electron-forge/publisher-github', + config: { + repository: { + owner: 'github-user-name', + name: 'github-repo-name', + }, + prerelease: false, + draft: true, + }, + }, + ], } ```
docs
3a91d1f1e18177ceadc02580722a1349c5b18357
Charles Kerr
2023-08-21 03:29:25
fix: dangling raw_ptr in ElectronBrowserMainParts dtor (#39539) * fix: dangling raw_ptr in ElectronBrowserMainParts dtor * fixup! fix: dangling raw_ptr in ElectronBrowserMainParts dtor Browser::WhenReady() holds a reference to JsEnv isolate so must come after
diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 6995be4069..61c0b3df01 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -204,11 +204,11 @@ ElectronBrowserMainParts* ElectronBrowserMainParts::self_ = nullptr; ElectronBrowserMainParts::ElectronBrowserMainParts() : fake_browser_process_(std::make_unique<BrowserProcessImpl>()), - browser_(std::make_unique<Browser>()), - node_bindings_( - NodeBindings::Create(NodeBindings::BrowserEnvironment::kBrowser)), - electron_bindings_( - std::make_unique<ElectronBindings>(node_bindings_->uv_loop())) { + node_bindings_{ + NodeBindings::Create(NodeBindings::BrowserEnvironment::kBrowser)}, + electron_bindings_{ + std::make_unique<ElectronBindings>(node_bindings_->uv_loop())}, + browser_{std::make_unique<Browser>()} { DCHECK(!self_) << "Cannot have two ElectronBrowserMainParts"; self_ = this; } diff --git a/shell/browser/electron_browser_main_parts.h b/shell/browser/electron_browser_main_parts.h index 917da86260..69f4c32cd9 100644 --- a/shell/browser/electron_browser_main_parts.h +++ b/shell/browser/electron_browser_main_parts.h @@ -157,11 +157,20 @@ class ElectronBrowserMainParts : public content::BrowserMainParts { // Before then, we just exit() without any intermediate steps. absl::optional<int> exit_code_; - std::unique_ptr<JavascriptEnvironment> js_env_; - std::unique_ptr<Browser> browser_; std::unique_ptr<NodeBindings> node_bindings_; + + // depends-on: node_bindings_ std::unique_ptr<ElectronBindings> electron_bindings_; + + // depends-on: node_bindings_ + std::unique_ptr<JavascriptEnvironment> js_env_; + + // depends-on: js_env_'s isolate std::unique_ptr<NodeEnvironment> node_env_; + + // depends-on: js_env_'s isolate + std::unique_ptr<Browser> browser_; + std::unique_ptr<IconManager> icon_manager_; std::unique_ptr<base::FieldTrialList> field_trial_list_;
fix
4d9c84d7c05853589408a1acca5155dd9250792f
David Sanders
2022-12-13 10:55:53
chore: update markdownlint (#36540)
diff --git a/.markdownlint.json b/.markdownlint.json index 495df656c2..a52c5d820b 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -23,5 +23,8 @@ "br_spaces": 0 }, "single-h1": false, - "no-inline-html": false + "no-inline-html": false, + "emphasis-style": false, + "strong-style": false, + "link-image-reference-definitions": false } diff --git a/package.json b/package.json index 17d97c0d30..f80c105480 100644 --- a/package.json +++ b/package.json @@ -54,8 +54,8 @@ "klaw": "^3.0.0", "lint": "^1.1.2", "lint-staged": "^10.2.11", - "markdownlint": "^0.21.1", - "markdownlint-cli": "^0.25.0", + "markdownlint": "^0.26.2", + "markdownlint-cli": "^0.32.2", "minimist": "^1.2.6", "null-loader": "^4.0.0", "pre-flight": "^1.1.0", diff --git a/yarn.lock b/yarn.lock index 6e84e641ae..a772fb18c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1300,6 +1300,13 @@ brace-expansion@^1.1.7: balanced-match "^1.0.0" concat-map "0.0.1" +brace-expansion@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae" + integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA== + dependencies: + balanced-match "^1.0.0" + braces@^3.0.1, braces@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" @@ -1647,10 +1654,10 @@ commander@^7.0.0: resolved "https://registry.yarnpkg.com/commander/-/commander-7.2.0.tgz#a36cb57d0b501ce108e4d20559a150a391d97ab7" integrity sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw== -commander@~6.2.0: - version "6.2.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.0.tgz#b990bfb8ac030aedc6d11bc04d1488ffef56db75" - integrity sha512-zP4jEKbe8SHzKJYQmq8Y9gYjtO/POJLgIdKgV7B9qNmABVFVc+ctqSX6iXh4mCpJfRBOabiZ2YKPg8ciDw6C+Q== +commander@~9.4.0: + version "9.4.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-9.4.1.tgz#d1dd8f2ce6faf93147295c0df13c7c21141cfbdd" + integrity sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw== compress-brotli@^1.3.8: version "1.3.8" @@ -1797,7 +1804,7 @@ deep-eql@^3.0.1: dependencies: type-detect "^4.0.0" -deep-extend@^0.6.0, deep-extend@~0.6.0: +deep-extend@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac" integrity sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA== @@ -2014,6 +2021,11 @@ entities@~2.0.0: resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.0.tgz#68d6084cab1b079767540d80e56a39b423e4abf4" integrity sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw== +entities@~3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/entities/-/entities-3.0.1.tgz#2b887ca62585e96db3903482d336c1006c3001d4" + integrity sha512-WiyBqoomrwMdFG1e0kqvASYfnlb0lp8M5o5Fw2OFq1hNZxxcNk8Ik0Xm7LxzBhuidnZB/UtBqVCgUz3kBOP51Q== + envinfo@^7.7.3: version "7.8.1" resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-7.8.1.tgz#06377e3e5f4d379fea7ac592d5ad8927e0c4d475" @@ -2789,10 +2801,10 @@ get-stdin@^7.0.0: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-7.0.0.tgz#8d5de98f15171a125c5e516643c7a6d0ea8a96f6" integrity sha512-zRKcywvrXlXsA0v0i9Io4KDRaAw7+a1ZpjRwl9Wox8PFlVCCHra7E9c4kqXCoCM9nR5tBkaTTZRBoCm60bFqTQ== -get-stdin@~8.0.0: - version "8.0.0" - resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-8.0.0.tgz#cbad6a73feb75f6eeb22ba9e01f89aa28aa97a53" - integrity sha512-sY22aA6xchAzprjyqmSEQv4UbAAzRN0L2dQB0NlN5acTTK9Don6nhoc3eAbUnpZiCANAMfd/+40kVdKfFygohg== +get-stdin@~9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-9.0.0.tgz#3983ff82e03d56f1b2ea0d3e60325f39d703a575" + integrity sha512-dVKBjfWisLAicarI2Sf+JuBE/DghV4UzNAVe9yhEJuzeREd3JhOTE9cUaJTeSa77fsbQUK3pcOpJfM59+VKZaA== get-stream@^4.1.0: version "4.1.0" @@ -2839,17 +2851,16 @@ glob@^7.0.0, glob@^7.0.5, glob@^7.1.3, glob@^7.1.6: once "^1.3.0" path-is-absolute "^1.0.0" -glob@~7.1.6: - version "7.1.6" - resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" - integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== +glob@~8.0.3: + version "8.0.3" + resolved "https://registry.yarnpkg.com/glob/-/glob-8.0.3.tgz#415c6eb2deed9e502c68fa44a272e6da6eeca42e" + integrity sha512-ull455NHSHI/Y1FqGaaYFaLGkNMMJbavMrEGFXG/PGrg6y7sutWHUHrz6gy6WEBH6akM1M414dWKCNs+IhKdiQ== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" inherits "2" - minimatch "^3.0.4" + minimatch "^5.0.1" once "^1.3.0" - path-is-absolute "^1.0.0" globals@^12.1.0: version "12.4.0" @@ -3033,11 +3044,16 @@ ignore@^4.0.6: resolved "https://registry.yarnpkg.com/ignore/-/ignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" integrity sha512-cyFDKrqc/YdcWFniJhzI42+AzS+gNwmUzOSFcRCQYwySuBBBy/KjuxWLZ/FHEH6Moq1NizMOBWyTcv8O4OZIMg== -ignore@^5.0.0, ignore@^5.1.1, ignore@^5.1.4, ignore@~5.1.8: +ignore@^5.0.0, ignore@^5.1.1, ignore@^5.1.4: version "5.1.8" resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.1.8.tgz#f150a8b50a34289b33e22f5889abd4d8016f0e57" integrity sha512-BMpfD7PpiETpBl/A6S498BaIJ6Y/ABT93ETbby2fP00v4EbvPBXWEoaR1UBPKs3iR53pJY7EtZk5KACI57i1Uw== +ignore@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.1.tgz#c2b1f76cb999ede1502f3a226a9310fdfe88d46c" + integrity sha512-d2qQLzTJ9WxQftPAuEQpSPmKqzxePjzVbpAVv62AQ64NTL+wR4JkrVqR/LqFsFEUsHDAiId52mJteHDFuDkElA== + import-fresh@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.1.0.tgz#6d33fa1dcef6df930fae003446f33415af905118" @@ -3097,11 +3113,16 @@ [email protected]: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= -ini@^1.3.5, ini@~1.3.0: +ini@^1.3.5: version "1.3.7" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.7.tgz#a09363e1911972ea16d7a8851005d84cf09a9a84" integrity sha512-iKpRpXP+CrP2jyrxvg1kMUpXDyRUFDWurxbnVT1vQPx+Wz9uCYsMIqYuSBLV+PAaZG/d7kRLKRFc9oDMsH+mFQ== +ini@~3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/ini/-/ini-3.0.1.tgz#c76ec81007875bc44d544ff7a11a55d12294102d" + integrity sha512-it4HyVAUTKBc6m8e1iXWvXSTdndF7HbdN713+kvLrymxTaU4AUBWrJ4vEooP+V7fexnVD3LKcBshjGGPefSMUQ== + inquirer@^7.0.0: version "7.3.0" resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-7.3.0.tgz#aa3e7cb0c18a410c3c16cdd2bc9dcbe83c4d333e" @@ -3354,21 +3375,13 @@ js-yaml@^3.13.1, js-yaml@^3.2.7: argparse "^1.0.7" esprima "^4.0.0" -js-yaml@^4.0.0: +js-yaml@^4.0.0, js-yaml@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602" integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA== dependencies: argparse "^2.0.1" -js-yaml@~3.14.0: - version "3.14.0" - resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.14.0.tgz#a7a34170f26a21bb162424d8adacb4113a69e482" - integrity sha512-/4IbIeHcD9VMHFqDR/gQ7EdZdLimOvW2DdcxFjdyyZ9NsbS+ccrXqVWDtab/lRl5AlUqmpBx8EhPaWR+OtY17A== - dependencies: - argparse "^1.0.7" - esprima "^4.0.0" - [email protected]: version "3.0.0" resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898" @@ -3413,10 +3426,10 @@ json5@^2.0.0, json5@^2.1.2: dependencies: minimist "^1.2.5" -jsonc-parser@~2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.3.1.tgz#59549150b133f2efacca48fe9ce1ec0659af2342" - integrity sha512-H8jvkz1O50L3dMZCsLqiuB2tA7muqbSg1AtGEkN0leAqGjsUzDJir3Zwr02BhqdcITPg3ei3mZ+HjMocAknhhg== +jsonc-parser@~3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.1.0.tgz#73b8f0e5c940b83d03476bc2e51a20ef0932615d" + integrity sha512-DRf0QjnNeCUds3xTjKlQQ3DpJD51GvDjJfnxUVWg6PZTo2otSm+slzNAxU/35hF8/oJIKoG9slq30JYOsF2azg== jsonfile@^4.0.0: version "4.0.0" @@ -3539,10 +3552,10 @@ linkify-it@^2.0.0: dependencies: uc.micro "^1.0.1" -linkify-it@^3.0.1: - version "3.0.2" - resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-3.0.2.tgz#f55eeb8bc1d3ae754049e124ab3bb56d97797fb8" - integrity sha512-gDBO4aHNZS6coiZCKVhSNh43F9ioIL4JwRjLZPkoLIY4yZFwg264Y5lu2x6rb1Js42Gh6Yqm2f6L2AJcnkzinQ== +linkify-it@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-4.0.1.tgz#01f1d5e508190d06669982ba31a7d9f56a5751ec" + integrity sha512-C7bfi1UZmoj8+PQx22XyeXCuBlokoyWQL5pWSP+EI6nzRylyThouddufc2c1NDIcP9k5agmN9fLpA7VNJfIiqw== dependencies: uc.micro "^1.0.1" @@ -3666,12 +3679,7 @@ lodash.camelcase@^4.3.0: resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6" integrity sha1-soqmKIorn8ZRA1x3EfZathkDMaY= -lodash.differencewith@~4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.differencewith/-/lodash.differencewith-4.5.0.tgz#bafafbc918b55154e179176a00bb0aefaac854b7" - integrity sha1-uvr7yRi1UVTheRdqALsK76rIVLc= - -lodash.flatten@^4.4.0, lodash.flatten@~4.4.0: +lodash.flatten@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8= @@ -3786,14 +3794,14 @@ make-error@^1.1.1: resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8" integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g== [email protected]: - version "11.0.0" - resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-11.0.0.tgz#dbfc30363e43d756ebc52c38586b91b90046b876" - integrity sha512-+CvOnmbSubmQFSA9dKz1BRiaSMV7rhexl3sngKqFyXSagoA3fBdJQ8oZWtRy2knXdpDXaBw44euz37DeJQ9asg== [email protected]: + version "13.0.1" + resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-13.0.1.tgz#c6ecc431cacf1a5da531423fc6a42807814af430" + integrity sha512-lTlxriVoy2criHP0JKRhO2VDG9c2ypWCsT237eDiLqi09rmbKoUetyGHq2uOIRoRS//kfoJckS0eUzzkDR+k2Q== dependencies: - argparse "^1.0.7" - entities "~2.0.0" - linkify-it "^3.0.1" + argparse "^2.0.1" + entities "~3.0.1" + linkify-it "^4.0.1" mdurl "^1.0.1" uc.micro "^1.0.5" @@ -3808,37 +3816,33 @@ markdown-it@^10.0.0: mdurl "^1.0.1" uc.micro "^1.0.5" -markdownlint-cli@^0.25.0: - version "0.25.0" - resolved "https://registry.yarnpkg.com/markdownlint-cli/-/markdownlint-cli-0.25.0.tgz#806b2c234259fa621af27673644506d447bdb6a1" - integrity sha512-pmiXJgPQtAx6YOMXPCCO3AudMWv8Gnhfrprn0raqevofOhO95nJZ6bTEXkUVbzEwvYhvGxE0Yl888aZwuRGMGw== - dependencies: - commander "~6.2.0" - deep-extend "~0.6.0" - get-stdin "~8.0.0" - glob "~7.1.6" - ignore "~5.1.8" - js-yaml "~3.14.0" - jsonc-parser "~2.3.1" - lodash.differencewith "~4.5.0" - lodash.flatten "~4.4.0" - markdownlint "~0.21.1" - markdownlint-rule-helpers "~0.12.0" - minimatch "~3.0.4" - minimist "~1.2.5" - rc "~1.2.8" - -markdownlint-rule-helpers@~0.12.0: - version "0.12.0" - resolved "https://registry.yarnpkg.com/markdownlint-rule-helpers/-/markdownlint-rule-helpers-0.12.0.tgz#c41d9b990c50911572e8eb2fba3e6975a5514b7e" - integrity sha512-Q7qfAk+AJvx82ZY52OByC4yjoQYryOZt6D8TKrZJIwCfhZvcj8vCQNuwDqILushtDBTvGFmUPq+uhOb1KIMi6A== - -markdownlint@^0.21.1, markdownlint@~0.21.1: - version "0.21.1" - resolved "https://registry.yarnpkg.com/markdownlint/-/markdownlint-0.21.1.tgz#9442afcf12bf65ce9d613212028cf85741677421" - integrity sha512-8kc88w5dyEzlmOWIElp8J17qBgzouOQfJ0LhCcpBFrwgyYK6JTKvILsk4FCEkiNqHkTxwxopT2RS2DYb/10qqg== - dependencies: - markdown-it "11.0.0" +markdownlint-cli@^0.32.2: + version "0.32.2" + resolved "https://registry.yarnpkg.com/markdownlint-cli/-/markdownlint-cli-0.32.2.tgz#b7b5c5808039aef4022aef603efaa607caf8e0de" + integrity sha512-xmJT1rGueUgT4yGNwk6D0oqQr90UJ7nMyakXtqjgswAkEhYYqjHew9RY8wDbOmh2R270IWjuKSeZzHDEGPAUkQ== + dependencies: + commander "~9.4.0" + get-stdin "~9.0.0" + glob "~8.0.3" + ignore "~5.2.0" + js-yaml "^4.1.0" + jsonc-parser "~3.1.0" + markdownlint "~0.26.2" + markdownlint-rule-helpers "~0.17.2" + minimatch "~5.1.0" + run-con "~1.2.11" + +markdownlint-rule-helpers@~0.17.2: + version "0.17.2" + resolved "https://registry.yarnpkg.com/markdownlint-rule-helpers/-/markdownlint-rule-helpers-0.17.2.tgz#64d6e8c66e497e631b0e40cf1cef7ca622a0b654" + integrity sha512-XaeoW2NYSlWxMCZM2B3H7YTG6nlaLfkEZWMBhr4hSPlq9MuY2sy83+Xr89jXOqZMZYjvi5nBCGoFh7hHoPKZmA== + +markdownlint@^0.26.2, markdownlint@~0.26.2: + version "0.26.2" + resolved "https://registry.yarnpkg.com/markdownlint/-/markdownlint-0.26.2.tgz#11d3d03e7f0dd3c2e239753ee8fd064a861d9237" + integrity sha512-2Am42YX2Ex5SQhRq35HxYWDfz1NLEOZWWN25nqd2h3AHRKsGRE+Qg1gt1++exW792eXTrR4jCNHfShfWk9Nz8w== + dependencies: + markdown-it "13.0.1" matcher-collection@^1.0.0: version "1.1.2" @@ -4177,7 +4181,14 @@ minimatch@^3.0.2, minimatch@^3.0.4, minimatch@~3.0.4: dependencies: brace-expansion "^1.1.7" -minimist@^1.0.0, minimist@^1.2.5, minimist@^1.2.6, minimist@~1.2.0, minimist@~1.2.5: +minimatch@^5.0.1, minimatch@~5.1.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.1.1.tgz#6c9dffcf9927ff2a31e74b5af11adf8b9604b022" + integrity sha512-362NP+zlprccbEt/SkxKfRMHnNY85V74mVnpUpNyr3F35covl09Kec7/sEFLt3RA4oXmewtoaanoIf67SE5Y5g== + dependencies: + brace-expansion "^2.0.1" + +minimist@^1.0.0, minimist@^1.2.5, minimist@^1.2.6, minimist@~1.2.0: version "1.2.6" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== @@ -4840,16 +4851,6 @@ [email protected]: iconv-lite "0.4.24" unpipe "1.0.0" -rc@~1.2.8: - version "1.2.8" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.8.tgz#cd924bf5200a075b83c188cd6b9e211b7fc0d3ed" - integrity sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw== - dependencies: - deep-extend "^0.6.0" - ini "~1.3.0" - minimist "^1.2.0" - strip-json-comments "~2.0.1" - react-is@^16.8.1: version "16.8.6" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16" @@ -5577,6 +5578,16 @@ run-async@^2.4.0: resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.4.1.tgz#8440eccf99ea3e70bd409d49aab88e10c189a455" integrity sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ== +run-con@~1.2.11: + version "1.2.11" + resolved "https://registry.yarnpkg.com/run-con/-/run-con-1.2.11.tgz#0014ed430bad034a60568dfe7de2235f32e3f3c4" + integrity sha512-NEMGsUT+cglWkzEr4IFK21P4Jca45HqiAbIIZIBdX5+UZTB24Mb/21iNGgz9xZa8tL6vbW7CXmq7MFN42+VjNQ== + dependencies: + deep-extend "^0.6.0" + ini "~3.0.0" + minimist "^1.2.6" + strip-json-comments "~3.1.1" + run-parallel@^1.1.2, run-parallel@^1.1.9: version "1.1.9" resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.1.9.tgz#c9dd3a7cf9f4b2c4b6244e173a6ed866e61dd679" @@ -6014,10 +6025,10 @@ strip-json-comments@^3.0.1, strip-json-comments@^3.1.0: resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.0.tgz#7638d31422129ecf4457440009fba03f9f9ac180" integrity sha512-e6/d0eBu7gHtdCqFt0xJr642LdToM5/cN4Qb9DbHjVx1CP5RyeM+zH7pbecEmDv/lBqb0QH+6Uqq75rxFPkM0w== -strip-json-comments@~2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a" - integrity sha1-PFMZQukIwml8DsNEhYwobHygpgo= +strip-json-comments@~3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006" + integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig== supports-color@^5.3.0: version "5.5.0"
chore
14fe0932f050669fb96fd459562ab84674406532
John Kleinschmidt
2025-02-10 13:40:27
test: make sure test window is on top for focus tests (#45435)
diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index dc54a816df..a925e5b055 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -98,14 +98,13 @@ describe('window.postMessage', () => { }); }); -// Tests disabled due to regression in Chromium upgrade -// https://github.com/electron/electron/issues/45322 -ifdescribe(!(process.platform === 'win32' && process.arch === 'ia32'))('focus handling', () => { +describe('focus handling', () => { let webviewContents: WebContents; let w: BrowserWindow; beforeEach(async () => { w = new BrowserWindow({ + alwaysOnTop: true, show: true, webPreferences: { nodeIntegration: true, diff --git a/spec/lib/screen-helpers.ts b/spec/lib/screen-helpers.ts index 0fb3128611..2358e5a35c 100644 --- a/spec/lib/screen-helpers.ts +++ b/spec/lib/screen-helpers.ts @@ -122,6 +122,14 @@ export class ScreenCapture { return this._expectImpl(findPoint(this.display.size), hexColor, true); } + public async takeScreenshot (filePrefix: string) { + const frame = await this.captureFrame(); + return await createArtifactWithRandomId( + (id) => `${filePrefix}-${id}.png`, + frame.toPNG() + ); + } + private async captureFrame (): Promise<NativeImage> { const sources = await desktopCapturer.getSources({ types: ['screen'],
test
3a5e2dd90c099b10679364642a0f7fa398dce875
David Sanders
2023-07-20 11:43:08
docs: remove redundant IPC event sections (#39133) * docs: use correct names for IPC events * docs: remove redundant IPC event sections
diff --git a/docs/api/ipc-main.md b/docs/api/ipc-main.md index 3b3e14e7cd..6bcf88ee04 100644 --- a/docs/api/ipc-main.md +++ b/docs/api/ipc-main.md @@ -110,7 +110,7 @@ provided to the renderer process. Please refer to * `channel` string * `listener` Function<Promise\<void&#62; | any&#62; - * `event` IpcMainInvokeEvent + * `event` [IpcMainInvokeEvent][ipc-main-invoke-event] * `...args` any[] Handles a single `invoke`able IPC message, then removes the listener. See @@ -122,17 +122,6 @@ Handles a single `invoke`able IPC message, then removes the listener. See Removes any handler for `channel`, if present. -## IpcMainEvent object - -The documentation for the `event` object passed to the `callback` can be found -in the [`ipc-main-event`][ipc-main-event] structure docs. - -## IpcMainInvokeEvent object - -The documentation for the `event` object passed to `handle` callbacks can be -found in the [`ipc-main-invoke-event`][ipc-main-invoke-event] -structure docs. - [IPC tutorial]: ../tutorial/ipc.md [event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter [web-contents-send]: ../api/web-contents.md#contentssendchannel-args diff --git a/docs/api/ipc-renderer.md b/docs/api/ipc-renderer.md index 29dd5ff79c..70fee3d51a 100644 --- a/docs/api/ipc-renderer.md +++ b/docs/api/ipc-renderer.md @@ -26,7 +26,7 @@ The `ipcRenderer` module has the following method to listen for events and send * `channel` string * `listener` Function - * `event` IpcRendererEvent + * `event` [IpcRendererEvent][ipc-renderer-event] * `...args` any[] Listens to `channel`, when a new message arrives `listener` would be called with @@ -36,7 +36,7 @@ Listens to `channel`, when a new message arrives `listener` would be called with * `channel` string * `listener` Function - * `event` IpcRendererEvent + * `event` [IpcRendererEvent][ipc-renderer-event] * `...args` any[] Adds a one time `listener` function for the event. This `listener` is invoked @@ -208,12 +208,8 @@ Sends a message to a window with `webContentsId` via `channel`. Like `ipcRenderer.send` but the event will be sent to the `<webview>` element in the host page instead of the main process. -## Event object - -The documentation for the `event` object passed to the `callback` can be found -in the [`ipc-renderer-event`](./structures/ipc-renderer-event.md) structure docs. - [event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter [SCA]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm [`window.postMessage`]: https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage [`MessagePort`]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort +[ipc-renderer-event]: ./structures/ipc-renderer-event.md
docs
75d0e725be490bf0a8643c6fe23ed7b542db4911
Keeley Hammond
2024-06-13 09:43:06
build: fix conditional for sas token (#42481)
diff --git a/.github/actions/checkout/action.yml b/.github/actions/checkout/action.yml index e8a300a014..241e93c67b 100644 --- a/.github/actions/checkout/action.yml +++ b/.github/actions/checkout/action.yml @@ -39,12 +39,12 @@ runs: node src/electron/script/generate-deps-hash.js && cat src/electron/.depshash-target echo "DEPSHASH=v1-src-cache-$(shasum src/electron/.depshash | cut -f1 -d' ')" >> $GITHUB_ENV - name: Generate SAS Key - if: ${{ inputs.generate-sas-token }} == 'true' + if: ${{ inputs.generate-sas-token == 'true' }} shell: bash run: | curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$DEPSHASH.tar" > sas-token - name: Save SAS Key - if: ${{ inputs.generate-sas-token }} == 'true' + if: ${{ inputs.generate-sas-token == 'true' }} uses: actions/cache/save@v4 with: path: |
build
51a249f380c2840464a9523e548bd942edc779ff
Sam Maddock
2025-01-20 03:57:10
chore: skip flaky contentTracing test (#45240)
diff --git a/spec/api-content-tracing-spec.ts b/spec/api-content-tracing-spec.ts index b584b1a818..243b3383e4 100644 --- a/spec/api-content-tracing-spec.ts +++ b/spec/api-content-tracing-spec.ts @@ -99,7 +99,8 @@ ifdescribe(!(['arm', 'arm64'].includes(process.arch)) || (process.platform !== ' this.timeout(5e3); } - it('does not crash on empty string', async () => { + // FIXME(samuelmaddock): this test regularly flakes + it.skip('does not crash on empty string', async () => { const options = { categoryFilter: '*', traceOptions: 'record-until-full,enable-sampling'
chore
cc5aa65cb421ffa0df823cae09a3dacb0485e698
Charles Kerr
2024-09-06 07:16:56
fix: delete UvTaskRunner's timers only after they're closed (#43561) * fix: free UvTaskRunner timers only after they are closed * refactor: UvTaskRunner now holds UvHandles
diff --git a/shell/app/uv_task_runner.cc b/shell/app/uv_task_runner.cc index e8cfc22860..606f384dbc 100644 --- a/shell/app/uv_task_runner.cc +++ b/shell/app/uv_task_runner.cc @@ -2,31 +2,33 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +#include "shell/app/uv_task_runner.h" + #include <utility> #include "base/location.h" #include "base/time/time.h" -#include "shell/app/uv_task_runner.h" namespace electron { -UvTaskRunner::UvTaskRunner(uv_loop_t* loop) : loop_(loop) {} +UvTaskRunner::UvTaskRunner(uv_loop_t* loop) : loop_{loop} {} -UvTaskRunner::~UvTaskRunner() { - for (auto& iter : tasks_) { - uv_unref(reinterpret_cast<uv_handle_t*>(iter.first)); - delete iter.first; - } -} +UvTaskRunner::~UvTaskRunner() = default; bool UvTaskRunner::PostDelayedTask(const base::Location& from_here, base::OnceClosure task, base::TimeDelta delay) { - auto* timer = new uv_timer_t; + auto on_timeout = [](uv_timer_t* timer) { + auto& tasks = static_cast<UvTaskRunner*>(timer->data)->tasks_; + if (auto iter = tasks.find(timer); iter != tasks.end()) + std::move(tasks.extract(iter).mapped()).Run(); + }; + + auto timer = UvHandle<uv_timer_t>{}; timer->data = this; - uv_timer_init(loop_, timer); - uv_timer_start(timer, UvTaskRunner::OnTimeout, delay.InMilliseconds(), 0); - tasks_[timer] = std::move(task); + uv_timer_init(loop_, timer.get()); + uv_timer_start(timer.get(), on_timeout, delay.InMilliseconds(), 0); + tasks_.insert_or_assign(std::move(timer), std::move(task)); return true; } @@ -40,22 +42,4 @@ bool UvTaskRunner::PostNonNestableDelayedTask(const base::Location& from_here, return PostDelayedTask(from_here, std::move(task), delay); } -// static -void UvTaskRunner::OnTimeout(uv_timer_t* timer) { - auto& tasks = static_cast<UvTaskRunner*>(timer->data)->tasks_; - const auto iter = tasks.find(timer); - if (iter == std::end(tasks)) - return; - - std::move(iter->second).Run(); - tasks.erase(iter); - uv_timer_stop(timer); - uv_close(reinterpret_cast<uv_handle_t*>(timer), UvTaskRunner::OnClose); -} - -// static -void UvTaskRunner::OnClose(uv_handle_t* handle) { - delete reinterpret_cast<uv_timer_t*>(handle); -} - } // namespace electron diff --git a/shell/app/uv_task_runner.h b/shell/app/uv_task_runner.h index 7f23826db1..2802899063 100644 --- a/shell/app/uv_task_runner.h +++ b/shell/app/uv_task_runner.h @@ -9,7 +9,7 @@ #include "base/memory/raw_ptr.h" #include "base/task/single_thread_task_runner.h" -#include "uv.h" // NOLINT(build/include_directory) +#include "shell/common/node_bindings.h" namespace base { class Location; @@ -38,12 +38,10 @@ class UvTaskRunner : public base::SingleThreadTaskRunner { private: ~UvTaskRunner() override; - static void OnTimeout(uv_timer_t* timer); - static void OnClose(uv_handle_t* handle); raw_ptr<uv_loop_t> loop_; - std::map<uv_timer_t*, base::OnceClosure> tasks_; + std::map<UvHandle<uv_timer_t>, base::OnceClosure, UvHandleCompare> tasks_; }; } // namespace electron diff --git a/shell/common/node_bindings.h b/shell/common/node_bindings.h index ad55645422..ac6faf470a 100644 --- a/shell/common/node_bindings.h +++ b/shell/common/node_bindings.h @@ -15,6 +15,7 @@ #include "base/memory/raw_ptr.h" #include "base/memory/raw_ptr_exclusion.h" #include "base/memory/weak_ptr.h" +#include "base/types/to_address.h" #include "gin/public/context_holder.h" #include "gin/public/gin_embedders.h" #include "uv.h" // NOLINT(build/include_directory) @@ -58,11 +59,25 @@ template <typename T, std::is_same<T, uv_udp_t>::value>::type* = nullptr> class UvHandle { public: - UvHandle() : t_(new T) {} + UvHandle() : t_{new T} {} ~UvHandle() { reset(); } + + UvHandle(UvHandle&&) = default; + UvHandle& operator=(UvHandle&&) = default; + + UvHandle(const UvHandle&) = delete; + UvHandle& operator=(const UvHandle&) = delete; + T* get() { return t_; } + T* operator->() { return t_; } + const T* get() const { return t_; } + const T* operator->() const { return t_; } + uv_handle_t* handle() { return reinterpret_cast<uv_handle_t*>(t_); } + // compare by handle pointer address + auto operator<=>(const UvHandle& that) const = default; + void reset() { auto* h = handle(); if (h != nullptr) { @@ -80,6 +95,16 @@ class UvHandle { RAW_PTR_EXCLUSION T* t_ = {}; }; +// Helper for comparing UvHandles and raw uv pointers, e.g. as map keys +struct UvHandleCompare { + using is_transparent = void; + + template <typename U, typename V> + bool operator()(U const& u, V const& v) const { + return base::to_address(u) < base::to_address(v); + } +}; + class NodeBindings { public: enum class BrowserEnvironment { kBrowser, kRenderer, kUtility, kWorker };
fix
2c742cfadb0658951ea83303518ce4df9a91219b
Matt Henkes
2023-05-31 04:58:48
chore: cherry-pick 0e1cc35 from v8 (#38490)
diff --git a/patches/v8/.patches b/patches/v8/.patches index 80aaafd7cf..7f06612a19 100644 --- a/patches/v8/.patches +++ b/patches/v8/.patches @@ -3,3 +3,4 @@ do_not_export_private_v8_symbols_on_windows.patch fix_build_deprecated_attribute_for_older_msvc_versions.patch fix_disable_implies_dcheck_for_node_stream_array_buffers.patch chore_allow_customizing_microtask_policy_per_context.patch +fix_set_proper_instruction_start_for_builtin.patch diff --git a/patches/v8/fix_set_proper_instruction_start_for_builtin.patch b/patches/v8/fix_set_proper_instruction_start_for_builtin.patch new file mode 100644 index 0000000000..e2f969576c --- /dev/null +++ b/patches/v8/fix_set_proper_instruction_start_for_builtin.patch @@ -0,0 +1,35 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: mjhenkes <[email protected]> +Date: Mon, 22 May 2023 15:52:36 -0500 +Subject: Fix: Set proper instruction start for builtin + +Added in this CL: https://chromium-review.googlesource.com/c/v8/v8/+/4547712 + +This patch makes the mksnapshot fix available sooner. + +This patch can be removed when v8 reaches version 11.6.21 + +diff --git a/src/execution/isolate.cc b/src/execution/isolate.cc +index 40d1b394ef30c7cdf1d5aa05a051d3a497abf28e..9b646b1527e9e6595cc2530983feb0279452c7dc 100644 +--- a/src/execution/isolate.cc ++++ b/src/execution/isolate.cc +@@ -3904,14 +3904,16 @@ void FinalizeBuiltinCodeObjects(Isolate* isolate) { + DCHECK_NOT_NULL(isolate->embedded_blob_data()); + DCHECK_NE(0, isolate->embedded_blob_data_size()); + ++ EmbeddedData d = EmbeddedData::FromBlob(isolate); + HandleScope scope(isolate); + static_assert(Builtins::kAllBuiltinsAreIsolateIndependent); + for (Builtin builtin = Builtins::kFirst; builtin <= Builtins::kLast; + ++builtin) { + Handle<Code> old_code = isolate->builtins()->code_handle(builtin); +- // Note we use `instruction_start` as given by the old code object (instead +- // of asking EmbeddedData) due to MaybeRemapEmbeddedBuiltinsIntoCodeRange. +- Address instruction_start = old_code->instruction_start(); ++ // Note that `old_code.instruction_start` might point to `old_code`'s ++ // InstructionStream which might be GCed once we replace the old code ++ // with the new code. ++ Address instruction_start = d.InstructionStartOf(builtin); + Handle<Code> new_code = isolate->factory()->NewCodeObjectForEmbeddedBuiltin( + old_code, instruction_start); +
chore
5094cb4115d52b8e915849cc9c7b9ca9bc37edd9
Felipe C
2023-12-11 11:43:06
fix: wrong default port in docs (#40665) fix: wrong default port
diff --git a/docs/tutorial/debugging-main-process.md b/docs/tutorial/debugging-main-process.md index 9b0b2ae6bc..811c87a200 100644 --- a/docs/tutorial/debugging-main-process.md +++ b/docs/tutorial/debugging-main-process.md @@ -14,10 +14,10 @@ process: Electron will listen for V8 inspector protocol messages on the specified `port`, an external debugger will need to connect on this port. The default `port` is -`5858`. +`9229`. ```shell -electron --inspect=5858 your/app +electron --inspect=9229 your/app ``` ### `--inspect-brk=[port]`
fix
be68d4f33684daea165070ac6cdeef8d2735974a
Samuel Attard
2024-09-23 02:08:03
build: update-check-skip on dependabot backport PRs (#43874)
diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 5f87388878..d747d13d68 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -16,7 +16,7 @@ updates: schedule: interval: weekly labels: - - "no-backport" + - "backport-check-skip" - "semver/none" target-branch: 33-x-y - package-ecosystem: github-actions @@ -24,7 +24,7 @@ updates: schedule: interval: weekly labels: - - "no-backport" + - "backport-check-skip" - "semver/none" target-branch: 32-x-y - package-ecosystem: github-actions @@ -32,7 +32,7 @@ updates: schedule: interval: weekly labels: - - "no-backport" + - "backport-check-skip" - "semver/none" target-branch: 31-x-y - package-ecosystem: github-actions @@ -40,7 +40,7 @@ updates: schedule: interval: weekly labels: - - "no-backport" + - "backport-check-skip" - "semver/none" target-branch: 30-x-y - package-ecosystem: npm @@ -53,7 +53,7 @@ updates: labels: - "no-backport" open-pull-requests-limit: 2 - target-branch: 33-x-y + target-branch: main - package-ecosystem: npm directories: - / @@ -62,9 +62,9 @@ updates: schedule: interval: daily labels: - - "no-backport" + - "backport-check-skip" open-pull-requests-limit: 0 - target-branch: main + target-branch: 33-x-y - package-ecosystem: npm directories: - / @@ -73,7 +73,7 @@ updates: schedule: interval: daily labels: - - "no-backport" + - "backport-check-skip" open-pull-requests-limit: 0 target-branch: 32-x-y - package-ecosystem: npm @@ -84,7 +84,7 @@ updates: schedule: interval: daily labels: - - "no-backport" + - "backport-check-skip" open-pull-requests-limit: 0 target-branch: 31-x-y - package-ecosystem: npm @@ -95,6 +95,6 @@ updates: schedule: interval: daily labels: - - "no-backport" + - "backport-check-skip" open-pull-requests-limit: 0 target-branch: 30-x-y \ No newline at end of file
build
9e066e7b745829c6f68897999c2f0a2d173d3902
Keeley Hammond
2024-06-13 16:35:20
build: add `v8_toolchain` to darwin/x64 (#42487) build: add v8_toolchain to darwin/x64
diff --git a/.github/actions/build-electron/action.yml b/.github/actions/build-electron/action.yml index 587c7ccec3..6b96737a8d 100644 --- a/.github/actions/build-electron/action.yml +++ b/.github/actions/build-electron/action.yml @@ -26,6 +26,12 @@ inputs: runs: using: "composite" steps: + - name: Set GN_EXTRA_ARGS for MacOS x64 Builds + shell: bash + if: ${{ inputs.target-arch == 'x64' && inputs.target-platform == 'macos' }} + run: | + GN_APPENDED_ARGS="$GN_EXTRA_ARGS v8_snapshot_toolchain='//build/toolchain/mac:clang_x64'" + echo "GN_EXTRA_ARGS=$GN_APPENDED_ARGS" >> $GITHUB_ENV - name: Build Electron ${{ inputs.step-suffix }} shell: bash run: |
build
e8ae0571b88079b030228f8c8b67aabaa36af50a
Shelley Vohr
2022-10-11 10:11:58
test: remove redundant color diffing dependency (#33215)
diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index 943200c6ac..1edc690465 100644 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -10,7 +10,7 @@ import { app, BrowserWindow, BrowserView, dialog, ipcMain, OnBeforeSendHeadersLi import { emittedOnce, emittedUntil, emittedNTimes } from './events-helpers'; import { ifit, ifdescribe, defer, delay } from './spec-helpers'; import { closeWindow, closeAllWindows } from './window-helpers'; -import { areColorsSimilar, captureScreen, CHROMA_COLOR_HEX, getPixelColor } from './screen-helpers'; +import { areColorsSimilar, captureScreen, HexColors, getPixelColor } from './screen-helpers'; const features = process._linkedBinding('electron_common_features'); const fixtures = path.resolve(__dirname, 'fixtures'); @@ -2070,15 +2070,7 @@ describe('BrowserWindow module', () => { }); ifdescribe(process.platform === 'darwin')('BrowserWindow.setVibrancy(type)', () => { - let appProcess: childProcess.ChildProcessWithoutNullStreams | childProcess.ChildProcess | undefined; - - afterEach(() => { - if (appProcess && !appProcess.killed) { - appProcess.kill(); - appProcess = undefined; - } - closeAllWindows(); - }); + afterEach(closeAllWindows); it('allows setting, changing, and removing the vibrancy', () => { const w = new BrowserWindow({ show: false }); @@ -2097,18 +2089,6 @@ describe('BrowserWindow module', () => { w.setVibrancy('i-am-not-a-valid-vibrancy-type' as any); }).to.not.throw(); }); - - // TODO(nornagon): disabled due to flakiness. - it.skip('Allows setting a transparent window via CSS', async () => { - const appPath = path.join(__dirname, 'fixtures', 'apps', 'background-color-transparent'); - - appProcess = childProcess.spawn(process.execPath, [appPath], { - stdio: 'inherit' - }); - - const [code] = await emittedOnce(appProcess, 'exit'); - expect(code).to.equal(0); - }); }); ifdescribe(process.platform === 'darwin')('trafficLightPosition', () => { @@ -5527,7 +5507,7 @@ describe('BrowserWindow module', () => { const backgroundWindow = new BrowserWindow({ ...display.bounds, frame: false, - backgroundColor: CHROMA_COLOR_HEX, + backgroundColor: HexColors.GREEN, hasShadow: false }); @@ -5541,9 +5521,10 @@ describe('BrowserWindow module', () => { hasShadow: false }); - foregroundWindow.loadFile(path.join(__dirname, 'fixtures', 'pages', 'half-background-color.html')); - await emittedOnce(foregroundWindow, 'ready-to-show'); + const colorFile = path.join(__dirname, 'fixtures', 'pages', 'half-background-color.html'); + await foregroundWindow.loadFile(colorFile); + await delay(1000); const screenCapture = await captureScreen(); const leftHalfColor = getPixelColor(screenCapture, { x: display.size.width / 4, @@ -5554,22 +5535,57 @@ describe('BrowserWindow module', () => { y: display.size.height / 2 }); - expect(areColorsSimilar(leftHalfColor, CHROMA_COLOR_HEX)).to.be.true(); - expect(areColorsSimilar(rightHalfColor, '#ff0000')).to.be.true(); + expect(areColorsSimilar(leftHalfColor, HexColors.GREEN)).to.be.true(); + expect(areColorsSimilar(rightHalfColor, HexColors.RED)).to.be.true(); + }); + + ifit(process.platform !== 'linux' && process.arch !== 'arm64')('Allows setting a transparent window via CSS', async () => { + const display = screen.getPrimaryDisplay(); + + const backgroundWindow = new BrowserWindow({ + ...display.bounds, + frame: false, + backgroundColor: HexColors.PURPLE, + hasShadow: false + }); + + await backgroundWindow.loadURL('about:blank'); + + const foregroundWindow = new BrowserWindow({ + ...display.bounds, + frame: false, + transparent: true, + hasShadow: false, + webPreferences: { + contextIsolation: false, + nodeIntegration: true + } + }); + + foregroundWindow.loadFile(path.join(__dirname, 'fixtures', 'pages', 'css-transparent.html')); + await emittedOnce(ipcMain, 'set-transparent'); + + await delay(); + const screenCapture = await captureScreen(); + const centerColor = getPixelColor(screenCapture, { + x: display.size.width / 2, + y: display.size.height / 2 + }); + + expect(areColorsSimilar(centerColor, HexColors.PURPLE)).to.be.true(); }); }); describe('"backgroundColor" option', () => { afterEach(closeAllWindows); - // Linux/WOA doesn't return any capture sources. - ifit(process.platform !== 'linux' && (process.platform !== 'win32' || process.arch !== 'arm64'))('should display the set color', async () => { + ifit(process.platform !== 'linux' && process.arch !== 'arm64')('should display the set color', async () => { const display = screen.getPrimaryDisplay(); const w = new BrowserWindow({ ...display.bounds, show: true, - backgroundColor: CHROMA_COLOR_HEX + backgroundColor: HexColors.BLUE }); w.loadURL('about:blank'); @@ -5581,7 +5597,7 @@ describe('BrowserWindow module', () => { y: display.size.height / 2 }); - expect(areColorsSimilar(centerColor, CHROMA_COLOR_HEX)).to.be.true(); + expect(areColorsSimilar(centerColor, HexColors.BLUE)).to.be.true(); }); }); }); diff --git a/spec/fixtures/apps/background-color-transparent/index.html b/spec/fixtures/apps/background-color-transparent/index.html deleted file mode 100644 index f8f5ff4c32..0000000000 --- a/spec/fixtures/apps/background-color-transparent/index.html +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE html> -<html> - <head> - <meta charset="UTF-8"> - <title>test-color-window</title> - <style> - body { - background: green; - } - </style> - </head> - <body id="body"> - <script src="./renderer.js"></script> - </body> -</html> diff --git a/spec/fixtures/apps/background-color-transparent/main.js b/spec/fixtures/apps/background-color-transparent/main.js deleted file mode 100644 index 3086db0dc6..0000000000 --- a/spec/fixtures/apps/background-color-transparent/main.js +++ /dev/null @@ -1,61 +0,0 @@ -const { app, BrowserWindow, desktopCapturer, ipcMain } = require('electron'); -const getColors = require('get-image-colors'); - -const colors = {}; - -// Fetch the test window. -const getWindow = async () => { - const sources = await desktopCapturer.getSources({ types: ['window'] }); - const filtered = sources.filter(s => s.name === 'test-color-window'); - - if (filtered.length === 0) { - throw new Error('Could not find test window'); - } - - return filtered[0]; -}; - -async function createWindow () { - const mainWindow = new BrowserWindow({ - frame: false, - transparent: true, - vibrancy: 'under-window', - webPreferences: { - backgroundThrottling: false, - contextIsolation: false, - nodeIntegration: true - } - }); - - await mainWindow.loadFile('index.html'); - - // Get initial green background color. - const window = await getWindow(); - const buf = window.thumbnail.toPNG(); - const result = await getColors(buf, { count: 1, type: 'image/png' }); - colors.green = result[0].hex(); -} - -ipcMain.on('set-transparent', async () => { - // Get updated background color. - const window = await getWindow(); - const buf = window.thumbnail.toPNG(); - const result = await getColors(buf, { count: 1, type: 'image/png' }); - colors.transparent = result[0].hex(); - - const { green, transparent } = colors; - console.log({ green, transparent }); - process.exit(green === transparent ? 1 : 0); -}); - -app.whenReady().then(() => { - createWindow(); - - app.on('activate', () => { - if (BrowserWindow.getAllWindows().length === 0) createWindow(); - }); -}); - -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') app.quit(); -}); diff --git a/spec/fixtures/apps/background-color-transparent/package.json b/spec/fixtures/apps/background-color-transparent/package.json deleted file mode 100644 index 6b8e31a177..0000000000 --- a/spec/fixtures/apps/background-color-transparent/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "electron-test-background-color-transparent", - "main": "main.js" -} diff --git a/spec/fixtures/apps/background-color-transparent/renderer.js b/spec/fixtures/apps/background-color-transparent/renderer.js deleted file mode 100644 index 1312f5f129..0000000000 --- a/spec/fixtures/apps/background-color-transparent/renderer.js +++ /dev/null @@ -1,9 +0,0 @@ -const { ipcRenderer } = require('electron'); - -window.setTimeout(async (_) => { - document.body.style.background = 'transparent'; - - window.setTimeout(async (_) => { - ipcRenderer.send('set-transparent'); - }, 2000); -}, 3000); diff --git a/spec/fixtures/pages/css-transparent.html b/spec/fixtures/pages/css-transparent.html new file mode 100644 index 0000000000..7747eafc94 --- /dev/null +++ b/spec/fixtures/pages/css-transparent.html @@ -0,0 +1,31 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="UTF-8"> + <title>test-color-window</title> + <style> + body { + background: red; + } + </style> + </head> + <body id="body"> + <script> + const { ipcRenderer } = require('electron'); + + const observer = new MutationObserver((mutationList, observer) => { + mutationList.forEach(({ type, attributeName }) => { + if (type === 'attributes' && attributeName === 'style') { + ipcRenderer.send('set-transparent'); + } + }); + }); + + observer.observe(document.body, { attributes: true }); + + document.addEventListener('DOMContentLoaded', event => { + document.body.style.background = 'transparent'; + }); + </script> + </body> +</html> diff --git a/spec/package.json b/spec/package.json index fd7ea280d5..ff20598a49 100644 --- a/spec/package.json +++ b/spec/package.json @@ -15,7 +15,6 @@ "coffeescript": "^2.4.1", "dbus-native": "github:nornagon/dbus-native#master", "dirty-chai": "^2.0.1", - "get-image-colors": "^4.0.0", "graceful-fs": "^4.1.15", "is-valid-window": "0.0.5", "mkdirp": "^0.5.1", diff --git a/spec/screen-helpers.ts b/spec/screen-helpers.ts index 7a1f7d4a97..0346b58a6a 100644 --- a/spec/screen-helpers.ts +++ b/spec/screen-helpers.ts @@ -4,8 +4,12 @@ import { screen, desktopCapturer, NativeImage } from 'electron'; const fixtures = path.resolve(__dirname, 'fixtures'); -/** Chroma key green. */ -export const CHROMA_COLOR_HEX = '#00b140'; +export enum HexColors { + GREEN = '#00b140', + PURPLE = '#6a0dad', + RED = '#ff0000', + BLUE = '#0000ff' +}; /** * Capture the screen at the given point. @@ -16,10 +20,10 @@ export const captureScreen = async (point: Electron.Point = { x: 0, y: 0 }): Pro const display = screen.getDisplayNearestPoint(point); const sources = await desktopCapturer.getSources({ types: ['screen'], thumbnailSize: display.size }); // Toggle to save screen captures for debugging. - const DEBUG_CAPTURE = false; + const DEBUG_CAPTURE = process.env.DEBUG_CAPTURE || false; if (DEBUG_CAPTURE) { for (const source of sources) { - await fs.promises.writeFile(path.join(fixtures, `screenshot_${source.display_id}.png`), source.thumbnail.toPNG()); + await fs.promises.writeFile(path.join(fixtures, `screenshot_${source.display_id}_${Date.now()}.png`), source.thumbnail.toPNG()); } } const screenCapture = sources.find(source => source.display_id === `${display.id}`); diff --git a/spec/yarn.lock b/spec/yarn.lock index ac0c5d3470..023fbb2cb0 100644 --- a/spec/yarn.lock +++ b/spec/yarn.lock @@ -176,11 +176,6 @@ bindings@^1.2.1: dependencies: file-uri-to-path "1.0.0" -boolbase@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" - integrity sha1-aN/1++YMUes3cl6p4+0xDcwed24= - brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -236,40 +231,6 @@ check-error@^1.0.2: resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= -cheerio@^0.22.0: - version "0.22.0" - resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.22.0.tgz#a9baa860a3f9b595a6b81b1a86873121ed3a269e" - integrity sha1-qbqoYKP5tZWmuBsahocxIe06Jp4= - dependencies: - css-select "~1.2.0" - dom-serializer "~0.1.0" - entities "~1.1.1" - htmlparser2 "^3.9.1" - lodash.assignin "^4.0.9" - lodash.bind "^4.1.4" - lodash.defaults "^4.0.1" - lodash.filter "^4.4.0" - lodash.flatten "^4.2.0" - lodash.foreach "^4.3.0" - lodash.map "^4.4.0" - lodash.merge "^4.4.0" - lodash.pick "^4.2.1" - lodash.reduce "^4.4.0" - lodash.reject "^4.4.0" - lodash.some "^4.4.0" - -chroma-js@^1.1.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/chroma-js/-/chroma-js-1.4.1.tgz#eb2d9c4d1ff24616be84b35119f4d26f8205f134" - integrity sha512-jTwQiT859RTFN/vIf7s+Vl/Z2LcMrvMv3WUFmd/4u76AdlFC0NTNgqEEFPcRiHmAswPsMiQEDZLM8vX8qXpZNQ== - -chroma-js@^2.1.0: - version "2.1.2" - resolved "https://registry.yarnpkg.com/chroma-js/-/chroma-js-2.1.2.tgz#1075cb9ae25bcb2017c109394168b5cf3aa500ec" - integrity sha512-ri/ouYDWuxfus3UcaMxC1Tfp3IE9K5iQzxc2hSxbBRVNQFut1UuGAsZmiAf2mOUubzGJwgMSv9lHg+XqLaz1QQ== - dependencies: - cross-env "^6.0.3" - cliui@^7.0.2: version "7.0.4" resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" @@ -318,49 +279,11 @@ [email protected]: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= -cross-env@^6.0.3: - version "6.0.3" - resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-6.0.3.tgz#4256b71e49b3a40637a0ce70768a6ef5c72ae941" - integrity sha512-+KqxF6LCvfhWvADcDPqo64yVIB31gv/jQulX2NGzKS/g3GEVz6/pt4wjHFtFWsHMddebWD/sDthJemzM4MaAag== - dependencies: - cross-spawn "^7.0.0" - -cross-spawn@^7.0.0: - version "7.0.3" - resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" - integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== - dependencies: - path-key "^3.1.0" - shebang-command "^2.0.0" - which "^2.0.1" - [email protected]: version "0.0.2" resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" integrity sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow== -css-select@~1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/css-select/-/css-select-1.2.0.tgz#2b3a110539c5355f1cd8d314623e870b121ec858" - integrity sha1-KzoRBTnFNV8c2NMUYj6HCxIeyFg= - dependencies: - boolbase "~1.0.0" - css-what "2.1" - domutils "1.5.1" - nth-check "~1.0.1" - [email protected]: - version "2.1.3" - resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.3.tgz#a6d7604573365fe74686c3f311c56513d88285f2" - integrity sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg== - -cwise-compiler@^1.1.2: - version "1.1.3" - resolved "https://registry.yarnpkg.com/cwise-compiler/-/cwise-compiler-1.1.3.tgz#f4d667410e850d3a313a7d2db7b1e505bb034cc5" - integrity sha1-9NZnQQ6FDToxOn0tt7HlBbsDTMU= - dependencies: - uniq "^1.0.0" - dashdash@^1.12.0: version "1.14.1" resolved "https://registry.yarnpkg.com/dashdash/-/dashdash-1.14.1.tgz#853cfa0f7cbe2fed5de20326b8dd581035f6e2f0" @@ -368,11 +291,6 @@ dashdash@^1.12.0: dependencies: assert-plus "^1.0.0" [email protected]: - version "0.0.3" - resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-0.0.3.tgz#18ae979a6a0ca994b0625853916d2662bbae0b1a" - integrity sha1-GK6XmmoMqZSwYlhTkW0mYruuCxo= - "dbus-native@github:nornagon/dbus-native#master": version "0.4.0" resolved "https://codeload.github.com/nornagon/dbus-native/tar.gz/b90ed62d0b5cb93909173c3e0551d9bff0602a90" @@ -452,55 +370,6 @@ dirty-chai@^2.0.1: resolved "https://registry.yarnpkg.com/dirty-chai/-/dirty-chai-2.0.1.tgz#6b2162ef17f7943589da840abc96e75bda01aff3" integrity sha512-ys79pWKvDMowIDEPC6Fig8d5THiC0DJ2gmTeGzVAoEH18J8OzLud0Jh7I9IWg3NSk8x2UocznUuFmfHCXYZx9w== -dom-serializer@0: - version "0.2.2" - resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.2.2.tgz#1afb81f533717175d478655debc5e332d9f9bb51" - integrity sha512-2/xPb3ORsQ42nHYiSunXkDjPLBaEj/xTwUO4B7XCZQTRk7EBtTOPaygh10YAAh2OI1Qrp6NWfpAhzswj0ydt9g== - dependencies: - domelementtype "^2.0.1" - entities "^2.0.0" - -dom-serializer@~0.1.0: - version "0.1.1" - resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-0.1.1.tgz#1ec4059e284babed36eec2941d4a970a189ce7c0" - integrity sha512-l0IU0pPzLWSHBcieZbpOKgkIn3ts3vAh7ZuFyXNwJxJXk/c4Gwj9xaTJwIDVQCXawWD0qb3IzMGH5rglQaO0XA== - dependencies: - domelementtype "^1.3.0" - entities "^1.1.1" - -domelementtype@1, domelementtype@^1.3.0, domelementtype@^1.3.1: - version "1.3.1" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-1.3.1.tgz#d048c44b37b0d10a7f2a3d5fee3f4333d790481f" - integrity sha512-BSKB+TSpMpFI/HOxCNr1O8aMOTZ8hT3pM3GQ0w/mWRmkhEDSFJkkyzz4XQsBV44BChwGkrDfMyjVD0eA2aFV3w== - -domelementtype@^2.0.1: - version "2.2.0" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.2.0.tgz#9a0b6c2782ed6a1c7323d42267183df9bd8b1d57" - integrity sha512-DtBMo82pv1dFtUmHyr48beiuq792Sxohr+8Hm9zoxklYPfa6n0Z3Byjj2IV7bmr2IyqClnqEQhfgHJJ5QF0R5A== - -domhandler@^2.3.0: - version "2.4.2" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-2.4.2.tgz#8805097e933d65e85546f726d60f5eb88b44f803" - integrity sha512-JiK04h0Ht5u/80fdLMCEmV4zkNh2BcoMFBmZ/91WtYZ8qVXSKjiw7fXMgFPnHcSZgOo3XdinHvmnDUeMf5R4wA== - dependencies: - domelementtype "1" - [email protected]: - version "1.5.1" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.5.1.tgz#dcd8488a26f563d61079e48c9f7b7e32373682cf" - integrity sha1-3NhIiib1Y9YQeeSMn3t+Mjc2gs8= - dependencies: - dom-serializer "0" - domelementtype "1" - -domutils@^1.5.1: - version "1.7.0" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-1.7.0.tgz#56ea341e834e06e6748af7a1cb25da67ea9f8c2a" - integrity sha512-Lgd2XcJ/NjEw+7tFvfKxOzCYKZsdct5lczQ2ZaQY8Djz7pfAD3Gbp8ySJWtreII/vDlMVmxwa6pHmdxIYgttDg== - dependencies: - dom-serializer "0" - domelementtype "1" - duplexer@^0.1.1, duplexer@~0.1.1: version "0.1.2" resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6" @@ -534,16 +403,6 @@ encodeurl@~1.0.2: resolved "https://registry.yarnpkg.com/encodeurl/-/encodeurl-1.0.2.tgz#ad3ff4c86ec2d029322f5a02c3a9a606c95b3f59" integrity sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w== -entities@^1.1.1, entities@~1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/entities/-/entities-1.1.2.tgz#bdfa735299664dfafd34529ed4f8522a275fea56" - integrity sha512-f2LZMYl1Fzu7YSBKg+RoROelpOaNrcGmE9AZubeDfrCEia483oW4MI4VyFd5VNHIgQ/7qm1I0wUHK1eJnn2y2w== - -entities@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.2.0.tgz#098dc90ebb83d8dffa089d55256b351d34c4da55" - integrity sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A== - escalade@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40" @@ -646,52 +505,6 @@ get-func-name@^2.0.0: resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" integrity sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig== -get-image-colors@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/get-image-colors/-/get-image-colors-4.0.0.tgz#c8fe161c386b5ae6300d953eac6bccc05a56069d" - integrity sha512-qQZ5vyqgJkQp1c8ZRwKGL03oDsyBBUKiwr4GbB2T4F+tHpfQrw1PjKMQai7jcjRdC2wIHl2rV+6ZuHKttpyk7A== - dependencies: - chroma-js "^2.1.0" - get-pixels "^3.3.2" - get-rgba-palette "^2.0.1" - get-svg-colors "^1.5.1" - pify "^5.0.0" - -get-pixels@^3.3.2: - version "3.3.3" - resolved "https://registry.yarnpkg.com/get-pixels/-/get-pixels-3.3.3.tgz#71e2dfd4befb810b5478a61c6354800976ce01c7" - integrity sha512-5kyGBn90i9tSMUVHTqkgCHsoWoR+/lGbl4yC83Gefyr0HLIhgSWEx/2F/3YgsZ7UpYNuM6pDhDK7zebrUJ5nXg== - dependencies: - data-uri-to-buffer "0.0.3" - jpeg-js "^0.4.1" - mime-types "^2.0.1" - ndarray "^1.0.13" - ndarray-pack "^1.1.1" - node-bitmap "0.0.1" - omggif "^1.0.5" - parse-data-uri "^0.2.0" - pngjs "^3.3.3" - request "^2.44.0" - through "^2.3.4" - -get-rgba-palette@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/get-rgba-palette/-/get-rgba-palette-2.0.1.tgz#5ce70f75c6ef52882f54dd079e5ed68b5a2323ca" - integrity sha1-XOcPdcbvUogvVN0Hnl7Wi1ojI8o= - dependencies: - quantize "^1.0.1" - -get-svg-colors@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/get-svg-colors/-/get-svg-colors-1.5.1.tgz#59f4004f5fb4fc0b0eaaec36dce004b3b10f188b" - integrity sha512-G3gXrkLrlmv2gqZvs05ap/kcGbchhNtUNaoaP6dIefRcrGPqSa17dGp5ap/2yN8Xs2Wi5mWn16Ww+nFuVU8lTw== - dependencies: - cheerio "^0.22.0" - chroma-js "^1.1.1" - is-svg "^3.0.0" - lodash.compact "^3.0.0" - lodash.uniq "^4.5.0" - getpass@^0.1.1: version "0.1.7" resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" @@ -738,7 +551,7 @@ har-schema@^2.0.0: resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" integrity sha1-qUwiJOvKwEeCoNkDVSHyRzW37JI= -har-validator@~5.1.0, har-validator@~5.1.3: +har-validator@~5.1.0: version "5.1.5" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.1.5.tgz#1f0803b9f8cb20c0fa13822df1ecddb36bde1efd" integrity sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w== @@ -766,23 +579,6 @@ hexy@^0.2.10: resolved "https://registry.yarnpkg.com/hexy/-/hexy-0.2.11.tgz#9939c25cb6f86a91302f22b8a8a72573518e25b4" integrity sha512-ciq6hFsSG/Bpt2DmrZJtv+56zpPdnq+NQ4ijEFrveKN0ZG1mhl/LdT1NQZ9se6ty1fACcI4d4vYqC9v8EYpH2A== -html-comment-regex@^1.1.0: - version "1.1.2" - resolved "https://registry.yarnpkg.com/html-comment-regex/-/html-comment-regex-1.1.2.tgz#97d4688aeb5c81886a364faa0cad1dda14d433a7" - integrity sha512-P+M65QY2JQ5Y0G9KKdlDpo0zK+/OHptU5AaBwUfAIDJZk1MYf32Frm84EcOytfJE0t5JvkAnKlmjsXDnWzCJmQ== - -htmlparser2@^3.9.1: - version "3.10.1" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.10.1.tgz#bd679dc3f59897b6a34bb10749c855bb53a9392f" - integrity sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ== - dependencies: - domelementtype "^1.3.1" - domhandler "^2.3.0" - domutils "^1.5.1" - entities "^1.1.1" - inherits "^2.0.1" - readable-stream "^3.1.1" - http-errors@~1.6.2: version "1.6.3" resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.6.3.tgz#8b55680bb4be283a0b5bf4ea2e38580be1d9320d" @@ -810,7 +606,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.1, inherits@^2.0.3: +inherits@2: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -820,12 +616,7 @@ [email protected]: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" integrity sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw== -iota-array@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/iota-array/-/iota-array-1.0.0.tgz#81ef57fe5d05814cd58c2483632a99c30a0e8087" - integrity sha1-ge9X/l0FgUzVjCSDYyqZwwoOgIc= - -is-buffer@^1.0.2, is-buffer@~1.1.6: +is-buffer@~1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== @@ -835,13 +626,6 @@ is-fullwidth-code-point@^3.0.0: resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d" integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg== -is-svg@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/is-svg/-/is-svg-3.0.0.tgz#9321dbd29c212e5ca99c4fa9794c714bcafa2f75" - integrity sha512-gi4iHK53LR2ujhLVVj+37Ykh9GLqYHX6JOVXbLAucaG/Cqw9xwdFOjDM2qeifLs1sF1npXXFvDu0r5HNgCMrzQ== - dependencies: - html-comment-regex "^1.1.0" - is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" @@ -859,21 +643,11 @@ [email protected]: resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= -isexe@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" - integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= - isstream@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= -jpeg-js@^0.4.1: - version "0.4.4" - resolved "https://registry.yarnpkg.com/jpeg-js/-/jpeg-js-0.4.4.tgz#a9f1c6f1f9f0fa80cdb3484ed9635054d28936aa" - integrity sha512-WZzeDOEtTOBK4Mdsar0IqEU5sMr3vSV2RqkAIzUEV2BHnUfKGyswWFPFwK5EeDo93K3FohSHbLAjj0s1Wzd+dg== - jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" @@ -925,81 +699,11 @@ loader-utils@^1.0.0: emojis-list "^2.0.0" json5 "^1.0.1" -lodash.assignin@^4.0.9: - version "4.2.0" - resolved "https://registry.yarnpkg.com/lodash.assignin/-/lodash.assignin-4.2.0.tgz#ba8df5fb841eb0a3e8044232b0e263a8dc6a28a2" - integrity sha1-uo31+4QesKPoBEIysOJjqNxqKKI= - -lodash.bind@^4.1.4: - version "4.2.1" - resolved "https://registry.yarnpkg.com/lodash.bind/-/lodash.bind-4.2.1.tgz#7ae3017e939622ac31b7d7d7dcb1b34db1690d35" - integrity sha1-euMBfpOWIqwxt9fX3LGzTbFpDTU= - -lodash.compact@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/lodash.compact/-/lodash.compact-3.0.1.tgz#540ce3837745975807471e16b4a2ba21e7256ca5" - integrity sha1-VAzjg3dFl1gHRx4WtKK6IeclbKU= - -lodash.defaults@^4.0.1: - version "4.2.0" - resolved "https://registry.yarnpkg.com/lodash.defaults/-/lodash.defaults-4.2.0.tgz#d09178716ffea4dde9e5fb7b37f6f0802274580c" - integrity sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw= - -lodash.filter@^4.4.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.filter/-/lodash.filter-4.6.0.tgz#668b1d4981603ae1cc5a6fa760143e480b4c4ace" - integrity sha1-ZosdSYFgOuHMWm+nYBQ+SAtMSs4= - -lodash.flatten@^4.2.0: - version "4.4.0" - resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" - integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8= - -lodash.foreach@^4.3.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.foreach/-/lodash.foreach-4.5.0.tgz#1a6a35eace401280c7f06dddec35165ab27e3e53" - integrity sha1-Gmo16s5AEoDH8G3d7DUWWrJ+PlM= - lodash.get@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" integrity sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk= -lodash.map@^4.4.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.map/-/lodash.map-4.6.0.tgz#771ec7839e3473d9c4cde28b19394c3562f4f6d3" - integrity sha1-dx7Hg540c9nEzeKLGTlMNWL09tM= - -lodash.merge@^4.4.0: - version "4.6.2" - resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a" - integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ== - -lodash.pick@^4.2.1: - version "4.4.0" - resolved "https://registry.yarnpkg.com/lodash.pick/-/lodash.pick-4.4.0.tgz#52f05610fff9ded422611441ed1fc123a03001b3" - integrity sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM= - -lodash.reduce@^4.4.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.reduce/-/lodash.reduce-4.6.0.tgz#f1ab6b839299ad48f784abbf476596f03b914d3b" - integrity sha1-8atrg5KZrUj3hKu/R2WW8DuRTTs= - -lodash.reject@^4.4.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.reject/-/lodash.reject-4.6.0.tgz#80d6492dc1470864bbf583533b651f42a9f52415" - integrity sha1-gNZJLcFHCGS79YNTO2UfQqn1JBU= - -lodash.some@^4.4.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d" - integrity sha1-G7nzFO9ri63tE7VJFpsqlF62jk0= - -lodash.uniq@^4.5.0: - version "4.5.0" - resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773" - integrity sha1-0CJTc662Uq3BvILklFM5qEJ1R3M= - lodash@^4.17.15: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" @@ -1036,7 +740,7 @@ [email protected]: resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.51.0.tgz#d9ff62451859b18342d960850dc3cfb77e63fb0c" integrity sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g== -mime-types@^2.0.1, mime-types@^2.1.12, mime-types@~2.1.19: +mime-types@^2.1.12, mime-types@~2.1.19: version "2.1.34" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.34.tgz#5a712f9ec1503511a945803640fafe09d3793c24" integrity sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A== @@ -1148,22 +852,6 @@ [email protected], nan@^2.12.1, "nan@github:jkleinsc/nan#remove_accessor_signature": version "2.16.0" resolved "https://codeload.github.com/jkleinsc/nan/tar.gz/6a2f95a6a2209d8aa7542fb18099fd808a802059" -ndarray-pack@^1.1.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/ndarray-pack/-/ndarray-pack-1.2.1.tgz#8caebeaaa24d5ecf70ff86020637977da8ee585a" - integrity sha1-jK6+qqJNXs9w/4YCBjeXfajuWFo= - dependencies: - cwise-compiler "^1.1.2" - ndarray "^1.0.13" - -ndarray@^1.0.13: - version "1.0.19" - resolved "https://registry.yarnpkg.com/ndarray/-/ndarray-1.0.19.tgz#6785b5f5dfa58b83e31ae5b2a058cfd1ab3f694e" - integrity sha512-B4JHA4vdyZU30ELBw3g7/p9bZupyew5a7tX1Y/gGeF2hafrPaQZhgrGQfsvgfYbgdFZjYwuEcnaobeM/WMW+HQ== - dependencies: - iota-array "^1.0.0" - is-buffer "^1.0.2" - nise@^4.0.1: version "4.0.3" resolved "https://registry.yarnpkg.com/nise/-/nise-4.0.3.tgz#9f79ff02fa002ed5ffbc538ad58518fa011dc913" @@ -1175,33 +863,16 @@ nise@^4.0.1: just-extend "^4.0.2" path-to-regexp "^1.7.0" [email protected]: - version "0.0.1" - resolved "https://registry.yarnpkg.com/node-bitmap/-/node-bitmap-0.0.1.tgz#180eac7003e0c707618ef31368f62f84b2a69091" - integrity sha1-GA6scAPgxwdhjvMTaPYvhLKmkJE= - node-ensure@^0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/node-ensure/-/node-ensure-0.0.0.tgz#ecae764150de99861ec5c810fd5d096b183932a7" integrity sha1-7K52QVDemYYexcgQ/V0Jaxg5Mqc= -nth-check@~1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.2.tgz#b2bd295c37e3dd58a3bf0700376663ba4d9cf05c" - integrity sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg== - dependencies: - boolbase "~1.0.0" - oauth-sign@~0.9.0: version "0.9.0" resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.9.0.tgz#47a7b016baa68b5fa0ecf3dee08a85c679ac6455" integrity sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ== -omggif@^1.0.5: - version "1.0.10" - resolved "https://registry.yarnpkg.com/omggif/-/omggif-1.0.10.tgz#ddaaf90d4a42f532e9e7cb3a95ecdd47f17c7b19" - integrity sha512-LMJTtvgc/nugXj0Vcrrs68Mn2D1r0zf630VNtqtpI1FEO7e+O9FP4gqs9AcnBaSEeoHIPm28u6qgPR0oyEpGSw== - on-finished@~2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" @@ -1224,23 +895,11 @@ optimist@^0.6.1: minimist "~0.0.1" wordwrap "~0.0.2" -parse-data-uri@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/parse-data-uri/-/parse-data-uri-0.2.0.tgz#bf04d851dd5c87b0ab238e5d01ace494b604b4c9" - integrity sha1-vwTYUd1ch7CrI45dAazklLYEtMk= - dependencies: - data-uri-to-buffer "0.0.3" - path-is-absolute@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== -path-key@^3.1.0: - version "3.1.1" - resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" - integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== - path-to-regexp@^1.7.0: version "1.8.0" resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.8.0.tgz#887b3ba9d84393e87a0a0b9f4cb756198b53548a" @@ -1273,32 +932,17 @@ performance-now@^2.1.0: resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" integrity sha1-Ywn04OX6kT7BxpMHrjZLSzd8nns= -pify@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/pify/-/pify-5.0.0.tgz#1f5eca3f5e87ebec28cc6d54a0e4aaf00acc127f" - integrity sha512-eW/gHNMlxdSP6dmG6uJip6FXN0EQBwm2clYYd8Wul42Cwu/DK8HEftzsapcNdYe2MfLiIwZqsDk2RDEsTE79hA== - -pngjs@^3.3.3: - version "3.4.0" - resolved "https://registry.yarnpkg.com/pngjs/-/pngjs-3.4.0.tgz#99ca7d725965fb655814eaf65f38f12bbdbf555f" - integrity sha512-NCrCHhWmnQklfH4MtJMRjZ2a8c80qXeMlQMv2uVp9ISJMTt562SbGd6n2oq0PaPgKm7Z6pL9E2UlLIhC+SHL3w== - psl@^1.1.24: version "1.9.0" resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7" integrity sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag== -psl@^1.1.28: - version "1.8.0" - resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24" - integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ== - punycode@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" integrity sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ== -punycode@^2.1.0, punycode@^2.1.1: +punycode@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== @@ -1313,25 +957,11 @@ qs@~6.5.2: resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.3.tgz#3aeeffc91967ef6e35c0e488ef46fb296ab76aad" integrity sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA== -quantize@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/quantize/-/quantize-1.0.2.tgz#d25ac200a77b6d70f40127ca171a10e33c8546de" - integrity sha1-0lrCAKd7bXD0ASfKFxoQ4zyFRt4= - range-parser@~1.2.0: version "1.2.1" resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== -readable-stream@^3.1.1: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - request-json@^0.6.4: version "0.6.5" resolved "https://registry.yarnpkg.com/request-json/-/request-json-0.6.5.tgz#dda8c08245aca950f5f7842ae68495fd23df0ecb" @@ -1366,32 +996,6 @@ [email protected]: tunnel-agent "^0.6.0" uuid "^3.3.2" -request@^2.44.0: - version "2.88.2" - resolved "https://registry.yarnpkg.com/request/-/request-2.88.2.tgz#d73c918731cb5a87da047e207234146f664d12b3" - integrity sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw== - dependencies: - aws-sign2 "~0.7.0" - aws4 "^1.8.0" - caseless "~0.12.0" - combined-stream "~1.0.6" - extend "~3.0.2" - forever-agent "~0.6.1" - form-data "~2.3.2" - har-validator "~5.1.3" - http-signature "~1.2.0" - is-typedarray "~1.0.0" - isstream "~0.1.2" - json-stringify-safe "~5.0.1" - mime-types "~2.1.19" - oauth-sign "~0.9.0" - performance-now "^2.1.0" - qs "~6.5.2" - safe-buffer "^5.1.2" - tough-cookie "~2.5.0" - tunnel-agent "^0.6.0" - uuid "^3.3.2" - require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -1409,7 +1013,7 @@ [email protected]: resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== -safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@~5.2.0: +safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@^5.1.2: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== @@ -1456,18 +1060,6 @@ [email protected]: resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" integrity sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ== -shebang-command@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea" - integrity sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA== - dependencies: - shebang-regex "^3.0.0" - -shebang-regex@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-3.0.0.tgz#ae16f1644d873ecad843b0307b143362d4c42172" - integrity sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A== - sinon@^9.0.1: version "9.0.2" resolved "https://registry.yarnpkg.com/sinon/-/sinon-9.0.2.tgz#b9017e24633f4b1c98dfb6e784a5f0509f5fd85d" @@ -1535,13 +1127,6 @@ string-width@^4.1.0, string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.1" -string_decoder@^1.1.1: - version "1.3.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" - integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== - dependencies: - safe-buffer "~5.2.0" - strip-ansi@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-4.0.0.tgz#a8479022eb1ac368a871389b635262c505ee368f" @@ -1578,7 +1163,7 @@ temp@^0.9.0: mkdirp "^0.5.1" rimraf "~2.6.2" -through@2, through@^2.3.4, through@^2.3.8, through@~2.3, through@~2.3.4: +through@2, through@^2.3.8, through@~2.3, through@~2.3.4: version "2.3.8" resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5" integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg== @@ -1591,14 +1176,6 @@ tough-cookie@~2.4.3: psl "^1.1.24" punycode "^1.4.1" -tough-cookie@~2.5.0: - version "2.5.0" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.5.0.tgz#cd9fb2a0aa1d5a12b473bd9fb96fa3dcff65ade2" - integrity sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g== - dependencies: - psl "^1.1.28" - punycode "^2.1.1" - tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" @@ -1616,11 +1193,6 @@ [email protected], type-detect@^4.0.0, type-detect@^4.0.5, type-detect@^4.0.8: resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== -uniq@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/uniq/-/uniq-1.0.1.tgz#b31c5ae8254844a3a8281541ce2b04b865a734ff" - integrity sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8= - uri-js@^4.2.2: version "4.4.1" resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" @@ -1628,11 +1200,6 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -util-deprecate@^1.0.1: - version "1.0.2" - resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" - integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= - uuid@^3.3.2, uuid@^3.3.3: version "3.4.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee" @@ -1652,13 +1219,6 @@ walkdir@^0.3.2: resolved "https://registry.yarnpkg.com/walkdir/-/walkdir-0.3.2.tgz#ac8437a288c295656848ebc19981ebc677a5f590" integrity sha512-0Twghia4Z5wDGDYWURlhZmI47GvERMCsXIu0QZWVVZyW9ZjpbbZvD9Zy9M6cWiQQRRbAcYajIyKNavaZZDt1Uw== -which@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" - integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA== - dependencies: - isexe "^2.0.0" - winreg@^1.2.4: version "1.2.4" resolved "https://registry.yarnpkg.com/winreg/-/winreg-1.2.4.tgz#ba065629b7a925130e15779108cf540990e98d1b"
test
9fc760bc4cffca6d269d62b7300242efef3f1d4d
Shelley Vohr
2024-07-23 22:40:59
docs: note macOS fullscreen events in fullscreen query (#42997) docs: note macOS fullscreen events in fs query
diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 9f7ecb6468..3dc7925b6e 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -690,6 +690,8 @@ Sets whether the window should be in fullscreen mode. Returns `boolean` - Whether the window is in fullscreen mode. +**Note:** On macOS, fullscreen transitions take place asynchronously. When querying for a BrowserWindow's fullscreen status, you should ensure that either the ['enter-full-screen'](browser-window.md#event-enter-full-screen) or ['leave-full-screen'](browser-window.md#event-leave-full-screen) events have been emitted. + #### `win.setSimpleFullScreen(flag)` _macOS_ * `flag` boolean
docs
dbdbb6fb3bd38f536dff6b6f1fa2ad7581d216f8
Samuel Attard
2023-01-31 13:58:39
build: bump deps to clean up yarn audit (#36535) build: update dependencies to clean up yarn audit
diff --git a/package.json b/package.json index 0e671ec84d..6593c6e722 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "check-for-leaks": "^1.2.1", "colors": "1.4.0", "dotenv-safe": "^4.0.4", - "dugite": "^1.103.0", + "dugite": "^2.3.0", "eslint": "^7.4.0", "eslint-config-standard": "^14.1.1", "eslint-plugin-import": "^2.22.0", diff --git a/yarn.lock b/yarn.lock index 71222a883b..3554f495a2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -135,16 +135,16 @@ "@types/glob" "^7.1.1" "@electron/docs-parser@^1.0.0": - version "1.0.0" - resolved "https://registry.yarnpkg.com/@electron/docs-parser/-/docs-parser-1.0.0.tgz#1844ed2e18528ea56aaef0ace1cfa0633a6fa1b1" - integrity sha512-nIqEO8Ga6LavdaY2aJMPfq2vSOPVlgOvNv7jpiyaoqsAz5vYnWNUnxeCyaalCaDyFiKhVeHbKwP8Kt2TENwneg== + version "1.0.1" + resolved "https://registry.yarnpkg.com/@electron/docs-parser/-/docs-parser-1.0.1.tgz#f9856d00ec1663a0fb6301f55bc674f44c7dc543" + integrity sha512-jqUHwo3MWUhWusHtTVpSHTZqWSVuc1sPUfavI5Zwdx64q7qd4phqOPGoxScWS3JthKt7Wydvo/eReIUNDJ0gRg== dependencies: - "@types/markdown-it" "^10.0.0" + "@types/markdown-it" "^12.0.0" chai "^4.2.0" chalk "^3.0.0" fs-extra "^8.1.0" lodash.camelcase "^4.3.0" - markdown-it "^10.0.0" + markdown-it "^12.0.0" minimist "^1.2.0" ora "^4.0.3" pretty-ms "^5.1.0" @@ -624,23 +624,11 @@ dependencies: object-assign "^4.1.1" -"@sindresorhus/is@^0.14.0": - version "0.14.0" - resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" - integrity sha512-9NET910DNaIPngYnLLPeg+Ogzqsi9uM4mSboU5y6p8S5DzMTVEsJZrawi+BoDNUVBa2DhJqQYUFvMDfgU062LQ== - "@sindresorhus/is@^4.0.0": version "4.6.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-4.6.0.tgz#3c7c9c46e678feefe7a2e5bb609d3dbd665ffb3f" integrity sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw== -"@szmarczak/http-timer@^1.1.2": - version "1.1.2" - resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-1.1.2.tgz#b1665e2c461a2cd92f4c1bbf50d5454de0d4b421" - integrity sha512-XIB2XbzHTN6ieIjfIMV9hlVcfPU26s2vafYWQcZHWXHOxiaRZYEDKEwdl129Zyg50+foYV2jCgtrqSA6qNuNSA== - dependencies: - defer-to-connect "^1.0.1" - "@szmarczak/http-timer@^4.0.5": version "4.0.6" resolved "https://registry.yarnpkg.com/@szmarczak/http-timer/-/http-timer-4.0.6.tgz#b4a914bb62e7c272d4e5989fe4440f812ab1d807" @@ -809,11 +797,6 @@ "@types/minimatch" "*" "@types/node" "*" -"@types/highlight.js@^9.7.0": - version "9.12.4" - resolved "https://registry.yarnpkg.com/@types/highlight.js/-/highlight.js-9.12.4.tgz#8c3496bd1b50cc04aeefd691140aa571d4dbfa34" - integrity sha512-t2szdkwmg2JJyuCM20e8kR2X59WCE5Zkl4bzm1u1Oukjm79zpbiAv+QjnwLnuuV0WHEcX2NgUItu0pAMKuOPww== - "@types/http-cache-semantics@*": version "4.0.1" resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812" @@ -854,10 +837,10 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= -"@types/jsonwebtoken@^8.3.3": - version "8.5.0" - resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-8.5.0.tgz#2531d5e300803aa63279b232c014acf780c981c5" - integrity sha512-9bVao7LvyorRGZCw0VmH/dr7Og+NdjYSsKAxB43OQoComFbBgsEpoR9JW6+qSq/ogwVBg8GI2MfAlk4SYI4OLg== +"@types/jsonwebtoken@^9.0.0": + version "9.0.1" + resolved "https://registry.yarnpkg.com/@types/jsonwebtoken/-/jsonwebtoken-9.0.1.tgz#29b1369c4774200d6d6f63135bf3d1ba3ef997a4" + integrity sha512-c5ltxazpWabia/4UzhIoaDcIza4KViOQhdbjRlfcIGVnsE3c3brkz9Z+F/EeJIECOQP7W7US2hNE930cWWkPiw== dependencies: "@types/node" "*" @@ -885,15 +868,13 @@ resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-5.1.0.tgz#57f228f2b80c046b4a1bd5cac031f81f207f4f03" integrity sha512-RaE0B+14ToE4l6UqdarKPnXwVDuigfFv+5j9Dze/Nqr23yyuqdNvzcZi3xB+3Agvi5R4EOgAksfv3lXX4vBt9w== -"@types/markdown-it@^10.0.0": - version "10.0.3" - resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-10.0.3.tgz#a9800d14b112c17f1de76ec33eff864a4815eec7" - integrity sha512-daHJk22isOUvNssVGF2zDnnSyxHhFYhtjeX4oQaKD6QzL3ZR1QSgiD1g+Q6/WSWYVogNXYDXODtbgW/WiFCtyw== +"@types/markdown-it@^12.0.0": + version "12.2.3" + resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-12.2.3.tgz#0d6f6e5e413f8daaa26522904597be3d6cd93b51" + integrity sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ== dependencies: - "@types/highlight.js" "^9.7.0" "@types/linkify-it" "*" "@types/mdurl" "*" - highlight.js "^9.7.0" "@types/mdast@^3.0.0": version "3.0.7" @@ -1333,13 +1314,13 @@ resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== -accepts@~1.3.7: - version "1.3.7" - resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd" - integrity sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA== +accepts@~1.3.8: + version "1.3.8" + resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e" + integrity sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw== dependencies: - mime-types "~2.1.24" - negotiator "0.6.2" + mime-types "~2.1.34" + negotiator "0.6.3" acorn-import-assertions@^1.7.6: version "1.8.0" @@ -1407,14 +1388,14 @@ ansi-regex@^4.1.0: integrity sha512-ILlv4k/3f6vfQ4OoP2AGvirOktlQ98ZEL1k9FaQjxa3L1abBgbuTDAdPOpvbGncC0BTVQrl+OM8xZGK6tWXt7g== ansi-regex@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" - integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== ansi-regex@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.0.tgz#ecc7f5933cbe5ac7b33e209a5ff409ab1669c6b2" - integrity sha512-tAaOSrWCHF+1Ear1Z4wnJCXA9GGox4K6Ic85a5qalES2aeEwQGr7UC93mwef49536PkCYjzkp0zIxfFvexJ6zQ== + version "6.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a" + integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA== ansi-styles@^3.2.0, ansi-styles@^3.2.1: version "3.2.1" @@ -1589,21 +1570,23 @@ binary-extensions@^2.0.0: resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.1.0.tgz#30fa40c9e7fe07dbc895678cd287024dea241dd9" integrity sha512-1Yj8h9Q+QDF5FzhMs/c9+6UntbD5MkRfRwac8DoEm9ZfUBZ7tZ55YcGVAzEe4bXsdQHEk+s9S5wsOKVdZrw0tQ== [email protected]: - version "1.19.0" - resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.19.0.tgz#96b2709e57c9c4e09a6fd66a8fd979844f69f08a" - integrity sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw== [email protected]: + version "1.20.1" + resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.1.tgz#b1812a8912c195cd371a3ee5e66faa2338a5c668" + integrity sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw== dependencies: - bytes "3.1.0" + bytes "3.1.2" content-type "~1.0.4" debug "2.6.9" - depd "~1.1.2" - http-errors "1.7.2" + depd "2.0.0" + destroy "1.2.0" + http-errors "2.0.0" iconv-lite "0.4.24" - on-finished "~2.3.0" - qs "6.7.0" - raw-body "2.4.0" - type-is "~1.6.17" + on-finished "2.4.1" + qs "6.11.0" + raw-body "2.5.1" + type-is "~1.6.18" + unpipe "1.0.0" boolean@^3.0.1: version "3.2.0" @@ -1691,29 +1674,16 @@ builtins@^4.0.0: dependencies: semver "^7.0.0" [email protected]: - version "3.1.0" - resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.0.tgz#f6cf7933a360e0588fa9fde85651cdc7f805d1f6" - integrity sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg== [email protected]: + version "3.1.2" + resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" + integrity sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg== cacheable-lookup@^5.0.3: version "5.0.4" resolved "https://registry.yarnpkg.com/cacheable-lookup/-/cacheable-lookup-5.0.4.tgz#5a6b865b2c44357be3d5ebc2a467b032719a7005" integrity sha512-2/kNscPhpcxrOigMZzbiWF7dz8ilhb/nIHU3EyZiXWXpeq/au8qJ8VhdftMkty3n7Gj6HIGalQG8oiBNB3AJgA== -cacheable-request@^6.0.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-6.1.0.tgz#20ffb8bd162ba4be11e9567d823db651052ca912" - integrity sha512-Oj3cAGPCqOZX7Rz64Uny2GYAZNliQSqfbePrgAQ1wKAihYmCUnraBtJtKcGR4xz7wF+LoJC+ssFZvv5BgF9Igg== - dependencies: - clone-response "^1.0.2" - get-stream "^5.1.0" - http-cache-semantics "^4.0.0" - keyv "^3.0.0" - lowercase-keys "^2.0.0" - normalize-url "^4.1.0" - responselike "^1.0.2" - cacheable-request@^7.0.2: version "7.0.2" resolved "https://registry.yarnpkg.com/cacheable-request/-/cacheable-request-7.0.2.tgz#ea0d0b889364a25854757301ca12b2da77f91d27" @@ -1727,6 +1697,14 @@ cacheable-request@^7.0.2: normalize-url "^6.0.1" responselike "^2.0.0" +call-bind@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" + integrity sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA== + dependencies: + function-bind "^1.1.1" + get-intrinsic "^1.0.2" + callsites@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.1.0.tgz#b3630abd8943432f54b3f0519238e33cd7df2f73" @@ -1814,13 +1792,6 @@ check-for-leaks@^1.2.1: parse-gitignore "^0.4.0" walk-sync "^0.3.2" -checksum@^0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/checksum/-/checksum-0.1.1.tgz#dc6527d4c90be8560dbd1ed4cecf3297d528e9e9" - integrity sha1-3GUn1MkL6FYNvR7Uzs8yl9Uo6ek= - dependencies: - optimist "~0.3.5" - chokidar@^3.0.0: version "3.5.2" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.2.tgz#dba3976fcadb016f66fd365021d91600d01c1e75" @@ -1836,10 +1807,10 @@ chokidar@^3.0.0: optionalDependencies: fsevents "~2.3.2" -chownr@^1.1.4: - version "1.1.4" - resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" - integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== +chownr@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-2.0.0.tgz#15bfbe53d2eab4cf70f18a8cd68ebe5b3cb1dece" + integrity sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ== chrome-trace-event@^1.0.2: version "1.0.2" @@ -2015,12 +1986,12 @@ contains-path@^0.1.0: resolved "https://registry.yarnpkg.com/contains-path/-/contains-path-0.1.0.tgz#fe8cf184ff6670b6baef01a9d4861a5cbec4120a" integrity sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo= [email protected]: - version "0.5.3" - resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.3.tgz#e130caf7e7279087c5616c2007d0485698984fbd" - integrity sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g== [email protected]: + version "0.5.4" + resolved "https://registry.yarnpkg.com/content-disposition/-/content-disposition-0.5.4.tgz#8b82b4efac82512a02bb0b1dcec9d2c5e8eb5bfe" + integrity sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ== dependencies: - safe-buffer "5.1.2" + safe-buffer "5.2.1" content-type@~1.0.4: version "1.0.4" @@ -2032,10 +2003,10 @@ [email protected]: resolved "https://registry.yarnpkg.com/cookie-signature/-/cookie-signature-1.0.6.tgz#e303a882b342cc3ee8ca513a79999734dab3ae2c" integrity sha1-4wOogrNCzD7oylE6eZmXNNqzriw= [email protected]: - version "0.4.0" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.4.0.tgz#beb437e7022b3b6d49019d088665303ebe9c14ba" - integrity sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg== [email protected]: + version "0.5.0" + resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.5.0.tgz#d1f5d71adec6558c58f389987c366aa47e994f8b" + integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== core-util-is@~1.0.0: version "1.0.2" @@ -2120,13 +2091,6 @@ decode-named-character-reference@^1.0.0: dependencies: character-entities "^2.0.0" -decompress-response@^3.3.0: - version "3.3.0" - resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-3.3.0.tgz#80a4dd323748384bfa248083622aedec982adff3" - integrity sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M= - dependencies: - mimic-response "^1.0.0" - decompress-response@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/decompress-response/-/decompress-response-6.0.0.tgz#ca387612ddb7e104bd16d85aab00d5ecf09c66fc" @@ -2163,11 +2127,6 @@ defaults@^1.0.3: dependencies: clone "^1.0.2" -defer-to-connect@^1.0.1: - version "1.1.3" - resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-1.1.3.tgz#331ae050c08dcf789f8c83a7b81f0ed94f4ac591" - integrity sha512-0ISdNousHvZT2EiFlZeZAHBUvSxmKswVCEf8hW7KWgG4a8MVEu/3Vb6uWYozkjylyCxe0JBIiRB1jV45S70WVQ== - defer-to-connect@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/defer-to-connect/-/defer-to-connect-2.0.1.tgz#8016bdb4143e4632b77a3449c6236277de520587" @@ -2197,10 +2156,10 @@ delayed-stream@~1.0.0: resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha1-3zrhmayt+31ECqrgsp4icrJOxhk= -depd@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9" - integrity sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak= [email protected]: + version "2.0.0" + resolved "https://registry.yarnpkg.com/depd/-/depd-2.0.0.tgz#b696163cc757560d09cf22cc8fad1571b79e76df" + integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw== deprecation@^2.0.0, deprecation@^2.3.1: version "2.3.1" @@ -2212,10 +2171,10 @@ dequal@^2.0.0: resolved "https://registry.yarnpkg.com/dequal/-/dequal-2.0.3.tgz#2644214f1997d39ed0ee0ece72335490a7ac67be" integrity sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA== -destroy@~1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.0.4.tgz#978857442c44749e4206613e37946205826abd80" - integrity sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA= [email protected]: + version "1.2.0" + resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" + integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== detect-node@^2.0.4: version "2.1.0" @@ -2273,22 +2232,13 @@ dotenv@^4.0.0: resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-4.0.0.tgz#864ef1379aced55ce6f95debecdce179f7a0cd1d" integrity sha1-hk7xN5rO1Vzm+V3r7NzhefegzR0= -dugite@^1.103.0: - version "1.103.0" - resolved "https://registry.yarnpkg.com/dugite/-/dugite-1.103.0.tgz#2229c83790782116f96b87763d9ea1a0f2a55842" - integrity sha512-8rKO/jQX2HKfSd5wNG/l3HnUfQPKqyC3+D+3CR5Go4+BJOyCPScQwiAVW+eeKLqHFOvjq/w67+ymMyPGxUqhIA== +dugite@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/dugite/-/dugite-2.3.0.tgz#ff6fdb4c899f84ed6695c9e01eaf4364a6211f13" + integrity sha512-78zuD3p5lx2IS8DilVvHbXQXRo+hGIb3EAshTEC3ZyBLyArKegA8R/6c4Ne1aUlx6JRf3wmKNgYkdJOYMyj9aA== dependencies: - checksum "^0.1.1" - got "^9.6.0" - mkdirp "^0.5.1" progress "^2.0.3" - rimraf "^2.5.4" - tar "^4.4.7" - -duplexer3@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/duplexer3/-/duplexer3-0.1.4.tgz#ee01dd1cac0ed3cbc7fdbea37dc0a8f1ce002ce2" - integrity sha1-7gHdHKwO08vH/b6jfcCo8c4ALOI= + tar "^6.1.11" duplexer@~0.1.1: version "0.1.1" @@ -2373,10 +2323,10 @@ ensure-posix-path@^1.0.0: resolved "https://registry.yarnpkg.com/ensure-posix-path/-/ensure-posix-path-1.1.1.tgz#3c62bdb19fa4681544289edb2b382adc029179ce" integrity sha512-VWU0/zXzVbeJNXvME/5EmLuEj2TauvoaTz6aFYK1Z92JCBlDlZ3Gu0tuGR42kpW1754ywTs+QB0g5TP0oj9Zaw== -entities@~2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/entities/-/entities-2.0.0.tgz#68d6084cab1b079767540d80e56a39b423e4abf4" - integrity sha512-D9f7V0JSRwIxlRI2mjMqufDrRDnx8p+eEOz7aUM9SuvF8gsBzra0/6tbjl1m8eQHrZlYj6PxqE00hZ1SAIKPLw== +entities@~2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/entities/-/entities-2.1.0.tgz#992d3129cf7df6870b96c57858c249a120f8b8b5" + integrity sha512-hCx1oky9PFrJ611mf0ifBLBRW8lUUVRlFolb5gWRfIELabBlbp9xZvrqZLZAs+NxFnbfQoeGd8wDkygjg7U85w== entities@~3.0.1: version "3.0.1" @@ -2886,37 +2836,38 @@ execa@^4.0.1: strip-final-newline "^2.0.0" express@^4.16.4: - version "4.17.1" - resolved "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134" - integrity sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g== + version "4.18.2" + resolved "https://registry.yarnpkg.com/express/-/express-4.18.2.tgz#3fabe08296e930c796c19e3c516979386ba9fd59" + integrity sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ== dependencies: - accepts "~1.3.7" + accepts "~1.3.8" array-flatten "1.1.1" - body-parser "1.19.0" - content-disposition "0.5.3" + body-parser "1.20.1" + content-disposition "0.5.4" content-type "~1.0.4" - cookie "0.4.0" + cookie "0.5.0" cookie-signature "1.0.6" debug "2.6.9" - depd "~1.1.2" + depd "2.0.0" encodeurl "~1.0.2" escape-html "~1.0.3" etag "~1.8.1" - finalhandler "~1.1.2" + finalhandler "1.2.0" fresh "0.5.2" + http-errors "2.0.0" merge-descriptors "1.0.1" methods "~1.1.2" - on-finished "~2.3.0" + on-finished "2.4.1" parseurl "~1.3.3" path-to-regexp "0.1.7" - proxy-addr "~2.0.5" - qs "6.7.0" + proxy-addr "~2.0.7" + qs "6.11.0" range-parser "~1.2.1" - safe-buffer "5.1.2" - send "0.17.1" - serve-static "1.14.1" - setprototypeof "1.1.1" - statuses "~1.5.0" + safe-buffer "5.2.1" + send "0.18.0" + serve-static "1.15.0" + setprototypeof "1.2.0" + statuses "2.0.1" type-is "~1.6.18" utils-merge "1.0.1" vary "~1.1.2" @@ -3025,17 +2976,17 @@ fill-range@^7.0.1: dependencies: to-regex-range "^5.0.1" -finalhandler@~1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d" - integrity sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA== [email protected]: + version "1.2.0" + resolved "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.2.0.tgz#7d23fe5731b207b4640e4fcd00aec1f9207a7b32" + integrity sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg== dependencies: debug "2.6.9" encodeurl "~1.0.2" escape-html "~1.0.3" - on-finished "~2.3.0" + on-finished "2.4.1" parseurl "~1.3.3" - statuses "~1.5.0" + statuses "2.0.1" unpipe "~1.0.0" find-root@^1.0.0: @@ -3111,10 +3062,10 @@ format@^0.2.0: resolved "https://registry.yarnpkg.com/format/-/format-0.2.2.tgz#d6170107e9efdc4ed30c9dc39016df942b5cb58b" integrity sha1-1hcBB+nv3E7TDJ3DkBbflCtctYs= -forwarded@~0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" - integrity sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ= [email protected]: + version "0.2.0" + resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" + integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== [email protected]: version "0.5.2" @@ -3158,12 +3109,12 @@ fs-extra@^9.0.1: jsonfile "^6.0.1" universalify "^1.0.0" -fs-minipass@^1.2.7: - version "1.2.7" - resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.7.tgz#ccff8570841e7fe4265693da88936c55aed7f7c7" - integrity sha512-GWSSJGFy4e9GUeCcbIkED+bgAoFyj7XF1mV8rma3QW4NIqX9Kyx79N/PF61H5udOV3aY1IaMLs6pGbH71nlCTA== +fs-minipass@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-2.1.0.tgz#7f5036fdbf12c63c169190cbe4199c852271f9fb" + integrity sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg== dependencies: - minipass "^2.6.0" + minipass "^3.0.0" fs.realpath@^1.0.0: version "1.0.0" @@ -3190,6 +3141,15 @@ get-func-name@^2.0.0: resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" integrity sha1-6td0q+5y4gQJQzoGY2YCPdaIekE= +get-intrinsic@^1.0.2: + version "1.2.0" + resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.0.tgz#7ad1dc0535f3a2904bba075772763e5051f6d05f" + integrity sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q== + dependencies: + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.3" + get-own-enumerable-property-symbols@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-own-enumerable-property-symbols/-/get-own-enumerable-property-symbols-3.0.0.tgz#b877b49a5c16aefac3655f2ed2ea5b684df8d203" @@ -3205,13 +3165,6 @@ get-stdin@~9.0.0: resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-9.0.0.tgz#3983ff82e03d56f1b2ea0d3e60325f39d703a575" integrity sha512-dVKBjfWisLAicarI2Sf+JuBE/DghV4UzNAVe9yhEJuzeREd3JhOTE9cUaJTeSa77fsbQUK3pcOpJfM59+VKZaA== -get-stream@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" - integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== - dependencies: - pump "^3.0.0" - get-stream@^5.0.0, get-stream@^5.1.0: version "5.2.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" @@ -3226,14 +3179,7 @@ getos@^3.2.1: dependencies: async "^3.2.0" -glob-parent@^5.0.0, glob-parent@^5.1.0: - version "5.1.1" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" - integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== - dependencies: - is-glob "^4.0.1" - -glob-parent@~5.1.2: +glob-parent@^5.0.0, glob-parent@^5.1.0, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== @@ -3323,23 +3269,6 @@ got@^11.8.5: p-cancelable "^2.0.0" responselike "^2.0.0" -got@^9.6.0: - version "9.6.0" - resolved "https://registry.yarnpkg.com/got/-/got-9.6.0.tgz#edf45e7d67f99545705de1f7bbeeeb121765ed85" - integrity sha512-R7eWptXuGYxwijs0eV+v3o6+XH1IqVK8dJOEecQfTmkncw9AV4dcw/Dhxi8MdlqPthxxpZyizMzyg8RTmEsG+Q== - dependencies: - "@sindresorhus/is" "^0.14.0" - "@szmarczak/http-timer" "^1.1.2" - cacheable-request "^6.0.0" - decompress-response "^3.3.0" - duplexer3 "^0.1.4" - get-stream "^4.1.0" - lowercase-keys "^1.0.1" - mimic-response "^1.0.1" - p-cancelable "^1.0.0" - to-readable-stream "^1.0.0" - url-parse-lax "^3.0.0" - graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.9: version "4.2.0" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.0.tgz#8d8fdc73977cb04104721cb53666c1ca64cd328b" @@ -3385,6 +3314,11 @@ has-symbols@^1.0.1: resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.1.tgz#9f5214758a44196c406d9bd76cebf81ec2dd31e8" integrity sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg== +has-symbols@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/has-symbols/-/has-symbols-1.0.3.tgz#bb7b2c4349251dce87b125f7bdf874aa7c8b39f8" + integrity sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A== + has@^1.0.1, has@^1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/has/-/has-1.0.3.tgz#722d7cbfc1f6aa8241f16dd814e011e1f41e8796" @@ -3392,11 +3326,6 @@ has@^1.0.1, has@^1.0.3: dependencies: function-bind "^1.1.1" -highlight.js@^9.7.0: - version "9.18.5" - resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.18.5.tgz#d18a359867f378c138d6819edfc2a8acd5f29825" - integrity sha512-a5bFyofd/BHCX52/8i8uJkjr9DYwXIPnM/plwI6W7ezItLGqzt7X2G2nXuYSfsIJdkwwj/g9DG1LkcGJI/dDoA== - hosted-git-info@^2.1.4: version "2.8.9" resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9" @@ -3407,27 +3336,16 @@ http-cache-semantics@^4.0.0: resolved "https://registry.yarnpkg.com/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz#49e91c5cbf36c9b94bcfcd71c23d5249ec74e390" integrity sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ== [email protected]: - version "1.7.2" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.2.tgz#4f5029cf13239f31036e5b2e55292bcfbcc85c8f" - integrity sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg== - dependencies: - depd "~1.1.2" - inherits "2.0.3" - setprototypeof "1.1.1" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.0" - -http-errors@~1.7.2: - version "1.7.3" - resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.3.tgz#6c619e4f9c60308c38519498c14fbb10aacebb06" - integrity sha512-ZTTX0MWrsQ2ZAhA1cejAwDLycFsd7I7nVtnkT3Ol0aqodaKW+0CTZDQ1uBv5whptCnc8e8HeRRJxRs0kmm/Qfw== [email protected]: + version "2.0.0" + resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-2.0.0.tgz#b7774a1486ef73cf7667ac9ae0858c012c57b9d3" + integrity sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ== dependencies: - depd "~1.1.2" + depd "2.0.0" inherits "2.0.4" - setprototypeof "1.1.1" - statuses ">= 1.5.0 < 2" - toidentifier "1.0.0" + setprototypeof "1.2.0" + statuses "2.0.1" + toidentifier "1.0.1" http2-wrapper@^1.0.0-beta.5.2: version "1.0.3" @@ -3533,11 +3451,6 @@ inherits@2, [email protected], inherits@^2.0.3, inherits@~2.0.1, inherits@~2.0.3: resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== [email protected]: - version "2.0.3" - resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" - integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= - ini@^1.3.5: version "1.3.7" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.7.tgz#a09363e1911972ea16d7a8851005d84cf09a9a84" @@ -3577,10 +3490,10 @@ interpret@^2.2.0: resolved "https://registry.yarnpkg.com/interpret/-/interpret-2.2.0.tgz#1a78a0b5965c40a5416d007ad6f50ad27c417df9" integrity sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw== [email protected]: - version "1.9.0" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.0.tgz#37df74e430a0e47550fe54a2defe30d8acd95f65" - integrity sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA== [email protected]: + version "1.9.1" + resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" + integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== is-alphabetical@^2.0.0: version "2.0.0" @@ -3812,11 +3725,6 @@ js-yaml@^4.0.0, js-yaml@^4.1.0: dependencies: argparse "^2.0.1" [email protected]: - version "3.0.0" - resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.0.tgz#5b1f397afc75d677bde8bcfc0e47e1f9a3d9a898" - integrity sha1-Wx85evx11ne96Lz8Dkfh+aPZqJg= - [email protected], json-buffer@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/json-buffer/-/json-buffer-3.0.1.tgz#9338802a30d3b6605fbe0613e094008ca8c05a13" @@ -3848,18 +3756,16 @@ json-stringify-safe@^5.0.1: integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA== json5@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" - integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow== + version "1.0.2" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" + integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== dependencies: minimist "^1.2.0" json5@^2.0.0, json5@^2.1.2: - version "2.2.0" - resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.0.tgz#2dfefe720c6ba525d9ebd909950f0515316c89a3" - integrity sha512-f+8cldu7X/y7RAJurMEJmdoKXGB/X550w2Nr3tTbezL6RwEE/iMcm+tZnXeoZtKuOq6ft8+CqzEkrIgx1fPoQA== - dependencies: - minimist "^1.2.5" + version "2.2.3" + resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283" + integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg== jsonc-parser@~3.2.0: version "3.2.0" @@ -3882,21 +3788,15 @@ jsonfile@^6.0.1: optionalDependencies: graceful-fs "^4.1.6" -jsonwebtoken@^8.5.1: - version "8.5.1" - resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz#00e71e0b8df54c2121a1f26137df2280673bcc0d" - integrity sha512-XjwVfRS6jTMsqYs0EsuJ4LGxXV14zQybNd4L2r0UvbVnSF9Af8x7p5MzbJ90Ioz/9TI41/hTCvznF/loiSzn8w== +jsonwebtoken@^9.0.0: + version "9.0.0" + resolved "https://registry.yarnpkg.com/jsonwebtoken/-/jsonwebtoken-9.0.0.tgz#d0faf9ba1cc3a56255fe49c0961a67e520c1926d" + integrity sha512-tuGfYXxkQGDPnLJ7SibiQgVgeDgfbPq2k2ICcbgqW8WxWLBAxKQM/ZCu/IT8SOSwmaYl4dpTFCW5xZv7YbbWUw== dependencies: jws "^3.2.2" - lodash.includes "^4.3.0" - lodash.isboolean "^3.0.3" - lodash.isinteger "^4.0.4" - lodash.isnumber "^3.0.3" - lodash.isplainobject "^4.0.6" - lodash.isstring "^4.0.1" - lodash.once "^4.0.0" + lodash "^4.17.21" ms "^2.1.1" - semver "^5.6.0" + semver "^7.3.8" jsx-ast-utils@^2.1.0: version "2.4.1" @@ -3923,13 +3823,6 @@ jws@^3.2.2: jwa "^1.4.1" safe-buffer "^5.0.1" -keyv@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/keyv/-/keyv-3.1.0.tgz#ecc228486f69991e49e9476485a5be1e8fc5c4d9" - integrity sha512-9ykJ/46SN/9KPM/sichzQ7OvXyGDYKGTaDlKMGCAlg2UK8KRy4jb0d8sFc+0Tt0YYnThq8X2RZgCg74RPxgcVA== - dependencies: - json-buffer "3.0.0" - keyv@^4.0.0: version "4.3.1" resolved "https://registry.yarnpkg.com/keyv/-/keyv-4.3.1.tgz#7970672f137d987945821b1a07b524ce5a4edd27" @@ -3939,9 +3832,9 @@ keyv@^4.0.0: json-buffer "3.0.1" kind-of@^6.0.2: - version "6.0.2" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" - integrity sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA== + version "6.0.3" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== klaw@^3.0.0: version "3.0.0" @@ -3985,10 +3878,10 @@ lines-and-columns@^1.1.6: resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00" integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA= -linkify-it@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-2.2.0.tgz#e3b54697e78bf915c70a38acd78fd09e0058b1cf" - integrity sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw== +linkify-it@^3.0.1: + version "3.0.3" + resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-3.0.3.tgz#a98baf44ce45a550efb4d49c769d07524cc2fa2e" + integrity sha512-ynTsyrFSdE5oZ/O9GEf00kPngmOfVwazR5GKDq6EYfhlpFug3J2zybX56a2PRRpc9P+FuSoGNAwjlbDs9jJBPQ== dependencies: uc.micro "^1.0.1" @@ -4083,9 +3976,9 @@ loader-utils@^1.0.2: json5 "^1.0.1" loader-utils@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.0.tgz#e4cace5b816d425a166b5f097e10cd12b36064b0" - integrity sha512-rP4F0h2RaWSvPEkD7BLDFQnvSf+nK+wr3ESUjNTyAGobqrijmW92zc+SO6d4p4B1wh7+B/Jg1mkQe5NYUEHtHQ== + version "2.0.4" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-2.0.4.tgz#8b5cb38b5c34a9a018ee1fc0e6a066d1dfcc528c" + integrity sha512-xXqpXoINfFhgua9xiqD8fPFHgkoq1mmmpE92WlDbm9rNRd/EbRb+Gqf908T2DMfuHjjJlksiK2RbHVOdD/MqSw== dependencies: big.js "^5.2.2" emojis-list "^3.0.0" @@ -4124,47 +4017,12 @@ lodash.flatten@^4.4.0: resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" integrity sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8= -lodash.includes@^4.3.0: - version "4.3.0" - resolved "https://registry.yarnpkg.com/lodash.includes/-/lodash.includes-4.3.0.tgz#60bb98a87cb923c68ca1e51325483314849f553f" - integrity sha1-YLuYqHy5I8aMoeUTJUgzFISfVT8= - -lodash.isboolean@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz#6c2e171db2a257cd96802fd43b01b20d5f5870f6" - integrity sha1-bC4XHbKiV82WgC/UOwGyDV9YcPY= - -lodash.isinteger@^4.0.4: - version "4.0.4" - resolved "https://registry.yarnpkg.com/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz#619c0af3d03f8b04c31f5882840b77b11cd68343" - integrity sha1-YZwK89A/iwTDH1iChAt3sRzWg0M= - -lodash.isnumber@^3.0.3: - version "3.0.3" - resolved "https://registry.yarnpkg.com/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz#3ce76810c5928d03352301ac287317f11c0b1ffc" - integrity sha1-POdoEMWSjQM1IwGsKHMX8RwLH/w= - -lodash.isplainobject@^4.0.6: - version "4.0.6" - resolved "https://registry.yarnpkg.com/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb" - integrity sha1-fFJqUtibRcRcxpC4gWO+BJf1UMs= - -lodash.isstring@^4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/lodash.isstring/-/lodash.isstring-4.0.1.tgz#d527dfb5456eca7cc9bb95d5daeaf88ba54a5451" - integrity sha1-1SfftUVuynzJu5XV2ur4i6VKVFE= - -lodash.once@^4.0.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac" - integrity sha1-DdOXEhPHxW34gJd9UEyI+0cal6w= - lodash.range@^3.2.0: version "3.2.0" resolved "https://registry.yarnpkg.com/lodash.range/-/lodash.range-3.2.0.tgz#f461e588f66683f7eadeade513e38a69a565a15d" integrity sha1-9GHliPZmg/fq3q3lE+OKaaVloV0= -lodash@^4.0.0, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15: +lodash@^4.0.0, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.21: version "4.17.21" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== @@ -4212,11 +4070,6 @@ loose-envify@^1.4.0: dependencies: js-tokens "^3.0.0 || ^4.0.0" -lowercase-keys@^1.0.0, lowercase-keys@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-1.0.1.tgz#6f9e30b47084d971a7c820ff15a6c5167b74c26f" - integrity sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA== - lowercase-keys@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/lowercase-keys/-/lowercase-keys-2.0.0.tgz#2603e78b7b4b0006cbca2fbcc8a3202558ac9479" @@ -4245,14 +4098,14 @@ [email protected]: mdurl "^1.0.1" uc.micro "^1.0.5" -markdown-it@^10.0.0: - version "10.0.0" - resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-10.0.0.tgz#abfc64f141b1722d663402044e43927f1f50a8dc" - integrity sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg== +markdown-it@^12.0.0: + version "12.3.2" + resolved "https://registry.yarnpkg.com/markdown-it/-/markdown-it-12.3.2.tgz#bf92ac92283fe983fe4de8ff8abfb5ad72cd0c90" + integrity sha512-TchMembfxfNVpHkbtriWltGWc+m3xszaRD0CZup7GFFhzIgQqxIfn3eGj1yZpfuflzPvfkt611B2Q/Bsk1YnGg== dependencies: - argparse "^1.0.7" - entities "~2.0.0" - linkify-it "^2.0.0" + argparse "^2.0.1" + entities "~2.1.0" + linkify-it "^3.0.1" mdurl "^1.0.1" uc.micro "^1.0.5" @@ -4604,7 +4457,7 @@ [email protected]: resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== -mime-types@^2.1.12, mime-types@^2.1.27: +mime-types@^2.1.12, mime-types@^2.1.27, mime-types@~2.1.34: version "2.1.35" resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== @@ -4633,7 +4486,7 @@ mimic-fn@^2.1.0: resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== -mimic-response@^1.0.0, mimic-response@^1.0.1: +mimic-response@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/mimic-response/-/mimic-response-1.0.1.tgz#4923538878eef42063cb8a3e3b0798781487ab1b" integrity sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ== @@ -4674,28 +4527,38 @@ minimist@^1.2.0: resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18" integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g== -minipass@^2.6.0, minipass@^2.9.0: - version "2.9.0" - resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.9.0.tgz#e713762e7d3e32fed803115cf93e04bca9fcc9a6" - integrity sha512-wxfUjg9WebH+CUDX/CdbRlh5SmfZiy/hpkxaRI16Y9W56Pa75sWgd/rvFilSgrauD9NyFymP/+JFV3KwzIsJeg== +minipass@^3.0.0: + version "3.3.6" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-3.3.6.tgz#7bba384db3a1520d18c9c0e5251c3444e95dd94a" + integrity sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw== dependencies: - safe-buffer "^5.1.2" - yallist "^3.0.0" + yallist "^4.0.0" -minizlib@^1.3.3: - version "1.3.3" - resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.3.3.tgz#2290de96818a34c29551c8a8d301216bd65a861d" - integrity sha512-6ZYMOEnmVsdCeTJVE0W9ZD+pVnE8h9Hma/iOwwRDsdQoePpoX56/8B6z3P9VNwppJuBKNRuFDRNRqRWexT9G9Q== +minipass@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-4.0.1.tgz#2b9408c6e81bb8b338d600fb3685e375a370a057" + integrity sha512-V9esFpNbK0arbN3fm2sxDKqMYgIp7XtVdE4Esj+PE4Qaaxdg1wIw48ITQIOn1sc8xXSmUviVL3cyjMqPlrVkiA== + +minizlib@^2.1.1: + version "2.1.2" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931" + integrity sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg== dependencies: - minipass "^2.9.0" + minipass "^3.0.0" + yallist "^4.0.0" -mkdirp@^0.5.1, mkdirp@^0.5.5: +mkdirp@^0.5.1: version "0.5.5" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== dependencies: minimist "^1.2.5" +mkdirp@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-1.0.4.tgz#3eb5ed62622756d79a5f0e2a221dfebad75c2f7e" + integrity sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw== + mri@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/mri/-/mri-1.2.0.tgz#6721480fec2a11a4889861115a48b6cbe7cc8f0b" @@ -4706,16 +4569,16 @@ [email protected]: resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= [email protected]: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.1.tgz#30a5864eb3ebb0a66f2ebe6d727af06a09d86e0a" - integrity sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg== - [email protected], ms@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== [email protected]: + version "2.1.3" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" + integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== + [email protected]: version "0.0.8" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d" @@ -4730,10 +4593,10 @@ natural-compare@^1.4.0: resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc= [email protected]: - version "0.6.2" - resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.2.tgz#feacf7ccf525a77ae9634436a64883ffeca346fb" - integrity sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw== [email protected]: + version "0.6.3" + resolved "https://registry.yarnpkg.com/negotiator/-/negotiator-0.6.3.tgz#58e323a72fedc0d6f9cd4d31fe49f51479590ccd" + integrity sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg== neo-async@^2.6.2: version "2.6.2" @@ -4779,11 +4642,6 @@ normalize-path@^3.0.0, normalize-path@~3.0.0: resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== -normalize-url@^4.1.0: - version "4.5.1" - resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-4.5.1.tgz#0dd90cf1288ee1d1313b87081c9a5932ee48518a" - integrity sha512-9UZCFRHQdNrfTpGg8+1INIg93B6zE0aXMVFkw1WFwvO4SlZywU6aLg5Of0Ap/PgcbSw4LNxvMWXMeugwMCX0AA== - normalize-url@^6.0.1: version "6.1.0" resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-6.1.0.tgz#40d0885b535deffe3f3147bec877d05fe4c5668a" @@ -4814,6 +4672,11 @@ object-inspect@^1.7.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0" integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA== +object-inspect@^1.9.0: + version "1.12.3" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.12.3.tgz#ba62dffd67ee256c8c086dfae69e016cd1f198b9" + integrity sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g== + object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" @@ -4858,10 +4721,10 @@ object.values@^1.1.0, object.values@^1.1.1: function-bind "^1.1.1" has "^1.0.3" -on-finished@~2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.3.0.tgz#20f1336481b083cd75337992a16971aa2d906947" - integrity sha1-IPEzZIGwg811M3mSoWlxqi2QaUc= [email protected]: + version "2.4.1" + resolved "https://registry.yarnpkg.com/on-finished/-/on-finished-2.4.1.tgz#58c8c44116e54845ad57f14ab10b03533184ac3f" + integrity sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg== dependencies: ee-first "1.1.1" @@ -4886,13 +4749,6 @@ onetime@^5.1.0: dependencies: mimic-fn "^2.1.0" -optimist@~0.3.5: - version "0.3.7" - resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.3.7.tgz#c90941ad59e4273328923074d2cf2e7cbc6ec0d9" - integrity sha1-yQlBrVnkJzMokjB00s8ufLxuwNk= - dependencies: - wordwrap "~0.0.2" - optionator@^0.8.3: version "0.8.3" resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495" @@ -4948,11 +4804,6 @@ os-tmpdir@^1.0.0, os-tmpdir@~1.0.2: resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= -p-cancelable@^1.0.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-1.1.0.tgz#d078d15a3af409220c886f1d9a0ca2e441ab26cc" - integrity sha512-s73XxOZ4zpt1edZYZzvhqFa6uvQc1vwUa0K0BdtIZgQMAJj9IbebH+JkgKZc9h+B05PKHLOTl4ajG1BmNrVZlw== - p-cancelable@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/p-cancelable/-/p-cancelable-2.1.1.tgz#aab7fbd416582fa32a3db49859c122487c5ed2cf" @@ -5228,11 +5079,6 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= -prepend-http@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897" - integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc= - pretty-ms@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/pretty-ms/-/pretty-ms-5.0.0.tgz#6133a8f55804b208e4728f6aa7bf01085e951e24" @@ -5271,13 +5117,13 @@ prop-types@^15.7.2: object-assign "^4.1.1" react-is "^16.8.1" -proxy-addr@~2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.5.tgz#34cbd64a2d81f4b1fd21e76f9f06c8a45299ee34" - integrity sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ== +proxy-addr@~2.0.7: + version "2.0.7" + resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" + integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== dependencies: - forwarded "~0.1.2" - ipaddr.js "1.9.0" + forwarded "0.2.0" + ipaddr.js "1.9.1" prr@~1.0.1: version "1.0.1" @@ -5307,10 +5153,12 @@ punycode@^2.1.0, punycode@^2.1.1: resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== [email protected]: - version "6.7.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.7.0.tgz#41dc1a015e3d581f1621776be31afb2876a9b1bc" - integrity sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ== [email protected]: + version "6.11.0" + resolved "https://registry.yarnpkg.com/qs/-/qs-6.11.0.tgz#fd0d963446f7a65e1367e01abd85429453f0c37a" + integrity sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q== + dependencies: + side-channel "^1.0.4" [email protected]: version "0.2.0" @@ -5339,13 +5187,13 @@ range-parser@~1.2.1: resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== [email protected]: - version "2.4.0" - resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.0.tgz#a1ce6fb9c9bc356ca52e89256ab59059e13d0332" - integrity sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q== [email protected]: + version "2.5.1" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.5.1.tgz#fe1b1628b181b700215e5fd42389f98b71392857" + integrity sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig== dependencies: - bytes "3.1.0" - http-errors "1.7.2" + bytes "3.1.2" + http-errors "2.0.0" iconv-lite "0.4.24" unpipe "1.0.0" @@ -6024,13 +5872,6 @@ resolve@^1.9.0: path-parse "^1.0.7" supports-preserve-symlinks-flag "^1.0.0" -responselike@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/responselike/-/responselike-1.0.2.tgz#918720ef3b631c5642be068f15ade5a46f4ba1e7" - integrity sha1-kYcg7ztjHFZCvgaPFa3lpG9Loec= - dependencies: - lowercase-keys "^1.0.0" - responselike@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/responselike/-/responselike-2.0.0.tgz#26391bcc3174f750f9a79eacc40a12a5c42d7723" @@ -6059,7 +5900,7 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== [email protected], rimraf@^2.5.4: [email protected]: version "2.6.3" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== @@ -6117,16 +5958,16 @@ sade@^1.7.3: dependencies: mri "^1.1.0" [email protected], safe-buffer@~5.1.0, safe-buffer@~5.1.1: - version "5.1.2" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" - integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== - -safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.2, safe-buffer@^5.2.1, safe-buffer@~5.2.0: [email protected], safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== +safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + "safer-buffer@>= 2.1.2 < 3": version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -6197,31 +6038,31 @@ semver@^7.2.1, semver@^7.3.2: resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.2.tgz#604962b052b81ed0786aae84389ffba70ffd3938" integrity sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ== -semver@^7.3.5: +semver@^7.3.5, semver@^7.3.8: version "7.3.8" resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798" integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A== dependencies: lru-cache "^6.0.0" [email protected]: - version "0.17.1" - resolved "https://registry.yarnpkg.com/send/-/send-0.17.1.tgz#c1d8b059f7900f7466dd4938bdc44e11ddb376c8" - integrity sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg== [email protected]: + version "0.18.0" + resolved "https://registry.yarnpkg.com/send/-/send-0.18.0.tgz#670167cc654b05f5aa4a767f9113bb371bc706be" + integrity sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg== dependencies: debug "2.6.9" - depd "~1.1.2" - destroy "~1.0.4" + depd "2.0.0" + destroy "1.2.0" encodeurl "~1.0.2" escape-html "~1.0.3" etag "~1.8.1" fresh "0.5.2" - http-errors "~1.7.2" + http-errors "2.0.0" mime "1.6.0" - ms "2.1.1" - on-finished "~2.3.0" + ms "2.1.3" + on-finished "2.4.1" range-parser "~1.2.1" - statuses "~1.5.0" + statuses "2.0.1" serialize-error@^7.0.1: version "7.0.1" @@ -6237,20 +6078,20 @@ serialize-javascript@^6.0.0: dependencies: randombytes "^2.1.0" [email protected]: - version "1.14.1" - resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.14.1.tgz#666e636dc4f010f7ef29970a88a674320898b2f9" - integrity sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg== [email protected]: + version "1.15.0" + resolved "https://registry.yarnpkg.com/serve-static/-/serve-static-1.15.0.tgz#faaef08cffe0a1a62f60cad0c4e513cff0ac9540" + integrity sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g== dependencies: encodeurl "~1.0.2" escape-html "~1.0.3" parseurl "~1.3.3" - send "0.17.1" + send "0.18.0" [email protected]: - version "1.1.1" - resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.1.tgz#7e95acb24aa92f5885e0abef5ba131330d4ae683" - integrity sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw== [email protected]: + version "1.2.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.2.0.tgz#66c9a24a73f9fc28cbe66b09fed3d33dcaf1b424" + integrity sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw== shallow-clone@^3.0.0: version "3.0.1" @@ -6301,15 +6142,24 @@ shx@^0.3.2: minimist "^1.2.0" shelljs "^0.8.1" +side-channel@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf" + integrity sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw== + dependencies: + call-bind "^1.0.0" + get-intrinsic "^1.0.2" + object-inspect "^1.9.0" + signal-exit@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== simple-git@^3.5.0: - version "3.15.1" - resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.15.1.tgz#57f595682cb0c2475d5056da078a05c8715a25ef" - integrity sha512-73MVa5984t/JP4JcQt0oZlKGr42ROYWC3BcUZfuHtT3IHKPspIvL0cZBnvPXF7LL3S/qVeVHVdYYmJ3LOTw4Rg== + version "3.16.0" + resolved "https://registry.yarnpkg.com/simple-git/-/simple-git-3.16.0.tgz#421773e24680f5716999cc4a1d60127b4b6a9dec" + integrity sha512-zuWYsOLEhbJRWVxpjdiXl6eyAyGo/KzVW+KFhhw9MqEEJttcq+32jTWSGyxTdf9e/YCohxRE+9xpWFj9FdiJNw== dependencies: "@kwsites/file-exists" "^1.1.1" "@kwsites/promise-deferred" "^1.1.1" @@ -6446,10 +6296,10 @@ standard@^14.3.1: eslint-plugin-standard "~4.0.0" standard-engine "^12.0.0" -"statuses@>= 1.5.0 < 2", statuses@~1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" - integrity sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow= [email protected]: + version "2.0.1" + resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" + integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== stream-chain@^2.2.3: version "2.2.3" @@ -6658,18 +6508,17 @@ tapable@^2.1.1, tapable@^2.2.0: resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ== -tar@^4.4.7: - version "4.4.19" - resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.19.tgz#2e4d7263df26f2b914dee10c825ab132123742f3" - integrity sha512-a20gEsvHnWe0ygBY8JbxoM4w3SJdhc7ZAuxkLqh+nvNQN2IOt0B5lLgM490X5Hl8FF0dl0tOf2ewFYAlIFgzVA== +tar@^6.1.11: + version "6.1.13" + resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.13.tgz#46e22529000f612180601a6fe0680e7da508847b" + integrity sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw== dependencies: - chownr "^1.1.4" - fs-minipass "^1.2.7" - minipass "^2.9.0" - minizlib "^1.3.3" - mkdirp "^0.5.5" - safe-buffer "^5.2.1" - yallist "^3.1.1" + chownr "^2.0.0" + fs-minipass "^2.0.0" + minipass "^4.0.0" + minizlib "^2.1.1" + mkdirp "^1.0.3" + yallist "^4.0.0" temp@^0.8.3: version "0.8.3" @@ -6732,11 +6581,6 @@ tmp@^0.0.33: dependencies: os-tmpdir "~1.0.2" -to-readable-stream@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/to-readable-stream/-/to-readable-stream-1.0.0.tgz#ce0aa0c2f3df6adf852efb404a783e77c0475771" - integrity sha512-Iq25XBt6zD5npPhlLVXGFN3/gyR2/qODcKNNyTMd4vbm39HUaOiAM4PMq0eMVC/Tkxz+Zjdsc55g9yyz+Yq00Q== - to-regex-range@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" @@ -6752,10 +6596,10 @@ to-vfile@^7.0.0: is-buffer "^2.0.0" vfile "^5.0.0" [email protected]: - version "1.0.0" - resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.0.tgz#7e1be3470f1e77948bc43d94a3c8f4d7752ba553" - integrity sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw== [email protected]: + version "1.0.1" + resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35" + integrity sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA== tough-cookie@^4.0.0: version "4.0.0" @@ -6872,7 +6716,7 @@ type-fest@^0.8.1: resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.8.1.tgz#09e249ebde851d3b1e48d27c105444667f17b83d" integrity sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA== -type-is@~1.6.17, type-is@~1.6.18: +type-is@~1.6.18: version "1.6.18" resolved "https://registry.yarnpkg.com/type-is/-/type-is-1.6.18.tgz#4e552cd05df09467dcbc4ef739de89f2cf37c131" integrity sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g== @@ -7053,12 +6897,12 @@ unist-util-visit@^4.1.1: unist-util-visit-parents "^5.1.1" universal-github-app-jwt@^1.0.1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/universal-github-app-jwt/-/universal-github-app-jwt-1.1.0.tgz#0abaa876101cdf1d3e4c546be2768841c0c1b514" - integrity sha512-3b+ocAjjz4JTyqaOT+NNBd5BtTuvJTxWElIoeHSVelUV9J3Jp7avmQTdLKCaoqi/5Ox2o/q+VK19TJ233rVXVQ== + version "1.1.1" + resolved "https://registry.yarnpkg.com/universal-github-app-jwt/-/universal-github-app-jwt-1.1.1.tgz#d57cee49020662a95ca750a057e758a1a7190e6e" + integrity sha512-G33RTLrIBMFmlDV4u4CBF7dh71eWwykck4XgaxaIVeZKOYZRAAxvcGMRFTUclVY6xoUPQvO4Ne5wKGxYm/Yy9w== dependencies: - "@types/jsonwebtoken" "^8.3.3" - jsonwebtoken "^8.5.1" + "@types/jsonwebtoken" "^9.0.0" + jsonwebtoken "^9.0.0" universal-user-agent@^6.0.0: version "6.0.0" @@ -7100,13 +6944,6 @@ uri-js@^4.2.2: dependencies: punycode "^2.1.0" -url-parse-lax@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/url-parse-lax/-/url-parse-lax-3.0.0.tgz#16b5cafc07dbe3676c1b1999177823d6503acb0c" - integrity sha1-FrXK/Afb42dsGxmZF3gj1lA6yww= - dependencies: - prepend-http "^2.0.0" - [email protected]: version "0.10.3" resolved "https://registry.yarnpkg.com/url/-/url-0.10.3.tgz#021e4d9c7705f21bbf37d03ceb58767402774c64" @@ -7370,11 +7207,6 @@ word-wrap@^1.2.3, word-wrap@~1.2.3: resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.3.tgz#610636f6b1f703891bd34771ccb17fb93b47079c" integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== -wordwrap@~0.0.2: - version "0.0.3" - resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-0.0.3.tgz#a3d5da6cd5c0bc0008d37234bbaf1bed63059107" - integrity sha1-o9XabNXAvAAI03I0u68b7WMFkQc= - wrap-ansi@^6.2.0: version "6.2.0" resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53" @@ -7447,11 +7279,6 @@ xtend@^4.0.1, xtend@~4.0.0, xtend@~4.0.1: resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== -yallist@^3.0.0, yallist@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" - integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== - yallist@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
build
ee966ad6ec76b923ced107aa2d0247f0c5ed69d7
Shelley Vohr
2023-02-21 09:48:52
build: remove unused python code (#37351)
diff --git a/script/lib/config.py b/script/lib/config.py index 2d1a5d95fd..3db917d172 100644 --- a/script/lib/config.py +++ b/script/lib/config.py @@ -30,10 +30,6 @@ def get_target_arch(): return arch -def get_env_var(name): - return os.environ.get('ELECTRON_' + name, '') - - def enable_verbose_mode(): print('Running in verbose mode') global verbose_mode diff --git a/script/lib/native_tests.py b/script/lib/native_tests.py index 04858bf7ed..ff3a3a74b2 100644 --- a/script/lib/native_tests.py +++ b/script/lib/native_tests.py @@ -121,11 +121,6 @@ class TestsList(): for binary in binaries]) return suite_returncode - def run_only(self, binary_name, output_dir=None, verbosity=Verbosity.CHATTY, - disabled_tests_policy=DisabledTestsPolicy.DISABLE): - return self.run([binary_name], output_dir, verbosity, - disabled_tests_policy) - def run_all(self, output_dir=None, verbosity=Verbosity.CHATTY, disabled_tests_policy=DisabledTestsPolicy.DISABLE): return self.run(self.get_for_current_platform(), output_dir, verbosity, diff --git a/script/lib/util.py b/script/lib/util.py index abf1310673..b33828a2a5 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -25,12 +25,9 @@ ELECTRON_DIR = os.path.abspath( TS_NODE = os.path.join(ELECTRON_DIR, 'node_modules', '.bin', 'ts-node') SRC_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..')) -NPM = 'npm' if sys.platform in ['win32', 'cygwin']: - NPM += '.cmd' TS_NODE += '.cmd' - @contextlib.contextmanager def scoped_cwd(path): cwd = os.getcwd() @@ -41,18 +38,6 @@ def scoped_cwd(path): os.chdir(cwd) [email protected] -def scoped_env(key, value): - origin = '' - if key in os.environ: - origin = os.environ[key] - os.environ[key] = value - try: - yield - finally: - os.environ[key] = origin - - def download(text, url, path): safe_mkdir(os.path.dirname(path)) with open(path, 'wb') as local_file:
build
3186c2f0efa92d275dc3d57b5a14a60ed3846b0e
Charles Kerr
2024-08-19 16:15:19
refactor: remove unused SetWMSpecState (#43347) last use removed in Aug 2022 by 53cd2315 #35179
diff --git a/shell/browser/ui/x/x_window_utils.cc b/shell/browser/ui/x/x_window_utils.cc index 7289f23b2d..fd0c5ec3aa 100644 --- a/shell/browser/ui/x/x_window_utils.cc +++ b/shell/browser/ui/x/x_window_utils.cc @@ -19,13 +19,6 @@ namespace electron { -void SetWMSpecState(x11::Window window, bool enabled, x11::Atom state) { - ui::SendClientMessage( - window, ui::GetX11RootWindow(), x11::GetAtom("_NET_WM_STATE"), - {static_cast<uint32_t>(enabled ? 1 : 0), static_cast<uint32_t>(state), - static_cast<uint32_t>(x11::Window::None), 1, 0}); -} - void SetWindowType(x11::Window window, const std::string& type) { std::string type_prefix = "_NET_WM_WINDOW_TYPE_"; std::string window_type_str = type_prefix + base::ToUpperASCII(type); diff --git a/shell/browser/ui/x/x_window_utils.h b/shell/browser/ui/x/x_window_utils.h index 0d909f25d6..767eb2112b 100644 --- a/shell/browser/ui/x/x_window_utils.h +++ b/shell/browser/ui/x/x_window_utils.h @@ -11,10 +11,6 @@ namespace electron { -// Sends a message to the x11 window manager, enabling or disabling the |state| -// for _NET_WM_STATE. -void SetWMSpecState(x11::Window window, bool enabled, x11::Atom state); - // Sets the _NET_WM_WINDOW_TYPE of window. void SetWindowType(x11::Window window, const std::string& type);
refactor
f95e1d8ea08d4c5297ff9017ae56ee00a843822f
Shelley Vohr
2024-11-20 17:34:46
chore: fix textured window conditional on macOS (#44728)
diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index c32949f820..dc483ee3fd 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -167,11 +167,6 @@ NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options, if (!rounded_corner && !has_frame()) styleMask = NSWindowStyleMaskBorderless; -// TODO: remove NSWindowStyleMaskTexturedBackground. -// https://github.com/electron/electron/issues/43125 -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - if (minimizable) styleMask |= NSWindowStyleMaskMiniaturizable; if (closable) @@ -179,9 +174,11 @@ NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options, if (resizable) styleMask |= NSWindowStyleMaskResizable; +// TODO: remove NSWindowStyleMaskTexturedBackground. +// https://github.com/electron/electron/issues/43125 #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" - if (windowType == "textured" || transparent() || !has_frame()) { + if (windowType == "textured" && (transparent() || !has_frame())) { util::EmitWarning( "The 'textured' window type is deprecated and will be removed", "DeprecationWarning"); @@ -189,9 +186,6 @@ NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options, } #pragma clang diagnostic pop -// -Wdeprecated-declarations -#pragma clang diagnostic pop - // Create views::Widget and assign window_ with it. // TODO(zcbenz): Get rid of the window_ in future. views::Widget::InitParams params(
chore
e57b69f106ae9c53a527038db4e8222692fa0ce7
Calvin
2025-01-13 15:15:24
docs: correct breaking changes versions (#45173)
diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md index 4c93781f29..7add55a43a 100644 --- a/docs/breaking-changes.md +++ b/docs/breaking-changes.md @@ -12,7 +12,7 @@ This document uses the following convention to categorize breaking changes: * **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release. * **Removed:** An API or feature was removed, and is no longer supported by Electron. -## Planned Breaking API Changes (34.0) +## Planned Breaking API Changes (35.0) ### Deprecated: `level`, `message`, `line`, and `sourceId` arguments in `console-message` event on `WebContents` @@ -29,6 +29,14 @@ webContents.on('console-message', ({ level, message, lineNumber, sourceId, frame Additionally, `level` is now a string with possible values of `info`, `warning`, `error`, and `debug`. +## Planned Breaking API Changes (34.0) + +### Behavior Changed: menu bar will be hidden during fullscreen on Windows + +This brings the behavior to parity with Linux. Prior behavior: Menu bar is still visible during fullscreen on Windows. New behavior: Menu bar is hidden during fullscreen on Windows. + +**Correction**: This was previously listed as a breaking change in Electron 33, but was first released in Electron 34. + ## Planned Breaking API Changes (33.0) ### Behavior Changed: frame properties may retrieve detached WebFrameMain instances or none at all @@ -86,10 +94,6 @@ mainWindow.loadURL('data:text/html,<script src="loaded-from-dataurl.js"></script mainWindow.loadURL('other://index.html') ``` -### Behavior Changed: menu bar will be hidden during fullscreen on Windows - -This brings the behavior to parity with Linux. Prior behavior: Menu bar is still visible during fullscreen on Windows. New behavior: Menu bar is hidden during fullscreen on Windows. - ### Behavior Changed: `webContents` property on `login` on `app` The `webContents` property in the `login` event from `app` will be `null`
docs
a208d45aca3b19fb661c630880451e26d46c92a6
Bruno Henrique da Silva
2024-01-02 15:59:47
fix: titlebar incorrectly displayed on frameless windows (#40749) * fix: titlebar incorrectly displayed on frameless windows * fix: enable transparency for Mica windows * Refactor ShouldWindowContentsBeTransparent --------- Co-authored-by: clavin <[email protected]>
diff --git a/patches/chromium/fix_activate_background_material_on_windows.patch b/patches/chromium/fix_activate_background_material_on_windows.patch index d63c73f064..06e2c43636 100644 --- a/patches/chromium/fix_activate_background_material_on_windows.patch +++ b/patches/chromium/fix_activate_background_material_on_windows.patch @@ -1,19 +1,23 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: clavin <[email protected]> -Date: Wed, 30 Aug 2023 18:15:36 -0700 +Date: Mon, 11 Dec 2023 20:43:34 -0300 Subject: fix: activate background material on windows This patch adds a condition to the HWND message handler to allow windows with translucent background materials to become activated. +It also ensures the lParam of WM_NCACTIVATE is set to -1 so as to not repaint +the client area, which can lead to a title bar incorrectly being displayed in +frameless windows. + This patch likely can't be upstreamed as-is, as Chromium doesn't have this use case in mind currently. diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc -index 23905a6b7f739ff3c6f391f984527ef5d2ed0bd9..ee72bad1b884677b02cc2f86ea307742e5528bad 100644 +index 23905a6b7f739ff3c6f391f984527ef5d2ed0bd9..aed8894a5514fddfc8d15b8fb4ae611fa4493b6f 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc -@@ -901,7 +901,7 @@ void HWNDMessageHandler::FrameTypeChanged() { +@@ -901,13 +901,13 @@ void HWNDMessageHandler::FrameTypeChanged() { void HWNDMessageHandler::PaintAsActiveChanged() { if (!delegate_->HasNonClientView() || !delegate_->CanActivate() || @@ -22,3 +26,34 @@ index 23905a6b7f739ff3c6f391f984527ef5d2ed0bd9..ee72bad1b884677b02cc2f86ea307742 (delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN)) { return; } + + DefWindowProcWithRedrawLock(WM_NCACTIVATE, delegate_->ShouldPaintAsActive(), +- 0); ++ delegate_->HasFrame() ? 0 : -1); + } + + void HWNDMessageHandler::SetWindowIcons(const gfx::ImageSkia& window_icon, +@@ -2254,17 +2254,18 @@ LRESULT HWNDMessageHandler::OnNCActivate(UINT message, + if (IsVisible()) + delegate_->SchedulePaint(); + +- // Calling DefWindowProc is only necessary if there's a system frame being +- // drawn. Otherwise it can draw an incorrect title bar and cause visual +- // corruption. +- if (!delegate_->HasFrame() || ++ // If the window is translucent, it may have the Mica background. ++ // In that case, it's necessary to call |DefWindowProc|, but we can ++ // pass -1 in the lParam to prevent any non-client area elements from ++ // being displayed. ++ if ((!delegate_->HasFrame() && !is_translucent_) || + delegate_->GetFrameMode() == FrameMode::CUSTOM_DRAWN) { + SetMsgHandled(TRUE); + return TRUE; + } + + return DefWindowProcWithRedrawLock(WM_NCACTIVATE, paint_as_active || active, +- 0); ++ delegate_->HasFrame() ? 0 : -1); + } + + LRESULT HWNDMessageHandler::OnNCCalcSize(BOOL mode, LPARAM l_param) { diff --git a/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc b/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc index d60675f31f..e9dab479ab 100644 --- a/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc +++ b/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc @@ -135,12 +135,12 @@ void ElectronDesktopWindowTreeHostWin::OnNativeThemeUpdated( bool ElectronDesktopWindowTreeHostWin::ShouldWindowContentsBeTransparent() const { - // Window should be marked as opaque if no transparency setting has been set, - // otherwise videos rendered in the window will trigger a DirectComposition - // redraw for every frame. + // Window should be marked as opaque if no transparency setting has been + // set, otherwise animations or videos rendered in the window will trigger a + // DirectComposition redraw for every frame. // https://github.com/electron/electron/pull/39895 return native_window_view_->GetOpacity() < 1.0 || - native_window_view_->transparent(); + native_window_view_->IsTranslucent(); } } // namespace electron
fix
5abefc5dc3e591973bdec20f78acc34baa84cf2c
Shelley Vohr
2024-06-12 22:12:30
build: use `GN_EXTRA_ARGS` on macOS (#42473) * build: use GN_EXTRA_ARGS on macOS * Switch back to main
diff --git a/.github/workflows/config/release/arm64/evm.mas.json b/.github/workflows/config/release/arm64/evm.mas.json deleted file mode 100644 index d6af529f31..0000000000 --- a/.github/workflows/config/release/arm64/evm.mas.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "root": "/Users/runner/work/electron/electron/", - "remotes": { - "electron": { - "origin": "https://github.com/electron/electron.git" - } - }, - "gen": { - "args": [ - "import(\"//electron/build/args/release.gn\")", - "use_remoteexec = true", - "target_cpu = \"arm64\"", - "is_mas_build = true" - ], - "out": "Default" - }, - "env": { - "CHROMIUM_BUILDTOOLS_PATH": "/Users/runner/work/electron/electron/src/buildtools", - "GIT_CACHE_PATH": "/Users/runner/work/electron/electron/.git-cache" - }, - "$schema": "file:///home/builduser/.electron_build_tools/evm-config.schema.json", - "configValidationLevel": "strict", - "reclient": "remote_exec", - "goma": "none", - "preserveXcode": 5 -} diff --git a/.github/workflows/config/release/x64/evm.mas.json b/.github/workflows/config/release/x64/evm.mas.json deleted file mode 100644 index a2f4fc551e..0000000000 --- a/.github/workflows/config/release/x64/evm.mas.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "root": "/Users/runner/work/electron/electron/", - "remotes": { - "electron": { - "origin": "https://github.com/electron/electron.git" - } - }, - "gen": { - "args": [ - "import(\"//electron/build/args/release.gn\")", - "use_remoteexec = true", - "target_cpu = \"x64\"", - "is_mas_build = true" - ], - "out": "Default" - }, - "env": { - "CHROMIUM_BUILDTOOLS_PATH": "/Users/runner/work/electron/electron/src/buildtools", - "GIT_CACHE_PATH": "/Users/runner/work/electron/electron/.git-cache" - }, - "$schema": "file:///home/builduser/.electron_build_tools/evm-config.schema.json", - "configValidationLevel": "strict", - "reclient": "remote_exec", - "goma": "none", - "preserveXcode": 5 -} diff --git a/.github/workflows/config/testing/arm64/evm.mas.json b/.github/workflows/config/testing/arm64/evm.mas.json deleted file mode 100644 index 4d2ae3b327..0000000000 --- a/.github/workflows/config/testing/arm64/evm.mas.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "root": "/Users/runner/work/electron/electron/", - "remotes": { - "electron": { - "origin": "https://github.com/electron/electron.git" - } - }, - "gen": { - "args": [ - "import(\"//electron/build/args/testing.gn\")", - "use_remoteexec = true", - "is_mas_build = true" - ], - "out": "Default" - }, - "env": { - "CHROMIUM_BUILDTOOLS_PATH": "/Users/runner/work/electron/electron/src/buildtools", - "GIT_CACHE_PATH": "/Users/runner/work/electron/electron/.git-cache" - }, - "$schema": "file:///home/builduser/.electron_build_tools/evm-config.schema.json", - "configValidationLevel": "strict", - "reclient": "remote_exec", - "goma": "none", - "preserveXcode": 5 -} diff --git a/.github/workflows/config/testing/x64/evm.mas.json b/.github/workflows/config/testing/x64/evm.mas.json deleted file mode 100644 index bdc3a60ca0..0000000000 --- a/.github/workflows/config/testing/x64/evm.mas.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "root": "/Users/runner/work/electron/electron/", - "remotes": { - "electron": { - "origin": "https://github.com/electron/electron.git" - } - }, - "gen": { - "args": [ - "import(\"//electron/build/args/testing.gn\")", - "use_remoteexec = true", - "target_cpu = \"x64\"", - "is_mas_build = true" - ], - "out": "Default" - }, - "env": { - "CHROMIUM_BUILDTOOLS_PATH": "/Users/runner/work/electron/electron/src/buildtools", - "GIT_CACHE_PATH": "/Users/runner/work/electron/electron/.git-cache" - }, - "$schema": "file:///home/builduser/.electron_build_tools/evm-config.schema.json", - "configValidationLevel": "strict", - "reclient": "remote_exec", - "goma": "none", - "preserveXcode": 5 -} diff --git a/.github/workflows/macos-pipeline.yml b/.github/workflows/macos-pipeline.yml index 7b83bb121f..64572ca573 100644 --- a/.github/workflows/macos-pipeline.yml +++ b/.github/workflows/macos-pipeline.yml @@ -41,7 +41,7 @@ env: ELECTRON_GITHUB_TOKEN: ${{ secrets.ELECTRON_GITHUB_TOKEN }} GN_CONFIG: ${{ inputs.gn-config }} # Disable pre-compiled headers to reduce out size - only useful for rebuilds - GN_BUILDFLAG_ARGS: 'enable_precompiled_headers = false' + GN_BUILDFLAG_ARGS: 'enable_precompiled_headers=false' GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac' # Only disable this in the Asan build CHECK_DIST_MANIFEST: true @@ -212,7 +212,6 @@ jobs: npm i -g @electron/build-tools e auto-update disable e init --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ matrix.build-arch }} - e use ${{ inputs.gn-build-type }} - name: Checkout Electron uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 with: @@ -553,11 +552,11 @@ jobs: with: name: generated_artifacts_darwin_${{ env.TARGET_ARCH }} path: ./generated_artifacts_darwin_${{ env.TARGET_ARCH }} - - name: Create MAS Config + - name: Set GN_EXTRA_ARGS for MAS Build run: | - mv src/electron/.github/workflows/config/${{ inputs.gn-build-type }}/${{ matrix.build-arch }}/evm.mas.json $HOME/.electron_build_tools/configs/evm.mas.json echo "MAS_BUILD=true" >> $GITHUB_ENV - e use mas + GN_EXTRA_ARGS='is_mas_build=true' + echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV - name: Build Electron (mas) run: | rm -rf "src/out/Default/Electron Framework.framework" @@ -660,7 +659,7 @@ jobs: export BUILD_TOOLS_SHA=ef894bc3cfa99d84a3b731252da0f83f500e4032 npm i -g @electron/build-tools e auto-update disable - e init --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} + e init --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ matrix.target-arch }} - name: Checkout Electron uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 with:
build
38a7da692aaae01dae97e96b7a5eb648765efe33
Shelley Vohr
2022-09-15 00:10:16
chore: make macOS spellchecker fns formal no-ops (#35514) * chore: make macOS spellchecker fns formal no-ops * docs: correct no-op note * test: add no-op specs
diff --git a/docs/api/session.md b/docs/api/session.md index c014ff09f7..4a578d6263 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -986,7 +986,7 @@ Returns `string[]` - An array of language codes the spellchecker is enabled for. will fallback to using `en-US`. By default on launch if this setting is an empty list Electron will try to populate this setting with the current OS locale. This setting is persisted across restarts. -**Note:** On macOS the OS spellchecker is used and has its own list of languages. This API is a no-op on macOS. +**Note:** On macOS the OS spellchecker is used and has its own list of languages. On macOS, this API will return whichever languages have been configured by the OS. #### `ses.setSpellCheckerDictionaryDownloadURL(url)` diff --git a/shell/browser/api/electron_api_session.cc b/shell/browser/api/electron_api_session.cc index 90fdc88f7a..f03e00f537 100644 --- a/shell/browser/api/electron_api_session.cc +++ b/shell/browser/api/electron_api_session.cc @@ -1043,6 +1043,7 @@ base::Value Session::GetSpellCheckerLanguages() { void Session::SetSpellCheckerLanguages( gin_helper::ErrorThrower thrower, const std::vector<std::string>& languages) { +#if !BUILDFLAG(IS_MAC) base::Value::List language_codes; for (const std::string& lang : languages) { std::string code = spellcheck::GetCorrespondingSpellCheckLanguage(lang); @@ -1058,10 +1059,12 @@ void Session::SetSpellCheckerLanguages( // Enable spellcheck if > 0 languages, disable if no languages set browser_context_->prefs()->SetBoolean(spellcheck::prefs::kSpellCheckEnable, !languages.empty()); +#endif } void SetSpellCheckerDictionaryDownloadURL(gin_helper::ErrorThrower thrower, const GURL& url) { +#if !BUILDFLAG(IS_MAC) if (!url.is_valid()) { thrower.ThrowError( "The URL you provided to setSpellCheckerDictionaryDownloadURL is not a " @@ -1069,6 +1072,7 @@ void SetSpellCheckerDictionaryDownloadURL(gin_helper::ErrorThrower thrower, return; } SpellcheckHunspellDictionary::SetBaseDownloadURL(url); +#endif } v8::Local<v8::Promise> Session::ListWordsInSpellCheckerDictionary() { diff --git a/spec/spellchecker-spec.ts b/spec/spellchecker-spec.ts index f5159cfe4d..fcd0042f3f 100644 --- a/spec/spellchecker-spec.ts +++ b/spec/spellchecker-spec.ts @@ -212,6 +212,44 @@ ifdescribe(features.isBuiltinSpellCheckerEnabled())('spellchecker', function () }); }); + describe('ses.setSpellCheckerLanguages', () => { + const isMac = process.platform === 'darwin'; + + ifit(isMac)('should be a no-op when setSpellCheckerLanguages is called on macOS', () => { + expect(() => { + w.webContents.session.setSpellCheckerLanguages(['i-am-a-nonexistent-language']); + }).to.not.throw(); + }); + + ifit(!isMac)('should throw when a bad language is passed', () => { + expect(() => { + w.webContents.session.setSpellCheckerLanguages(['i-am-a-nonexistent-language']); + }).to.throw(/Invalid language code provided: "i-am-a-nonexistent-language" is not a valid language code/); + }); + + ifit(!isMac)('should not throw when a recognized language is passed', () => { + expect(() => { + w.webContents.session.setSpellCheckerLanguages(['es']); + }).to.not.throw(); + }); + }); + + describe('SetSpellCheckerDictionaryDownloadURL', () => { + const isMac = process.platform === 'darwin'; + + ifit(isMac)('should be a no-op when a bad url is passed on macOS', () => { + expect(() => { + w.webContents.session.setSpellCheckerDictionaryDownloadURL('i-am-not-a-valid-url'); + }).to.not.throw(); + }); + + ifit(!isMac)('should throw when a bad url is passed', () => { + expect(() => { + w.webContents.session.setSpellCheckerDictionaryDownloadURL('i-am-not-a-valid-url'); + }).to.throw(/The URL you provided to setSpellCheckerDictionaryDownloadURL is not a valid URL/); + }); + }); + describe('ses.removeWordFromSpellCheckerDictionary', () => { it('should successfully remove words to custom dictionary', async () => { const result1 = ses.addWordToSpellCheckerDictionary('foobar');
chore
46adb0a3a9f1fa60ee2bb140f08894543777256a
tuanzijiang
2024-04-22 21:50:55
fix: offscreen rendering does not paint after gpu process crashed (#41904) Co-authored-by: zhangqi.67 <[email protected]>
diff --git a/shell/browser/osr/osr_render_widget_host_view.cc b/shell/browser/osr/osr_render_widget_host_view.cc index efeecef961..afe4c5ee56 100644 --- a/shell/browser/osr/osr_render_widget_host_view.cc +++ b/shell/browser/osr/osr_render_widget_host_view.cc @@ -230,6 +230,7 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView( ResizeRootLayer(false); render_widget_host_->SetView(this); + render_widget_host_->render_frame_metadata_provider()->AddObserver(this); if (content::GpuDataManager::GetInstance()->HardwareAccelerationEnabled()) { video_consumer_ = std::make_unique<OffScreenVideoConsumer>( @@ -240,7 +241,21 @@ OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView( } } +void OffScreenRenderWidgetHostView::OnLocalSurfaceIdChanged( + const cc::RenderFrameMetadata& metadata) { + if (metadata.local_surface_id) { + bool changed = delegated_frame_host_allocator_.UpdateFromChild( + *metadata.local_surface_id); + + if (changed) { + ResizeRootLayer(true); + } + } +} + OffScreenRenderWidgetHostView::~OffScreenRenderWidgetHostView() { + render_widget_host_->render_frame_metadata_provider()->RemoveObserver(this); + // Marking the DelegatedFrameHost as removed from the window hierarchy is // necessary to remove all connections to its old ui::Compositor. if (is_showing_) diff --git a/shell/browser/osr/osr_render_widget_host_view.h b/shell/browser/osr/osr_render_widget_host_view.h index fec8525118..b674f7cfbc 100644 --- a/shell/browser/osr/osr_render_widget_host_view.h +++ b/shell/browser/osr/osr_render_widget_host_view.h @@ -59,9 +59,11 @@ typedef base::RepeatingCallback<void(const gfx::Rect&, const SkBitmap&)> OnPaintCallback; typedef base::RepeatingCallback<void(const gfx::Rect&)> OnPopupPaintCallback; -class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, - public ui::CompositorDelegate, - public OffscreenViewProxyObserver { +class OffScreenRenderWidgetHostView + : public content::RenderWidgetHostViewBase, + public content::RenderFrameMetadataProvider::Observer, + public ui::CompositorDelegate, + public OffscreenViewProxyObserver { public: OffScreenRenderWidgetHostView(bool transparent, bool painting, @@ -175,6 +177,15 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, RenderWidgetHostViewBase* target_view, gfx::PointF* transformed_point) override; + // RenderFrameMetadataProvider::Observer: + void OnRenderFrameMetadataChangedBeforeActivation( + const cc::RenderFrameMetadata& metadata) override {} + void OnRenderFrameMetadataChangedAfterActivation( + base::TimeTicks activation_time) override {} + void OnRenderFrameSubmission() override {} + void OnLocalSurfaceIdChanged( + const cc::RenderFrameMetadata& metadata) override; + // ui::CompositorDelegate: bool IsOffscreen() const override; std::unique_ptr<viz::HostDisplayClient> CreateHostDisplayClient(
fix
2029224a845bb0751fb8b092ab28c109821e1715
David Sanders
2023-11-21 22:20:34
ci: trigger Slack workflow on backport requested (#40487)
diff --git a/.github/workflows/pull-request-labeled.yml b/.github/workflows/pull-request-labeled.yml index d56be56a18..24331fbab0 100644 --- a/.github/workflows/pull-request-labeled.yml +++ b/.github/workflows/pull-request-labeled.yml @@ -8,6 +8,20 @@ permissions: contents: read jobs: + pull-request-labeled-backport-requested: + name: backport/requested label added + if: github.event.label.name == 'backport/requested 🗳' + runs-on: ubuntu-latest + steps: + - name: Trigger Slack workflow + uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 # v1.24.0 + with: + payload: | + { + "url": "${{ github.event.pull_request.html_url }}" + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.BACKPORT_REQUESTED_SLACK_WEBHOOK_URL }} pull-request-labeled-deprecation-review-complete: name: deprecation-review/complete label added if: github.event.label.name == 'deprecation-review/complete ✅'
ci
f7c0a29d89155fff1f0a281f0cb6280c695707c8
Shelley Vohr
2023-06-14 20:06:46
build: update to latest TypeScript (#38763)
diff --git a/lib/browser/guest-view-manager.ts b/lib/browser/guest-view-manager.ts index 03f786a30a..eda3d9aff5 100644 --- a/lib/browser/guest-view-manager.ts +++ b/lib/browser/guest-view-manager.ts @@ -8,7 +8,7 @@ import { IPC_MESSAGES } from '@electron/internal/common/ipc-messages'; interface GuestInstance { elementInstanceId: number; - visibilityState?: VisibilityState; + visibilityState?: DocumentVisibilityState; embedder: Electron.WebContents; guest: Electron.WebContents; } @@ -229,7 +229,7 @@ const watchEmbedder = function (embedder: Electron.WebContents) { watchedEmbedders.add(embedder); // Forward embedder window visibility change events to guest - const onVisibilityChange = function (visibilityState: VisibilityState) { + const onVisibilityChange = function (visibilityState: DocumentVisibilityState) { for (const guestInstance of guestInstances.values()) { guestInstance.visibilityState = visibilityState; if (guestInstance.embedder === embedder) { diff --git a/lib/common/deprecate.ts b/lib/common/deprecate.ts index 5d71548561..94f2e80acd 100644 --- a/lib/common/deprecate.ts +++ b/lib/common/deprecate.ts @@ -110,7 +110,7 @@ export function removeProperty<T, K extends (keyof T & string)>(object: T, remov } // change the name of a property -export function renameProperty<T, K extends (keyof T & string)>(object: T, oldName: string, newName: K): T { +export function renameProperty<T extends Object, K extends (keyof T & string)>(object: T, oldName: string, newName: K): T { const warn = warnOnce(oldName, newName); // if the new property isn't there yet, diff --git a/lib/renderer/init.ts b/lib/renderer/init.ts index c8fb8bcfb7..6abdfe027d 100644 --- a/lib/renderer/init.ts +++ b/lib/renderer/init.ts @@ -122,7 +122,10 @@ if (nodeIntegration) { } } -const { preloadPaths } = ipcRendererUtils.invokeSync(IPC_MESSAGES.BROWSER_NONSANDBOX_LOAD); +const { preloadPaths } = ipcRendererUtils.invokeSync<{ + preloadPaths: string[] +}>(IPC_MESSAGES.BROWSER_NONSANDBOX_LOAD); + // Load the preload scripts. for (const preloadScript of preloadPaths) { try { diff --git a/lib/renderer/window-setup.ts b/lib/renderer/window-setup.ts index 6c9f15a2d4..9dc539edb6 100644 --- a/lib/renderer/window-setup.ts +++ b/lib/renderer/window-setup.ts @@ -30,7 +30,7 @@ export const windowSetup = (isWebView: boolean, isHiddenPage: boolean) => { let cachedVisibilityState = isHiddenPage ? 'hidden' : 'visible'; // Subscribe to visibilityState changes. - ipcRendererInternal.on(IPC_MESSAGES.GUEST_INSTANCE_VISIBILITY_CHANGE, function (_event, visibilityState: VisibilityState) { + ipcRendererInternal.on(IPC_MESSAGES.GUEST_INSTANCE_VISIBILITY_CHANGE, function (_event, visibilityState: DocumentVisibilityState) { if (cachedVisibilityState !== visibilityState) { cachedVisibilityState = visibilityState; document.dispatchEvent(new Event('visibilitychange')); diff --git a/lib/sandboxed_renderer/init.ts b/lib/sandboxed_renderer/init.ts index 913b57480c..555c7d35cd 100644 --- a/lib/sandboxed_renderer/init.ts +++ b/lib/sandboxed_renderer/init.ts @@ -30,7 +30,17 @@ Object.setPrototypeOf(process, EventEmitter.prototype); const { ipcRendererInternal } = require('@electron/internal/renderer/ipc-renderer-internal') as typeof ipcRendererInternalModule; const ipcRendererUtils = require('@electron/internal/renderer/ipc-renderer-internal-utils') as typeof ipcRendererUtilsModule; -const { preloadScripts, process: processProps } = ipcRendererUtils.invokeSync(IPC_MESSAGES.BROWSER_SANDBOX_LOAD); +const { + preloadScripts, + process: processProps +} = ipcRendererUtils.invokeSync<{ + preloadScripts: { + preloadPath: string; + preloadSrc: string | null; + preloadError: null | Error; + }[]; + process: NodeJS.Process; +}>(IPC_MESSAGES.BROWSER_SANDBOX_LOAD); const electron = require('electron'); diff --git a/package.json b/package.json index cda8388fc2..58738bfebc 100644 --- a/package.json +++ b/package.json @@ -70,7 +70,7 @@ "timers-browserify": "1.4.2", "ts-loader": "^8.0.2", "ts-node": "6.2.0", - "typescript": "^4.5.5", + "typescript": "^5.1.2", "url": "^0.11.0", "webpack": "^5.76.0", "webpack-cli": "^4.10.0", diff --git a/yarn.lock b/yarn.lock index 6cc2cc1d5e..71750a1098 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6645,10 +6645,10 @@ typedarray@^0.0.6: resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= -typescript@^4.5.5: - version "4.5.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3" - integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA== +typescript@^5.1.2: + version "5.1.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.1.3.tgz#8d84219244a6b40b6fb2b33cc1c062f715b9e826" + integrity sha512-XH627E9vkeqhlZFQuL+UsyAXEnibT0kWR2FWONlr4sTjvxyJYnyefgrkyECLzM5NenmKzRAy2rR/OlYLA1HkZw== uc.micro@^1.0.1, uc.micro@^1.0.5: version "1.0.6"
build
6486ce8191d4d02ed90ea8c1e034c3b57ae32cb0
Shelley Vohr
2025-02-05 12:47:54
build: remove debugger agent timeout patch (#45457)
diff --git a/patches/node/.patches b/patches/node/.patches index e6447a2d98..92738d2a80 100644 --- a/patches/node/.patches +++ b/patches/node/.patches @@ -8,7 +8,6 @@ refactor_allow_embedder_overriding_of_internal_fs_calls.patch chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch fix_handle_boringssl_and_openssl_incompatibilities.patch fix_crypto_tests_to_run_with_bssl.patch -fix_account_for_debugger_agent_race_condition.patch feat_add_uv_loop_interrupt_on_io_change_option_to_uv_loop_configure.patch support_v8_sandboxed_pointers.patch build_ensure_native_module_compilation_fails_if_not_using_a_new.patch diff --git a/patches/node/fix_account_for_debugger_agent_race_condition.patch b/patches/node/fix_account_for_debugger_agent_race_condition.patch deleted file mode 100644 index cd5a3eacd4..0000000000 --- a/patches/node/fix_account_for_debugger_agent_race_condition.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Shelley Vohr <[email protected]> -Date: Thu, 10 Jun 2021 15:15:35 +0200 -Subject: fix: account for debugger agent race condition - -In Electron the debugger agent hasn't necessarily been enabled by the -time the inspect prompt displays, leading to "Debugger agent is not enabled" -errors. This is remedied by adding a small timeout to the test. - -We'll either upstream this or figure out a better solution. - -diff --git a/test/parallel/test-debugger-address.mjs b/test/parallel/test-debugger-address.mjs -index eab99c9b0e2fb387ef9a716396e41c7fc93e93bc..ef8b20a60df88a0a412c309f597e1b1f652fef07 100644 ---- a/test/parallel/test-debugger-address.mjs -+++ b/test/parallel/test-debugger-address.mjs -@@ -56,6 +56,7 @@ function launchTarget(...args) { - const { childProc, host, port } = await launchTarget('--inspect=0', script); - target = childProc; - cli = startCLI([`${host || '127.0.0.1'}:${port}`]); -+ await new Promise(resolve => setTimeout(resolve, 1000)); - await cli.waitForPrompt(); - await cli.command('sb("alive.js", 3)'); - await cli.waitFor(/break/); -diff --git a/test/parallel/test-debugger-random-port-with-inspect-port.js b/test/parallel/test-debugger-random-port-with-inspect-port.js -index 3acc6bdd733eb002a2592960528bb04eebb2dc60..a9f2d29327464281c10d4c2210277eab47c9a262 100644 ---- a/test/parallel/test-debugger-random-port-with-inspect-port.js -+++ b/test/parallel/test-debugger-random-port-with-inspect-port.js -@@ -13,6 +13,7 @@ const script = fixtures.path('debugger', 'three-lines.js'); - const cli = startCLI(['--inspect-port=0', script]); - - (async () => { -+ await new Promise(resolve => setTimeout(resolve, 1000)); - await cli.waitForInitialBreak(); - await cli.waitForPrompt(); - assert.match(cli.output, /debug>/, 'prints a prompt'); -diff --git a/test/sequential/test-debugger-pid.js b/test/sequential/test-debugger-pid.js -index 99062149dfe3374b86439850e0655383e2bad662..78c173f5073818fae7d46413842cb7790130c3f5 100644 ---- a/test/sequential/test-debugger-pid.js -+++ b/test/sequential/test-debugger-pid.js -@@ -20,6 +20,7 @@ const runTest = async () => { - await cli.command('sb("alive.js", 3)'); - await cli.waitFor(/break/); - await cli.waitForPrompt(); -+ await new Promise(resolve => setTimeout(resolve, 1000)); - assert.match( - cli.output, - /> 3 {3}\+\+x;/,
build
09bab60a9eb110b031330545885bf07205492a1c
David Sanders
2023-10-18 02:32:10
docs: fix represented file fiddle (#40233)
diff --git a/docs/fiddles/features/represented-file/main.js b/docs/fiddles/features/represented-file/main.js index 183b3fc3d1..6898a110f9 100644 --- a/docs/fiddles/features/represented-file/main.js +++ b/docs/fiddles/features/represented-file/main.js @@ -7,14 +7,20 @@ function createWindow () { height: 600 }) + win.setRepresentedFilename(os.homedir()) + win.setDocumentEdited(true) + win.loadFile('index.html') } app.whenReady().then(() => { - const win = new BrowserWindow() + createWindow() - win.setRepresentedFilename(os.homedir()) - win.setDocumentEdited(true) + app.on('activate', () => { + if (BrowserWindow.getAllWindows().length === 0) { + createWindow() + } + }) }) app.on('window-all-closed', () => { @@ -22,9 +28,3 @@ app.on('window-all-closed', () => { app.quit() } }) - -app.on('activate', () => { - if (BrowserWindow.getAllWindows().length === 0) { - createWindow() - } -})
docs
8be458d1a2e65a760f5be249cea83302edc49bd2
Samuel Attard
2024-09-22 22:57:23
build: enable dependabot on supported branches (#43755)
diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 4c45cc07f4..6f212e561d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -10,3 +10,91 @@ updates: labels: - "no-backport" - "semver/none" + target-branch: main + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + labels: + - "no-backport" + - "semver/none" + target-branch: 33-x-y + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + labels: + - "no-backport" + - "semver/none" + target-branch: 32-x-y + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + labels: + - "no-backport" + - "semver/none" + target-branch: 31-x-y + - package-ecosystem: github-actions + directory: / + schedule: + interval: weekly + labels: + - "no-backport" + - "semver/none" + target-branch: 30-x-y + - package-ecosystem: npm + directories: + - / + - /spec + - /npm + schedule: + interval: daily + labels: + - "no-backport" + open-pull-requests-limit: 5 + target-branch: 33-x-y + - package-ecosystem: npm + directories: + - / + - /spec + - /npm + schedule: + interval: daily + labels: + - "no-backport" + open-pull-requests-limit: 5 + target-branch: main + - package-ecosystem: npm + directories: + - / + - /spec + - /npm + schedule: + interval: daily + labels: + - "no-backport" + open-pull-requests-limit: 5 + target-branch: 32-x-y + - package-ecosystem: npm + directories: + - / + - /spec + - /npm + schedule: + interval: daily + labels: + - "no-backport" + open-pull-requests-limit: 5 + target-branch: 31-x-y + - package-ecosystem: npm + directories: + - / + - /spec + - /npm + schedule: + interval: daily + labels: + - "no-backport" + open-pull-requests-limit: 5 + target-branch: 30-x-y \ No newline at end of file
build
8f0dffea9ed0a77b63ba5263adf58e1bad049d18
Niklas Wenzel
2024-09-16 11:32:03
docs: document View.removeChildView edge case (#43673)
diff --git a/docs/api/view.md b/docs/api/view.md index 62c710626f..435367d278 100644 --- a/docs/api/view.md +++ b/docs/api/view.md @@ -55,6 +55,8 @@ it becomes the topmost view. * `view` View - Child view to remove. +If the view passed as a parameter is not a child of this view, this method is a no-op. + #### `view.setBounds(bounds)` * `bounds` [Rectangle](structures/rectangle.md) - New bounds of the View.
docs
ffcbc3203188bc999669b5d9241bb4552a9f2533
electron-appveyor-updater[bot]
2024-08-14 10:10:33
build: update appveyor image to latest version (#43318) Co-authored-by: electron-appveyor-updater[bot] <161660339+electron-appveyor-updater[bot]@users.noreply.github.com>
diff --git a/appveyor-woa.yml b/appveyor-woa.yml index 066aac07bc..d6000d91df 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-129.0.6652.0 +image: e-129.0.6654.0 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default diff --git a/appveyor.yml b/appveyor.yml index 7697b22f1a..2da889b5d6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-129.0.6652.0 +image: e-129.0.6654.0 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default
build
94f2722fa38a6638bf95cdd81fc03adf097e1ad6
Keeley Hammond
2024-09-04 17:18:57
build: don't run symbol generation on PS (#43554) fix: don't run symbol generation on PS
diff --git a/appveyor-woa.yml b/appveyor-woa.yml index 18449884f4..39c61f327f 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -174,8 +174,8 @@ for: if ($env:GN_CONFIG -eq 'release') { # Needed for msdia140.dll on 64-bit windows $env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin" - autoninja -C out/Default electron:electron_symbols } + - if "%GN_CONFIG%"=="release" ( autoninja -C out/Default electron:electron_symbols ) - ps: >- if ($env:GN_CONFIG -eq 'release') { python3 electron\script\zip-symbols.py diff --git a/appveyor.yml b/appveyor.yml index 4d85752b66..d92636c360 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -171,8 +171,8 @@ for: if ($env:GN_CONFIG -eq 'release') { # Needed for msdia140.dll on 64-bit windows $env:Path += ";$pwd\third_party\llvm-build\Release+Asserts\bin" - autoninja -C out/Default electron:electron_symbols } + - if "%GN_CONFIG%"=="release" ( autoninja -C out/Default electron:electron_symbols ) - ps: >- if ($env:GN_CONFIG -eq 'release') { python3 electron\script\zip-symbols.py
build
0e0a0bf724064400c117ba68e761818fd5b2ad30
Charles Kerr
2024-01-30 14:48:47
fix: avoid potential `CHECK()` failure in `DictionaryToRect()` (#41160) refactor: use gfx::Rect::Contains() instead of reinventing the wheel perf: use base::Value::FindInt() to avoid redundant map lookups
diff --git a/shell/browser/ui/inspectable_web_contents.cc b/shell/browser/ui/inspectable_web_contents.cc index 3bb01208a9..b69628e328 100644 --- a/shell/browser/ui/inspectable_web_contents.cc +++ b/shell/browser/ui/inspectable_web_contents.cc @@ -15,6 +15,7 @@ #include "base/json/string_escape.h" #include "base/memory/raw_ptr.h" #include "base/metrics/histogram.h" +#include "base/ranges/algorithm.h" #include "base/stl_util.h" #include "base/strings/pattern.h" #include "base/strings/string_number_conversions.h" @@ -108,32 +109,16 @@ base::Value::Dict RectToDictionary(const gfx::Rect& bounds) { } gfx::Rect DictionaryToRect(const base::Value::Dict& dict) { - const base::Value* found = dict.Find("x"); - int x = found ? found->GetInt() : 0; - - found = dict.Find("y"); - int y = found ? found->GetInt() : 0; - - found = dict.Find("width"); - int width = found ? found->GetInt() : 800; - - found = dict.Find("height"); - int height = found ? found->GetInt() : 600; - - return gfx::Rect(x, y, width, height); -} - -bool IsPointInRect(const gfx::Point& point, const gfx::Rect& rect) { - return point.x() > rect.x() && point.x() < (rect.width() + rect.x()) && - point.y() > rect.y() && point.y() < (rect.height() + rect.y()); + return gfx::Rect{dict.FindInt("x").value_or(0), dict.FindInt("y").value_or(0), + dict.FindInt("width").value_or(800), + dict.FindInt("height").value_or(600)}; } bool IsPointInScreen(const gfx::Point& point) { - for (const auto& display : display::Screen::GetScreen()->GetAllDisplays()) { - if (IsPointInRect(point, display.bounds())) - return true; - } - return false; + return base::ranges::any_of(display::Screen::GetScreen()->GetAllDisplays(), + [&point](auto const& display) { + return display.bounds().Contains(point); + }); } void SetZoomLevelForWebContents(content::WebContents* web_contents,
fix
13e601e35c43ad640fbe2bfea57e9a054f1dca4c
David Sanders
2024-02-28 21:36:56
ci: verified commits for appveyor update PR (#41470)
diff --git a/.github/workflows/update_appveyor_image.yml b/.github/workflows/update_appveyor_image.yml index 5eba50527a..3c53800c73 100644 --- a/.github/workflows/update_appveyor_image.yml +++ b/.github/workflows/update_appveyor_image.yml @@ -6,22 +6,23 @@ on: schedule: - cron: '0 8 * * 1-5' # runs 8:00 every business day (see https://crontab.guru) -permissions: - contents: write - pull-requests: write +permissions: {} jobs: bake-appveyor-image: name: Bake AppVeyor Image - permissions: - contents: write - pull-requests: write # to create a new PR with updated Appveyor images runs-on: ubuntu-latest steps: + - name: Generate GitHub App token + uses: electron/github-app-auth-action@384fd19694fe7b6dcc9a684746c6976ad78228ae # v1.1.1 + id: generate-token + with: + creds: ${{ secrets.APPVEYOR_UPDATER_GH_APP_CREDS }} - name: Checkout uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 with: fetch-depth: 0 + token: ${{ steps.generate-token.outputs.token }} - name: Yarn install run: | node script/yarn.js install --frozen-lockfile @@ -49,26 +50,24 @@ jobs: diff -w -B appveyor.yml appveyor2.yml > appveyor.diff || true patch -f appveyor.yml < appveyor.diff rm appveyor2.yml appveyor.diff + git add appveyor.yml - name: (Optionally) Generate Commit Diff for WOA if: ${{ env.APPVEYOR_IMAGE_VERSION }} run: | diff -w -B appveyor-woa.yml appveyor-woa2.yml > appveyor-woa.diff || true patch -f appveyor-woa.yml < appveyor-woa.diff rm appveyor-woa2.yml appveyor-woa.diff - - name: (Optionally) Commit and Pull Request + git add appveyor-woa.yml + - name: (Optionally) Commit to Branch if: ${{ env.APPVEYOR_IMAGE_VERSION }} - uses: peter-evans/create-pull-request@b1ddad2c994a25fbc81a28b3ec0e368bb2021c50 # v6.0.0 + uses: dsanders11/github-app-commit-action@1dd0a2d22c564461d3f598b6858856e8842d7a16 # v1.1.0 with: - token: ${{ secrets.GITHUB_TOKEN }} - commit-message: 'build: update appveyor image to latest version' - committer: GitHub <[email protected]> - author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com> - signoff: false - branch: bump-appveyor-image - delete-branch: true - reviewers: electron/wg-releases - title: 'build: update appveyor image to latest version' - labels: semver/none,no-backport - body: | - This PR updates appveyor.yml to the latest baked image, ${{ env.APPVEYOR_IMAGE_VERSION }}. - Notes: none + message: 'build: update appveyor image to latest version' + ref: bump-appveyor-image + token: ${{ steps.generate-token.outputs.token }} + - name: (Optionally) Create Pull Request + if: ${{ env.APPVEYOR_IMAGE_VERSION }} + run: | + printf "This PR updates appveyor.yml to the latest baked image, ${{ env.APPVEYOR_IMAGE_VERSION }}.\n\nNotes: none" | gh pr create --head bump-appveyor-image --reviewer electron/wg-releases --label no-backport --label semver/none --title 'build: update appveyor image to latest version' --body-file=- + env: + GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
ci
9e630eb66aaa237401f87a97ee114eef7e1a74cc
John Kleinschmidt
2024-01-25 15:26:21
build: remove unneeded dlls in Windows zip (#41120) * build: fixup zip manifest check on Windows * build: remove unused dlls
diff --git a/appveyor-woa.yml b/appveyor-woa.yml index b3fae14f32..fcb6690424 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -177,7 +177,12 @@ for: # built on CI. 7z a pdb.zip out\Default\*.pdb } - - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest + - ps: | + $manifest_file = "electron/script/zip_manifests/dist_zip.win.$env:TARGET_ARCH.manifest" + python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip $manifest_file + if ($LASTEXITCODE -ne 0) { + throw "Zip contains files not listed in the manifest $manifest_file" + } - ps: | cd C:\projects\src $missing_artifacts = $false diff --git a/appveyor.yml b/appveyor.yml index 661f545a2c..5e4811c363 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -174,7 +174,12 @@ for: # built on CI. 7z a pdb.zip out\Default\*.pdb } - - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest + - ps: | + $manifest_file = "electron/script/zip_manifests/dist_zip.win.$env:TARGET_ARCH.manifest" + python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip $manifest_file + if ($LASTEXITCODE -ne 0) { + throw "Zip contains files not listed in the manifest $manifest_file" + } - ps: | cd C:\projects\src $missing_artifacts = $false diff --git a/build/args/all.gn b/build/args/all.gn index bc448d238e..56589e30b2 100644 --- a/build/args/all.gn +++ b/build/args/all.gn @@ -24,6 +24,10 @@ enable_printing = true angle_enable_vulkan_validation_layers = false dawn_enable_vulkan_validation_layers = false +# Removes dxc dll's that are only used experimentally. +# See https://bugs.chromium.org/p/chromium/issues/detail?id=1474897 +dawn_use_built_dxc = false + # These are disabled because they cause the zip manifest to differ between # testing and release builds. # See https://chromium-review.googlesource.com/c/chromium/src/+/2774898.
build
892c9d78a394f256b361d019abd50d3f8c7a2366
Milan Burda
2024-01-10 23:23:35
chore: replace absl::optional<T> with std::optional<T> (#40928) * chore: replace absl::optional<T> with std::optional<T> * IWYU
diff --git a/shell/app/electron_main_delegate.cc b/shell/app/electron_main_delegate.cc index ad771f2900..19d01f471e 100644 --- a/shell/app/electron_main_delegate.cc +++ b/shell/app/electron_main_delegate.cc @@ -238,7 +238,7 @@ const char* const ElectronMainDelegate::kNonWildcardDomainNonPortSchemes[] = { const size_t ElectronMainDelegate::kNonWildcardDomainNonPortSchemesSize = std::size(kNonWildcardDomainNonPortSchemes); -absl::optional<int> ElectronMainDelegate::BasicStartupComplete() { +std::optional<int> ElectronMainDelegate::BasicStartupComplete() { auto* command_line = base::CommandLine::ForCurrentProcess(); #if BUILDFLAG(IS_WIN) @@ -311,7 +311,7 @@ absl::optional<int> ElectronMainDelegate::BasicStartupComplete() { ::switches::kDisableGpuMemoryBufferCompositorResources); #endif - return absl::nullopt; + return std::nullopt; } void ElectronMainDelegate::PreSandboxStartup() { @@ -398,7 +398,7 @@ void ElectronMainDelegate::SandboxInitialized(const std::string& process_type) { #endif } -absl::optional<int> ElectronMainDelegate::PreBrowserMain() { +std::optional<int> ElectronMainDelegate::PreBrowserMain() { // This is initialized early because the service manager reads some feature // flags and we need to make sure the feature list is initialized before the // service manager reads the features. @@ -408,7 +408,7 @@ absl::optional<int> ElectronMainDelegate::PreBrowserMain() { #if BUILDFLAG(IS_MAC) RegisterAtomCrApp(); #endif - return absl::nullopt; + return std::nullopt; } base::StringPiece ElectronMainDelegate::GetBrowserV8SnapshotFilename() { diff --git a/shell/app/electron_main_delegate.h b/shell/app/electron_main_delegate.h index 15cff1cc76..ccac19187d 100644 --- a/shell/app/electron_main_delegate.h +++ b/shell/app/electron_main_delegate.h @@ -34,10 +34,10 @@ class ElectronMainDelegate : public content::ContentMainDelegate { protected: // content::ContentMainDelegate: - absl::optional<int> BasicStartupComplete() override; + std::optional<int> BasicStartupComplete() override; void PreSandboxStartup() override; void SandboxInitialized(const std::string& process_type) override; - absl::optional<int> PreBrowserMain() override; + std::optional<int> PreBrowserMain() override; content::ContentClient* CreateContentClient() override; content::ContentBrowserClient* CreateContentBrowserClient() override; content::ContentGpuClient* CreateContentGpuClient() override; diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index ee434db917..1b3f213ff6 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -5,6 +5,7 @@ #include "shell/browser/api/electron_api_app.h" #include <memory> +#include <optional> #include <string> #include <utility> #include <vector> @@ -75,7 +76,6 @@ #include "shell/common/platform_util.h" #include "shell/common/thread_restrictions.h" #include "shell/common/v8_value_serializer.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/gfx/image/image.h" #if BUILDFLAG(IS_WIN) @@ -927,7 +927,7 @@ void App::SetAppPath(const base::FilePath& app_path) { #if !BUILDFLAG(IS_MAC) void App::SetAppLogsPath(gin_helper::ErrorThrower thrower, - absl::optional<base::FilePath> custom_path) { + std::optional<base::FilePath> custom_path) { if (custom_path.has_value()) { if (!custom_path->IsAbsolute()) { thrower.ThrowError("Path must be absolute"); @@ -1604,7 +1604,7 @@ void ConfigureHostResolver(v8::Isolate* isolate, // doh_config. std::vector<net::DnsOverHttpsServerConfig> servers; for (const std::string& server_template : secure_dns_server_strings) { - absl::optional<net::DnsOverHttpsServerConfig> server_config = + std::optional<net::DnsOverHttpsServerConfig> server_config = net::DnsOverHttpsServerConfig::FromString(server_template); if (!server_config.has_value()) { thrower.ThrowTypeError(std::string("not a valid DoH template: ") + diff --git a/shell/browser/api/electron_api_app.h b/shell/browser/api/electron_api_app.h index 082dc94152..c2f5eae50b 100644 --- a/shell/browser/api/electron_api_app.h +++ b/shell/browser/api/electron_api_app.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_APP_H_ #include <memory> +#include <optional> #include <string> #include <vector> @@ -180,7 +181,7 @@ class App : public ElectronBrowserClient::Delegate, void ChildProcessDisconnected(int pid); void SetAppLogsPath(gin_helper::ErrorThrower thrower, - absl::optional<base::FilePath> custom_path); + std::optional<base::FilePath> custom_path); // Get/Set the pre-defined path in PathService. base::FilePath GetPath(gin_helper::ErrorThrower thrower, diff --git a/shell/browser/api/electron_api_app_mac.mm b/shell/browser/api/electron_api_app_mac.mm index 90ca396fe8..5415c8cfac 100644 --- a/shell/browser/api/electron_api_app_mac.mm +++ b/shell/browser/api/electron_api_app_mac.mm @@ -17,7 +17,7 @@ namespace electron::api { void App::SetAppLogsPath(gin_helper::ErrorThrower thrower, - absl::optional<base::FilePath> custom_path) { + std::optional<base::FilePath> custom_path) { if (custom_path.has_value()) { if (!custom_path->IsAbsolute()) { thrower.ThrowError("Path must be absolute"); diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc index c05837938a..7b040f8cad 100644 --- a/shell/browser/api/electron_api_base_window.cc +++ b/shell/browser/api/electron_api_base_window.cc @@ -826,11 +826,11 @@ bool BaseWindow::GetWindowButtonVisibility() const { return window_->GetWindowButtonVisibility(); } -void BaseWindow::SetWindowButtonPosition(absl::optional<gfx::Point> position) { +void BaseWindow::SetWindowButtonPosition(std::optional<gfx::Point> position) { window_->SetWindowButtonPosition(std::move(position)); } -absl::optional<gfx::Point> BaseWindow::GetWindowButtonPosition() const { +std::optional<gfx::Point> BaseWindow::GetWindowButtonPosition() const { return window_->GetWindowButtonPosition(); } #endif diff --git a/shell/browser/api/electron_api_base_window.h b/shell/browser/api/electron_api_base_window.h index 42771d622f..2c2d0fdf57 100644 --- a/shell/browser/api/electron_api_base_window.h +++ b/shell/browser/api/electron_api_base_window.h @@ -7,6 +7,7 @@ #include <map> #include <memory> +#include <optional> #include <string> #include <vector> @@ -187,8 +188,8 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>, std::string GetAlwaysOnTopLevel() const; void SetWindowButtonVisibility(bool visible); bool GetWindowButtonVisibility() const; - void SetWindowButtonPosition(absl::optional<gfx::Point> position); - absl::optional<gfx::Point> GetWindowButtonPosition() const; + void SetWindowButtonPosition(std::optional<gfx::Point> position); + std::optional<gfx::Point> GetWindowButtonPosition() const; bool IsHiddenInMissionControl(); void SetHiddenInMissionControl(bool hidden); diff --git a/shell/browser/api/electron_api_content_tracing.cc b/shell/browser/api/electron_api_content_tracing.cc index 4a5f373b69..384a16e1b3 100644 --- a/shell/browser/api/electron_api_content_tracing.cc +++ b/shell/browser/api/electron_api_content_tracing.cc @@ -2,6 +2,7 @@ // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. +#include <optional> #include <set> #include <string> #include <utility> @@ -17,7 +18,6 @@ #include "shell/common/gin_helper/dictionary.h" #include "shell/common/gin_helper/promise.h" #include "shell/common/node_includes.h" -#include "third_party/abseil-cpp/absl/types/optional.h" using content::TracingController; @@ -58,18 +58,18 @@ namespace { using CompletionCallback = base::OnceCallback<void(const base::FilePath&)>; -absl::optional<base::FilePath> CreateTemporaryFileOnIO() { +std::optional<base::FilePath> CreateTemporaryFileOnIO() { base::FilePath temp_file_path; if (!base::CreateTemporaryFile(&temp_file_path)) - return absl::nullopt; - return absl::make_optional(std::move(temp_file_path)); + return std::nullopt; + return std::make_optional(std::move(temp_file_path)); } void StopTracing(gin_helper::Promise<base::FilePath> promise, - absl::optional<base::FilePath> file_path) { + std::optional<base::FilePath> file_path) { auto resolve_or_reject = base::BindOnce( [](gin_helper::Promise<base::FilePath> promise, - const base::FilePath& path, absl::optional<std::string> error) { + const base::FilePath& path, std::optional<std::string> error) { if (error) { promise.RejectWithErrorMessage(error.value()); } else { @@ -81,20 +81,20 @@ void StopTracing(gin_helper::Promise<base::FilePath> promise, auto* instance = TracingController::GetInstance(); if (!instance->IsTracing()) { std::move(resolve_or_reject) - .Run(absl::make_optional( + .Run(std::make_optional( "Failed to stop tracing - no trace in progress")); } else if (file_path) { auto split_callback = base::SplitOnceCallback(std::move(resolve_or_reject)); auto endpoint = TracingController::CreateFileEndpoint( *file_path, - base::BindOnce(std::move(split_callback.first), absl::nullopt)); + base::BindOnce(std::move(split_callback.first), std::nullopt)); if (!instance->StopTracing(endpoint)) { std::move(split_callback.second) - .Run(absl::make_optional("Failed to stop tracing")); + .Run(std::make_optional("Failed to stop tracing")); } } else { std::move(resolve_or_reject) - .Run(absl::make_optional( + .Run(std::make_optional( "Failed to create temporary file for trace data")); } } @@ -105,7 +105,7 @@ v8::Local<v8::Promise> StopRecording(gin_helper::Arguments* args) { base::FilePath path; if (args->GetNext(&path) && !path.empty()) { - StopTracing(std::move(promise), absl::make_optional(path)); + StopTracing(std::move(promise), std::make_optional(path)); } else { // use a temporary file. base::ThreadPool::PostTaskAndReplyWithResult( diff --git a/shell/browser/api/electron_api_cookies.cc b/shell/browser/api/electron_api_cookies.cc index 0606776e73..d166af491a 100644 --- a/shell/browser/api/electron_api_cookies.cc +++ b/shell/browser/api/electron_api_cookies.cc @@ -127,13 +127,13 @@ bool MatchesCookie(const base::Value::Dict& filter, if ((str = filter.FindString("domain")) && !MatchesDomain(*str, cookie.Domain())) return false; - absl::optional<bool> secure_filter = filter.FindBool("secure"); + std::optional<bool> secure_filter = filter.FindBool("secure"); if (secure_filter && *secure_filter != cookie.IsSecure()) return false; - absl::optional<bool> session_filter = filter.FindBool("session"); + std::optional<bool> session_filter = filter.FindBool("session"); if (session_filter && *session_filter == cookie.IsPersistent()) return false; - absl::optional<bool> httpOnly_filter = filter.FindBool("httpOnly"); + std::optional<bool> httpOnly_filter = filter.FindBool("httpOnly"); if (httpOnly_filter && *httpOnly_filter != cookie.IsHttpOnly()) return false; return true; @@ -161,7 +161,7 @@ void FilterCookieWithStatuses( } // Parse dictionary property to CanonicalCookie time correctly. -base::Time ParseTimeProperty(const absl::optional<double>& value) { +base::Time ParseTimeProperty(const std::optional<double>& value) { if (!value) // empty time means ignoring the parameter return base::Time(); if (*value == 0) // FromSecondsSinceUnixEpoch would convert 0 to empty Time @@ -321,7 +321,7 @@ v8::Local<v8::Promise> Cookies::Set(v8::Isolate* isolate, path ? *path : "", ParseTimeProperty(details.FindDouble("creationDate")), ParseTimeProperty(details.FindDouble("expirationDate")), ParseTimeProperty(details.FindDouble("lastAccessDate")), secure, - http_only, same_site, net::COOKIE_PRIORITY_DEFAULT, absl::nullopt, + http_only, same_site, net::COOKIE_PRIORITY_DEFAULT, std::nullopt, &status); if (!canonical_cookie || !canonical_cookie->IsCanonical()) { diff --git a/shell/browser/api/electron_api_debugger.cc b/shell/browser/api/electron_api_debugger.cc index 3e731a25ad..1148b84aa2 100755 --- a/shell/browser/api/electron_api_debugger.cc +++ b/shell/browser/api/electron_api_debugger.cc @@ -44,12 +44,12 @@ void Debugger::DispatchProtocolMessage(DevToolsAgentHost* agent_host, base::StringPiece message_str(reinterpret_cast<const char*>(message.data()), message.size()); - absl::optional<base::Value> parsed_message = base::JSONReader::Read( + std::optional<base::Value> parsed_message = base::JSONReader::Read( message_str, base::JSON_REPLACE_INVALID_CHARACTERS); if (!parsed_message || !parsed_message->is_dict()) return; base::Value::Dict& dict = parsed_message->GetDict(); - absl::optional<int> id = dict.FindInt("id"); + std::optional<int> id = dict.FindInt("id"); if (!id) { std::string* method = dict.FindString("method"); if (!method) diff --git a/shell/browser/api/electron_api_menu_mac.mm b/shell/browser/api/electron_api_menu_mac.mm index 9bb7ddf238..2473953ddd 100644 --- a/shell/browser/api/electron_api_menu_mac.mm +++ b/shell/browser/api/electron_api_menu_mac.mm @@ -25,7 +25,7 @@ static NSMenu* __strong applicationMenu_; ui::Accelerator GetAcceleratorFromKeyEquivalentAndModifierMask( NSString* key_equivalent, NSUInteger modifier_mask) { - absl::optional<char16_t> shifted_char; + std::optional<char16_t> shifted_char; ui::KeyboardCode code = electron::KeyboardCodeFromStr( base::SysNSStringToUTF8(key_equivalent), &shifted_char); int modifiers = 0; diff --git a/shell/browser/api/electron_api_net_log.cc b/shell/browser/api/electron_api_net_log.cc index 24ebc6e29b..45c21384c1 100644 --- a/shell/browser/api/electron_api_net_log.cc +++ b/shell/browser/api/electron_api_net_log.cc @@ -125,7 +125,7 @@ v8::Local<v8::Promise> NetLog::StartLogging(base::FilePath log_path, } pending_start_promise_ = - absl::make_optional<gin_helper::Promise<void>>(args->isolate()); + std::make_optional<gin_helper::Promise<void>>(args->isolate()); v8::Local<v8::Promise> handle = pending_start_promise_->GetHandle(); auto command_line_string = diff --git a/shell/browser/api/electron_api_net_log.h b/shell/browser/api/electron_api_net_log.h index e715e0e241..3a745ca695 100644 --- a/shell/browser/api/electron_api_net_log.h +++ b/shell/browser/api/electron_api_net_log.h @@ -5,6 +5,8 @@ #ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NET_LOG_H_ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NET_LOG_H_ +#include <optional> + #include "base/files/file_path.h" #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" @@ -16,7 +18,6 @@ #include "net/log/net_log_capture_mode.h" #include "services/network/public/mojom/net_log.mojom.h" #include "shell/common/gin_helper/promise.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace gin { class Arguments; @@ -67,7 +68,7 @@ class NetLog : public gin::Wrappable<NetLog> { mojo::Remote<network::mojom::NetLogExporter> net_log_exporter_; - absl::optional<gin_helper::Promise<void>> pending_start_promise_; + std::optional<gin_helper::Promise<void>> pending_start_promise_; scoped_refptr<base::TaskRunner> file_task_runner_; diff --git a/shell/browser/api/electron_api_session.cc b/shell/browser/api/electron_api_session.cc index f1e14449ae..93666811ac 100644 --- a/shell/browser/api/electron_api_session.cc +++ b/shell/browser/api/electron_api_session.cc @@ -281,7 +281,7 @@ void DownloadIdCallback(content::DownloadManager* download_manager, url_chain, GURL(), content::StoragePartitionConfig::CreateDefault( download_manager->GetBrowserContext()), - GURL(), GURL(), absl::nullopt, mime_type, mime_type, start_time, + GURL(), GURL(), std::nullopt, mime_type, mime_type, start_time, base::Time(), etag, last_modified, offset, length, std::string(), download::DownloadItem::INTERRUPTED, download::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, @@ -432,7 +432,7 @@ v8::Local<v8::Promise> Session::ResolveProxy(gin::Arguments* args) { v8::Local<v8::Promise> Session::ResolveHost( std::string host, - absl::optional<network::mojom::ResolveHostParametersPtr> params) { + std::optional<network::mojom::ResolveHostParametersPtr> params) { gin_helper::Promise<gin_helper::Dictionary> promise(isolate_); v8::Local<v8::Promise> handle = promise.GetHandle(); @@ -441,7 +441,7 @@ v8::Local<v8::Promise> Session::ResolveHost( params ? std::move(params.value()) : nullptr, base::BindOnce( [](gin_helper::Promise<gin_helper::Dictionary> promise, - int64_t net_error, const absl::optional<net::AddressList>& addrs) { + int64_t net_error, const std::optional<net::AddressList>& addrs) { if (net_error < 0) { promise.RejectWithErrorMessage(net::ErrorToString(net_error)); } else { @@ -1271,7 +1271,7 @@ gin::Handle<Session> Session::FromPartition(v8::Isolate* isolate, } // static -absl::optional<gin::Handle<Session>> Session::FromPath( +std::optional<gin::Handle<Session>> Session::FromPath( v8::Isolate* isolate, const base::FilePath& path, base::Value::Dict options) { @@ -1280,12 +1280,12 @@ absl::optional<gin::Handle<Session>> Session::FromPath( if (path.empty()) { gin_helper::Promise<v8::Local<v8::Value>> promise(isolate); promise.RejectWithErrorMessage("An empty path was specified"); - return absl::nullopt; + return std::nullopt; } if (!path.IsAbsolute()) { gin_helper::Promise<v8::Local<v8::Value>> promise(isolate); promise.RejectWithErrorMessage("An absolute path was not provided"); - return absl::nullopt; + return std::nullopt; } browser_context = @@ -1410,7 +1410,7 @@ v8::Local<v8::Value> FromPath(const base::FilePath& path, } base::Value::Dict options; args->GetNext(&options); - absl::optional<gin::Handle<Session>> session_handle = + std::optional<gin::Handle<Session>> session_handle = Session::FromPath(args->isolate(), path, std::move(options)); if (session_handle) diff --git a/shell/browser/api/electron_api_session.h b/shell/browser/api/electron_api_session.h index a71609273c..a6ad55fa3c 100644 --- a/shell/browser/api/electron_api_session.h +++ b/shell/browser/api/electron_api_session.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_SESSION_H_ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_SESSION_H_ +#include <optional> #include <string> #include <vector> @@ -85,7 +86,7 @@ class Session : public gin::Wrappable<Session>, base::Value::Dict options = {}); // Gets the Session based on |path|. - static absl::optional<gin::Handle<Session>> FromPath( + static std::optional<gin::Handle<Session>> FromPath( v8::Isolate* isolate, const base::FilePath& path, base::Value::Dict options = {}); @@ -101,7 +102,7 @@ class Session : public gin::Wrappable<Session>, // Methods. v8::Local<v8::Promise> ResolveHost( std::string host, - absl::optional<network::mojom::ResolveHostParametersPtr> params); + std::optional<network::mojom::ResolveHostParametersPtr> params); v8::Local<v8::Promise> ResolveProxy(gin::Arguments* args); v8::Local<v8::Promise> GetCacheSize(); v8::Local<v8::Promise> ClearCache(); diff --git a/shell/browser/api/electron_api_tray.cc b/shell/browser/api/electron_api_tray.cc index 822ed7acdc..5ecb4b851a 100644 --- a/shell/browser/api/electron_api_tray.cc +++ b/shell/browser/api/electron_api_tray.cc @@ -51,7 +51,7 @@ gin::WrapperInfo Tray::kWrapperInfo = {gin::kEmbedderNativeGin}; Tray::Tray(v8::Isolate* isolate, v8::Local<v8::Value> image, - absl::optional<UUID> guid) + std::optional<UUID> guid) : tray_icon_(TrayIcon::Create(guid)) { SetImage(isolate, image); tray_icon_->AddObserver(this); @@ -62,7 +62,7 @@ Tray::~Tray() = default; // static gin::Handle<Tray> Tray::New(gin_helper::ErrorThrower thrower, v8::Local<v8::Value> image, - absl::optional<UUID> guid, + std::optional<UUID> guid, gin::Arguments* args) { if (!Browser::Get()->is_ready()) { thrower.ThrowError("Cannot create Tray before app is ready"); @@ -232,7 +232,7 @@ void Tray::SetToolTip(const std::string& tool_tip) { } void Tray::SetTitle(const std::string& title, - const absl::optional<gin_helper::Dictionary>& options, + const std::optional<gin_helper::Dictionary>& options, gin::Arguments* args) { if (!CheckAlive()) return; diff --git a/shell/browser/api/electron_api_tray.h b/shell/browser/api/electron_api_tray.h index 5b6b1b5752..26429e9ee8 100644 --- a/shell/browser/api/electron_api_tray.h +++ b/shell/browser/api/electron_api_tray.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_TRAY_H_ #include <memory> +#include <optional> #include <string> #include <vector> @@ -43,7 +44,7 @@ class Tray : public gin::Wrappable<Tray>, // gin_helper::Constructible static gin::Handle<Tray> New(gin_helper::ErrorThrower thrower, v8::Local<v8::Value> image, - absl::optional<UUID> guid, + std::optional<UUID> guid, gin::Arguments* args); static void FillObjectTemplate(v8::Isolate*, v8::Local<v8::ObjectTemplate>); @@ -60,7 +61,7 @@ class Tray : public gin::Wrappable<Tray>, private: Tray(v8::Isolate* isolate, v8::Local<v8::Value> image, - absl::optional<UUID> guid); + std::optional<UUID> guid); ~Tray() override; // TrayIconObserver: @@ -92,7 +93,7 @@ class Tray : public gin::Wrappable<Tray>, void SetPressedImage(v8::Isolate* isolate, v8::Local<v8::Value> image); void SetToolTip(const std::string& tool_tip); void SetTitle(const std::string& title, - const absl::optional<gin_helper::Dictionary>& options, + const std::optional<gin_helper::Dictionary>& options, gin::Arguments* args); std::string GetTitle(); void SetIgnoreDoubleClickEvents(bool ignore); diff --git a/shell/browser/api/electron_api_view.cc b/shell/browser/api/electron_api_view.cc index f5a8aa2ec2..eea9c8098b 100644 --- a/shell/browser/api/electron_api_view.cc +++ b/shell/browser/api/electron_api_view.cc @@ -182,7 +182,7 @@ View::~View() { } void View::AddChildViewAt(gin::Handle<View> child, - absl::optional<size_t> maybe_index) { + std::optional<size_t> maybe_index) { // TODO(nornagon): !view_ is only for supporting the weird case of // WebContentsView's view being deleted when the underlying WebContents is // destroyed (on non-Mac). We should fix that so that WebContentsView always @@ -292,7 +292,7 @@ std::vector<v8::Local<v8::Value>> View::GetChildren() { return ret; } -void View::SetBackgroundColor(absl::optional<WrappedSkColor> color) { +void View::SetBackgroundColor(std::optional<WrappedSkColor> color) { if (!view_) return; view_->SetBackground(color ? views::CreateSolidBackground(*color) : nullptr); diff --git a/shell/browser/api/electron_api_view.h b/shell/browser/api/electron_api_view.h index 3a90d79118..1080333c2f 100644 --- a/shell/browser/api/electron_api_view.h +++ b/shell/browser/api/electron_api_view.h @@ -5,6 +5,8 @@ #ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_VIEW_H_ +#include <optional> + #include "base/memory/raw_ptr.h" #include "gin/handle.h" #include "shell/common/color_util.h" @@ -26,14 +28,14 @@ class View : public gin_helper::EventEmitter<View>, public views::ViewObserver { static void BuildPrototype(v8::Isolate* isolate, v8::Local<v8::FunctionTemplate> prototype); - void AddChildViewAt(gin::Handle<View> child, absl::optional<size_t> index); + void AddChildViewAt(gin::Handle<View> child, std::optional<size_t> index); void RemoveChildView(gin::Handle<View> child); void SetBounds(const gfx::Rect& bounds); gfx::Rect GetBounds(); void SetLayout(v8::Isolate* isolate, v8::Local<v8::Object> value); std::vector<v8::Local<v8::Value>> GetChildren(); - void SetBackgroundColor(absl::optional<WrappedSkColor> color); + void SetBackgroundColor(std::optional<WrappedSkColor> color); void SetVisible(bool visible); // views::ViewObserver diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index c24d328883..893f51e7ba 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -6,6 +6,7 @@ #include <limits> #include <memory> +#include <optional> #include <set> #include <string> #include <utility> @@ -128,7 +129,6 @@ #include "shell/common/thread_restrictions.h" #include "shell/common/v8_value_serializer.h" #include "storage/browser/file_system/isolated_context.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/common/input/web_input_event.h" #include "third_party/blink/public/common/messaging/transferable_message_mojom_traits.h" @@ -496,9 +496,9 @@ void OnCapturePageDone(gin_helper::Promise<gfx::Image> promise, capture_handle.RunAndReset(); } -absl::optional<base::TimeDelta> GetCursorBlinkInterval() { +std::optional<base::TimeDelta> GetCursorBlinkInterval() { #if BUILDFLAG(IS_MAC) - absl::optional<base::TimeDelta> system_value( + std::optional<base::TimeDelta> system_value( ui::TextInsertionCaretBlinkPeriodFromDefaults()); if (system_value) return *system_value; @@ -512,7 +512,7 @@ absl::optional<base::TimeDelta> GetCursorBlinkInterval() { : base::Milliseconds(system_msec); } #endif - return absl::nullopt; + return std::nullopt; } #if BUILDFLAG(ENABLE_PRINTING) @@ -1104,7 +1104,7 @@ void WebContents::Destroy() { } } -void WebContents::Close(absl::optional<gin_helper::Dictionary> options) { +void WebContents::Close(std::optional<gin_helper::Dictionary> options) { bool dispatch_beforeunload = false; if (options) options->Get("waitForBeforeUnload", &dispatch_beforeunload); @@ -1675,7 +1675,7 @@ void WebContents::HandleNewRenderFrame( } void WebContents::OnBackgroundColorChanged() { - absl::optional<SkColor> color = web_contents()->GetBackgroundColor(); + std::optional<SkColor> color = web_contents()->GetBackgroundColor(); if (color.has_value()) { auto* const view = web_contents()->GetRenderWidgetHostView(); static_cast<content::RenderWidgetHostViewBase*>(view) @@ -2266,7 +2266,7 @@ void WebContents::SetOwnerWindow(NativeWindow* owner_window) { SetOwnerWindow(GetWebContents(), owner_window); } -void WebContents::SetOwnerBaseWindow(absl::optional<BaseWindow*> owner_window) { +void WebContents::SetOwnerBaseWindow(std::optional<BaseWindow*> owner_window) { SetOwnerWindow(GetWebContents(), owner_window ? (*owner_window)->window() : nullptr); } @@ -3169,8 +3169,8 @@ v8::Local<v8::Promise> WebContents::PrintToPDF(const base::Value& settings) { web_contents()->GetPrimaryMainFrame()->GetLastCommittedURL(), landscape, display_header_footer, print_background, scale, paper_width, paper_height, margin_top, margin_bottom, margin_left, - margin_right, absl::make_optional(header_template), - absl::make_optional(footer_template), prefer_css_page_size, + margin_right, std::make_optional(header_template), + std::make_optional(footer_template), prefer_css_page_size, generate_tagged_pdf, generate_document_outline); if (absl::holds_alternative<std::string>(print_pages_params)) { @@ -3780,7 +3780,7 @@ void WebContents::SetImageAnimationPolicy(const std::string& new_policy) { web_contents()->OnWebPreferencesChanged(); } -void WebContents::SetBackgroundColor(absl::optional<SkColor> maybe_color) { +void WebContents::SetBackgroundColor(std::optional<SkColor> maybe_color) { SkColor color = maybe_color.value_or((IsGuest() && guest_transparent_) || type_ == Type::kBrowserView ? SK_ColorTRANSPARENT @@ -4124,7 +4124,7 @@ void WebContents::DevToolsIndexPath( if (devtools_indexing_jobs_.count(request_id) != 0) return; std::vector<std::string> excluded_folders; - absl::optional<base::Value> parsed_excluded_folders = + std::optional<base::Value> parsed_excluded_folders = base::JSONReader::Read(excluded_folders_message); if (parsed_excluded_folders && parsed_excluded_folders->is_list()) { for (const base::Value& folder_path : parsed_excluded_folders->GetList()) { diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index 00c3ad8648..27f6d27640 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -7,6 +7,7 @@ #include <map> #include <memory> +#include <optional> #include <string> #include <utility> #include <vector> @@ -164,7 +165,7 @@ class WebContents : public ExclusiveAccessContext, const char* GetTypeName() override; void Destroy(); - void Close(absl::optional<gin_helper::Dictionary> options); + void Close(std::optional<gin_helper::Dictionary> options); base::WeakPtr<WebContents> GetWeakPtr() { return weak_factory_.GetWeakPtr(); } bool GetBackgroundThrottling() const override; @@ -403,7 +404,7 @@ class WebContents : public ExclusiveAccessContext, void SetOwnerWindow(NativeWindow* owner_window); void SetOwnerWindow(content::WebContents* web_contents, NativeWindow* owner_window); - void SetOwnerBaseWindow(absl::optional<BaseWindow*> owner_window); + void SetOwnerBaseWindow(std::optional<BaseWindow*> owner_window); // Returns the WebContents managed by this delegate. content::WebContents* GetWebContents() const; @@ -474,7 +475,7 @@ class WebContents : public ExclusiveAccessContext, void CancelDialogs(content::WebContents* web_contents, bool reset_state) override; - void SetBackgroundColor(absl::optional<SkColor> color); + void SetBackgroundColor(std::optional<SkColor> color); SkRegion* draggable_region() { return force_non_draggable_ ? nullptr : draggable_region_.get(); diff --git a/shell/browser/api/electron_api_web_contents_view.cc b/shell/browser/api/electron_api_web_contents_view.cc index 6a85727a3a..aabda22ff9 100644 --- a/shell/browser/api/electron_api_web_contents_view.cc +++ b/shell/browser/api/electron_api_web_contents_view.cc @@ -66,7 +66,7 @@ gin::Handle<WebContents> WebContentsView::GetWebContents(v8::Isolate* isolate) { return gin::Handle<WebContents>(); } -void WebContentsView::SetBackgroundColor(absl::optional<WrappedSkColor> color) { +void WebContentsView::SetBackgroundColor(std::optional<WrappedSkColor> color) { View::SetBackgroundColor(color); if (api_web_contents_) { api_web_contents_->SetBackgroundColor(color); diff --git a/shell/browser/api/electron_api_web_contents_view.h b/shell/browser/api/electron_api_web_contents_view.h index 6852f6becb..353086427b 100644 --- a/shell/browser/api/electron_api_web_contents_view.h +++ b/shell/browser/api/electron_api_web_contents_view.h @@ -5,6 +5,8 @@ #ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_VIEW_H_ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_VIEW_H_ +#include <optional> + #include "base/memory/raw_ptr.h" #include "content/public/browser/web_contents_observer.h" #include "shell/browser/api/electron_api_view.h" @@ -36,7 +38,7 @@ class WebContentsView : public View, // Public APIs. gin::Handle<WebContents> GetWebContents(v8::Isolate* isolate); - void SetBackgroundColor(absl::optional<WrappedSkColor> color); + void SetBackgroundColor(std::optional<WrappedSkColor> color); int NonClientHitTest(const gfx::Point& point) override; diff --git a/shell/browser/api/electron_api_web_frame_main.cc b/shell/browser/api/electron_api_web_frame_main.cc index 24952767db..da0e9ca50c 100644 --- a/shell/browser/api/electron_api_web_frame_main.cc +++ b/shell/browser/api/electron_api_web_frame_main.cc @@ -229,7 +229,7 @@ void WebFrameMain::OnRendererConnectionError() { void WebFrameMain::PostMessage(v8::Isolate* isolate, const std::string& channel, v8::Local<v8::Value> message_value, - absl::optional<v8::Local<v8::Value>> transfer) { + std::optional<v8::Local<v8::Value>> transfer) { blink::TransferableMessage transferable_message; if (!electron::SerializeV8Value(isolate, message_value, &transferable_message)) { diff --git a/shell/browser/api/electron_api_web_frame_main.h b/shell/browser/api/electron_api_web_frame_main.h index d3ac3914d6..ddf7bdd630 100644 --- a/shell/browser/api/electron_api_web_frame_main.h +++ b/shell/browser/api/electron_api_web_frame_main.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_FRAME_MAIN_H_ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_FRAME_MAIN_H_ +#include <optional> #include <string> #include <vector> @@ -103,7 +104,7 @@ class WebFrameMain : public gin::Wrappable<WebFrameMain>, void PostMessage(v8::Isolate* isolate, const std::string& channel, v8::Local<v8::Value> message_value, - absl::optional<v8::Local<v8::Value>> transfer); + std::optional<v8::Local<v8::Value>> transfer); int FrameTreeNodeID() const; std::string Name() const; diff --git a/shell/browser/api/process_metric.cc b/shell/browser/api/process_metric.cc index a7d628e691..75c0f04cd8 100644 --- a/shell/browser/api/process_metric.cc +++ b/shell/browser/api/process_metric.cc @@ -5,10 +5,9 @@ #include "shell/browser/api/process_metric.h" #include <memory> +#include <optional> #include <utility> -#include "third_party/abseil-cpp/absl/types/optional.h" - #if BUILDFLAG(IS_WIN) #include <windows.h> @@ -34,14 +33,14 @@ mach_port_t TaskForPid(pid_t pid) { return task; } -absl::optional<mach_task_basic_info_data_t> GetTaskInfo(mach_port_t task) { +std::optional<mach_task_basic_info_data_t> GetTaskInfo(mach_port_t task) { if (task == MACH_PORT_NULL) - return absl::nullopt; + return std::nullopt; mach_task_basic_info_data_t info = {}; mach_msg_type_number_t count = MACH_TASK_BASIC_INFO_COUNT; kern_return_t kr = task_info(task, MACH_TASK_BASIC_INFO, reinterpret_cast<task_info_t>(&info), &count); - return (kr == KERN_SUCCESS) ? absl::make_optional(info) : absl::nullopt; + return (kr == KERN_SUCCESS) ? std::make_optional(info) : std::nullopt; } } // namespace diff --git a/shell/browser/badging/badge_manager.cc b/shell/browser/badging/badge_manager.cc index 16c1a69701..3de1482bfb 100755 --- a/shell/browser/badging/badge_manager.cc +++ b/shell/browser/badging/badge_manager.cc @@ -67,7 +67,7 @@ void BadgeManager::BindServiceWorkerReceiver( std::move(context)); } -std::string BadgeManager::GetBadgeString(absl::optional<int> badge_content) { +std::string BadgeManager::GetBadgeString(std::optional<int> badge_content) { if (!badge_content) return "•"; @@ -87,9 +87,9 @@ void BadgeManager::SetBadge(blink::mojom::BadgeValuePtr mojo_value) { return; } - absl::optional<int> value = - mojo_value->is_flag() ? absl::nullopt - : absl::make_optional(mojo_value->get_number()); + std::optional<int> value = mojo_value->is_flag() + ? std::nullopt + : std::make_optional(mojo_value->get_number()); electron::Browser::Get()->SetBadgeCount(value); } diff --git a/shell/browser/badging/badge_manager.h b/shell/browser/badging/badge_manager.h index 0db3e53fb2..1fc523ce7c 100644 --- a/shell/browser/badging/badge_manager.h +++ b/shell/browser/badging/badge_manager.h @@ -6,11 +6,11 @@ #define ELECTRON_SHELL_BROWSER_BADGING_BADGE_MANAGER_H_ #include <memory> +#include <optional> #include <string> #include "components/keyed_service/core/keyed_service.h" #include "mojo/public/cpp/bindings/receiver_set.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/mojom/badging/badging.mojom.h" #include "url/gurl.h" @@ -44,7 +44,7 @@ class BadgeManager : public KeyedService, public blink::mojom::BadgeService { mojo::PendingReceiver<blink::mojom::BadgeService> receiver); // Determines the text to put on the badge based on some badge_content. - static std::string GetBadgeString(absl::optional<int> badge_content); + static std::string GetBadgeString(std::optional<int> badge_content); private: // The BindingContext of a mojo request. Allows mojo calls to be tied back diff --git a/shell/browser/bluetooth/electron_bluetooth_delegate.cc b/shell/browser/bluetooth/electron_bluetooth_delegate.cc index 94e7a3b2a6..3616c55b03 100644 --- a/shell/browser/bluetooth/electron_bluetooth_delegate.cc +++ b/shell/browser/bluetooth/electron_bluetooth_delegate.cc @@ -161,7 +161,7 @@ void ElectronBluetoothDelegate::ShowDevicePairPrompt( const std::u16string& device_identifier, PairPromptCallback callback, PairingKind pairing_kind, - const absl::optional<std::u16string>& pin) { + const std::optional<std::u16string>& pin) { auto* web_contents = content::WebContents::FromRenderFrameHost(frame); if (web_contents) { auto* permission_manager = static_cast<ElectronPermissionManager*>( diff --git a/shell/browser/bluetooth/electron_bluetooth_delegate.h b/shell/browser/bluetooth/electron_bluetooth_delegate.h index 8328f45636..f0fef90e01 100644 --- a/shell/browser/bluetooth/electron_bluetooth_delegate.h +++ b/shell/browser/bluetooth/electron_bluetooth_delegate.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_BLUETOOTH_ELECTRON_BLUETOOTH_DELEGATE_H_ #include <memory> +#include <optional> #include <string> #include <vector> @@ -57,7 +58,7 @@ class ElectronBluetoothDelegate : public content::BluetoothDelegate { const std::u16string& device_identifier, PairPromptCallback callback, PairingKind pairing_kind, - const absl::optional<std::u16string>& pin) override; + const std::optional<std::u16string>& pin) override; blink::WebBluetoothDeviceId GetWebBluetoothDeviceId( content::RenderFrameHost* frame, const std::string& device_address) override; diff --git a/shell/browser/browser.h b/shell/browser/browser.h index 1e7123773c..8b0434cf06 100644 --- a/shell/browser/browser.h +++ b/shell/browser/browser.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_BROWSER_H_ #include <memory> +#include <optional> #include <string> #include <vector> @@ -108,7 +109,7 @@ class Browser : public WindowListObserver { #endif // Set/Get the badge count. - bool SetBadgeCount(absl::optional<int> count); + bool SetBadgeCount(std::optional<int> count); int GetBadgeCount(); #if BUILDFLAG(IS_WIN) @@ -374,7 +375,7 @@ class Browser : public WindowListObserver { #if BUILDFLAG(IS_WIN) void UpdateBadgeContents(HWND hwnd, - const absl::optional<std::string>& badge_content, + const std::optional<std::string>& badge_content, const std::string& badge_alt_string); // In charge of running taskbar related APIs. diff --git a/shell/browser/browser_linux.cc b/shell/browser/browser_linux.cc index 1a6f5b40b7..fc297546c4 100644 --- a/shell/browser/browser_linux.cc +++ b/shell/browser/browser_linux.cc @@ -49,7 +49,7 @@ bool LaunchXdgUtility(const std::vector<std::string>& argv, int* exit_code) { return process.WaitForExit(exit_code); } -absl::optional<std::string> GetXdgAppOutput( +std::optional<std::string> GetXdgAppOutput( const std::vector<std::string>& argv) { std::string reply; int success_code; @@ -58,9 +58,9 @@ absl::optional<std::string> GetXdgAppOutput( &success_code); if (!ran_ok || success_code != EXIT_SUCCESS) - return absl::optional<std::string>(); + return std::optional<std::string>(); - return absl::make_optional(reply); + return std::make_optional(reply); } bool SetDefaultWebClient(const std::string& protocol) { @@ -126,7 +126,7 @@ std::u16string Browser::GetApplicationNameForProtocol(const GURL& url) { return base::ASCIIToUTF16(GetXdgAppOutput(argv).value_or(std::string())); } -bool Browser::SetBadgeCount(absl::optional<int> count) { +bool Browser::SetBadgeCount(std::optional<int> count) { if (IsUnityRunning() && count.has_value()) { unity::SetDownloadCount(count.value()); badge_count_ = count.value(); diff --git a/shell/browser/browser_mac.mm b/shell/browser/browser_mac.mm index c35ccc1afe..3745a2e2d3 100644 --- a/shell/browser/browser_mac.mm +++ b/shell/browser/browser_mac.mm @@ -266,7 +266,7 @@ std::u16string Browser::GetApplicationNameForProtocol(const GURL& url) { return app_display_name; } -bool Browser::SetBadgeCount(absl::optional<int> count) { +bool Browser::SetBadgeCount(std::optional<int> count) { DockSetBadgeText(!count.has_value() || count.value() != 0 ? badging::BadgeManager::GetBadgeString(count) : ""); diff --git a/shell/browser/browser_win.cc b/shell/browser/browser_win.cc index a585882eac..a7379fe921 100644 --- a/shell/browser/browser_win.cc +++ b/shell/browser/browser_win.cc @@ -516,10 +516,10 @@ v8::Local<v8::Promise> Browser::GetApplicationInfoForProtocol( return handle; } -bool Browser::SetBadgeCount(absl::optional<int> count) { - absl::optional<std::string> badge_content; +bool Browser::SetBadgeCount(std::optional<int> count) { + std::optional<std::string> badge_content; if (count.has_value() && count.value() == 0) { - badge_content = absl::nullopt; + badge_content = std::nullopt; } else { badge_content = badging::BadgeManager::GetBadgeString(count); } @@ -560,7 +560,7 @@ bool Browser::SetBadgeCount(absl::optional<int> count) { void Browser::UpdateBadgeContents( HWND hwnd, - const absl::optional<std::string>& badge_content, + const std::optional<std::string>& badge_content, const std::string& badge_alt_string) { SkBitmap badge; if (badge_content) { diff --git a/shell/browser/electron_browser_client.cc b/shell/browser/electron_browser_client.cc index 40a25edc33..71ff545726 100644 --- a/shell/browser/electron_browser_client.cc +++ b/shell/browser/electron_browser_client.cc @@ -924,7 +924,7 @@ bool ElectronBrowserClient::HandleExternalProtocol( network::mojom::WebSandboxFlags sandbox_flags, ui::PageTransition page_transition, bool has_user_gesture, - const absl::optional<url::Origin>& initiating_origin, + const std::optional<url::Origin>& initiating_origin, content::RenderFrameHost* initiator_document, mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) { content::GetUIThreadTaskRunner({})->PostTask( @@ -1129,7 +1129,7 @@ class FileURLLoaderFactory : public network::SelfDeletingURLLoaderFactory { void ElectronBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories( int render_process_id, int render_frame_id, - const absl::optional<url::Origin>& request_initiator_origin, + const std::optional<url::Origin>& request_initiator_origin, NonNetworkURLLoaderFactoryMap* factories) { auto* render_process_host = content::RenderProcessHost::FromID(render_process_id); @@ -1265,7 +1265,7 @@ void ElectronBrowserClient::CreateWebSocket( WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const absl::optional<std::string>& user_agent, + const std::optional<std::string>& user_agent, mojo::PendingRemote<network::mojom::WebSocketHandshakeClient> handshake_client) { v8::Isolate* isolate = JavascriptEnvironment::GetIsolate(); @@ -1302,7 +1302,7 @@ bool ElectronBrowserClient::WillCreateURLLoaderFactory( int render_process_id, URLLoaderFactoryType type, const url::Origin& request_initiator, - absl::optional<int64_t> navigation_id, + std::optional<int64_t> navigation_id, ukm::SourceIdObj ukm_source_id, mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver, mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>* diff --git a/shell/browser/electron_browser_client.h b/shell/browser/electron_browser_client.h index 80131015f3..5a4a26ce98 100644 --- a/shell/browser/electron_browser_client.h +++ b/shell/browser/electron_browser_client.h @@ -201,7 +201,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient, void RegisterNonNetworkSubresourceURLLoaderFactories( int render_process_id, int render_frame_id, - const absl::optional<url::Origin>& request_initiator_origin, + const std::optional<url::Origin>& request_initiator_origin, NonNetworkURLLoaderFactoryMap* factories) override; void RegisterNonNetworkServiceWorkerUpdateURLLoaderFactories( content::BrowserContext* browser_context, @@ -211,7 +211,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient, WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const absl::optional<std::string>& user_agent, + const std::optional<std::string>& user_agent, mojo::PendingRemote<network::mojom::WebSocketHandshakeClient> handshake_client) override; bool WillInterceptWebSocket(content::RenderFrameHost*) override; @@ -221,7 +221,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient, int render_process_id, URLLoaderFactoryType type, const url::Origin& request_initiator, - absl::optional<int64_t> navigation_id, + std::optional<int64_t> navigation_id, ukm::SourceIdObj ukm_source_id, mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver, mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>* @@ -263,7 +263,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient, network::mojom::WebSandboxFlags sandbox_flags, ui::PageTransition page_transition, bool has_user_gesture, - const absl::optional<url::Origin>& initiating_origin, + const std::optional<url::Origin>& initiating_origin, content::RenderFrameHost* initiator_document, mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) override; diff --git a/shell/browser/electron_browser_context.cc b/shell/browser/electron_browser_context.cc index 88e937a696..4f8b281816 100644 --- a/shell/browser/electron_browser_context.cc +++ b/shell/browser/electron_browser_context.cc @@ -447,7 +447,7 @@ ElectronBrowserContext::GetURLLoaderFactory() { ->WillCreateURLLoaderFactory( this, nullptr, -1, content::ContentBrowserClient::URLLoaderFactoryType::kNavigation, - url::Origin(), absl::nullopt, ukm::kInvalidSourceIdObj, + url::Origin(), std::nullopt, ukm::kInvalidSourceIdObj, &factory_receiver, &header_client, nullptr, nullptr, nullptr, nullptr); diff --git a/shell/browser/electron_browser_context.h b/shell/browser/electron_browser_context.h index 80581f2d3f..9ec947e5f6 100644 --- a/shell/browser/electron_browser_context.h +++ b/shell/browser/electron_browser_context.h @@ -7,9 +7,11 @@ #include <map> #include <memory> +#include <optional> #include <string> #include <variant> #include <vector> + #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "chrome/browser/predictors/preconnect_manager.h" @@ -253,7 +255,7 @@ class ElectronBrowserContext : public content::BrowserContext { std::unique_ptr<predictors::PreconnectManager> preconnect_manager_; std::unique_ptr<ProtocolRegistry> protocol_registry_; - absl::optional<std::string> user_agent_; + std::optional<std::string> user_agent_; base::FilePath path_; bool in_memory_ = false; bool use_cache_ = true; diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 1638f64c04..7165fc1257 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -5,6 +5,7 @@ #include "shell/browser/electron_browser_main_parts.h" #include <memory> +#include <optional> #include <string> #include <utility> #include <vector> @@ -64,7 +65,6 @@ #include "shell/common/logging.h" #include "shell/common/node_bindings.h" #include "shell/common/node_includes.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/idle/idle.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/ui_base_switches.h" @@ -308,7 +308,7 @@ int ElectronBrowserMainParts::PreCreateThreads() { // We must set this env first to make ui::ResourceBundle accept the custom // locale. auto env = base::Environment::Create(); - absl::optional<std::string> lc_all; + std::optional<std::string> lc_all; if (!locale.empty()) { std::string str; if (env->GetVar("LC_ALL", &str)) diff --git a/shell/browser/electron_browser_main_parts.h b/shell/browser/electron_browser_main_parts.h index 62c8441b66..41d69716f1 100644 --- a/shell/browser/electron_browser_main_parts.h +++ b/shell/browser/electron_browser_main_parts.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_ELECTRON_BROWSER_MAIN_PARTS_H_ #include <memory> +#include <optional> #include <string> #include "base/functional/callback.h" @@ -16,7 +17,6 @@ #include "electron/buildflags/buildflags.h" #include "mojo/public/cpp/bindings/remote.h" #include "services/device/public/mojom/geolocation_control.mojom.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/display/screen.h" #include "ui/views/layout/layout_provider.h" @@ -153,7 +153,7 @@ class ElectronBrowserMainParts : public content::BrowserMainParts { // A place to remember the exit code once the message loop is ready. // Before then, we just exit() without any intermediate steps. - absl::optional<int> exit_code_; + std::optional<int> exit_code_; std::unique_ptr<NodeBindings> node_bindings_; diff --git a/shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.cc b/shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.cc index a7dce3c231..e93bd81b71 100644 --- a/shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.cc +++ b/shell/browser/extensions/api/pdf_viewer_private/pdf_viewer_private_api.cc @@ -53,7 +53,7 @@ PdfViewerPrivateIsAllowedLocalFileAccessFunction:: ExtensionFunction::ResponseAction PdfViewerPrivateIsAllowedLocalFileAccessFunction::Run() { - absl::optional<IsAllowedLocalFileAccess::Params> params = + std::optional<IsAllowedLocalFileAccess::Params> params = IsAllowedLocalFileAccess::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -81,7 +81,7 @@ PdfViewerPrivateSetPdfOcrPrefFunction:: // TODO(codebytere): enable when https://crbug.com/1393069 works properly. ExtensionFunction::ResponseAction PdfViewerPrivateSetPdfOcrPrefFunction::Run() { - absl::optional<SetPdfOcrPref::Params> params = + std::optional<SetPdfOcrPref::Params> params = SetPdfOcrPref::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); return RespondNow(WithArguments(false)); diff --git a/shell/browser/extensions/api/resources_private/resources_private_api.cc b/shell/browser/extensions/api/resources_private/resources_private_api.cc index 2dd1f974a4..d3f1158bd6 100644 --- a/shell/browser/extensions/api/resources_private/resources_private_api.cc +++ b/shell/browser/extensions/api/resources_private/resources_private_api.cc @@ -40,7 +40,7 @@ ResourcesPrivateGetStringsFunction::~ResourcesPrivateGetStringsFunction() = default; ExtensionFunction::ResponseAction ResourcesPrivateGetStringsFunction::Run() { - absl::optional<get_strings::Params> params( + std::optional<get_strings::Params> params( get_strings::Params::Create(args())); base::Value::Dict dict; diff --git a/shell/browser/extensions/api/scripting/scripting_api.cc b/shell/browser/extensions/api/scripting/scripting_api.cc index bc1b1cb973..2024e36443 100644 --- a/shell/browser/extensions/api/scripting/scripting_api.cc +++ b/shell/browser/extensions/api/scripting/scripting_api.cc @@ -198,14 +198,14 @@ bool GetFileResources(const std::vector<std::string>& files, using ResourcesLoadedCallback = base::OnceCallback<void(std::vector<InjectedFileSource>, - absl::optional<std::string>)>; + std::optional<std::string>)>; // Checks the loaded content of extension resources. Invokes `callback` with // the constructed file sources on success or with an error on failure. void CheckLoadedResources(std::vector<std::string> file_names, ResourcesLoadedCallback callback, std::vector<std::unique_ptr<std::string>> file_data, - absl::optional<std::string> load_error) { + std::optional<std::string> load_error) { if (load_error) { std::move(callback).Run({}, std::move(load_error)); return; @@ -228,7 +228,7 @@ void CheckLoadedResources(std::vector<std::string> file_names, } } - std::move(callback).Run(std::move(file_sources), absl::nullopt); + std::move(callback).Run(std::move(file_sources), std::nullopt); } // Checks the specified `files` for validity, and attempts to load and localize @@ -582,7 +582,7 @@ ScriptingExecuteScriptFunction::ScriptingExecuteScriptFunction() = default; ScriptingExecuteScriptFunction::~ScriptingExecuteScriptFunction() = default; ExtensionFunction::ResponseAction ScriptingExecuteScriptFunction::Run() { - absl::optional<api::scripting::ExecuteScript::Params> params = + std::optional<api::scripting::ExecuteScript::Params> params = api::scripting::ExecuteScript::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); injection_ = std::move(params->injection); @@ -654,7 +654,7 @@ ExtensionFunction::ResponseAction ScriptingExecuteScriptFunction::Run() { void ScriptingExecuteScriptFunction::DidLoadResources( std::vector<InjectedFileSource> file_sources, - absl::optional<std::string> load_error) { + std::optional<std::string> load_error) { if (load_error) { Respond(Error(std::move(*load_error))); return; @@ -749,7 +749,7 @@ ScriptingInsertCSSFunction::ScriptingInsertCSSFunction() = default; ScriptingInsertCSSFunction::~ScriptingInsertCSSFunction() = default; ExtensionFunction::ResponseAction ScriptingInsertCSSFunction::Run() { - absl::optional<api::scripting::InsertCSS::Params> params = + std::optional<api::scripting::InsertCSS::Params> params = api::scripting::InsertCSS::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -793,7 +793,7 @@ ExtensionFunction::ResponseAction ScriptingInsertCSSFunction::Run() { void ScriptingInsertCSSFunction::DidLoadResources( std::vector<InjectedFileSource> file_sources, - absl::optional<std::string> load_error) { + std::optional<std::string> load_error) { if (load_error) { Respond(Error(std::move(*load_error))); return; @@ -850,7 +850,7 @@ ScriptingRemoveCSSFunction::ScriptingRemoveCSSFunction() = default; ScriptingRemoveCSSFunction::~ScriptingRemoveCSSFunction() = default; ExtensionFunction::ResponseAction ScriptingRemoveCSSFunction::Run() { - absl::optional<api::scripting::RemoveCSS::Params> params = + std::optional<api::scripting::RemoveCSS::Params> params = api::scripting::RemoveCSS::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -929,7 +929,7 @@ ScriptingRegisterContentScriptsFunction:: ~ScriptingRegisterContentScriptsFunction() = default; ExtensionFunction::ResponseAction ScriptingUpdateContentScriptsFunction::Run() { - absl::optional<api::scripting::UpdateContentScripts::Params> params = + std::optional<api::scripting::UpdateContentScripts::Params> params = api::scripting::UpdateContentScripts::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -1087,7 +1087,7 @@ void ScriptingRegisterContentScriptsFunction::OnContentScriptFilesValidated( } void ScriptingRegisterContentScriptsFunction::OnContentScriptsRegistered( - const absl::optional<std::string>& error) { + const std::optional<std::string>& error) { if (error.has_value()) Respond(Error(std::move(*error))); else @@ -1102,11 +1102,11 @@ ScriptingGetRegisteredContentScriptsFunction:: ExtensionFunction::ResponseAction ScriptingGetRegisteredContentScriptsFunction::Run() { - absl::optional<api::scripting::GetRegisteredContentScripts::Params> params = + std::optional<api::scripting::GetRegisteredContentScripts::Params> params = api::scripting::GetRegisteredContentScripts::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); - const absl::optional<api::scripting::ContentScriptFilter>& filter = + const std::optional<api::scripting::ContentScriptFilter>& filter = params->filter; std::set<std::string> id_filter; if (filter && filter->ids) { @@ -1157,7 +1157,7 @@ ScriptingUnregisterContentScriptsFunction::Run() { api::scripting::UnregisterContentScripts::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); - absl::optional<api::scripting::ContentScriptFilter>& filter = params->filter; + std::optional<api::scripting::ContentScriptFilter>& filter = params->filter; ExtensionUserScriptLoader* loader = ExtensionSystem::Get(browser_context()) ->user_script_manager() @@ -1206,7 +1206,7 @@ ScriptingUnregisterContentScriptsFunction::Run() { } void ScriptingUnregisterContentScriptsFunction::OnContentScriptsUnregistered( - const absl::optional<std::string>& error) { + const std::optional<std::string>& error) { if (error.has_value()) Respond(Error(std::move(*error))); else @@ -1220,7 +1220,7 @@ ScriptingUpdateContentScriptsFunction:: ExtensionFunction::ResponseAction ScriptingRegisterContentScriptsFunction::Run() { - absl::optional<api::scripting::RegisterContentScripts::Params> params = + std::optional<api::scripting::RegisterContentScripts::Params> params = api::scripting::RegisterContentScripts::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -1341,7 +1341,7 @@ void ScriptingUpdateContentScriptsFunction::OnContentScriptFilesValidated( } void ScriptingUpdateContentScriptsFunction::OnContentScriptsUpdated( - const absl::optional<std::string>& error) { + const std::optional<std::string>& error) { if (error.has_value()) Respond(Error(std::move(*error))); else diff --git a/shell/browser/extensions/api/scripting/scripting_api.h b/shell/browser/extensions/api/scripting/scripting_api.h index c0d83ebef7..9466aa8514 100644 --- a/shell/browser/extensions/api/scripting/scripting_api.h +++ b/shell/browser/extensions/api/scripting/scripting_api.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_EXTENSIONS_API_SCRIPTING_SCRIPTING_API_H_ #include <memory> +#include <optional> #include <string> #include <utility> #include <vector> @@ -16,7 +17,6 @@ #include "extensions/browser/script_executor.h" #include "extensions/common/mojom/code_injection.mojom.h" #include "extensions/common/user_script.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace extensions { @@ -49,7 +49,7 @@ class ScriptingExecuteScriptFunction : public ExtensionFunction { // Called when the resource files to be injected has been loaded. void DidLoadResources(std::vector<InjectedFileSource> file_sources, - absl::optional<std::string> load_error); + std::optional<std::string> load_error); // Triggers the execution of `sources` in the appropriate context. // Returns true on success; on failure, populates `error`. @@ -78,7 +78,7 @@ class ScriptingInsertCSSFunction : public ExtensionFunction { // Called when the resource files to be injected has been loaded. void DidLoadResources(std::vector<InjectedFileSource> file_sources, - absl::optional<std::string> load_error); + std::optional<std::string> load_error); // Triggers the execution of `sources` in the appropriate context. // Returns true on success; on failure, populates `error`. @@ -132,7 +132,7 @@ class ScriptingRegisterContentScriptsFunction : public ExtensionFunction { scripting::ValidateScriptsResult result); // Called when content scripts have been registered. - void OnContentScriptsRegistered(const absl::optional<std::string>& error); + void OnContentScriptsRegistered(const std::optional<std::string>& error); }; class ScriptingGetRegisteredContentScriptsFunction : public ExtensionFunction { @@ -171,7 +171,7 @@ class ScriptingUnregisterContentScriptsFunction : public ExtensionFunction { ~ScriptingUnregisterContentScriptsFunction() override; // Called when content scripts have been unregistered. - void OnContentScriptsUnregistered(const absl::optional<std::string>& error); + void OnContentScriptsUnregistered(const std::optional<std::string>& error); }; class ScriptingUpdateContentScriptsFunction : public ExtensionFunction { @@ -197,7 +197,7 @@ class ScriptingUpdateContentScriptsFunction : public ExtensionFunction { scripting::ValidateScriptsResult result); // Called when content scripts have been updated. - void OnContentScriptsUpdated(const absl::optional<std::string>& error); + void OnContentScriptsUpdated(const std::optional<std::string>& error); }; } // namespace extensions diff --git a/shell/browser/extensions/api/tabs/tabs_api.cc b/shell/browser/extensions/api/tabs/tabs_api.cc index 1252bc5a9b..bbe0c14e35 100644 --- a/shell/browser/extensions/api/tabs/tabs_api.cc +++ b/shell/browser/extensions/api/tabs/tabs_api.cc @@ -71,7 +71,7 @@ void ZoomModeToZoomSettings(WebContentsZoomController::ZoomMode zoom_mode, // Returns true if either |boolean| is disengaged, or if |boolean| and // |value| are equal. This function is used to check if a tab's parameters match // those of the browser. -bool MatchesBool(const absl::optional<bool>& boolean, bool value) { +bool MatchesBool(const std::optional<bool>& boolean, bool value) { return !boolean || *boolean == value; } @@ -210,7 +210,7 @@ bool TabsExecuteScriptFunction::ShouldRemoveCSS() const { } ExtensionFunction::ResponseAction TabsReloadFunction::Run() { - absl::optional<tabs::Reload::Params> params = + std::optional<tabs::Reload::Params> params = tabs::Reload::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -233,7 +233,7 @@ ExtensionFunction::ResponseAction TabsReloadFunction::Run() { } ExtensionFunction::ResponseAction TabsQueryFunction::Run() { - absl::optional<tabs::Query::Params> params = + std::optional<tabs::Query::Params> params = tabs::Query::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -255,8 +255,8 @@ ExtensionFunction::ResponseAction TabsQueryFunction::Run() { } std::string title = params->query_info.title.value_or(std::string()); - absl::optional<bool> audible = params->query_info.audible; - absl::optional<bool> muted = params->query_info.muted; + std::optional<bool> audible = params->query_info.audible; + std::optional<bool> muted = params->query_info.muted; base::Value::List result; @@ -321,7 +321,7 @@ ExtensionFunction::ResponseAction TabsQueryFunction::Run() { } ExtensionFunction::ResponseAction TabsGetFunction::Run() { - absl::optional<tabs::Get::Params> params = tabs::Get::Params::Create(args()); + std::optional<tabs::Get::Params> params = tabs::Get::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); int tab_id = params->tab_id; @@ -349,7 +349,7 @@ ExtensionFunction::ResponseAction TabsGetFunction::Run() { } ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() { - absl::optional<tabs::SetZoom::Params> params = + std::optional<tabs::SetZoom::Params> params = tabs::SetZoom::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -377,7 +377,7 @@ ExtensionFunction::ResponseAction TabsSetZoomFunction::Run() { } ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() { - absl::optional<tabs::GetZoomSettings::Params> params = + std::optional<tabs::GetZoomSettings::Params> params = tabs::GetZoomSettings::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -393,7 +393,7 @@ ExtensionFunction::ResponseAction TabsGetZoomFunction::Run() { } ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() { - absl::optional<tabs::GetZoomSettings::Params> params = + std::optional<tabs::GetZoomSettings::Params> params = tabs::GetZoomSettings::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -417,7 +417,7 @@ ExtensionFunction::ResponseAction TabsGetZoomSettingsFunction::Run() { ExtensionFunction::ResponseAction TabsSetZoomSettingsFunction::Run() { using tabs::ZoomSettings; - absl::optional<tabs::SetZoomSettings::Params> params = + std::optional<tabs::SetZoomSettings::Params> params = tabs::SetZoomSettings::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); @@ -588,7 +588,7 @@ base::expected<GURL, std::string> PrepareURLForNavigation( TabsUpdateFunction::TabsUpdateFunction() : web_contents_(nullptr) {} ExtensionFunction::ResponseAction TabsUpdateFunction::Run() { - absl::optional<tabs::Update::Params> params = + std::optional<tabs::Update::Params> params = tabs::Update::Params::Create(args()); EXTENSION_FUNCTION_VALIDATE(params); diff --git a/shell/browser/extensions/electron_messaging_delegate.cc b/shell/browser/extensions/electron_messaging_delegate.cc index aec0ba4115..487515f12f 100644 --- a/shell/browser/extensions/electron_messaging_delegate.cc +++ b/shell/browser/extensions/electron_messaging_delegate.cc @@ -41,7 +41,7 @@ ElectronMessagingDelegate::IsNativeMessagingHostAllowed( return PolicyPermission::DISALLOW; } -absl::optional<base::Value::Dict> ElectronMessagingDelegate::MaybeGetTabInfo( +std::optional<base::Value::Dict> ElectronMessagingDelegate::MaybeGetTabInfo( content::WebContents* web_contents) { if (web_contents) { auto* api_contents = electron::api::WebContents::From(web_contents); @@ -54,7 +54,7 @@ absl::optional<base::Value::Dict> ElectronMessagingDelegate::MaybeGetTabInfo( return tab.ToValue(); } } - return absl::nullopt; + return std::nullopt; } content::WebContents* ElectronMessagingDelegate::GetWebContentsByTabId( diff --git a/shell/browser/extensions/electron_messaging_delegate.h b/shell/browser/extensions/electron_messaging_delegate.h index 1b6c921a73..67b6aabe81 100644 --- a/shell/browser/extensions/electron_messaging_delegate.h +++ b/shell/browser/extensions/electron_messaging_delegate.h @@ -27,7 +27,7 @@ class ElectronMessagingDelegate : public MessagingDelegate { PolicyPermission IsNativeMessagingHostAllowed( content::BrowserContext* browser_context, const std::string& native_host_name) override; - absl::optional<base::Value::Dict> MaybeGetTabInfo( + std::optional<base::Value::Dict> MaybeGetTabInfo( content::WebContents* web_contents) override; content::WebContents* GetWebContentsByTabId( content::BrowserContext* browser_context, diff --git a/shell/browser/login_handler.cc b/shell/browser/login_handler.cc index 446562c57e..44d14b1463 100644 --- a/shell/browser/login_handler.cc +++ b/shell/browser/login_handler.cc @@ -52,7 +52,7 @@ void LoginHandler::EmitEvent( api::WebContents* api_web_contents = api::WebContents::From(web_contents()); if (!api_web_contents) { - std::move(auth_required_callback_).Run(absl::nullopt); + std::move(auth_required_callback_).Run(std::nullopt); return; } @@ -75,7 +75,7 @@ void LoginHandler::EmitEvent( // deleted. Check the weak ptr before accessing any member variables to // prevent UAF. if (weak_this && !default_prevented && auth_required_callback_) { - std::move(auth_required_callback_).Run(absl::nullopt); + std::move(auth_required_callback_).Run(std::nullopt); } } @@ -85,7 +85,7 @@ void LoginHandler::CallbackFromJS(gin::Arguments* args) { if (auth_required_callback_) { std::u16string username, password; if (!args->GetNext(&username) || !args->GetNext(&password)) { - std::move(auth_required_callback_).Run(absl::nullopt); + std::move(auth_required_callback_).Run(std::nullopt); return; } std::move(auth_required_callback_) diff --git a/shell/browser/mac/in_app_purchase_observer.h b/shell/browser/mac/in_app_purchase_observer.h index a5e610091f..b8a1b4cdb8 100644 --- a/shell/browser/mac/in_app_purchase_observer.h +++ b/shell/browser/mac/in_app_purchase_observer.h @@ -5,13 +5,13 @@ #ifndef ELECTRON_SHELL_BROWSER_MAC_IN_APP_PURCHASE_OBSERVER_H_ #define ELECTRON_SHELL_BROWSER_MAC_IN_APP_PURCHASE_OBSERVER_H_ +#include <optional> #include <string> #include <vector> #include "base/functional/callback.h" #include "base/memory/raw_ptr_exclusion.h" #include "base/memory/weak_ptr.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #if defined(__OBJC__) @class InAppTransactionObserver; @@ -39,7 +39,7 @@ struct Payment { std::string productIdentifier = ""; int quantity = 1; std::string applicationUsername; - absl::optional<PaymentDiscount> paymentDiscount; + std::optional<PaymentDiscount> paymentDiscount; Payment(); Payment(const Payment&); diff --git a/shell/browser/mac/in_app_purchase_product.h b/shell/browser/mac/in_app_purchase_product.h index ad76841ffb..753f0d6317 100644 --- a/shell/browser/mac/in_app_purchase_product.h +++ b/shell/browser/mac/in_app_purchase_product.h @@ -5,11 +5,11 @@ #ifndef ELECTRON_SHELL_BROWSER_MAC_IN_APP_PURCHASE_PRODUCT_H_ #define ELECTRON_SHELL_BROWSER_MAC_IN_APP_PURCHASE_PRODUCT_H_ +#include <optional> #include <string> #include <vector> #include "base/functional/callback.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace in_app_purchase { @@ -31,7 +31,7 @@ struct ProductDiscount { std::string priceLocale; std::string paymentMode; int numberOfPeriods; - absl::optional<ProductSubscriptionPeriod> subscriptionPeriod; + std::optional<ProductSubscriptionPeriod> subscriptionPeriod; ProductDiscount(const ProductDiscount&); ProductDiscount(); @@ -50,10 +50,10 @@ struct Product { double price = 0.0; std::string formattedPrice; std::string currencyCode; - absl::optional<ProductDiscount> introductoryPrice; + std::optional<ProductDiscount> introductoryPrice; std::vector<ProductDiscount> discounts; std::string subscriptionGroupIdentifier; - absl::optional<ProductSubscriptionPeriod> subscriptionPeriod; + std::optional<ProductSubscriptionPeriod> subscriptionPeriod; // Downloadable Content Information bool isDownloadable = false; diff --git a/shell/browser/native_window.cc b/shell/browser/native_window.cc index 3be30d4455..46a0c7fc49 100644 --- a/shell/browser/native_window.cc +++ b/shell/browser/native_window.cc @@ -488,7 +488,7 @@ bool NativeWindow::AddTabbedWindow(NativeWindow* window) { return true; // for non-Mac platforms } -absl::optional<std::string> NativeWindow::GetTabbingIdentifier() const { +std::optional<std::string> NativeWindow::GetTabbingIdentifier() const { return ""; // for non-Mac platforms } @@ -539,7 +539,7 @@ void NativeWindow::PreviewFile(const std::string& path, void NativeWindow::CloseFilePreview() {} -absl::optional<gfx::Rect> NativeWindow::GetWindowControlsOverlayRect() { +std::optional<gfx::Rect> NativeWindow::GetWindowControlsOverlayRect() { return overlay_rect_; } diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h index b2d215854b..bc7868cc07 100644 --- a/shell/browser/native_window.h +++ b/shell/browser/native_window.h @@ -7,6 +7,7 @@ #include <list> #include <memory> +#include <optional> #include <queue> #include <string> #include <vector> @@ -22,7 +23,6 @@ #include "shell/browser/draggable_region_provider.h" #include "shell/browser/native_window_observer.h" #include "shell/browser/ui/inspectable_web_contents_view.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/views/widget/widget_delegate.h" class SkRegion; @@ -229,8 +229,8 @@ class NativeWindow : public base::SupportsUserData, #if BUILDFLAG(IS_MAC) virtual void SetWindowButtonVisibility(bool visible) = 0; virtual bool GetWindowButtonVisibility() const = 0; - virtual void SetWindowButtonPosition(absl::optional<gfx::Point> position) = 0; - virtual absl::optional<gfx::Point> GetWindowButtonPosition() const = 0; + virtual void SetWindowButtonPosition(std::optional<gfx::Point> position) = 0; + virtual std::optional<gfx::Point> GetWindowButtonPosition() const = 0; virtual void RedrawTrafficLights() = 0; virtual void UpdateFrame() = 0; #endif @@ -254,7 +254,7 @@ class NativeWindow : public base::SupportsUserData, virtual void MoveTabToNewWindow(); virtual void ToggleTabBar(); virtual bool AddTabbedWindow(NativeWindow* window); - virtual absl::optional<std::string> GetTabbingIdentifier() const; + virtual std::optional<std::string> GetTabbingIdentifier() const; // Toggle the menu bar. virtual void SetAutoHideMenuBar(bool auto_hide); @@ -284,7 +284,7 @@ class NativeWindow : public base::SupportsUserData, return weak_factory_.GetWeakPtr(); } - virtual absl::optional<gfx::Rect> GetWindowControlsOverlayRect(); + virtual std::optional<gfx::Rect> GetWindowControlsOverlayRect(); virtual void SetWindowControlsOverlayRect(const gfx::Rect& overlay_rect); // Methods called by the WebContents. @@ -433,11 +433,11 @@ class NativeWindow : public base::SupportsUserData, TitleBarStyle title_bar_style_ = TitleBarStyle::kNormal; // Minimum and maximum size. - absl::optional<extensions::SizeConstraints> size_constraints_; + std::optional<extensions::SizeConstraints> size_constraints_; // Same as above but stored as content size, we are storing 2 types of size // constraints beacause converting between them will cause rounding errors // on HiDPI displays on some environments. - absl::optional<extensions::SizeConstraints> content_size_constraints_; + std::optional<extensions::SizeConstraints> content_size_constraints_; std::queue<bool> pending_transitions_; FullScreenTransitionState fullscreen_transition_state_ = diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h index 3abbe323ad..fd359e9cce 100644 --- a/shell/browser/native_window_mac.h +++ b/shell/browser/native_window_mac.h @@ -8,6 +8,7 @@ #import <Cocoa/Cocoa.h> #include <memory> +#include <optional> #include <string> #include <vector> @@ -127,8 +128,8 @@ class NativeWindowMac : public NativeWindow, void SetVibrancy(const std::string& type) override; void SetWindowButtonVisibility(bool visible) override; bool GetWindowButtonVisibility() const override; - void SetWindowButtonPosition(absl::optional<gfx::Point> position) override; - absl::optional<gfx::Point> GetWindowButtonPosition() const override; + void SetWindowButtonPosition(std::optional<gfx::Point> position) override; + std::optional<gfx::Point> GetWindowButtonPosition() const override; void RedrawTrafficLights() override; void UpdateFrame() override; void SetTouchBar( @@ -142,7 +143,7 @@ class NativeWindowMac : public NativeWindow, void MoveTabToNewWindow() override; void ToggleTabBar() override; bool AddTabbedWindow(NativeWindow* window) override; - absl::optional<std::string> GetTabbingIdentifier() const override; + std::optional<std::string> GetTabbingIdentifier() const override; void SetAspectRatio(double aspect_ratio, const gfx::Size& extra_size) override; void PreviewFile(const std::string& path, @@ -150,7 +151,7 @@ class NativeWindowMac : public NativeWindow, void CloseFilePreview() override; gfx::Rect ContentBoundsToWindowBounds(const gfx::Rect& bounds) const override; gfx::Rect WindowBoundsToContentBounds(const gfx::Rect& bounds) const override; - absl::optional<gfx::Rect> GetWindowControlsOverlayRect() override; + std::optional<gfx::Rect> GetWindowControlsOverlayRect() override; void NotifyWindowEnterFullScreen() override; void NotifyWindowLeaveFullScreen() override; void SetActive(bool is_key) override; @@ -249,7 +250,7 @@ class NativeWindowMac : public NativeWindow, bool fullscreen_before_kiosk_ = false; bool is_kiosk_ = false; bool zoom_to_page_width_ = false; - absl::optional<gfx::Point> traffic_light_position_; + std::optional<gfx::Point> traffic_light_position_; // Trying to close an NSWindow during a fullscreen transition will cause the // window to lock up. Use this to track if CloseWindow was called during a @@ -271,7 +272,7 @@ class NativeWindowMac : public NativeWindow, // The visibility mode of window button controls when explicitly set through // setWindowButtonVisibility(). - absl::optional<bool> window_button_visibility_; + std::optional<bool> window_button_visibility_; // Controls the position and visibility of window buttons. WindowButtonsProxy* __strong buttons_proxy_; diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 0064431cc2..9e87c14ea4 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -1545,7 +1545,7 @@ bool NativeWindowMac::GetWindowButtonVisibility() const { } void NativeWindowMac::SetWindowButtonPosition( - absl::optional<gfx::Point> position) { + std::optional<gfx::Point> position) { traffic_light_position_ = std::move(position); if (buttons_proxy_) { [buttons_proxy_ setMargin:traffic_light_position_]; @@ -1553,7 +1553,7 @@ void NativeWindowMac::SetWindowButtonPosition( } } -absl::optional<gfx::Point> NativeWindowMac::GetWindowButtonPosition() const { +std::optional<gfx::Point> NativeWindowMac::GetWindowButtonPosition() const { return traffic_light_position_; } @@ -1623,9 +1623,9 @@ bool NativeWindowMac::AddTabbedWindow(NativeWindow* window) { return true; } -absl::optional<std::string> NativeWindowMac::GetTabbingIdentifier() const { +std::optional<std::string> NativeWindowMac::GetTabbingIdentifier() const { if ([window_ tabbingMode] == NSWindowTabbingModeDisallowed) - return absl::nullopt; + return std::nullopt; return base::SysNSStringToUTF8([window_ tabbingIdentifier]); } @@ -1870,9 +1870,9 @@ void NativeWindowMac::SetForwardMouseMessages(bool forward) { [window_ setAcceptsMouseMovedEvents:forward]; } -absl::optional<gfx::Rect> NativeWindowMac::GetWindowControlsOverlayRect() { +std::optional<gfx::Rect> NativeWindowMac::GetWindowControlsOverlayRect() { if (!titlebar_overlay_) - return absl::nullopt; + return std::nullopt; // On macOS, when in fullscreen mode, window controls (the menu bar, title // bar, and toolbar) are attached to a separate NSView that slides down from @@ -1896,7 +1896,7 @@ absl::optional<gfx::Rect> NativeWindowMac::GetWindowControlsOverlayRect() { return overlay; } - return absl::nullopt; + return std::nullopt; } // static diff --git a/shell/browser/native_window_views.h b/shell/browser/native_window_views.h index f8b1d272c4..e5683cecf0 100644 --- a/shell/browser/native_window_views.h +++ b/shell/browser/native_window_views.h @@ -8,6 +8,7 @@ #include "shell/browser/native_window.h" #include <memory> +#include <optional> #include <set> #include <string> @@ -304,7 +305,7 @@ class NativeWindowViews : public NativeWindow, // Whether the window is currently being moved. bool is_moving_ = false; - absl::optional<gfx::Rect> pending_bounds_change_; + std::optional<gfx::Rect> pending_bounds_change_; // The color to use as the theme and symbol colors respectively for Window // Controls Overlay if enabled on Windows. diff --git a/shell/browser/net/asar/asar_file_validator.h b/shell/browser/net/asar/asar_file_validator.h index b5ba25770e..31a8a05d8e 100644 --- a/shell/browser/net/asar/asar_file_validator.h +++ b/shell/browser/net/asar/asar_file_validator.h @@ -7,12 +7,12 @@ #include <algorithm> #include <memory> +#include <optional> #include "crypto/secure_hash.h" #include "mojo/public/cpp/system/file_data_source.h" #include "mojo/public/cpp/system/filtered_data_source.h" #include "shell/common/asar/archive.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace asar { diff --git a/shell/browser/net/asar/asar_url_loader.cc b/shell/browser/net/asar/asar_url_loader.cc index 74a4353313..c1e83c5d6e 100644 --- a/shell/browser/net/asar/asar_url_loader.cc +++ b/shell/browser/net/asar/asar_url_loader.cc @@ -78,7 +78,7 @@ class AsarURLLoader : public network::mojom::URLLoader { const std::vector<std::string>& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional<GURL>& new_url) override {} + const std::optional<GURL>& new_url) override {} void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override {} void PauseReadingBodyFromNet() override {} @@ -270,7 +270,7 @@ class AsarURLLoader : public network::mojom::URLLoader { head->mime_type.c_str()); } client_->OnReceiveResponse(std::move(head), std::move(consumer_handle), - absl::nullopt); + std::nullopt); if (total_bytes_to_send == 0) { // There's definitely no more data, so we're already done. diff --git a/shell/browser/net/cert_verifier_client.cc b/shell/browser/net/cert_verifier_client.cc index bf14cdb397..0a9d2dca85 100644 --- a/shell/browser/net/cert_verifier_client.cc +++ b/shell/browser/net/cert_verifier_client.cc @@ -26,7 +26,7 @@ void CertVerifierClient::Verify( const scoped_refptr<net::X509Certificate>& certificate, const std::string& hostname, int flags, - const absl::optional<std::string>& ocsp_response, + const std::optional<std::string>& ocsp_response, VerifyCallback callback) { VerifyRequestParams params; params.hostname = hostname; diff --git a/shell/browser/net/cert_verifier_client.h b/shell/browser/net/cert_verifier_client.h index f46eaf87b5..975c5b7871 100644 --- a/shell/browser/net/cert_verifier_client.h +++ b/shell/browser/net/cert_verifier_client.h @@ -40,7 +40,7 @@ class CertVerifierClient : public network::mojom::CertVerifierClient { const scoped_refptr<net::X509Certificate>& certificate, const std::string& hostname, int flags, - const absl::optional<std::string>& ocsp_response, + const std::optional<std::string>& ocsp_response, VerifyCallback callback) override; private: diff --git a/shell/browser/net/electron_url_loader_factory.cc b/shell/browser/net/electron_url_loader_factory.cc index 933c706c01..e07730ccde 100644 --- a/shell/browser/net/electron_url_loader_factory.cc +++ b/shell/browser/net/electron_url_loader_factory.cc @@ -211,7 +211,7 @@ void ElectronURLLoaderFactory::RedirectedRequest::FollowRedirect( const std::vector<std::string>& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional<GURL>& new_url) { + const std::optional<GURL>& new_url) { // Update |request_| with info from the redirect, so that it's accurate // The following references code in WorkerScriptLoader::FollowRedirect bool should_clear_upload = false; @@ -592,7 +592,7 @@ void ElectronURLLoaderFactory::StartLoadingStream( // Note that We must submit a empty body otherwise NetworkService would // crash. client_remote->OnReceiveResponse(std::move(head), std::move(consumer), - absl::nullopt); + std::nullopt); producer.reset(); // The data pipe is empty. client_remote->OnComplete(network::URLLoaderCompletionStatus(net::OK)); return; @@ -640,7 +640,7 @@ void ElectronURLLoaderFactory::SendContents( } client_remote->OnReceiveResponse(std::move(head), std::move(consumer), - absl::nullopt); + std::nullopt); auto write_data = std::make_unique<WriteData>(); write_data->client = std::move(client_remote); diff --git a/shell/browser/net/electron_url_loader_factory.h b/shell/browser/net/electron_url_loader_factory.h index 60a451332e..9fd628bddd 100644 --- a/shell/browser/net/electron_url_loader_factory.h +++ b/shell/browser/net/electron_url_loader_factory.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_NET_ELECTRON_URL_LOADER_FACTORY_H_ #include <map> +#include <optional> #include <string> #include <utility> #include <vector> @@ -21,7 +22,6 @@ #include "services/network/public/mojom/url_loader_factory.mojom.h" #include "services/network/public/mojom/url_response_head.mojom.h" #include "shell/common/gin_helper/dictionary.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace electron { @@ -73,7 +73,7 @@ class ElectronURLLoaderFactory : public network::SelfDeletingURLLoaderFactory { const std::vector<std::string>& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional<GURL>& new_url) override; + const std::optional<GURL>& new_url) override; void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override {} void PauseReadingBodyFromNet() override {} diff --git a/shell/browser/net/node_stream_loader.cc b/shell/browser/net/node_stream_loader.cc index d0ea49cd9c..d11e5eccba 100644 --- a/shell/browser/net/node_stream_loader.cc +++ b/shell/browser/net/node_stream_loader.cc @@ -59,7 +59,7 @@ void NodeStreamLoader::Start(network::mojom::URLResponseHeadPtr head) { producer_ = std::make_unique<mojo::DataPipeProducer>(std::move(producer)); client_->OnReceiveResponse(std::move(head), std::move(consumer), - absl::nullopt); + std::nullopt); auto weak = weak_factory_.GetWeakPtr(); On("end", diff --git a/shell/browser/net/node_stream_loader.h b/shell/browser/net/node_stream_loader.h index 5629f64b55..5ca1e9b299 100644 --- a/shell/browser/net/node_stream_loader.h +++ b/shell/browser/net/node_stream_loader.h @@ -60,7 +60,7 @@ class NodeStreamLoader : public network::mojom::URLLoader { const std::vector<std::string>& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional<GURL>& new_url) override {} + const std::optional<GURL>& new_url) override {} void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override {} void PauseReadingBodyFromNet() override {} diff --git a/shell/browser/net/proxying_url_loader_factory.cc b/shell/browser/net/proxying_url_loader_factory.cc index 3d38d75396..2a0728105f 100644 --- a/shell/browser/net/proxying_url_loader_factory.cc +++ b/shell/browser/net/proxying_url_loader_factory.cc @@ -93,11 +93,11 @@ ProxyingURLLoaderFactory::InProgressRequest::~InProgressRequest() { } if (on_before_send_headers_callback_) { std::move(on_before_send_headers_callback_) - .Run(net::ERR_ABORTED, absl::nullopt); + .Run(net::ERR_ABORTED, std::nullopt); } if (on_headers_received_callback_) { std::move(on_headers_received_callback_) - .Run(net::ERR_ABORTED, absl::nullopt, absl::nullopt); + .Run(net::ERR_ABORTED, std::nullopt, std::nullopt); } } @@ -182,7 +182,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::FollowRedirect( const std::vector<std::string>& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional<GURL>& new_url) { + const std::optional<GURL>& new_url) { if (new_url) request_.url = new_url.value(); @@ -241,7 +241,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnReceiveEarlyHints( void ProxyingURLLoaderFactory::InProgressRequest::OnReceiveResponse( network::mojom::URLResponseHeadPtr head, mojo::ScopedDataPipeConsumerHandle body, - absl::optional<mojo_base::BigBuffer> cached_metadata) { + std::optional<mojo_base::BigBuffer> cached_metadata) { current_body_ = std::move(body); current_cached_metadata_ = std::move(cached_metadata); if (current_request_uses_header_client_) { @@ -342,7 +342,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnBeforeSendHeaders( const net::HttpRequestHeaders& headers, OnBeforeSendHeadersCallback callback) { if (!current_request_uses_header_client_) { - std::move(callback).Run(net::OK, absl::nullopt); + std::move(callback).Run(net::OK, std::nullopt); return; } @@ -356,7 +356,7 @@ void ProxyingURLLoaderFactory::InProgressRequest::OnHeadersReceived( const net::IPEndPoint& remote_endpoint, OnHeadersReceivedCallback callback) { if (!current_request_uses_header_client_) { - std::move(callback).Run(net::OK, absl::nullopt, GURL()); + std::move(callback).Run(net::OK, std::nullopt, GURL()); if (for_cors_preflight_) { // CORS preflight is supported only when "extraHeaders" is specified. @@ -581,7 +581,7 @@ void ProxyingURLLoaderFactory::InProgressRequest:: } DCHECK(on_headers_received_callback_); - absl::optional<std::string> headers; + std::optional<std::string> headers; if (override_headers_) { headers = override_headers_->raw_headers(); if (current_request_uses_header_client_) { @@ -749,7 +749,7 @@ ProxyingURLLoaderFactory::ProxyingURLLoaderFactory( int frame_routing_id, uint64_t* request_id_generator, std::unique_ptr<extensions::ExtensionNavigationUIData> navigation_ui_data, - absl::optional<int64_t> navigation_id, + std::optional<int64_t> navigation_id, mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_request, mojo::PendingRemote<network::mojom::URLLoaderFactory> target_factory_remote, mojo::PendingReceiver<network::mojom::TrustedURLLoaderHeaderClient> diff --git a/shell/browser/net/proxying_url_loader_factory.h b/shell/browser/net/proxying_url_loader_factory.h index 49a107e5d5..828c7da67f 100644 --- a/shell/browser/net/proxying_url_loader_factory.h +++ b/shell/browser/net/proxying_url_loader_factory.h @@ -7,6 +7,7 @@ #include <cstdint> #include <memory> +#include <optional> #include <set> #include <string> #include <vector> @@ -33,7 +34,6 @@ #include "services/network/url_loader_factory.h" #include "shell/browser/net/electron_url_loader_factory.h" #include "shell/browser/net/web_request_api_interface.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace electron { @@ -83,7 +83,7 @@ class ProxyingURLLoaderFactory const std::vector<std::string>& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional<GURL>& new_url) override; + const std::optional<GURL>& new_url) override; void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override; void PauseReadingBodyFromNet() override; @@ -95,7 +95,7 @@ class ProxyingURLLoaderFactory void OnReceiveResponse( network::mojom::URLResponseHeadPtr head, mojo::ScopedDataPipeConsumerHandle body, - absl::optional<mojo_base::BigBuffer> cached_metadata) override; + std::optional<mojo_base::BigBuffer> cached_metadata) override; void OnReceiveRedirect(const net::RedirectInfo& redirect_info, network::mojom::URLResponseHeadPtr head) override; void OnUploadProgress(int64_t current_position, @@ -135,7 +135,7 @@ class ProxyingURLLoaderFactory raw_ptr<ProxyingURLLoaderFactory> const factory_; network::ResourceRequest request_; - const absl::optional<url::Origin> original_initiator_; + const std::optional<url::Origin> original_initiator_; const uint64_t request_id_ = 0; const int32_t network_service_request_id_ = 0; const int32_t frame_routing_id_ = MSG_ROUTING_NONE; @@ -144,7 +144,7 @@ class ProxyingURLLoaderFactory mojo::Receiver<network::mojom::URLLoader> proxied_loader_receiver_; mojo::Remote<network::mojom::URLLoaderClient> target_client_; - absl::optional<extensions::WebRequestInfo> info_; + std::optional<extensions::WebRequestInfo> info_; mojo::Receiver<network::mojom::URLLoaderClient> proxied_client_receiver_{ this}; @@ -180,7 +180,7 @@ class ProxyingURLLoaderFactory std::vector<std::string> removed_headers; net::HttpRequestHeaders modified_headers; net::HttpRequestHeaders modified_cors_exempt_headers; - absl::optional<GURL> new_url; + std::optional<GURL> new_url; // disable copy FollowRedirectParams(const FollowRedirectParams&) = delete; @@ -188,7 +188,7 @@ class ProxyingURLLoaderFactory }; std::unique_ptr<FollowRedirectParams> pending_follow_redirect_params_; - absl::optional<mojo_base::BigBuffer> current_cached_metadata_; + std::optional<mojo_base::BigBuffer> current_cached_metadata_; base::WeakPtrFactory<InProgressRequest> weak_factory_{this}; }; @@ -200,7 +200,7 @@ class ProxyingURLLoaderFactory int frame_routing_id, uint64_t* request_id_generator, std::unique_ptr<extensions::ExtensionNavigationUIData> navigation_ui_data, - absl::optional<int64_t> navigation_id, + std::optional<int64_t> navigation_id, mojo::PendingReceiver<network::mojom::URLLoaderFactory> loader_request, mojo::PendingRemote<network::mojom::URLLoaderFactory> target_factory_remote, @@ -264,7 +264,7 @@ class ProxyingURLLoaderFactory const int frame_routing_id_; raw_ptr<uint64_t> request_id_generator_; // managed by ElectronBrowserClient std::unique_ptr<extensions::ExtensionNavigationUIData> navigation_ui_data_; - absl::optional<int64_t> navigation_id_; + std::optional<int64_t> navigation_id_; mojo::ReceiverSet<network::mojom::URLLoaderFactory> proxy_receivers_; mojo::Remote<network::mojom::URLLoaderFactory> target_factory_; mojo::Receiver<network::mojom::TrustedURLLoaderHeaderClient> diff --git a/shell/browser/net/proxying_websocket.cc b/shell/browser/net/proxying_websocket.cc index 3519f67d36..ae73b6d70f 100644 --- a/shell/browser/net/proxying_websocket.cc +++ b/shell/browser/net/proxying_websocket.cc @@ -44,16 +44,16 @@ ProxyingWebSocket::ProxyingWebSocket( /*is_download=*/false, /*is_async=*/true, /*is_service_worker_script=*/false, - /*navigation_id=*/absl::nullopt)) {} + /*navigation_id=*/std::nullopt)) {} ProxyingWebSocket::~ProxyingWebSocket() { if (on_before_send_headers_callback_) { std::move(on_before_send_headers_callback_) - .Run(net::ERR_ABORTED, absl::nullopt); + .Run(net::ERR_ABORTED, std::nullopt); } if (on_headers_received_callback_) { std::move(on_headers_received_callback_) - .Run(net::ERR_ABORTED, absl::nullopt, GURL()); + .Run(net::ERR_ABORTED, std::nullopt, GURL()); } } @@ -229,7 +229,7 @@ void ProxyingWebSocket::StartProxying( WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const absl::optional<std::string>& user_agent, + const std::optional<std::string>& user_agent, mojo::PendingRemote<network::mojom::WebSocketHandshakeClient> handshake_client, bool has_extra_headers, @@ -358,11 +358,11 @@ void ProxyingWebSocket::OnHeadersReceivedComplete(int error_code) { } if (on_headers_received_callback_) { - absl::optional<std::string> headers; + std::optional<std::string> headers; if (override_headers_) headers = override_headers_->raw_headers(); std::move(on_headers_received_callback_) - .Run(net::OK, headers, absl::nullopt); + .Run(net::OK, headers, std::nullopt); } if (override_headers_) { @@ -384,7 +384,7 @@ void ProxyingWebSocket::OnAuthRequiredComplete(AuthRequiredResponse rv) { switch (rv) { case AuthRequiredResponse::kNoAction: case AuthRequiredResponse::kCancelAuth: - std::move(auth_required_callback_).Run(absl::nullopt); + std::move(auth_required_callback_).Run(std::nullopt); break; case AuthRequiredResponse::kSetAuth: diff --git a/shell/browser/net/proxying_websocket.h b/shell/browser/net/proxying_websocket.h index 96dc08bb58..c3e953c2f7 100644 --- a/shell/browser/net/proxying_websocket.h +++ b/shell/browser/net/proxying_websocket.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_NET_PROXYING_WEBSOCKET_H_ #define ELECTRON_SHELL_BROWSER_NET_PROXYING_WEBSOCKET_H_ +#include <optional> #include <set> #include <string> #include <vector> @@ -19,7 +20,6 @@ #include "services/network/public/mojom/network_context.mojom.h" #include "services/network/public/mojom/websocket.mojom.h" #include "shell/browser/net/web_request_api_interface.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" #include "url/origin.h" @@ -101,7 +101,7 @@ class ProxyingWebSocket : public network::mojom::WebSocketHandshakeClient, WebSocketFactory factory, const GURL& url, const net::SiteForCookies& site_for_cookies, - const absl::optional<std::string>& user_agent, + const std::optional<std::string>& user_agent, mojo::PendingRemote<network::mojom::WebSocketHandshakeClient> handshake_client, bool has_extra_headers, diff --git a/shell/browser/net/resolve_host_function.cc b/shell/browser/net/resolve_host_function.cc index 3071955e92..826511f006 100644 --- a/shell/browser/net/resolve_host_function.cc +++ b/shell/browser/net/resolve_host_function.cc @@ -53,8 +53,8 @@ void ResolveHostFunction::Run() { receiver_.set_disconnect_handler(base::BindOnce( &ResolveHostFunction::OnComplete, this, net::ERR_NAME_NOT_RESOLVED, net::ResolveErrorInfo(net::ERR_FAILED), - /*resolved_addresses=*/absl::nullopt, - /*endpoint_results_with_metadata=*/absl::nullopt)); + /*resolved_addresses=*/std::nullopt, + /*endpoint_results_with_metadata=*/std::nullopt)); if (electron::IsUtilityProcess()) { URLLoaderBundle::GetInstance()->GetHostResolver()->ResolveHost( network::mojom::HostResolverHost::NewHostPortPair( @@ -75,8 +75,8 @@ void ResolveHostFunction::Run() { void ResolveHostFunction::OnComplete( int result, const net::ResolveErrorInfo& resolve_error_info, - const absl::optional<net::AddressList>& resolved_addresses, - const absl::optional<net::HostResolverEndpointResults>& + const std::optional<net::AddressList>& resolved_addresses, + const std::optional<net::HostResolverEndpointResults>& endpoint_results_with_metadata) { DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); diff --git a/shell/browser/net/resolve_host_function.h b/shell/browser/net/resolve_host_function.h index a860e09d5f..0260faaa22 100644 --- a/shell/browser/net/resolve_host_function.h +++ b/shell/browser/net/resolve_host_function.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_NET_RESOLVE_HOST_FUNCTION_H_ #define ELECTRON_SHELL_BROWSER_NET_RESOLVE_HOST_FUNCTION_H_ +#include <optional> #include <string> #include "base/memory/raw_ptr.h" @@ -16,7 +17,6 @@ #include "services/network/public/cpp/resolve_host_client_base.h" #include "services/network/public/mojom/host_resolver.mojom.h" #include "services/network/public/mojom/network_context.mojom.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace electron { @@ -26,9 +26,8 @@ class ResolveHostFunction : public base::RefCountedThreadSafe<ResolveHostFunction>, network::ResolveHostClientBase { public: - using ResolveHostCallback = base::OnceCallback<void( - int64_t, - const absl::optional<net::AddressList>& resolved_addresses)>; + using ResolveHostCallback = base::OnceCallback< + void(int64_t, const std::optional<net::AddressList>& resolved_addresses)>; explicit ResolveHostFunction(ElectronBrowserContext* browser_context, std::string host, @@ -50,8 +49,8 @@ class ResolveHostFunction // network::mojom::ResolveHostClient implementation void OnComplete(int result, const net::ResolveErrorInfo& resolve_error_info, - const absl::optional<net::AddressList>& resolved_addresses, - const absl::optional<net::HostResolverEndpointResults>& + const std::optional<net::AddressList>& resolved_addresses, + const std::optional<net::HostResolverEndpointResults>& endpoint_results_with_metadata) override; SEQUENCE_CHECKER(sequence_checker_); diff --git a/shell/browser/net/resolve_proxy_helper.cc b/shell/browser/net/resolve_proxy_helper.cc index 474a3ec494..106e863169 100644 --- a/shell/browser/net/resolve_proxy_helper.cc +++ b/shell/browser/net/resolve_proxy_helper.cc @@ -53,7 +53,7 @@ void ResolveProxyHelper::StartPendingRequest() { receiver_.BindNewPipeAndPassRemote(); receiver_.set_disconnect_handler( base::BindOnce(&ResolveProxyHelper::OnProxyLookupComplete, - base::Unretained(this), net::ERR_ABORTED, absl::nullopt)); + base::Unretained(this), net::ERR_ABORTED, std::nullopt)); browser_context_->GetDefaultStoragePartition() ->GetNetworkContext() ->LookUpProxyForURL(pending_requests_.front().url, @@ -63,7 +63,7 @@ void ResolveProxyHelper::StartPendingRequest() { void ResolveProxyHelper::OnProxyLookupComplete( int32_t net_error, - const absl::optional<net::ProxyInfo>& proxy_info) { + const std::optional<net::ProxyInfo>& proxy_info) { DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!pending_requests_.empty()); diff --git a/shell/browser/net/resolve_proxy_helper.h b/shell/browser/net/resolve_proxy_helper.h index 632e160041..20c998be26 100644 --- a/shell/browser/net/resolve_proxy_helper.h +++ b/shell/browser/net/resolve_proxy_helper.h @@ -6,13 +6,13 @@ #define ELECTRON_SHELL_BROWSER_NET_RESOLVE_PROXY_HELPER_H_ #include <deque> +#include <optional> #include <string> #include "base/memory/raw_ptr.h" #include "base/memory/ref_counted.h" #include "mojo/public/cpp/bindings/receiver.h" #include "services/network/public/mojom/proxy_lookup_client.mojom.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "url/gurl.h" namespace electron { @@ -61,7 +61,7 @@ class ResolveProxyHelper // network::mojom::ProxyLookupClient implementation. void OnProxyLookupComplete( int32_t net_error, - const absl::optional<net::ProxyInfo>& proxy_info) override; + const std::optional<net::ProxyInfo>& proxy_info) override; // Self-reference. Owned as long as there's an outstanding proxy lookup. scoped_refptr<ResolveProxyHelper> owned_self_; diff --git a/shell/browser/net/system_network_context_manager.h b/shell/browser/net/system_network_context_manager.h index dfce7949f7..819894da4c 100644 --- a/shell/browser/net/system_network_context_manager.h +++ b/shell/browser/net/system_network_context_manager.h @@ -5,6 +5,8 @@ #ifndef ELECTRON_SHELL_BROWSER_NET_SYSTEM_NETWORK_CONTEXT_MANAGER_H_ #define ELECTRON_SHELL_BROWSER_NET_SYSTEM_NETWORK_CONTEXT_MANAGER_H_ +#include <optional> + #include "base/memory/ref_counted.h" #include "chrome/browser/net/proxy_config_monitor.h" #include "mojo/public/cpp/bindings/remote.h" @@ -14,7 +16,6 @@ #include "services/network/public/mojom/network_service.mojom.h" #include "services/network/public/mojom/url_loader.mojom.h" #include "services/network/public/mojom/url_loader_factory.mojom.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace electron { network::mojom::HttpAuthDynamicParamsPtr CreateHttpAuthDynamicParams(); diff --git a/shell/browser/net/url_pipe_loader.cc b/shell/browser/net/url_pipe_loader.cc index ff53323ffa..688613deee 100644 --- a/shell/browser/net/url_pipe_loader.cc +++ b/shell/browser/net/url_pipe_loader.cc @@ -72,7 +72,7 @@ void URLPipeLoader::OnResponseStarted( producer_ = std::make_unique<mojo::DataPipeProducer>(std::move(producer)); client_->OnReceiveResponse(response_head.Clone(), std::move(consumer), - absl::nullopt); + std::nullopt); } void URLPipeLoader::OnWrite(base::OnceClosure resume, MojoResult result) { diff --git a/shell/browser/net/url_pipe_loader.h b/shell/browser/net/url_pipe_loader.h index e55a771ea1..bb302084bd 100644 --- a/shell/browser/net/url_pipe_loader.h +++ b/shell/browser/net/url_pipe_loader.h @@ -68,7 +68,7 @@ class URLPipeLoader : public network::mojom::URLLoader, const std::vector<std::string>& removed_headers, const net::HttpRequestHeaders& modified_headers, const net::HttpRequestHeaders& modified_cors_exempt_headers, - const absl::optional<GURL>& new_url) override {} + const std::optional<GURL>& new_url) override {} void SetPriority(net::RequestPriority priority, int32_t intra_priority_value) override {} void PauseReadingBodyFromNet() override {} diff --git a/shell/browser/osr/osr_render_widget_host_view.cc b/shell/browser/osr/osr_render_widget_host_view.cc index d9bd9211cc..12e45ae544 100644 --- a/shell/browser/osr/osr_render_widget_host_view.cc +++ b/shell/browser/osr/osr_render_widget_host_view.cc @@ -6,6 +6,7 @@ #include <algorithm> #include <memory> +#include <optional> #include <utility> #include <vector> @@ -31,7 +32,6 @@ #include "content/public/browser/render_process_host.h" #include "gpu/command_buffer/client/gl_helper.h" #include "media/base/video_frame.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "third_party/blink/public/common/input/web_input_event.h" #include "third_party/skia/include/core/SkCanvas.h" #include "ui/compositor/compositor.h" @@ -355,7 +355,7 @@ void OffScreenRenderWidgetHostView::SetBackgroundColor(SkColor color) { } } -absl::optional<SkColor> OffScreenRenderWidgetHostView::GetBackgroundColor() { +std::optional<SkColor> OffScreenRenderWidgetHostView::GetBackgroundColor() { return background_color_; } @@ -508,9 +508,9 @@ gfx::Rect OffScreenRenderWidgetHostView::GetBoundsInRootWindow() { return gfx::Rect(size_); } -absl::optional<content::DisplayFeature> +std::optional<content::DisplayFeature> OffScreenRenderWidgetHostView::GetDisplayFeature() { - return absl::nullopt; + return std::nullopt; } void OffScreenRenderWidgetHostView::SetDisplayFeatureForTesting( @@ -530,8 +530,8 @@ OffScreenRenderWidgetHostView::CreateSyntheticGestureTarget() { void OffScreenRenderWidgetHostView::ImeCompositionRangeChanged( const gfx::Range&, - const absl::optional<std::vector<gfx::Rect>>& character_bounds, - const absl::optional<std::vector<gfx::Rect>>& line_bounds) {} + const std::optional<std::vector<gfx::Rect>>& character_bounds, + const std::optional<std::vector<gfx::Rect>>& line_bounds) {} gfx::Size OffScreenRenderWidgetHostView::GetCompositorViewportPixelSize() { return gfx::ScaleToCeiledSize(GetRequestedRendererSize(), diff --git a/shell/browser/osr/osr_render_widget_host_view.h b/shell/browser/osr/osr_render_widget_host_view.h index f85d8cc17b..fa3da32660 100644 --- a/shell/browser/osr/osr_render_widget_host_view.h +++ b/shell/browser/osr/osr_render_widget_host_view.h @@ -95,7 +95,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, gfx::Size GetVisibleViewportSize() override; void SetInsets(const gfx::Insets&) override; void SetBackgroundColor(SkColor color) override; - absl::optional<SkColor> GetBackgroundColor() override; + std::optional<SkColor> GetBackgroundColor() override; void UpdateBackgroundColor() override; blink::mojom::PointerLockResult LockMouse( bool request_unadjusted_movement) override; @@ -141,7 +141,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, display::ScreenInfo GetScreenInfo() const override; void TransformPointToRootSurface(gfx::PointF* point) override; gfx::Rect GetBoundsInRootWindow(void) override; - absl::optional<content::DisplayFeature> GetDisplayFeature() override; + std::optional<content::DisplayFeature> GetDisplayFeature() override; void SetDisplayFeatureForTesting( const content::DisplayFeature* display_feature) override; void NotifyHostAndDelegateOnWasShown( @@ -154,8 +154,8 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, CreateSyntheticGestureTarget() override; void ImeCompositionRangeChanged( const gfx::Range&, - const absl::optional<std::vector<gfx::Rect>>& character_bounds, - const absl::optional<std::vector<gfx::Rect>>& line_bounds) override; + const std::optional<std::vector<gfx::Rect>>& character_bounds, + const std::optional<std::vector<gfx::Rect>>& line_bounds) override; gfx::Size GetCompositorViewportPixelSize() override; ui::Compositor* GetCompositor() override; diff --git a/shell/browser/osr/osr_video_consumer.cc b/shell/browser/osr/osr_video_consumer.cc index f2ed683460..917b483e2e 100644 --- a/shell/browser/osr/osr_video_consumer.cc +++ b/shell/browser/osr/osr_video_consumer.cc @@ -128,7 +128,7 @@ void OffScreenVideoConsumer::OnFrameCaptured( new FramePinner{std::move(mapping), callbacks_remote.Unbind()}); bitmap.setImmutable(); - absl::optional<gfx::Rect> update_rect = info->metadata.capture_update_rect; + std::optional<gfx::Rect> update_rect = info->metadata.capture_update_rect; if (!update_rect.has_value() || update_rect->IsEmpty()) { update_rect = content_rect; } diff --git a/shell/browser/ui/accelerator_util.cc b/shell/browser/ui/accelerator_util.cc index 6f1dfaca36..28f1fb9ac4 100644 --- a/shell/browser/ui/accelerator_util.cc +++ b/shell/browser/ui/accelerator_util.cc @@ -34,7 +34,7 @@ bool StringToAccelerator(const std::string& shortcut, // Now, parse it into an accelerator. int modifiers = ui::EF_NONE; ui::KeyboardCode key = ui::VKEY_UNKNOWN; - absl::optional<char16_t> shifted_char; + std::optional<char16_t> shifted_char; for (const auto& token : tokens) { ui::KeyboardCode code = electron::KeyboardCodeFromStr(token, &shifted_char); if (shifted_char) diff --git a/shell/browser/ui/cocoa/electron_ns_window_delegate.h b/shell/browser/ui/cocoa/electron_ns_window_delegate.h index 97e7dddf3e..f65d78a095 100644 --- a/shell/browser/ui/cocoa/electron_ns_window_delegate.h +++ b/shell/browser/ui/cocoa/electron_ns_window_delegate.h @@ -7,9 +7,10 @@ #include <Quartz/Quartz.h> +#include <optional> + #include "base/memory/raw_ptr.h" #include "components/remote_cocoa/app_shim/views_nswindow_delegate.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace electron { class NativeWindowMac; @@ -30,7 +31,7 @@ class NativeWindowMac; // Only valid during a live resize. // Used to keep track of whether a resize is happening horizontally or // vertically, even if physically the user is resizing in both directions. - absl::optional<bool> resizingHorizontally_; + std::optional<bool> resizingHorizontally_; } - (id)initWithShell:(electron::NativeWindowMac*)shell; @end diff --git a/shell/browser/ui/cocoa/window_buttons_proxy.h b/shell/browser/ui/cocoa/window_buttons_proxy.h index 39ef57c4c4..77b68d79d1 100644 --- a/shell/browser/ui/cocoa/window_buttons_proxy.h +++ b/shell/browser/ui/cocoa/window_buttons_proxy.h @@ -7,7 +7,8 @@ #import <Cocoa/Cocoa.h> -#include "third_party/abseil-cpp/absl/types/optional.h" +#include <optional> + #include "ui/gfx/geometry/point.h" @class WindowButtonsProxy; @@ -48,7 +49,7 @@ - (void)setShowOnHover:(BOOL)yes; // Set left-top margin of the window buttons.. -- (void)setMargin:(const absl::optional<gfx::Point>&)margin; +- (void)setMargin:(const std::optional<gfx::Point>&)margin; // Set height of button container - (void)setHeight:(const float)height; diff --git a/shell/browser/ui/cocoa/window_buttons_proxy.mm b/shell/browser/ui/cocoa/window_buttons_proxy.mm index 6cc28b279b..2edf2d22d7 100644 --- a/shell/browser/ui/cocoa/window_buttons_proxy.mm +++ b/shell/browser/ui/cocoa/window_buttons_proxy.mm @@ -79,7 +79,7 @@ [self updateButtonsVisibility]; } -- (void)setMargin:(const absl::optional<gfx::Point>&)margin { +- (void)setMargin:(const std::optional<gfx::Point>&)margin { if (margin) margin_ = *margin; else diff --git a/shell/browser/ui/electron_menu_model.cc b/shell/browser/ui/electron_menu_model.cc index 3f305cb515..d85de9d907 100644 --- a/shell/browser/ui/electron_menu_model.cc +++ b/shell/browser/ui/electron_menu_model.cc @@ -100,7 +100,7 @@ void ElectronMenuModel::SetSharingItem(SharingItem item) { sharing_item_.emplace(std::move(item)); } -const absl::optional<ElectronMenuModel::SharingItem>& +const std::optional<ElectronMenuModel::SharingItem>& ElectronMenuModel::GetSharingItem() const { return sharing_item_; } diff --git a/shell/browser/ui/electron_menu_model.h b/shell/browser/ui/electron_menu_model.h index ba96b14187..297b302288 100644 --- a/shell/browser/ui/electron_menu_model.h +++ b/shell/browser/ui/electron_menu_model.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_UI_ELECTRON_MENU_MODEL_H_ #define ELECTRON_SHELL_BROWSER_UI_ELECTRON_MENU_MODEL_H_ +#include <optional> #include <string> #include <vector> @@ -14,7 +15,6 @@ #include "base/memory/weak_ptr.h" #include "base/observer_list.h" #include "base/observer_list_types.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/models/simple_menu_model.h" #include "url/gurl.h" @@ -29,9 +29,9 @@ class ElectronMenuModel : public ui::SimpleMenuModel { SharingItem(const SharingItem&) = delete; ~SharingItem(); - absl::optional<std::vector<std::string>> texts; - absl::optional<std::vector<GURL>> urls; - absl::optional<std::vector<base::FilePath>> file_paths; + std::optional<std::vector<std::string>> texts; + std::optional<std::vector<GURL>> urls; + std::optional<std::vector<base::FilePath>> file_paths; }; #endif @@ -98,7 +98,7 @@ class ElectronMenuModel : public ui::SimpleMenuModel { bool GetSharingItemAt(size_t index, SharingItem* item) const; // Set/Get the SharingItem of this menu. void SetSharingItem(SharingItem item); - const absl::optional<SharingItem>& GetSharingItem() const; + const std::optional<SharingItem>& GetSharingItem() const; #endif // ui::SimpleMenuModel: @@ -116,7 +116,7 @@ class ElectronMenuModel : public ui::SimpleMenuModel { raw_ptr<Delegate> delegate_; // weak ref. #if BUILDFLAG(IS_MAC) - absl::optional<SharingItem> sharing_item_; + std::optional<SharingItem> sharing_item_; #endif base::flat_map<int, std::u16string> toolTips_; // command id -> tooltip diff --git a/shell/browser/ui/message_box.h b/shell/browser/ui/message_box.h index 66932b515d..489b17a328 100644 --- a/shell/browser/ui/message_box.h +++ b/shell/browser/ui/message_box.h @@ -5,12 +5,12 @@ #ifndef ELECTRON_SHELL_BROWSER_UI_MESSAGE_BOX_H_ #define ELECTRON_SHELL_BROWSER_UI_MESSAGE_BOX_H_ +#include <optional> #include <string> #include <vector> #include "base/functional/callback_forward.h" #include "base/memory/raw_ptr_exclusion.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/gfx/image/image_skia.h" namespace electron { @@ -29,7 +29,7 @@ struct MessageBoxSettings { RAW_PTR_EXCLUSION electron::NativeWindow* parent_window = nullptr; MessageBoxType type = electron::MessageBoxType::kNone; std::vector<std::string> buttons; - absl::optional<int> id; + std::optional<int> id; int default_id; int cancel_id; bool no_link = false; diff --git a/shell/browser/ui/message_box_gtk.cc b/shell/browser/ui/message_box_gtk.cc index dd5130722c..51bb743b0d 100644 --- a/shell/browser/ui/message_box_gtk.cc +++ b/shell/browser/ui/message_box_gtk.cc @@ -192,7 +192,7 @@ class GtkMessageBox : public NativeWindowObserver { private: // The id of the dialog. - absl::optional<int> id_; + std::optional<int> id_; // The id to return when the dialog is closed without pressing buttons. int cancel_id_ = 0; diff --git a/shell/browser/ui/message_box_mac.mm b/shell/browser/ui/message_box_mac.mm index 63d93d3efe..975e5e0a72 100644 --- a/shell/browser/ui/message_box_mac.mm +++ b/shell/browser/ui/message_box_mac.mm @@ -162,7 +162,7 @@ void ShowMessageBox(const MessageBoxSettings& settings, // Duplicate the callback object here since c is a reference and gcd would // only store the pointer, by duplication we can force gcd to store a copy. __block MessageBoxCallback callback_ = std::move(callback); - __block absl::optional<int> id = std::move(settings.id); + __block std::optional<int> id = std::move(settings.id); __block int cancel_id = settings.cancel_id; auto handler = ^(NSModalResponse response) { diff --git a/shell/browser/ui/message_box_win.cc b/shell/browser/ui/message_box_win.cc index f5f64dae50..3761ccd7d3 100644 --- a/shell/browser/ui/message_box_win.cc +++ b/shell/browser/ui/message_box_win.cc @@ -304,7 +304,7 @@ void ShowMessageBox(const MessageBoxSettings& settings, dialog_thread::Run(base::BindOnce(&ShowTaskDialogUTF8, settings, parent_widget, base::Unretained(hwnd)), base::BindOnce( - [](MessageBoxCallback callback, absl::optional<int> id, + [](MessageBoxCallback callback, std::optional<int> id, DialogResult result) { if (id) GetDialogsMap().erase(*id); diff --git a/shell/browser/ui/tray_icon.h b/shell/browser/ui/tray_icon.h index 98ebe66480..03c1a637c8 100644 --- a/shell/browser/ui/tray_icon.h +++ b/shell/browser/ui/tray_icon.h @@ -18,7 +18,7 @@ namespace electron { class TrayIcon { public: - static TrayIcon* Create(absl::optional<UUID> guid); + static TrayIcon* Create(std::optional<UUID> guid); #if BUILDFLAG(IS_WIN) using ImageType = HICON; diff --git a/shell/browser/ui/tray_icon_cocoa.mm b/shell/browser/ui/tray_icon_cocoa.mm index 3e01df792d..16dc1b8e24 100644 --- a/shell/browser/ui/tray_icon_cocoa.mm +++ b/shell/browser/ui/tray_icon_cocoa.mm @@ -422,7 +422,7 @@ gfx::Rect TrayIconCocoa::GetBounds() { } // static -TrayIcon* TrayIcon::Create(absl::optional<UUID> guid) { +TrayIcon* TrayIcon::Create(std::optional<UUID> guid) { return new TrayIconCocoa; } diff --git a/shell/browser/ui/tray_icon_linux.cc b/shell/browser/ui/tray_icon_linux.cc index 3309984ef1..c21ecb8e4a 100644 --- a/shell/browser/ui/tray_icon_linux.cc +++ b/shell/browser/ui/tray_icon_linux.cc @@ -108,7 +108,7 @@ ui::StatusIconLinux* TrayIconLinux::GetStatusIcon() { } // static -TrayIcon* TrayIcon::Create(absl::optional<UUID> guid) { +TrayIcon* TrayIcon::Create(std::optional<UUID> guid) { return new TrayIconLinux; } diff --git a/shell/browser/ui/tray_icon_win.cc b/shell/browser/ui/tray_icon_win.cc index 0f4e0059f8..328e83a9d9 100644 --- a/shell/browser/ui/tray_icon_win.cc +++ b/shell/browser/ui/tray_icon_win.cc @@ -8,7 +8,7 @@ namespace electron { // static -TrayIcon* TrayIcon::Create(absl::optional<UUID> guid) { +TrayIcon* TrayIcon::Create(std::optional<UUID> guid) { static NotifyIconHost host; return host.CreateNotifyIcon(guid); } diff --git a/shell/browser/ui/views/autofill_popup_view.cc b/shell/browser/ui/views/autofill_popup_view.cc index 67cebf4f74..9919b1504c 100644 --- a/shell/browser/ui/views/autofill_popup_view.cc +++ b/shell/browser/ui/views/autofill_popup_view.cc @@ -147,8 +147,8 @@ bool AutofillPopupView::CanStartDragForView(views::View*, } void AutofillPopupView::OnSelectedRowChanged( - absl::optional<int> previous_row_selection, - absl::optional<int> current_row_selection) { + std::optional<int> previous_row_selection, + std::optional<int> current_row_selection) { SchedulePaint(); if (current_row_selection) { @@ -436,7 +436,7 @@ void AutofillPopupView::AcceptSelection(const gfx::Point& point) { AcceptSelectedLine(); } -void AutofillPopupView::SetSelectedLine(absl::optional<int> selected_line) { +void AutofillPopupView::SetSelectedLine(std::optional<int> selected_line) { if (!popup_) return; if (selected_line_ == selected_line) @@ -479,7 +479,7 @@ void AutofillPopupView::SelectPreviousLine() { } void AutofillPopupView::ClearSelection() { - SetSelectedLine(absl::nullopt); + SetSelectedLine(std::nullopt); } void AutofillPopupView::RemoveObserver() { diff --git a/shell/browser/ui/views/autofill_popup_view.h b/shell/browser/ui/views/autofill_popup_view.h index e8e45a42ed..88420bb4cd 100644 --- a/shell/browser/ui/views/autofill_popup_view.h +++ b/shell/browser/ui/views/autofill_popup_view.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_UI_VIEWS_AUTOFILL_POPUP_VIEW_H_ #include <memory> +#include <optional> #include "shell/browser/ui/autofill_popup.h" @@ -14,7 +15,6 @@ #include "content/public/common/input/native_web_keyboard_event.h" #include "electron/buildflags/buildflags.h" #include "shell/browser/osr/osr_view_proxy.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/accessibility/ax_node_data.h" #include "ui/base/metadata/metadata_header_macros.h" #include "ui/base/metadata/metadata_impl_macros.h" @@ -84,8 +84,8 @@ class AutofillPopupView : public views::WidgetDelegateView, private: friend class AutofillPopup; - void OnSelectedRowChanged(absl::optional<int> previous_row_selection, - absl::optional<int> current_row_selection); + void OnSelectedRowChanged(std::optional<int> previous_row_selection, + std::optional<int> current_row_selection); // Draw the given autofill entry in |entry_rect|. void DrawAutofillEntry(gfx::Canvas* canvas, @@ -122,7 +122,7 @@ class AutofillPopupView : public views::WidgetDelegateView, void AcceptSuggestion(int index); bool AcceptSelectedLine(); void AcceptSelection(const gfx::Point& point); - void SetSelectedLine(absl::optional<int> selected_line); + void SetSelectedLine(std::optional<int> selected_line); void SetSelection(const gfx::Point& point); void SelectNextLine(); void SelectPreviousLine(); @@ -141,7 +141,7 @@ class AutofillPopupView : public views::WidgetDelegateView, base::Time show_time_; // The index of the currently selected line - absl::optional<int> selected_line_; + std::optional<int> selected_line_; std::unique_ptr<OffscreenViewProxy> view_proxy_; diff --git a/shell/browser/ui/views/menu_delegate.cc b/shell/browser/ui/views/menu_delegate.cc index 589424c04f..895fc0e0c5 100644 --- a/shell/browser/ui/views/menu_delegate.cc +++ b/shell/browser/ui/views/menu_delegate.cc @@ -78,7 +78,7 @@ const gfx::FontList* MenuDelegate::GetLabelFontList(int id) const { return adapter_->GetLabelFontList(id); } -absl::optional<SkColor> MenuDelegate::GetLabelColor(int id) const { +std::optional<SkColor> MenuDelegate::GetLabelColor(int id) const { return adapter_->GetLabelColor(id); } diff --git a/shell/browser/ui/views/menu_delegate.h b/shell/browser/ui/views/menu_delegate.h index 8af32cbcb7..b7511688e8 100644 --- a/shell/browser/ui/views/menu_delegate.h +++ b/shell/browser/ui/views/menu_delegate.h @@ -53,7 +53,7 @@ class MenuDelegate : public views::MenuDelegate { bool GetAccelerator(int id, ui::Accelerator* accelerator) const override; std::u16string GetLabel(int id) const override; const gfx::FontList* GetLabelFontList(int id) const override; - absl::optional<SkColor> GetLabelColor(int id) const override; + std::optional<SkColor> GetLabelColor(int id) const override; bool IsCommandEnabled(int id) const override; bool IsCommandVisible(int id) const override; bool IsItemChecked(int id) const override; diff --git a/shell/browser/ui/webui/accessibility_ui.cc b/shell/browser/ui/webui/accessibility_ui.cc index 8006920f0c..058dd0d622 100644 --- a/shell/browser/ui/webui/accessibility_ui.cc +++ b/shell/browser/ui/webui/accessibility_ui.cc @@ -5,6 +5,7 @@ #include "shell/browser/ui/webui/accessibility_ui.h" #include <memory> +#include <optional> #include <string> #include <utility> #include <vector> @@ -42,7 +43,6 @@ #include "content/public/browser/web_ui_data_source.h" #include "shell/browser/native_window.h" #include "shell/browser/window_list.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/accessibility/platform/ax_platform_node.h" #include "ui/accessibility/platform/ax_platform_node_delegate.h" #include "ui/base/webui/web_ui_util.h" diff --git a/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc b/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc index e9dab479ab..9ec2588c70 100644 --- a/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc +++ b/shell/browser/ui/win/electron_desktop_window_tree_host_win.cc @@ -4,11 +4,12 @@ #include "shell/browser/ui/win/electron_desktop_window_tree_host_win.h" +#include <optional> + #include "base/win/windows_version.h" #include "electron/buildflags/buildflags.h" #include "shell/browser/ui/views/win_frame_view.h" #include "shell/browser/win/dark_mode.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/base/win/hwnd_metrics.h" #include "ui/base/win/shell.h" diff --git a/shell/browser/ui/win/electron_desktop_window_tree_host_win.h b/shell/browser/ui/win/electron_desktop_window_tree_host_win.h index 2c627ceeb0..66cf2ae123 100644 --- a/shell/browser/ui/win/electron_desktop_window_tree_host_win.h +++ b/shell/browser/ui/win/electron_desktop_window_tree_host_win.h @@ -7,8 +7,9 @@ #include <windows.h> +#include <optional> + #include "shell/browser/native_window_views.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" namespace electron { @@ -44,7 +45,7 @@ class ElectronDesktopWindowTreeHostWin : public views::DesktopWindowTreeHostWin, private: raw_ptr<NativeWindowViews> native_window_view_; // weak ref - absl::optional<bool> force_should_paint_as_active_; + std::optional<bool> force_should_paint_as_active_; }; } // namespace electron diff --git a/shell/browser/ui/win/notify_icon_host.cc b/shell/browser/ui/win/notify_icon_host.cc index 63d0df3d9e..285d6ab37a 100644 --- a/shell/browser/ui/win/notify_icon_host.cc +++ b/shell/browser/ui/win/notify_icon_host.cc @@ -191,7 +191,7 @@ NotifyIconHost::~NotifyIconHost() { delete ptr; } -NotifyIcon* NotifyIconHost::CreateNotifyIcon(absl::optional<UUID> guid) { +NotifyIcon* NotifyIconHost::CreateNotifyIcon(std::optional<UUID> guid) { if (guid.has_value()) { for (NotifyIcons::const_iterator i(notify_icons_.begin()); i != notify_icons_.end(); ++i) { diff --git a/shell/browser/ui/win/notify_icon_host.h b/shell/browser/ui/win/notify_icon_host.h index 3b5ce54626..b58da039e1 100644 --- a/shell/browser/ui/win/notify_icon_host.h +++ b/shell/browser/ui/win/notify_icon_host.h @@ -7,10 +7,10 @@ #include <windows.h> +#include <optional> #include <vector> #include "shell/common/gin_converters/guid_converter.h" -#include "third_party/abseil-cpp/absl/types/optional.h" const GUID GUID_DEFAULT = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}}; @@ -27,7 +27,7 @@ class NotifyIconHost { NotifyIconHost(const NotifyIconHost&) = delete; NotifyIconHost& operator=(const NotifyIconHost&) = delete; - NotifyIcon* CreateNotifyIcon(absl::optional<UUID> guid); + NotifyIcon* CreateNotifyIcon(std::optional<UUID> guid); void Remove(NotifyIcon* notify_icon); private: diff --git a/shell/browser/web_contents_preferences.cc b/shell/browser/web_contents_preferences.cc index 8c43cd3da1..4a7ab22770 100644 --- a/shell/browser/web_contents_preferences.cc +++ b/shell/browser/web_contents_preferences.cc @@ -119,7 +119,7 @@ void WebContentsPreferences::Clear() { node_integration_in_worker_ = false; disable_html_fullscreen_window_resize_ = false; webview_tag_ = false; - sandbox_ = absl::nullopt; + sandbox_ = std::nullopt; context_isolation_ = true; javascript_ = true; images_ = true; @@ -133,24 +133,24 @@ void WebContentsPreferences::Clear() { navigate_on_drag_drop_ = false; autoplay_policy_ = blink::mojom::AutoplayPolicy::kNoUserGestureRequired; default_font_family_.clear(); - default_font_size_ = absl::nullopt; - default_monospace_font_size_ = absl::nullopt; - minimum_font_size_ = absl::nullopt; - default_encoding_ = absl::nullopt; + default_font_size_ = std::nullopt; + default_monospace_font_size_ = std::nullopt; + minimum_font_size_ = std::nullopt; + default_encoding_ = std::nullopt; is_webview_ = false; custom_args_.clear(); custom_switches_.clear(); - enable_blink_features_ = absl::nullopt; - disable_blink_features_ = absl::nullopt; + enable_blink_features_ = std::nullopt; + disable_blink_features_ = std::nullopt; disable_popups_ = false; disable_dialogs_ = false; safe_dialogs_ = false; - safe_dialogs_message_ = absl::nullopt; + safe_dialogs_message_ = std::nullopt; ignore_menu_shortcuts_ = false; - background_color_ = absl::nullopt; + background_color_ = std::nullopt; image_animation_policy_ = blink::mojom::ImageAnimationPolicy::kImageAnimationPolicyAllowed; - preload_path_ = absl::nullopt; + preload_path_ = std::nullopt; v8_cache_options_ = blink::mojom::V8CacheOptions::kDefault; #if BUILDFLAG(IS_MAC) diff --git a/shell/browser/web_contents_preferences.h b/shell/browser/web_contents_preferences.h index e46ee17bbb..05e6665a00 100644 --- a/shell/browser/web_contents_preferences.h +++ b/shell/browser/web_contents_preferences.h @@ -55,10 +55,10 @@ class WebContentsPreferences base::Value* last_preference() { return &last_web_preferences_; } bool IsOffscreen() const { return offscreen_; } - absl::optional<SkColor> GetBackgroundColor() const { + std::optional<SkColor> GetBackgroundColor() const { return background_color_; } - void SetBackgroundColor(absl::optional<SkColor> color) { + void SetBackgroundColor(std::optional<SkColor> color) { background_color_ = color; } bool ShouldUsePreferredSizeMode() const { @@ -104,7 +104,7 @@ class WebContentsPreferences bool node_integration_in_worker_; bool disable_html_fullscreen_window_resize_; bool webview_tag_; - absl::optional<bool> sandbox_; + std::optional<bool> sandbox_; bool context_isolation_; bool javascript_; bool images_; @@ -118,23 +118,23 @@ class WebContentsPreferences bool navigate_on_drag_drop_; blink::mojom::AutoplayPolicy autoplay_policy_; std::map<std::string, std::u16string> default_font_family_; - absl::optional<int> default_font_size_; - absl::optional<int> default_monospace_font_size_; - absl::optional<int> minimum_font_size_; - absl::optional<std::string> default_encoding_; + std::optional<int> default_font_size_; + std::optional<int> default_monospace_font_size_; + std::optional<int> minimum_font_size_; + std::optional<std::string> default_encoding_; bool is_webview_; std::vector<std::string> custom_args_; std::vector<std::string> custom_switches_; - absl::optional<std::string> enable_blink_features_; - absl::optional<std::string> disable_blink_features_; + std::optional<std::string> enable_blink_features_; + std::optional<std::string> disable_blink_features_; bool disable_popups_; bool disable_dialogs_; bool safe_dialogs_; - absl::optional<std::string> safe_dialogs_message_; + std::optional<std::string> safe_dialogs_message_; bool ignore_menu_shortcuts_; - absl::optional<SkColor> background_color_; + std::optional<SkColor> background_color_; blink::mojom::ImageAnimationPolicy image_animation_policy_; - absl::optional<base::FilePath> preload_path_; + std::optional<base::FilePath> preload_path_; blink::mojom::V8CacheOptions v8_cache_options_; #if BUILDFLAG(IS_MAC) diff --git a/shell/browser/zoom_level_delegate.cc b/shell/browser/zoom_level_delegate.cc index 6e85a5cad4..c91afb6a81 100644 --- a/shell/browser/zoom_level_delegate.cc +++ b/shell/browser/zoom_level_delegate.cc @@ -100,7 +100,7 @@ void ZoomLevelDelegate::ExtractPerHostZoomLevels( std::vector<std::string> keys_to_remove; base::Value::Dict host_zoom_dictionary_copy = host_zoom_dictionary.Clone(); for (auto [host, value] : host_zoom_dictionary_copy) { - const absl::optional<double> zoom_level = value.GetIfDouble(); + const std::optional<double> zoom_level = value.GetIfDouble(); // Filter out A) the empty host, B) zoom levels equal to the default; and // remember them, so that we can later erase them from Prefs. diff --git a/shell/common/api/electron_api_clipboard.cc b/shell/common/api/electron_api_clipboard.cc index ea1c8d5f91..c29dc3ed3a 100644 --- a/shell/common/api/electron_api_clipboard.cc +++ b/shell/common/api/electron_api_clipboard.cc @@ -229,7 +229,7 @@ gfx::Image Clipboard::ReadImage(gin_helper::Arguments* args) { } ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); - absl::optional<gfx::Image> image; + std::optional<gfx::Image> image; base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed); base::RepeatingClosure callback = run_loop.QuitClosure(); @@ -237,7 +237,7 @@ gfx::Image Clipboard::ReadImage(gin_helper::Arguments* args) { GetClipboardBuffer(args), /* data_dst = */ nullptr, base::BindOnce( - [](absl::optional<gfx::Image>* image, base::RepeatingClosure cb, + [](std::optional<gfx::Image>* image, base::RepeatingClosure cb, const std::vector<uint8_t>& result) { SkBitmap bitmap; gfx::PNGCodec::Decode(result.data(), result.size(), &bitmap); diff --git a/shell/common/api/electron_api_native_image.cc b/shell/common/api/electron_api_native_image.cc index a2994e1e33..ef772bf72f 100644 --- a/shell/common/api/electron_api_native_image.cc +++ b/shell/common/api/electron_api_native_image.cc @@ -324,7 +324,7 @@ bool NativeImage::IsEmpty() { return image_.IsEmpty(); } -gfx::Size NativeImage::GetSize(const absl::optional<float> scale_factor) { +gfx::Size NativeImage::GetSize(const std::optional<float> scale_factor) { float sf = scale_factor.value_or(1.0f); gfx::ImageSkiaRep image_rep = image_.AsImageSkia().GetRepresentation(sf); @@ -340,7 +340,7 @@ std::vector<float> NativeImage::GetScaleFactors() { return scale_factors; } -float NativeImage::GetAspectRatio(const absl::optional<float> scale_factor) { +float NativeImage::GetAspectRatio(const std::optional<float> scale_factor) { float sf = scale_factor.value_or(1.0f); gfx::Size size = GetSize(sf); if (size.IsEmpty()) @@ -354,8 +354,8 @@ gin::Handle<NativeImage> NativeImage::Resize(gin::Arguments* args, float scale_factor = GetScaleFactorFromOptions(args); gfx::Size size = GetSize(scale_factor); - absl::optional<int> new_width = options.FindInt("width"); - absl::optional<int> new_height = options.FindInt("height"); + std::optional<int> new_width = options.FindInt("width"); + std::optional<int> new_height = options.FindInt("height"); int width = new_width.value_or(size.width()); int height = new_height.value_or(size.height()); size.SetSize(width, height); diff --git a/shell/common/api/electron_api_native_image.h b/shell/common/api/electron_api_native_image.h index 1a346444d1..6087eb2033 100644 --- a/shell/common/api/electron_api_native_image.h +++ b/shell/common/api/electron_api_native_image.h @@ -117,8 +117,8 @@ class NativeImage : public gin::Wrappable<NativeImage> { gin::Handle<NativeImage> Crop(v8::Isolate* isolate, const gfx::Rect& rect); std::string ToDataURL(gin::Arguments* args); bool IsEmpty(); - gfx::Size GetSize(const absl::optional<float> scale_factor); - float GetAspectRatio(const absl::optional<float> scale_factor); + gfx::Size GetSize(const std::optional<float> scale_factor); + float GetAspectRatio(const std::optional<float> scale_factor); void AddRepresentation(const gin_helper::Dictionary& options); void UpdateExternalAllocatedMemoryUsage(); diff --git a/shell/common/api/electron_api_net.cc b/shell/common/api/electron_api_net.cc index 8339dc68db..78a3b0a26c 100644 --- a/shell/common/api/electron_api_net.cc +++ b/shell/common/api/electron_api_net.cc @@ -46,7 +46,7 @@ base::FilePath FileURLToFilePath(v8::Isolate* isolate, const GURL& url) { v8::Local<v8::Promise> ResolveHost( v8::Isolate* isolate, std::string host, - absl::optional<network::mojom::ResolveHostParametersPtr> params) { + std::optional<network::mojom::ResolveHostParametersPtr> params) { gin_helper::Promise<gin_helper::Dictionary> promise(isolate); v8::Local<v8::Promise> handle = promise.GetHandle(); @@ -54,7 +54,7 @@ v8::Local<v8::Promise> ResolveHost( nullptr, std::move(host), params ? std::move(params.value()) : nullptr, base::BindOnce( [](gin_helper::Promise<gin_helper::Dictionary> promise, - int64_t net_error, const absl::optional<net::AddressList>& addrs) { + int64_t net_error, const std::optional<net::AddressList>& addrs) { if (net_error < 0) { promise.RejectWithErrorMessage(net::ErrorToString(net_error)); } else { diff --git a/shell/common/api/electron_api_url_loader.cc b/shell/common/api/electron_api_url_loader.cc index 9cb27af9b7..975c571cd3 100644 --- a/shell/common/api/electron_api_url_loader.cc +++ b/shell/common/api/electron_api_url_loader.cc @@ -392,7 +392,7 @@ void SimpleURLLoaderWrapper::PinBodyGetter(v8::Local<v8::Value> body_getter) { SimpleURLLoaderWrapper::~SimpleURLLoaderWrapper() = default; void SimpleURLLoaderWrapper::OnAuthRequired( - const absl::optional<base::UnguessableToken>& window_id, + const std::optional<base::UnguessableToken>& window_id, uint32_t request_id, const GURL& url, bool first_auth_attempt, @@ -413,7 +413,7 @@ void SimpleURLLoaderWrapper::OnAuthRequired( gin::Arguments* args) { std::u16string username_str, password_str; if (!args->GetNext(&username_str) || !args->GetNext(&password_str)) { - auth_responder->OnAuthCredentials(absl::nullopt); + auth_responder->OnAuthCredentials(std::nullopt); return; } auth_responder->OnAuthCredentials( @@ -436,7 +436,7 @@ void SimpleURLLoaderWrapper::OnClearSiteData( const GURL& url, const std::string& header_value, int32_t load_flags, - const absl::optional<net::CookiePartitionKey>& cookie_partition_key, + const std::optional<net::CookiePartitionKey>& cookie_partition_key, bool partitioned_state_allowed_only, OnClearSiteDataCallback callback) { std::move(callback).Run(); @@ -758,7 +758,7 @@ void SimpleURLLoaderWrapper::OnRedirect( bool should_clear_upload = false; net::RedirectUtil::UpdateHttpRequest( request_->url, request_->method, redirect_info, *removed_headers, - /* modified_headers = */ absl::nullopt, &request_->headers, + /* modified_headers = */ std::nullopt, &request_->headers, &should_clear_upload); if (should_clear_upload) { // The request body is no longer applicable. diff --git a/shell/common/api/electron_api_url_loader.h b/shell/common/api/electron_api_url_loader.h index ccabfb83bd..5729b1d8c9 100644 --- a/shell/common/api/electron_api_url_loader.h +++ b/shell/common/api/electron_api_url_loader.h @@ -73,7 +73,7 @@ class SimpleURLLoaderWrapper // network::mojom::URLLoaderNetworkServiceObserver: void OnAuthRequired( - const absl::optional<base::UnguessableToken>& window_id, + const std::optional<base::UnguessableToken>& window_id, uint32_t request_id, const GURL& url, bool first_auth_attempt, @@ -87,21 +87,21 @@ class SimpleURLLoaderWrapper bool fatal, OnSSLCertificateErrorCallback response) override; void OnCertificateRequested( - const absl::optional<base::UnguessableToken>& window_id, + const std::optional<base::UnguessableToken>& window_id, const scoped_refptr<net::SSLCertRequestInfo>& cert_info, mojo::PendingRemote<network::mojom::ClientCertificateResponder> client_cert_responder) override {} void OnPrivateNetworkAccessPermissionRequired( const GURL& url, const net::IPAddress& ip_address, - const absl::optional<std::string>& private_network_device_id, - const absl::optional<std::string>& private_network_device_name, + const std::optional<std::string>& private_network_device_id, + const std::optional<std::string>& private_network_device_name, OnPrivateNetworkAccessPermissionRequiredCallback callback) override {} void OnClearSiteData( const GURL& url, const std::string& header_value, int32_t load_flags, - const absl::optional<net::CookiePartitionKey>& cookie_partition_key, + const std::optional<net::CookiePartitionKey>& cookie_partition_key, bool partitioned_state_allowed_only, OnClearSiteDataCallback callback) override; void OnLoadingStateUpdate(network::mojom::LoadInfoPtr info, diff --git a/shell/common/asar/archive.cc b/shell/common/asar/archive.cc index 905fafe74e..578dd3b6a1 100644 --- a/shell/common/asar/archive.cc +++ b/shell/common/asar/archive.cc @@ -90,13 +90,13 @@ bool FillFileInfoWithNode(Archive::FileInfo* info, uint32_t header_size, bool load_integrity, const base::Value::Dict* node) { - if (absl::optional<int> size = node->FindInt("size")) { + if (std::optional<int> size = node->FindInt("size")) { info->size = static_cast<uint32_t>(*size); } else { return false; } - if (absl::optional<bool> unpacked = node->FindBool("unpacked")) { + if (std::optional<bool> unpacked = node->FindBool("unpacked")) { info->unpacked = *unpacked; if (info->unpacked) { return true; @@ -111,7 +111,7 @@ bool FillFileInfoWithNode(Archive::FileInfo* info, return false; } - if (absl::optional<bool> executable = node->FindBool("executable")) { + if (std::optional<bool> executable = node->FindBool("executable")) { info->executable = *executable; } @@ -121,7 +121,7 @@ bool FillFileInfoWithNode(Archive::FileInfo* info, if (const base::Value::Dict* integrity = node->FindDict("integrity")) { const std::string* algorithm = integrity->FindString("algorithm"); const std::string* hash = integrity->FindString("hash"); - absl::optional<int> block_size = integrity->FindInt("blockSize"); + std::optional<int> block_size = integrity->FindInt("blockSize"); const base::Value::List* blocks = integrity->FindList("blocks"); if (algorithm && hash && block_size && block_size > 0 && blocks) { @@ -242,7 +242,7 @@ bool Archive::Init() { // Validate header signature if required and possible if (electron::fuses::IsEmbeddedAsarIntegrityValidationEnabled() && RelativePath().has_value()) { - absl::optional<IntegrityPayload> integrity = HeaderIntegrity(); + std::optional<IntegrityPayload> integrity = HeaderIntegrity(); if (!integrity.has_value()) { LOG(FATAL) << "Failed to get integrity for validatable asar archive: " << RelativePath().value(); @@ -264,7 +264,7 @@ bool Archive::Init() { } #endif - absl::optional<base::Value> value = base::JSONReader::Read(header); + std::optional<base::Value> value = base::JSONReader::Read(header); if (!value || !value->is_dict()) { LOG(ERROR) << "Failed to parse header"; return false; @@ -276,12 +276,12 @@ bool Archive::Init() { } #if !BUILDFLAG(IS_MAC) -absl::optional<IntegrityPayload> Archive::HeaderIntegrity() const { - return absl::nullopt; +std::optional<IntegrityPayload> Archive::HeaderIntegrity() const { + return std::nullopt; } -absl::optional<base::FilePath> Archive::RelativePath() const { - return absl::nullopt; +std::optional<base::FilePath> Archive::RelativePath() const { + return std::nullopt; } #endif diff --git a/shell/common/asar/archive.h b/shell/common/asar/archive.h index b11f2ac212..ed9b18d74c 100644 --- a/shell/common/asar/archive.h +++ b/shell/common/asar/archive.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_COMMON_ASAR_ARCHIVE_H_ #include <memory> +#include <optional> #include <string> #include <unordered_map> #include <vector> @@ -16,7 +17,6 @@ #include "base/files/file_path.h" #include "base/synchronization/lock.h" #include "base/values.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace asar { @@ -48,7 +48,7 @@ class Archive { bool executable; uint32_t size; uint64_t offset; - absl::optional<IntegrityPayload> integrity; + std::optional<IntegrityPayload> integrity; }; enum class FileType { @@ -71,8 +71,8 @@ class Archive { // Read and parse the header. bool Init(); - absl::optional<IntegrityPayload> HeaderIntegrity() const; - absl::optional<base::FilePath> RelativePath() const; + std::optional<IntegrityPayload> HeaderIntegrity() const; + std::optional<base::FilePath> RelativePath() const; // Get the info of a file. bool GetFileInfo(const base::FilePath& path, FileInfo* info) const; @@ -106,7 +106,7 @@ class Archive { base::File file_; int fd_ = -1; uint32_t header_size_ = 0; - absl::optional<base::Value::Dict> header_; + std::optional<base::Value::Dict> header_; // Cached external temporary files. base::Lock external_files_lock_; diff --git a/shell/common/asar/archive_mac.mm b/shell/common/asar/archive_mac.mm index 4501bab716..ac4b485991 100644 --- a/shell/common/asar/archive_mac.mm +++ b/shell/common/asar/archive_mac.mm @@ -21,19 +21,19 @@ namespace asar { -absl::optional<base::FilePath> Archive::RelativePath() const { +std::optional<base::FilePath> Archive::RelativePath() const { base::FilePath bundle_path = base::MakeAbsoluteFilePath( base::apple::MainBundlePath().Append("Contents")); base::FilePath relative_path; if (!bundle_path.AppendRelativePath(path_, &relative_path)) - return absl::nullopt; + return std::nullopt; return relative_path; } -absl::optional<IntegrityPayload> Archive::HeaderIntegrity() const { - absl::optional<base::FilePath> relative_path = RelativePath(); +std::optional<IntegrityPayload> Archive::HeaderIntegrity() const { + std::optional<base::FilePath> relative_path = RelativePath(); // Callers should have already asserted this CHECK(relative_path.has_value()); @@ -42,7 +42,7 @@ absl::optional<IntegrityPayload> Archive::HeaderIntegrity() const { // Integrity not provided if (!integrity) - return absl::nullopt; + return std::nullopt; NSString* ns_relative_path = base::apple::FilePathToNSString(relative_path.value()); @@ -50,7 +50,7 @@ absl::optional<IntegrityPayload> Archive::HeaderIntegrity() const { NSDictionary* integrity_payload = [integrity objectForKey:ns_relative_path]; if (!integrity_payload) - return absl::nullopt; + return std::nullopt; NSString* algorithm = [integrity_payload objectForKey:@"algorithm"]; NSString* hash = [integrity_payload objectForKey:@"hash"]; @@ -61,7 +61,7 @@ absl::optional<IntegrityPayload> Archive::HeaderIntegrity() const { return header_integrity; } - return absl::nullopt; + return std::nullopt; } } // namespace asar diff --git a/shell/common/asar/scoped_temporary_file.cc b/shell/common/asar/scoped_temporary_file.cc index f2982c9d37..d0f00034db 100644 --- a/shell/common/asar/scoped_temporary_file.cc +++ b/shell/common/asar/scoped_temporary_file.cc @@ -55,7 +55,7 @@ bool ScopedTemporaryFile::InitFromFile( const base::FilePath::StringType& ext, uint64_t offset, uint64_t size, - const absl::optional<IntegrityPayload>& integrity) { + const std::optional<IntegrityPayload>& integrity) { if (!src->IsValid()) return false; diff --git a/shell/common/asar/scoped_temporary_file.h b/shell/common/asar/scoped_temporary_file.h index 5fd31a848b..0cf4f00955 100644 --- a/shell/common/asar/scoped_temporary_file.h +++ b/shell/common/asar/scoped_temporary_file.h @@ -5,9 +5,10 @@ #ifndef ELECTRON_SHELL_COMMON_ASAR_SCOPED_TEMPORARY_FILE_H_ #define ELECTRON_SHELL_COMMON_ASAR_SCOPED_TEMPORARY_FILE_H_ +#include <optional> + #include "base/files/file_path.h" #include "shell/common/asar/archive.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace base { class File; @@ -34,7 +35,7 @@ class ScopedTemporaryFile { const base::FilePath::StringType& ext, uint64_t offset, uint64_t size, - const absl::optional<IntegrityPayload>& integrity); + const std::optional<IntegrityPayload>& integrity); base::FilePath path() const { return path_; } diff --git a/shell/common/gin_converters/blink_converter.cc b/shell/common/gin_converters/blink_converter.cc index 8a85c34a6e..ae886e7d0a 100644 --- a/shell/common/gin_converters/blink_converter.cc +++ b/shell/common/gin_converters/blink_converter.cc @@ -258,7 +258,7 @@ bool Converter<blink::WebKeyboardEvent>::FromV8(v8::Isolate* isolate, if (!dict.Get("keyCode", &str)) return false; - absl::optional<char16_t> shifted_char; + std::optional<char16_t> shifted_char; ui::KeyboardCode keyCode = electron::KeyboardCodeFromStr(str, &shifted_char); out->windows_key_code = keyCode; if (shifted_char) @@ -460,9 +460,9 @@ v8::Local<v8::Value> Converter<blink::mojom::ContextMenuDataMediaType>::ToV8( // static v8::Local<v8::Value> -Converter<absl::optional<blink::mojom::FormControlType>>::ToV8( +Converter<std::optional<blink::mojom::FormControlType>>::ToV8( v8::Isolate* isolate, - const absl::optional<blink::mojom::FormControlType>& in) { + const std::optional<blink::mojom::FormControlType>& in) { base::StringPiece str{"none"}; if (in.has_value()) { switch (*in) { diff --git a/shell/common/gin_converters/blink_converter.h b/shell/common/gin_converters/blink_converter.h index 506758ce89..1dd38e9de4 100644 --- a/shell/common/gin_converters/blink_converter.h +++ b/shell/common/gin_converters/blink_converter.h @@ -80,10 +80,10 @@ struct Converter<blink::mojom::ContextMenuDataMediaType> { }; template <> -struct Converter<absl::optional<blink::mojom::FormControlType>> { +struct Converter<std::optional<blink::mojom::FormControlType>> { static v8::Local<v8::Value> ToV8( v8::Isolate* isolate, - const absl::optional<blink::mojom::FormControlType>& in); + const std::optional<blink::mojom::FormControlType>& in); }; template <> diff --git a/shell/common/gin_converters/content_converter.cc b/shell/common/gin_converters/content_converter.cc index 4f1bb7c77d..8b016584e5 100644 --- a/shell/common/gin_converters/content_converter.cc +++ b/shell/common/gin_converters/content_converter.cc @@ -25,7 +25,7 @@ namespace { [[nodiscard]] constexpr base::StringPiece FormControlToInputFieldTypeString( - const absl::optional<blink::mojom::FormControlType> form_control_type) { + const std::optional<blink::mojom::FormControlType> form_control_type) { if (!form_control_type) return "none"; diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc index d23c4a21af..888bc8ba0a 100644 --- a/shell/common/gin_converters/net_converter.cc +++ b/shell/common/gin_converters/net_converter.cc @@ -482,7 +482,7 @@ class ChunkedDataPipeReadableStream mojo::Remote<network::mojom::ChunkedDataPipeGetter> chunked_data_pipe_getter_; mojo::ScopedDataPipeConsumerHandle data_pipe_; mojo::SimpleWatcher handle_watcher_; - absl::optional<uint64_t> size_; + std::optional<uint64_t> size_; uint64_t bytes_read_ = 0; bool is_eof_ = false; v8::Global<v8::ArrayBufferView> buf_; diff --git a/shell/common/gin_converters/optional_converter.h b/shell/common/gin_converters/optional_converter.h index e40a463c76..16feb18dfd 100644 --- a/shell/common/gin_converters/optional_converter.h +++ b/shell/common/gin_converters/optional_converter.h @@ -5,17 +5,17 @@ #ifndef ELECTRON_SHELL_COMMON_GIN_CONVERTERS_OPTIONAL_CONVERTER_H_ #define ELECTRON_SHELL_COMMON_GIN_CONVERTERS_OPTIONAL_CONVERTER_H_ +#include <optional> #include <utility> #include "gin/converter.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace gin { template <typename T> -struct Converter<absl::optional<T>> { +struct Converter<std::optional<T>> { static v8::Local<v8::Value> ToV8(v8::Isolate* isolate, - const absl::optional<T>& val) { + const std::optional<T>& val) { if (val) return Converter<T>::ToV8(isolate, val.value()); else @@ -23,7 +23,7 @@ struct Converter<absl::optional<T>> { } static bool FromV8(v8::Isolate* isolate, v8::Local<v8::Value> val, - absl::optional<T>* out) { + std::optional<T>* out) { T converted; if (Converter<T>::FromV8(isolate, val, &converted)) out->emplace(std::move(converted)); diff --git a/shell/common/gin_helper/dictionary.h b/shell/common/gin_helper/dictionary.h index dbf7a9c33e..b490e5d6d0 100644 --- a/shell/common/gin_helper/dictionary.h +++ b/shell/common/gin_helper/dictionary.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_DICTIONARY_H_ #define ELECTRON_SHELL_COMMON_GIN_HELPER_DICTIONARY_H_ +#include <optional> #include <type_traits> #include <utility> @@ -12,7 +13,6 @@ #include "shell/common/gin_converters/std_converter.h" #include "shell/common/gin_helper/accessor.h" #include "shell/common/gin_helper/function_template.h" -#include "third_party/abseil-cpp/absl/types/optional.h" namespace gin_helper { @@ -66,9 +66,9 @@ class Dictionary : public gin::Dictionary { return !result.IsNothing() && result.FromJust(); } - // Like normal Get but put result in an absl::optional. + // Like normal Get but put result in an std::optional. template <typename T> - bool GetOptional(base::StringPiece key, absl::optional<T>* out) const { + bool GetOptional(base::StringPiece key, std::optional<T>* out) const { T ret; if (Get(key, &ret)) { out->emplace(std::move(ret)); diff --git a/shell/common/gin_helper/function_template.h b/shell/common/gin_helper/function_template.h index 11b38f8fac..0a0922b3be 100644 --- a/shell/common/gin_helper/function_template.h +++ b/shell/common/gin_helper/function_template.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_FUNCTION_TEMPLATE_H_ #define ELECTRON_SHELL_COMMON_GIN_HELPER_FUNCTION_TEMPLATE_H_ +#include <optional> #include <utility> #include "base/functional/bind.h" @@ -15,7 +16,6 @@ #include "shell/common/gin_helper/destroyable.h" #include "shell/common/gin_helper/error_thrower.h" #include "shell/common/gin_helper/microtasks_scope.h" -#include "third_party/abseil-cpp/absl/types/optional.h" // This file is forked from gin/function_template.h with 2 differences: // 1. Support for additional types of arguments. @@ -96,13 +96,13 @@ bool GetNextArgument(gin::Arguments* args, } } -// Support absl::optional as output, which would be empty and do not throw error +// Support std::optional as output, which would be empty and do not throw error // when conversion to T fails. template <typename T> bool GetNextArgument(gin::Arguments* args, int create_flags, bool is_first, - absl::optional<T>* result) { + std::optional<T>* result) { T converted; // Use gin::Arguments::GetNext which always advances |next| counter. if (args->GetNext(&converted)) diff --git a/shell/common/gin_helper/function_template_extensions.h b/shell/common/gin_helper/function_template_extensions.h index 7420ffde72..ace47fdb75 100644 --- a/shell/common/gin_helper/function_template_extensions.h +++ b/shell/common/gin_helper/function_template_extensions.h @@ -16,12 +16,12 @@ // in the gin_helper namespace. namespace gin { -// Support absl::optional as an argument. +// Support std::optional as an argument. template <typename T> bool GetNextArgument(Arguments* args, const InvokerOptions& invoker_options, bool is_first, - absl::optional<T>* result) { + std::optional<T>* result) { T converted; // Use gin::Arguments::GetNext which always advances |next| counter. if (args->GetNext(&converted)) diff --git a/shell/common/keyboard_util.cc b/shell/common/keyboard_util.cc index 84e4ea7a28..d8d8d553d8 100644 --- a/shell/common/keyboard_util.cc +++ b/shell/common/keyboard_util.cc @@ -15,8 +15,7 @@ namespace electron { namespace { -using CodeAndShiftedChar = - std::pair<ui::KeyboardCode, absl::optional<char16_t>>; +using CodeAndShiftedChar = std::pair<ui::KeyboardCode, std::optional<char16_t>>; constexpr CodeAndShiftedChar KeyboardCodeFromKeyIdentifier( base::StringPiece str) { @@ -274,7 +273,7 @@ constexpr CodeAndShiftedChar KeyboardCodeFromCharCode(char16_t c) { } // namespace ui::KeyboardCode KeyboardCodeFromStr(base::StringPiece str, - absl::optional<char16_t>* shifted_char) { + std::optional<char16_t>* shifted_char) { auto const [code, shifted] = str.size() == 1 ? KeyboardCodeFromCharCode(base::ToLowerASCII(str[0])) : KeyboardCodeFromKeyIdentifier(base::ToLowerASCII(str)); diff --git a/shell/common/keyboard_util.h b/shell/common/keyboard_util.h index 95ebda6c44..45cc80f264 100644 --- a/shell/common/keyboard_util.h +++ b/shell/common/keyboard_util.h @@ -5,8 +5,9 @@ #ifndef ELECTRON_SHELL_COMMON_KEYBOARD_UTIL_H_ #define ELECTRON_SHELL_COMMON_KEYBOARD_UTIL_H_ +#include <optional> + #include "base/strings/string_piece.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/events/keycodes/keyboard_codes.h" namespace electron { @@ -15,7 +16,7 @@ namespace electron { // for example + and /, set it in |shifted_char|. // pressed. ui::KeyboardCode KeyboardCodeFromStr(base::StringPiece str, - absl::optional<char16_t>* shifted_char); + std::optional<char16_t>* shifted_char); } // namespace electron diff --git a/shell/common/mac/codesign_util.cc b/shell/common/mac/codesign_util.cc index 2abfb2eb32..455bfa5d02 100644 --- a/shell/common/mac/codesign_util.cc +++ b/shell/common/mac/codesign_util.cc @@ -5,17 +5,18 @@ #include "shell/common/mac/codesign_util.h" +#include <optional> + #include "base/apple/foundation_util.h" #include "base/apple/osstatus_logging.h" #include "base/apple/scoped_cftyperef.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include <CoreFoundation/CoreFoundation.h> #include <Security/Security.h> namespace electron { -absl::optional<bool> IsUnsignedOrAdHocSigned(SecCodeRef code) { +std::optional<bool> IsUnsignedOrAdHocSigned(SecCodeRef code) { base::apple::ScopedCFTypeRef<SecStaticCodeRef> static_code; OSStatus status = SecCodeCopyStaticCode(code, kSecCSDefaultFlags, static_code.InitializeInto()); @@ -24,7 +25,7 @@ absl::optional<bool> IsUnsignedOrAdHocSigned(SecCodeRef code) { } if (status != errSecSuccess) { OSSTATUS_LOG(ERROR, status) << "SecCodeCopyStaticCode"; - return absl::optional<bool>(); + return std::optional<bool>(); } // Copy the signing info from the SecStaticCodeRef. base::apple::ScopedCFTypeRef<CFDictionaryRef> signing_info; @@ -33,7 +34,7 @@ absl::optional<bool> IsUnsignedOrAdHocSigned(SecCodeRef code) { signing_info.InitializeInto()); if (status != errSecSuccess) { OSSTATUS_LOG(ERROR, status) << "SecCodeCopySigningInformation"; - return absl::optional<bool>(); + return std::optional<bool>(); } // Look up the code signing flags. If the flags are absent treat this as // unsigned. This decision is consistent with the StaticCode source: @@ -50,7 +51,7 @@ absl::optional<bool> IsUnsignedOrAdHocSigned(SecCodeRef code) { long long flags; if (!CFNumberGetValue(signing_info_flags, kCFNumberLongLongType, &flags)) { LOG(ERROR) << "CFNumberGetValue"; - return absl::optional<bool>(); + return std::optional<bool>(); } if (static_cast<uint32_t>(flags) & kSecCodeSignatureAdhoc) { return true; @@ -67,7 +68,7 @@ bool ProcessSignatureIsSameWithCurrentApp(pid_t pid) { OSSTATUS_LOG(ERROR, status) << "SecCodeCopyGuestWithAttributes"; return false; } - absl::optional<bool> not_signed = IsUnsignedOrAdHocSigned(self_code.get()); + std::optional<bool> not_signed = IsUnsignedOrAdHocSigned(self_code.get()); if (!not_signed.has_value()) { // Error happened. return false; diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 704f71e8b9..676c712371 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -556,7 +556,7 @@ std::shared_ptr<node::Environment> NodeBindings::CreateEnvironment( node::MultiIsolatePlatform* platform, std::vector<std::string> args, std::vector<std::string> exec_args, - absl::optional<base::RepeatingCallback<void()>> on_app_code_ready) { + std::optional<base::RepeatingCallback<void()>> on_app_code_ready) { // Feed node the path to initialization script. std::string process_type; switch (browser_env_) { @@ -762,7 +762,7 @@ std::shared_ptr<node::Environment> NodeBindings::CreateEnvironment( std::shared_ptr<node::Environment> NodeBindings::CreateEnvironment( v8::Handle<v8::Context> context, node::MultiIsolatePlatform* platform, - absl::optional<base::RepeatingCallback<void()>> on_app_code_ready) { + std::optional<base::RepeatingCallback<void()>> on_app_code_ready) { #if BUILDFLAG(IS_WIN) auto& electron_args = ElectronCommandLine::argv(); std::vector<std::string> args(electron_args.size()); diff --git a/shell/common/node_bindings.h b/shell/common/node_bindings.h index cd476c4dbb..596eee17d3 100644 --- a/shell/common/node_bindings.h +++ b/shell/common/node_bindings.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_COMMON_NODE_BINDINGS_H_ #include <memory> +#include <optional> #include <string> #include <type_traits> #include <vector> @@ -18,7 +19,6 @@ #include "gin/public/context_holder.h" #include "gin/public/gin_embedders.h" #include "shell/common/node_includes.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "uv.h" // NOLINT(build/include_directory) #include "v8/include/v8.h" @@ -97,14 +97,14 @@ class NodeBindings { node::MultiIsolatePlatform* platform, std::vector<std::string> args, std::vector<std::string> exec_args, - absl::optional<base::RepeatingCallback<void()>> on_app_code_ready = - absl::nullopt); + std::optional<base::RepeatingCallback<void()>> on_app_code_ready = + std::nullopt); std::shared_ptr<node::Environment> CreateEnvironment( v8::Handle<v8::Context> context, node::MultiIsolatePlatform* platform, - absl::optional<base::RepeatingCallback<void()>> on_app_code_ready = - absl::nullopt); + std::optional<base::RepeatingCallback<void()>> on_app_code_ready = + std::nullopt); // Load node.js in the environment. void LoadEnvironment(node::Environment* env); diff --git a/shell/common/platform_util_linux.cc b/shell/common/platform_util_linux.cc index e29ace1c64..27245423db 100644 --- a/shell/common/platform_util_linux.cc +++ b/shell/common/platform_util_linux.cc @@ -7,6 +7,7 @@ #include <fcntl.h> #include <stdio.h> +#include <optional> #include <string> #include <vector> @@ -30,7 +31,6 @@ #include "dbus/message.h" #include "dbus/object_proxy.h" #include "shell/common/platform_util_internal.h" -#include "third_party/abseil-cpp/absl/types/optional.h" #include "ui/gtk/gtk_util.h" // nogncheck #include "url/gurl.h" @@ -247,7 +247,7 @@ class ShowItemHelper { raw_ptr<dbus::ObjectProxy> dbus_proxy_ = nullptr; raw_ptr<dbus::ObjectProxy> object_proxy_ = nullptr; - absl::optional<bool> prefer_filemanager_interface_; + std::optional<bool> prefer_filemanager_interface_; }; // Descriptions pulled from https://linux.die.net/man/1/xdg-open diff --git a/shell/renderer/api/electron_api_ipc_renderer.cc b/shell/renderer/api/electron_api_ipc_renderer.cc index 58feca6ad4..317b933687 100644 --- a/shell/renderer/api/electron_api_ipc_renderer.cc +++ b/shell/renderer/api/electron_api_ipc_renderer.cc @@ -131,7 +131,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>, gin_helper::ErrorThrower thrower, const std::string& channel, v8::Local<v8::Value> message_value, - absl::optional<v8::Local<v8::Value>> transfer) { + std::optional<v8::Local<v8::Value>> transfer) { if (!electron_ipc_remote_) { thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError); return; @@ -153,7 +153,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>, std::vector<blink::MessagePortChannel> ports; for (auto& transferable : transferables) { - absl::optional<blink::MessagePortChannel> port = + std::optional<blink::MessagePortChannel> port = blink::WebMessagePortConverter:: DisentangleAndExtractMessagePortChannel(isolate, transferable); if (!port.has_value()) {
chore
294f196907a92b26350d9bfc5f05abd855f2d344
David Sanders
2023-05-25 00:54:09
build: upgrade @electron/github-app-auth to 2.0.0 (#38435)
diff --git a/package.json b/package.json index 9e2fe89ba4..c70145e2cf 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "@electron/asar": "^3.2.1", "@electron/docs-parser": "^1.1.0", "@electron/fiddle-core": "^1.0.4", - "@electron/github-app-auth": "^1.5.0", + "@electron/github-app-auth": "^2.0.0", "@electron/lint-roller": "^1.2.1", "@electron/typescript-definitions": "^8.14.0", "@octokit/rest": "^19.0.7", @@ -150,7 +150,6 @@ ] }, "resolutions": { - "nan": "nodejs/nan#16fa32231e2ccd89d2804b3f765319128b20c4ac", - "@octokit/request": "6.2.4" + "nan": "nodejs/nan#16fa32231e2ccd89d2804b3f765319128b20c4ac" } } diff --git a/yarn.lock b/yarn.lock index 3703a66584..b386dfb94d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -186,13 +186,13 @@ optionalDependencies: global-agent "^3.0.0" -"@electron/github-app-auth@^1.5.0": - version "1.5.0" - resolved "https://registry.yarnpkg.com/@electron/github-app-auth/-/github-app-auth-1.5.0.tgz#426e64ba50143417d9b68f2795a1b119cb62108b" - integrity sha512-t6Za+3E7jdIf1CX06nNV/avZhqSXNEkCLJ1xeAt5FKU9HdGbjzwSfirM+UlHO7lMGyuf13BGCZOCB1kODhDLWQ== +"@electron/github-app-auth@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@electron/github-app-auth/-/github-app-auth-2.0.0.tgz#346d194b1327589cef3478ba321d092975093af8" + integrity sha512-NsJrDjyAEZbuKAkSCkDaz3+Tpn6Sr0li9iC37SLF/E1gg6qI28jtsix7DTzgOY20LstQuzIfh+tZosrgk96AUg== dependencies: - "@octokit/auth-app" "^3.6.1" - "@octokit/rest" "^18.12.0" + "@octokit/auth-app" "^4.0.13" + "@octokit/rest" "^19.0.11" "@electron/lint-roller@^1.2.1": version "1.2.1" @@ -373,45 +373,34 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@octokit/auth-app@^3.6.1": - version "3.6.1" - resolved "https://registry.yarnpkg.com/@octokit/auth-app/-/auth-app-3.6.1.tgz#aa5b02cc211175cbc28ce6c03c73373c1206d632" - integrity sha512-6oa6CFphIYI7NxxHrdVOzhG7hkcKyGyYocg7lNDSJVauVOLtylg8hNJzoUyPAYKKK0yUeoZamE/lMs2tG+S+JA== - dependencies: - "@octokit/auth-oauth-app" "^4.3.0" - "@octokit/auth-oauth-user" "^1.2.3" - "@octokit/request" "^5.6.0" - "@octokit/request-error" "^2.1.0" - "@octokit/types" "^6.0.3" - "@types/lru-cache" "^5.1.0" +"@octokit/auth-app@^4.0.13": + version "4.0.13" + resolved "https://registry.yarnpkg.com/@octokit/auth-app/-/auth-app-4.0.13.tgz#53323bee6bfefbb73ea544dd8e6a0144550e13e3" + integrity sha512-NBQkmR/Zsc+8fWcVIFrwDgNXS7f4XDrkd9LHdi9DPQw1NdGHLviLzRO2ZBwTtepnwHXW5VTrVU9eFGijMUqllg== + dependencies: + "@octokit/auth-oauth-app" "^5.0.0" + "@octokit/auth-oauth-user" "^2.0.0" + "@octokit/request" "^6.0.0" + "@octokit/request-error" "^3.0.0" + "@octokit/types" "^9.0.0" deprecation "^2.3.1" - lru-cache "^6.0.0" - universal-github-app-jwt "^1.0.1" + lru-cache "^9.0.0" + universal-github-app-jwt "^1.1.1" universal-user-agent "^6.0.0" -"@octokit/auth-oauth-app@^4.3.0": - version "4.3.4" - resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-app/-/auth-oauth-app-4.3.4.tgz#7030955b1a59d4d977904775c606477d95fcfe8e" - integrity sha512-OYOTSSINeUAiLMk1uelaGB/dEkReBqHHr8+hBejzMG4z1vA4c7QSvDAS0RVZSr4oD4PEUPYFzEl34K7uNrXcWA== +"@octokit/auth-oauth-app@^5.0.0": + version "5.0.5" + resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-app/-/auth-oauth-app-5.0.5.tgz#be2a93d72835133b4866ac4721aa628849475525" + integrity sha512-UPX1su6XpseaeLVCi78s9droxpGtBWIgz9XhXAx9VXabksoF0MyI5vaa1zo1njyYt6VaAjFisC2A2Wchcu2WmQ== dependencies: - "@octokit/auth-oauth-device" "^3.1.1" + "@octokit/auth-oauth-device" "^4.0.0" "@octokit/auth-oauth-user" "^2.0.0" - "@octokit/request" "^5.6.3" - "@octokit/types" "^6.0.3" + "@octokit/request" "^6.0.0" + "@octokit/types" "^9.0.0" "@types/btoa-lite" "^1.0.0" btoa-lite "^1.0.0" universal-user-agent "^6.0.0" -"@octokit/auth-oauth-device@^3.1.1": - version "3.1.4" - resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-device/-/auth-oauth-device-3.1.4.tgz#703c42f27a1e2eb23498a7001ad8e9ecf4a2f477" - integrity sha512-6sHE/++r+aEFZ/BKXOGPJcH/nbgbBjS1A4CHfq/PbPEwb0kZEt43ykW98GBO/rYBPAYaNpCPvXfGwzgR9yMCXg== - dependencies: - "@octokit/oauth-methods" "^2.0.0" - "@octokit/request" "^6.0.0" - "@octokit/types" "^6.10.0" - universal-user-agent "^6.0.0" - "@octokit/auth-oauth-device@^4.0.0": version "4.0.3" resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-device/-/auth-oauth-device-4.0.3.tgz#00ce77233517e0d7d39e42a02652f64337d9df81" @@ -422,18 +411,6 @@ "@octokit/types" "^8.0.0" universal-user-agent "^6.0.0" -"@octokit/auth-oauth-user@^1.2.3": - version "1.3.0" - resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-user/-/auth-oauth-user-1.3.0.tgz#da4e4529145181a6aa717ae858afb76ebd6e3360" - integrity sha512-3QC/TAdk7onnxfyZ24BnJRfZv8TRzQK7SEFUS9vLng4Vv6Hv6I64ujdk/CUkREec8lhrwU764SZ/d+yrjjqhaQ== - dependencies: - "@octokit/auth-oauth-device" "^3.1.1" - "@octokit/oauth-methods" "^1.1.0" - "@octokit/request" "^5.4.14" - "@octokit/types" "^6.12.2" - btoa-lite "^1.0.0" - universal-user-agent "^6.0.0" - "@octokit/auth-oauth-user@^2.0.0": version "2.0.4" resolved "https://registry.yarnpkg.com/@octokit/auth-oauth-user/-/auth-oauth-user-2.0.4.tgz#88f060ec678d7d493695af8d827e115dd064e212" @@ -446,13 +423,6 @@ btoa-lite "^1.0.0" universal-user-agent "^6.0.0" -"@octokit/auth-token@^2.4.4": - version "2.5.0" - resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-2.5.0.tgz#27c37ea26c205f28443402477ffd261311f21e36" - integrity sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g== - dependencies: - "@octokit/types" "^6.0.3" - "@octokit/auth-token@^3.0.0": version "3.0.3" resolved "https://registry.yarnpkg.com/@octokit/auth-token/-/auth-token-3.0.3.tgz#ce7e48a3166731f26068d7a7a7996b5da58cbe0c" @@ -460,19 +430,6 @@ dependencies: "@octokit/types" "^9.0.0" -"@octokit/core@^3.5.1": - version "3.6.0" - resolved "https://registry.yarnpkg.com/@octokit/core/-/core-3.6.0.tgz#3376cb9f3008d9b3d110370d90e0a1fcd5fe6085" - integrity sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q== - dependencies: - "@octokit/auth-token" "^2.4.4" - "@octokit/graphql" "^4.5.8" - "@octokit/request" "^5.6.3" - "@octokit/request-error" "^2.0.5" - "@octokit/types" "^6.0.3" - before-after-hook "^2.2.0" - universal-user-agent "^6.0.0" - "@octokit/core@^4.1.0": version "4.2.0" resolved "https://registry.yarnpkg.com/@octokit/core/-/core-4.2.0.tgz#8c253ba9605aca605bc46187c34fcccae6a96648" @@ -486,6 +443,19 @@ before-after-hook "^2.2.0" universal-user-agent "^6.0.0" +"@octokit/core@^4.2.1": + version "4.2.1" + resolved "https://registry.yarnpkg.com/@octokit/core/-/core-4.2.1.tgz#fee6341ad0ce60c29cc455e056cd5b500410a588" + integrity sha512-tEDxFx8E38zF3gT7sSMDrT1tGumDgsw5yPG6BBh/X+5ClIQfMH/Yqocxz1PnHx6CHyF6pxmovUTOfZAUvQ0Lvw== + dependencies: + "@octokit/auth-token" "^3.0.0" + "@octokit/graphql" "^5.0.0" + "@octokit/request" "^6.0.0" + "@octokit/request-error" "^3.0.0" + "@octokit/types" "^9.0.0" + before-after-hook "^2.2.0" + universal-user-agent "^6.0.0" + "@octokit/endpoint@^7.0.0": version "7.0.3" resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-7.0.3.tgz#0b96035673a9e3bedf8bab8f7335de424a2147ed" @@ -495,15 +465,6 @@ is-plain-object "^5.0.0" universal-user-agent "^6.0.0" -"@octokit/graphql@^4.5.8": - version "4.8.0" - resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-4.8.0.tgz#664d9b11c0e12112cbf78e10f49a05959aa22cc3" - integrity sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg== - dependencies: - "@octokit/request" "^5.6.0" - "@octokit/types" "^6.0.3" - universal-user-agent "^6.0.0" - "@octokit/graphql@^5.0.0": version "5.0.5" resolved "https://registry.yarnpkg.com/@octokit/graphql/-/graphql-5.0.5.tgz#a4cb3ea73f83b861893a6370ee82abb36e81afd2" @@ -513,27 +474,11 @@ "@octokit/types" "^9.0.0" universal-user-agent "^6.0.0" -"@octokit/oauth-authorization-url@^4.3.1": - version "4.3.3" - resolved "https://registry.yarnpkg.com/@octokit/oauth-authorization-url/-/oauth-authorization-url-4.3.3.tgz#6a6ef38f243086fec882b62744f39b517528dfb9" - integrity sha512-lhP/t0i8EwTmayHG4dqLXgU+uPVys4WD/qUNvC+HfB1S1dyqULm5Yx9uKc1x79aP66U1Cb4OZeW8QU/RA9A4XA== - "@octokit/oauth-authorization-url@^5.0.0": version "5.0.0" resolved "https://registry.yarnpkg.com/@octokit/oauth-authorization-url/-/oauth-authorization-url-5.0.0.tgz#029626ce87f3b31addb98cd0d2355c2381a1c5a1" integrity sha512-y1WhN+ERDZTh0qZ4SR+zotgsQUE1ysKnvBt1hvDRB2WRzYtVKQjn97HEPzoehh66Fj9LwNdlZh+p6TJatT0zzg== -"@octokit/oauth-methods@^1.1.0": - version "1.2.6" - resolved "https://registry.yarnpkg.com/@octokit/oauth-methods/-/oauth-methods-1.2.6.tgz#b9ac65e374b2cc55ee9dd8dcdd16558550438ea7" - integrity sha512-nImHQoOtKnSNn05uk2o76om1tJWiAo4lOu2xMAHYsNr0fwopP+Dv+2MlGvaMMlFjoqVd3fF3X5ZDTKCsqgmUaQ== - dependencies: - "@octokit/oauth-authorization-url" "^4.3.1" - "@octokit/request" "^5.4.14" - "@octokit/request-error" "^2.0.5" - "@octokit/types" "^6.12.2" - btoa-lite "^1.0.0" - "@octokit/oauth-methods@^2.0.0": version "2.0.4" resolved "https://registry.yarnpkg.com/@octokit/oauth-methods/-/oauth-methods-2.0.4.tgz#6abd9593ca7f91fe5068375a363bd70abd5516dc" @@ -545,11 +490,6 @@ "@octokit/types" "^8.0.0" btoa-lite "^1.0.0" -"@octokit/openapi-types@^12.11.0": - version "12.11.0" - resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-12.11.0.tgz#da5638d64f2b919bca89ce6602d059f1b52d3ef0" - integrity sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ== - "@octokit/openapi-types@^14.0.0": version "14.0.0" resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-14.0.0.tgz#949c5019028c93f189abbc2fb42f333290f7134a" @@ -560,12 +500,10 @@ resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-16.0.0.tgz#d92838a6cd9fb4639ca875ddb3437f1045cc625e" integrity sha512-JbFWOqTJVLHZSUUoF4FzAZKYtqdxWu9Z5m2QQnOyEa04fOFljvyh7D3GYKbfuaSWisqehImiVIMG4eyJeP5VEA== -"@octokit/plugin-paginate-rest@^2.16.8": - version "2.21.3" - resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-2.21.3.tgz#7f12532797775640dbb8224da577da7dc210c87e" - integrity sha512-aCZTEf0y2h3OLbrgKkrfFdjRL6eSOo8komneVQJnYecAxIej7Bafor2xhuDJOIFau4pk0i/P28/XgtbyPF0ZHw== - dependencies: - "@octokit/types" "^6.40.0" +"@octokit/openapi-types@^17.2.0": + version "17.2.0" + resolved "https://registry.yarnpkg.com/@octokit/openapi-types/-/openapi-types-17.2.0.tgz#f1800b5f9652b8e1b85cc6dfb1e0dc888810bdb5" + integrity sha512-MazrFNx4plbLsGl+LFesMo96eIXkFgEtaKbnNpdh4aQ0VM10aoylFsTYP1AEjkeoRNZiiPe3T6Gl2Hr8dJWdlQ== "@octokit/plugin-paginate-rest@^6.0.0": version "6.0.0" @@ -574,19 +512,19 @@ dependencies: "@octokit/types" "^9.0.0" +"@octokit/plugin-paginate-rest@^6.1.2": + version "6.1.2" + resolved "https://registry.yarnpkg.com/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-6.1.2.tgz#f86456a7a1fe9e58fec6385a85cf1b34072341f8" + integrity sha512-qhrmtQeHU/IivxucOV1bbI/xZyC/iOBhclokv7Sut5vnejAIAEXVcGQeRpQlU39E0WwK9lNvJHphHri/DB6lbQ== + dependencies: + "@octokit/tsconfig" "^1.0.2" + "@octokit/types" "^9.2.3" + "@octokit/plugin-request-log@^1.0.4": version "1.0.4" resolved "https://registry.yarnpkg.com/@octokit/plugin-request-log/-/plugin-request-log-1.0.4.tgz#5e50ed7083a613816b1e4a28aeec5fb7f1462e85" integrity sha512-mLUsMkgP7K/cnFEw07kWqXGF5LKrOkD+lhCrKvPHXWDywAwuDUeDwWBpc69XK3pNX0uKiVt8g5z96PJ6z9xCFA== -"@octokit/plugin-rest-endpoint-methods@^5.12.0": - version "5.16.2" - resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-5.16.2.tgz#7ee8bf586df97dd6868cf68f641354e908c25342" - integrity sha512-8QFz29Fg5jDuTPXVtey05BLm7OB+M8fnvE64RNegzX7U+5NUXcOcnpTIK0YfSHBg8gYd0oxIq3IZTe9SfPZiRw== - dependencies: - "@octokit/types" "^6.39.0" - deprecation "^2.3.1" - "@octokit/plugin-rest-endpoint-methods@^7.0.0": version "7.0.1" resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-7.0.1.tgz#f7ebe18144fd89460f98f35a587b056646e84502" @@ -595,14 +533,13 @@ "@octokit/types" "^9.0.0" deprecation "^2.3.1" -"@octokit/request-error@^2.0.5", "@octokit/request-error@^2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-2.1.0.tgz#9e150357831bfc788d13a4fd4b1913d60c74d677" - integrity sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg== +"@octokit/plugin-rest-endpoint-methods@^7.1.2": + version "7.1.2" + resolved "https://registry.yarnpkg.com/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-7.1.2.tgz#b77a8844601d3a394a02200cddb077f3ab841f38" + integrity sha512-R0oJ7j6f/AdqPLtB9qRXLO+wjI9pctUn8Ka8UGfGaFCcCv3Otx14CshQ89K4E88pmyYZS8p0rNTiprML/81jig== dependencies: - "@octokit/types" "^6.0.3" - deprecation "^2.0.0" - once "^1.4.0" + "@octokit/types" "^9.2.3" + deprecation "^2.3.1" "@octokit/request-error@^3.0.0": version "3.0.2" @@ -613,7 +550,7 @@ deprecation "^2.0.0" once "^1.4.0" -"@octokit/[email protected]", "@octokit/request@^5.4.14", "@octokit/request@^5.6.0", "@octokit/request@^5.6.3", "@octokit/request@^6.0.0": +"@octokit/request@^6.0.0": version "6.2.4" resolved "https://registry.yarnpkg.com/@octokit/request/-/request-6.2.4.tgz#b00a7185865c72bdd432e63168b1e900953ded0c" integrity sha512-at92SYQstwh7HH6+Kf3bFMnHrle7aIrC0r5rTP+Bb30118B6j1vI2/M4walh6qcQgfuLIKs8NUO5CytHTnUI3A== @@ -625,15 +562,15 @@ node-fetch "^2.6.7" universal-user-agent "^6.0.0" -"@octokit/rest@^18.12.0": - version "18.12.0" - resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-18.12.0.tgz#f06bc4952fc87130308d810ca9d00e79f6988881" - integrity sha512-gDPiOHlyGavxr72y0guQEhLsemgVjwRePayJ+FcKc2SJqKUbxbkvf5kAZEWA/MKvsfYlQAMVzNJE3ezQcxMJ2Q== +"@octokit/rest@^19.0.11": + version "19.0.11" + resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-19.0.11.tgz#2ae01634fed4bd1fca5b642767205ed3fd36177c" + integrity sha512-m2a9VhaP5/tUw8FwfnW2ICXlXpLPIqxtg3XcAiGMLj/Xhw3RSBfZ8le/466ktO1Gcjr8oXudGnHhxV1TXJgFxw== dependencies: - "@octokit/core" "^3.5.1" - "@octokit/plugin-paginate-rest" "^2.16.8" + "@octokit/core" "^4.2.1" + "@octokit/plugin-paginate-rest" "^6.1.2" "@octokit/plugin-request-log" "^1.0.4" - "@octokit/plugin-rest-endpoint-methods" "^5.12.0" + "@octokit/plugin-rest-endpoint-methods" "^7.1.2" "@octokit/rest@^19.0.7": version "19.0.7" @@ -645,12 +582,10 @@ "@octokit/plugin-request-log" "^1.0.4" "@octokit/plugin-rest-endpoint-methods" "^7.0.0" -"@octokit/types@^6.0.3", "@octokit/types@^6.10.0", "@octokit/types@^6.12.2", "@octokit/types@^6.39.0", "@octokit/types@^6.40.0": - version "6.41.0" - resolved "https://registry.yarnpkg.com/@octokit/types/-/types-6.41.0.tgz#e58ef78d78596d2fb7df9c6259802464b5f84a04" - integrity sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg== - dependencies: - "@octokit/openapi-types" "^12.11.0" +"@octokit/tsconfig@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@octokit/tsconfig/-/tsconfig-1.0.2.tgz#59b024d6f3c0ed82f00d08ead5b3750469125af7" + integrity sha512-I0vDR0rdtP8p2lGMzvsJzbhdOWy405HcGovrspJ8RRibHnyRgggUSNO5AIox5LmqiwmatHKYsvj6VGFHkqS7lA== "@octokit/types@^8.0.0": version "8.0.0" @@ -666,6 +601,13 @@ dependencies: "@octokit/openapi-types" "^16.0.0" +"@octokit/types@^9.2.3": + version "9.2.3" + resolved "https://registry.yarnpkg.com/@octokit/types/-/types-9.2.3.tgz#d0af522f394d74b585cefb7efd6197ca44d183a9" + integrity sha512-MMeLdHyFIALioycq+LFcA71v0S2xpQUX2cw6pPbHQjaibcHYwLnmK/kMZaWuGfGfjBJZ3wRUq+dOaWsvrPJVvA== + dependencies: + "@octokit/openapi-types" "^17.2.0" + "@opentelemetry/api@^1.0.1": version "1.0.4" resolved "https://registry.yarnpkg.com/@opentelemetry/api/-/api-1.0.4.tgz#a167e46c10d05a07ab299fc518793b0cff8f6924" @@ -917,11 +859,6 @@ resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-2.1.0.tgz#ea3dd64c4805597311790b61e872cbd1ed2cd806" integrity sha512-Q7DYAOi9O/+cLLhdaSvKdaumWyHbm7HAk/bFwwyTuU0arR5yyCeW5GOoqt4tJTpDRxhpx9Q8kQL6vMpuw9hDSw== -"@types/lru-cache@^5.1.0": - version "5.1.0" - resolved "https://registry.yarnpkg.com/@types/lru-cache/-/lru-cache-5.1.0.tgz#57f228f2b80c046b4a1bd5cac031f81f207f4f03" - integrity sha512-RaE0B+14ToE4l6UqdarKPnXwVDuigfFv+5j9Dze/Nqr23yyuqdNvzcZi3xB+3Agvi5R4EOgAksfv3lXX4vBt9w== - "@types/markdown-it@^12.0.0": version "12.2.3" resolved "https://registry.yarnpkg.com/@types/markdown-it/-/markdown-it-12.2.3.tgz#0d6f6e5e413f8daaa26522904597be3d6cd93b51" @@ -4356,6 +4293,11 @@ lru-cache@^6.0.0: dependencies: yallist "^4.0.0" +lru-cache@^9.0.0: + version "9.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-9.1.1.tgz#c58a93de58630b688de39ad04ef02ef26f1902f1" + integrity sha512-65/Jky17UwSb0BuB9V+MyDpsOtXKmYwzhyl+cOa9XUiI4uV2Ouy/2voFP3+al0BjZbJgMBD8FojMpAf+Z+qn4A== + make-error@^1.1.1: version "1.3.5" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8" @@ -7233,7 +7175,7 @@ unist-util-visit@^4.1.2: unist-util-is "^5.0.0" unist-util-visit-parents "^5.1.1" -universal-github-app-jwt@^1.0.1: +universal-github-app-jwt@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/universal-github-app-jwt/-/universal-github-app-jwt-1.1.1.tgz#d57cee49020662a95ca750a057e758a1a7190e6e" integrity sha512-G33RTLrIBMFmlDV4u4CBF7dh71eWwykck4XgaxaIVeZKOYZRAAxvcGMRFTUclVY6xoUPQvO4Ne5wKGxYm/Yy9w==
build
fe9031eb23bfab177abdffd5fcfda7f5d709e507
Charles Kerr
2025-01-21 17:41:52
refactor: in `StopTracing()`, use string literals instead of `optional<string>` (#45270) refactor: simplify StopTracing() a little by using a string_view instead of an optional<string> We have compile-time string literals that we're passing to a method that takes a string_view argument, so we don't need all this extra optional<string> scaffolding
diff --git a/shell/browser/api/electron_api_content_tracing.cc b/shell/browser/api/electron_api_content_tracing.cc index 384a16e1b3..70215fb765 100644 --- a/shell/browser/api/electron_api_content_tracing.cc +++ b/shell/browser/api/electron_api_content_tracing.cc @@ -5,6 +5,7 @@ #include <optional> #include <set> #include <string> +#include <string_view> #include <utility> #include "base/files/file_util.h" @@ -20,6 +21,7 @@ #include "shell/common/node_includes.h" using content::TracingController; +using namespace std::literals; namespace gin { @@ -69,9 +71,9 @@ void StopTracing(gin_helper::Promise<base::FilePath> promise, std::optional<base::FilePath> file_path) { auto resolve_or_reject = base::BindOnce( [](gin_helper::Promise<base::FilePath> promise, - const base::FilePath& path, std::optional<std::string> error) { - if (error) { - promise.RejectWithErrorMessage(error.value()); + const base::FilePath& path, const std::string_view error) { + if (!std::empty(error)) { + promise.RejectWithErrorMessage(error); } else { promise.Resolve(path); } @@ -81,21 +83,17 @@ void StopTracing(gin_helper::Promise<base::FilePath> promise, auto* instance = TracingController::GetInstance(); if (!instance->IsTracing()) { std::move(resolve_or_reject) - .Run(std::make_optional( - "Failed to stop tracing - no trace in progress")); + .Run("Failed to stop tracing - no trace in progress"sv); } else if (file_path) { auto split_callback = base::SplitOnceCallback(std::move(resolve_or_reject)); auto endpoint = TracingController::CreateFileEndpoint( - *file_path, - base::BindOnce(std::move(split_callback.first), std::nullopt)); + *file_path, base::BindOnce(std::move(split_callback.first), ""sv)); if (!instance->StopTracing(endpoint)) { - std::move(split_callback.second) - .Run(std::make_optional("Failed to stop tracing")); + std::move(split_callback.second).Run("Failed to stop tracing"sv); } } else { std::move(resolve_or_reject) - .Run(std::make_optional( - "Failed to create temporary file for trace data")); + .Run("Failed to create temporary file for trace data"sv); } }
refactor
5ff91159cdf0bd181967b09e1dc14f9524a266b3
Charles Kerr
2024-07-08 05:56:03
fix: dangling raw_ptr ElectronBrowserContext::extension_system_ (#42785) The extension system is freed by the DestroyBrowserContextServices() call in the destructor, so we need to zero out the pointer to avoid a dangling raw_ptr error.
diff --git a/shell/browser/electron_browser_context.cc b/shell/browser/electron_browser_context.cc index 4c8534e8c6..906e040ba1 100644 --- a/shell/browser/electron_browser_context.cc +++ b/shell/browser/electron_browser_context.cc @@ -372,6 +372,10 @@ ElectronBrowserContext::ElectronBrowserContext( ElectronBrowserContext::~ElectronBrowserContext() { DCHECK_CURRENTLY_ON(BrowserThread::UI); NotifyWillBeDestroyed(); + + // the DestroyBrowserContextServices() call below frees this. + extension_system_ = nullptr; + // Notify any keyed services of browser context destruction. BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( this);
fix
2337d8676dbde6cd10f6112a13e73e3bb18a28e5
cptpcrd
2024-08-01 06:13:13
fix: handle failing to enter fullscreen on macOS (#43112) * fix: handle failing to enter/exit fullscreen on macOS On macOS, failing to enter/exit fullscreen can fail. If this happens, properly restore the original window state. * refactor: remove fail to exit fullscreen handlers Seem to be unnecessary since the window exits fullscreen anyway.
diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h index d3c541ba68..cb39aab484 100644 --- a/shell/browser/native_window_mac.h +++ b/shell/browser/native_window_mac.h @@ -167,6 +167,7 @@ class NativeWindowMac : public NativeWindow, void DetachChildren() override; void NotifyWindowWillEnterFullScreen(); + void NotifyWindowDidFailToEnterFullScreen(); void NotifyWindowWillLeaveFullScreen(); // Cleanup observers when window is getting closed. Note that the destructor diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 06b4600245..3766e10d31 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -1662,6 +1662,13 @@ void NativeWindowMac::NotifyWindowWillEnterFullScreen() { UpdateVibrancyRadii(true); } +void NativeWindowMac::NotifyWindowDidFailToEnterFullScreen() { + UpdateVibrancyRadii(false); + + if (buttons_proxy_) + [buttons_proxy_ redraw]; +} + void NativeWindowMac::NotifyWindowWillLeaveFullScreen() { if (buttons_proxy_) { // Hide window title when leaving fullscreen. diff --git a/shell/browser/ui/cocoa/electron_ns_window_delegate.mm b/shell/browser/ui/cocoa/electron_ns_window_delegate.mm index e15687a942..d6af0ac6d9 100644 --- a/shell/browser/ui/cocoa/electron_ns_window_delegate.mm +++ b/shell/browser/ui/cocoa/electron_ns_window_delegate.mm @@ -311,6 +311,18 @@ using FullScreenTransitionState = shell_->HandlePendingFullscreenTransitions(); } +- (void)windowDidFailToEnterFullScreen:(NSWindow*)window { + shell_->set_fullscreen_transition_state(FullScreenTransitionState::kNone); + + shell_->SetResizable(is_resizable_); + shell_->NotifyWindowDidFailToEnterFullScreen(); + + if (shell_->HandleDeferredClose()) + return; + + shell_->HandlePendingFullscreenTransitions(); +} + - (void)windowWillExitFullScreen:(NSNotification*)notification { shell_->set_fullscreen_transition_state(FullScreenTransitionState::kExiting);
fix
f33bf2a27113bd9cd92bdd35233107779fc79f47
Erick Zhao
2023-03-08 18:41:26
docs: remove outdated ipc example (#37523)
diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index fc6edfedd4..c8b0ef8c01 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -786,7 +786,7 @@ cancel the request. If no event listener is added for this event, all bluetooth requests will be cancelled. -```javascript +```javascript title='main.js' const { app, BrowserWindow } = require('electron') let win = null @@ -1631,7 +1631,7 @@ ipcMain.on('open-devtools', (event, targetContentsId, devtoolsContentsId) => { An example of showing devtools in a `BrowserWindow`: -```js +```js title='main.js' const { app, BrowserWindow } = require('electron') let win = null @@ -1714,40 +1714,14 @@ Algorithm][SCA], just like [`postMessage`][], so prototype chains will not be included. Sending Functions, Promises, Symbols, WeakMaps, or WeakSets will throw an exception. -> **NOTE**: Sending non-standard JavaScript types such as DOM objects or -> special Electron objects will throw an exception. - -The renderer process can handle the message by listening to `channel` with the -[`ipcRenderer`](ipc-renderer.md) module. - -An example of sending messages from the main process to the renderer process: +:::warning -```javascript -// In the main process. -const { app, BrowserWindow } = require('electron') -let win = null +Sending non-standard JavaScript types such as DOM objects or +special Electron objects will throw an exception. -app.whenReady().then(() => { - win = new BrowserWindow({ width: 800, height: 600 }) - win.loadURL(`file://${__dirname}/index.html`) - win.webContents.on('did-finish-load', () => { - win.webContents.send('ping', 'whoooooooh!') - }) -}) -``` +::: -```html -<!-- index.html --> -<html> -<body> - <script> - require('electron').ipcRenderer.on('ping', (event, message) => { - console.log(message) // Prints 'whoooooooh!' - }) - </script> -</body> -</html> -``` +For additional reading, refer to [Electron's IPC guide](../tutorial/ipc.md). #### `contents.sendToFrame(frameId, channel, ...args)`
docs
75919e28b8e2f47ac3ba13d89b10fbc7c86186a7
David Sanders
2023-03-30 10:13:21
docs: add links to IPC event structures (#37760)
diff --git a/docs/api/structures/ipc-main-event.md b/docs/api/structures/ipc-main-event.md index 868fe4d0fb..eb06bb9315 100644 --- a/docs/api/structures/ipc-main-event.md +++ b/docs/api/structures/ipc-main-event.md @@ -3,9 +3,9 @@ * `processId` Integer - The internal ID of the renderer process that sent this message * `frameId` Integer - The ID of the renderer frame that sent this message * `returnValue` any - Set this to the value to be returned in a synchronous message -* `sender` WebContents - Returns the `webContents` that sent the message -* `senderFrame` WebFrameMain _Readonly_ - The frame that sent this message -* `ports` MessagePortMain[] - A list of MessagePorts that were transferred with this message +* `sender` [WebContents](../web-contents.md) - Returns the `webContents` that sent the message +* `senderFrame` [WebFrameMain](../web-frame-main.md) _Readonly_ - The frame that sent this message +* `ports` [MessagePortMain](../message-port-main.md)[] - A list of MessagePorts that were transferred with this message * `reply` Function - A function that will send an IPC message to the renderer frame that sent the original message that you are currently handling. You should use this method to "reply" to the sent message in order to guarantee the reply will go to the correct process and frame. * `channel` string * `...args` any[] diff --git a/docs/api/structures/ipc-main-invoke-event.md b/docs/api/structures/ipc-main-invoke-event.md index d15f44df40..9e24be40dc 100644 --- a/docs/api/structures/ipc-main-invoke-event.md +++ b/docs/api/structures/ipc-main-invoke-event.md @@ -2,5 +2,5 @@ * `processId` Integer - The internal ID of the renderer process that sent this message * `frameId` Integer - The ID of the renderer frame that sent this message -* `sender` WebContents - Returns the `webContents` that sent the message -* `senderFrame` WebFrameMain _Readonly_ - The frame that sent this message +* `sender` [WebContents](../web-contents.md) - Returns the `webContents` that sent the message +* `senderFrame` [WebFrameMain](../web-frame-main.md) _Readonly_ - The frame that sent this message diff --git a/docs/api/structures/ipc-renderer-event.md b/docs/api/structures/ipc-renderer-event.md index 1ac2def46d..cac7fff78e 100644 --- a/docs/api/structures/ipc-renderer-event.md +++ b/docs/api/structures/ipc-renderer-event.md @@ -1,7 +1,8 @@ # IpcRendererEvent Object extends `Event` -* `sender` IpcRenderer - The `IpcRenderer` instance that emitted the event originally +* `sender` [IpcRenderer](../ipc-renderer.md) - The `IpcRenderer` instance that emitted the event originally * `senderId` Integer - The `webContents.id` that sent the message, you can call `event.sender.sendTo(event.senderId, ...)` to reply to the message, see [ipcRenderer.sendTo][ipc-renderer-sendto] for more information. This only applies to messages sent from a different renderer. Messages sent directly from the main process set `event.senderId` to `0`. -* `ports` MessagePort[] - A list of MessagePorts that were transferred with this message +* `ports` [MessagePort][][] - A list of MessagePorts that were transferred with this message [ipc-renderer-sendto]: ../ipc-renderer.md#ipcrenderersendtowebcontentsid-channel-args +[MessagePort]: https://developer.mozilla.org/en-US/docs/Web/API/MessagePort
docs
a3af8ea76856f704f7d4b4239319fd444c96f2bd
Keeley Hammond
2024-09-23 16:58:46
build: use Node 20 in Appveyor images (#43897) * build: update Appveyor to Node 20 * build: update appveyor images * chore: return bake script to original form
diff --git a/appveyor-woa.yml b/appveyor-woa.yml index c22f31c7df..5154a5d3d0 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-130.0.6695.0 +image: e-130.0.6695.0-node-20 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default diff --git a/appveyor.yml b/appveyor.yml index a44b7904c2..67855a8daf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-130.0.6695.0 +image: e-130.0.6695.0-node-20 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default diff --git a/script/setup-win-for-dev.bat b/script/setup-win-for-dev.bat index ee71a3ab71..af870d068b 100644 --- a/script/setup-win-for-dev.bat +++ b/script/setup-win-for-dev.bat @@ -56,11 +56,14 @@ REM Install Windows SDK choco install windows-sdk-11-version-22h2-all REM Install nodejs python git and yarn needed dependencies -choco install -y --force nodejs --version=18.12.1 +choco install -y --force nodejs --version=20.9.0 choco install -y python2 git yarn choco install python --version 3.7.9 call C:\ProgramData\chocolatey\bin\RefreshEnv.cmd SET PATH=C:\Python27\;C:\Python27\Scripts;C:\Python39\;C:\Python39\Scripts;%PATH% +if not exist "C:\Users\appveyor\AppData\Roaming\npm" ( + mkdir "C:\Users\appveyor\AppData\Roaming\npm" +) REM Setup Depot Tools git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git C:\depot_tools
build
b7aad14e8d1c147866f158165c46b6b247527e99
Samuel Attard
2024-06-13 17:14:45
build: run gha on tag not branch (#42490)
diff --git a/script/release/ci-release-build.js b/script/release/ci-release-build.js index 2401cd0ecd..207be62225 100644 --- a/script/release/ci-release-build.js +++ b/script/release/ci-release-build.js @@ -93,7 +93,7 @@ async function githubActionsCall (targetBranch, workflowName, options) { } await octokit.request(`POST ${GH_ACTIONS_API_URL}/workflows/${workflowName}.yml/dispatches`, { - ref: buildRequest.branch, + ref: `refs/tags/${options.newVersion}`, inputs: { ...buildRequest.parameters }, diff --git a/script/release/prepare-release.js b/script/release/prepare-release.js index c84580e4bf..25e2c7490c 100755 --- a/script/release/prepare-release.js +++ b/script/release/prepare-release.js @@ -158,9 +158,10 @@ async function pushRelease (branch) { } } -async function runReleaseBuilds (branch) { +async function runReleaseBuilds (branch, newVersion) { await ciReleaseBuild(branch, { - ghRelease: true + ghRelease: true, + newVersion }); } @@ -190,6 +191,8 @@ async function verifyNewVersion () { console.log(`${fail} Aborting release of ${newVersion}`); process.exit(); } + + return newVersion; } async function promptForVersion (version) { @@ -225,10 +228,10 @@ async function prepareRelease (isBeta, notesOnly) { } else { const changes = await changesToRelease(); if (changes) { - await verifyNewVersion(); + const newVersion = await verifyNewVersion(); await createRelease(currentBranch, isBeta); await pushRelease(currentBranch); - await runReleaseBuilds(currentBranch); + await runReleaseBuilds(currentBranch, newVersion); } else { console.log('There are no new changes to this branch since the last release, aborting release.'); process.exit(1);
build
55c818d0a84400621c0817c8a2e4cc17d9eb24c8
Shelley Vohr
2023-01-19 19:44:23
fix: `<datalist>` dropdown positioning (#36934) fix: datalist dropdown positioning
diff --git a/shell/browser/ui/autofill_popup.cc b/shell/browser/ui/autofill_popup.cc index 1b62c04af2..516806b582 100644 --- a/shell/browser/ui/autofill_popup.cc +++ b/shell/browser/ui/autofill_popup.cc @@ -33,12 +33,14 @@ namespace electron { +namespace { + void CalculatePopupXAndWidthHorizontallyCentered( int popup_preferred_width, const gfx::Rect& content_area_bounds, const gfx::Rect& element_bounds, bool is_rtl, - gfx::Rect* bubble_bounds) { + gfx::Rect* popup_bounds) { // The preferred horizontal starting point for the pop-up is at the horizontal // center of the field. int preferred_starting_point = @@ -66,15 +68,15 @@ void CalculatePopupXAndWidthHorizontallyCentered( int amount_to_grow_in_unpreferred_direction = std::max(0, popup_width - space_to_grow_in_preferred_direction); - bubble_bounds->set_width(popup_width); + popup_bounds->set_width(popup_width); if (is_rtl) { // Note, in RTL the |pop_up_width| must be subtracted to achieve // right-alignment of the pop-up with the element. - bubble_bounds->set_x(preferred_starting_point - popup_width + - amount_to_grow_in_unpreferred_direction); + popup_bounds->set_x(preferred_starting_point - popup_width + + amount_to_grow_in_unpreferred_direction); } else { - bubble_bounds->set_x(preferred_starting_point - - amount_to_grow_in_unpreferred_direction); + popup_bounds->set_x(preferred_starting_point - + amount_to_grow_in_unpreferred_direction); } } @@ -82,7 +84,7 @@ void CalculatePopupXAndWidth(int popup_preferred_width, const gfx::Rect& content_area_bounds, const gfx::Rect& element_bounds, bool is_rtl, - gfx::Rect* bubble_bounds) { + gfx::Rect* popup_bounds) { int right_growth_start = base::clamp( element_bounds.x(), content_area_bounds.x(), content_area_bounds.right()); int left_growth_end = @@ -107,15 +109,15 @@ void CalculatePopupXAndWidth(int popup_preferred_width, right_available < popup_width && right_available < left_available; } - bubble_bounds->set_width(popup_width); - bubble_bounds->set_x(grow_left ? left_growth_end - popup_width - : right_growth_start); + popup_bounds->set_width(popup_width); + popup_bounds->set_x(grow_left ? left_growth_end - popup_width + : right_growth_start); } void CalculatePopupYAndHeight(int popup_preferred_height, const gfx::Rect& content_area_bounds, const gfx::Rect& element_bounds, - gfx::Rect* bubble_bounds) { + gfx::Rect* popup_bounds) { int top_growth_end = base::clamp(element_bounds.y(), content_area_bounds.y(), content_area_bounds.bottom()); int bottom_growth_start = @@ -125,18 +127,18 @@ void CalculatePopupYAndHeight(int popup_preferred_height, int top_available = top_growth_end - content_area_bounds.y(); int bottom_available = content_area_bounds.bottom() - bottom_growth_start; - bubble_bounds->set_height(popup_preferred_height); - bubble_bounds->set_y(top_growth_end); + popup_bounds->set_height(popup_preferred_height); + popup_bounds->set_y(top_growth_end); if (bottom_available >= popup_preferred_height || bottom_available >= top_available) { - bubble_bounds->AdjustToFit( - gfx::Rect(bubble_bounds->x(), element_bounds.bottom(), - bubble_bounds->width(), bottom_available)); + popup_bounds->AdjustToFit( + gfx::Rect(popup_bounds->x(), element_bounds.bottom(), + popup_bounds->width(), bottom_available)); } else { - bubble_bounds->AdjustToFit( - gfx::Rect(bubble_bounds->x(), content_area_bounds.y(), - bubble_bounds->width(), top_available)); + popup_bounds->AdjustToFit(gfx::Rect(popup_bounds->x(), + content_area_bounds.y(), + popup_bounds->width(), top_available)); } } @@ -145,22 +147,24 @@ gfx::Rect CalculatePopupBounds(const gfx::Size& desired_size, const gfx::Rect& element_bounds, bool is_rtl, bool horizontally_centered) { - gfx::Rect bubble_bounds; + gfx::Rect popup_bounds; if (horizontally_centered) { CalculatePopupXAndWidthHorizontallyCentered( desired_size.width(), content_area_bounds, element_bounds, is_rtl, - &bubble_bounds); + &popup_bounds); } else { CalculatePopupXAndWidth(desired_size.width(), content_area_bounds, - element_bounds, is_rtl, &bubble_bounds); + element_bounds, is_rtl, &popup_bounds); } CalculatePopupYAndHeight(desired_size.height(), content_area_bounds, - element_bounds, &bubble_bounds); + element_bounds, &popup_bounds); - return bubble_bounds; + return popup_bounds; } +} // namespace + AutofillPopup::AutofillPopup() { bold_font_list_ = gfx::FontList().DeriveWithWeight(gfx::Font::Weight::BOLD); smaller_font_list_ = @@ -242,16 +246,12 @@ void AutofillPopup::UpdatePopupBounds() { views::View::ConvertPointToScreen(parent_, &origin); gfx::Rect bounds(origin, element_bounds_.size()); - gfx::Rect window_bounds = parent_->GetBoundsInScreen(); - gfx::Size preferred_size = gfx::Size(GetDesiredPopupWidth(), GetDesiredPopupHeight()); - popup_bounds_ = CalculatePopupBounds(preferred_size, window_bounds, bounds, - base::i18n::IsRTL(), true); - CalculatePopupXAndWidthHorizontallyCentered( - preferred_size.width(), window_bounds, element_bounds_, - base::i18n::IsRTL(), &popup_bounds_); + popup_bounds_ = + CalculatePopupBounds(preferred_size, parent_->GetBoundsInScreen(), bounds, + base::i18n::IsRTL(), false); } gfx::Rect AutofillPopup::popup_bounds_in_view() {
fix
b497700e363e1f406466050e0dd13d3fc108e96b
Shelley Vohr
2024-08-16 11:17:42
test: fixup Node.js snapshot tests to run correctly (#43332)
diff --git a/patches/node/ci_ensure_node_tests_set_electron_run_as_node.patch b/patches/node/ci_ensure_node_tests_set_electron_run_as_node.patch index c28b9e94f1..05a70dd710 100644 --- a/patches/node/ci_ensure_node_tests_set_electron_run_as_node.patch +++ b/patches/node/ci_ensure_node_tests_set_electron_run_as_node.patch @@ -7,18 +7,53 @@ Some node tests / test fixtures spawn other tests that clobber env, which causes the `ELECTRON_RUN_AS_NODE` variable to be lost. This patch re-injects it. -diff --git a/test/common/assertSnapshot.js b/test/common/assertSnapshot.js -index 88f40281e069b77ac071ac872c4491f749b64e21..0fa102da111fa370406ca74069316fa7a7a3a050 100644 ---- a/test/common/assertSnapshot.js -+++ b/test/common/assertSnapshot.js -@@ -80,6 +80,7 @@ async function spawnAndAssert(filename, transform = (x) => x, { tty = false, ... - const flags = common.parseTestFlags(filename); - const executable = tty ? 'tools/pseudo-tty.py' : process.execPath; - const args = tty ? [process.execPath, ...flags, filename] : [...flags, filename]; -+ if (options && options.env) options.env.ELECTRON_RUN_AS_NODE = 1; - const { stdout, stderr } = await common.spawnPromisified(executable, args, options); - await assertSnapshot(transform(`${stdout}${stderr}`), filename); - } +diff --git a/test/fixtures/errors/promise_unhandled_warn_with_error.snapshot b/test/fixtures/errors/promise_unhandled_warn_with_error.snapshot +index d7f1aa2f72007f6f70b6b66b81913f39e5678d2f..e091b1575954f5dc82a05a5d200ee028e053f616 100644 +--- a/test/fixtures/errors/promise_unhandled_warn_with_error.snapshot ++++ b/test/fixtures/errors/promise_unhandled_warn_with_error.snapshot +@@ -6,5 +6,5 @@ + at * + at * + at * +-(Use `node --trace-warnings ...` to show where the warning was created) ++(Use `* --trace-warnings ...` to show where the warning was created) + (node:*) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https:*nodejs.org*api*cli.html#cli_unhandled_rejections_mode). (rejection id: 1) +diff --git a/test/fixtures/errors/throw_error_with_getter_throw.snapshot b/test/fixtures/errors/throw_error_with_getter_throw.snapshot +index 30bbb336a22aaffbd63333f297eb598a8f501d75..1786f96f19856cdc43e0e86c8271a845e337359f 100644 +--- a/test/fixtures/errors/throw_error_with_getter_throw.snapshot ++++ b/test/fixtures/errors/throw_error_with_getter_throw.snapshot +@@ -3,6 +3,6 @@ + throw { * eslint-disable-line no-throw-literal + ^ + [object Object] +-(Use `node --trace-uncaught ...` to show where the exception was thrown) ++(Use `* --trace-uncaught ...` to show where the exception was thrown) + + Node.js * +diff --git a/test/fixtures/errors/throw_null.snapshot b/test/fixtures/errors/throw_null.snapshot +index 88494ec6832205b30e7ae159708112a45494834c..1a1191ca9ced90936b764c32c1c334cce114b46e 100644 +--- a/test/fixtures/errors/throw_null.snapshot ++++ b/test/fixtures/errors/throw_null.snapshot +@@ -3,6 +3,6 @@ + throw null; + ^ + null +-(Use `node --trace-uncaught ...` to show where the exception was thrown) ++(Use `* --trace-uncaught ...` to show where the exception was thrown) + + Node.js * +diff --git a/test/fixtures/errors/throw_undefined.snapshot b/test/fixtures/errors/throw_undefined.snapshot +index baae7384453373f3a005b4f85abb702a4c165f98..b6b6060b17839f3452aa915c12bd5174b7585414 100644 +--- a/test/fixtures/errors/throw_undefined.snapshot ++++ b/test/fixtures/errors/throw_undefined.snapshot +@@ -3,6 +3,6 @@ + throw undefined; + ^ + undefined +-(Use `node --trace-uncaught ...` to show where the exception was thrown) ++(Use `* --trace-uncaught ...` to show where the exception was thrown) + + Node.js * diff --git a/test/fixtures/test-runner/output/arbitrary-output-colored.js b/test/fixtures/test-runner/output/arbitrary-output-colored.js index af23e674cb361ed81dafa22670d5633559cd1144..1dd59990cb7cdba8aecf4f499ee6b92e7cd41b30 100644 --- a/test/fixtures/test-runner/output/arbitrary-output-colored.js @@ -32,48 +67,32 @@ index af23e674cb361ed81dafa22670d5633559cd1144..1dd59990cb7cdba8aecf4f499ee6b92e + await once(spawn(process.execPath, ['-r', reset, '--test', test], { stdio: 'inherit', env: { ELECTRON_RUN_AS_NODE: 1 }}), 'exit'); + await once(spawn(process.execPath, ['-r', reset, '--test', '--test-reporter', 'tap', test], { stdio: 'inherit', env: { ELECTRON_RUN_AS_NODE: 1 } }), 'exit'); })().then(common.mustCall()); -diff --git a/test/parallel/test-node-output-console.mjs b/test/parallel/test-node-output-console.mjs -index f995c170540ffaa80b1b5f8b95dbd8f52bbd5431..6455dbdd015477e16c414b6d2113139327fea4b3 100644 ---- a/test/parallel/test-node-output-console.mjs -+++ b/test/parallel/test-node-output-console.mjs -@@ -31,6 +31,7 @@ describe('console output', { concurrency: true }, () => { - .transform(snapshot.replaceWindowsLineEndings, snapshot.replaceWindowsPaths, replaceStackTrace); - for (const { name, transform, env } of tests) { - it(name, async () => { -+ if (env) env.ELECTRON_RUN_AS_NODE = 1; - await snapshot.spawnAndAssert( - fixtures.path(name), - transform ?? defaultTransform, diff --git a/test/parallel/test-node-output-errors.mjs b/test/parallel/test-node-output-errors.mjs -index 84f20a77dda367fe1ada8d616c7b6813d39efd43..27d16d74884a006ba01b777f5a20339b4906197b 100644 +index 84f20a77dda367fe1ada8d616c7b6813d39efd43..9bebb256776c5be155a8de07abbe4284bc8dad8a 100644 --- a/test/parallel/test-node-output-errors.mjs +++ b/test/parallel/test-node-output-errors.mjs -@@ -59,21 +59,22 @@ describe('errors output', { concurrency: true }, () => { - { name: 'errors/events_unhandled_error_subclass.js', transform: errTransform }, - { name: 'errors/if-error-has-good-stack.js', transform: errTransform }, - { name: 'errors/throw_custom_error.js', transform: errTransform }, -- { name: 'errors/throw_error_with_getter_throw.js', transform: errTransform }, -+ // { name: 'errors/throw_error_with_getter_throw.js', transform: errTransform }, - { name: 'errors/throw_in_line_with_tabs.js', transform: errTransform }, - { name: 'errors/throw_non_error.js', transform: errTransform }, -- { name: 'errors/throw_null.js', transform: errTransform }, -- { name: 'errors/throw_undefined.js', transform: errTransform }, -+ // { name: 'errors/throw_null.js', transform: errTransform }, -+ // { name: 'errors/throw_undefined.js', transform: errTransform }, - { name: 'errors/timeout_throw.js', transform: errTransform }, - { name: 'errors/undefined_reference_in_new_context.js', transform: errTransform }, - { name: 'errors/promise_always_throw_unhandled.js', transform: promiseTransform }, -- { name: 'errors/promise_unhandled_warn_with_error.js', transform: promiseTransform }, -+ // { name: 'errors/promise_unhandled_warn_with_error.js', transform: promiseTransform }, - { name: 'errors/unhandled_promise_trace_warnings.js', transform: promiseTransform }, -- { skip: skipForceColors, name: 'errors/force_colors.js', -- transform: forceColorsTransform, env: { FORCE_COLOR: 1 } }, -+ // { skip: skipForceColors, name: 'errors/force_colors.js', -+ // transform: forceColorsTransform, env: { FORCE_COLOR: 1 } }, - ]; - for (const { name, transform = defaultTransform, env, skip = false } of tests) { - it(name, { skip }, async () => { -+ if (env) env.ELECTRON_RUN_AS_NODE = 1; - await snapshot.spawnAndAssert(fixtures.path(name), transform, { env: { ...env, ...process.env } }); - }); +@@ -3,6 +3,7 @@ import * as fixtures from '../common/fixtures.mjs'; + import * as snapshot from '../common/assertSnapshot.js'; + import * as os from 'node:os'; + import { describe, it } from 'node:test'; ++import { basename } from 'node:path'; + import { pathToFileURL } from 'node:url'; + + const skipForceColors = +@@ -20,13 +21,15 @@ function replaceForceColorsStackTrace(str) { + + describe('errors output', { concurrency: true }, () => { + function normalize(str) { ++ const baseName = basename(process.argv0 || 'node', '.exe'); + return str.replaceAll(snapshot.replaceWindowsPaths(process.cwd()), '') + .replaceAll(pathToFileURL(process.cwd()).pathname, '') + .replaceAll('//', '*') + .replaceAll(/\/(\w)/g, '*$1') + .replaceAll('*test*', '*') + .replaceAll('*fixtures*errors*', '*') +- .replaceAll('file:**', 'file:*/'); ++ .replaceAll('file:**', 'file:*/') ++ .replaceAll(`${baseName} --`, '* --'); } + + function normalizeNoNumbers(str) {
test
f1019c2c4ace19be9f9c80696101106ee20d190c
Charles Kerr
2024-09-09 15:34:42
fix: -Wunsafe-buffer-usage warnings in asar file IO (#43624) * fix: -Wunsafe-buffer-usage warnings in ScopedTemporaryFile::InitFromFile() * fix: -Wunsafe-buffer-usage warnings in Archive::Init()
diff --git a/shell/common/asar/archive.cc b/shell/common/asar/archive.cc index b3daddcf8c..4fb9a70f5c 100644 --- a/shell/common/asar/archive.cc +++ b/shell/common/asar/archive.cc @@ -201,22 +201,19 @@ bool Archive::Init() { return false; } - std::vector<char> buf; - int len; + std::vector<uint8_t> buf; buf.resize(8); { electron::ScopedAllowBlockingForElectron allow_blocking; - len = file_.ReadAtCurrentPos(buf.data(), buf.size()); - } - if (len != static_cast<int>(buf.size())) { - PLOG(ERROR) << "Failed to read header size from " << path_.value(); - return false; + if (!file_.ReadAtCurrentPosAndCheck(buf)) { + PLOG(ERROR) << "Failed to read header size from " << path_.value(); + return false; + } } uint32_t size; - if (!base::PickleIterator(base::Pickle::WithData(base::as_byte_span(buf))) - .ReadUInt32(&size)) { + if (!base::PickleIterator(base::Pickle::WithData(buf)).ReadUInt32(&size)) { LOG(ERROR) << "Failed to parse header size from " << path_.value(); return false; } @@ -224,16 +221,14 @@ bool Archive::Init() { buf.resize(size); { electron::ScopedAllowBlockingForElectron allow_blocking; - len = file_.ReadAtCurrentPos(buf.data(), buf.size()); - } - if (len != static_cast<int>(buf.size())) { - PLOG(ERROR) << "Failed to read header from " << path_.value(); - return false; + if (!file_.ReadAtCurrentPosAndCheck(buf)) { + PLOG(ERROR) << "Failed to read header from " << path_.value(); + return false; + } } std::string header; - if (!base::PickleIterator(base::Pickle::WithData(base::as_byte_span(buf))) - .ReadString(&header)) { + if (!base::PickleIterator(base::Pickle::WithData(buf)).ReadString(&header)) { LOG(ERROR) << "Failed to parse header from " << path_.value(); return false; } diff --git a/shell/common/asar/scoped_temporary_file.cc b/shell/common/asar/scoped_temporary_file.cc index 32b192dda0..fc209c60f7 100644 --- a/shell/common/asar/scoped_temporary_file.cc +++ b/shell/common/asar/scoped_temporary_file.cc @@ -62,20 +62,15 @@ bool ScopedTemporaryFile::InitFromFile( return false; electron::ScopedAllowBlockingForElectron allow_blocking; - std::vector<char> buf(size); - int len = src->Read(offset, buf.data(), buf.size()); - if (len != static_cast<int>(size)) + std::vector<uint8_t> buf(size); + if (!src->ReadAndCheck(offset, buf)) return false; if (integrity) - ValidateIntegrityOrDie(base::as_byte_span(buf), *integrity); + ValidateIntegrityOrDie(buf, *integrity); base::File dest(path_, base::File::FLAG_OPEN | base::File::FLAG_WRITE); - if (!dest.IsValid()) - return false; - - return dest.WriteAtCurrentPos(buf.data(), buf.size()) == - static_cast<int>(size); + return dest.IsValid() && dest.WriteAtCurrentPosAndCheck(buf); } } // namespace asar
fix
3534923bd2fe933089f8672fbef88cda2bc4d9d8
Shelley Vohr
2024-06-25 07:32:43
build: account for `subjectAndDescription` null in patch linting (#42636) fix: account for subjectAndDescription null in patch linting
diff --git a/script/lint.js b/script/lint.js index fd5d57e2f4..775895770f 100755 --- a/script/lint.js +++ b/script/lint.js @@ -252,8 +252,10 @@ const LINTERS = [{ const allOk = filenames.length > 0 && filenames.map(f => { const patchText = fs.readFileSync(f, 'utf8'); - const subjectAndDescription = /Subject: (.*?)\n\n([\s\S]*?)\s*(?=diff)/ms.exec(patchText); - if (!subjectAndDescription[2]) { + + const regex = /Subject: (.*?)\n\n([\s\S]*?)\s*(?=diff)/ms; + const subjectAndDescription = regex.exec(patchText); + if (!subjectAndDescription?.[2]) { console.warn(`Patch file '${f}' has no description. Every patch must contain a justification for why the patch exists and the plan for its removal.`); return false; }
build
d8d5d4a4a18796d2ec78e2ffa75d6f5908372c26
David Sanders
2022-10-17 04:35:36
docs: update VS Code debugger types to remove "pwa-" prefix (#36042)
diff --git a/docs/tutorial/tutorial-2-first-app.md b/docs/tutorial/tutorial-2-first-app.md index d8cc8eb6fd..171fe4ecb7 100644 --- a/docs/tutorial/tutorial-2-first-app.md +++ b/docs/tutorial/tutorial-2-first-app.md @@ -369,12 +369,12 @@ run. Create a launch.json configuration in a new `.vscode` folder in your projec "name": "Renderer", "port": 9222, "request": "attach", - "type": "pwa-chrome", + "type": "chrome", "webRoot": "${workspaceFolder}" }, { "name": "Main", - "type": "pwa-node", + "type": "node", "request": "launch", "cwd": "${workspaceFolder}", "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron", @@ -398,11 +398,11 @@ What we have done in the `launch.json` file is to create 3 configurations: - `Main` is used to start the main process and also expose port 9222 for remote debugging (`--remote-debugging-port=9222`). This is the port that we will use to attach the debugger for the `Renderer`. Because the main process is a Node.js process, the type is set to - `pwa-node` (`pwa-` is the prefix that tells VS Code to use the latest JavaScript debugger). + `node`. - `Renderer` is used to debug the renderer process. Because the main process is the one that creates the process, we have to "attach" to it (`"request": "attach"`) instead of creating a new one. - The renderer process is a web one, so the debugger we have to use is `pwa-chrome`. + The renderer process is a web one, so the debugger we have to use is `chrome`. - `Main + renderer` is a [compound task] that executes the previous ones simultaneously. :::caution
docs
2eb13d377e27eb5557d578e321df0de3e70d700a
Yureka
2023-12-08 04:14:54
docs: fix year typos in electron-timelines.md (#40728)
diff --git a/docs/tutorial/electron-timelines.md b/docs/tutorial/electron-timelines.md index fae659cb6d..3f991f2cd1 100644 --- a/docs/tutorial/electron-timelines.md +++ b/docs/tutorial/electron-timelines.md @@ -9,7 +9,7 @@ check out our [Electron Versioning](./electron-versioning.md) doc. | Electron | Alpha | Beta | Stable | EOL | Chrome | Node | Supported | | ------- | ----- | ------- | ------ | ------ | ---- | ---- | ---- | -| 29.0.0 | 2023-Dec-07 | 2023-Jan-24 | 2023-Feb-20 | 2024-Aug-20 | M122 | v18.19 | ✅ | +| 29.0.0 | 2023-Dec-07 | 2024-Jan-24 | 2024-Feb-20 | 2024-Aug-20 | M122 | v18.19 | ✅ | | 28.0.0 | 2023-Oct-11 | 2023-Nov-06 | 2023-Dec-05 | 2024-Jun-11 | M120 | v18.18 | ✅ | | 27.0.0 | 2023-Aug-17 | 2023-Sep-13 | 2023-Oct-10 | 2024-Apr-16 | M118 | v18.17 | ✅ | | 26.0.0 | 2023-Jun-01 | 2023-Jun-27 | 2023-Aug-15 | 2024-Feb-20 | M116 | v18.16 | ✅ |
docs
bc22ee7897b9d482bbe7e5322ef771462a2bd6ec
Shelley Vohr
2025-01-31 10:29:50
build: fix `slack-github-action` for backports (#45388) build: fix slack-github-action for backports
diff --git a/.github/workflows/pull-request-labeled.yml b/.github/workflows/pull-request-labeled.yml index f17524034e..ae1e6f6896 100644 --- a/.github/workflows/pull-request-labeled.yml +++ b/.github/workflows/pull-request-labeled.yml @@ -15,12 +15,12 @@ jobs: - name: Trigger Slack workflow uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0 with: + webhook: ${{ secrets.BACKPORT_REQUESTED_SLACK_WEBHOOK_URL }} + webhook-type: webhook-trigger payload: | { "url": "${{ github.event.pull_request.html_url }}" } - env: - SLACK_WEBHOOK_URL: ${{ secrets.BACKPORT_REQUESTED_SLACK_WEBHOOK_URL }} pull-request-labeled-deprecation-review-complete: name: deprecation-review/complete label added if: github.event.label.name == 'deprecation-review/complete ✅'
build
6953f5505f76e5faa72c8a27b826b8d83d28eddc
michal-pichlinski-openfin
2025-01-17 16:21:10
refactor: remove InspectableWebContentsViewMac in favor of the Views version (#44628) * refactor: remove InspectableWebContentsViewMac in favor of the Views version * cherry-pick: refactor: remove InspectableWebContentsViewMac in favor of the Views version (#41326) commit e67ab9a93dadccecff30de50ab4555191c30b6c4 Confilcts not resolved, except removal of the files removed by the original commit. * resolved conflicts and build issues after cherry-pick * cherry-picked: fix: add method allowing to disable headless mode in native widget https://github.com/electron/electron/pull/42996 fixing https://github.com/electron/electron/issues/42995 * fix: displaying select popup in window created as fullscreen window `constrainFrameRect:toScreen:` is not being call for windows created with `fullscreen: true` therefore `headless` mode was not being removed and `RenderWidgetHostNSViewBridge::DisplayPopupMenu` ignored displaying popup. Issue could be fixed by placing additional removal of `headless` mode in the `toggleFullScreen:`, but `orderWindow:relativeTo:` is called both for a regular and a fullscreen window, therefore there will be a single place fixing both cases. Because `electron::NativeWindowMac` lifetime may be shorter than `ElectronNSWindow` on which macOS may execute `orderWindow:relativeTo:` we need to clear `shell_` when `NativeWindow` is being closed. Fixes #43010. * fix: Content visibility when using `vibrancy` We need to put `NSVisualEffectView` before `ViewsCompositorSuperview` otherwise when using `vibrancy` in `BrowserWindow` `NSVisualEffectView` will hide content displayed by the compositor. Fixes #43003 Fixes #42336 In fact main issues reported in these tickets were not present after cherry-picking original refactor switching to `views::WebView`, so text could be selected and click event was properly generated. However both issues testcases were using `vibrancy` and actual content was invisible, because it was covered by the `NSVisualEffectView`. * fix: EXCEPTION_ACCESS_VIOLATION crash on BrowserWindow.destroy() Restored postponed deletion of the `NativeWindow`. Restoration caused `DCHECK(new_parent_ui_layer->GetCompositor());` failure in `BrowserCompositorMac::SetParentUiLayer` after the spec test: `chrome extensions chrome.webRequest does not take precedence over Electron webRequest - http` with stack: ``` 7 Electron Framework 0x000000011fe07830 content::BrowserCompositorMac::SetParentUiLayer(ui::Layer*) + 628 8 Electron Framework 0x000000011fe0c154 content::RenderWidgetHostViewMac::SetParentUiLayer(ui::Layer*) + 220 9 Electron Framework 0x000000011fe226a8 content::WebContentsViewMac::CreateViewForWidget(content::RenderWidgetHost*) + 600 10 Electron Framework 0x000000011fd37e4c content::WebContentsImpl::CreateRenderWidgetHostViewForRenderManager(content::RenderViewHost*) + 164 11 Electron Framework 0x000000011fb32278 content::RenderFrameHostManager::CreateSpeculativeRenderFrame(content::SiteInstanceImpl*, bool, scoped_refptr<content::BrowsingContextState> const&) + 816 12 Electron Framework 0x000000011fb2ab8c content::RenderFrameHostManager::CreateSpeculativeRenderFrameHost(content::SiteInstanceImpl*, content::SiteInstanceImpl*, bool) + 1308 13 Electron Framework 0x000000011fb28598 content::RenderFrameHostManager::GetFrameHostForNavigation(content::NavigationRequest*, content::BrowsingContextGroupSwap*, std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char>>*) + 1796 14 Electron Framework 0x000000011fa78660 content::NavigationRequest::SelectFrameHostForOnRequestFailedInternal(bool, bool, std::__Cr::optional<std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char>>> const&) + 280 15 Electron Framework 0x000000011fa6a994 content::NavigationRequest::OnRequestFailedInternal(network::URLLoaderCompletionStatus const&, bool, std::__Cr::optional<std::__Cr::basic_string<char, std::__Cr::char_traits<char>, std::__Cr::allocator<char>>> const&, bo + 1008 16 Electron Framework 0x000000011fa7772c content::NavigationRequest::OnRequestFailed(network::URLLoaderCompletionStatus const&) + 72 17 Electron Framework 0x000000011f8554ac content::NavigationURLLoaderImpl::NotifyRequestFailed(network::URLLoaderCompletionStatus const&) + 248 ``` This was probably the reason of removing `NativeWindow` immediately in order to cleanup `views_host_` in `WebContentsViewMac` to prevent using layer without compositor in `WebContentsViewMac::CreateViewForWidget`. `[ElectronNSWindowDelegate windowWillClose:]` is deleting window host and the compositor used by the `NativeWindow` therefore detach `NativeWindow` contents from parent. This will clear `views_host_` and prevent failing mentioned `DCHECK`. Fixes #42975 * chore: Applied review suggestions * refactor: directly cleanup shell --------- Co-authored-by: Samuel Maddock <[email protected]>
diff --git a/filenames.gni b/filenames.gni index 99c80b915a..9a950d0e19 100644 --- a/filenames.gni +++ b/filenames.gni @@ -159,12 +159,8 @@ filenames = { "shell/browser/osr/osr_web_contents_view_mac.mm", "shell/browser/relauncher_mac.cc", "shell/browser/ui/certificate_trust_mac.mm", - "shell/browser/ui/cocoa/delayed_native_view_host.h", - "shell/browser/ui/cocoa/delayed_native_view_host.mm", "shell/browser/ui/cocoa/electron_bundle_mover.h", "shell/browser/ui/cocoa/electron_bundle_mover.mm", - "shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h", - "shell/browser/ui/cocoa/electron_inspectable_web_contents_view.mm", "shell/browser/ui/cocoa/electron_menu_controller.h", "shell/browser/ui/cocoa/electron_menu_controller.mm", "shell/browser/ui/cocoa/electron_native_widget_mac.h", @@ -191,8 +187,6 @@ filenames = { "shell/browser/ui/cocoa/window_buttons_proxy.mm", "shell/browser/ui/drag_util_mac.mm", "shell/browser/ui/file_dialog_mac.mm", - "shell/browser/ui/inspectable_web_contents_view_mac.h", - "shell/browser/ui/inspectable_web_contents_view_mac.mm", "shell/browser/ui/message_box_mac.mm", "shell/browser/ui/tray_icon_cocoa.h", "shell/browser/ui/tray_icon_cocoa.mm", @@ -224,8 +218,6 @@ filenames = { "shell/browser/ui/views/electron_views_delegate.h", "shell/browser/ui/views/frameless_view.cc", "shell/browser/ui/views/frameless_view.h", - "shell/browser/ui/views/inspectable_web_contents_view_views.cc", - "shell/browser/ui/views/inspectable_web_contents_view_views.h", "shell/browser/ui/views/menu_bar.cc", "shell/browser/ui/views/menu_bar.h", "shell/browser/ui/views/menu_delegate.cc", diff --git a/patches/chromium/.patches b/patches/chromium/.patches index dc05787535..939c675377 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -133,6 +133,8 @@ osr_shared_texture_remove_keyed_mutex_on_win_dxgi.patch feat_allow_usage_of_sccontentsharingpicker_on_supported_platforms.patch chore_partial_revert_of.patch fix_software_compositing_infinite_loop.patch +fix_add_method_which_disables_headless_mode_on_native_widget.patch +fix_put_nsvisualeffectview_before_viewscompositorsuperview.patch refactor_unfilter_unresponsive_events.patch build_disable_thin_lto_mac.patch build_add_public_config_simdutf_config.patch diff --git a/patches/chromium/fix_add_method_which_disables_headless_mode_on_native_widget.patch b/patches/chromium/fix_add_method_which_disables_headless_mode_on_native_widget.patch new file mode 100644 index 0000000000..95d2235914 --- /dev/null +++ b/patches/chromium/fix_add_method_which_disables_headless_mode_on_native_widget.patch @@ -0,0 +1,26 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Cezary Kulakowski <[email protected]> +Date: Mon, 22 Jul 2024 16:23:13 +0200 +Subject: fix: add method which disables headless mode on native widget + +We need this method as we create window in headless mode and we +switch it back to normal mode only after inital paint is done in +order to get some events like WebContents.beginFrameSubscription. +If we don't set `is_headless_` to false then some child windows +e.g. autofill popups will be created in headless mode leading to +ui problems (like dissapearing popup during typing in html's +input list. + +diff --git a/ui/views/widget/widget.h b/ui/views/widget/widget.h +index 30d0ea6633cb0f7f9aab37951a38be9b0482a12a..734e91e6d50c8d3afd20b39167c6254e934e7c1e 100644 +--- a/ui/views/widget/widget.h ++++ b/ui/views/widget/widget.h +@@ -1144,6 +1144,8 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate, + // True if widget was created in headless mode. + bool is_headless() const { return is_headless_; } + ++ void DisableHeadlessMode() { is_headless_ = false; } ++ + // True if the window size will follow the content preferred size. + bool is_autosized() const { return is_autosized_; } + diff --git a/patches/chromium/fix_put_nsvisualeffectview_before_viewscompositorsuperview.patch b/patches/chromium/fix_put_nsvisualeffectview_before_viewscompositorsuperview.patch new file mode 100644 index 0000000000..d7e0977944 --- /dev/null +++ b/patches/chromium/fix_put_nsvisualeffectview_before_viewscompositorsuperview.patch @@ -0,0 +1,36 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20Pichli=C5=84ski?= + <[email protected]> +Date: Tue, 29 Oct 2024 21:16:29 +0100 +Subject: fix: Put NSVisualEffectView before ViewsCompositorSuperview + +Upstreamed at https://chromium-review.googlesource.com/c/chromium/src/+/6030552 + +Otherwise when using `vibrancy` in `BrowserWindow` NSVisualEffectView +will hide content displayed by the compositor. + +diff --git a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm +index 07c3997e6565cf77362ee73959c4d21da4fefe96..3353a7847df90b58eec34ea4d6ff8fb19617f5cc 100644 +--- a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm ++++ b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm +@@ -223,8 +223,19 @@ NSComparisonResult SubviewSorter(__kindof NSView* lhs, + void* rank_as_void) { + DCHECK_NE(lhs, rhs); + +- if ([lhs isKindOfClass:[ViewsCompositorSuperview class]]) ++ ++ // Put NSVisualEffectView before ViewsCompositorSuperview otherwise when using ++ // `vibrancy` in `BrowserWindow` NSVisualEffectView will hide content ++ // displayed by the compositor. ++ if ([lhs isKindOfClass:[NSVisualEffectView class]]) { + return NSOrderedAscending; ++ } ++ if ([lhs isKindOfClass:[ViewsCompositorSuperview class]]) { ++ if ([rhs isKindOfClass:[NSVisualEffectView class]]) { ++ return NSOrderedDescending; ++ } ++ return NSOrderedAscending; ++ } + + const RankMap* rank = static_cast<const RankMap*>(rank_as_void); + auto left_rank = rank->find(lhs); diff --git a/shell/browser/api/electron_api_web_contents_view.cc b/shell/browser/api/electron_api_web_contents_view.cc index 644ea373a7..f76209fbdf 100644 --- a/shell/browser/api/electron_api_web_contents_view.cc +++ b/shell/browser/api/electron_api_web_contents_view.cc @@ -27,29 +27,14 @@ #include "ui/views/view_class_properties.h" #include "ui/views/widget/widget.h" -#if BUILDFLAG(IS_MAC) -#include "shell/browser/ui/cocoa/delayed_native_view_host.h" -#endif - namespace electron::api { WebContentsView::WebContentsView(v8::Isolate* isolate, gin::Handle<WebContents> web_contents) -#if BUILDFLAG(IS_MAC) - : View(new DelayedNativeViewHost(web_contents->inspectable_web_contents() - ->GetView() - ->GetNativeView())), -#else - : View(web_contents->inspectable_web_contents()->GetView()->GetView()), -#endif + : View(web_contents->inspectable_web_contents()->GetView()), web_contents_(isolate, web_contents.ToV8()), api_web_contents_(web_contents.get()) { -#if !BUILDFLAG(IS_MAC) - // On macOS the View is a newly-created |DelayedNativeViewHost| and it is our - // responsibility to delete it. On other platforms the View is created and - // managed by InspectableWebContents. set_delete_view(false); -#endif view()->SetProperty( views::kFlexBehaviorKey, views::FlexSpecification(views::MinimumFlexSizeRule::kScaleToMinimum, diff --git a/shell/browser/native_window_mac.h b/shell/browser/native_window_mac.h index d153dec7f8..c49cdc9635 100644 --- a/shell/browser/native_window_mac.h +++ b/shell/browser/native_window_mac.h @@ -169,9 +169,6 @@ class NativeWindowMac : public NativeWindow, void NotifyWindowDidFailToEnterFullScreen(); void NotifyWindowWillLeaveFullScreen(); - // views::WidgetDelegate: - views::View* GetContentsView() override; - // Cleanup observers when window is getting closed. Note that the destructor // can be called much later after window gets closed, so we should not do // cleanup in destructor. @@ -223,6 +220,7 @@ class NativeWindowMac : public NativeWindow, protected: // views::WidgetDelegate: + views::View* GetContentsView() override; bool CanMaximize() const override; std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView( views::Widget* widget) override; diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index dc483ee3fd..2acea04280 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -194,6 +194,8 @@ NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options, params.bounds = bounds; params.delegate = this; params.type = views::Widget::InitParams::TYPE_WINDOW; + // Allow painting before shown, to be later disabled in ElectronNSWindow. + params.headless_mode = true; params.native_widget = new ElectronNativeWidgetMac(this, windowType, styleMask, widget()); widget()->Init(std::move(params)); @@ -1674,6 +1676,7 @@ void NativeWindowMac::Cleanup() { DCHECK(!IsClosed()); ui::NativeTheme::GetInstanceForNativeUi()->RemoveObserver(this); display::Screen::GetScreen()->RemoveObserver(this); + [window_ cleanup]; } class NativeAppWindowFrameViewMac : public views::NativeFrameViewMac { diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 1f6c3957c4..d5118ec346 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -27,6 +27,7 @@ #include "content/public/browser/desktop_media_id.h" #include "content/public/common/color_parser.h" #include "shell/browser/api/electron_api_web_contents.h" +#include "shell/browser/ui/inspectable_web_contents_view.h" #include "shell/browser/ui/views/root_view.h" #include "shell/browser/web_contents_preferences.h" #include "shell/browser/web_view_manager.h" diff --git a/shell/browser/ui/cocoa/delayed_native_view_host.h b/shell/browser/ui/cocoa/delayed_native_view_host.h deleted file mode 100644 index e7020dba60..0000000000 --- a/shell/browser/ui/cocoa/delayed_native_view_host.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) 2018 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#ifndef ELECTRON_SHELL_BROWSER_UI_COCOA_DELAYED_NATIVE_VIEW_HOST_H_ -#define ELECTRON_SHELL_BROWSER_UI_COCOA_DELAYED_NATIVE_VIEW_HOST_H_ - -#include "ui/views/controls/native/native_view_host.h" - -namespace electron { - -// Automatically attach the native view after the NativeViewHost is attached to -// a widget. (Attaching it directly would cause crash.) -class DelayedNativeViewHost : public views::NativeViewHost { - public: - explicit DelayedNativeViewHost(gfx::NativeView native_view); - ~DelayedNativeViewHost() override; - - // disable copy - DelayedNativeViewHost(const DelayedNativeViewHost&) = delete; - DelayedNativeViewHost& operator=(const DelayedNativeViewHost&) = delete; - - // views::View: - void ViewHierarchyChanged( - const views::ViewHierarchyChangedDetails& details) override; - - private: - gfx::NativeView native_view_; -}; - -} // namespace electron - -#endif // ELECTRON_SHELL_BROWSER_UI_COCOA_DELAYED_NATIVE_VIEW_HOST_H_ diff --git a/shell/browser/ui/cocoa/delayed_native_view_host.mm b/shell/browser/ui/cocoa/delayed_native_view_host.mm deleted file mode 100644 index 38b0796555..0000000000 --- a/shell/browser/ui/cocoa/delayed_native_view_host.mm +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2018 GitHub, Inc. -// Use of this source code is governed by the MIT license that can be -// found in the LICENSE file. - -#include "shell/browser/ui/cocoa/delayed_native_view_host.h" - -namespace electron { - -DelayedNativeViewHost::DelayedNativeViewHost(gfx::NativeView native_view) - : native_view_(native_view) {} - -DelayedNativeViewHost::~DelayedNativeViewHost() = default; - -void DelayedNativeViewHost::ViewHierarchyChanged( - const views::ViewHierarchyChangedDetails& details) { - if (!details.is_add && native_view()) - Detach(); - NativeViewHost::ViewHierarchyChanged(details); - if (details.is_add && GetWidget() && !native_view()) - Attach(native_view_); -} - -} // namespace electron diff --git a/shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h b/shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h deleted file mode 100644 index 4286312573..0000000000 --- a/shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (c) 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-CHROMIUM file. - -#ifndef ELECTRON_SHELL_BROWSER_UI_COCOA_ELECTRON_INSPECTABLE_WEB_CONTENTS_VIEW_H_ -#define ELECTRON_SHELL_BROWSER_UI_COCOA_ELECTRON_INSPECTABLE_WEB_CONTENTS_VIEW_H_ - -#import <AppKit/AppKit.h> - -#include "base/apple/owned_objc.h" -#include "base/memory/raw_ptr.h" -#include "chrome/browser/devtools/devtools_contents_resizing_strategy.h" -#include "ui/base/cocoa/base_view.h" - -namespace electron { -class InspectableWebContentsViewMac; -} - -using electron::InspectableWebContentsViewMac; - -@interface NSView (WebContentsView) -- (void)setMouseDownCanMoveWindow:(BOOL)can_move; -@end - -@interface ElectronInspectableWebContentsView : BaseView <NSWindowDelegate> { - @private - raw_ptr<electron::InspectableWebContentsViewMac> inspectableWebContentsView_; - - NSView* __strong fake_view_; - NSWindow* __strong devtools_window_; - BOOL devtools_visible_; - BOOL devtools_docked_; - BOOL devtools_is_first_responder_; - BOOL attached_to_window_; - - DevToolsContentsResizingStrategy strategy_; -} - -- (instancetype)initWithInspectableWebContentsViewMac: - (InspectableWebContentsViewMac*)view; -- (void)notifyDevToolsFocused; -- (void)setCornerRadii:(CGFloat)cornerRadius; -- (void)setDevToolsVisible:(BOOL)visible activate:(BOOL)activate; -- (BOOL)isDevToolsVisible; -- (BOOL)isDevToolsFocused; -- (void)setIsDocked:(BOOL)docked activate:(BOOL)activate; -- (void)setContentsResizingStrategy: - (const DevToolsContentsResizingStrategy&)strategy; -- (void)setTitle:(NSString*)title; -- (NSString*)getTitle; - -@end - -#endif // ELECTRON_SHELL_BROWSER_UI_COCOA_ELECTRON_INSPECTABLE_WEB_CONTENTS_VIEW_H_ diff --git a/shell/browser/ui/cocoa/electron_inspectable_web_contents_view.mm b/shell/browser/ui/cocoa/electron_inspectable_web_contents_view.mm deleted file mode 100644 index d719fc164e..0000000000 --- a/shell/browser/ui/cocoa/electron_inspectable_web_contents_view.mm +++ /dev/null @@ -1,337 +0,0 @@ -// Copyright (c) 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-CHROMIUM file. - -#include "shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h" - -#include "content/public/browser/render_widget_host_view.h" -#include "shell/browser/api/electron_api_web_contents.h" -#include "shell/browser/ui/cocoa/event_dispatching_window.h" -#include "shell/browser/ui/inspectable_web_contents.h" -#include "shell/browser/ui/inspectable_web_contents_view_delegate.h" -#include "shell/browser/ui/inspectable_web_contents_view_mac.h" -#include "ui/base/cocoa/base_view.h" -#include "ui/gfx/mac/scoped_cocoa_disable_screen_updates.h" - -@implementation ElectronInspectableWebContentsView - -- (instancetype)initWithInspectableWebContentsViewMac: - (InspectableWebContentsViewMac*)view { - self = [super init]; - if (!self) - return nil; - - inspectableWebContentsView_ = view; - devtools_visible_ = NO; - devtools_docked_ = NO; - devtools_is_first_responder_ = NO; - attached_to_window_ = NO; - - if (inspectableWebContentsView_->inspectable_web_contents()->is_guest()) { - fake_view_ = [[NSView alloc] init]; - [fake_view_ setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; - [self addSubview:fake_view_]; - } else { - auto* contents = inspectableWebContentsView_->inspectable_web_contents() - ->GetWebContents(); - auto* contentsView = contents->GetNativeView().GetNativeNSView(); - [contentsView setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; - [self addSubview:contentsView]; - } - - // See https://code.google.com/p/chromium/issues/detail?id=348490. - [self setWantsLayer:YES]; - - return self; -} - -- (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -- (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { - [self adjustSubviews]; -} - -- (void)viewDidMoveToWindow { - if (attached_to_window_ && !self.window) { - attached_to_window_ = NO; - [[NSNotificationCenter defaultCenter] removeObserver:self]; - } else if (!attached_to_window_ && self.window) { - attached_to_window_ = YES; - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(viewDidBecomeFirstResponder:) - name:kViewDidBecomeFirstResponder - object:nil]; - [[NSNotificationCenter defaultCenter] - addObserver:self - selector:@selector(parentWindowBecameMain:) - name:NSWindowDidBecomeMainNotification - object:nil]; - } -} - -- (IBAction)showDevTools:(id)sender { - inspectableWebContentsView_->inspectable_web_contents()->ShowDevTools(true); -} - -- (void)notifyDevToolsFocused { - if (inspectableWebContentsView_->GetDelegate()) - inspectableWebContentsView_->GetDelegate()->DevToolsFocused(); -} - -- (void)setCornerRadii:(CGFloat)cornerRadius { - auto* inspectable_web_contents = - inspectableWebContentsView_->inspectable_web_contents(); - DCHECK(inspectable_web_contents); - auto* webContents = inspectable_web_contents->GetWebContents(); - if (!webContents) - return; - auto* webContentsView = webContents->GetNativeView().GetNativeNSView(); - webContentsView.wantsLayer = YES; - webContentsView.layer.cornerRadius = cornerRadius; -} - -- (void)notifyDevToolsResized { - // When devtools is opened, resizing devtools would not trigger - // UpdateDraggableRegions for WebContents, so we have to notify the window - // to do an update of draggable regions. - if (inspectableWebContentsView_->GetDelegate()) - inspectableWebContentsView_->GetDelegate()->DevToolsResized(); -} - -- (void)setDevToolsVisible:(BOOL)visible activate:(BOOL)activate { - if (visible == devtools_visible_) - return; - - auto* inspectable_web_contents = - inspectableWebContentsView_->inspectable_web_contents(); - auto* devToolsWebContents = - inspectable_web_contents->GetDevToolsWebContents(); - auto* devToolsView = devToolsWebContents->GetNativeView().GetNativeNSView(); - - devtools_visible_ = visible; - if (devtools_docked_) { - if (visible) { - // Place the devToolsView under contentsView, notice that we didn't set - // sizes for them until the setContentsResizingStrategy message. - [self addSubview:devToolsView positioned:NSWindowBelow relativeTo:nil]; - [self adjustSubviews]; - - // Focus on web view. - devToolsWebContents->RestoreFocus(); - } else { - gfx::ScopedCocoaDisableScreenUpdates disabler; - [devToolsView removeFromSuperview]; - [self adjustSubviews]; - [self notifyDevToolsResized]; - } - } else { - if (visible) { - if (activate) { - [devtools_window_ makeKeyAndOrderFront:nil]; - } else { - [devtools_window_ orderBack:nil]; - } - } else { - [devtools_window_ setDelegate:nil]; - [devtools_window_ close]; - devtools_window_ = nil; - } - } -} - -- (BOOL)isDevToolsVisible { - return devtools_visible_; -} - -- (BOOL)isDevToolsFocused { - if (devtools_docked_) { - return [[self window] isKeyWindow] && devtools_is_first_responder_; - } else { - return [devtools_window_ isKeyWindow]; - } -} - -// TODO: remove NSWindowStyleMaskTexturedBackground. -// https://github.com/electron/electron/issues/43125 -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - -- (void)setIsDocked:(BOOL)docked activate:(BOOL)activate { - // Revert to no-devtools state. - [self setDevToolsVisible:NO activate:NO]; - - // Switch to new state. - devtools_docked_ = docked; - auto* inspectable_web_contents = - inspectableWebContentsView_->inspectable_web_contents(); - auto* devToolsWebContents = - inspectable_web_contents->GetDevToolsWebContents(); - auto devToolsView = devToolsWebContents->GetNativeView().GetNativeNSView(); - if (!docked) { - auto styleMask = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | - NSWindowStyleMaskMiniaturizable | - NSWindowStyleMaskResizable | - NSWindowStyleMaskTexturedBackground | - NSWindowStyleMaskUnifiedTitleAndToolbar; - devtools_window_ = [[EventDispatchingWindow alloc] - initWithContentRect:NSMakeRect(0, 0, 800, 600) - styleMask:styleMask - backing:NSBackingStoreBuffered - defer:YES]; - [devtools_window_ setDelegate:self]; - [devtools_window_ setFrameAutosaveName:@"electron.devtools"]; - [devtools_window_ setTitle:@"Developer Tools"]; - [devtools_window_ setReleasedWhenClosed:NO]; - [devtools_window_ setAutorecalculatesContentBorderThickness:NO - forEdge:NSMaxYEdge]; - [devtools_window_ setContentBorderThickness:24 forEdge:NSMaxYEdge]; - - NSView* contentView = [devtools_window_ contentView]; - devToolsView.frame = contentView.bounds; - devToolsView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; - - [contentView addSubview:devToolsView]; - [devToolsView setMouseDownCanMoveWindow:NO]; - } else { - [devToolsView setMouseDownCanMoveWindow:YES]; - } - [self setDevToolsVisible:YES activate:activate]; -} - -// -Wdeprecated-declarations -#pragma clang diagnostic pop - -- (void)setContentsResizingStrategy: - (const DevToolsContentsResizingStrategy&)strategy { - strategy_.CopyFrom(strategy); - [self adjustSubviews]; -} - -- (void)adjustSubviews { - if (![[self subviews] count]) - return; - - if (![self isDevToolsVisible] || devtools_window_) { - DCHECK_EQ(1u, [[self subviews] count]); - NSView* contents = [[self subviews] objectAtIndex:0]; - [contents setFrame:[self bounds]]; - return; - } - - NSView* devToolsView = [[self subviews] objectAtIndex:0]; - NSView* contentsView = [[self subviews] objectAtIndex:1]; - - DCHECK_EQ(2u, [[self subviews] count]); - - gfx::Rect new_devtools_bounds; - gfx::Rect new_contents_bounds; - ApplyDevToolsContentsResizingStrategy( - strategy_, gfx::Size(NSSizeToCGSize([self bounds].size)), - &new_devtools_bounds, &new_contents_bounds); - [devToolsView setFrame:[self flipRectToNSRect:new_devtools_bounds]]; - [contentsView setFrame:[self flipRectToNSRect:new_contents_bounds]]; - - // Move mask to the devtools area to exclude it from dragging. - NSRect cf = contentsView.frame; - NSRect sb = [self bounds]; - NSRect devtools_frame; - if (cf.size.height < sb.size.height) { // bottom docked - devtools_frame.origin.x = 0; - devtools_frame.origin.y = 0; - devtools_frame.size.width = sb.size.width; - devtools_frame.size.height = sb.size.height - cf.size.height; - } else { // left or right docked - if (cf.origin.x > 0) // left docked - devtools_frame.origin.x = 0; - else // right docked. - devtools_frame.origin.x = cf.size.width; - devtools_frame.origin.y = 0; - devtools_frame.size.width = sb.size.width - cf.size.width; - devtools_frame.size.height = sb.size.height; - } - - [self notifyDevToolsResized]; -} - -- (void)setTitle:(NSString*)title { - [devtools_window_ setTitle:title]; -} - -- (NSString*)getTitle { - return [devtools_window_ title]; -} - -- (void)viewDidBecomeFirstResponder:(NSNotification*)notification { - auto* inspectable_web_contents = - inspectableWebContentsView_->inspectable_web_contents(); - DCHECK(inspectable_web_contents); - auto* webContents = inspectable_web_contents->GetWebContents(); - if (!webContents) - return; - auto* webContentsView = webContents->GetNativeView().GetNativeNSView(); - - NSView* view = [notification object]; - if ([[webContentsView subviews] containsObject:view]) { - devtools_is_first_responder_ = NO; - return; - } - - auto* devToolsWebContents = - inspectable_web_contents->GetDevToolsWebContents(); - if (!devToolsWebContents) - return; - auto devToolsView = devToolsWebContents->GetNativeView().GetNativeNSView(); - - if ([[devToolsView subviews] containsObject:view]) { - devtools_is_first_responder_ = YES; - [self notifyDevToolsFocused]; - } -} - -- (void)parentWindowBecameMain:(NSNotification*)notification { - NSWindow* parentWindow = [notification object]; - if ([self window] == parentWindow && devtools_docked_ && - devtools_is_first_responder_) - [self notifyDevToolsFocused]; -} - -#pragma mark - NSWindowDelegate - -- (void)windowWillClose:(NSNotification*)notification { - inspectableWebContentsView_->inspectable_web_contents()->CloseDevTools(); -} - -- (void)windowDidBecomeMain:(NSNotification*)notification { - content::WebContents* web_contents = - inspectableWebContentsView_->inspectable_web_contents() - ->GetDevToolsWebContents(); - if (!web_contents) - return; - - web_contents->RestoreFocus(); - - content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView(); - if (rwhv) - rwhv->SetActive(true); - - [self notifyDevToolsFocused]; -} - -- (void)windowDidResignMain:(NSNotification*)notification { - content::WebContents* web_contents = - inspectableWebContentsView_->inspectable_web_contents() - ->GetDevToolsWebContents(); - if (!web_contents) - return; - - web_contents->StoreFocus(); - - content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView(); - if (rwhv) - rwhv->SetActive(false); -} - -@end diff --git a/shell/browser/ui/cocoa/electron_ns_window.h b/shell/browser/ui/cocoa/electron_ns_window.h index 502592313c..63ea535546 100644 --- a/shell/browser/ui/cocoa/electron_ns_window.h +++ b/shell/browser/ui/cocoa/electron_ns_window.h @@ -29,6 +29,8 @@ class ScopedDisableResize { } // namespace electron +class ElectronNativeWindowObserver; + @interface ElectronNSWindow : NativeWidgetMacNSWindow { @private raw_ptr<electron::NativeWindowMac> shell_; @@ -41,6 +43,7 @@ class ScopedDisableResize { @property(nonatomic, retain) NSImage* cornerMask; - (id)initWithShell:(electron::NativeWindowMac*)shell styleMask:(NSUInteger)styleMask; +- (void)cleanup; - (electron::NativeWindowMac*)shell; - (id)accessibilityFocusedUIElement; - (NSRect)originalContentRectForFrameRect:(NSRect)frameRect; diff --git a/shell/browser/ui/cocoa/electron_ns_window.mm b/shell/browser/ui/cocoa/electron_ns_window.mm index 5c5f1512f4..30780277d3 100644 --- a/shell/browser/ui/cocoa/electron_ns_window.mm +++ b/shell/browser/ui/cocoa/electron_ns_window.mm @@ -8,8 +8,6 @@ #include "electron/mas.h" #include "shell/browser/api/electron_api_web_contents.h" #include "shell/browser/native_window_mac.h" -#include "shell/browser/ui/cocoa/delayed_native_view_host.h" -#include "shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h" #include "shell/browser/ui/cocoa/electron_preview_item.h" #include "shell/browser/ui/cocoa/electron_touch_bar.h" #include "shell/browser/ui/cocoa/root_view_mac.h" @@ -113,6 +111,7 @@ void SwizzleSwipeWithEvent(NSView* view, SEL swiz_selector) { method_getImplementation(new_swipe_with_event)); } #endif + } // namespace @implementation ElectronNSWindow @@ -168,6 +167,10 @@ void SwizzleSwipeWithEvent(NSView* view, SEL swiz_selector) { return self; } +- (void)cleanup { + shell_ = nullptr; +} + - (electron::NativeWindowMac*)shell { return shell_; } @@ -255,6 +258,17 @@ void SwizzleSwipeWithEvent(NSView* view, SEL swiz_selector) { [super setFrame:windowFrame display:displayViews]; } +- (void)orderWindow:(NSWindowOrderingMode)place relativeTo:(NSInteger)otherWin { + if (shell_) { + // We initialize the window in headless mode to allow painting before it is + // shown, but we don't want the headless behavior of allowing the window to + // be placed unconstrained. + self.isHeadless = false; + shell_->widget()->DisableHeadlessMode(); + } + [super orderWindow:place relativeTo:otherWin]; +} + - (id)accessibilityAttributeValue:(NSString*)attribute { if ([attribute isEqual:NSAccessibilityEnabledAttribute]) return [NSNumber numberWithBool:YES]; diff --git a/shell/browser/ui/cocoa/electron_ns_window_delegate.mm b/shell/browser/ui/cocoa/electron_ns_window_delegate.mm index d6af0ac6d9..3f7c689bfc 100644 --- a/shell/browser/ui/cocoa/electron_ns_window_delegate.mm +++ b/shell/browser/ui/cocoa/electron_ns_window_delegate.mm @@ -365,6 +365,19 @@ using FullScreenTransitionState = shell_->GetNativeWindow()); auto* bridged_view = bridge_host->GetInProcessNSWindowBridge(); bridged_view->OnWindowWillClose(); + + // Native widget and its compositor have been destroyed upon close. We need + // to detach contents view in order to prevent reusing its layer without + // compositor in the `WebContentsViewMac::CreateViewForWidget`, leading to + // `DCHECK` failure in `BrowserCompositorMac::SetParentUiLayer`. + auto* contents_view = + static_cast<views::WidgetDelegate*>(shell_)->GetContentsView(); + if (contents_view) { + auto* parent = contents_view->parent(); + if (parent) { + parent->RemoveChildView(contents_view); + } + } } - (BOOL)windowShouldClose:(id)window { diff --git a/shell/browser/ui/inspectable_web_contents.cc b/shell/browser/ui/inspectable_web_contents.cc index ea02168ef5..75ebdd6441 100644 --- a/shell/browser/ui/inspectable_web_contents.cc +++ b/shell/browser/ui/inspectable_web_contents.cc @@ -297,11 +297,6 @@ class InspectableWebContents::NetworkResourceLoader base::TimeDelta retry_delay_; }; -// Implemented separately on each platform. -InspectableWebContentsView* CreateInspectableContentsView( - InspectableWebContents* inspectable_web_contents); - -// static // static void InspectableWebContents::RegisterPrefs(PrefRegistrySimple* registry) { registry->RegisterDictionaryPref(kDevToolsBoundsPref, @@ -317,7 +312,7 @@ InspectableWebContents::InspectableWebContents( : pref_service_(pref_service), web_contents_(std::move(web_contents)), is_guest_(is_guest), - view_(CreateInspectableContentsView(this)) { + view_(new InspectableWebContentsView(this)) { const base::Value* bounds_dict = &pref_service_->GetValue(kDevToolsBoundsPref); if (bounds_dict->is_dict()) { diff --git a/shell/browser/ui/inspectable_web_contents_view.cc b/shell/browser/ui/inspectable_web_contents_view.cc index 946b5071bc..e61f008414 100644 --- a/shell/browser/ui/inspectable_web_contents_view.cc +++ b/shell/browser/ui/inspectable_web_contents_view.cc @@ -5,12 +5,250 @@ #include "shell/browser/ui/inspectable_web_contents_view.h" +#include <memory> +#include <utility> + +#include "base/memory/raw_ptr.h" +#include "base/strings/utf_string_conversions.h" +#include "shell/browser/ui/drag_util.h" +#include "shell/browser/ui/inspectable_web_contents.h" +#include "shell/browser/ui/inspectable_web_contents_delegate.h" +#include "shell/browser/ui/inspectable_web_contents_view_delegate.h" +#include "ui/base/models/image_model.h" +#include "ui/views/controls/label.h" +#include "ui/views/controls/webview/webview.h" +#include "ui/views/widget/widget.h" +#include "ui/views/widget/widget_delegate.h" +#include "ui/views/window/client_view.h" + namespace electron { +namespace { + +class DevToolsWindowDelegate : public views::ClientView, + public views::WidgetDelegate { + public: + DevToolsWindowDelegate(InspectableWebContentsView* shell, + views::View* view, + views::Widget* widget) + : views::ClientView(widget, view), + shell_(shell), + view_(view), + widget_(widget) { + SetOwnedByWidget(true); + set_owned_by_client(); + + if (shell->GetDelegate()) + icon_ = shell->GetDelegate()->GetDevToolsWindowIcon(); + } + ~DevToolsWindowDelegate() override = default; + + // disable copy + DevToolsWindowDelegate(const DevToolsWindowDelegate&) = delete; + DevToolsWindowDelegate& operator=(const DevToolsWindowDelegate&) = delete; + + // views::WidgetDelegate: + views::View* GetInitiallyFocusedView() override { return view_; } + std::u16string GetWindowTitle() const override { return shell_->GetTitle(); } + ui::ImageModel GetWindowAppIcon() override { return GetWindowIcon(); } + ui::ImageModel GetWindowIcon() override { return icon_; } + views::Widget* GetWidget() override { return widget_; } + const views::Widget* GetWidget() const override { return widget_; } + views::View* GetContentsView() override { return view_; } + views::ClientView* CreateClientView(views::Widget* widget) override { + return this; + } + + // views::ClientView: + views::CloseRequestResult OnWindowCloseRequested() override { + shell_->inspectable_web_contents()->CloseDevTools(); + return views::CloseRequestResult::kCannotClose; + } + + private: + raw_ptr<InspectableWebContentsView> shell_; + raw_ptr<views::View> view_; + raw_ptr<views::Widget> widget_; + ui::ImageModel icon_; +}; + +} // namespace + InspectableWebContentsView::InspectableWebContentsView( InspectableWebContents* inspectable_web_contents) - : inspectable_web_contents_(inspectable_web_contents) {} + : inspectable_web_contents_(inspectable_web_contents), + devtools_web_view_(new views::WebView(nullptr)), + title_(u"Developer Tools") { + if (!inspectable_web_contents_->is_guest() && + inspectable_web_contents_->GetWebContents()->GetNativeView()) { + auto* contents_web_view = new views::WebView(nullptr); + contents_web_view->SetWebContents( + inspectable_web_contents_->GetWebContents()); + contents_web_view_ = contents_web_view; + } else { + no_contents_view_ = new views::Label(u"No content under offscreen mode"); + } + + devtools_web_view_->SetVisible(false); + AddChildView(devtools_web_view_.get()); + AddChildView(GetContentsView()); +} + +InspectableWebContentsView::~InspectableWebContentsView() { + if (devtools_window_) + inspectable_web_contents()->SaveDevToolsBounds( + devtools_window_->GetWindowBoundsInScreen()); +} + +void InspectableWebContentsView::SetCornerRadii( + const gfx::RoundedCornersF& corner_radii) { + // WebView won't exist for offscreen rendering. + if (contents_web_view_) { + contents_web_view_->holder()->SetCornerRadii(corner_radii); + } +} + +void InspectableWebContentsView::ShowDevTools(bool activate) { + if (devtools_visible_) + return; + + devtools_visible_ = true; + if (devtools_window_) { + devtools_window_web_view_->SetWebContents( + inspectable_web_contents_->GetDevToolsWebContents()); + devtools_window_->SetBounds(inspectable_web_contents()->dev_tools_bounds()); + if (activate) { + devtools_window_->Show(); + } else { + devtools_window_->ShowInactive(); + } + + // Update draggable regions to account for the new dock position. + if (GetDelegate()) + GetDelegate()->DevToolsResized(); + } else { + devtools_web_view_->SetVisible(true); + devtools_web_view_->SetWebContents( + inspectable_web_contents_->GetDevToolsWebContents()); + devtools_web_view_->RequestFocus(); + DeprecatedLayoutImmediately(); + } +} + +void InspectableWebContentsView::CloseDevTools() { + if (!devtools_visible_) + return; + + devtools_visible_ = false; + if (devtools_window_) { + auto save_bounds = devtools_window_->IsMinimized() + ? devtools_window_->GetRestoredBounds() + : devtools_window_->GetWindowBoundsInScreen(); + inspectable_web_contents()->SaveDevToolsBounds(save_bounds); + + devtools_window_.reset(); + devtools_window_web_view_ = nullptr; + devtools_window_delegate_ = nullptr; + } else { + devtools_web_view_->SetVisible(false); + devtools_web_view_->SetWebContents(nullptr); + DeprecatedLayoutImmediately(); + } +} + +bool InspectableWebContentsView::IsDevToolsViewShowing() { + return devtools_visible_; +} + +bool InspectableWebContentsView::IsDevToolsViewFocused() { + if (devtools_window_web_view_) + return devtools_window_web_view_->HasFocus(); + else if (devtools_web_view_) + return devtools_web_view_->HasFocus(); + else + return false; +} + +void InspectableWebContentsView::SetIsDocked(bool docked, bool activate) { + CloseDevTools(); + + if (!docked) { + devtools_window_ = std::make_unique<views::Widget>(); + devtools_window_web_view_ = new views::WebView(nullptr); + devtools_window_delegate_ = new DevToolsWindowDelegate( + this, devtools_window_web_view_, devtools_window_.get()); + + views::Widget::InitParams params( + views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET, + views::Widget::InitParams::TYPE_WINDOW); + params.delegate = devtools_window_delegate_; + params.bounds = inspectable_web_contents()->dev_tools_bounds(); + +#if BUILDFLAG(IS_LINUX) + params.wm_role_name = "devtools"; + if (GetDelegate()) + GetDelegate()->GetDevToolsWindowWMClass(&params.wm_class_name, + &params.wm_class_class); +#endif + + devtools_window_->Init(std::move(params)); + devtools_window_->UpdateWindowIcon(); + devtools_window_->widget_delegate()->SetHasWindowSizeControls(true); + } + + ShowDevTools(activate); +} + +void InspectableWebContentsView::SetContentsResizingStrategy( + const DevToolsContentsResizingStrategy& strategy) { + strategy_.CopyFrom(strategy); + DeprecatedLayoutImmediately(); +} + +void InspectableWebContentsView::SetTitle(const std::u16string& title) { + if (devtools_window_) { + title_ = title; + devtools_window_->UpdateWindowTitle(); + } +} + +const std::u16string InspectableWebContentsView::GetTitle() { + return title_; +} + +void InspectableWebContentsView::Layout(PassKey) { + if (!devtools_web_view_->GetVisible()) { + GetContentsView()->SetBoundsRect(GetContentsBounds()); + // Propagate layout call to all children, for example browser views. + LayoutSuperclass<View>(this); + return; + } + + gfx::Size container_size(width(), height()); + gfx::Rect new_devtools_bounds; + gfx::Rect new_contents_bounds; + ApplyDevToolsContentsResizingStrategy( + strategy_, container_size, &new_devtools_bounds, &new_contents_bounds); + + // DevTools cares about the specific position, so we have to compensate RTL + // layout here. + new_devtools_bounds.set_x(GetMirroredXForRect(new_devtools_bounds)); + new_contents_bounds.set_x(GetMirroredXForRect(new_contents_bounds)); + + devtools_web_view_->SetBoundsRect(new_devtools_bounds); + GetContentsView()->SetBoundsRect(new_contents_bounds); + + // Propagate layout call to all children, for example browser views. + LayoutSuperclass<View>(this); + + if (GetDelegate()) + GetDelegate()->DevToolsResized(); +} + +views::View* InspectableWebContentsView::GetContentsView() const { + DCHECK(contents_web_view_ || no_contents_view_); -InspectableWebContentsView::~InspectableWebContentsView() = default; + return contents_web_view_ ? contents_web_view_ : no_contents_view_; +} } // namespace electron diff --git a/shell/browser/ui/inspectable_web_contents_view.h b/shell/browser/ui/inspectable_web_contents_view.h index a9c95d477e..282d3bf805 100644 --- a/shell/browser/ui/inspectable_web_contents_view.h +++ b/shell/browser/ui/inspectable_web_contents_view.h @@ -9,13 +9,9 @@ #include <string> #include "base/memory/raw_ptr.h" -#include "build/build_config.h" - -#if defined(TOOLKIT_VIEWS) && !BUILDFLAG(IS_MAC) -#include "ui/views/view.h" -#else +#include "chrome/browser/devtools/devtools_contents_resizing_strategy.h" #include "ui/gfx/native_widget_types.h" -#endif +#include "ui/views/view.h" class DevToolsContentsResizingStrategy; @@ -23,23 +19,22 @@ namespace gfx { class RoundedCornersF; } // namespace gfx -#if defined(TOOLKIT_VIEWS) namespace views { -class View; class WebView; +class Widget; +class WidgetDelegate; } // namespace views -#endif namespace electron { class InspectableWebContents; class InspectableWebContentsViewDelegate; -class InspectableWebContentsView { +class InspectableWebContentsView : public views::View { public: explicit InspectableWebContentsView( InspectableWebContents* inspectable_web_contents); - virtual ~InspectableWebContentsView(); + ~InspectableWebContentsView() override; InspectableWebContents* inspectable_web_contents() { return inspectable_web_contents_; @@ -51,32 +46,40 @@ class InspectableWebContentsView { } InspectableWebContentsViewDelegate* GetDelegate() const { return delegate_; } -#if defined(TOOLKIT_VIEWS) && !BUILDFLAG(IS_MAC) - // Returns the container control, which has devtools view attached. - virtual views::View* GetView() = 0; -#else - virtual gfx::NativeView GetNativeView() const = 0; -#endif - - virtual void ShowDevTools(bool activate) = 0; - virtual void SetCornerRadii(const gfx::RoundedCornersF& corner_radii) = 0; - // Hide the DevTools view. - virtual void CloseDevTools() = 0; - virtual bool IsDevToolsViewShowing() = 0; - virtual bool IsDevToolsViewFocused() = 0; - virtual void SetIsDocked(bool docked, bool activate) = 0; - virtual void SetContentsResizingStrategy( - const DevToolsContentsResizingStrategy& strategy) = 0; - virtual void SetTitle(const std::u16string& title) = 0; - virtual const std::u16string GetTitle() = 0; - - protected: + void SetCornerRadii(const gfx::RoundedCornersF& corner_radii); + + void ShowDevTools(bool activate); + void CloseDevTools(); + bool IsDevToolsViewShowing(); + bool IsDevToolsViewFocused(); + void SetIsDocked(bool docked, bool activate); + void SetContentsResizingStrategy( + const DevToolsContentsResizingStrategy& strategy); + void SetTitle(const std::u16string& title); + const std::u16string GetTitle(); + + // views::View: + void Layout(PassKey) override; + + private: + views::View* GetContentsView() const; + // Owns us. raw_ptr<InspectableWebContents> inspectable_web_contents_; - private: raw_ptr<InspectableWebContentsViewDelegate> delegate_ = nullptr; // weak references. + + std::unique_ptr<views::Widget> devtools_window_; + raw_ptr<views::WebView> devtools_window_web_view_ = nullptr; + raw_ptr<views::WebView> contents_web_view_ = nullptr; + raw_ptr<views::View> no_contents_view_ = nullptr; + raw_ptr<views::WebView> devtools_web_view_ = nullptr; + + DevToolsContentsResizingStrategy strategy_; + bool devtools_visible_ = false; + raw_ptr<views::WidgetDelegate> devtools_window_delegate_ = nullptr; + std::u16string title_; }; } // namespace electron diff --git a/shell/browser/ui/inspectable_web_contents_view_mac.h b/shell/browser/ui/inspectable_web_contents_view_mac.h deleted file mode 100644 index 88b4078614..0000000000 --- a/shell/browser/ui/inspectable_web_contents_view_mac.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Copyright (c) 2013 Adam Roben <[email protected]>. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-CHROMIUM file. - -#ifndef ELECTRON_SHELL_BROWSER_UI_INSPECTABLE_WEB_CONTENTS_VIEW_MAC_H_ -#define ELECTRON_SHELL_BROWSER_UI_INSPECTABLE_WEB_CONTENTS_VIEW_MAC_H_ - -#include "shell/browser/ui/inspectable_web_contents_view.h" - -@class ElectronInspectableWebContentsView; - -namespace electron { - -class InspectableWebContentsViewMac : public InspectableWebContentsView { - public: - explicit InspectableWebContentsViewMac( - InspectableWebContents* inspectable_web_contents); - InspectableWebContentsViewMac(const InspectableWebContentsViewMac&) = delete; - InspectableWebContentsViewMac& operator=( - const InspectableWebContentsViewMac&) = delete; - ~InspectableWebContentsViewMac() override; - - gfx::NativeView GetNativeView() const override; - void SetCornerRadii(const gfx::RoundedCornersF& corner_radii) override; - void ShowDevTools(bool activate) override; - void CloseDevTools() override; - bool IsDevToolsViewShowing() override; - bool IsDevToolsViewFocused() override; - void SetIsDocked(bool docked, bool activate) override; - void SetContentsResizingStrategy( - const DevToolsContentsResizingStrategy& strategy) override; - void SetTitle(const std::u16string& title) override; - const std::u16string GetTitle() override; - - private: - ElectronInspectableWebContentsView* __strong view_; -}; - -} // namespace electron - -#endif // ELECTRON_SHELL_BROWSER_UI_INSPECTABLE_WEB_CONTENTS_VIEW_MAC_H_ diff --git a/shell/browser/ui/inspectable_web_contents_view_mac.mm b/shell/browser/ui/inspectable_web_contents_view_mac.mm deleted file mode 100644 index a3789e09a8..0000000000 --- a/shell/browser/ui/inspectable_web_contents_view_mac.mm +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Copyright (c) 2013 Adam Roben <[email protected]>. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-CHROMIUM file. - -#include "shell/browser/ui/inspectable_web_contents_view_mac.h" - -#include "base/strings/sys_string_conversions.h" -#import "shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h" -#include "shell/browser/ui/inspectable_web_contents.h" -#include "shell/browser/ui/inspectable_web_contents_view_delegate.h" -#include "ui/gfx/geometry/rounded_corners_f.h" - -namespace electron { - -InspectableWebContentsView* CreateInspectableContentsView( - InspectableWebContents* inspectable_web_contents) { - return new InspectableWebContentsViewMac(inspectable_web_contents); -} - -InspectableWebContentsViewMac::InspectableWebContentsViewMac( - InspectableWebContents* inspectable_web_contents) - : InspectableWebContentsView(inspectable_web_contents), - view_([[ElectronInspectableWebContentsView alloc] - initWithInspectableWebContentsViewMac:this]) {} - -InspectableWebContentsViewMac::~InspectableWebContentsViewMac() { - [[NSNotificationCenter defaultCenter] removeObserver:view_]; - CloseDevTools(); -} - -gfx::NativeView InspectableWebContentsViewMac::GetNativeView() const { - return view_; -} - -void InspectableWebContentsViewMac::SetCornerRadii( - const gfx::RoundedCornersF& corner_radii) { - // We can assume all four values are identical. - [view_ setCornerRadii:corner_radii.upper_left()]; -} - -void InspectableWebContentsViewMac::ShowDevTools(bool activate) { - [view_ setDevToolsVisible:YES activate:activate]; -} - -void InspectableWebContentsViewMac::CloseDevTools() { - [view_ setDevToolsVisible:NO activate:NO]; -} - -bool InspectableWebContentsViewMac::IsDevToolsViewShowing() { - return [view_ isDevToolsVisible]; -} - -bool InspectableWebContentsViewMac::IsDevToolsViewFocused() { - return [view_ isDevToolsFocused]; -} - -void InspectableWebContentsViewMac::SetIsDocked(bool docked, bool activate) { - [view_ setIsDocked:docked activate:activate]; -} - -void InspectableWebContentsViewMac::SetContentsResizingStrategy( - const DevToolsContentsResizingStrategy& strategy) { - [view_ setContentsResizingStrategy:strategy]; -} - -void InspectableWebContentsViewMac::SetTitle(const std::u16string& title) { - [view_ setTitle:base::SysUTF16ToNSString(title)]; -} - -const std::u16string InspectableWebContentsViewMac::GetTitle() { - return base::SysNSStringToUTF16([view_ getTitle]); -} - -} // namespace electron diff --git a/shell/browser/ui/views/frameless_view.cc b/shell/browser/ui/views/frameless_view.cc index c963d17310..dcfed5ef69 100644 --- a/shell/browser/ui/views/frameless_view.cc +++ b/shell/browser/ui/views/frameless_view.cc @@ -5,6 +5,8 @@ #include "shell/browser/ui/views/frameless_view.h" #include "shell/browser/native_window_views.h" +#include "shell/browser/ui/inspectable_web_contents_view.h" +#include "ui/aura/window.h" #include "ui/base/hit_test.h" #include "ui/base/metadata/metadata_impl_macros.h" #include "ui/views/widget/widget.h" diff --git a/shell/browser/ui/views/inspectable_web_contents_view_views.cc b/shell/browser/ui/views/inspectable_web_contents_view_views.cc deleted file mode 100644 index 61a5b013ec..0000000000 --- a/shell/browser/ui/views/inspectable_web_contents_view_views.cc +++ /dev/null @@ -1,257 +0,0 @@ -// Copyright (c) 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-CHROMIUM file. - -#include "shell/browser/ui/views/inspectable_web_contents_view_views.h" - -#include <memory> -#include <utility> - -#include "base/memory/raw_ptr.h" -#include "shell/browser/ui/drag_util.h" -#include "shell/browser/ui/inspectable_web_contents.h" -#include "shell/browser/ui/inspectable_web_contents_delegate.h" -#include "shell/browser/ui/inspectable_web_contents_view_delegate.h" -#include "ui/base/models/image_model.h" -#include "ui/gfx/geometry/rounded_corners_f.h" -#include "ui/views/controls/label.h" -#include "ui/views/controls/webview/webview.h" -#include "ui/views/widget/widget.h" -#include "ui/views/widget/widget_delegate.h" -#include "ui/views/window/client_view.h" - -namespace electron { - -namespace { - -class DevToolsWindowDelegate : public views::ClientView, - public views::WidgetDelegate { - public: - DevToolsWindowDelegate(InspectableWebContentsViewViews* shell, - views::View* view, - views::Widget* widget) - : views::ClientView(widget, view), - shell_(shell), - view_(view), - widget_(widget) { - SetOwnedByWidget(true); - set_owned_by_client(); - - if (shell->GetDelegate()) - icon_ = shell->GetDelegate()->GetDevToolsWindowIcon(); - } - ~DevToolsWindowDelegate() override = default; - - // disable copy - DevToolsWindowDelegate(const DevToolsWindowDelegate&) = delete; - DevToolsWindowDelegate& operator=(const DevToolsWindowDelegate&) = delete; - - // views::WidgetDelegate: - views::View* GetInitiallyFocusedView() override { return view_; } - std::u16string GetWindowTitle() const override { return shell_->GetTitle(); } - ui::ImageModel GetWindowAppIcon() override { return GetWindowIcon(); } - ui::ImageModel GetWindowIcon() override { return icon_; } - views::Widget* GetWidget() override { return widget_; } - const views::Widget* GetWidget() const override { return widget_; } - views::View* GetContentsView() override { return view_; } - views::ClientView* CreateClientView(views::Widget* widget) override { - return this; - } - - // views::ClientView: - views::CloseRequestResult OnWindowCloseRequested() override { - shell_->inspectable_web_contents()->CloseDevTools(); - return views::CloseRequestResult::kCannotClose; - } - - private: - raw_ptr<InspectableWebContentsViewViews> shell_; - raw_ptr<views::View> view_; - raw_ptr<views::Widget> widget_; - ui::ImageModel icon_; -}; - -} // namespace - -InspectableWebContentsView* CreateInspectableContentsView( - InspectableWebContents* inspectable_web_contents) { - return new InspectableWebContentsViewViews(inspectable_web_contents); -} - -InspectableWebContentsViewViews::InspectableWebContentsViewViews( - InspectableWebContents* inspectable_web_contents) - : InspectableWebContentsView(inspectable_web_contents), - devtools_web_view_(new views::WebView(nullptr)), - title_(u"Developer Tools") { - if (!inspectable_web_contents_->is_guest() && - inspectable_web_contents_->GetWebContents()->GetNativeView()) { - auto* contents_web_view = new views::WebView(nullptr); - contents_web_view->SetWebContents( - inspectable_web_contents_->GetWebContents()); - contents_view_ = contents_web_view_ = contents_web_view; - } else { - contents_view_ = new views::Label(u"No content under offscreen mode"); - } - - devtools_web_view_->SetVisible(false); - AddChildView(devtools_web_view_.get()); - AddChildView(contents_view_.get()); -} - -InspectableWebContentsViewViews::~InspectableWebContentsViewViews() { - if (devtools_window_) - inspectable_web_contents()->SaveDevToolsBounds( - devtools_window_->GetWindowBoundsInScreen()); -} - -views::View* InspectableWebContentsViewViews::GetView() { - return this; -} - -void InspectableWebContentsViewViews::SetCornerRadii( - const gfx::RoundedCornersF& corner_radii) { - // WebView won't exist for offscreen rendering. - if (contents_web_view_) { - contents_web_view_->holder()->SetCornerRadii( - gfx::RoundedCornersF(corner_radii)); - } -} - -void InspectableWebContentsViewViews::ShowDevTools(bool activate) { - if (devtools_visible_) - return; - - devtools_visible_ = true; - if (devtools_window_) { - devtools_window_web_view_->SetWebContents( - inspectable_web_contents_->GetDevToolsWebContents()); - devtools_window_->SetBounds(inspectable_web_contents()->dev_tools_bounds()); - if (activate) { - devtools_window_->Show(); - } else { - devtools_window_->ShowInactive(); - } - - // Update draggable regions to account for the new dock position. - if (GetDelegate()) - GetDelegate()->DevToolsResized(); - } else { - devtools_web_view_->SetVisible(true); - devtools_web_view_->SetWebContents( - inspectable_web_contents_->GetDevToolsWebContents()); - devtools_web_view_->RequestFocus(); - DeprecatedLayoutImmediately(); - } -} - -void InspectableWebContentsViewViews::CloseDevTools() { - if (!devtools_visible_) - return; - - devtools_visible_ = false; - if (devtools_window_) { - auto save_bounds = devtools_window_->IsMinimized() - ? devtools_window_->GetRestoredBounds() - : devtools_window_->GetWindowBoundsInScreen(); - inspectable_web_contents()->SaveDevToolsBounds(save_bounds); - - devtools_window_.reset(); - devtools_window_web_view_ = nullptr; - devtools_window_delegate_ = nullptr; - } else { - devtools_web_view_->SetVisible(false); - devtools_web_view_->SetWebContents(nullptr); - DeprecatedLayoutImmediately(); - } -} - -bool InspectableWebContentsViewViews::IsDevToolsViewShowing() { - return devtools_visible_; -} - -bool InspectableWebContentsViewViews::IsDevToolsViewFocused() { - if (devtools_window_web_view_) - return devtools_window_web_view_->HasFocus(); - else if (devtools_web_view_) - return devtools_web_view_->HasFocus(); - else - return false; -} - -void InspectableWebContentsViewViews::SetIsDocked(bool docked, bool activate) { - CloseDevTools(); - - if (!docked) { - devtools_window_ = std::make_unique<views::Widget>(); - devtools_window_web_view_ = new views::WebView(nullptr); - devtools_window_delegate_ = new DevToolsWindowDelegate( - this, devtools_window_web_view_, devtools_window_.get()); - - views::Widget::InitParams params{ - views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET}; - params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; - params.delegate = devtools_window_delegate_; - params.bounds = inspectable_web_contents()->dev_tools_bounds(); - -#if BUILDFLAG(IS_LINUX) - params.wm_role_name = "devtools"; - if (GetDelegate()) - GetDelegate()->GetDevToolsWindowWMClass(&params.wm_class_name, - &params.wm_class_class); -#endif - - devtools_window_->Init(std::move(params)); - devtools_window_->UpdateWindowIcon(); - devtools_window_->widget_delegate()->SetHasWindowSizeControls(true); - } - - ShowDevTools(activate); -} - -void InspectableWebContentsViewViews::SetContentsResizingStrategy( - const DevToolsContentsResizingStrategy& strategy) { - strategy_.CopyFrom(strategy); - DeprecatedLayoutImmediately(); -} - -void InspectableWebContentsViewViews::SetTitle(const std::u16string& title) { - if (devtools_window_) { - title_ = title; - devtools_window_->UpdateWindowTitle(); - } -} - -const std::u16string InspectableWebContentsViewViews::GetTitle() { - return title_; -} - -void InspectableWebContentsViewViews::Layout(PassKey) { - if (!devtools_web_view_->GetVisible()) { - contents_view_->SetBoundsRect(GetContentsBounds()); - // Propagate layout call to all children, for example browser views. - LayoutSuperclass<View>(this); - return; - } - - gfx::Size container_size(width(), height()); - gfx::Rect new_devtools_bounds; - gfx::Rect new_contents_bounds; - ApplyDevToolsContentsResizingStrategy( - strategy_, container_size, &new_devtools_bounds, &new_contents_bounds); - - // DevTools cares about the specific position, so we have to compensate RTL - // layout here. - new_devtools_bounds.set_x(GetMirroredXForRect(new_devtools_bounds)); - new_contents_bounds.set_x(GetMirroredXForRect(new_contents_bounds)); - - devtools_web_view_->SetBoundsRect(new_devtools_bounds); - contents_view_->SetBoundsRect(new_contents_bounds); - - // Propagate layout call to all children, for example browser views. - LayoutSuperclass<View>(this); - - if (GetDelegate()) - GetDelegate()->DevToolsResized(); -} - -} // namespace electron diff --git a/shell/browser/ui/views/inspectable_web_contents_view_views.h b/shell/browser/ui/views/inspectable_web_contents_view_views.h deleted file mode 100644 index 36554a497d..0000000000 --- a/shell/browser/ui/views/inspectable_web_contents_view_views.h +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (c) 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE-CHROMIUM file. - -#ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_INSPECTABLE_WEB_CONTENTS_VIEW_VIEWS_H_ -#define ELECTRON_SHELL_BROWSER_UI_VIEWS_INSPECTABLE_WEB_CONTENTS_VIEW_VIEWS_H_ - -#include <memory> - -#include "base/compiler_specific.h" -#include "base/memory/raw_ptr.h" -#include "chrome/browser/devtools/devtools_contents_resizing_strategy.h" -#include "shell/browser/ui/inspectable_web_contents_view.h" -#include "third_party/skia/include/core/SkRegion.h" -#include "ui/views/view.h" - -namespace views { -class WebView; -class Widget; -class WidgetDelegate; -} // namespace views - -namespace electron { - -class InspectableWebContentsViewViews : public InspectableWebContentsView, - public views::View { - public: - explicit InspectableWebContentsViewViews( - InspectableWebContents* inspectable_web_contents); - ~InspectableWebContentsViewViews() override; - - // InspectableWebContentsView: - views::View* GetView() override; - void ShowDevTools(bool activate) override; - void SetCornerRadii(const gfx::RoundedCornersF& corner_radii) override; - void CloseDevTools() override; - bool IsDevToolsViewShowing() override; - bool IsDevToolsViewFocused() override; - void SetIsDocked(bool docked, bool activate) override; - void SetContentsResizingStrategy( - const DevToolsContentsResizingStrategy& strategy) override; - void SetTitle(const std::u16string& title) override; - const std::u16string GetTitle() override; - - // views::View: - void Layout(PassKey) override; - - private: - std::unique_ptr<views::Widget> devtools_window_; - raw_ptr<views::WebView> devtools_window_web_view_ = nullptr; - raw_ptr<views::WebView> contents_web_view_ = nullptr; - raw_ptr<views::View> contents_view_ = nullptr; - raw_ptr<views::WebView> devtools_web_view_ = nullptr; - - DevToolsContentsResizingStrategy strategy_; - bool devtools_visible_ = false; - raw_ptr<views::WidgetDelegate> devtools_window_delegate_ = nullptr; - std::u16string title_; -}; - -} // namespace electron - -#endif // ELECTRON_SHELL_BROWSER_UI_VIEWS_INSPECTABLE_WEB_CONTENTS_VIEW_VIEWS_H_
refactor
16b2a097879f55aa3e3a98c1b26179f84d7cc015
John Kleinschmidt
2024-06-13 17:49:38
build: only load SDK for mac builds (#42485)
diff --git a/.github/workflows/pipeline-segment-electron-build.yml b/.github/workflows/pipeline-segment-electron-build.yml index 4842a368e0..7caf63e95e 100644 --- a/.github/workflows/pipeline-segment-electron-build.yml +++ b/.github/workflows/pipeline-segment-electron-build.yml @@ -41,6 +41,7 @@ on: type: string default: '0' + concurrency: group: electron-build-${{ inputs.target-platform }}-${{ inputs.target-arch }}-${{ github.ref }} cancel-in-progress: true @@ -66,12 +67,8 @@ jobs: env: TARGET_ARCH: ${{ inputs.target-arch }} steps: - - name: Load Build Tools - run: | - export BUILD_TOOLS_SHA=ef894bc3cfa99d84a3b731252da0f83f500e4032 - npm i -g @electron/build-tools - e auto-update disable - e init --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }} + - name: Create src dir + run: mkdir src - name: Checkout Electron uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 with: @@ -135,6 +132,12 @@ jobs: with: path: src/electron fetch-depth: 0 + - name: Load Build Tools + run: | + export BUILD_TOOLS_SHA=5e75f554ba5b919b4ed67caa2ba8042d8e3be947 + npm i -g @electron/build-tools + e auto-update disable + e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }} --only-sdk - name: Run Electron Only Hooks run: | gclient runhooks --spec="solutions=[{'name':'src/electron','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':False},'managed':False}]"
build
22b7403cd1beb2aa95bec223ddd6f328c18b7f8c
Milan Burda
2025-02-19 01:59:00
chore: remove deprecated `systemPreferences.isAeroGlassEnabled()` (#45563)
diff --git a/docs/api/system-preferences.md b/docs/api/system-preferences.md index 05e83be870..3a6488274e 100644 --- a/docs/api/system-preferences.md +++ b/docs/api/system-preferences.md @@ -181,16 +181,6 @@ Some popular `key` and `type`s are: Removes the `key` in `NSUserDefaults`. This can be used to restore the default or global value of a `key` previously set with `setUserDefault`. -### `systemPreferences.isAeroGlassEnabled()` _Windows_ _Deprecated_ - -Returns `boolean` - `true` if [DWM composition][dwm-composition] (Aero Glass) is -enabled, and `false` otherwise. - -**Deprecated:** -This function has been always returning `true` since Electron 23, which only supports Windows 10+. - -[dwm-composition]: https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw - ### `systemPreferences.getAccentColor()` _Windows_ _macOS_ Returns `string` - The users current system wide accent color preference in RGBA diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md index 15a74912ba..061ce6d287 100644 --- a/docs/breaking-changes.md +++ b/docs/breaking-changes.md @@ -12,6 +12,15 @@ This document uses the following convention to categorize breaking changes: * **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release. * **Removed:** An API or feature was removed, and is no longer supported by Electron. +## Planned Breaking API Changes (36.0) + +### Removed: `systemPreferences.isAeroGlassEnabled()` + +The `systemPreferences.isAeroGlassEnabled()` function has been removed without replacement. +It has been always returning `true` since Electron 23, which only supports Windows 10+, where DWM composition can no longer be disabled. + +https://learn.microsoft.com/en-us/windows/win32/dwm/composition-ovw#disabling-dwm-composition-windows7-and-earlier + ## Planned Breaking API Changes (35.0) ### Removed:`isDefault` and `status` properties on `PrinterInfo` diff --git a/lib/browser/api/system-preferences.ts b/lib/browser/api/system-preferences.ts index 3f78083d02..b5485a7361 100644 --- a/lib/browser/api/system-preferences.ts +++ b/lib/browser/api/system-preferences.ts @@ -20,12 +20,4 @@ if ('accessibilityDisplayShouldReduceTransparency' in systemPreferences) { }); } -if (process.platform === 'win32') { - const isAeroGlassEnabledDeprecated = deprecate.warnOnce('systemPreferences.isAeroGlassEnabled'); - systemPreferences.isAeroGlassEnabled = () => { - isAeroGlassEnabledDeprecated(); - return true; - }; -} - export default systemPreferences; diff --git a/spec/api-system-preferences-spec.ts b/spec/api-system-preferences-spec.ts index 44637669f2..05de0b91e8 100644 --- a/spec/api-system-preferences-spec.ts +++ b/spec/api-system-preferences-spec.ts @@ -2,7 +2,6 @@ import { systemPreferences } from 'electron/main'; import { expect } from 'chai'; -import { expectDeprecationMessages } from './lib/deprecate-helpers'; import { ifdescribe } from './lib/spec-helpers'; describe('systemPreferences module', () => { @@ -60,13 +59,6 @@ describe('systemPreferences module', () => { }); }); - ifdescribe(process.platform === 'win32')('systemPreferences.isAeroGlassEnabled()', () => { - it('always returns true', () => { - expect(systemPreferences.isAeroGlassEnabled()).to.equal(true); - expectDeprecationMessages(() => systemPreferences.isAeroGlassEnabled(), '\'systemPreferences.isAeroGlassEnabled\' is deprecated and will be removed.'); - }); - }); - ifdescribe(process.platform === 'darwin')('systemPreferences.getUserDefault(key, type)', () => { it('returns values for known user defaults', () => { const locale = systemPreferences.getUserDefault('AppleLocale', 'string'); diff --git a/spec/ts-smoke/electron/main.ts b/spec/ts-smoke/electron/main.ts index 4dfef7df74..62f2726970 100644 --- a/spec/ts-smoke/electron/main.ts +++ b/spec/ts-smoke/electron/main.ts @@ -370,6 +370,8 @@ if (process.platform === 'win32') { // @ts-expect-error Removed API systemPreferences.on('high-contrast-color-scheme-changed', (_, highContrast) => console.log(highContrast ? 'high contrast' : 'not high contrast')); console.log('Color for menu is', systemPreferences.getColor('menu')); + // @ts-expect-error Removed API + systemPreferences.isAeroGlassEnabled(); } if (process.platform === 'darwin') {
chore
4cf69f396ff3d2657a802d8038bfa0d53b3d302d
Charles Kerr
2024-10-08 09:54:33
fix: context shear in cli_remove_deprecated_v8_flag.patch (#44148) fix: patch shear in cli_remove_deprecated_v8_flag.patch
diff --git a/patches/node/cli_remove_deprecated_v8_flag.patch b/patches/node/cli_remove_deprecated_v8_flag.patch index 0f6e243a7a..0a4e8eb25b 100644 --- a/patches/node/cli_remove_deprecated_v8_flag.patch +++ b/patches/node/cli_remove_deprecated_v8_flag.patch @@ -18,22 +18,22 @@ Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> diff --git a/doc/api/cli.md b/doc/api/cli.md -index 8f32a44ad41314dce2e4b58b318e4b5a7530b802..10dc8da655690d1ce020474256b2134fb881fa39 100644 +index ed0a43306e87962cf0e756d9e059ec5c08ad674b..7ada2802b2590e78fa5b9847935866b743cf94ed 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md -@@ -2810,7 +2810,6 @@ V8 options that are allowed are: - * `--abort-on-uncaught-exception` +@@ -2868,7 +2868,6 @@ V8 options that are allowed are: * `--disallow-code-generation-from-strings` * `--enable-etw-stack-walking` + * `--expose-gc` -* `--huge-max-old-generation-size` * `--interpreted-frames-native-stack` * `--jitless` * `--max-old-space-size` diff --git a/src/node_options.cc b/src/node_options.cc -index 409c6e3918e3ef7c9d35f87e093cb965cb889dd7..eefdf7a48ed3ddebda3b6771b2d103455d2c8d70 100644 +index 4e3c82e9528b04fd1a0cc99d30fb885e4b224bc9..38e173f72b446aa2db07f676b6ece26247bbf56b 100644 --- a/src/node_options.cc +++ b/src/node_options.cc -@@ -854,11 +854,6 @@ PerIsolateOptionsParser::PerIsolateOptionsParser( +@@ -866,11 +866,6 @@ PerIsolateOptionsParser::PerIsolateOptionsParser( "disallow eval and friends", V8Option{}, kAllowedInEnvvar); @@ -46,13 +46,13 @@ index 409c6e3918e3ef7c9d35f87e093cb965cb889dd7..eefdf7a48ed3ddebda3b6771b2d10345 "disable runtime allocation of executable memory", V8Option{}, diff --git a/test/parallel/test-cli-node-options.js b/test/parallel/test-cli-node-options.js -index 4d659a7b212441963a8b8be35ad0d44440842380..6f90230a3a2a105b9eb8f5a57eaf94c7cc64215f 100644 +index 8d614e607177cdd922fef65a85a2ccdcf54116c0..146df3a21a0551e910c46248d2fd97dde8896164 100644 --- a/test/parallel/test-cli-node-options.js +++ b/test/parallel/test-cli-node-options.js -@@ -69,7 +69,6 @@ if (common.hasCrypto) { - // V8 options +@@ -70,7 +70,6 @@ if (common.hasCrypto) { expect('--abort_on-uncaught_exception', 'B\n'); expect('--disallow-code-generation-from-strings', 'B\n'); + expect('--expose-gc', 'B\n'); -expect('--huge-max-old-generation-size', 'B\n'); expect('--jitless', 'B\n'); expect('--max-old-space-size=0', 'B\n');
fix
8ae5aacc8c2734e65ac0e1ccfbe96539f5f07dd2
Charles Kerr
2024-09-04 18:40:02
refactor: declare gin::Wrapper subclasses as final (#43527) As per the gin docs: "Wrappable<T> explicitly does not support further subclassing of T. Subclasses of Wrappable<T> should be declared final."
diff --git a/shell/browser/api/electron_api_app.h b/shell/browser/api/electron_api_app.h index 9c42389242..0d17c25e7d 100644 --- a/shell/browser/api/electron_api_app.h +++ b/shell/browser/api/electron_api_app.h @@ -57,12 +57,12 @@ enum class JumpListResult : int; namespace api { -class App : public ElectronBrowserClient::Delegate, - public gin::Wrappable<App>, - public gin_helper::EventEmitterMixin<App>, - private BrowserObserver, - private content::GpuDataManagerObserver, - private content::BrowserChildProcessObserver { +class App final : public ElectronBrowserClient::Delegate, + public gin::Wrappable<App>, + public gin_helper::EventEmitterMixin<App>, + private BrowserObserver, + private content::GpuDataManagerObserver, + private content::BrowserChildProcessObserver { public: using FileIconCallback = base::RepeatingCallback<void(v8::Local<v8::Value>, const gfx::Image&)>; diff --git a/shell/browser/api/electron_api_auto_updater.h b/shell/browser/api/electron_api_auto_updater.h index 00fc40fbaf..22a0f1f7c0 100644 --- a/shell/browser/api/electron_api_auto_updater.h +++ b/shell/browser/api/electron_api_auto_updater.h @@ -19,10 +19,10 @@ class Handle; namespace electron::api { -class AutoUpdater : public gin::Wrappable<AutoUpdater>, - public gin_helper::EventEmitterMixin<AutoUpdater>, - public auto_updater::Delegate, - private WindowListObserver { +class AutoUpdater final : public gin::Wrappable<AutoUpdater>, + public gin_helper::EventEmitterMixin<AutoUpdater>, + public auto_updater::Delegate, + private WindowListObserver { public: static gin::Handle<AutoUpdater> Create(v8::Isolate* isolate); diff --git a/shell/browser/api/electron_api_cookies.h b/shell/browser/api/electron_api_cookies.h index 50a9470401..df509fdb1d 100644 --- a/shell/browser/api/electron_api_cookies.h +++ b/shell/browser/api/electron_api_cookies.h @@ -31,8 +31,8 @@ class ElectronBrowserContext; namespace api { -class Cookies : public gin::Wrappable<Cookies>, - public gin_helper::EventEmitterMixin<Cookies> { +class Cookies final : public gin::Wrappable<Cookies>, + public gin_helper::EventEmitterMixin<Cookies> { public: static gin::Handle<Cookies> Create(v8::Isolate* isolate, ElectronBrowserContext* browser_context); diff --git a/shell/browser/api/electron_api_data_pipe_holder.h b/shell/browser/api/electron_api_data_pipe_holder.h index f6c09cf34a..1203ac0986 100644 --- a/shell/browser/api/electron_api_data_pipe_holder.h +++ b/shell/browser/api/electron_api_data_pipe_holder.h @@ -20,7 +20,7 @@ class Handle; namespace electron::api { // Retains reference to the data pipe. -class DataPipeHolder : public gin::Wrappable<DataPipeHolder> { +class DataPipeHolder final : public gin::Wrappable<DataPipeHolder> { public: // gin::Wrappable static gin::WrapperInfo kWrapperInfo; diff --git a/shell/browser/api/electron_api_debugger.h b/shell/browser/api/electron_api_debugger.h index f4329ee4fc..4f4b6fd4fb 100644 --- a/shell/browser/api/electron_api_debugger.h +++ b/shell/browser/api/electron_api_debugger.h @@ -32,10 +32,10 @@ class Promise; namespace electron::api { -class Debugger : public gin::Wrappable<Debugger>, - public gin_helper::EventEmitterMixin<Debugger>, - public content::DevToolsAgentHostClient, - private content::WebContentsObserver { +class Debugger final : public gin::Wrappable<Debugger>, + public gin_helper::EventEmitterMixin<Debugger>, + public content::DevToolsAgentHostClient, + private content::WebContentsObserver { public: static gin::Handle<Debugger> Create(v8::Isolate* isolate, content::WebContents* web_contents); diff --git a/shell/browser/api/electron_api_desktop_capturer.h b/shell/browser/api/electron_api_desktop_capturer.h index f02d782a20..1a146feb52 100644 --- a/shell/browser/api/electron_api_desktop_capturer.h +++ b/shell/browser/api/electron_api_desktop_capturer.h @@ -21,9 +21,9 @@ class Handle; namespace electron::api { -class DesktopCapturer : public gin::Wrappable<DesktopCapturer>, - public gin_helper::Pinnable<DesktopCapturer>, - private DesktopMediaListObserver { +class DesktopCapturer final : public gin::Wrappable<DesktopCapturer>, + public gin_helper::Pinnable<DesktopCapturer>, + private DesktopMediaListObserver { public: struct Source { DesktopMediaList::Source media_list_source; diff --git a/shell/browser/api/electron_api_download_item.h b/shell/browser/api/electron_api_download_item.h index 46e9e7b193..17d02fdb54 100644 --- a/shell/browser/api/electron_api_download_item.h +++ b/shell/browser/api/electron_api_download_item.h @@ -25,10 +25,10 @@ class Handle; namespace electron::api { -class DownloadItem : public gin::Wrappable<DownloadItem>, - public gin_helper::Pinnable<DownloadItem>, - public gin_helper::EventEmitterMixin<DownloadItem>, - private download::DownloadItem::Observer { +class DownloadItem final : public gin::Wrappable<DownloadItem>, + public gin_helper::Pinnable<DownloadItem>, + public gin_helper::EventEmitterMixin<DownloadItem>, + private download::DownloadItem::Observer { public: static gin::Handle<DownloadItem> FromOrCreate(v8::Isolate* isolate, download::DownloadItem* item); diff --git a/shell/browser/api/electron_api_global_shortcut.h b/shell/browser/api/electron_api_global_shortcut.h index 8b1048680c..614082d889 100644 --- a/shell/browser/api/electron_api_global_shortcut.h +++ b/shell/browser/api/electron_api_global_shortcut.h @@ -20,8 +20,9 @@ class Handle; namespace electron::api { -class GlobalShortcut : private extensions::GlobalShortcutListener::Observer, - public gin::Wrappable<GlobalShortcut> { +class GlobalShortcut final + : private extensions::GlobalShortcutListener::Observer, + public gin::Wrappable<GlobalShortcut> { public: static gin::Handle<GlobalShortcut> Create(v8::Isolate* isolate); diff --git a/shell/browser/api/electron_api_in_app_purchase.h b/shell/browser/api/electron_api_in_app_purchase.h index 4e88a49556..b50cba62f4 100644 --- a/shell/browser/api/electron_api_in_app_purchase.h +++ b/shell/browser/api/electron_api_in_app_purchase.h @@ -22,9 +22,9 @@ class Handle; namespace electron::api { -class InAppPurchase : public gin::Wrappable<InAppPurchase>, - public gin_helper::EventEmitterMixin<InAppPurchase>, - private in_app_purchase::TransactionObserver { +class InAppPurchase final : public gin::Wrappable<InAppPurchase>, + public gin_helper::EventEmitterMixin<InAppPurchase>, + private in_app_purchase::TransactionObserver { public: static gin::Handle<InAppPurchase> Create(v8::Isolate* isolate); diff --git a/shell/browser/api/electron_api_native_theme.h b/shell/browser/api/electron_api_native_theme.h index 70066558b2..d94f148ec5 100644 --- a/shell/browser/api/electron_api_native_theme.h +++ b/shell/browser/api/electron_api_native_theme.h @@ -18,9 +18,9 @@ class handle; namespace electron::api { -class NativeTheme : public gin::Wrappable<NativeTheme>, - public gin_helper::EventEmitterMixin<NativeTheme>, - private ui::NativeThemeObserver { +class NativeTheme final : public gin::Wrappable<NativeTheme>, + public gin_helper::EventEmitterMixin<NativeTheme>, + private ui::NativeThemeObserver { public: static gin::Handle<NativeTheme> Create(v8::Isolate* isolate); diff --git a/shell/browser/api/electron_api_net_log.h b/shell/browser/api/electron_api_net_log.h index e7aa9b733f..b3d84d5a9e 100644 --- a/shell/browser/api/electron_api_net_log.h +++ b/shell/browser/api/electron_api_net_log.h @@ -35,7 +35,7 @@ class ElectronBrowserContext; namespace api { // The code is referenced from the net_log::NetExportFileWriter class. -class NetLog : public gin::Wrappable<NetLog> { +class NetLog final : public gin::Wrappable<NetLog> { public: static gin::Handle<NetLog> Create(v8::Isolate* isolate, ElectronBrowserContext* browser_context); diff --git a/shell/browser/api/electron_api_notification.h b/shell/browser/api/electron_api_notification.h index 7cdf6cba5d..c67c5d7160 100644 --- a/shell/browser/api/electron_api_notification.h +++ b/shell/browser/api/electron_api_notification.h @@ -30,11 +30,11 @@ class ErrorThrower; namespace electron::api { -class Notification : public gin::Wrappable<Notification>, - public gin_helper::EventEmitterMixin<Notification>, - public gin_helper::Constructible<Notification>, - public gin_helper::CleanedUpAtExit, - public NotificationDelegate { +class Notification final : public gin::Wrappable<Notification>, + public gin_helper::EventEmitterMixin<Notification>, + public gin_helper::Constructible<Notification>, + public gin_helper::CleanedUpAtExit, + public NotificationDelegate { public: static bool IsSupported(); diff --git a/shell/browser/api/electron_api_power_monitor.h b/shell/browser/api/electron_api_power_monitor.h index 436fd9c0f8..d0dd651f01 100644 --- a/shell/browser/api/electron_api_power_monitor.h +++ b/shell/browser/api/electron_api_power_monitor.h @@ -17,12 +17,12 @@ namespace electron::api { -class PowerMonitor : public gin::Wrappable<PowerMonitor>, - public gin_helper::EventEmitterMixin<PowerMonitor>, - public gin_helper::Pinnable<PowerMonitor>, - private base::PowerStateObserver, - private base::PowerSuspendObserver, - private base::PowerThermalObserver { +class PowerMonitor final : public gin::Wrappable<PowerMonitor>, + public gin_helper::EventEmitterMixin<PowerMonitor>, + public gin_helper::Pinnable<PowerMonitor>, + private base::PowerStateObserver, + private base::PowerSuspendObserver, + private base::PowerThermalObserver { public: static v8::Local<v8::Value> Create(v8::Isolate* isolate); diff --git a/shell/browser/api/electron_api_power_save_blocker.h b/shell/browser/api/electron_api_power_save_blocker.h index 43b2265b06..881a222e1a 100644 --- a/shell/browser/api/electron_api_power_save_blocker.h +++ b/shell/browser/api/electron_api_power_save_blocker.h @@ -19,7 +19,7 @@ class Handle; namespace electron::api { -class PowerSaveBlocker : public gin::Wrappable<PowerSaveBlocker> { +class PowerSaveBlocker final : public gin::Wrappable<PowerSaveBlocker> { public: static gin::Handle<PowerSaveBlocker> Create(v8::Isolate* isolate); diff --git a/shell/browser/api/electron_api_protocol.h b/shell/browser/api/electron_api_protocol.h index 82d74013b3..273efc4dea 100644 --- a/shell/browser/api/electron_api_protocol.h +++ b/shell/browser/api/electron_api_protocol.h @@ -45,8 +45,8 @@ enum class ProtocolError { }; // Protocol implementation based on network services. -class Protocol : public gin::Wrappable<Protocol>, - public gin_helper::Constructible<Protocol> { +class Protocol final : public gin::Wrappable<Protocol>, + public gin_helper::Constructible<Protocol> { public: static gin::Handle<Protocol> Create(v8::Isolate* isolate, ElectronBrowserContext* browser_context); diff --git a/shell/browser/api/electron_api_push_notifications.h b/shell/browser/api/electron_api_push_notifications.h index 5cc3277080..eea0f9909d 100644 --- a/shell/browser/api/electron_api_push_notifications.h +++ b/shell/browser/api/electron_api_push_notifications.h @@ -21,7 +21,7 @@ class Handle; namespace electron::api { -class PushNotifications +class PushNotifications final : public ElectronBrowserClient::Delegate, public gin::Wrappable<PushNotifications>, public gin_helper::EventEmitterMixin<PushNotifications>, diff --git a/shell/browser/api/electron_api_screen.h b/shell/browser/api/electron_api_screen.h index bbc7ade94d..cd5d7f5b5d 100644 --- a/shell/browser/api/electron_api_screen.h +++ b/shell/browser/api/electron_api_screen.h @@ -25,9 +25,9 @@ class ErrorThrower; namespace electron::api { -class Screen : public gin::Wrappable<Screen>, - public gin_helper::EventEmitterMixin<Screen>, - private display::DisplayObserver { +class Screen final : public gin::Wrappable<Screen>, + public gin_helper::EventEmitterMixin<Screen>, + private display::DisplayObserver { public: static v8::Local<v8::Value> Create(gin_helper::ErrorThrower error_thrower); diff --git a/shell/browser/api/electron_api_service_worker_context.h b/shell/browser/api/electron_api_service_worker_context.h index fb6bb9fe6e..286c3bcecc 100644 --- a/shell/browser/api/electron_api_service_worker_context.h +++ b/shell/browser/api/electron_api_service_worker_context.h @@ -22,7 +22,7 @@ class ElectronBrowserContext; namespace api { -class ServiceWorkerContext +class ServiceWorkerContext final : public gin::Wrappable<ServiceWorkerContext>, public gin_helper::EventEmitterMixin<ServiceWorkerContext>, private content::ServiceWorkerContextObserver { diff --git a/shell/browser/api/electron_api_session.h b/shell/browser/api/electron_api_session.h index 37a1c9b2fb..8e921eb290 100644 --- a/shell/browser/api/electron_api_session.h +++ b/shell/browser/api/electron_api_session.h @@ -60,18 +60,18 @@ class ElectronBrowserContext; namespace api { -class Session : public gin::Wrappable<Session>, - public gin_helper::Pinnable<Session>, - public gin_helper::Constructible<Session>, - public gin_helper::EventEmitterMixin<Session>, - public gin_helper::CleanedUpAtExit, +class Session final : public gin::Wrappable<Session>, + public gin_helper::Pinnable<Session>, + public gin_helper::Constructible<Session>, + public gin_helper::EventEmitterMixin<Session>, + public gin_helper::CleanedUpAtExit, #if BUILDFLAG(ENABLE_BUILTIN_SPELLCHECKER) - private SpellcheckHunspellDictionary::Observer, + private SpellcheckHunspellDictionary::Observer, #endif #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) - private extensions::ExtensionRegistryObserver, + private extensions::ExtensionRegistryObserver, #endif - private content::DownloadManager::Observer { + private content::DownloadManager::Observer { public: // Gets or creates Session from the |browser_context|. static gin::Handle<Session> CreateFrom( diff --git a/shell/browser/api/electron_api_system_preferences.h b/shell/browser/api/electron_api_system_preferences.h index f5021242a0..100d77b8a3 100644 --- a/shell/browser/api/electron_api_system_preferences.h +++ b/shell/browser/api/electron_api_system_preferences.h @@ -37,7 +37,7 @@ enum class NotificationCenterKind { }; #endif -class SystemPreferences +class SystemPreferences final : public gin::Wrappable<SystemPreferences>, public gin_helper::EventEmitterMixin<SystemPreferences> #if BUILDFLAG(IS_WIN) diff --git a/shell/browser/api/electron_api_tray.h b/shell/browser/api/electron_api_tray.h index 8f3433d33a..fbcb908d04 100644 --- a/shell/browser/api/electron_api_tray.h +++ b/shell/browser/api/electron_api_tray.h @@ -38,12 +38,12 @@ namespace electron::api { class Menu; -class Tray : public gin::Wrappable<Tray>, - public gin_helper::EventEmitterMixin<Tray>, - public gin_helper::Constructible<Tray>, - public gin_helper::CleanedUpAtExit, - public gin_helper::Pinnable<Tray>, - private TrayIconObserver { +class Tray final : public gin::Wrappable<Tray>, + public gin_helper::EventEmitterMixin<Tray>, + public gin_helper::Constructible<Tray>, + public gin_helper::CleanedUpAtExit, + public gin_helper::Pinnable<Tray>, + private TrayIconObserver { public: // gin_helper::Constructible static gin::Handle<Tray> New(gin_helper::ErrorThrower thrower, diff --git a/shell/browser/api/electron_api_utility_process.h b/shell/browser/api/electron_api_utility_process.h index 767252d54f..2e37157c85 100644 --- a/shell/browser/api/electron_api_utility_process.h +++ b/shell/browser/api/electron_api_utility_process.h @@ -39,7 +39,7 @@ class Connector; namespace electron::api { -class UtilityProcessWrapper +class UtilityProcessWrapper final : public gin::Wrappable<UtilityProcessWrapper>, public gin_helper::Pinnable<UtilityProcessWrapper>, public gin_helper::EventEmitterMixin<UtilityProcessWrapper>, diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index a54ba3da24..93f0cd25aa 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -1902,7 +1902,7 @@ namespace { // This object wraps the InvokeCallback so that if it gets GC'd by V8, we can // still call the callback and send an error. Not doing so causes a Mojo DCHECK, // since Mojo requires callbacks to be called before they are destroyed. -class ReplyChannel : public gin::Wrappable<ReplyChannel> { +class ReplyChannel final : public gin::Wrappable<ReplyChannel> { public: using InvokeCallback = electron::mojom::ElectronApiIPC::InvokeCallback; static gin::Handle<ReplyChannel> Create(v8::Isolate* isolate, diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index 850f9de729..20c96abdd1 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -110,19 +110,19 @@ class BaseWindow; class FrameSubscriber; // Wrapper around the content::WebContents. -class WebContents : public ExclusiveAccessContext, - public gin::Wrappable<WebContents>, - public gin_helper::EventEmitterMixin<WebContents>, - public gin_helper::Constructible<WebContents>, - public gin_helper::Pinnable<WebContents>, - public gin_helper::CleanedUpAtExit, - public content::WebContentsObserver, - public content::WebContentsDelegate, - private content::RenderWidgetHost::InputEventObserver, - public content::JavaScriptDialogManager, - public InspectableWebContentsDelegate, - public InspectableWebContentsViewDelegate, - public BackgroundThrottlingSource { +class WebContents final : public ExclusiveAccessContext, + public gin::Wrappable<WebContents>, + public gin_helper::EventEmitterMixin<WebContents>, + public gin_helper::Constructible<WebContents>, + public gin_helper::Pinnable<WebContents>, + public gin_helper::CleanedUpAtExit, + public content::WebContentsObserver, + public content::WebContentsDelegate, + private content::RenderWidgetHost::InputEventObserver, + public content::JavaScriptDialogManager, + public InspectableWebContentsDelegate, + public InspectableWebContentsViewDelegate, + public BackgroundThrottlingSource { public: enum class Type { kBackgroundPage, // An extension background page. diff --git a/shell/browser/api/electron_api_web_frame_main.h b/shell/browser/api/electron_api_web_frame_main.h index c4552b03a8..ec86f3edcc 100644 --- a/shell/browser/api/electron_api_web_frame_main.h +++ b/shell/browser/api/electron_api_web_frame_main.h @@ -38,10 +38,10 @@ namespace electron::api { class WebContents; // Bindings for accessing frames from the main process. -class WebFrameMain : public gin::Wrappable<WebFrameMain>, - public gin_helper::EventEmitterMixin<WebFrameMain>, - public gin_helper::Pinnable<WebFrameMain>, - public gin_helper::Constructible<WebFrameMain> { +class WebFrameMain final : public gin::Wrappable<WebFrameMain>, + public gin_helper::EventEmitterMixin<WebFrameMain>, + public gin_helper::Pinnable<WebFrameMain>, + public gin_helper::Constructible<WebFrameMain> { public: // Create a new WebFrameMain and return the V8 wrapper of it. static gin::Handle<WebFrameMain> New(v8::Isolate* isolate); diff --git a/shell/browser/api/electron_api_web_request.h b/shell/browser/api/electron_api_web_request.h index 7a0add857f..d7a78c3e59 100644 --- a/shell/browser/api/electron_api_web_request.h +++ b/shell/browser/api/electron_api_web_request.h @@ -31,7 +31,8 @@ class Handle; namespace electron::api { -class WebRequest : public gin::Wrappable<WebRequest>, public WebRequestAPI { +class WebRequest final : public gin::Wrappable<WebRequest>, + public WebRequestAPI { public: // Return the WebRequest object attached to |browser_context|, create if there // is no one. diff --git a/shell/browser/api/message_port.h b/shell/browser/api/message_port.h index ce4bde2a64..1a2c7ff52b 100644 --- a/shell/browser/api/message_port.h +++ b/shell/browser/api/message_port.h @@ -27,9 +27,9 @@ class Connector; namespace electron { // A non-blink version of blink::MessagePort. -class MessagePort : public gin::Wrappable<MessagePort>, - public gin_helper::CleanedUpAtExit, - public mojo::MessageReceiver { +class MessagePort final : public gin::Wrappable<MessagePort>, + public gin_helper::CleanedUpAtExit, + public mojo::MessageReceiver { public: ~MessagePort() override; static gin::Handle<MessagePort> Create(v8::Isolate* isolate); diff --git a/shell/common/api/electron_api_native_image.h b/shell/common/api/electron_api_native_image.h index 94fc3cc5c0..3b82956f82 100644 --- a/shell/common/api/electron_api_native_image.h +++ b/shell/common/api/electron_api_native_image.h @@ -45,7 +45,7 @@ class ErrorThrower; namespace electron::api { -class NativeImage : public gin::Wrappable<NativeImage> { +class NativeImage final : public gin::Wrappable<NativeImage> { public: NativeImage(v8::Isolate* isolate, const gfx::Image& image); #if BUILDFLAG(IS_WIN) diff --git a/shell/common/api/electron_api_url_loader.cc b/shell/common/api/electron_api_url_loader.cc index 20551a27bb..2c7e546b5f 100644 --- a/shell/common/api/electron_api_url_loader.cc +++ b/shell/common/api/electron_api_url_loader.cc @@ -162,8 +162,9 @@ class BufferDataSource : public mojo::DataPipeProducer::DataSource { std::vector<char> buffer_; }; -class JSChunkedDataPipeGetter : public gin::Wrappable<JSChunkedDataPipeGetter>, - public network::mojom::ChunkedDataPipeGetter { +class JSChunkedDataPipeGetter final + : public gin::Wrappable<JSChunkedDataPipeGetter>, + public network::mojom::ChunkedDataPipeGetter { public: static gin::Handle<JSChunkedDataPipeGetter> Create( v8::Isolate* isolate, diff --git a/shell/common/api/electron_api_url_loader.h b/shell/common/api/electron_api_url_loader.h index b78f9e3d1d..98b2c56701 100644 --- a/shell/common/api/electron_api_url_loader.h +++ b/shell/common/api/electron_api_url_loader.h @@ -47,7 +47,7 @@ class ElectronBrowserContext; namespace electron::api { /** Wraps a SimpleURLLoader to make it usable from JavaScript */ -class SimpleURLLoaderWrapper +class SimpleURLLoaderWrapper final : public gin::Wrappable<SimpleURLLoaderWrapper>, public gin_helper::EventEmitterMixin<SimpleURLLoaderWrapper>, private network::SimpleURLLoaderStreamConsumer, diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc index 47a4ffb52f..7a41afd470 100644 --- a/shell/common/gin_converters/net_converter.cc +++ b/shell/common/gin_converters/net_converter.cc @@ -253,7 +253,7 @@ bool Converter<net::HttpRequestHeaders>::FromV8(v8::Isolate* isolate, namespace { -class ChunkedDataPipeReadableStream +class ChunkedDataPipeReadableStream final : public gin::Wrappable<ChunkedDataPipeReadableStream> { public: static gin::Handle<ChunkedDataPipeReadableStream> Create( diff --git a/shell/common/gin_helper/event.h b/shell/common/gin_helper/event.h index 7f04d27edb..389f1d84ac 100644 --- a/shell/common/gin_helper/event.h +++ b/shell/common/gin_helper/event.h @@ -23,8 +23,8 @@ class ObjectTemplate; namespace gin_helper::internal { -class Event : public gin::Wrappable<Event>, - public gin_helper::Constructible<Event> { +class Event final : public gin::Wrappable<Event>, + public gin_helper::Constructible<Event> { public: // gin_helper::Constructible static gin::Handle<Event> New(v8::Isolate* isolate); diff --git a/shell/renderer/api/electron_api_ipc_renderer.cc b/shell/renderer/api/electron_api_ipc_renderer.cc index bf8867a31e..35dab4c4c5 100644 --- a/shell/renderer/api/electron_api_ipc_renderer.cc +++ b/shell/renderer/api/electron_api_ipc_renderer.cc @@ -40,8 +40,8 @@ RenderFrame* GetCurrentRenderFrame() { return RenderFrame::FromWebFrame(frame); } -class IPCRenderer : public gin::Wrappable<IPCRenderer>, - private content::RenderFrameObserver { +class IPCRenderer final : public gin::Wrappable<IPCRenderer>, + private content::RenderFrameObserver { public: static gin::WrapperInfo kWrapperInfo; diff --git a/shell/renderer/api/electron_api_web_frame.cc b/shell/renderer/api/electron_api_web_frame.cc index 495ddf4b5e..2750e17a43 100644 --- a/shell/renderer/api/electron_api_web_frame.cc +++ b/shell/renderer/api/electron_api_web_frame.cc @@ -326,8 +326,8 @@ class SpellCheckerHolder final : private content::RenderFrameObserver { std::unique_ptr<SpellCheckClient> spell_check_client_; }; -class WebFrameRenderer : public gin::Wrappable<WebFrameRenderer>, - private content::RenderFrameObserver { +class WebFrameRenderer final : public gin::Wrappable<WebFrameRenderer>, + private content::RenderFrameObserver { public: static gin::WrapperInfo kWrapperInfo; diff --git a/shell/services/node/parent_port.h b/shell/services/node/parent_port.h index 082d47a2ef..20f6adc5b1 100644 --- a/shell/services/node/parent_port.h +++ b/shell/services/node/parent_port.h @@ -30,8 +30,8 @@ namespace electron { // There is only a single instance of this class // for the lifetime of a Utility Process which // also means that GC lifecycle is ignored by this class. -class ParentPort : public gin::Wrappable<ParentPort>, - public mojo::MessageReceiver { +class ParentPort final : public gin::Wrappable<ParentPort>, + public mojo::MessageReceiver { public: static ParentPort* GetInstance(); static gin::Handle<ParentPort> Create(v8::Isolate* isolate);
refactor
e1494ddc4776cbf3204ede868f04e4c3f8249943
Samuel Attard
2022-10-06 04:27:28
chore: cherry-pick c83640db21b5 from chromium (#35924) * chore: cherry-pick c83640db21b5 from chromium * chore: update patches Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 3d99ad54ef..a7692e6e09 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -121,3 +121,4 @@ disable_optimization_guide_for_preconnect_feature.patch fix_return_v8_value_from_localframe_requestexecutescript.patch create_browser_v8_snapshot_file_name_fuse.patch feat_ensure_mas_builds_of_the_same_application_can_use_safestorage.patch +cherry-pick-c83640db21b5.patch diff --git a/patches/chromium/cherry-pick-c83640db21b5.patch b/patches/chromium/cherry-pick-c83640db21b5.patch new file mode 100644 index 0000000000..723f455e3f --- /dev/null +++ b/patches/chromium/cherry-pick-c83640db21b5.patch @@ -0,0 +1,122 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samuel Attard <[email protected]> +Date: Wed, 5 Oct 2022 06:03:23 +0000 +Subject: build: set DTSDKBuild correctly when generating plist files + +Currently we set DTSDKBuild to the version of the SDK used to build +Chromium. This value is supposed to be the build version (this is +what xcode sets it to for instance). We read this value out of the +SDK directly and use it instead. + +Change-Id: Ieb7990f13095683ad8c026f027b2605ae39523a4 + +diff --git a/build/config/mac/mac_sdk.gni b/build/config/mac/mac_sdk.gni +index 98bedab98c2cd808387bca779221fab7297b37ee..d39350ed74d5c9493006266375664a9808e97af7 100644 +--- a/build/config/mac/mac_sdk.gni ++++ b/build/config/mac/mac_sdk.gni +@@ -40,6 +40,11 @@ declare_args() { + # will fail. + mac_sdk_official_version = "12.3" + ++ # The SDK build version used when making official builds. This is a single ++ # exact version found at "System/Library/CoreServices/SystemVersion.plist" ++ # inside the SDK. ++ mac_sdk_official_build_version = "21E226" ++ + # Production builds should use hermetic Xcode. If you want to do production + # builds with system Xcode to test new SDKs, set this. + # Don't set this on any bots. +@@ -103,11 +108,13 @@ if (use_system_xcode) { + find_sdk_args = [ + "--print_sdk_path", + "--print_bin_path", ++ "--print_sdk_build", + mac_sdk_min, + ] + find_sdk_lines = + exec_script("//build/mac/find_sdk.py", find_sdk_args, "list lines") +- mac_sdk_version = find_sdk_lines[2] ++ mac_sdk_version = find_sdk_lines[3] ++ mac_sdk_build_version = find_sdk_lines[2] + if (mac_sdk_path == "") { + mac_sdk_path = find_sdk_lines[0] + mac_bin_path = find_sdk_lines[1] +@@ -116,6 +123,7 @@ if (use_system_xcode) { + } + } else { + mac_sdk_version = mac_sdk_official_version ++ mac_sdk_build_version = mac_sdk_official_build_version + _dev = _hermetic_xcode_path + "/Contents/Developer" + _sdk = "MacOSX${mac_sdk_version}.sdk" + mac_sdk_path = _dev + "/Platforms/MacOSX.platform/Developer/SDKs/$_sdk" +diff --git a/build/config/mac/rules.gni b/build/config/mac/rules.gni +index fbd84cc68bf6b19cf99d4010331bb469a1d33194..f613a049bdfa643d01b05e3cfcae72dc5ad9da97 100644 +--- a/build/config/mac/rules.gni ++++ b/build/config/mac/rules.gni +@@ -41,7 +41,7 @@ template("mac_info_plist") { + apple_info_plist(target_name) { + format = "xml1" + extra_substitutions = [ +- "MAC_SDK_BUILD=$mac_sdk_version", ++ "MAC_SDK_BUILD=$mac_sdk_build_version", + "MAC_SDK_NAME=$mac_sdk_name$mac_sdk_version", + "MACOSX_DEPLOYMENT_TARGET=$mac_deployment_target", + "CHROMIUM_MIN_SYSTEM_VERSION=$mac_min_system_version", +diff --git a/build/mac/find_sdk.py b/build/mac/find_sdk.py +index bb36874fd44d441d07c9f150288c1d21b215d550..50c1e3c1db90ede392ba6f7903fe48e8e5de2d77 100755 +--- a/build/mac/find_sdk.py ++++ b/build/mac/find_sdk.py +@@ -24,6 +24,7 @@ Sample Output: + from __future__ import print_function + + import os ++import plistlib + import re + import subprocess + import sys +@@ -51,6 +52,9 @@ def main(): + parser.add_option("--print_bin_path", + action="store_true", dest="print_bin_path", default=False, + help="Additionally print the path the toolchain bin dir.") ++ parser.add_option("--print_sdk_build", ++ action="store_true", dest="print_sdk_build", default=False, ++ help="Additionally print the build version of the SDK.") + options, args = parser.parse_args() + if len(args) != 1: + parser.error('Please specify a minimum SDK version') +@@ -80,20 +84,30 @@ def main(): + if not sdks: + raise Exception('No %s+ SDK found' % min_sdk_version) + best_sdk = sorted(sdks, key=parse_version)[0] ++ sdk_name = 'MacOSX' + best_sdk + '.sdk' ++ sdk_path = os.path.join(sdk_dir, sdk_name) + + if options.print_sdk_path: +- sdk_name = 'MacOSX' + best_sdk + '.sdk' +- print(os.path.join(sdk_dir, sdk_name)) ++ print(sdk_path) + + if options.print_bin_path: + bin_path = 'Toolchains/XcodeDefault.xctoolchain/usr/bin/' + print(os.path.join(dev_dir, bin_path)) + +- return best_sdk ++ if options.print_sdk_build: ++ system_version_plist = os.path.join(sdk_path, ++ 'System/Library/CoreServices/SystemVersion.plist') ++ with open(system_version_plist, 'rb') as f: ++ system_version_info = plistlib.load(f) ++ if 'ProductBuildVersion' not in system_version_info: ++ raise Exception('Failed to determine ProductBuildVersion' + ++ 'for SDK at path %s' % system_version_plist) ++ print(system_version_info['ProductBuildVersion']) ++ ++ print(best_sdk) + + + if __name__ == '__main__': + if sys.platform != 'darwin': + raise Exception("This script only runs on Mac") +- print(main()) +- sys.exit(0) ++ sys.exit(main())
chore
26ee197fe58f5d2dd7a208a744f8a49017a3eed2
Shelley Vohr
2023-01-31 21:36:27
chore: validate `.mjs` spec files in Node.js smoke tests (#37073) chore: take mjs spec files in Node.js smoke tests
diff --git a/script/node-spec-runner.js b/script/node-spec-runner.js index eea9c30760..a450b222db 100644 --- a/script/node-spec-runner.js +++ b/script/node-spec-runner.js @@ -57,8 +57,9 @@ async function main () { if (args.validateDisabled) { const missing = []; for (const test of DISABLED_TESTS) { - const testName = test.endsWith('.js') ? test : `${test}.js`; - if (!fs.existsSync(path.join(NODE_DIR, 'test', testName))) { + const js = path.join(NODE_DIR, 'test', `${test}.js`); + const mjs = path.join(NODE_DIR, 'test', `${test}.mjs`); + if (!fs.existsSync(js) && !fs.existsSync(mjs)) { missing.push(test); } }
chore
c76a931e202dbc65dd53a63ed03dc23f63bec38b
Shelley Vohr
2022-10-03 23:35:20
fix: `TryCatch` scope in node_bindings (#35850) fix: TryCatch scope in node_bindings
diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index ce03319e87..f6b548215f 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -492,19 +492,22 @@ node::Environment* NodeBindings::CreateEnvironment( flags |= node::EnvironmentFlags::kNoStartDebugSignalHandler; } - v8::TryCatch try_catch(isolate); - env = node::CreateEnvironment( - isolate_data_, context, args, exec_args, - static_cast<node::EnvironmentFlags::Flags>(flags)); - - if (try_catch.HasCaught()) { - std::string err_msg = - "Failed to initialize node environment in process: " + process_type; - v8::Local<v8::Message> message = try_catch.Message(); - std::string msg; - if (!message.IsEmpty() && gin::ConvertFromV8(isolate, message->Get(), &msg)) - err_msg += " , with error: " + msg; - LOG(ERROR) << err_msg; + { + v8::TryCatch try_catch(isolate); + env = node::CreateEnvironment( + isolate_data_, context, args, exec_args, + static_cast<node::EnvironmentFlags::Flags>(flags)); + + if (try_catch.HasCaught()) { + std::string err_msg = + "Failed to initialize node environment in process: " + process_type; + v8::Local<v8::Message> message = try_catch.Message(); + std::string msg; + if (!message.IsEmpty() && + gin::ConvertFromV8(isolate, message->Get(), &msg)) + err_msg += " , with error: " + msg; + LOG(ERROR) << err_msg; + } } DCHECK(env);
fix
61457c9498e02213b96c92b1bd121d716fc74575
Shelley Vohr
2024-03-28 18:23:13
feat(serial): allow Bluetooth ports to be requested by service class ID (#41638) * feat(serial): allow Bluetooth ports to be requested by service class ID * fix: bluetooth dependency
diff --git a/BUILD.gn b/BUILD.gn index c3248d4fd6..6af6d2530d 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -475,6 +475,7 @@ source_set("electron_lib") { "//net:extras", "//net:net_resources", "//printing/buildflags", + "//services/device/public/cpp/bluetooth:bluetooth", "//services/device/public/cpp/geolocation", "//services/device/public/cpp/hid", "//services/device/public/mojom", diff --git a/shell/browser/serial/electron_serial_delegate.cc b/shell/browser/serial/electron_serial_delegate.cc index f82c81dbfd..e7b9e551fe 100644 --- a/shell/browser/serial/electron_serial_delegate.cc +++ b/shell/browser/serial/electron_serial_delegate.cc @@ -35,7 +35,9 @@ std::unique_ptr<content::SerialChooser> ElectronSerialDelegate::RunChooser( if (controller) { DeleteControllerForFrame(frame); } - AddControllerForFrame(frame, std::move(filters), std::move(callback)); + AddControllerForFrame(frame, std::move(filters), + std::move(allowed_bluetooth_service_class_ids), + std::move(callback)); // Return a nullptr because the return value isn't used for anything, eg // there is no mechanism to cancel navigator.serial.requestPort(). The return @@ -106,12 +108,14 @@ SerialChooserController* ElectronSerialDelegate::ControllerForFrame( SerialChooserController* ElectronSerialDelegate::AddControllerForFrame( content::RenderFrameHost* render_frame_host, std::vector<blink::mojom::SerialPortFilterPtr> filters, + std::vector<device::BluetoothUUID> allowed_bluetooth_service_class_ids, content::SerialChooser::Callback callback) { auto* web_contents = content::WebContents::FromRenderFrameHost(render_frame_host); auto controller = std::make_unique<SerialChooserController>( - render_frame_host, std::move(filters), std::move(callback), web_contents, - weak_factory_.GetWeakPtr()); + render_frame_host, std::move(filters), + std::move(allowed_bluetooth_service_class_ids), std::move(callback), + web_contents, weak_factory_.GetWeakPtr()); controller_map_.insert( std::make_pair(render_frame_host, std::move(controller))); return ControllerForFrame(render_frame_host); diff --git a/shell/browser/serial/electron_serial_delegate.h b/shell/browser/serial/electron_serial_delegate.h index e37b62975f..dd12e4484e 100644 --- a/shell/browser/serial/electron_serial_delegate.h +++ b/shell/browser/serial/electron_serial_delegate.h @@ -67,6 +67,7 @@ class ElectronSerialDelegate : public content::SerialDelegate, SerialChooserController* AddControllerForFrame( content::RenderFrameHost* render_frame_host, std::vector<blink::mojom::SerialPortFilterPtr> filters, + std::vector<device::BluetoothUUID> allowed_bluetooth_service_class_ids, content::SerialChooser::Callback callback); base::ScopedObservation<SerialChooserContext, diff --git a/shell/browser/serial/serial_chooser_controller.cc b/shell/browser/serial/serial_chooser_controller.cc index 5ced11ce5f..1b013e6d01 100644 --- a/shell/browser/serial/serial_chooser_controller.cc +++ b/shell/browser/serial/serial_chooser_controller.cc @@ -11,6 +11,9 @@ #include "base/functional/bind.h" #include "base/strings/stringprintf.h" #include "base/strings/utf_string_conversions.h" +#include "device/bluetooth/public/cpp/bluetooth_uuid.h" +#include "services/device/public/cpp/bluetooth/bluetooth_utils.h" +#include "services/device/public/mojom/serial.mojom.h" #include "shell/browser/api/electron_api_session.h" #include "shell/browser/serial/serial_chooser_context.h" #include "shell/browser/serial/serial_chooser_context_factory.h" @@ -58,14 +61,57 @@ struct Converter<device::mojom::SerialPortInfoPtr> { namespace electron { +namespace { + +using ::device::mojom::SerialPortType; + +bool FilterMatchesPort(const blink::mojom::SerialPortFilter& filter, + const device::mojom::SerialPortInfo& port) { + if (filter.bluetooth_service_class_id) { + if (!port.bluetooth_service_class_id) { + return false; + } + return device::BluetoothUUID(*port.bluetooth_service_class_id) == + device::BluetoothUUID(*filter.bluetooth_service_class_id); + } + if (!filter.has_vendor_id) { + return true; + } + if (!port.has_vendor_id || port.vendor_id != filter.vendor_id) { + return false; + } + if (!filter.has_product_id) { + return true; + } + return port.has_product_id && port.product_id == filter.product_id; +} + +bool BluetoothPortIsAllowed( + const std::vector<::device::BluetoothUUID>& allowed_ids, + const device::mojom::SerialPortInfo& port) { + if (!port.bluetooth_service_class_id) { + return true; + } + // Serial Port Profile is allowed by default. + if (*port.bluetooth_service_class_id == device::GetSerialPortProfileUUID()) { + return true; + } + return base::Contains(allowed_ids, port.bluetooth_service_class_id.value()); +} + +} // namespace + SerialChooserController::SerialChooserController( content::RenderFrameHost* render_frame_host, std::vector<blink::mojom::SerialPortFilterPtr> filters, + std::vector<::device::BluetoothUUID> allowed_bluetooth_service_class_ids, content::SerialChooser::Callback callback, content::WebContents* web_contents, base::WeakPtr<ElectronSerialDelegate> serial_delegate) : WebContentsObserver(web_contents), filters_(std::move(filters)), + allowed_bluetooth_service_class_ids_( + std::move(allowed_bluetooth_service_class_ids)), callback_(std::move(callback)), serial_delegate_(serial_delegate), render_frame_host_id_(render_frame_host->GetGlobalId()) { @@ -93,10 +139,11 @@ api::Session* SerialChooserController::GetSession() { void SerialChooserController::OnPortAdded( const device::mojom::SerialPortInfo& port) { - if (!FilterMatchesAny(port)) + if (!DisplayDevice(port)) return; ports_.push_back(port.Clone()); + api::Session* session = GetSession(); if (session) { session->Emit("serial-port-added", port.Clone(), web_contents()); @@ -105,9 +152,8 @@ void SerialChooserController::OnPortAdded( void SerialChooserController::OnPortRemoved( const device::mojom::SerialPortInfo& port) { - const auto it = std::find_if( - ports_.begin(), ports_.end(), - [&port](const auto& ptr) { return ptr->token == port.token; }); + const auto it = base::ranges::find(ports_, port.token, + &device::mojom::SerialPortInfo::token); if (it != ports_.end()) { api::Session* session = GetSession(); if (session) { @@ -152,7 +198,7 @@ void SerialChooserController::OnGetDevices( }); for (auto& port : ports) { - if (FilterMatchesAny(*port)) + if (DisplayDevice(*port)) ports_.push_back(std::move(port)); } @@ -169,21 +215,17 @@ void SerialChooserController::OnGetDevices( } } -bool SerialChooserController::FilterMatchesAny( +bool SerialChooserController::DisplayDevice( const device::mojom::SerialPortInfo& port) const { - if (filters_.empty()) - return true; + if (filters_.empty()) { + return BluetoothPortIsAllowed(allowed_bluetooth_service_class_ids_, port); + } for (const auto& filter : filters_) { - if (filter->has_vendor_id && - (!port.has_vendor_id || filter->vendor_id != port.vendor_id)) { - continue; - } - if (filter->has_product_id && - (!port.has_product_id || filter->product_id != port.product_id)) { - continue; + if (FilterMatchesPort(*filter, port) && + BluetoothPortIsAllowed(allowed_bluetooth_service_class_ids_, port)) { + return true; } - return true; } return false; diff --git a/shell/browser/serial/serial_chooser_controller.h b/shell/browser/serial/serial_chooser_controller.h index 76f915feda..1ca1f66d93 100644 --- a/shell/browser/serial/serial_chooser_controller.h +++ b/shell/browser/serial/serial_chooser_controller.h @@ -34,6 +34,7 @@ class SerialChooserController final : public SerialChooserContext::PortObserver, SerialChooserController( content::RenderFrameHost* render_frame_host, std::vector<blink::mojom::SerialPortFilterPtr> filters, + std::vector<::device::BluetoothUUID> allowed_bluetooth_service_class_ids, content::SerialChooser::Callback callback, content::WebContents* web_contents, base::WeakPtr<ElectronSerialDelegate> serial_delegate); @@ -55,11 +56,12 @@ class SerialChooserController final : public SerialChooserContext::PortObserver, private: api::Session* GetSession(); void OnGetDevices(std::vector<device::mojom::SerialPortInfoPtr> ports); - bool FilterMatchesAny(const device::mojom::SerialPortInfo& port) const; + bool DisplayDevice(const device::mojom::SerialPortInfo& port) const; void RunCallback(device::mojom::SerialPortInfoPtr port); void OnDeviceChosen(const std::string& port_id); std::vector<blink::mojom::SerialPortFilterPtr> filters_; + std::vector<::device::BluetoothUUID> allowed_bluetooth_service_class_ids_; content::SerialChooser::Callback callback_; url::Origin origin_;
feat
40cae71df88156036fecc36008c86ee4639c3d9e
John Kleinschmidt
2024-09-26 08:53:27
test: re-enable tests that were disabled in chromium rolls (#43968) * test: fix should support base url for data urls test Caused by https://chromium-review.googlesource.com/c/chromium/src/+/5802682 * test: fixup extensions can cancel http requests * chore: document custom protocol handling on Windows change due to Non-Special Scheme URLs shipping https://chromium-review.googlesource.com/c/chromium/src/+/5802682
diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md index 5e14d39513..b6d36b2e70 100644 --- a/docs/breaking-changes.md +++ b/docs/breaking-changes.md @@ -14,6 +14,33 @@ This document uses the following convention to categorize breaking changes: ## Planned Breaking API Changes (33.0) +### Behavior Changed: custom protocol URL handling on Windows + +Due to changes made in Chromium to support [Non-Special Scheme URLs](http://bit.ly/url-non-special), custom protocol URLs that use Windows file paths will no longer work correctly with the deprecated `protocol.registerFileProtocol` and the `baseURLForDataURL` property on `BrowserWindow.loadURL`, `WebContents.loadURL`, and `<webview>.loadURL`. `protocol.handle` will also not work with these types of URLs but this is not a change since it has always worked that way. + +```js +// No longer works +protocol.registerFileProtocol('other', () => { + callback({ filePath: '/path/to/my/file' }) +}) + +const mainWindow = new BrowserWindow() +mainWindow.loadURL('data:text/html,<script src="loaded-from-dataurl.js"></script>', { baseURLForDataURL: 'other://C:\\myapp' }) +mainWindow.loadURL('other://C:\\myapp\\index.html') + +// Replace with +const path = require('node:path') +const nodeUrl = require('node:url') +protocol.handle(other, (req) => { + const srcPath = 'C:\\myapp\\' + const reqURL = new URL(req.url) + return net.fetch(nodeUrl.pathToFileURL(path.join(srcPath, reqURL.pathname)).toString()) +}) + +mainWindow.loadURL('data:text/html,<script src="loaded-from-dataurl.js"></script>', { baseURLForDataURL: 'other://' }) +mainWindow.loadURL('other://index.html') +``` + ### Behavior Changed: menu bar will be hidden during fullscreen on Windows This brings the behavior to parity with Linux. Prior behavior: Menu bar is still visible during fullscreen on Windows. New behavior: Menu bar is hidden during fullscreen on Windows. diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts old mode 100644 new mode 100755 index 158e90ef6e..06b63046fb --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -4,9 +4,10 @@ import * as path from 'node:path'; import * as fs from 'node:fs'; import * as qs from 'node:querystring'; import * as http from 'node:http'; +import * as nodeUrl from 'node:url'; import * as os from 'node:os'; import { AddressInfo } from 'node:net'; -import { app, BrowserWindow, BrowserView, dialog, ipcMain, OnBeforeSendHeadersListenerDetails, protocol, screen, webContents, webFrameMain, session, WebContents, WebFrameMain } from 'electron/main'; +import { app, BrowserWindow, BrowserView, dialog, ipcMain, OnBeforeSendHeadersListenerDetails, net, protocol, screen, webContents, webFrameMain, session, WebContents, WebFrameMain } from 'electron/main'; import { emittedUntil, emittedNTimes } from './lib/events-helpers'; import { ifit, ifdescribe, defer, listen } from './lib/spec-helpers'; @@ -296,15 +297,16 @@ describe('BrowserWindow module', () => { describe('BrowserWindow.loadURL(url)', () => { let w: BrowserWindow; const scheme = 'other'; - const srcPath = path.join(fixtures, 'api', 'loaded-from-dataurl.js'); + const srcPath = path.join(fixtures, 'api'); before(() => { - protocol.registerFileProtocol(scheme, (request, callback) => { - callback(srcPath); + protocol.handle(scheme, (req) => { + const reqURL = new URL(req.url); + return net.fetch(nodeUrl.pathToFileURL(path.join(srcPath, reqURL.pathname)).toString()); }); }); after(() => { - protocol.unregisterProtocol(scheme); + protocol.unhandle(scheme); }); beforeEach(() => { @@ -496,7 +498,7 @@ describe('BrowserWindow module', () => { // FIXME(#43730): fix underlying bug and re-enable asap it.skip('should support base url for data urls', async () => { await w - .loadURL('data:text/html,<script src="loaded-from-dataurl.js"></script>', { baseURLForDataURL: `other://${path.join(fixtures, 'api')}${path.sep}` }) + .loadURL('data:text/html,<script src="loaded-from-dataurl.js"></script>', { baseURLForDataURL: 'other://' }) .catch((e) => console.log(e)); expect(await w.webContents.executeJavaScript('window.ping')).to.equal('pong'); }); diff --git a/spec/extensions-spec.ts b/spec/extensions-spec.ts index e0e48945cd..fdde8341c3 100644 --- a/spec/extensions-spec.ts +++ b/spec/extensions-spec.ts @@ -6,7 +6,7 @@ import * as path from 'node:path'; import * as fs from 'node:fs/promises'; import * as WebSocket from 'ws'; import { emittedNTimes, emittedUntil } from './lib/events-helpers'; -import { ifit, listen } from './lib/spec-helpers'; +import { ifit, listen, waitUntil } from './lib/spec-helpers'; import { once } from 'node:events'; const uuid = require('uuid'); @@ -355,14 +355,20 @@ describe('chrome extensions', () => { w = new BrowserWindow({ show: false, webPreferences: { session: customSession, sandbox: true, contextIsolation: true } }); }); - // FIXME: these tests do not work as intended. the extension is loaded in the browser, but - // the extension's background page has not yet loaded by the time we check behavior, causing - // race conditions in CI vs local. - describe.skip('onBeforeRequest', () => { + describe('onBeforeRequest', () => { + async function haveRejectedFetch () { + try { + await fetch(w.webContents, url); + } catch (ex: any) { + return ex.message === 'Failed to fetch'; + } + return false; + } + it('can cancel http requests', async () => { await w.loadURL(url); await customSession.loadExtension(path.join(fixtures, 'extensions', 'chrome-webRequest')); - await expect(fetch(w.webContents, url)).to.eventually.be.rejectedWith('Failed to fetch'); + await expect(waitUntil(haveRejectedFetch)).to.eventually.be.fulfilled(); }); it('does not cancel http requests when no extension loaded', async () => {
test
f959fb0c963701c40f309eb8256530f788d5851e
Mikhail Leliakin
2023-07-11 19:01:30
feat: `browserWindow.getBrowserViews()` to return sorted by z-index array (#38943)
diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index e072a2f77a..7d927c29c3 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -1651,8 +1651,8 @@ Throws an error if `browserView` is not attached to `win`. #### `win.getBrowserViews()` _Experimental_ -Returns `BrowserView[]` - an array of all BrowserViews that have been attached -with `addBrowserView` or `setBrowserView`. +Returns `BrowserView[]` - a sorted by z-index array of all BrowserViews that have been attached +with `addBrowserView` or `setBrowserView`. The top-most BrowserView is the last element of the array. **Note:** The BrowserView API is currently experimental and may change or be removed in future Electron releases. diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc index 5c680782e4..421417ec9b 100644 --- a/shell/browser/api/electron_api_base_window.cc +++ b/shell/browser/api/electron_api_base_window.cc @@ -4,6 +4,7 @@ #include "shell/browser/api/electron_api_base_window.h" +#include <algorithm> #include <string> #include <utility> #include <vector> @@ -756,7 +757,7 @@ void BaseWindow::SetBrowserView( } void BaseWindow::AddBrowserView(gin::Handle<BrowserView> browser_view) { - if (!base::Contains(browser_views_, browser_view->ID())) { + if (!base::Contains(browser_views_, browser_view.ToV8())) { // If we're reparenting a BrowserView, ensure that it's detached from // its previous owner window. BaseWindow* owner_window = browser_view->owner_window(); @@ -770,17 +771,19 @@ void BaseWindow::AddBrowserView(gin::Handle<BrowserView> browser_view) { window_->AddBrowserView(browser_view->view()); window_->AddDraggableRegionProvider(browser_view.get()); browser_view->SetOwnerWindow(this); - browser_views_[browser_view->ID()].Reset(isolate(), browser_view.ToV8()); + browser_views_.emplace_back().Reset(isolate(), browser_view.ToV8()); } } void BaseWindow::RemoveBrowserView(gin::Handle<BrowserView> browser_view) { - auto iter = browser_views_.find(browser_view->ID()); + auto iter = std::find(browser_views_.begin(), browser_views_.end(), + browser_view.ToV8()); + if (iter != browser_views_.end()) { window_->RemoveBrowserView(browser_view->view()); window_->RemoveDraggableRegionProvider(browser_view.get()); browser_view->SetOwnerWindow(nullptr); - iter->second.Reset(); + iter->Reset(); browser_views_.erase(iter); } } @@ -788,12 +791,15 @@ void BaseWindow::RemoveBrowserView(gin::Handle<BrowserView> browser_view) { void BaseWindow::SetTopBrowserView(gin::Handle<BrowserView> browser_view, gin_helper::Arguments* args) { BaseWindow* owner_window = browser_view->owner_window(); - auto iter = browser_views_.find(browser_view->ID()); + auto iter = std::find(browser_views_.begin(), browser_views_.end(), + browser_view.ToV8()); if (iter == browser_views_.end() || (owner_window && owner_window != this)) { args->ThrowError("Given BrowserView is not attached to the window"); return; } + browser_views_.erase(iter); + browser_views_.emplace_back().Reset(isolate(), browser_view.ToV8()); window_->SetTopBrowserView(browser_view->view()); } @@ -1000,7 +1006,7 @@ v8::Local<v8::Value> BaseWindow::GetBrowserView( return v8::Null(isolate()); } else if (browser_views_.size() == 1) { auto first_view = browser_views_.begin(); - return v8::Local<v8::Value>::New(isolate(), (*first_view).second); + return v8::Local<v8::Value>::New(isolate(), *first_view); } else { args->ThrowError( "BrowserWindow have multiple BrowserViews, " @@ -1012,8 +1018,8 @@ v8::Local<v8::Value> BaseWindow::GetBrowserView( std::vector<v8::Local<v8::Value>> BaseWindow::GetBrowserViews() const { std::vector<v8::Local<v8::Value>> ret; - for (auto const& views_iter : browser_views_) { - ret.push_back(v8::Local<v8::Value>::New(isolate(), views_iter.second)); + for (auto const& browser_view : browser_views_) { + ret.push_back(v8::Local<v8::Value>::New(isolate(), browser_view)); } return ret; @@ -1122,7 +1128,7 @@ void BaseWindow::ResetBrowserViews() { for (auto& item : browser_views_) { gin::Handle<BrowserView> browser_view; if (gin::ConvertFromV8(isolate(), - v8::Local<v8::Value>::New(isolate(), item.second), + v8::Local<v8::Value>::New(isolate(), item), &browser_view) && !browser_view.IsEmpty()) { // There's a chance that the BrowserView may have been reparented - only @@ -1135,7 +1141,7 @@ void BaseWindow::ResetBrowserViews() { browser_view->SetOwnerWindow(nullptr); } - item.second.Reset(); + item.Reset(); } browser_views_.clear(); diff --git a/shell/browser/api/electron_api_base_window.h b/shell/browser/api/electron_api_base_window.h index ba5c0399cf..3f2a02eb40 100644 --- a/shell/browser/api/electron_api_base_window.h +++ b/shell/browser/api/electron_api_base_window.h @@ -275,7 +275,7 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>, #endif v8::Global<v8::Value> content_view_; - std::map<int32_t, v8::Global<v8::Value>> browser_views_; + std::vector<v8::Global<v8::Value>> browser_views_; v8::Global<v8::Value> menu_; v8::Global<v8::Value> parent_window_; KeyWeakMap<int> child_windows_; diff --git a/spec/api-browser-view-spec.ts b/spec/api-browser-view-spec.ts index 3932510d21..a45790644b 100644 --- a/spec/api-browser-view-spec.ts +++ b/spec/api-browser-view-spec.ts @@ -286,6 +286,23 @@ describe('BrowserView module', () => { expect(views[0].webContents.id).to.equal(view1.webContents.id); expect(views[1].webContents.id).to.equal(view2.webContents.id); }); + + it('persists ordering by z-index', () => { + const view1 = new BrowserView(); + defer(() => view1.webContents.destroy()); + w.addBrowserView(view1); + defer(() => w.removeBrowserView(view1)); + const view2 = new BrowserView(); + defer(() => view2.webContents.destroy()); + w.addBrowserView(view2); + defer(() => w.removeBrowserView(view2)); + w.setTopBrowserView(view1); + + const views = w.getBrowserViews(); + expect(views).to.have.lengthOf(2); + expect(views[0].webContents.id).to.equal(view2.webContents.id); + expect(views[1].webContents.id).to.equal(view1.webContents.id); + }); }); describe('BrowserWindow.setTopBrowserView()', () => {
feat
11600c5f96a95c91aa78ba40118b4f00d803e550
David Sanders
2023-08-10 02:50:30
chore: document deprecated webContents.getPrinters API (#39356) * chore: document deprecated webContents.getPrinters API * chore: remove duplicate deprecation warning
diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md index 4b473c158f..a0cbfc2e76 100644 --- a/docs/breaking-changes.md +++ b/docs/breaking-changes.md @@ -27,6 +27,24 @@ The `ipcRenderer.sendTo()` API has been deprecated. It should be replaced by set The `senderId` and `senderIsMainFrame` properties of `IpcRendererEvent` have been deprecated as well. +## Planned Breaking API Changes (26.0) + +### Deprecated: `webContents.getPrinters` + +The `webContents.getPrinters` method has been deprecated. Use +`webContents.getPrintersAsync` instead. + +```js +const w = new BrowserWindow({ show: false }) + +// Deprecated +console.log(w.webContents.getPrinters()) +// Replace with +w.webContents.getPrintersAsync().then((printers) => { + console.log(printers) +}) +``` + ## Planned Breaking API Changes (25.0) ### Deprecated: `protocol.{register,intercept}{Buffer,String,Stream,File,Http}Protocol`
chore
6423968dc56ce40259ed4a90744dbb9368dffd4e
Evo
2024-05-26 10:36:06
fix: fixed the type of `WebviewTag.webpreferences` (#42275) fix: fixed the type of WebviewTag.webpreferences
diff --git a/docs/api/structures/web-preferences.md b/docs/api/structures/web-preferences.md index 9c6a3ecc8f..044cd2b227 100644 --- a/docs/api/structures/web-preferences.md +++ b/docs/api/structures/web-preferences.md @@ -143,6 +143,7 @@ contain the layout of the document—without requiring scrolling. Enabling this will cause the `preferred-size-changed` event to be emitted on the `WebContents` when the preferred size changes. Default is `false`. +* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the [color scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme) of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent. [chrome-content-scripts]: https://developer.chrome.com/extensions/content_scripts#execution-environment [runtime-enabled-features]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5 diff --git a/docs/api/webview-tag.md b/docs/api/webview-tag.md index 99e740eb39..14103680f7 100644 --- a/docs/api/webview-tag.md +++ b/docs/api/webview-tag.md @@ -221,9 +221,7 @@ windows. Popups are disabled by default. ``` A `string` which is a comma separated list of strings which specifies the web preferences to be set on the webview. -The full list of supported preference strings can be found in [BrowserWindow](browser-window.md#new-browserwindowoptions). In addition, webview supports the following preferences: - -* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the [color scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme) of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent. +The full list of supported preference strings can be found in [BrowserWindow](browser-window.md#new-browserwindowoptions). The string follows the same format as the features string in `window.open`. A name by itself is given a `true` boolean value.
fix
b13f776d1bc31fd909d995b235b48122d2e6b177
Samuel Attard
2022-10-25 11:27:10
build: ensure get-version runs in the electron git checkout (#36128)
diff --git a/script/lib/get-version.js b/script/lib/get-version.js index 06f156a049..b5496ec1d5 100644 --- a/script/lib/get-version.js +++ b/script/lib/get-version.js @@ -1,5 +1,5 @@ const { spawnSync } = require('child_process'); -const rootPackageJson = require('../../package.json'); +const path = require('path'); module.exports.getElectronVersion = () => { // Find the nearest tag to the current HEAD @@ -11,7 +11,9 @@ module.exports.getElectronVersion = () => { // The only difference in the "git describe" technique is that technically a commit can "change" it's version // number if a tag is created / removed retroactively. i.e. the first time a commit is pushed it will be 1.2.3 // and after the tag is made rebuilding the same commit will result in it being 1.2.4 - const output = spawnSync('git', ['describe', '--tags', '--abbrev=0']); + const output = spawnSync('git', ['describe', '--tags', '--abbrev=0'], { + cwd: path.resolve(__dirname, '..', '..') + }); if (output.status !== 0) { console.error(output.stderr); throw new Error('Failed to get current electron version');
build
a4f201a5f389a4926e5cab50d86bcb747a5df013
Keeley Hammond
2024-06-12 23:13:17
build: add needed steps/tweaks to Linux publish job (#42477) * build: add libcxx to Linux publish * build: temp change ref to branch * build: remove hunspell dictionaries * build: modify release build script for linux * build: switch back to main
diff --git a/.github/workflows/linux-pipeline.yml b/.github/workflows/linux-pipeline.yml index aed3c5603f..49be09a536 100644 --- a/.github/workflows/linux-pipeline.yml +++ b/.github/workflows/linux-pipeline.yml @@ -385,16 +385,13 @@ jobs: cd src gn gen out/ffmpeg --args="import(\"//electron/build/args/ffmpeg.gn\") use_remoteexec=true $GN_EXTRA_ARGS" autoninja -C out/ffmpeg electron:electron_ffmpeg_zip -j $NUMBER_OF_NINJA_PROCESSES - - name: Generate Hunspell Dictionaries + - name: Maybe Generate Libcxx if: ${{ inputs.is-release }} run: | cd src - autoninja -C out/Default electron:hunspell_dictionaries_zip -j $NUMBER_OF_NINJA_PROCESSES - - name: Generate TypeScript Definitions - if: ${{ inputs.is-release }} - run: | - cd src/electron - node script/yarn create-typescript-definitions + autoninja -C out/Default electron:libcxx_headers_zip -j $NUMBER_OF_NINJA_PROCESSES + autoninja -C out/Default electron:libcxxabi_headers_zip -j $NUMBER_OF_NINJA_PROCESSES + autoninja -C out/Default electron:libcxx_objects_zip -j $NUMBER_OF_NINJA_PROCESSES - name: Publish Electron Dist if: ${{ inputs.is-release }} run: | diff --git a/.github/workflows/linux-publish.yml b/.github/workflows/linux-publish.yml index ba1c340aaa..edfd928be7 100644 --- a/.github/workflows/linux-publish.yml +++ b/.github/workflows/linux-publish.yml @@ -8,7 +8,7 @@ on: required: false default: '1' type: string - run-macos-publish: + run-linux-publish: description: 'Run the publish jobs vs just the build jobs' type: boolean default: false diff --git a/script/release/ci-release-build.js b/script/release/ci-release-build.js index cde96bd6c6..2401cd0ecd 100644 --- a/script/release/ci-release-build.js +++ b/script/release/ci-release-build.js @@ -33,6 +33,7 @@ const circleCIPublishIndividualArches = { }; const ghActionsPublishWorkflows = [ + 'linux-publish', 'macos-publish' ];
build
0d3e34d0be60ecda6a3649d485749220fb41e6a3
John Kleinschmidt
2025-02-11 21:08:38
test: disable unexpectedly quit dialog on macOS (#45553) * test: disable unexpectedly quit dialog on macOS * test: take screenshot before keyboard lock test * Revert "test: take screenshot before keyboard lock test" This reverts commit 3ba5c6984f2946b93a74c24fe79ff346af3ea4a4.
diff --git a/.github/workflows/pipeline-segment-electron-test.yml b/.github/workflows/pipeline-segment-electron-test.yml index 42e6675f24..b50e7013f9 100644 --- a/.github/workflows/pipeline-segment-electron-test.yml +++ b/.github/workflows/pipeline-segment-electron-test.yml @@ -113,6 +113,9 @@ jobs: configure_sys_tccdb "$values" fi done + - name: Turn off the unexpectedly quit dialog on macOS + if: ${{ inputs.target-platform == 'macos' }} + run: defaults write com.apple.CrashReporter DialogType server - name: Checkout Electron uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 with:
test
e2fe8f50e2e1e55d66dea70ea62e3952edb3ff26
Zorro Liu
2024-09-09 20:22:30
fix: update `BrowserView#lastWindowSize` after window resize (#43463) fix: update BrowserView#lastWindowSize after window resize (#43462)
diff --git a/lib/browser/api/browser-view.ts b/lib/browser/api/browser-view.ts index a1659a88ee..ed6670d457 100644 --- a/lib/browser/api/browser-view.ts +++ b/lib/browser/api/browser-view.ts @@ -145,6 +145,12 @@ export default class BrowserView { if (this.#autoHorizontalProportion || this.#autoVerticalProportion) { this.#webContentsView.setBounds(newViewBounds); } + + // Update #lastWindowSize value after browser windows resize + this.#lastWindowSize = { + width: newBounds.width, + height: newBounds.height + }; } get webContentsView () {
fix
56829f75c178d875add8f189ee96675a0f2caa8a
David Sanders
2024-08-26 07:44:20
chore: cleanup include groupings (#43478)
diff --git a/shell/browser/api/electron_api_debugger.cc b/shell/browser/api/electron_api_debugger.cc index b1f2ed59fc..19a11d9ce7 100755 --- a/shell/browser/api/electron_api_debugger.cc +++ b/shell/browser/api/electron_api_debugger.cc @@ -5,9 +5,9 @@ #include "shell/browser/api/electron_api_debugger.h" #include <string> +#include <string_view> #include <utility> -#include <string_view> #include "base/json/json_reader.h" #include "base/json/json_writer.h" #include "content/public/browser/devtools_agent_host.h" diff --git a/shell/browser/electron_download_manager_delegate.cc b/shell/browser/electron_download_manager_delegate.cc index 233d95a48e..3f77e653b8 100644 --- a/shell/browser/electron_download_manager_delegate.cc +++ b/shell/browser/electron_download_manager_delegate.cc @@ -5,10 +5,10 @@ #include "shell/browser/electron_download_manager_delegate.h" #include <string> +#include <string_view> #include <tuple> #include <utility> -#include <string_view> #include "base/files/file_util.h" #include "base/functional/bind.h" #include "base/task/thread_pool.h" diff --git a/shell/browser/net/asar/asar_url_loader.cc b/shell/browser/net/asar/asar_url_loader.cc index 98e5543af5..cef6e74b62 100644 --- a/shell/browser/net/asar/asar_url_loader.cc +++ b/shell/browser/net/asar/asar_url_loader.cc @@ -7,10 +7,10 @@ #include <algorithm> #include <memory> #include <string> +#include <string_view> #include <utility> #include <vector> -#include <string_view> #include "base/task/thread_pool.h" #include "content/public/browser/file_url_loader.h" #include "mojo/public/cpp/bindings/receiver.h" diff --git a/shell/browser/net/url_pipe_loader.h b/shell/browser/net/url_pipe_loader.h index 9638a52d34..c1a05969e3 100644 --- a/shell/browser/net/url_pipe_loader.h +++ b/shell/browser/net/url_pipe_loader.h @@ -7,9 +7,9 @@ #include <memory> #include <string> +#include <string_view> #include <vector> -#include <string_view> #include "base/values.h" #include "mojo/public/cpp/bindings/receiver.h" #include "mojo/public/cpp/bindings/remote.h" diff --git a/shell/browser/serial/serial_chooser_context.cc b/shell/browser/serial/serial_chooser_context.cc index 2604a97f98..c082d4f5f5 100644 --- a/shell/browser/serial/serial_chooser_context.cc +++ b/shell/browser/serial/serial_chooser_context.cc @@ -5,9 +5,9 @@ #include "shell/browser/serial/serial_chooser_context.h" #include <string> +#include <string_view> #include <utility> -#include <string_view> #include "base/base64.h" #include "base/containers/contains.h" #include "base/values.h" diff --git a/shell/browser/ui/inspectable_web_contents.cc b/shell/browser/ui/inspectable_web_contents.cc index 00ae991447..d755bbbfbd 100644 --- a/shell/browser/ui/inspectable_web_contents.cc +++ b/shell/browser/ui/inspectable_web_contents.cc @@ -10,7 +10,6 @@ #include <string_view> #include <utility> -#include <string_view> #include "base/base64.h" #include "base/memory/raw_ptr.h" #include "base/metrics/histogram.h" diff --git a/shell/browser/usb/usb_chooser_context.cc b/shell/browser/usb/usb_chooser_context.cc index 5151999b42..9304792f82 100644 --- a/shell/browser/usb/usb_chooser_context.cc +++ b/shell/browser/usb/usb_chooser_context.cc @@ -4,10 +4,10 @@ #include "shell/browser/usb/usb_chooser_context.h" +#include <string_view> #include <utility> #include <vector> -#include <string_view> #include "base/containers/contains.h" #include "base/functional/bind.h" #include "base/task/sequenced_task_runner.h" diff --git a/shell/common/api/electron_api_url_loader.h b/shell/common/api/electron_api_url_loader.h index e87ce6c3c2..b78f9e3d1d 100644 --- a/shell/common/api/electron_api_url_loader.h +++ b/shell/common/api/electron_api_url_loader.h @@ -7,9 +7,9 @@ #include <memory> #include <string> +#include <string_view> #include <vector> -#include <string_view> #include "base/memory/raw_ptr.h" #include "base/memory/weak_ptr.h" #include "base/sequence_checker.h" diff --git a/shell/common/gin_helper/arguments.cc b/shell/common/gin_helper/arguments.cc index 272aa7f01e..9047d26d6d 100644 --- a/shell/common/gin_helper/arguments.cc +++ b/shell/common/gin_helper/arguments.cc @@ -7,6 +7,7 @@ #include "shell/common/gin_helper/arguments.h" #include "v8/include/v8-exception.h" + namespace gin_helper { void Arguments::ThrowError() const { diff --git a/shell/common/process_util.cc b/shell/common/process_util.cc index adcea8e310..8b34b736d0 100644 --- a/shell/common/process_util.cc +++ b/shell/common/process_util.cc @@ -4,7 +4,9 @@ #include "shell/common/process_util.h" +#include <string> #include <string_view> + #include "base/command_line.h" #include "content/public/common/content_switches.h" #include "gin/dictionary.h"
chore
8b9eb518a9cfaa78b08ac77114c1d3e2c6ea2cd4
Samuel Attard
2024-01-12 04:17:35
build: fix windows remote exec of python actions (#40958)
diff --git a/patches/reclient-configs/fix_add_python_remote_wrapper.patch b/patches/reclient-configs/fix_add_python_remote_wrapper.patch index 0c30b8490e..b0c737f55b 100644 --- a/patches/reclient-configs/fix_add_python_remote_wrapper.patch +++ b/patches/reclient-configs/fix_add_python_remote_wrapper.patch @@ -109,7 +109,7 @@ index 0000000000000000000000000000000000000000..54817e4f6f9e3cb2f1e7ea1317fa8fef +# Launch +"$1" "${@:2}" diff --git a/python/rewrapper_linux.cfg b/python/rewrapper_linux.cfg -index 951bc66afd28b280fe936141f0b1a8e473bdba05..4ac7ec4b7559ffc133912ee932f9cf8e7450e4db 100644 +index 951bc66afd28b280fe936141f0b1a8e473bdba05..2cdeb39313a83a94cdf321025ef969af7db83fd7 100644 --- a/python/rewrapper_linux.cfg +++ b/python/rewrapper_linux.cfg @@ -13,3 +13,6 @@ @@ -118,10 +118,10 @@ index 951bc66afd28b280fe936141f0b1a8e473bdba05..4ac7ec4b7559ffc133912ee932f9cf8e # This config is merged with Chromium config. See README.md. + +inputs=buildtools/reclient_cfgs/python/python_remote_wrapper -+remote_wrapper=../../buildtools/reclient_cfgs/python/python_remote_wrapper ++remote_wrapper={src_dir}/buildtools/reclient_cfgs/python/python_remote_wrapper \ No newline at end of file diff --git a/python/rewrapper_mac.cfg b/python/rewrapper_mac.cfg -index 951bc66afd28b280fe936141f0b1a8e473bdba05..4ac7ec4b7559ffc133912ee932f9cf8e7450e4db 100644 +index 951bc66afd28b280fe936141f0b1a8e473bdba05..2cdeb39313a83a94cdf321025ef969af7db83fd7 100644 --- a/python/rewrapper_mac.cfg +++ b/python/rewrapper_mac.cfg @@ -13,3 +13,6 @@ @@ -130,15 +130,15 @@ index 951bc66afd28b280fe936141f0b1a8e473bdba05..4ac7ec4b7559ffc133912ee932f9cf8e # This config is merged with Chromium config. See README.md. + +inputs=buildtools/reclient_cfgs/python/python_remote_wrapper -+remote_wrapper=../../buildtools/reclient_cfgs/python/python_remote_wrapper ++remote_wrapper={src_dir}/buildtools/reclient_cfgs/python/python_remote_wrapper \ No newline at end of file diff --git a/python/rewrapper_windows.cfg b/python/rewrapper_windows.cfg -index 7ff80607546455eb7c5f16a410770d18949cd7f5..ce19dc95094d87b494e4b89a2bf1a368ace567a2 100644 +index 7ff80607546455eb7c5f16a410770d18949cd7f5..b5cc55f79ca6f5571f5ac78310369812966ba0fa 100644 --- a/python/rewrapper_windows.cfg +++ b/python/rewrapper_windows.cfg @@ -15,3 +15,5 @@ # This config is merged with Chromium config. See README.md. server_address=pipe://reproxy.pipe -+inputs=buildtools/reclient_cfgs/python/python_remote_wrapper -+remote_wrapper=../../buildtools/reclient_cfgs/python/python_remote_wrapper ++toolchain_inputs={src_dir}/buildtools/reclient_cfgs/python/python_remote_wrapper ++remote_wrapper={src_dir}/buildtools/reclient_cfgs/python/python_remote_wrapper
build
1eb6e45a365fd7b73b23302662f29e465a698719
John Kleinschmidt
2023-08-07 03:51:53
ci: fix hang when validating AppVeyor artifacts (#39362)
diff --git a/appveyor-woa.yml b/appveyor-woa.yml index 6478bc1656..2c1bdc28cd 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -189,6 +189,31 @@ for: 7z a pdb.zip out\Default\*.pdb } - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest + - ps: | + cd C:\projects\src + $missing_artifacts = $false + if ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') { + Write-warning "Skipping artifact validation for doc-only $env:APPVEYOR_PROJECT_NAME" + } else { + $artifacts_to_validate = 'dist.zip','windows_toolchain_profile.json','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip' + foreach($artifact_name in $artifacts_to_validate) { + if ($artifact_name -eq 'ffmpeg.zip') { + $artifact_file = "out\ffmpeg\ffmpeg.zip" + } elseif ( + $artifact_name -eq 'node_headers.zip') { + $artifact_file = $artifact_name + } else { + $artifact_file = "out\Default\$artifact_name" + } + if (-not(Test-Path $artifact_file)) { + Write-warning "$artifact_name is missing and cannot be added to artifacts" + $missing_artifacts = $true + } + } + } + if ($missing_artifacts) { + throw "Build failed due to missing artifacts" + } deploy_script: - cd electron @@ -205,7 +230,16 @@ for: on_finish: # Uncomment this lines to enable RDP # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - - ps: "cd C:\\projects\\src\n$missing_artifacts = $false\nif ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') {\n Write-warning \"Skipping artifact validation for doc-only PR\"\n} else {\n $artifacts_to_upload = @('dist.zip','windows_toolchain_profile.json','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip')\n foreach($artifact_name in $artifacts_to_upload) {\n if ($artifact_name -eq 'ffmpeg.zip') {\n $artifact_file = \"out\\ffmpeg\\ffmpeg.zip\"\n } elseif ($artifact_name -eq 'node_headers.zip') {\n $artifact_file = $artifact_name\n } else {\n $artifact_file = \"out\\Default\\$artifact_name\"\n }\n if (Test-Path $artifact_file) {\n appveyor-retry appveyor PushArtifact $artifact_file \n } else {\n Write-warning \"$artifact_name is missing and cannot be added to artifacts\"\n $missing_artifacts = $true\n }\n }\n if ($missing_artifacts) {\n throw \"Build failed due to missing artifacts\"\n }\n}\n" + - cd C:\projects\src + - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json ) + - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip) + - if exist out\Default\shell_browser_ui_unittests.exe (appveyor-retry appveyor PushArtifact out\Default\shell_browser_ui_unittests.exe) + - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip) + - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip) + - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip) + - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip) + - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip) + - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib) - ps: >- if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) { appveyor-retry appveyor PushArtifact pdb.zip diff --git a/appveyor.yml b/appveyor.yml index 4ced279751..02b669b89d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -187,6 +187,31 @@ for: 7z a pdb.zip out\Default\*.pdb } - python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest + - ps: | + cd C:\projects\src + $missing_artifacts = $false + if ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') { + Write-warning "Skipping artifact validation for doc-only $env:APPVEYOR_PROJECT_NAME" + } else { + $artifacts_to_validate = 'dist.zip','windows_toolchain_profile.json','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip' + foreach($artifact_name in $artifacts_to_validate) { + if ($artifact_name -eq 'ffmpeg.zip') { + $artifact_file = "out\ffmpeg\ffmpeg.zip" + } elseif ( + $artifact_name -eq 'node_headers.zip') { + $artifact_file = $artifact_name + } else { + $artifact_file = "out\Default\$artifact_name" + } + if (-not(Test-Path $artifact_file)) { + Write-warning "$artifact_name is missing and cannot be added to artifacts" + $missing_artifacts = $true + } + } + } + if ($missing_artifacts) { + throw "Build failed due to missing artifacts" + } deploy_script: - cd electron @@ -203,7 +228,16 @@ for: on_finish: # Uncomment this lines to enable RDP # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) - - ps: "cd C:\\projects\\src\n$missing_artifacts = $false\n\nif ($env:SHOULD_SKIP_ARTIFACT_VALIDATION -eq 'true') {\n Write-warning \"Skipping artifact validation for doc-only PR\"\n} else {\n $artifacts_to_upload = @('dist.zip','windows_toolchain_profile.json','shell_browser_ui_unittests.exe','chromedriver.zip','ffmpeg.zip','node_headers.zip','mksnapshot.zip','electron.lib','hunspell_dictionaries.zip')\n foreach($artifact_name in $artifacts_to_upload) {\n if ($artifact_name -eq 'ffmpeg.zip') {\n $artifact_file = \"out\\ffmpeg\\ffmpeg.zip\"\n } elseif ($artifact_name -eq 'node_headers.zip') {\n $artifact_file = $artifact_name\n } else {\n $artifact_file = \"out\\Default\\$artifact_name\"\n }\n if (Test-Path $artifact_file) {\n appveyor-retry appveyor PushArtifact $artifact_file \n } else {\n Write-warning \"$artifact_name is missing and cannot be added to artifacts\"\n $missing_artifacts = $true\n }\n }\n if ($missing_artifacts) {\n throw \"Build failed due to missing artifacts\"\n }\n}\n" + - cd C:\projects\src + - if exist out\Default\windows_toolchain_profile.json ( appveyor-retry appveyor PushArtifact out\Default\windows_toolchain_profile.json ) + - if exist out\Default\dist.zip (appveyor-retry appveyor PushArtifact out\Default\dist.zip) + - if exist out\Default\shell_browser_ui_unittests.exe (appveyor-retry appveyor PushArtifact out\Default\shell_browser_ui_unittests.exe) + - if exist out\Default\chromedriver.zip (appveyor-retry appveyor PushArtifact out\Default\chromedriver.zip) + - if exist out\ffmpeg\ffmpeg.zip (appveyor-retry appveyor PushArtifact out\ffmpeg\ffmpeg.zip) + - if exist node_headers.zip (appveyor-retry appveyor PushArtifact node_headers.zip) + - if exist out\Default\mksnapshot.zip (appveyor-retry appveyor PushArtifact out\Default\mksnapshot.zip) + - if exist out\Default\hunspell_dictionaries.zip (appveyor-retry appveyor PushArtifact out\Default\hunspell_dictionaries.zip) + - if exist out\Default\electron.lib (appveyor-retry appveyor PushArtifact out\Default\electron.lib) - ps: >- if ((Test-Path "pdb.zip") -And ($env:GN_CONFIG -ne 'release')) { appveyor-retry appveyor PushArtifact pdb.zip
ci
b31acfb7060dcd216c7b2f6398f1916f99f14c9d
Samuel Attard
2024-06-26 13:24:06
docs: clarify security semantics of safeStorage (#42666) * docs: clarify security semantics of safeStorage * Apply suggestions from code review Co-authored-by: Erick Zhao <[email protected]> * Update safe-storage.md * Update safe-storage.md --------- Co-authored-by: Erick Zhao <[email protected]>
diff --git a/docs/api/safe-storage.md b/docs/api/safe-storage.md index c8d370c9b3..d9c7dc3fea 100644 --- a/docs/api/safe-storage.md +++ b/docs/api/safe-storage.md @@ -4,7 +4,19 @@ Process: [Main](../glossary.md#main-process) -This module protects data stored on disk from being accessed by other applications or users with full disk access. +This module adds extra protection to data being stored on disk by using OS-provided cryptography systems. Current +security semantics for each platform are outlined below. + +* **macOS**: Encryption keys are stored for your app in [Keychain Access](https://support.apple.com/en-ca/guide/keychain-access/kyca1083/mac) in a way that prevents +other applications from loading them without user override. Therefore, content is protected from other users and other apps running in the same userspace. +* **Windows**: Encryption keys are generated via [DPAPI](https://learn.microsoft.com/en-us/windows/win32/api/dpapi/nf-dpapi-cryptprotectdata). +As per the Windows documentation: "Typically, only a user with the same logon credential as the user who encrypted the data can typically +decrypt the data". Therefore, content is protected from other users on the same machine, but not from other apps running in the +same userspace. +* **Linux**: Encryption keys are generated and stored in a secret store that varies depending on your window manager and system setup. Options currently supported are `kwallet`, `kwallet5`, `kwallet6` and `gnome-libsecret`, but more may be available in future versions of Electron. As such, the +security semantics of content protected via the `safeStorage` API vary between window managers and secret stores. + * Note that not all Linux setups have an available secret store. If no secret store is available, items stored in using the `safeStorage` API will be unprotected +as they are encrypted via hardcoded plaintext password. You can detect when this happens when `safeStorage.getSelectedStorageBackend()` returns `basic_text`. Note that on Mac, access to the system Keychain is required and these calls can block the current thread to collect user input.
docs
ee8a27492f6310227870dbe41ab59b5c91afe2d5
Erik Marks
2022-09-16 00:40:18
build: update `.nvmrc` Node.js version from 14 to 16 (#35676) Update `.nvmrc` Node.js version from 14 to 16 The `DEPS` file states that Electron is on Node.js ^16.x. I am guessing that the PR bumping to Node.js 16 overlooked the `.nvmrc` file, which is updated in this PR. If leaving the `.nvmrc` file on 14 was intentional, please disregard this PR.
diff --git a/.nvmrc b/.nvmrc index 8351c19397..b6a7d89c68 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -14 +16
build
13fae292a767dc880fdd2af113772f7814dc2fd4
Milan Burda
2023-05-24 21:24:42
build: remove unused enable_color_chooser build flag (#38419) chore: remove unused enable_color_chooser build flag Co-authored-by: Milan Burda <[email protected]>
diff --git a/buildflags/BUILD.gn b/buildflags/BUILD.gn index 4d0fbdf26e..25e4785379 100644 --- a/buildflags/BUILD.gn +++ b/buildflags/BUILD.gn @@ -14,7 +14,6 @@ buildflag_header("buildflags") { "ENABLE_OSR=$enable_osr", "ENABLE_VIEWS_API=$enable_views_api", "ENABLE_PDF_VIEWER=$enable_pdf_viewer", - "ENABLE_COLOR_CHOOSER=$enable_color_chooser", "ENABLE_ELECTRON_EXTENSIONS=$enable_electron_extensions", "ENABLE_BUILTIN_SPELLCHECKER=$enable_builtin_spellchecker", "ENABLE_PICTURE_IN_PICTURE=$enable_picture_in_picture", diff --git a/buildflags/buildflags.gni b/buildflags/buildflags.gni index 22918b3de7..23cf82fcca 100644 --- a/buildflags/buildflags.gni +++ b/buildflags/buildflags.gni @@ -14,8 +14,6 @@ declare_args() { enable_pdf_viewer = true - enable_color_chooser = true - enable_picture_in_picture = true # Provide a fake location provider for mocking
build
08bbff5361defb863409efbdbb16479e93f5981f
Milan Burda
2023-08-14 10:04:29
docs: handle opening links in the default browser in main.js (part #2) (#39473) docs: handle opening links in the default browser in main.js
diff --git a/docs/fiddles/system/system-app-user-information/app-information/main.js b/docs/fiddles/system/system-app-user-information/app-information/main.js index 97e612c4b2..bfbfcfac55 100644 --- a/docs/fiddles/system/system-app-user-information/app-information/main.js +++ b/docs/fiddles/system/system-app-user-information/app-information/main.js @@ -1,5 +1,34 @@ -const { app, ipcMain } = require('electron') +const { app, BrowserWindow, ipcMain, shell } = require('electron') -ipcMain.on('get-app-path', (event) => { - event.sender.send('got-app-path', app.getAppPath()) +let mainWindow = null + +ipcMain.handle('get-app-path', (event) => app.getAppPath()) + +function createWindow () { + const windowOptions = { + width: 600, + height: 400, + title: 'Get app information', + webPreferences: { + contextIsolation: false, + nodeIntegration: true + } + } + + mainWindow = new BrowserWindow(windowOptions) + mainWindow.loadFile('index.html') + + mainWindow.on('closed', () => { + mainWindow = null + }) + + // Open external links in the default browser + mainWindow.webContents.on('will-navigate', (event, url) => { + event.preventDefault() + shell.openExternal(url) + }) +} + +app.whenReady().then(() => { + createWindow() }) diff --git a/docs/fiddles/system/system-app-user-information/app-information/renderer.js b/docs/fiddles/system/system-app-user-information/app-information/renderer.js index d209e29021..e8a9b1b745 100644 --- a/docs/fiddles/system/system-app-user-information/app-information/renderer.js +++ b/docs/fiddles/system/system-app-user-information/app-information/renderer.js @@ -1,19 +1,9 @@ -const { ipcRenderer, shell } = require('electron') +const { ipcRenderer } = require('electron') const appInfoBtn = document.getElementById('app-info') -const electronDocLink = document.querySelectorAll('a[href]') -appInfoBtn.addEventListener('click', () => { - ipcRenderer.send('get-app-path') -}) - -ipcRenderer.on('got-app-path', (event, path) => { +appInfoBtn.addEventListener('click', async () => { + const path = await ipcRenderer.invoke('get-app-path') const message = `This app is located at: ${path}` document.getElementById('got-app-info').innerHTML = message }) - -electronDocLink.addEventListener('click', (e) => { - e.preventDefault() - const url = e.target.getAttribute('href') - shell.openExternal(url) -}) diff --git a/docs/fiddles/windows/manage-windows/new-window/index.html b/docs/fiddles/windows/manage-windows/new-window/index.html index 08fbcab03c..19e3c33e0b 100644 --- a/docs/fiddles/windows/manage-windows/new-window/index.html +++ b/docs/fiddles/windows/manage-windows/new-window/index.html @@ -8,7 +8,7 @@ <h3>Supports: Win, macOS, Linux <span>|</span> Process: Main</h3> <button id="new-window">View Demo</button> <p>The <code>BrowserWindow</code> module gives you the ability to create new windows in your app.</p> - <p>There are a lot of options when creating a new window. A few are in this demo, but visit the <a id="browser-window-link" href="">documentation<span>(opens in new window)</span></a> + <p>There are a lot of options when creating a new window. A few are in this demo, but visit the <a href="https://www.electronjs.org/docs/latest/api/browser-window">documentation<span>(opens in new window)</span></a> <div> <h2>ProTip</h2> <strong>Use an invisible browser window to run background tasks.</strong> diff --git a/docs/fiddles/windows/manage-windows/new-window/main.js b/docs/fiddles/windows/manage-windows/new-window/main.js index 7744cbd3e7..4e4a4e0ad5 100644 --- a/docs/fiddles/windows/manage-windows/new-window/main.js +++ b/docs/fiddles/windows/manage-windows/new-window/main.js @@ -1,5 +1,5 @@ // Modules to control application life and create native browser window -const { app, BrowserWindow, ipcMain } = require('electron') +const { app, BrowserWindow, ipcMain, shell } = require('electron') ipcMain.on('new-window', (event, { url, width, height }) => { const win = new BrowserWindow({ width, height }) @@ -19,6 +19,12 @@ function createWindow () { // and load the index.html of the app. mainWindow.loadFile('index.html') + + // Open external links in the default browser + mainWindow.webContents.on('will-navigate', (event, url) => { + event.preventDefault() + shell.openExternal(url) + }) } // This method will be called when Electron has finished diff --git a/docs/fiddles/windows/manage-windows/new-window/renderer.js b/docs/fiddles/windows/manage-windows/new-window/renderer.js index 3ce7216148..0d80d2ee2c 100644 --- a/docs/fiddles/windows/manage-windows/new-window/renderer.js +++ b/docs/fiddles/windows/manage-windows/new-window/renderer.js @@ -1,14 +1,8 @@ -const { shell, ipcRenderer } = require('electron') +const { ipcRenderer } = require('electron') const newWindowBtn = document.getElementById('new-window') -const link = document.getElementById('browser-window-link') newWindowBtn.addEventListener('click', (event) => { const url = 'https://electronjs.org' ipcRenderer.send('new-window', { url, width: 400, height: 320 }) }) - -link.addEventListener('click', (e) => { - e.preventDefault() - shell.openExternal('https://www.electronjs.org/docs/latest/api/browser-window') -})
docs
7c2df8860bdbc0121eb2b91d4f587e5a3e8dd443
Fredy Whatley
2023-09-21 10:46:23
docs: tiny update on example message-ports.md (#39884) Update message-ports.md fix multiplying object * a number. It would multiply number * number.
diff --git a/docs/tutorial/message-ports.md b/docs/tutorial/message-ports.md index 1f5fca4948..90703a4ccd 100644 --- a/docs/tutorial/message-ports.md +++ b/docs/tutorial/message-ports.md @@ -365,7 +365,7 @@ window.onmessage = (event) => { // process. port.onmessage = (event) => { console.log('from main process:', event.data) - port.postMessage(event.data * 2) + port.postMessage(event.data.test * 2) } } }
docs
d7e4bb660848dc68856dd62d33d5257d147f9b26
Milan Burda
2023-09-18 18:55:47
chore: remove no-op `fullscreenWindowTitle` option (#39815)
diff --git a/docs/api/structures/browser-window-options.md b/docs/api/structures/browser-window-options.md index 136132ba57..18ebcc589c 100644 --- a/docs/api/structures/browser-window-options.md +++ b/docs/api/structures/browser-window-options.md @@ -97,9 +97,6 @@ * `roundedCorners` boolean (optional) _macOS_ - Whether frameless window should have rounded corners on macOS. Default is `true`. Setting this property to `false` will prevent the window from being fullscreenable. -* `fullscreenWindowTitle` boolean (optional) _macOS_ _Deprecated_ - Shows - the title in the title bar in full screen mode on macOS for `hiddenInset` - titleBarStyle. Default is `false`. * `thickFrame` boolean (optional) - Use `WS_THICKFRAME` style for frameless windows on Windows, which adds standard window frame. Setting it to `false` will remove window shadow and window animations. Default is `true`. diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 4ec29b6d99..805ab87b2d 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -39,7 +39,6 @@ #include "shell/common/gin_helper/dictionary.h" #include "shell/common/node_includes.h" #include "shell/common/options_switches.h" -#include "shell/common/process_util.h" #include "skia/ext/skia_utils_mac.h" #include "third_party/skia/include/core/SkRegion.h" #include "third_party/webrtc/modules/desktop_capture/mac/window_list_utils.h" @@ -227,14 +226,6 @@ NativeWindowMac::NativeWindowMac(const gin_helper::Dictionary& options, options.GetOptional(options::kTrafficLightPosition, &traffic_light_position_); options.Get(options::kVisualEffectState, &visual_effect_state_); - if (options.Has(options::kFullscreenWindowTitle)) { - EmitWarning( - node::Environment::GetCurrent(JavascriptEnvironment::GetIsolate()), - "\"fullscreenWindowTitle\" option has been deprecated and is " - "no-op now.", - "electron"); - } - bool minimizable = true; options.Get(options::kMinimizable, &minimizable); diff --git a/shell/common/options_switches.cc b/shell/common/options_switches.cc index 51b5a1fac5..4f1ec42cad 100644 --- a/shell/common/options_switches.cc +++ b/shell/common/options_switches.cc @@ -62,9 +62,6 @@ const char kUseContentSize[] = "useContentSize"; // Whether window zoom should be to page width. const char kZoomToPageWidth[] = "zoomToPageWidth"; -// Whether always show title text in full screen is enabled. -const char kFullscreenWindowTitle[] = "fullscreenWindowTitle"; - // The requested title bar style for the window const char kTitleBarStyle[] = "titleBarStyle"; diff --git a/shell/common/options_switches.h b/shell/common/options_switches.h index fecd43c37e..c529b7d02d 100644 --- a/shell/common/options_switches.h +++ b/shell/common/options_switches.h @@ -39,7 +39,6 @@ extern const char kAlwaysOnTop[]; extern const char kAcceptFirstMouse[]; extern const char kUseContentSize[]; extern const char kZoomToPageWidth[]; -extern const char kFullscreenWindowTitle[]; extern const char kTitleBarStyle[]; extern const char kTabbingIdentifier[]; extern const char kAutoHideMenuBar[];
chore