From fdb2502a19e0dabc7df5e7eaab6199bed3f788b0 Mon Sep 17 00:00:00 2001 From: Electron Bot Date: Thu, 27 Jun 2019 08:31:59 -0700 Subject: [PATCH 01/46] Bump v7.0.0-nightly.20190627 --- ELECTRON_VERSION | 2 +- package.json | 2 +- shell/browser/resources/win/atom.rc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ELECTRON_VERSION b/ELECTRON_VERSION index 951ba67985d74..04fef377da207 100644 --- a/ELECTRON_VERSION +++ b/ELECTRON_VERSION @@ -1 +1 @@ -7.0.0-nightly.20190626 \ No newline at end of file +7.0.0-nightly.20190627 \ No newline at end of file diff --git a/package.json b/package.json index d3c38965c35ee..574a26bfa03f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron", - "version": "7.0.0-nightly.20190626", + "version": "7.0.0-nightly.20190627", "repository": "https://github.com/electron/electron", "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS", "devDependencies": { diff --git a/shell/browser/resources/win/atom.rc b/shell/browser/resources/win/atom.rc index 7b36b7efcdd57..81ad519dd13bb 100644 --- a/shell/browser/resources/win/atom.rc +++ b/shell/browser/resources/win/atom.rc @@ -50,8 +50,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,0,0,20190626 - PRODUCTVERSION 7,0,0,20190626 + FILEVERSION 7,0,0,20190627 + PRODUCTVERSION 7,0,0,20190627 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L From ec8697bcdcabe896030ba965cbe7716e41368ec5 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Thu, 27 Jun 2019 14:20:29 -0700 Subject: [PATCH 02/46] test: move protocol specs to main process (#18923) --- docs/api/protocol.md | 26 +- docs/api/structures/file-path-with-headers.md | 4 + .../structures/stream-protocol-response.md | 6 +- .../structures/string-protocol-response.md | 5 + docs/api/structures/upload-data.md | 5 +- filenames.auto.gni | 2 + .../api-protocol-spec.ts | 591 ++++++++---------- spec-main/index.js | 3 + spec/fixtures/pages/blank.html | 0 9 files changed, 309 insertions(+), 333 deletions(-) create mode 100644 docs/api/structures/file-path-with-headers.md create mode 100644 docs/api/structures/string-protocol-response.md rename spec/api-protocol-spec.js => spec-main/api-protocol-spec.ts (55%) create mode 100644 spec/fixtures/pages/blank.html diff --git a/docs/api/protocol.md b/docs/api/protocol.md index ae0858ad59b90..d8e4f611a8912 100644 --- a/docs/api/protocol.md +++ b/docs/api/protocol.md @@ -131,11 +131,12 @@ protocol.registerSchemesAsPrivileged([ * `handler` Function * `request` Object * `url` String + * `headers` Record * `referrer` String * `method` String * `uploadData` [UploadData[]](structures/upload-data.md) * `callback` Function - * `filePath` String (optional) + * `filePath` String | [FilePathWithHeaders](structures/file-path-with-headers.md) (optional) * `completion` Function (optional) * `error` Error @@ -165,6 +166,7 @@ than protocols that follow the "generic URI syntax" like `file:`. * `handler` Function * `request` Object * `url` String + * `headers` Record * `referrer` String * `method` String * `uploadData` [UploadData[]](structures/upload-data.md) @@ -197,11 +199,12 @@ protocol.registerBufferProtocol('atom', (request, callback) => { * `handler` Function * `request` Object * `url` String + * `headers` Record * `referrer` String * `method` String * `uploadData` [UploadData[]](structures/upload-data.md) * `callback` Function - * `data` String (optional) + * `data` (String | [StringProtocolResponse](structures/string-protocol-response.md)) (optional) * `completion` Function (optional) * `error` Error @@ -217,14 +220,14 @@ should be called with either a `String` or an object that has the `data`, * `handler` Function * `request` Object * `url` String - * `headers` Object + * `headers` Record * `referrer` String * `method` String * `uploadData` [UploadData[]](structures/upload-data.md) * `callback` Function * `redirectRequest` Object * `url` String - * `method` String + * `method` String (optional) * `session` Object (optional) * `uploadData` Object (optional) * `contentType` String - MIME type of the content. @@ -249,7 +252,7 @@ For POST requests the `uploadData` object must be provided. * `handler` Function * `request` Object * `url` String - * `headers` Object + * `headers` Record * `referrer` String * `method` String * `uploadData` [UploadData[]](structures/upload-data.md) @@ -325,6 +328,7 @@ already a handler for `scheme`. * `handler` Function * `request` Object * `url` String + * `headers` Record * `referrer` String * `method` String * `uploadData` [UploadData[]](structures/upload-data.md) @@ -342,11 +346,12 @@ which sends a file as a response. * `handler` Function * `request` Object * `url` String + * `headers` Record * `referrer` String * `method` String * `uploadData` [UploadData[]](structures/upload-data.md) * `callback` Function - * `data` String (optional) + * `data` (String | [StringProtocolResponse](structures/string-protocol-response.md)) (optional) * `completion` Function (optional) * `error` Error @@ -359,6 +364,7 @@ which sends a `String` as a response. * `handler` Function * `request` Object * `url` String + * `headers` Record * `referrer` String * `method` String * `uploadData` [UploadData[]](structures/upload-data.md) @@ -376,15 +382,15 @@ which sends a `Buffer` as a response. * `handler` Function * `request` Object * `url` String - * `headers` Object + * `headers` Record * `referrer` String * `method` String * `uploadData` [UploadData[]](structures/upload-data.md) * `callback` Function * `redirectRequest` Object * `url` String - * `method` String - * `session` Object (optional) + * `method` String (optional) + * `session` Object | null (optional) * `uploadData` Object (optional) * `contentType` String - MIME type of the content. * `data` String - Content to be sent. @@ -400,7 +406,7 @@ which sends a new HTTP request as a response. * `handler` Function * `request` Object * `url` String - * `headers` Object + * `headers` Record * `referrer` String * `method` String * `uploadData` [UploadData[]](structures/upload-data.md) diff --git a/docs/api/structures/file-path-with-headers.md b/docs/api/structures/file-path-with-headers.md new file mode 100644 index 0000000000000..9bb1526edcd10 --- /dev/null +++ b/docs/api/structures/file-path-with-headers.md @@ -0,0 +1,4 @@ +# FilePathWithHeaders Object + +* `path` String - The path to the file to send. +* `headers` Record (optional) - Additional headers to be sent. diff --git a/docs/api/structures/stream-protocol-response.md b/docs/api/structures/stream-protocol-response.md index ec1fa27e5e7de..ac5718d07fdf4 100644 --- a/docs/api/structures/stream-protocol-response.md +++ b/docs/api/structures/stream-protocol-response.md @@ -1,5 +1,5 @@ # StreamProtocolResponse Object -* `statusCode` Number - The HTTP response code. -* `headers` Object - An object containing the response headers. -* `data` ReadableStream - A Node.js readable stream representing the response body. +* `statusCode` Number (optional) - The HTTP response code. +* `headers` Record (optional) - An object containing the response headers. +* `data` ReadableStream | null - A Node.js readable stream representing the response body. diff --git a/docs/api/structures/string-protocol-response.md b/docs/api/structures/string-protocol-response.md new file mode 100644 index 0000000000000..19414e3f2aa7c --- /dev/null +++ b/docs/api/structures/string-protocol-response.md @@ -0,0 +1,5 @@ +# StringProtocolResponse Object + +* `mimeType` String (optional) - MIME type of the response. +* `charset` String (optional) - Charset of the response. +* `data` String | null - A string representing the response body. diff --git a/docs/api/structures/upload-data.md b/docs/api/structures/upload-data.md index f5bc4a6260837..ba719af667511 100644 --- a/docs/api/structures/upload-data.md +++ b/docs/api/structures/upload-data.md @@ -1,6 +1,7 @@ # UploadData Object +* `contentType` String (optional) - Content type of the content to be sent. * `bytes` Buffer - Content being sent. -* `file` String - Path of file being uploaded. -* `blobUUID` String - UUID of blob data. Use [ses.getBlobData](../session.md#sesgetblobdataidentifier method +* `file` String (optional) - Path of file being uploaded. +* `blobUUID` String (optional) - UUID of blob data. Use [ses.getBlobData](../session.md#sesgetblobdataidentifier) method to retrieve the data. diff --git a/filenames.auto.gni b/filenames.auto.gni index 6f71eb59761d6..6f2bc9b1d47b0 100644 --- a/filenames.auto.gni +++ b/filenames.auto.gni @@ -75,6 +75,7 @@ auto_filenames = { "docs/api/structures/display.md", "docs/api/structures/event.md", "docs/api/structures/file-filter.md", + "docs/api/structures/file-path-with-headers.md", "docs/api/structures/gpu-feature-status.md", "docs/api/structures/io-counters.md", "docs/api/structures/ipc-main-event.md", @@ -100,6 +101,7 @@ auto_filenames = { "docs/api/structures/shortcut-details.md", "docs/api/structures/size.md", "docs/api/structures/stream-protocol-response.md", + "docs/api/structures/string-protocol-response.md", "docs/api/structures/task.md", "docs/api/structures/thumbar-button.md", "docs/api/structures/trace-categories-and-options.md", diff --git a/spec/api-protocol-spec.js b/spec-main/api-protocol-spec.ts similarity index 55% rename from spec/api-protocol-spec.js rename to spec-main/api-protocol-spec.ts index 652118f60d297..45d2923198c7a 100644 --- a/spec/api-protocol-spec.js +++ b/spec-main/api-protocol-spec.ts @@ -1,125 +1,124 @@ -const chai = require('chai') -const dirtyChai = require('dirty-chai') -const chaiAsPromised = require('chai-as-promised') - -const http = require('http') -const path = require('path') -const qs = require('querystring') -const { promisify } = require('util') -const { emittedOnce } = require('./events-helpers') -const { closeWindow } = require('./window-helpers') -const { remote } = require('electron') -const { BrowserWindow, ipcMain, protocol, session, webContents } = remote -// The RPC API doesn't seem to support calling methods on remote objects very -// well. In order to test stream protocol, we must work around this limitation -// and use Stream instances created in the browser process. -const stream = remote.require('stream') - -const { expect } = chai -chai.use(dirtyChai) -chai.use(chaiAsPromised) - -/* The whole protocol API doesn't use standard callbacks */ -/* eslint-disable standard/no-callback-literal */ +import { expect } from 'chai' +import { protocol, webContents, WebContents, session, BrowserWindow, ipcMain } from 'electron' +import { promisify } from 'util' +import { AddressInfo } from 'net' +import * as path from 'path' +import * as http from 'http' +import * as fs from 'fs' +import * as qs from 'querystring' +import * as stream from 'stream' +import { closeWindow } from './window-helpers' +import { emittedOnce } from './events-helpers' + +const fixturesPath = path.resolve(__dirname, '..', 'spec', 'fixtures') + +const registerStringProtocol = promisify(protocol.registerStringProtocol) +const registerBufferProtocol = promisify(protocol.registerBufferProtocol) +const registerFileProtocol = promisify(protocol.registerFileProtocol) +const registerHttpProtocol = promisify(protocol.registerHttpProtocol) +const registerStreamProtocol = promisify(protocol.registerStreamProtocol) +const interceptStringProtocol = promisify(protocol.interceptStringProtocol) +const interceptBufferProtocol = promisify(protocol.interceptBufferProtocol) +const interceptHttpProtocol = promisify(protocol.interceptHttpProtocol) +const interceptStreamProtocol = promisify(protocol.interceptStreamProtocol) +const unregisterProtocol = promisify(protocol.unregisterProtocol) +const uninterceptProtocol = promisify(protocol.uninterceptProtocol) + +const text = 'valar morghulis' +const protocolName = 'sp' +const postData = { + name: 'post test', + type: 'string' +} + +function delay (ms: number) { + return new Promise((resolve) => { + setTimeout(resolve, ms) + }) +} + +function getStream (chunkSize = text.length, data: Buffer | string = text) { + const body = new stream.PassThrough() + + async function sendChunks () { + await delay(0) // the stream protocol API breaks if you send data immediately. + let buf = Buffer.from(data as any) // nodejs typings are wrong, Buffer.from can take a Buffer + for (;;) { + body.push(buf.slice(0, chunkSize)) + buf = buf.slice(chunkSize) + if (!buf.length) { + break + } + // emulate some network delay + await delay(10) + } + body.push(null) + } + + sendChunks() + return body +} + +// A promise that can be resolved externally. +function defer(): Promise & {resolve: Function, reject: Function} { + let promiseResolve: Function = null as unknown as Function + let promiseReject: Function = null as unknown as Function + const promise: any = new Promise((resolve, reject) => { + promiseResolve = resolve + promiseReject = reject + }) + promise.resolve = promiseResolve + promise.reject = promiseReject + return promise +} describe('protocol module', () => { - const fixtures = path.resolve(__dirname, 'fixtures') - const protocolName = 'sp' - const text = 'valar morghulis' - const postData = { - name: 'post test', - type: 'string' - } + let contents: WebContents = null as unknown as WebContents + // NB. sandbox: true is used because it makes navigations much (~8x) faster. + before(() => contents = (webContents as any).create({sandbox: true})) + after(() => (contents as any).destroy()) - const registerStringProtocol = promisify(protocol.registerStringProtocol) - const registerBufferProtocol = promisify(protocol.registerBufferProtocol) - const registerStreamProtocol = promisify(protocol.registerStreamProtocol) - const registerFileProtocol = promisify(protocol.registerFileProtocol) - const registerHttpProtocol = promisify(protocol.registerHttpProtocol) - const unregisterProtocol = promisify(protocol.unregisterProtocol) - const interceptStringProtocol = promisify(protocol.interceptStringProtocol) - const interceptBufferProtocol = promisify(protocol.interceptBufferProtocol) - const interceptStreamProtocol = promisify(protocol.interceptStreamProtocol) - const interceptFileProtocol = promisify(protocol.interceptFileProtocol) - const interceptHttpProtocol = promisify(protocol.interceptHttpProtocol) - const uninterceptProtocol = promisify(protocol.uninterceptProtocol) - - const contents = webContents.create({}) - after(() => contents.destroy()) - - async function ajax (url, options = {}) { + async function ajax (url: string, options = {}) { // Note that we need to do navigation every time after a protocol is // registered or unregistered, otherwise the new protocol won't be // recognized by current page when NetworkService is used. - await contents.loadFile(path.join(fixtures, 'pages', 'jquery.html')) + await contents.loadFile(path.join(fixturesPath, 'pages', 'jquery.html')) return contents.executeJavaScript(`ajax("${url}", ${JSON.stringify(options)})`) } - function delay (ms) { - return new Promise((resolve) => { - setTimeout(resolve, ms) - }) - } - - function getStream (chunkSize = text.length, data = text) { - const body = stream.PassThrough() - - async function sendChunks () { - let buf = Buffer.from(data) - for (;;) { - body.push(buf.slice(0, chunkSize)) - buf = buf.slice(chunkSize) - if (!buf.length) { - break - } - // emulate network delay - await delay(50) - } - body.push(null) - } - - sendChunks() - return body - } - - afterEach((done) => { - protocol.unregisterProtocol(protocolName, () => { - protocol.uninterceptProtocol('http', () => done()) - }) + afterEach(async () => { + await new Promise(resolve => protocol.unregisterProtocol(protocolName, (/* ignore error */) => resolve())) + await new Promise(resolve => protocol.uninterceptProtocol('http', () => resolve())) }) describe('protocol.register(Any)Protocol', () => { - const emptyHandler = (request, callback) => callback() - it('throws error when scheme is already registered', async () => { - await registerStringProtocol(protocolName, emptyHandler) - await expect(registerBufferProtocol(protocolName, emptyHandler)).to.be.eventually.rejectedWith(Error) + await registerStringProtocol(protocolName, (req, cb) => cb()) + await expect(registerBufferProtocol(protocolName, (req, cb) => cb())).to.be.eventually.rejectedWith(Error) }) it('does not crash when handler is called twice', async () => { - const doubleHandler = (request, callback) => { + await registerStringProtocol(protocolName, (request, callback) => { try { callback(text) callback() } catch (error) { // Ignore error } - } - await registerStringProtocol(protocolName, doubleHandler) + }) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(text) }) it('sends error when callback is called with nothing', async () => { - await registerBufferProtocol(protocolName, emptyHandler) + await registerBufferProtocol(protocolName, (req, cb) => cb()) await expect(ajax(protocolName + '://fake-host')).to.be.eventually.rejectedWith(Error, '404') }) it('does not crash when callback is called in next tick', async () => { - const handler = (request, callback) => { + await registerStringProtocol(protocolName, (request, callback) => { setImmediate(() => callback(text)) - } - await registerStringProtocol(protocolName, handler) + }) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(text) }) @@ -133,36 +132,32 @@ describe('protocol module', () => { describe('protocol.registerStringProtocol', () => { it('sends string as response', async () => { - const handler = (request, callback) => callback(text) - await registerStringProtocol(protocolName, handler) + await registerStringProtocol(protocolName, (request, callback) => callback(text)) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(text) }) it('sets Access-Control-Allow-Origin', async () => { - const handler = (request, callback) => callback(text) - await registerStringProtocol(protocolName, handler) + await registerStringProtocol(protocolName, (request, callback) => callback(text)) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(text) expect(r.headers).to.include('access-control-allow-origin: *') }) it('sends object as response', async () => { - const handler = (request, callback) => { + await registerStringProtocol(protocolName, (request, callback) => { callback({ data: text, mimeType: 'text/html' }) - } - await registerStringProtocol(protocolName, handler) + }) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(text) }) it('fails when sending object other than string', async () => { const notAString = () => {} - const handler = (request, callback) => callback(notAString) - await registerStringProtocol(protocolName, handler) + await registerStringProtocol(protocolName, (request, callback) => callback(notAString as any)) await expect(ajax(protocolName + '://fake-host')).to.be.eventually.rejectedWith(Error, '404') }) }) @@ -170,108 +165,96 @@ describe('protocol module', () => { describe('protocol.registerBufferProtocol', () => { const buffer = Buffer.from(text) it('sends Buffer as response', async () => { - const handler = (request, callback) => callback(buffer) - await registerBufferProtocol(protocolName, handler) + await registerBufferProtocol(protocolName, (request, callback) => callback(buffer)) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(text) }) it('sets Access-Control-Allow-Origin', async () => { - const handler = (request, callback) => callback(buffer) - await registerBufferProtocol(protocolName, handler) + await registerBufferProtocol(protocolName, (request, callback) => callback(buffer)) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(text) expect(r.headers).to.include('access-control-allow-origin: *') }) it('sends object as response', async () => { - const handler = (request, callback) => { + await registerBufferProtocol(protocolName, (request, callback) => { callback({ data: buffer, mimeType: 'text/html' }) - } - await registerBufferProtocol(protocolName, handler) + }) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(text) }) it('fails when sending string', async () => { - const handler = (request, callback) => callback(text) - await registerBufferProtocol(protocolName, handler) + await registerBufferProtocol(protocolName, (request, callback) => callback(text as any)) await expect(ajax(protocolName + '://fake-host')).to.be.eventually.rejectedWith(Error, '404') }) }) describe('protocol.registerFileProtocol', () => { - const filePath = path.join(fixtures, 'asar', 'a.asar', 'file1') - const fileContent = require('fs').readFileSync(filePath) - const normalPath = path.join(fixtures, 'pages', 'a.html') - const normalContent = require('fs').readFileSync(normalPath) + const filePath = path.join(fixturesPath, 'asar', 'a.asar', 'file1') + const fileContent = fs.readFileSync(filePath) + const normalPath = path.join(fixturesPath, 'pages', 'a.html') + const normalContent = fs.readFileSync(normalPath) it('sends file path as response', async () => { - const handler = (request, callback) => callback(filePath) - await registerFileProtocol(protocolName, handler) + await registerFileProtocol(protocolName, (request, callback) => callback(filePath)) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(String(fileContent)) }) it('sets Access-Control-Allow-Origin', async () => { - const handler = (request, callback) => callback(filePath) - await registerFileProtocol(protocolName, handler) + await registerFileProtocol(protocolName, (request, callback) => callback(filePath)) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(String(fileContent)) expect(r.headers).to.include('access-control-allow-origin: *') }) it('sets custom headers', async () => { - const handler = (request, callback) => callback({ + await registerFileProtocol(protocolName, (request, callback) => callback({ path: filePath, headers: { 'X-Great-Header': 'sogreat' } - }) - await registerFileProtocol(protocolName, handler) + })) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(String(fileContent)) expect(r.headers).to.include('x-great-header: sogreat') }) it('throws an error when custom headers are invalid', (done) => { - const handler = (request, callback) => { + registerFileProtocol(protocolName, (request, callback) => { expect(() => callback({ path: filePath, - headers: { 'X-Great-Header': 42 } - })).to.throw(Error, 'Value of \'X-Great-Header\' header has to be a string') + headers: { 'X-Great-Header': (42 as any) } + })).to.throw(Error, `Value of 'X-Great-Header' header has to be a string`) done() - } - registerFileProtocol(protocolName, handler).then(() => { + }).then(() => { ajax(protocolName + '://fake-host') }) }) it('sends object as response', async () => { - const handler = (request, callback) => callback({ path: filePath }) - await registerFileProtocol(protocolName, handler) + await registerFileProtocol(protocolName, (request, callback) => callback({ path: filePath })) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(String(fileContent)) }) it('can send normal file', async () => { - const handler = (request, callback) => callback(normalPath) - await registerFileProtocol(protocolName, handler) + await registerFileProtocol(protocolName, (request, callback) => callback(normalPath)) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(String(normalContent)) }) it('fails when sending unexist-file', async () => { - const fakeFilePath = path.join(fixtures, 'asar', 'a.asar', 'not-exist') - const handler = (request, callback) => callback(fakeFilePath) - await registerFileProtocol(protocolName, handler) + const fakeFilePath = path.join(fixturesPath, 'asar', 'a.asar', 'not-exist') + await registerFileProtocol(protocolName, (request, callback) => callback(fakeFilePath)) await expect(ajax(protocolName + '://fake-host')).to.be.eventually.rejectedWith(Error, '404') }) it('fails when sending unsupported content', async () => { - const handler = (request, callback) => callback(new Date()) - await registerFileProtocol(protocolName, handler) + await registerFileProtocol(protocolName, (request, callback) => callback(new Date() as any)) await expect(ajax(protocolName + '://fake-host')).to.be.eventually.rejectedWith(Error, '404') }) }) @@ -285,23 +268,20 @@ describe('protocol module', () => { }) await server.listen(0, '127.0.0.1') - const port = server.address().port + const port = (server.address() as AddressInfo).port const url = 'http://127.0.0.1:' + port - const handler = (request, callback) => callback({ url }) - await registerHttpProtocol(protocolName, handler) + await registerHttpProtocol(protocolName, (request, callback) => callback({ url })) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(text) }) it('fails when sending invalid url', async () => { - const handler = (request, callback) => callback({ url: 'url' }) - await registerHttpProtocol(protocolName, handler) + await registerHttpProtocol(protocolName, (request, callback) => callback({ url: 'url' })) await expect(ajax(protocolName + '://fake-host')).to.be.eventually.rejectedWith(Error, '404') }) it('fails when sending unsupported content', async () => { - const handler = (request, callback) => callback(new Date()) - await registerHttpProtocol(protocolName, handler) + await registerHttpProtocol(protocolName, (request, callback) => callback(new Date() as any)) await expect(ajax(protocolName + '://fake-host')).to.be.eventually.rejectedWith(Error, '404') }) @@ -318,22 +298,20 @@ describe('protocol module', () => { after(() => server.close()) await server.listen(0, '127.0.0.1') - const port = server.address().port + const port = (server.address() as AddressInfo).port const url = `${protocolName}://fake-host` const redirectURL = `http://127.0.0.1:${port}/serverRedirect` - const handler = (request, callback) => callback({ url: redirectURL }) - await registerHttpProtocol(protocolName, handler) + await registerHttpProtocol(protocolName, (request, callback) => callback({ url: redirectURL })) const r = await ajax(url) expect(r.data).to.equal(text) }) it('can access request headers', (done) => { - const handler = (request) => { - expect(request).to.have.a.property('headers') + protocol.registerHttpProtocol(protocolName, (request) => { + expect(request).to.have.property('headers') done() - } - registerHttpProtocol(protocolName, handler, () => { + }, () => { ajax(protocolName + '://fake-host') }) }) @@ -341,28 +319,25 @@ describe('protocol module', () => { describe('protocol.registerStreamProtocol', () => { it('sends Stream as response', async () => { - const handler = (request, callback) => callback(getStream()) - await registerStreamProtocol(protocolName, handler) + await registerStreamProtocol(protocolName, (request, callback) => callback(getStream())) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(text) }) it('sends object as response', async () => { - const handler = (request, callback) => callback({ data: getStream() }) - await registerStreamProtocol(protocolName, handler) + await registerStreamProtocol(protocolName, (request, callback) => callback({ data: getStream() })) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(text) expect(r.status).to.equal(200) }) it('sends custom response headers', async () => { - const handler = (request, callback) => callback({ + await registerStreamProtocol(protocolName, (request, callback) => callback({ data: getStream(3), headers: { 'x-electron': ['a', 'b'] } - }) - await registerStreamProtocol(protocolName, handler) + })) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.equal(text) expect(r.status).to.equal(200) @@ -370,32 +345,30 @@ describe('protocol module', () => { }) it('sends custom status code', async () => { - const handler = (request, callback) => callback({ + await registerStreamProtocol(protocolName, (request, callback) => callback({ statusCode: 204, data: null - }) - await registerStreamProtocol(protocolName, handler) + })) const r = await ajax(protocolName + '://fake-host') - expect(r.data).to.be.undefined() + expect(r.data).to.be.undefined('data') expect(r.status).to.equal(204) }) it('receives request headers', async () => { - const handler = (request, callback) => { + await registerStreamProtocol(protocolName, (request, callback) => { callback({ headers: { 'content-type': 'application/json' }, data: getStream(5, JSON.stringify(Object.assign({}, request.headers))) }) - } - await registerStreamProtocol(protocolName, handler) + }) const r = await ajax(protocolName + '://fake-host', { headers: { 'x-return-headers': 'yes' } }) expect(r.data['x-return-headers']).to.equal('yes') }) it('returns response multiple response headers with the same name', async () => { - const handler = (request, callback) => { + await registerStreamProtocol(protocolName, (request, callback) => { callback({ headers: { 'header1': ['value1', 'value2'], @@ -403,8 +376,7 @@ describe('protocol module', () => { }, data: getStream() }) - } - await registerStreamProtocol(protocolName, handler) + }) const r = await ajax(protocolName + '://fake-host') // SUBTLE: when the response headers have multiple values it // separates values by ", ". When the response headers are incorrectly @@ -414,115 +386,94 @@ describe('protocol module', () => { it('can handle large responses', async () => { const data = Buffer.alloc(128 * 1024) - const handler = (request, callback) => { + await registerStreamProtocol(protocolName, (request, callback) => { callback(getStream(data.length, data)) - } - await registerStreamProtocol(protocolName, handler) + }) const r = await ajax(protocolName + '://fake-host') expect(r.data).to.have.lengthOf(data.length) }) }) describe('protocol.isProtocolHandled', () => { - it('returns true for about:', async () => { - const result = await protocol.isProtocolHandled('about') - expect(result).to.be.true() - }) - - it('returns true for file:', async () => { - const result = await protocol.isProtocolHandled('file') - expect(result).to.be.true() - }) - - it('returns true for http:', async () => { - const result = await protocol.isProtocolHandled('http') - expect(result).to.be.true() - }) - - it('returns true for https:', async () => { - const result = await protocol.isProtocolHandled('https') - expect(result).to.be.true() + it('returns true for built-in protocols', async () => { + for (const p of ['about', 'file', 'http', 'https']) { + const handled = await protocol.isProtocolHandled(p) + expect(handled).to.be.true(`${p}: is handled`) + } }) it('returns false when scheme is not registered', async () => { const result = await protocol.isProtocolHandled('no-exist') - expect(result).to.be.false() + expect(result).to.be.false('no-exist: is handled') }) it('returns true for custom protocol', async () => { - const emptyHandler = (request, callback) => callback() - await registerStringProtocol(protocolName, emptyHandler) + await registerStringProtocol(protocolName, (request, callback) => callback()) const result = await protocol.isProtocolHandled(protocolName) - expect(result).to.be.true() + expect(result).to.be.true('custom protocol is handled') }) it('returns true for intercepted protocol', async () => { - const emptyHandler = (request, callback) => callback() - await interceptStringProtocol('http', emptyHandler) + await interceptStringProtocol('http', (request, callback) => callback()) const result = await protocol.isProtocolHandled('http') - expect(result).to.be.true() + expect(result).to.be.true('intercepted protocol is handled') }) }) describe('protocol.intercept(Any)Protocol', () => { - const emptyHandler = (request, callback) => callback() it('throws error when scheme is already intercepted', (done) => { - protocol.interceptStringProtocol('http', emptyHandler, (error) => { - expect(error).to.be.null() - protocol.interceptBufferProtocol('http', emptyHandler, (error) => { - expect(error).to.not.be.null() + protocol.interceptStringProtocol('http', (request, callback) => callback(), (error) => { + expect(error).to.be.null('error') + protocol.interceptBufferProtocol('http', (request, callback) => callback(), (error) => { + expect(error).to.not.be.null('error') done() }) }) }) it('does not crash when handler is called twice', async () => { - const doubleHandler = (request, callback) => { + await interceptStringProtocol('http', (request, callback) => { try { callback(text) callback() } catch (error) { // Ignore error } - } - await interceptStringProtocol('http', doubleHandler) + }) const r = await ajax('http://fake-host') expect(r.data).to.be.equal(text) }) it('sends error when callback is called with nothing', async () => { - await interceptStringProtocol('http', emptyHandler) + await interceptStringProtocol('http', (request, callback) => callback()) await expect(ajax('http://fake-host')).to.be.eventually.rejectedWith(Error, '404') }) }) describe('protocol.interceptStringProtocol', () => { it('can intercept http protocol', async () => { - const handler = (request, callback) => callback(text) - await interceptStringProtocol('http', handler) + await interceptStringProtocol('http', (request, callback) => callback(text)) const r = await ajax('http://fake-host') expect(r.data).to.equal(text) }) it('can set content-type', async () => { - const handler = (request, callback) => { + await interceptStringProtocol('http', (request, callback) => { callback({ mimeType: 'application/json', data: '{"value": 1}' }) - } - await interceptStringProtocol('http', handler) + }) const r = await ajax('http://fake-host') expect(r.data).to.be.an('object') - expect(r.data).to.have.a.property('value').that.is.equal(1) + expect(r.data).to.have.property('value').that.is.equal(1) }) it('can receive post data', async () => { - const handler = (request, callback) => { + await interceptStringProtocol('http', (request, callback) => { const uploadData = request.uploadData[0].bytes.toString() callback({ data: uploadData }) - } - await interceptStringProtocol('http', handler) + }) const r = await ajax('http://fake-host', { type: 'POST', data: postData }) expect({ ...qs.parse(r.data) }).to.deep.equal(postData) }) @@ -530,20 +481,18 @@ describe('protocol module', () => { describe('protocol.interceptBufferProtocol', () => { it('can intercept http protocol', async () => { - const handler = (request, callback) => callback(Buffer.from(text)) - await interceptBufferProtocol('http', handler) + await interceptBufferProtocol('http', (request, callback) => callback(Buffer.from(text))) const r = await ajax('http://fake-host') expect(r.data).to.equal(text) }) it('can receive post data', async () => { - const handler = (request, callback) => { + await interceptBufferProtocol('http', (request, callback) => { const uploadData = request.uploadData[0].bytes callback(uploadData) - } - await interceptBufferProtocol('http', handler) + }) const r = await ajax('http://fake-host', { type: 'POST', data: postData }) - expect(r.data).to.equal($.param(postData)) + expect(r.data).to.equal('name=post+test&type=string') }) }) @@ -565,21 +514,20 @@ describe('protocol module', () => { after(() => server.close()) await server.listen(0, '127.0.0.1') - const port = server.address().port + const port = (server.address() as AddressInfo).port const url = `http://127.0.0.1:${port}` - const handler = (request, callback) => { + await interceptHttpProtocol('http', (request, callback) => { const data = { url: url, method: 'POST', uploadData: { contentType: 'application/x-www-form-urlencoded', - data: request.uploadData[0].bytes.toString() + bytes: request.uploadData[0].bytes }, session: null } callback(data) - } - await interceptHttpProtocol('http', handler) + }) const r = await ajax('http://fake-host', { type: 'POST', data: postData }) expect({ ...qs.parse(r.data) }).to.deep.equal(postData) }) @@ -592,46 +540,42 @@ describe('protocol module', () => { }) after(() => customSession.webRequest.onBeforeRequest(null)) - const handler = (request, callback) => { + await interceptHttpProtocol('http', (request, callback) => { callback({ url: request.url, session: customSession }) - } - await interceptHttpProtocol('http', handler) - await expect(fetch('http://fake-host')).to.be.eventually.rejectedWith(Error) + }) + await expect(ajax('http://fake-host')).to.be.eventually.rejectedWith(Error) }) it('can access request headers', (done) => { - const handler = (request) => { - expect(request).to.have.a.property('headers') + protocol.interceptHttpProtocol('http', (request) => { + expect(request).to.have.property('headers') done() - } - protocol.interceptHttpProtocol('http', handler, () => { - fetch('http://fake-host') + }, () => { + ajax('http://fake-host') }) }) }) describe('protocol.interceptStreamProtocol', () => { it('can intercept http protocol', async () => { - const handler = (request, callback) => callback(getStream()) - await interceptStreamProtocol('http', handler) + await interceptStreamProtocol('http', (request, callback) => callback(getStream())) const r = await ajax('http://fake-host') expect(r.data).to.equal(text) }) it('can receive post data', async () => { - const handler = (request, callback) => { + await interceptStreamProtocol('http', (request, callback) => { callback(getStream(3, request.uploadData[0].bytes.toString())) - } - await interceptStreamProtocol('http', handler) + }) const r = await ajax('http://fake-host', { type: 'POST', data: postData }) expect({ ...qs.parse(r.data) }).to.deep.equal(postData) }) it('can execute redirects', async () => { - const handler = (request, callback) => { + await interceptStreamProtocol('http', (request, callback) => { if (request.url.indexOf('http://fake-host') === 0) { setTimeout(() => { callback({ @@ -646,8 +590,7 @@ describe('protocol module', () => { expect(request.url.indexOf('http://fake-redirect')).to.equal(0) callback(getStream(1, 'redirect')) } - } - await interceptStreamProtocol('http', handler) + }) const r = await ajax('http://fake-host') expect(r.data).to.equal('redirect') }) @@ -664,13 +607,12 @@ describe('protocol module', () => { }) describe('protocol.registerSchemesAsPrivileged standard', () => { - const standardScheme = remote.getGlobal('standardScheme') + const standardScheme = (global as any).standardScheme const origin = `${standardScheme}://fake-host` const imageURL = `${origin}/test.png` - const filePath = path.join(fixtures, 'pages', 'b.html') + const filePath = path.join(fixturesPath, 'pages', 'b.html') const fileContent = '' - let w = null - let success = null + let w: BrowserWindow = null as unknown as BrowserWindow beforeEach(() => { w = new BrowserWindow({ @@ -679,35 +621,28 @@ describe('protocol module', () => { nodeIntegration: true } }) - success = false }) - afterEach((done) => { - protocol.unregisterProtocol(standardScheme, () => { - closeWindow(w).then(() => { - w = null - done() - }) - }) + afterEach(async () => { + await closeWindow(w) + await unregisterProtocol(standardScheme) + w = null as unknown as BrowserWindow }) it('resolves relative resources', async () => { - const handler = (request, callback) => { + await registerFileProtocol(standardScheme, (request, callback) => { if (request.url === imageURL) { - success = true callback() } else { callback(filePath) } - } - await registerFileProtocol(standardScheme, handler) + }) await w.loadURL(origin) }) it('resolves absolute resources', async () => { - const handler = (request, callback) => { + await registerStringProtocol(standardScheme, (request, callback) => { if (request.url === imageURL) { - success = true callback() } else { callback({ @@ -715,22 +650,28 @@ describe('protocol module', () => { mimeType: 'text/html' }) } - } - await registerStringProtocol(standardScheme, handler) + }) await w.loadURL(origin) }) it('can have fetch working in it', async () => { - const content = '' - const handler = (request, callback) => callback({ data: content, mimeType: 'text/html' }) - await registerStringProtocol(standardScheme, handler) + const requestReceived = defer() + const server = http.createServer((req, res) => { + res.end() + server.close() + requestReceived.resolve() + }) + await new Promise(resolve => server.listen(0, '127.0.0.1', resolve)) + const port = (server.address() as AddressInfo).port + const content = `` + await registerStringProtocol(standardScheme, (request, callback) => callback({ data: content, mimeType: 'text/html' })) await w.loadURL(origin) + await requestReceived }) it('can access files through the FileSystem API', (done) => { - const filePath = path.join(fixtures, 'pages', 'filesystem.html') - const handler = (request, callback) => callback({ path: filePath }) - protocol.registerFileProtocol(standardScheme, handler, (error) => { + const filePath = path.join(fixturesPath, 'pages', 'filesystem.html') + protocol.registerFileProtocol(standardScheme, (request, callback) => callback({ path: filePath }), (error) => { if (error) return done(error) w.loadURL(origin) }) @@ -739,11 +680,10 @@ describe('protocol module', () => { }) it('registers secure, when {secure: true}', (done) => { - const filePath = path.join(fixtures, 'pages', 'cache-storage.html') - const handler = (request, callback) => callback({ path: filePath }) + const filePath = path.join(fixturesPath, 'pages', 'cache-storage.html') ipcMain.once('success', () => done()) ipcMain.once('failure', (event, err) => done(err)) - protocol.registerFileProtocol(standardScheme, handler, (error) => { + protocol.registerFileProtocol(standardScheme, (request, callback) => callback({ path: filePath }), (error) => { if (error) return done(error) w.loadURL(origin) }) @@ -751,88 +691,103 @@ describe('protocol module', () => { }) describe('protocol.registerSchemesAsPrivileged cors-fetch', function () { - const standardScheme = remote.getGlobal('standardScheme') - let w = null - - beforeEach((done) => { - protocol.unregisterProtocol(standardScheme, () => done()) + const standardScheme = (global as any).standardScheme + let w: BrowserWindow = null as unknown as BrowserWindow + beforeEach(async () => { + w = new BrowserWindow({show: false}) }) - afterEach((done) => { - closeWindow(w).then(() => { - w = null - done() - }) + afterEach(async () => { + await closeWindow(w) + w = null as unknown as BrowserWindow + await Promise.all( + [standardScheme, 'cors', 'no-cors', 'no-fetch'].map(scheme => + new Promise(resolve => protocol.unregisterProtocol(scheme, (/* ignore error */) => resolve())) + ) + ) }) it('supports fetch api by default', async () => { - const url = 'file://' + fixtures + '/assets/logo.png' - const response = await window.fetch(url) - expect(response.ok).to.be.true() + const url = `file://${fixturesPath}/assets/logo.png` + await w.loadURL(`file://${fixturesPath}/pages/blank.html`) + const ok = await w.webContents.executeJavaScript(`fetch(${JSON.stringify(url)}).then(r => r.ok)`) + expect(ok).to.be.true('response ok') }) it('allows CORS requests by default', async () => { - await allowsCORSRequests('cors', 200, ` - - `) + }) }) - it('disallows CORS, but allows fetch requests, when specified', async () => { - await allowsCORSRequests('no-cors', 'failed', ` - - `) + }) }) it('allows CORS, but disallows fetch requests, when specified', async () => { - await allowsCORSRequests('no-fetch', 'failed', ` - - `) + }) }) - async function allowsCORSRequests (corsScheme, expected, content) { + async function allowsCORSRequests (corsScheme: string, expected: any, expectedConsole: RegExp, content: Function) { await registerStringProtocol(standardScheme, (request, callback) => { - callback({ data: content, mimeType: 'text/html' }) + callback({ data: ``, mimeType: 'text/html' }) }) await registerStringProtocol(corsScheme, (request, callback) => { callback('') }) - after(async () => { - try { - await unregisterProtocol(corsScheme) - } catch { - // Ignore error. - } - }) - - const newContents = webContents.create({ nodeIntegration: true }) - after(() => newContents.destroy()) - const event = emittedOnce(ipcMain, 'response') - newContents.loadURL(standardScheme + '://fake-host') - const [, response] = await event - expect(response).to.equal(expected) + const newContents: WebContents = (webContents as any).create({ nodeIntegration: true }) + const consoleMessages: string[] = [] + newContents.on('console-message', (e, level, message, line, sourceId) => consoleMessages.push(message)) + try { + newContents.loadURL(standardScheme + '://fake-host') + const [, response] = await emittedOnce(ipcMain, 'response') + expect(response).to.deep.equal(expected) + expect(consoleMessages.join('\n')).to.match(expectedConsole) + } finally { + // This is called in a timeout to avoid a crash that happens when + // calling destroy() in a microtask. + setTimeout(() => { + (newContents as any).destroy() + }) + } } }) }) diff --git a/spec-main/index.js b/spec-main/index.js index 115174ceb351f..22c70a9023d39 100644 --- a/spec-main/index.js +++ b/spec-main/index.js @@ -27,6 +27,9 @@ global.standardScheme = 'app' protocol.registerSchemesAsPrivileged([ { scheme: global.standardScheme, privileges: { standard: true, secure: true } }, { scheme: 'cors-blob', privileges: { corsEnabled: true, supportFetchAPI: true } }, + { scheme: 'cors', privileges: { corsEnabled: true, supportFetchAPI: true } }, + { scheme: 'no-cors', privileges: { supportFetchAPI: true } }, + { scheme: 'no-fetch', privileges: { corsEnabled: true } } ]) app.whenReady().then(() => { diff --git a/spec/fixtures/pages/blank.html b/spec/fixtures/pages/blank.html new file mode 100644 index 0000000000000..e69de29bb2d1d From 1a6a16e3469af88712f8e6514ca133b296345024 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 27 Jun 2019 14:51:18 -0700 Subject: [PATCH 03/46] docs: fix platform location for params (#18987) --- docs/api/app.md | 8 ++++---- docs/api/menu-item.md | 2 +- docs/api/shell.md | 5 ++--- docs/api/structures/process-memory-info.md | 5 ++--- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/docs/api/app.md b/docs/api/app.md index 21ed9c9824bbd..e4c89982b587a 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -1179,10 +1179,10 @@ Show the app's about panel options. These options can be overridden with `app.se * `applicationVersion` String (optional) - The app's version. * `copyright` String (optional) - Copyright information. * `version` String (optional) - The app's build version number. - * `credits` String (optional) - Credit information. _macOS_ - * `authors` String[] (optional) - List of app authors. _Linux_ - * `website` String (optional) - The app's website. _Linux_ - * `iconPath` String (optional) - Path to the app's icon. Will be shown as 64x64 pixels while retaining aspect ratio. _Linux_ + * `credits` String (optional) _macOS_ - Credit information. + * `authors` String[] (optional) _Linux_ - List of app authors. + * `website` String (optional) _Linux_ - The app's website. + * `iconPath` String (optional) _Linux_ - Path to the app's icon. Will be shown as 64x64 pixels while retaining aspect ratio. Set the about panel options. This will override the values defined in the app's `.plist` file on MacOS. See the [Apple docs][about-panel-options] for more details. On Linux, values must be set in order to be shown; there are no defaults. diff --git a/docs/api/menu-item.md b/docs/api/menu-item.md index 971f9878bafd2..fa8e5fefa0f44 100644 --- a/docs/api/menu-item.md +++ b/docs/api/menu-item.md @@ -24,7 +24,7 @@ See [`Menu`](menu.md) for examples. * `icon` ([NativeImage](native-image.md) | String) (optional) * `enabled` Boolean (optional) - If false, the menu item will be greyed out and unclickable. - * `acceleratorWorksWhenHidden` Boolean (optional) - default is `true`, and when `false` will prevent the accelerator from triggering the item if the item is not visible`. _macOS_ + * `acceleratorWorksWhenHidden` Boolean (optional) _macOS_ - default is `true`, and when `false` will prevent the accelerator from triggering the item if the item is not visible`. * `visible` Boolean (optional) - If false, the menu item will be entirely hidden. * `checked` Boolean (optional) - Should only be specified for `checkbox` or `radio` type menu items. diff --git a/docs/api/shell.md b/docs/api/shell.md index ff085164bcccf..6f6b9306fe28f 100644 --- a/docs/api/shell.md +++ b/docs/api/shell.md @@ -36,9 +36,8 @@ Open the given file in the desktop's default manner. * `url` String - Max 2081 characters on windows. * `options` Object (optional) - * `activate` Boolean (optional) - `true` to bring the opened application to the - foreground. The default is `true`. _macOS_ - * `workingDirectory` String (optional) - The working directory. _Windows_ + * `activate` Boolean (optional) _macOS_ - `true` to bring the opened application to the foreground. The default is `true`. + * `workingDirectory` String (optional) _Windows_ - The working directory. Returns `Promise` diff --git a/docs/api/structures/process-memory-info.md b/docs/api/structures/process-memory-info.md index 806d3c94fbbfa..2fb81477b46d1 100644 --- a/docs/api/structures/process-memory-info.md +++ b/docs/api/structures/process-memory-info.md @@ -1,8 +1,7 @@ # ProcessMemoryInfo Object -* `residentSet` Integer - _Linux_ and _Windows_ - The amount of memory +* `residentSet` Integer _Linux_ _Windows_ - The amount of memory currently pinned to actual physical RAM in Kilobytes. -* `private` Integer - The amount of memory not shared by other processes, such as - JS heap or HTML content in Kilobytes. +* `private` Integer - The amount of memory not shared by other processes, such as JS heap or HTML content in Kilobytes. * `shared` Integer - The amount of memory shared between processes, typically memory consumed by the Electron code itself in Kilobytes. From 127d617db5c40080ab44aeef014cf02954b2b0ff Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Thu, 27 Jun 2019 19:01:28 -0700 Subject: [PATCH 04/46] fix: delay emitting screen events by a tick to avoid re-entrancy crash (#19016) --- shell/browser/api/atom_api_screen.cc | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/shell/browser/api/atom_api_screen.cc b/shell/browser/api/atom_api_screen.cc index d8fc8b8b0093c..783910b952749 100644 --- a/shell/browser/api/atom_api_screen.cc +++ b/shell/browser/api/atom_api_screen.cc @@ -51,6 +51,19 @@ std::vector MetricsToArray(uint32_t metrics) { return array; } +void DelayEmit(Screen* screen, + const base::StringPiece& name, + const display::Display& display) { + screen->Emit(name, display); +} + +void DelayEmitWithMetrics(Screen* screen, + const base::StringPiece& name, + const display::Display& display, + const std::vector& metrics) { + screen->Emit(name, display, metrics); +} + } // namespace Screen::Screen(v8::Isolate* isolate, display::Screen* screen) @@ -100,16 +113,23 @@ static gfx::Rect DIPToScreenRect(electron::NativeWindow* window, #endif void Screen::OnDisplayAdded(const display::Display& new_display) { - Emit("display-added", new_display); + base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( + FROM_HERE, base::Bind(&DelayEmit, base::Unretained(this), "display-added", + new_display)); } void Screen::OnDisplayRemoved(const display::Display& old_display) { - Emit("display-removed", old_display); + base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( + FROM_HERE, base::Bind(&DelayEmit, base::Unretained(this), + "display-removed", old_display)); } void Screen::OnDisplayMetricsChanged(const display::Display& display, uint32_t changed_metrics) { - Emit("display-metrics-changed", display, MetricsToArray(changed_metrics)); + base::ThreadTaskRunnerHandle::Get()->PostNonNestableTask( + FROM_HERE, base::Bind(&DelayEmitWithMetrics, base::Unretained(this), + "display-metrics-changed", display, + MetricsToArray(changed_metrics))); } // static From 0a9438dbba36f741d442fc74569126363eedfb9e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 28 Jun 2019 16:25:30 +0900 Subject: [PATCH 05/46] docs: documentation of NetworkService-based protocol module (#18952) * docs: NetworkService-based protocol module * docs: separate ProtocolRequest * docs: separate ProtocolResponse * docs: fix lint warning * docs: fix electron.d.ts * fix: print deprecation warnings for protocol module * docs: fix links * Apply suggestions from code review Co-Authored-By: Felix Rieseberg * Apply suggestions from code review Co-Authored-By: Samuel Attard * Do not publish NetworkService changes draft * Apply suggestions from code review Co-Authored-By: Samuel Attard * docs: filePath must be absolute --- docs/api/breaking-changes-ns.md | 61 +++++ docs/api/protocol-ns.md | 309 ++++++++++++++++++++++ docs/api/structures/protocol-request.md | 6 + docs/api/structures/protocol-response.md | 36 +++ filenames.auto.gni | 4 + package.json | 4 +- shell/browser/api/atom_api_protocol_ns.cc | 17 +- shell/browser/api/atom_api_protocol_ns.h | 3 +- yarn.lock | 17 +- 9 files changed, 451 insertions(+), 6 deletions(-) create mode 100644 docs/api/breaking-changes-ns.md create mode 100644 docs/api/protocol-ns.md create mode 100644 docs/api/structures/protocol-request.md create mode 100644 docs/api/structures/protocol-response.md diff --git a/docs/api/breaking-changes-ns.md b/docs/api/breaking-changes-ns.md new file mode 100644 index 0000000000000..1914c1f43f449 --- /dev/null +++ b/docs/api/breaking-changes-ns.md @@ -0,0 +1,61 @@ +# Breaking changes (NetworkService) (Draft) + +This document describes changes to Electron APIs after migrating network code +to NetworkService API. + +We don't currently have an estimate of when we will enable `NetworkService` by +default in Electron, but as Chromium is already removing non-`NetworkService` +code, we might switch before Electron 10. + +The content of this document should be moved to `breaking-changes.md` once we have +determined when to enable `NetworkService` in Electron. + +## Planned Breaking API Changes + +### `protocol.unregisterProtocol` +### `protocol.uninterceptProtocol` + +The APIs are now synchronous and the optional callback is no longer needed. + +```javascript +// Deprecated +protocol.unregisterProtocol(scheme, () => { /* ... */ }) +// Replace with +protocol.unregisterProtocol(scheme) +``` + +### `protocol.registerFileProtocol` +### `protocol.registerBufferProtocol` +### `protocol.registerStringProtocol` +### `protocol.registerHttpProtocol` +### `protocol.registerStreamProtocol` +### `protocol.interceptFileProtocol` +### `protocol.interceptStringProtocol` +### `protocol.interceptBufferProtocol` +### `protocol.interceptHttpProtocol` +### `protocol.interceptStreamProtocol` + +The APIs are now synchronous and the optional callback is no longer needed. + +```javascript +// Deprecated +protocol.registerFileProtocol(scheme, handler, () => { /* ... */ }) +// Replace with +protocol.registerFileProtocol(scheme, handler) +``` + +The registered or intercepted protocol does not have effect on current page +until navigation happens. + +### `protocol.isProtocolHandled` + +This API is deprecated and users should use `protocol.isProtocolRegistered` +and `protocol.isProtocolIntercepted` instead. + +```javascript +// Deprecated +protocol.isProtocolHandled(scheme).then(() => { /* ... */ }) +// Replace with +const isRegistered = protocol.isProtocolRegistered(scheme) +const isIntercepted = protocol.isProtocolIntercepted(scheme) +``` diff --git a/docs/api/protocol-ns.md b/docs/api/protocol-ns.md new file mode 100644 index 0000000000000..45a96f4511dac --- /dev/null +++ b/docs/api/protocol-ns.md @@ -0,0 +1,309 @@ +# protocol (NetworkService) (Draft) + +This document describes the new protocol APIs based on the [NetworkService](https://www.chromium.org/servicification). + +We don't currently have an estimate of when we will enable the `NetworkService` by +default in Electron, but as Chromium is already removing non-`NetworkService` +code, we will probably switch before Electron 10. + +The content of this document should be moved to `protocol.md` after we have +enabled the `NetworkService` by default in Electron. + +> Register a custom protocol and intercept existing protocol requests. + +Process: [Main](../glossary.md#main-process) + +An example of implementing a protocol that has the same effect as the +`file://` protocol: + +```javascript +const { app, protocol } = require('electron') +const path = require('path') + +app.on('ready', () => { + protocol.registerFileProtocol('atom', (request, callback) => { + const url = request.url.substr(7) + callback({ path: path.normalize(`${__dirname}/${url}`) }) + }) +}) +``` + +**Note:** All methods unless specified can only be used after the `ready` event +of the `app` module gets emitted. + +## Using `protocol` with a custom `partition` or `session` + +A protocol is registered to a specific Electron [`session`](./session.md) +object. If you don't specify a session, then your `protocol` will be applied to +the default session that Electron uses. However, if you define a `partition` or +`session` on your `browserWindow`'s `webPreferences`, then that window will use +a different session and your custom protocol will not work if you just use +`electron.protocol.XXX`. + +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 path = require('path') + +app.on('ready', () => { + const partition = 'persist:example' + const ses = session.fromPartition(partition) + + ses.protocol.registerFileProtocol('atom', (request, callback) => { + const url = request.url.substr(7) + callback({ path: path.normalize(`${__dirname}/${url}`) }) + }) + + mainWindow = new BrowserWindow({ webPreferences: { partition } }) +}) +``` + +## Methods + +The `protocol` module has the following methods: + +### `protocol.registerSchemesAsPrivileged(customSchemes)` + +* `customSchemes` [CustomScheme[]](structures/custom-scheme.md) + +**Note:** This method can only be used before the `ready` event of the `app` +module gets emitted and can be called only once. + +Registers the `scheme` as standard, secure, bypasses content security policy for +resources, allows registering ServiceWorker and supports fetch API. Specify a +privilege with the value of `true` to enable the capability. + +An example of registering a privileged scheme, that bypasses Content Security +Policy: + +```javascript +const { protocol } = require('electron') +protocol.registerSchemesAsPrivileged([ + { scheme: 'foo', privileges: { bypassCSP: true } } +]) +``` + +A standard scheme adheres to what RFC 3986 calls [generic URI +syntax](https://tools.ietf.org/html/rfc3986#section-3). For example `http` and +`https` are standard schemes, while `file` is not. + +Registering a scheme as standard allows relative and absolute resources to +be resolved correctly when served. Otherwise the scheme will behave like the +`file` protocol, but without the ability to resolve relative URLs. + +For example when you load following page with custom protocol without +registering it as standard scheme, the image will not be loaded because +non-standard schemes can not recognize relative URLs: + +```html + + + +``` + +Registering a scheme as standard will allow access to files through the +[FileSystem API][file-system-api]. Otherwise the renderer will throw a security +error for the scheme. + +By default web storage apis (localStorage, sessionStorage, webSQL, indexedDB, +cookies) are disabled for non standard schemes. So in general if you want to +register a custom protocol to replace the `http` protocol, you have to register +it as a standard scheme. + +### `protocol.registerFileProtocol(scheme, handler)` + +* `scheme` String +* `handler` Function + * `request` ProtocolRequest + * `callback` Function + * `response` (String | [ProtocolResponse](structures/protocol-response.md)) + +Registers a protocol of `scheme` that will send a file as the response. The +`handler` will be called with `request` and `callback` where `request` is +an incoming request for the `scheme`. + +To handle the `request`, the `callback` should be called with either the file's +path or an object that has a `path` property, e.g. `callback(filePath)` or +`callback({ path: filePath })`. The `filePath` must be an absolute path. + +By default the `scheme` is treated like `http:`, which is parsed differently +from protocols that follow the "generic URI syntax" like `file:`. + +### `protocol.registerBufferProtocol(scheme, handler)` + +* `scheme` String +* `handler` Function + * `request` ProtocolRequest + * `callback` Function + * `response` (Buffer | [ProtocolResponse](structures/protocol-response.md)) + +Registers a protocol of `scheme` that will send a `Buffer` as a response. + +The usage is the same with `registerFileProtocol`, except that the `callback` +should be called with either a `Buffer` object or an object that has the `data` +property. + +Example: + +```javascript +protocol.registerBufferProtocol('atom', (request, callback) => { + callback({ mimeType: 'text/html', data: Buffer.from('
Response
') }) +}) +``` + +### `protocol.registerStringProtocol(scheme, handler)` + +* `scheme` String +* `handler` Function + * `request` ProtocolRequest + * `callback` Function + * `response` (String | [ProtocolResponse](structures/protocol-response.md)) + +Registers a protocol of `scheme` that will send a `String` as a response. + +The usage is the same with `registerFileProtocol`, except that the `callback` +should be called with either a `String` or an object that has the `data` +property. + +### `protocol.registerHttpProtocol(scheme, handler)` + +* `scheme` String +* `handler` Function + * `request` ProtocolRequest + * `callback` Function + * `response` ProtocolResponse + +Registers a protocol of `scheme` that will send an HTTP request as a response. + +The usage is the same with `registerFileProtocol`, except that the `callback` +should be called with an object that has the `url` property. + +### `protocol.registerStreamProtocol(scheme, handler)` + +* `scheme` String +* `handler` Function + * `request` ProtocolRequest + * `callback` Function + * `response` (ReadableStream | [ProtocolResponse](structures/protocol-response.md)) + +Registers a protocol of `scheme` that will send a stream as a response. + +The usage is the same with `registerFileProtocol`, except that the +`callback` should be called with either a [`ReadableStream`](https://nodejs.org/api/stream.html#stream_class_stream_readable) object or an object that +has the `data` property. + +Example: + +```javascript +const { protocol } = require('electron') +const { PassThrough } = require('stream') + +function createStream (text) { + const rv = new PassThrough() // PassThrough is also a Readable stream + rv.push(text) + rv.push(null) + return rv +} + +protocol.registerStreamProtocol('atom', (request, callback) => { + callback({ + statusCode: 200, + headers: { + 'content-type': 'text/html' + }, + data: createStream('
Response
') + }) +}) +``` + +It is possible to pass any object that implements the readable stream API (emits +`data`/`end`/`error` events). For example, here's how a file could be returned: + +```javascript +protocol.registerStreamProtocol('atom', (request, callback) => { + callback(fs.createReadStream('index.html')) +}) +``` + +### `protocol.unregisterProtocol(scheme)` + +* `scheme` String + +Unregisters the custom protocol of `scheme`. + +### `protocol.isProtocolRegistered(scheme)` + +* `scheme` String + +Returns `Boolean` - Whether `scheme` is already registered. + +### `protocol.interceptFileProtocol(scheme, handler)` + +* `scheme` String +* `handler` Function + * `request` ProtocolRequest + * `callback` Function + * `response` (String | [ProtocolResponse](structures/protocol-response.md)) + +Intercepts `scheme` protocol and uses `handler` as the protocol's new handler +which sends a file as a response. + +### `protocol.interceptStringProtocol(scheme, handler)` + +* `scheme` String +* `handler` Function + * `request` ProtocolRequest + * `callback` Function + * `response` (String | [ProtocolResponse](structures/protocol-response.md)) + +Intercepts `scheme` protocol and uses `handler` as the protocol's new handler +which sends a `String` as a response. + +### `protocol.interceptBufferProtocol(scheme, handler)` + +* `scheme` String +* `handler` Function + * `request` ProtocolRequest + * `callback` Function + * `response` (Buffer | [ProtocolResponse](structures/protocol-response.md)) + +Intercepts `scheme` protocol and uses `handler` as the protocol's new handler +which sends a `Buffer` as a response. + +### `protocol.interceptHttpProtocol(scheme, handler)` + +* `scheme` String +* `handler` Function + * `request` ProtocolRequest + * `callback` Function + * `response` ProtocolResponse + +Intercepts `scheme` protocol and uses `handler` as the protocol's new handler +which sends a new HTTP request as a response. + +### `protocol.interceptStreamProtocol(scheme, handler)` + +* `scheme` String +* `handler` Function + * `request` ProtocolRequest + * `callback` Function + * `response` (ReadableStream | [ProtocolResponse](structures/protocol-response.md)) + +Same as `protocol.registerStreamProtocol`, except that it replaces an existing +protocol handler. + +### `protocol.uninterceptProtocol(scheme)` + +* `scheme` String + +Remove the interceptor installed for `scheme` and restore its original handler. + +### `protocol.isProtocolIntercepted(scheme)` + +* `scheme` String + +Returns `Boolean` - Whether `scheme` is already intercepted. + +[file-system-api]: https://developer.mozilla.org/en-US/docs/Web/API/LocalFileSystem diff --git a/docs/api/structures/protocol-request.md b/docs/api/structures/protocol-request.md new file mode 100644 index 0000000000000..4251c93e25c92 --- /dev/null +++ b/docs/api/structures/protocol-request.md @@ -0,0 +1,6 @@ +# ProtocolRequest Object + +* `url` String +* `referrer` String +* `method` String +* `uploadData` [UploadData[]](upload-data.md) (optional) diff --git a/docs/api/structures/protocol-response.md b/docs/api/structures/protocol-response.md new file mode 100644 index 0000000000000..d3b9c99abf961 --- /dev/null +++ b/docs/api/structures/protocol-response.md @@ -0,0 +1,36 @@ +# ProtocolResponse Object + +* `error` Integer (optional) - When assigned, the `request` will fail with the + `error` number . For the available error numbers you can use, please see the + [net error list][net-error]. +* `statusCode` Number (optional) - The HTTP response code, default is 200. +* `charset` String (optional) - The charset of response body, default is + `"utf-8"`. +* `mimeType` String (optional) - The MIME type of response body, default is + `"text/html"`. Setting `mimeType` would implicitly set the `content-type` + header in response, but if `content-type` is already set in `headers`, the + `mimeType` would be ignored. +* `headers` Record (optional) - An object containing the response headers. The + keys must be String, and values must be either String or Array of String. +* `data` (Buffer | String | ReadableStream) (optional) - The response body. When + returning stream as response, this is a Node.js readable stream representing + the response body. When returning `Buffer` as response, this is a `Buffer`. + When returning `String` as response, this is a `String`. This is ignored for + other types of responses. +* `path` String (optional) - Path to the file which would be sent as response + body. This is only used for file responses. +* `url` String (optional) - Download the `url` and pipe the result as response + body. This is only used for URL responses. +* `referrer` String (optional) - The `referrer` URL. This is only used for file + and URL responses. +* `method` String (optional) - The HTTP `method`. This is only used for file + and URL responses. +* `session` Session (optional) - The session used for requesting URL, by default + the HTTP request will reuse the current session. Setting `session` to `null` + would use a random independent session. This is only used for URL responses. +* `uploadData` Object (optional) - The data used as upload data. This is only + used for URL responses when `method` is `"POST"`. + * `contentType` String - MIME type of the content. + * `data` String - Content to be sent. + +[net-error]: https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h diff --git a/filenames.auto.gni b/filenames.auto.gni index 6f2bc9b1d47b0..9139ef1054fb7 100644 --- a/filenames.auto.gni +++ b/filenames.auto.gni @@ -4,6 +4,7 @@ auto_filenames = { "docs/api/accelerator.md", "docs/api/app.md", "docs/api/auto-updater.md", + "docs/api/breaking-changes-ns.md", "docs/api/breaking-changes.md", "docs/api/browser-view.md", "docs/api/browser-window-proxy.md", @@ -39,6 +40,7 @@ auto_filenames = { "docs/api/power-monitor.md", "docs/api/power-save-blocker.md", "docs/api/process.md", + "docs/api/protocol-ns.md", "docs/api/protocol.md", "docs/api/remote.md", "docs/api/sandbox-option.md", @@ -92,6 +94,8 @@ auto_filenames = { "docs/api/structures/process-memory-info.md", "docs/api/structures/process-metric.md", "docs/api/structures/product.md", + "docs/api/structures/protocol-request.md", + "docs/api/structures/protocol-response.md", "docs/api/structures/rectangle.md", "docs/api/structures/referrer.md", "docs/api/structures/remove-client-certificate.md", diff --git a/package.json b/package.json index 574a26bfa03f7..485882bce68a1 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "repository": "https://github.com/electron/electron", "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS", "devDependencies": { - "@electron/docs-parser": "^0.2.2", + "@electron/docs-parser": "^0.3.0", "@electron/typescript-definitions": "^8.3.1", "@octokit/rest": "^16.3.2", "@types/chai": "^4.1.7", @@ -127,4 +127,4 @@ "git add filenames.auto.gni" ] } -} \ No newline at end of file +} diff --git a/shell/browser/api/atom_api_protocol_ns.cc b/shell/browser/api/atom_api_protocol_ns.cc index fd1e6c35f8f8b..4489f12d279f9 100644 --- a/shell/browser/api/atom_api_protocol_ns.cc +++ b/shell/browser/api/atom_api_protocol_ns.cc @@ -9,6 +9,7 @@ #include "base/stl_util.h" #include "shell/browser/atom_browser_context.h" +#include "shell/common/deprecate_util.h" #include "shell/common/native_mate_converters/net_converter.h" #include "shell/common/native_mate_converters/once_callback.h" #include "shell/common/promise_util.h" @@ -106,8 +107,15 @@ bool ProtocolNS::IsProtocolIntercepted(const std::string& scheme) { return base::ContainsKey(intercept_handlers_, scheme); } -v8::Local ProtocolNS::IsProtocolHandled( - const std::string& scheme) { +v8::Local ProtocolNS::IsProtocolHandled(const std::string& scheme, + mate::Arguments* args) { + node::Environment* env = node::Environment::GetCurrent(args->isolate()); + EmitDeprecationWarning( + env, + "The protocol.isProtocolHandled API is deprecated, use " + "protocol.isProtocolRegistered or protocol.isProtocolIntercepted " + "instead.", + "ProtocolDeprecateIsProtocolHandled"); util::Promise promise(isolate()); promise.Resolve(IsProtocolRegistered(scheme) || IsProtocolIntercepted(scheme) || @@ -126,6 +134,11 @@ void ProtocolNS::HandleOptionalCallback(mate::Arguments* args, ProtocolError error) { CompletionCallback callback; if (args->GetNext(&callback)) { + node::Environment* env = node::Environment::GetCurrent(args->isolate()); + EmitDeprecationWarning( + env, + "The callback argument of protocol module APIs is no longer needed.", + "ProtocolDeprecateCallback"); if (error == ProtocolError::OK) callback.Run(v8::Null(args->isolate())); else diff --git a/shell/browser/api/atom_api_protocol_ns.h b/shell/browser/api/atom_api_protocol_ns.h index 6031af4a44c9f..585e006b59e83 100644 --- a/shell/browser/api/atom_api_protocol_ns.h +++ b/shell/browser/api/atom_api_protocol_ns.h @@ -65,7 +65,8 @@ class ProtocolNS : public mate::TrackableObject { bool IsProtocolIntercepted(const std::string& scheme); // Old async version of IsProtocolRegistered. - v8::Local IsProtocolHandled(const std::string& scheme); + v8::Local IsProtocolHandled(const std::string& scheme, + mate::Arguments* args); // Helper for converting old registration APIs to new RegisterProtocol API. template diff --git a/yarn.lock b/yarn.lock index 4bd4919d4414c..72d36a47761b1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,7 +22,7 @@ dependencies: regenerator-runtime "^0.12.0" -"@electron/docs-parser@^0.2.1", "@electron/docs-parser@^0.2.2": +"@electron/docs-parser@^0.2.1": version "0.2.2" resolved "https://registry.yarnpkg.com/@electron/docs-parser/-/docs-parser-0.2.2.tgz#7c9acd6cc10559c86a27bb0653ec13df10955f02" integrity sha512-FKXktu5i6cHL+AkvWv34j2lpBXNpqfHN7YwhswcBqRFXsj24phpih/sY2NKx6OrFP9R3ReJeg681/luAf/3k8Q== @@ -37,6 +37,21 @@ ora "^3.4.0" pretty-ms "^5.0.0" +"@electron/docs-parser@^0.3.0": + version "0.3.0" + resolved "https://registry.yarnpkg.com/@electron/docs-parser/-/docs-parser-0.3.0.tgz#cf8c33ed9cebffe7f3463a1e2d60ccf457b52ec6" + integrity sha512-/q2et0q6eMDItzv1ZCAH5ZJZY8AFGFkK1+wfAJfdarMDJOVs29pH8b0HjTXo2k+kLGlbC2TROZfuCHRgx+l/EQ== + dependencies: + "@types/markdown-it" "^0.0.7" + chai "^4.2.0" + chalk "^2.4.2" + fs-extra "^7.0.1" + lodash.camelcase "^4.3.0" + markdown-it "^8.4.2" + minimist "^1.2.0" + ora "^3.4.0" + pretty-ms "^5.0.0" + "@electron/typescript-definitions@^8.3.1": version "8.3.4" resolved "https://registry.yarnpkg.com/@electron/typescript-definitions/-/typescript-definitions-8.3.4.tgz#2345e4058e66677792f1bc11662b13e6ccc9a17e" From e44bb8474baf37ed5a30fae92d452db370a18db8 Mon Sep 17 00:00:00 2001 From: Micha Hanselmann Date: Fri, 28 Jun 2019 07:43:05 -0700 Subject: [PATCH 06/46] test: move tray api tests to main process (#18986) --- .../api-tray-spec.ts | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) rename spec/api-tray-spec.js => spec-main/api-tray-spec.ts (84%) diff --git a/spec/api-tray-spec.js b/spec-main/api-tray-spec.ts similarity index 84% rename from spec/api-tray-spec.js rename to spec-main/api-tray-spec.ts index 49a31729d0887..4d79512bb644e 100644 --- a/spec/api-tray-spec.js +++ b/spec-main/api-tray-spec.ts @@ -1,18 +1,20 @@ -const { remote } = require('electron') -const { expect } = require('chai') -const { Menu, Tray, nativeImage } = remote +import { expect } from 'chai' +import { Menu, Tray, nativeImage } from 'electron' describe('tray module', () => { - let tray + let tray: Tray; beforeEach(() => { tray = new Tray(nativeImage.createEmpty()) }) + afterEach(() => { + tray = null as any + }) + describe('tray.setContextMenu', () => { afterEach(() => { tray.destroy() - tray = null }) it('accepts menu instance', () => { @@ -26,18 +28,16 @@ describe('tray module', () => { describe('tray.destroy()', () => { it('destroys a tray', () => { - expect(tray.isDestroyed()).to.be.false() + expect(tray.isDestroyed()).to.be.false('tray should not be destroyed') tray.destroy() - expect(tray.isDestroyed()).to.be.true() - tray = null + expect(tray.isDestroyed()).to.be.true('tray should be destroyed') }) }) describe('tray.popUpContextMenu', () => { afterEach(() => { tray.destroy() - tray = null }) before(function () { @@ -59,7 +59,6 @@ describe('tray module', () => { tray.setImage(nativeImage.createEmpty()) tray.destroy() - tray = null }) }) @@ -68,7 +67,6 @@ describe('tray module', () => { tray.setPressedImage(nativeImage.createEmpty()) tray.destroy() - tray = null }) }) @@ -79,7 +77,6 @@ describe('tray module', () => { afterEach(() => { tray.destroy() - tray = null }) it('sets/gets non-empty title', () => { From a4f61565c39f266b0e06159e99a7989bb93877b7 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Fri, 28 Jun 2019 08:24:54 -0700 Subject: [PATCH 07/46] fix: crash when tray popup called twice (#18999) --- shell/browser/ui/tray_icon_cocoa.mm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/shell/browser/ui/tray_icon_cocoa.mm b/shell/browser/ui/tray_icon_cocoa.mm index 3c116eb7c1229..8a83a8feb3b27 100644 --- a/shell/browser/ui/tray_icon_cocoa.mm +++ b/shell/browser/ui/tray_icon_cocoa.mm @@ -340,9 +340,6 @@ - (void)popUpContextMenu:(electron::AtomMenuModel*)menu_model { // Make sure events can be pumped while the menu is up. base::MessageLoopCurrent::ScopedNestableTaskAllower allow; - // Ensure the UI can update while the menu is fading out. - base::ScopedPumpMessagesInPrivateModes pump_private; - // Show a custom menu. if (menu_model) { base::scoped_nsobject menuController( @@ -358,6 +355,9 @@ - (void)popUpContextMenu:(electron::AtomMenuModel*)menu_model { } if (menuController_ && ![menuController_ isMenuOpen]) { + // Ensure the UI can update while the menu is fading out. + base::ScopedPumpMessagesInPrivateModes pump_private; + // Redraw the tray icon to show highlight if it is enabled. [self setNeedsDisplay:YES]; From 769dcce9d7499f521463da6ec8a9c876a285e28a Mon Sep 17 00:00:00 2001 From: Electron Bot Date: Fri, 28 Jun 2019 08:31:15 -0700 Subject: [PATCH 08/46] Bump v7.0.0-nightly.20190628 --- ELECTRON_VERSION | 2 +- package.json | 4 ++-- shell/browser/resources/win/atom.rc | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ELECTRON_VERSION b/ELECTRON_VERSION index 04fef377da207..0760cd8b859e2 100644 --- a/ELECTRON_VERSION +++ b/ELECTRON_VERSION @@ -1 +1 @@ -7.0.0-nightly.20190627 \ No newline at end of file +7.0.0-nightly.20190628 \ No newline at end of file diff --git a/package.json b/package.json index 485882bce68a1..010b5d831a29a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron", - "version": "7.0.0-nightly.20190627", + "version": "7.0.0-nightly.20190628", "repository": "https://github.com/electron/electron", "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS", "devDependencies": { @@ -127,4 +127,4 @@ "git add filenames.auto.gni" ] } -} +} \ No newline at end of file diff --git a/shell/browser/resources/win/atom.rc b/shell/browser/resources/win/atom.rc index 81ad519dd13bb..3559f58f50af4 100644 --- a/shell/browser/resources/win/atom.rc +++ b/shell/browser/resources/win/atom.rc @@ -50,8 +50,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,0,0,20190627 - PRODUCTVERSION 7,0,0,20190627 + FILEVERSION 7,0,0,20190628 + PRODUCTVERSION 7,0,0,20190628 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L From 23b8c9c917ba435d125fb8d9295d53083f71fab1 Mon Sep 17 00:00:00 2001 From: Electron Bot Date: Fri, 28 Jun 2019 09:07:12 -0700 Subject: [PATCH 09/46] Revert "Bump v7.0.0-nightly.20190628" This reverts commit 769dcce9d7499f521463da6ec8a9c876a285e28a. --- ELECTRON_VERSION | 2 +- package.json | 4 ++-- shell/browser/resources/win/atom.rc | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ELECTRON_VERSION b/ELECTRON_VERSION index 0760cd8b859e2..04fef377da207 100644 --- a/ELECTRON_VERSION +++ b/ELECTRON_VERSION @@ -1 +1 @@ -7.0.0-nightly.20190628 \ No newline at end of file +7.0.0-nightly.20190627 \ No newline at end of file diff --git a/package.json b/package.json index 010b5d831a29a..485882bce68a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron", - "version": "7.0.0-nightly.20190628", + "version": "7.0.0-nightly.20190627", "repository": "https://github.com/electron/electron", "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS", "devDependencies": { @@ -127,4 +127,4 @@ "git add filenames.auto.gni" ] } -} \ No newline at end of file +} diff --git a/shell/browser/resources/win/atom.rc b/shell/browser/resources/win/atom.rc index 3559f58f50af4..81ad519dd13bb 100644 --- a/shell/browser/resources/win/atom.rc +++ b/shell/browser/resources/win/atom.rc @@ -50,8 +50,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,0,0,20190628 - PRODUCTVERSION 7,0,0,20190628 + FILEVERSION 7,0,0,20190627 + PRODUCTVERSION 7,0,0,20190627 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L From 1d8e16bc6ecb5a2700e75e8466f17da9e3391628 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Sat, 29 Jun 2019 03:19:01 +0900 Subject: [PATCH 10/46] docs: UploadData does not have contentType (#19026) --- docs/api/protocol.md | 4 +--- docs/api/structures/protocol-response-upload-data.md | 4 ++++ docs/api/structures/protocol-response.md | 4 +--- docs/api/structures/upload-data.md | 1 - filenames.auto.gni | 1 + 5 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 docs/api/structures/protocol-response-upload-data.md diff --git a/docs/api/protocol.md b/docs/api/protocol.md index d8e4f611a8912..215fbe6673dee 100644 --- a/docs/api/protocol.md +++ b/docs/api/protocol.md @@ -229,9 +229,7 @@ should be called with either a `String` or an object that has the `data`, * `url` String * `method` String (optional) * `session` Object (optional) - * `uploadData` Object (optional) - * `contentType` String - MIME type of the content. - * `data` String - Content to be sent. + * `uploadData` [ProtocolResponseUploadData](structures/protocol-response-upload-data.md) (optional) * `completion` Function (optional) * `error` Error diff --git a/docs/api/structures/protocol-response-upload-data.md b/docs/api/structures/protocol-response-upload-data.md new file mode 100644 index 0000000000000..bcb70da071ed4 --- /dev/null +++ b/docs/api/structures/protocol-response-upload-data.md @@ -0,0 +1,4 @@ +# ProtocolResponseUploadData Object + +* `contentType` String - MIME type of the content. +* `data` String - Content to be sent. diff --git a/docs/api/structures/protocol-response.md b/docs/api/structures/protocol-response.md index d3b9c99abf961..0d139ed4f85aa 100644 --- a/docs/api/structures/protocol-response.md +++ b/docs/api/structures/protocol-response.md @@ -28,9 +28,7 @@ * `session` Session (optional) - The session used for requesting URL, by default the HTTP request will reuse the current session. Setting `session` to `null` would use a random independent session. This is only used for URL responses. -* `uploadData` Object (optional) - The data used as upload data. This is only +* `uploadData` ProtocolResponseUploadData (optional) - The data used as upload data. This is only used for URL responses when `method` is `"POST"`. - * `contentType` String - MIME type of the content. - * `data` String - Content to be sent. [net-error]: https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h diff --git a/docs/api/structures/upload-data.md b/docs/api/structures/upload-data.md index ba719af667511..bcbed755b2b9b 100644 --- a/docs/api/structures/upload-data.md +++ b/docs/api/structures/upload-data.md @@ -1,6 +1,5 @@ # UploadData Object -* `contentType` String (optional) - Content type of the content to be sent. * `bytes` Buffer - Content being sent. * `file` String (optional) - Path of file being uploaded. * `blobUUID` String (optional) - UUID of blob data. Use [ses.getBlobData](../session.md#sesgetblobdataidentifier) method diff --git a/filenames.auto.gni b/filenames.auto.gni index 9139ef1054fb7..dc6bc77772101 100644 --- a/filenames.auto.gni +++ b/filenames.auto.gni @@ -95,6 +95,7 @@ auto_filenames = { "docs/api/structures/process-metric.md", "docs/api/structures/product.md", "docs/api/structures/protocol-request.md", + "docs/api/structures/protocol-response-upload-data.md", "docs/api/structures/protocol-response.md", "docs/api/structures/rectangle.md", "docs/api/structures/referrer.md", From 6eed4a98ceb48cb048777d9515586f76aa276476 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Fri, 28 Jun 2019 14:37:00 -0700 Subject: [PATCH 11/46] fix: do not remove node globals when context isolation is enabled (#18967) --- lib/renderer/init.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/renderer/init.ts b/lib/renderer/init.ts index 13b396a3691e3..c181abfeba6c6 100644 --- a/lib/renderer/init.ts +++ b/lib/renderer/init.ts @@ -179,14 +179,17 @@ if (nodeIntegration) { } } } else { - // Delete Node's symbols after the Environment has been loaded. - process.once('loaded', function () { - delete global.process - delete global.Buffer - delete global.setImmediate - delete global.clearImmediate - delete global.global - }) + // Delete Node's symbols after the Environment has been loaded in a + // non context-isolated environment + if (!contextIsolation) { + process.once('loaded', function () { + delete global.process + delete global.Buffer + delete global.setImmediate + delete global.clearImmediate + delete global.global + }) + } } const errorUtils = require('@electron/internal/common/error-utils') From e03a40026a238eec5b2e5b8bc144a7596a4c1ba1 Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Fri, 28 Jun 2019 14:38:18 -0700 Subject: [PATCH 12/46] fix: correct triggeredByAccelerator Event property behavior (#18865) Fixes #18808 Previously, the triggeredByAccelerator flag would be entirely coupled with whether or not the modifier keys were being used or not. This PR swaps out the ui::EventFlagsFromModifiers([event modifierFlags])) call in the macOS code to ui::EventFlagsFromNSEventWithModifiers(event, [event modifierFlags])). The latter outputs flags that take into account mouse click events on top of modifier flags (see Chromium documentation). The business logic to detect triggeredByAccelerator is then changed to exclude any mouse click flags. --- shell/browser/api/event_emitter.cc | 7 +- .../browser/ui/cocoa/atom_menu_controller.mm | 2 +- spec/api-menu-spec.js | 95 +++++++++++++++---- 3 files changed, 81 insertions(+), 23 deletions(-) diff --git a/shell/browser/api/event_emitter.cc b/shell/browser/api/event_emitter.cc index 5e8566b77db57..c5ea6d04df73c 100644 --- a/shell/browser/api/event_emitter.cc +++ b/shell/browser/api/event_emitter.cc @@ -77,12 +77,17 @@ v8::Local CreateCustomEvent(v8::Isolate* isolate, } v8::Local CreateEventFromFlags(v8::Isolate* isolate, int flags) { + const int mouse_button_flags = + (ui::EF_RIGHT_MOUSE_BUTTON | ui::EF_LEFT_MOUSE_BUTTON | + ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_BACK_MOUSE_BUTTON | + ui::EF_FORWARD_MOUSE_BUTTON); + const int is_mouse_click = static_cast(flags & mouse_button_flags); mate::Dictionary obj = mate::Dictionary::CreateEmpty(isolate); obj.Set("shiftKey", static_cast(flags & ui::EF_SHIFT_DOWN)); obj.Set("ctrlKey", static_cast(flags & ui::EF_CONTROL_DOWN)); obj.Set("altKey", static_cast(flags & ui::EF_ALT_DOWN)); obj.Set("metaKey", static_cast(flags & ui::EF_COMMAND_DOWN)); - obj.Set("triggeredByAccelerator", static_cast(flags)); + obj.Set("triggeredByAccelerator", !is_mouse_click); return obj.GetHandle(); } diff --git a/shell/browser/ui/cocoa/atom_menu_controller.mm b/shell/browser/ui/cocoa/atom_menu_controller.mm index 8a8b3322f8115..4f7b1cee9115b 100644 --- a/shell/browser/ui/cocoa/atom_menu_controller.mm +++ b/shell/browser/ui/cocoa/atom_menu_controller.mm @@ -345,7 +345,7 @@ - (void)itemSelected:(id)sender { if (model) { NSEvent* event = [NSApp currentEvent]; model->ActivatedAt(modelIndex, - ui::EventFlagsFromModifiers([event modifierFlags])); + ui::EventFlagsFromNSEventWithModifiers(event, [event modifierFlags])); } } diff --git a/spec/api-menu-spec.js b/spec/api-menu-spec.js index 720c45b988c67..e31d50ad7004a 100644 --- a/spec/api-menu-spec.js +++ b/spec/api-menu-spec.js @@ -2,13 +2,15 @@ const chai = require('chai') const dirtyChai = require('dirty-chai') const { ipcRenderer, remote } = require('electron') -const { BrowserWindow, Menu, MenuItem } = remote +const { BrowserWindow, globalShortcut, Menu, MenuItem } = remote const { sortMenuItems } = require('../lib/browser/api/menu-utils') const { closeWindow } = require('./window-helpers') const { expect } = chai chai.use(dirtyChai) +const isCi = remote.getGlobal('isCi') + describe('Menu module', () => { describe('Menu.buildFromTemplate', () => { it('should be able to attach extra fields', () => { @@ -835,36 +837,86 @@ describe('Menu module', () => { }) }) - describe('menu accelerators', () => { - let testFn = it - try { - // We have other tests that check if native modules work, if we fail to require - // robotjs let's skip this test to avoid false negatives - require('robotjs') - } catch (err) { - testFn = it.skip - } + describe('menu accelerators', async () => { const sendRobotjsKey = (key, modifiers = [], delay = 500) => { return new Promise((resolve, reject) => { - require('robotjs').keyTap(key, modifiers) - setTimeout(() => { - resolve() - }, delay) + try { + require('robotjs').keyTap(key, modifiers) + setTimeout(() => { + resolve() + }, delay) + } catch (e) { + reject(e) + } }) } - testFn('menu accelerators perform the specified action', async () => { + before(async function () { + // --ci flag breaks accelerator and robotjs interaction + if (isCi) { + this.skip() + } + + // before accelerator tests, use globalShortcut to test if + // RobotJS is working at all + let isKeyPressed = false + globalShortcut.register('q', () => { + isKeyPressed = true + }) + try { + await sendRobotjsKey('q') + } catch (e) { + this.skip() + } + + if (!isKeyPressed) { + this.skip() + } + + globalShortcut.unregister('q') + }) + + it('should perform the specified action', async () => { + let hasBeenClicked = false + const menu = Menu.buildFromTemplate([ + { + label: 'Test', + submenu: [ + { + label: 'Test Item', + accelerator: 'T', + click: (a, b, event) => { + hasBeenClicked = true + expect(event).to.deep.equal({ + shiftKey: false, + ctrlKey: false, + altKey: false, + metaKey: false, + triggeredByAccelerator: true + }) + }, + id: 'test' + } + ] + } + ]) + Menu.setApplicationMenu(menu) + expect(Menu.getApplicationMenu()).to.not.be.null() + await sendRobotjsKey('t') + expect(hasBeenClicked).to.equal(true) + }) + + it('should not activate upon clicking another key combination', async () => { + let hasBeenClicked = false const menu = Menu.buildFromTemplate([ { label: 'Test', submenu: [ { label: 'Test Item', - accelerator: 'Ctrl+T', - click: () => { - // Test will succeed, only when the menu accelerator action - // is triggered - Promise.resolve() + accelerator: 'T', + click: (a, b, event) => { + hasBeenClicked = true }, id: 'test' } @@ -873,7 +925,8 @@ describe('Menu module', () => { ]) Menu.setApplicationMenu(menu) expect(Menu.getApplicationMenu()).to.not.be.null() - await sendRobotjsKey('t', 'control') + await sendRobotjsKey('t', 'shift') + expect(hasBeenClicked).to.equal(false) }) }) }) From 6ece477779ae2bdc5aa58c0f0ef5f40628047a70 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Fri, 28 Jun 2019 15:22:23 -0700 Subject: [PATCH 13/46] refactor: nws13n: setCertificateVerifyProc (#18221) --- patches/chromium/.patches | 1 + ...emote_certificate_verification_logic.patch | 196 ++++++++++++++++++ shell/browser/api/atom_api_session.cc | 65 +++++- spec-main/api-session-spec.js | 20 ++ 4 files changed, 274 insertions(+), 8 deletions(-) create mode 100644 patches/chromium/network_service_allow_remote_certificate_verification_logic.patch diff --git a/patches/chromium/.patches b/patches/chromium/.patches index db0de05fd2d83..6d7710231a3bc 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -78,3 +78,4 @@ cross_site_document_resource_handler.patch woa_compiler_workaround.patch crashpad_pid_check.patch chore_add_debounce_on_the_updatewebcontentsvisibility_method_to.patch +network_service_allow_remote_certificate_verification_logic.patch diff --git a/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch b/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch new file mode 100644 index 0000000000000..ddeb623ebedae --- /dev/null +++ b/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch @@ -0,0 +1,196 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jeremy Apthorp +Date: Wed, 8 May 2019 17:25:55 -0700 +Subject: network service: allow remote certificate verification logic + + +diff --git a/services/network/network_context.cc b/services/network/network_context.cc +index 5d871fc08218b71c93141963db66465f775b1bc2..97128a6b6223e7fb977b5c9f20bf18da26c8348d 100644 +--- a/services/network/network_context.cc ++++ b/services/network/network_context.cc +@@ -89,6 +89,11 @@ + #include "services/network/url_loader.h" + #include "services/network/url_request_context_builder_mojo.h" + ++// Electron ++#include "net/cert/caching_cert_verifier.h" ++#include "net/cert/cert_verify_proc.h" ++#include "net/cert/multi_threaded_cert_verifier.h" ++ + #if BUILDFLAG(IS_CT_SUPPORTED) + #include "components/certificate_transparency/chrome_ct_policy_enforcer.h" + #include "components/certificate_transparency/chrome_require_ct_delegate.h" +@@ -310,6 +315,75 @@ std::string HashesToBase64String(const net::HashValueVector& hashes) { + + } // namespace + ++class RemoteCertVerifier : public net::CertVerifier { ++ public: ++ RemoteCertVerifier(std::unique_ptr upstream): upstream_(std::move(upstream)) { ++ } ++ ~RemoteCertVerifier() override = default; ++ ++ void Bind(mojom::CertVerifierClientPtr client_info) { ++ client_ = std::move(client_info); ++ } ++ ++ // CertVerifier implementation ++ int Verify(const RequestParams& params, ++ net::CertVerifyResult* verify_result, ++ net::CompletionOnceCallback callback, ++ std::unique_ptr* out_req, ++ const net::NetLogWithSource& net_log) override { ++ out_req->reset(); ++ ++ net::CompletionOnceCallback callback2 = base::BindOnce( ++ &RemoteCertVerifier::OnRequestFinished, base::Unretained(this), ++ params, std::move(callback), verify_result); ++ int result = upstream_->Verify(params, verify_result, ++ std::move(callback2), out_req, net_log); ++ if (result != net::ERR_IO_PENDING) { ++ // Synchronous completion ++ } ++ ++ return result; ++ } ++ ++ ++ void SetConfig(const Config& config) override { ++ upstream_->SetConfig(config); ++ } ++ ++ void OnRequestFinished(const RequestParams& params, net::CompletionOnceCallback callback, net::CertVerifyResult* verify_result, int error) { ++ if (client_) { ++ client_->Verify(error, *verify_result, params.certificate(), ++ params.hostname(), params.flags(), params.ocsp_response(), ++ base::BindOnce(&RemoteCertVerifier::OnRemoteResponse, ++ base::Unretained(this), params, verify_result, error, ++ std::move(callback))); ++ } else { ++ std::move(callback).Run(error); ++ } ++ } ++ ++ void OnRemoteResponse( ++ const RequestParams& params, ++ net::CertVerifyResult* verify_result, ++ int error, ++ net::CompletionOnceCallback callback, ++ int error2, ++ const net::CertVerifyResult& verify_result2) { ++ if (error2 == net::ERR_ABORTED) { ++ // use the default ++ std::move(callback).Run(error); ++ } else { ++ // use the override ++ verify_result->Reset(); ++ verify_result->verified_cert = verify_result2.verified_cert; ++ std::move(callback).Run(error2); ++ } ++ } ++ private: ++ std::unique_ptr upstream_; ++ mojom::CertVerifierClientPtr client_; ++}; ++ + constexpr uint32_t NetworkContext::kMaxOutstandingRequestsPerProcess; + constexpr bool NetworkContext::enable_resource_scheduler_; + +@@ -668,6 +742,12 @@ void NetworkContext::SetClient(mojom::NetworkContextClientPtr client) { + client_ = std::move(client); + } + ++void NetworkContext::SetCertVerifierClient(mojom::CertVerifierClientPtr client) { ++ if (remote_cert_verifier_) { ++ remote_cert_verifier_->Bind(std::move(client)); ++ } ++} ++ + void NetworkContext::CreateURLLoaderFactory( + mojom::URLLoaderFactoryRequest request, + mojom::URLLoaderFactoryParamsPtr params) { +@@ -2130,12 +2210,19 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext() { + net::CreateCertVerifyProcBuiltin(cert_net_fetcher_))); + } + #endif +- if (!cert_verifier) +- cert_verifier = net::CertVerifier::CreateDefault(cert_net_fetcher_); ++ if (!cert_verifier) { ++ auto mt_verifier = std::make_unique( ++ net::CertVerifyProc::CreateDefault(std::move(cert_net_fetcher_))); ++ auto remote_cert_verifier = std::make_unique(std::move(mt_verifier)); ++ remote_cert_verifier_ = remote_cert_verifier.get(); ++ cert_verifier = std::make_unique(std::move(remote_cert_verifier)); ++ } + } + +- builder.SetCertVerifier(IgnoreErrorsCertVerifier::MaybeWrapCertVerifier( +- *command_line, nullptr, std::move(cert_verifier))); ++ cert_verifier = IgnoreErrorsCertVerifier::MaybeWrapCertVerifier( ++ *command_line, nullptr, std::move(cert_verifier)); ++ ++ builder.SetCertVerifier(std::move(cert_verifier)); + + std::unique_ptr network_delegate = + std::make_unique(this); +diff --git a/services/network/network_context.h b/services/network/network_context.h +index 0f9e0fe5922c228d96ba7d8668a88d5d31c516e9..9552cfa88d2a45aa6bff24c3e89d080c8aad98a0 100644 +--- a/services/network/network_context.h ++++ b/services/network/network_context.h +@@ -74,6 +74,7 @@ class DomainReliabilityMonitor; + + namespace network { + class CertVerifierWithTrustAnchors; ++class RemoteCertVerifier; + class CookieManager; + class ExpectCTReporter; + class HostResolver; +@@ -176,6 +177,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext + + // mojom::NetworkContext implementation: + void SetClient(mojom::NetworkContextClientPtr client) override; ++ void SetCertVerifierClient(mojom::CertVerifierClientPtr client) override; + void CreateURLLoaderFactory(mojom::URLLoaderFactoryRequest request, + mojom::URLLoaderFactoryParamsPtr params) override; + void ResetURLLoaderFactories() override; +@@ -561,6 +563,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext + std::unique_ptr nss_temp_certs_cache_; + #endif + ++ RemoteCertVerifier* remote_cert_verifier_ = nullptr; ++ + // CertNetFetcher used by the context's CertVerifier. May be nullptr if + // CertNetFetcher is not used by the current platform. + scoped_refptr cert_net_fetcher_; +diff --git a/services/network/public/mojom/network_context.mojom b/services/network/public/mojom/network_context.mojom +index 69885a8bc0e2219ed6c10e684db0ad7d5cd6b87e..bf0750e75e357275f5a569cc8e0680b606b544f6 100644 +--- a/services/network/public/mojom/network_context.mojom ++++ b/services/network/public/mojom/network_context.mojom +@@ -160,6 +160,17 @@ interface TrustedURLLoaderHeaderClient { + OnLoaderCreated(int32 request_id, TrustedHeaderClient& header_client); + }; + ++interface CertVerifierClient { ++ Verify( ++ int32 default_error, ++ CertVerifyResult default_result, ++ X509Certificate certificate, ++ string hostname, ++ int32 flags, ++ string? ocsp_response ++ ) => (int32 error_code, CertVerifyResult result); ++}; ++ + // Parameters for constructing a network context. + struct NetworkContextParams { + // Name used by memory tools to identify the context. +@@ -541,6 +552,9 @@ interface NetworkContext { + // Sets a client for this network context. + SetClient(NetworkContextClient client); + ++ // Sets a certificate verifier client for this network context. ++ SetCertVerifierClient(CertVerifierClient? client); ++ + // Creates a new URLLoaderFactory with the given |params|. + CreateURLLoaderFactory(URLLoaderFactory& url_loader_factory, + URLLoaderFactoryParams params); diff --git a/shell/browser/api/atom_api_session.cc b/shell/browser/api/atom_api_session.cc index 3e724eb916ff0..bcf4e4b01267b 100644 --- a/shell/browser/api/atom_api_session.cc +++ b/shell/browser/api/atom_api_session.cc @@ -28,6 +28,7 @@ #include "content/public/browser/download_manager_delegate.h" #include "content/public/browser/network_service_instance.h" #include "content/public/browser/storage_partition.h" +#include "mojo/public/cpp/bindings/strong_binding.h" #include "native_mate/dictionary.h" #include "native_mate/object_template_builder.h" #include "net/base/completion_repeating_callback.h" @@ -39,6 +40,7 @@ #include "net/url_request/static_http_user_agent_settings.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" +#include "services/network/network_service.h" #include "services/network/public/cpp/features.h" #include "shell/browser/api/atom_api_cookies.h" #include "shell/browser/api/atom_api_download_item.h" @@ -415,6 +417,40 @@ void Session::DisableNetworkEmulation() { network_emulation_token_, network::mojom::NetworkConditions::New()); } +class ElectronCertVerifierClient : public network::mojom::CertVerifierClient { + public: + using CertVerifyProc = + base::RepeatingCallback)>; + explicit ElectronCertVerifierClient(CertVerifyProc proc) + : cert_verify_proc_(proc) {} + ~ElectronCertVerifierClient() override = default; + + // network::mojom::CertVerifierClient + void Verify(int default_error, + const net::CertVerifyResult& default_result, + const scoped_refptr& certificate, + const std::string& hostname, + int flags, + const base::Optional& ocsp_response, + VerifyCallback callback) override { + VerifyRequestParams params; + params.hostname = hostname; + params.default_result = net::ErrorToString(default_error); + params.error_code = default_error; + params.certificate = certificate; + cert_verify_proc_.Run( + params, + base::AdaptCallbackForRepeating(base::BindOnce( + [](VerifyCallback callback, const net::CertVerifyResult& result, + int err) { std::move(callback).Run(err, result); }, + std::move(callback), default_result))); + } + + private: + CertVerifyProc cert_verify_proc_; +}; + void WrapVerifyProc( base::RepeatingCallback)> proc, @@ -425,19 +461,32 @@ void WrapVerifyProc( void Session::SetCertVerifyProc(v8::Local val, mate::Arguments* args) { - base::RepeatingCallback)> - proc; + ElectronCertVerifierClient::CertVerifyProc proc; if (!(val->IsNull() || mate::ConvertFromV8(args->isolate(), val, &proc))) { args->ThrowError("Must pass null or function"); return; } - base::PostTaskWithTraits( - FROM_HERE, {BrowserThread::IO}, - base::BindOnce(&SetCertVerifyProcInIO, - WrapRefCounted(browser_context_->GetRequestContext()), - base::BindRepeating(&WrapVerifyProc, proc))); + if (base::FeatureList::IsEnabled(network::features::kNetworkService)) { + network::mojom::CertVerifierClientPtr cert_verifier_client; + if (proc) { + mojo::MakeStrongBinding( + std::make_unique(proc), + mojo::MakeRequest(&cert_verifier_client)); + } + content::BrowserContext::GetDefaultStoragePartition(browser_context_.get()) + ->GetNetworkContext() + ->SetCertVerifierClient(std::move(cert_verifier_client)); + + // This causes the cert verifier cache to be cleared. + content::GetNetworkService()->OnCertDBChanged(); + } else { + base::PostTaskWithTraits( + FROM_HERE, {BrowserThread::IO}, + base::BindOnce(&SetCertVerifyProcInIO, + WrapRefCounted(browser_context_->GetRequestContext()), + base::BindRepeating(&WrapVerifyProc, proc))); + } } void Session::SetPermissionRequestHandler(v8::Local val, diff --git a/spec-main/api-session-spec.js b/spec-main/api-session-spec.js index f338f29fcce9e..7d73a3420574b 100644 --- a/spec-main/api-session-spec.js +++ b/spec-main/api-session-spec.js @@ -468,6 +468,26 @@ describe('session module', () => { await expect(w.loadURL(url)).to.eventually.be.rejectedWith(/ERR_FAILED/) expect(w.webContents.getTitle()).to.equal(url) }) + + it('saves cached results', async () => { + let numVerificationRequests = 0 + session.defaultSession.setCertificateVerifyProc(({ hostname, certificate, verificationResult }, callback) => { + numVerificationRequests++ + callback(-2) + }) + + const url = `https://127.0.0.1:${server.address().port}` + await expect(w.loadURL(url), 'first load').to.eventually.be.rejectedWith(/ERR_FAILED/) + await emittedOnce(w.webContents, 'did-stop-loading') + await expect(w.loadURL(url + '/test'), 'second load').to.eventually.be.rejectedWith(/ERR_FAILED/) + expect(w.webContents.getTitle()).to.equal(url + '/test') + + // TODO(nornagon): there's no way to check if the network service is + // enabled from JS, so once we switch it on by default just change this + // test :) + const networkServiceEnabled = false + expect(numVerificationRequests).to.equal(networkServiceEnabled ? 1 : 2) + }) }) describe('ses.clearAuthCache(options)', () => { From 684d1838f9882fe66e2889d857b258ed3ba0598d Mon Sep 17 00:00:00 2001 From: Electron Bot Date: Sat, 29 Jun 2019 08:31:55 -0700 Subject: [PATCH 14/46] Bump v7.0.0-nightly.20190629 --- ELECTRON_VERSION | 2 +- package.json | 4 ++-- shell/browser/resources/win/atom.rc | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ELECTRON_VERSION b/ELECTRON_VERSION index 04fef377da207..5a3a966b11311 100644 --- a/ELECTRON_VERSION +++ b/ELECTRON_VERSION @@ -1 +1 @@ -7.0.0-nightly.20190627 \ No newline at end of file +7.0.0-nightly.20190629 \ No newline at end of file diff --git a/package.json b/package.json index 485882bce68a1..a0adebaa886b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron", - "version": "7.0.0-nightly.20190627", + "version": "7.0.0-nightly.20190629", "repository": "https://github.com/electron/electron", "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS", "devDependencies": { @@ -127,4 +127,4 @@ "git add filenames.auto.gni" ] } -} +} \ No newline at end of file diff --git a/shell/browser/resources/win/atom.rc b/shell/browser/resources/win/atom.rc index 81ad519dd13bb..835a5770ec697 100644 --- a/shell/browser/resources/win/atom.rc +++ b/shell/browser/resources/win/atom.rc @@ -50,8 +50,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,0,0,20190627 - PRODUCTVERSION 7,0,0,20190627 + FILEVERSION 7,0,0,20190629 + PRODUCTVERSION 7,0,0,20190629 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L From 0348b60a3452521ddc84eab4b41449019bef646e Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Sat, 29 Jun 2019 22:12:00 -0700 Subject: [PATCH 15/46] feat: add a series of new printing options (#18984) --- docs/api/web-contents.md | 21 ++- shell/browser/api/atom_api_web_contents.cc | 171 ++++++++++++++++++++- 2 files changed, 186 insertions(+), 6 deletions(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index d8418a2813965..0cdf39b6e495a 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -1227,9 +1227,26 @@ Returns [`PrinterInfo[]`](structures/printer-info.md). * `options` Object (optional) * `silent` Boolean (optional) - Don't ask user for print settings. Default is `false`. - * `printBackground` Boolean (optional) - Also prints the background color and image of + * `printBackground` Boolean (optional) - Prints the background color and image of the web page. Default is `false`. * `deviceName` String (optional) - Set the printer device name to use. Default is `''`. + * `color` Boolean (optional) - Set whether the printed web page will be in color or grayscale. Default is `true`. + * `margins` Object (optional) + * `marginType` String (optional) - Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen, you will also need to specify `top`, `bottom`, `left`, and `right`. + * `top` Number (optional) - The top margin of the printed web page, in pixels. + * `bottom` Number (optional) - The bottom margin of the printed web page, in pixels. + * `left` Number (optional) - The left margin of the printed web page, in pixels. + * `right` Number (optional) - The right margin of the printed web page, in pixels. + * `landscape` Boolean (optional) - Whether the web page should be printed in landscape mode. Default is `false`. + * `scaleFactor` Number (optional) - The scale factor of the web page. + * `pagesPerSheet` Number (optional) - The number of pages to print per page sheet. + * `collate` Boolean (optional) - Whether the web page should be collated. + * `copies` Number (optional) - The number of copies of the web page to print. + * `pageRanges` Record (optional) - The page range to print. Should have two keys: `from` and `to`. + * `duplexMode` String (optional) - Set the duplex mode of the printed web page. Can be `simplex`, `shortEdge`, or `longEdge`. + * `dpi` Object (optional) + * `horizontal` Number (optional) - The horizontal dpi. + * `vertical` Number (optional) - The vertical dpi. * `callback` Function (optional) * `success` Boolean - Indicates success of the print call. @@ -1240,7 +1257,7 @@ for printing. Calling `window.print()` in web page is equivalent to calling `webContents.print({ silent: false, printBackground: false, deviceName: '' })`. -Use `page-break-before: always; ` CSS style to force to print to a new page. +Use `page-break-before: always;` CSS style to force to print to a new page. #### `contents.printToPDF(options)` diff --git a/shell/browser/api/atom_api_web_contents.cc b/shell/browser/api/atom_api_web_contents.cc index 7933b9822a535..ae85795e20bb2 100644 --- a/shell/browser/api/atom_api_web_contents.cc +++ b/shell/browser/api/atom_api_web_contents.cc @@ -127,6 +127,59 @@ struct Converter { return dict.GetHandle(); } }; + +template <> +struct Converter { + static bool FromV8(v8::Isolate* isolate, + v8::Local val, + printing::MarginType* out) { + std::string type; + if (ConvertFromV8(isolate, val, &type)) { + if (type == "default") { + *out = printing::DEFAULT_MARGINS; + return true; + } + if (type == "none") { + *out = printing::NO_MARGINS; + return true; + } + if (type == "printableArea") { + *out = printing::PRINTABLE_AREA_MARGINS; + return true; + } + if (type == "custom") { + *out = printing::CUSTOM_MARGINS; + return true; + } + } + return false; + } +}; + +template <> +struct Converter { + static bool FromV8(v8::Isolate* isolate, + v8::Local val, + printing::DuplexMode* out) { + std::string mode; + if (ConvertFromV8(isolate, val, &mode)) { + if (mode == "simplex") { + *out = printing::SIMPLEX; + return true; + } + if (mode == "longEdge") { + *out = printing::LONG_EDGE; + return true; + } + if (mode == "shortEdge") { + *out = printing::SHORT_EDGE; + return true; + } + } + return false; + } +}; + #endif template <> @@ -1534,8 +1587,6 @@ bool WebContents::IsCurrentlyAudible() { #if BUILDFLAG(ENABLE_PRINTING) void WebContents::Print(mate::Arguments* args) { - bool silent = false, print_background = false; - base::string16 device_name; mate::Dictionary options = mate::Dictionary::CreateEmpty(args->isolate()); base::DictionaryValue settings; if (args->Length() >= 1 && !args->GetNext(&options)) { @@ -1547,11 +1598,123 @@ void WebContents::Print(mate::Arguments* args) { args->ThrowError("Invalid optional callback provided"); return; } + + // Set optional silent printing + bool silent = false; options.Get("silent", &silent); + + // Set custom margin settings + mate::Dictionary margins; + if (options.Get("margins", &margins)) { + printing::MarginType margin_type = printing::DEFAULT_MARGINS; + margins.Get("marginType", &margin_type); + settings.SetInteger(printing::kSettingMarginsType, margin_type); + + if (margin_type == printing::CUSTOM_MARGINS) { + int top = 0; + margins.Get("top", &top); + settings.SetInteger(printing::kSettingMarginTop, top); + int bottom = 0; + margins.Get("bottom", &bottom); + settings.SetInteger(printing::kSettingMarginBottom, bottom); + int left = 0; + margins.Get("left", &left); + settings.SetInteger(printing::kSettingMarginLeft, left); + int right = 0; + margins.Get("right", &right); + settings.SetInteger(printing::kSettingMarginRight, right); + } + } else { + settings.SetInteger(printing::kSettingMarginsType, + printing::DEFAULT_MARGINS); + } + + settings.SetBoolean(printing::kSettingHeaderFooterEnabled, false); + + // Set whether to print color or greyscale + bool print_color = true; + options.Get("color", &print_color); + int color_setting = print_color ? printing::COLOR : printing::GRAY; + settings.SetInteger(printing::kSettingColor, color_setting); + + bool landscape = false; + options.Get("landscape", &landscape); + settings.SetBoolean(printing::kSettingLandscape, landscape); + + base::string16 device_name; + options.Get("deviceName", &device_name); + settings.SetString(printing::kSettingDeviceName, device_name); + + int scale_factor = 100; + options.Get("scaleFactor", &scale_factor); + settings.SetInteger(printing::kSettingScaleFactor, scale_factor); + + int pages_per_sheet = 1; + options.Get("pagesPerSheet", &pages_per_sheet); + settings.SetInteger(printing::kSettingPagesPerSheet, pages_per_sheet); + + bool collate = true; + options.Get("collate", &collate); + settings.SetBoolean(printing::kSettingCollate, collate); + + int copies = 1; + options.Get("copies", &copies); + settings.SetInteger(printing::kSettingCopies, copies); + + bool print_background = false; options.Get("printBackground", &print_background); - if (options.Get("deviceName", &device_name) && !device_name.empty()) { - settings.SetString(printing::kSettingDeviceName, device_name); + settings.SetBoolean(printing::kSettingShouldPrintBackgrounds, + print_background); + + // For now we don't want to allow the user to enable these settings + // but we need to set them or a CHECK is hit. + settings.SetBoolean(printing::kSettingPrintToPDF, false); + settings.SetBoolean(printing::kSettingCloudPrintDialog, false); + settings.SetBoolean(printing::kSettingPrintWithPrivet, false); + settings.SetBoolean(printing::kSettingShouldPrintSelectionOnly, false); + settings.SetBoolean(printing::kSettingPrintWithExtension, false); + settings.SetBoolean(printing::kSettingRasterizePdf, false); + + // Set custom page ranges to print + std::vector page_ranges; + if (options.Get("pageRanges", &page_ranges)) { + std::unique_ptr page_range_list(new base::ListValue()); + for (size_t i = 0; i < page_ranges.size(); ++i) { + int from, to; + if (page_ranges[i].Get("from", &from) && page_ranges[i].Get("to", &to)) { + std::unique_ptr range( + new base::DictionaryValue()); + range->SetInteger(printing::kSettingPageRangeFrom, from); + range->SetInteger(printing::kSettingPageRangeTo, to); + page_range_list->Append(std::move(range)); + } else { + continue; + } + } + if (page_range_list->GetSize() > 0) + settings.SetList(printing::kSettingPageRange, std::move(page_range_list)); + } + + // Set custom duplex mode + printing::DuplexMode duplex_mode; + options.Get("duplexMode", &duplex_mode); + settings.SetInteger(printing::kSettingDuplexMode, duplex_mode); + + // Set custom dots per inch (dpi) + mate::Dictionary dpi_settings; + int dpi = 72; + if (options.Get("dpi", &dpi_settings)) { + int horizontal = 72; + dpi_settings.Get("horizontal", &horizontal); + settings.SetInteger(printing::kSettingDpiHorizontal, horizontal); + int vertical = 72; + dpi_settings.Get("vertical", &vertical); + settings.SetInteger(printing::kSettingDpiVertical, vertical); + } else { + settings.SetInteger(printing::kSettingDpiHorizontal, dpi); + settings.SetInteger(printing::kSettingDpiVertical, dpi); } + auto* print_view_manager = printing::PrintViewManagerBasic::FromWebContents(web_contents()); auto* focused_frame = web_contents()->GetFocusedFrame(); From f62d9f1411c756f3647d5d8b1bf9efeab23dc29e Mon Sep 17 00:00:00 2001 From: Electron Bot Date: Sun, 30 Jun 2019 08:31:45 -0700 Subject: [PATCH 16/46] Bump v7.0.0-nightly.20190630 --- ELECTRON_VERSION | 2 +- package.json | 2 +- shell/browser/resources/win/atom.rc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ELECTRON_VERSION b/ELECTRON_VERSION index 5a3a966b11311..c254469185067 100644 --- a/ELECTRON_VERSION +++ b/ELECTRON_VERSION @@ -1 +1 @@ -7.0.0-nightly.20190629 \ No newline at end of file +7.0.0-nightly.20190630 \ No newline at end of file diff --git a/package.json b/package.json index a0adebaa886b9..7821e09c0ccad 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron", - "version": "7.0.0-nightly.20190629", + "version": "7.0.0-nightly.20190630", "repository": "https://github.com/electron/electron", "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS", "devDependencies": { diff --git a/shell/browser/resources/win/atom.rc b/shell/browser/resources/win/atom.rc index 835a5770ec697..7c2726377d36e 100644 --- a/shell/browser/resources/win/atom.rc +++ b/shell/browser/resources/win/atom.rc @@ -50,8 +50,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,0,0,20190629 - PRODUCTVERSION 7,0,0,20190629 + FILEVERSION 7,0,0,20190630 + PRODUCTVERSION 7,0,0,20190630 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L From cc223d7cd270f6b0a401985d2467c5b815b6f68d Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Sun, 30 Jun 2019 19:57:31 -0700 Subject: [PATCH 17/46] fix: fire close event upon closing modal BrowserWindow in macOS (#19014) * fix: emit close event from modal on macOS * fix: Move fn call to correct spot * refactor: call notify fn directly --- shell/browser/native_window_mac.mm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index f96e8ddccd6a5..f0693079d84a7 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -492,6 +492,8 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { // When this is a sheet showing, performClose won't work. if (is_modal() && parent() && IsVisible()) { [parent()->GetNativeWindow().GetNativeNSWindow() endSheet:window_]; + // Manually emit close event (not triggered from close fn) + NotifyWindowCloseButtonClicked(); CloseImmediately(); return; } From 3859244a79aee8cbf8b89efe8f766984b62fb4d8 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Mon, 1 Jul 2019 04:58:39 +0200 Subject: [PATCH 18/46] chore: remove unused switches::kDisableHtmlFullscreenWindowResize (#19041) --- shell/browser/web_contents_preferences.cc | 3 --- shell/common/options_switches.cc | 4 ---- shell/common/options_switches.h | 1 - 3 files changed, 8 deletions(-) diff --git a/shell/browser/web_contents_preferences.cc b/shell/browser/web_contents_preferences.cc index 5b51fa35ff624..3b40c6e63b032 100644 --- a/shell/browser/web_contents_preferences.cc +++ b/shell/browser/web_contents_preferences.cc @@ -415,9 +415,6 @@ void WebContentsPreferences::AppendCommandLineSwitches( if (IsEnabled(options::kNodeIntegrationInSubFrames)) command_line->AppendSwitch(switches::kNodeIntegrationInSubFrames); - if (IsEnabled(options::kDisableHtmlFullscreenWindowResize)) - command_line->AppendSwitch(switches::kDisableHtmlFullscreenWindowResize); - // We are appending args to a webContents so let's save the current state // of our preferences object so that during the lifetime of the WebContents // we can fetch the options used to initally configure the WebContents diff --git a/shell/common/options_switches.cc b/shell/common/options_switches.cc index 7362ce381f162..912e73e41cd2b 100644 --- a/shell/common/options_switches.cc +++ b/shell/common/options_switches.cc @@ -242,10 +242,6 @@ const char kNodeIntegrationInWorker[] = "node-integration-in-worker"; // environments will be created in sub-frames. const char kNodeIntegrationInSubFrames[] = "node-integration-in-subframes"; -// Disable window resizing when HTML Fullscreen API is activated. -const char kDisableHtmlFullscreenWindowResize[] = - "disable-html-fullscreen-window-resize"; - // Widevine options // Path to Widevine CDM binaries. const char kWidevineCdmPath[] = "widevine-cdm-path"; diff --git a/shell/common/options_switches.h b/shell/common/options_switches.h index b16a24b8cf068..30881e95a2e29 100644 --- a/shell/common/options_switches.h +++ b/shell/common/options_switches.h @@ -117,7 +117,6 @@ extern const char kNativeWindowOpen[]; extern const char kNodeIntegrationInWorker[]; extern const char kWebviewTag[]; extern const char kNodeIntegrationInSubFrames[]; -extern const char kDisableHtmlFullscreenWindowResize[]; extern const char kDisableElectronSiteInstanceOverrides[]; extern const char kWidevineCdmPath[]; From 3038846f5d9375b3b275accf0e27b4a4bf825cc3 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 1 Jul 2019 07:58:06 -0700 Subject: [PATCH 19/46] chore: DirectoryLister memory management improvement (#18634) * chore: small memory management improvement Co-authored-by: Charles Kerr * chore: fix code style * use start-from-one ref count, check ref_counted.h for motivations * reuse list_base_dir_ * net::DirectorLister offloads directory enumeration to a different task sequence in its implementation, use of sequence runner on our end is unnecessary * Don't manually `Release` in `WebContentsDestroyed`, content::FileSelectListener already handles this case. --- shell/browser/web_dialog_helper.cc | 97 +++++++++++++++--------------- shell/browser/web_dialog_helper.h | 27 --------- 2 files changed, 47 insertions(+), 77 deletions(-) diff --git a/shell/browser/web_dialog_helper.cc b/shell/browser/web_dialog_helper.cc index 783eec2a16542..85e028d31a512 100644 --- a/shell/browser/web_dialog_helper.cc +++ b/shell/browser/web_dialog_helper.cc @@ -21,6 +21,7 @@ #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_observer.h" #include "native_mate/dictionary.h" +#include "net/base/directory_lister.h" #include "net/base/mime_util.h" #include "shell/browser/atom_browser_context.h" #include "shell/browser/native_window.h" @@ -36,8 +37,10 @@ namespace { class FileSelectHelper : public base::RefCounted, public content::WebContentsObserver, - public electron::DirectoryListerHelperDelegate { + public net::DirectoryLister::DirectoryListerDelegate { public: + REQUIRE_ADOPTION_FOR_REFCOUNTED_TYPE(); + FileSelectHelper(content::RenderFrameHost* render_frame_host, std::unique_ptr listener, blink::mojom::FileChooserParams::Mode mode) @@ -73,28 +76,46 @@ class FileSelectHelper : public base::RefCounted, base::BindOnce(&FileSelectHelper::OnSaveDialogDone, this))))); } - void OnDirectoryListerDone(std::vector file_info, - base::FilePath base_dir) override { - OnFilesSelected(std::move(file_info), base_dir); - Release(); - } - private: friend class base::RefCounted; ~FileSelectHelper() override {} - void EnumerateDirectory(base::FilePath base_dir) { - auto* lister = new net::DirectoryLister( - base_dir, net::DirectoryLister::NO_SORT_RECURSIVE, - new electron::DirectoryListerHelper(base_dir, this)); - lister->Start(); + // net::DirectoryLister::DirectoryListerDelegate + void OnListFile( + const net::DirectoryLister::DirectoryListerData& data) override { + // We don't want to return directory paths, only file paths + if (data.info.IsDirectory()) + return; + + lister_paths_.push_back(data.path); + } + + // net::DirectoryLister::DirectoryListerDelegate + void OnListDone(int error) override { + std::vector file_info; + for (const auto& path : lister_paths_) + file_info.push_back(FileChooserFileInfo::NewNativeFile( + blink::mojom::NativeFileInfo::New(path, base::string16()))); + + OnFilesSelected(std::move(file_info), lister_base_dir_); + Release(); + } + + void EnumerateDirectory() { + // Ensure that this fn is only called once + DCHECK(!lister_); + DCHECK(!lister_base_dir_.empty()); + DCHECK(lister_paths_.empty()); + + lister_.reset(new net::DirectoryLister( + lister_base_dir_, net::DirectoryLister::NO_SORT_RECURSIVE, this)); + lister_->Start(); // It is difficult for callers to know how long to keep a reference to // this instance. We AddRef() here to keep the instance alive after we // return to the caller. Once the directory lister is complete we - // Release() in OnDirectoryListerDone() and at that point we run - // OnFilesSelected() which will deref the last reference held by the - // listener. + // Release() & at that point we run OnFilesSelected() which will + // deref the last reference held by the listener. AddRef(); } @@ -102,7 +123,6 @@ class FileSelectHelper : public base::RefCounted, std::vector file_info; bool canceled = true; result.Get("canceled", &canceled); - base::FilePath base_dir; // For certain file chooser modes (kUploadFolder) we need to do some async // work before calling back to the listener. In that particular case the // listener is called from the directory enumerator. @@ -114,12 +134,8 @@ class FileSelectHelper : public base::RefCounted, // If we are uploading a folder we need to enumerate its contents if (mode_ == FileChooserParams::Mode::kUploadFolder && paths.size() >= 1) { - base_dir = paths[0]; - - // Actually enumerate soemwhere off-thread - base::SequencedTaskRunnerHandle::Get()->PostTask( - FROM_HERE, base::BindOnce(&FileSelectHelper::EnumerateDirectory, - this, base_dir)); + lister_base_dir_ = paths[0]; + EnumerateDirectory(); } else { for (auto& path : paths) { file_info.push_back(FileChooserFileInfo::NewNativeFile( @@ -140,7 +156,7 @@ class FileSelectHelper : public base::RefCounted, } if (ready_to_call_listener) - OnFilesSelected(std::move(file_info), base_dir); + OnFilesSelected(std::move(file_info), lister_base_dir_); } void OnSaveDialogDone(mate::Dictionary result) { @@ -187,6 +203,11 @@ class FileSelectHelper : public base::RefCounted, content::RenderFrameHost* render_frame_host_; std::unique_ptr listener_; blink::mojom::FileChooserParams::Mode mode_; + + // DirectoryLister-specific members + std::unique_ptr lister_; + base::FilePath lister_base_dir_; + std::vector lister_paths_; }; file_dialog::Filters GetFileTypesFromAcceptType( @@ -227,7 +248,7 @@ file_dialog::Filters GetFileTypesFromAcceptType( valid_type_count++; } - // If no valid exntesion is added, return empty filters. + // If no valid extension is added, return empty filters. if (extensions.empty()) return filters; @@ -259,30 +280,6 @@ file_dialog::Filters GetFileTypesFromAcceptType( namespace electron { -DirectoryListerHelper::DirectoryListerHelper( - base::FilePath base, - DirectoryListerHelperDelegate* helper) - : base_dir_(base), delegate_(helper) {} -DirectoryListerHelper::~DirectoryListerHelper() {} - -void DirectoryListerHelper::OnListFile( - const net::DirectoryLister::DirectoryListerData& data) { - // We don't want to return directory paths, only file paths - if (data.info.IsDirectory()) - return; - - paths_.push_back(data.path); -} -void DirectoryListerHelper::OnListDone(int error) { - std::vector file_info; - for (auto path : paths_) - file_info.push_back(FileChooserFileInfo::NewNativeFile( - blink::mojom::NativeFileInfo::New(path, base::string16()))); - - delegate_->OnDirectoryListerDone(std::move(file_info), base_dir_); - delete this; -} - WebDialogHelper::WebDialogHelper(NativeWindow* window, bool offscreen) : window_(window), offscreen_(offscreen), weak_factory_(this) {} @@ -298,8 +295,8 @@ void WebDialogHelper::RunFileChooser( settings.parent_window = window_; settings.title = base::UTF16ToUTF8(params.title); - scoped_refptr file_select_helper(new FileSelectHelper( - render_frame_host, std::move(listener), params.mode)); + auto file_select_helper = base::MakeRefCounted( + render_frame_host, std::move(listener), params.mode); if (params.mode == FileChooserParams::Mode::kSave) { settings.default_path = params.default_file_name; file_select_helper->ShowSaveDialog(settings); diff --git a/shell/browser/web_dialog_helper.h b/shell/browser/web_dialog_helper.h index fa1ed8d0e6090..ab745309ce02d 100644 --- a/shell/browser/web_dialog_helper.h +++ b/shell/browser/web_dialog_helper.h @@ -9,7 +9,6 @@ #include #include "base/memory/weak_ptr.h" -#include "net/base/directory_lister.h" #include "third_party/blink/public/mojom/choosers/file_chooser.mojom.h" namespace base { @@ -24,32 +23,6 @@ class WebContents; namespace electron { -class DirectoryListerHelperDelegate { - public: - virtual void OnDirectoryListerDone( - std::vector file_info, - base::FilePath base_dir) = 0; -}; - -class DirectoryListerHelper - : public net::DirectoryLister::DirectoryListerDelegate { - public: - DirectoryListerHelper(base::FilePath base, - DirectoryListerHelperDelegate* helper); - ~DirectoryListerHelper() override; - - private: - void OnListFile( - const net::DirectoryLister::DirectoryListerData& data) override; - void OnListDone(int error) override; - - base::FilePath base_dir_; - DirectoryListerHelperDelegate* delegate_; - std::vector paths_; - - DISALLOW_COPY_AND_ASSIGN(DirectoryListerHelper); -}; - class NativeWindow; class WebDialogHelper { From 3173b66d005150bcb7dfdcf14b8d289d64fb23e4 Mon Sep 17 00:00:00 2001 From: Electron Bot Date: Mon, 1 Jul 2019 08:31:22 -0700 Subject: [PATCH 20/46] Bump v7.0.0-nightly.20190701 --- ELECTRON_VERSION | 2 +- package.json | 2 +- shell/browser/resources/win/atom.rc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ELECTRON_VERSION b/ELECTRON_VERSION index c254469185067..4d08344113d3e 100644 --- a/ELECTRON_VERSION +++ b/ELECTRON_VERSION @@ -1 +1 @@ -7.0.0-nightly.20190630 \ No newline at end of file +7.0.0-nightly.20190701 \ No newline at end of file diff --git a/package.json b/package.json index 7821e09c0ccad..ba603c0b26ae3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron", - "version": "7.0.0-nightly.20190630", + "version": "7.0.0-nightly.20190701", "repository": "https://github.com/electron/electron", "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS", "devDependencies": { diff --git a/shell/browser/resources/win/atom.rc b/shell/browser/resources/win/atom.rc index 7c2726377d36e..0085bd81d5de4 100644 --- a/shell/browser/resources/win/atom.rc +++ b/shell/browser/resources/win/atom.rc @@ -50,8 +50,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,0,0,20190630 - PRODUCTVERSION 7,0,0,20190630 + FILEVERSION 7,0,0,20190701 + PRODUCTVERSION 7,0,0,20190701 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L From c7da54e82a5727b0a4491e788b4c37eafe425e9a Mon Sep 17 00:00:00 2001 From: Erick Zhao Date: Mon, 1 Jul 2019 10:07:27 -0700 Subject: [PATCH 21/46] fix: Correct modal focus behavior on macOS (#18995) Fixes #18502 This PR changes the focus and blur events that we emit in Electron to listen to changes in key window rather than main window. It swaps out windowDidBecomeMain and windowDidResignMain for windowDidBecomeKey and windowDidResignKey, respectively. --- .../ui/cocoa/atom_ns_window_delegate.mm | 4 +-- spec/api-browser-window-spec.js | 28 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/shell/browser/ui/cocoa/atom_ns_window_delegate.mm b/shell/browser/ui/cocoa/atom_ns_window_delegate.mm index f685377843105..371bfd2f13347 100644 --- a/shell/browser/ui/cocoa/atom_ns_window_delegate.mm +++ b/shell/browser/ui/cocoa/atom_ns_window_delegate.mm @@ -88,11 +88,11 @@ - (NSRect)windowWillUseStandardFrame:(NSWindow*)window return frame; } -- (void)windowDidBecomeMain:(NSNotification*)notification { +- (void)windowDidBecomeKey:(NSNotification*)notification { shell_->NotifyWindowFocus(); } -- (void)windowDidResignMain:(NSNotification*)notification { +- (void)windowDidResignKey:(NSNotification*)notification { shell_->NotifyWindowBlur(); } diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index e310090dc7809..8dd37d158b3ab 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -1637,6 +1637,34 @@ describe('BrowserWindow module', () => { }) }) + describe('focus event', () => { + it('should not emit if focusing on a main window with a modal open', (done) => { + const childWindowClosed = false + const child = new BrowserWindow({ + parent: w, + modal: true, + show: false + }) + + child.once('ready-to-show', () => { + child.show() + }) + + child.on('show', () => { + w.once('focus', () => { + expect(child.isDestroyed()).to.equal(true) + done() + }) + w.focus() // this should not trigger the above listener + child.close() + }) + + // act + child.loadURL(server.url) + w.show() + }) + }) + describe('sheet-begin event', () => { let sheet = null From 5a3073128c47ce8a17db608e58093836cab24531 Mon Sep 17 00:00:00 2001 From: Heilig Benedek Date: Mon, 1 Jul 2019 19:47:16 +0200 Subject: [PATCH 22/46] fix: add shell=True to make run-gn-format run properly on Windows (#18993) --- script/run-gn-format.py | 1 + 1 file changed, 1 insertion(+) diff --git a/script/run-gn-format.py b/script/run-gn-format.py index a982d4f39c95c..649b085bfa1b5 100644 --- a/script/run-gn-format.py +++ b/script/run-gn-format.py @@ -15,6 +15,7 @@ def main(): for gn_file in sys.argv[1:]: subprocess.check_call( ['gn', 'format', gn_file], + shell=True, env=new_env ) From 5154b954470e87842e3ff6f9c6785e2371059d60 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 1 Jul 2019 11:25:45 -0700 Subject: [PATCH 23/46] chore: update @types/node and @primer/octicons (#19025) --- filenames.gni | 12 ++++++------ package.json | 6 +++--- spec-main/api-app-spec.ts | 8 ++++++-- yarn.lock | 41 +++++++++++++++++++++++++-------------- 4 files changed, 41 insertions(+), 26 deletions(-) diff --git a/filenames.gni b/filenames.gni index 8eec52480b950..ef18228df675f 100644 --- a/filenames.gni +++ b/filenames.gni @@ -14,12 +14,12 @@ filenames = { ] default_app_octicon_sources = [ - "node_modules/octicons/build/build.css", - "node_modules/octicons/build/svg/gist.svg", - "node_modules/octicons/build/svg/mark-github.svg", - "node_modules/octicons/build/svg/gear.svg", - "node_modules/octicons/build/svg/star.svg", - "node_modules/octicons/build/svg/gift.svg", + "node_modules/@primer/octicons/build/build.css", + "node_modules/@primer/octicons/build/svg/gist.svg", + "node_modules/@primer/octicons/build/svg/mark-github.svg", + "node_modules/@primer/octicons/build/svg/gear.svg", + "node_modules/@primer/octicons/build/svg/star.svg", + "node_modules/@primer/octicons/build/svg/gift.svg", ] lib_sources = [ diff --git a/package.json b/package.json index ba603c0b26ae3..c2bd5da80fb66 100644 --- a/package.json +++ b/package.json @@ -7,19 +7,20 @@ "@electron/docs-parser": "^0.3.0", "@electron/typescript-definitions": "^8.3.1", "@octokit/rest": "^16.3.2", + "@primer/octicons": "^9.1.1", "@types/chai": "^4.1.7", "@types/chai-as-promised": "^7.1.0", "@types/express": "^4.16.1", "@types/fs-extra": "^5.0.5", "@types/mocha": "^5.2.6", - "@types/node": "^10.12.21", + "@types/node": "^12.0.10", "@types/split": "^1.0.0", "@types/webpack": "^4.4.32", "@types/webpack-env": "^1.13.9", "@typescript-eslint/eslint-plugin": "^1.4.2", "@typescript-eslint/parser": "^1.4.2", "asar": "^1.0.0", - "check-for-leaks": "^1.0.2", + "check-for-leaks": "^1.2.1", "clang-format": "^1.2.3", "colors": "^1.1.2", "dotenv-safe": "^4.0.4", @@ -40,7 +41,6 @@ "lint-staged": "^8.1.0", "minimist": "^1.2.0", "nugget": "^2.0.1", - "octicons": "^7.3.0", "pre-flight": "^1.1.0", "remark-cli": "^4.0.0", "remark-preset-lint-markdown-style-guide": "^2.1.1", diff --git a/spec-main/api-app-spec.ts b/spec-main/api-app-spec.ts index 59b686ff9bd40..e042ee1a11ba1 100644 --- a/spec-main/api-app-spec.ts +++ b/spec-main/api-app-spec.ts @@ -164,7 +164,9 @@ describe('app module', () => { let output = '' appProcess = cp.spawn(electronPath, [appPath]) - appProcess.stdout.on('data', data => { output += data }) + if (appProcess && appProcess.stdout) { + appProcess.stdout.on('data', data => { output += data }) + } const [code] = await emittedOnce(appProcess, 'close') if (process.platform !== 'win32') { @@ -196,7 +198,9 @@ describe('app module', () => { // Singleton will send us greeting data to let us know it's running. // After that, ask it to exit gracefully and confirm that it does. - appProcess.stdout.on('data', data => appProcess!.kill()) + if (appProcess && appProcess.stdout) { + appProcess.stdout.on('data', data => appProcess!.kill()) + } const [code, signal] = await emittedOnce(appProcess, 'close') const message = `code:\n${code}\nsignal:\n${signal}` diff --git a/yarn.lock b/yarn.lock index 72d36a47761b1..eda1f0bac7ae4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -120,6 +120,13 @@ universal-user-agent "^2.0.0" url-template "^2.0.8" +"@primer/octicons@^9.1.1": + version "9.1.1" + resolved "https://registry.yarnpkg.com/@primer/octicons/-/octicons-9.1.1.tgz#a72a59e8ec77521cc2eefb36c345f780a61c79fb" + integrity sha512-7EGM0+Kx39bIgaYr9bTCzFvBCxm+fqh/YJIoSns8zfCwss32ZJ2GDP3024UH709VQtM5cKFU4JcIYPHyGdSfIg== + dependencies: + object-assign "^4.1.1" + "@samverschueren/stream-to-observable@^0.3.0": version "0.3.0" resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f" @@ -199,15 +206,16 @@ version "11.13.8" resolved "https://registry.yarnpkg.com/@types/node/-/node-11.13.8.tgz#e5d71173c95533be9842b2c798978f095f912aab" -"@types/node@^10.12.21": - version "10.14.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.6.tgz#9cbfcb62c50947217f4d88d4d274cc40c22625a9" - "@types/node@^11.13.7": version "11.13.14" resolved "https://registry.yarnpkg.com/@types/node/-/node-11.13.14.tgz#03e9416f7d699d71742e5a1e455def7bd55f8fb9" integrity sha512-9NjFOB6UUGjJLNANmyIouuaN8YPsPgC4DCOd5lU+DL7HSX/RCfzz0JOtHlspEJq1Ll/JUu/8Cm4wzxpZ8w5sjQ== +"@types/node@^12.0.10": + version "12.0.10" + resolved "https://registry.yarnpkg.com/@types/node/-/node-12.0.10.tgz#51babf9c7deadd5343620055fc8aff7995c8b031" + integrity sha512-LcsGbPomWsad6wmMNv7nBLw7YYYyfdYcz6xryKYQhx89c3XXan+8Q6AJ43G5XDIaklaVkK3mE4fCb0SBvMiPSQ== + "@types/normalize-package-data@^2.4.0": version "2.4.0" resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.0.tgz#e486d0d97396d79beedd0a6e33f4534ff6b4973e" @@ -537,6 +545,14 @@ anymatch@^2.0.0: micromatch "^3.1.4" normalize-path "^2.1.1" +anymatch@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.0.2.tgz#ddb3a8495d44875423af7b919aace11e91732a41" + integrity sha512-rUe9SxpRQlVg4EM8It7JMNWWYHAirTPpbTuvaSKybb5IejNgWB3PGBBX9rrPKDx2pM/p3Wh+7+ASaWRyyAbxmQ== + dependencies: + normalize-path "^3.0.0" + picomatch "^2.0.4" + aproba@^1.0.3, aproba@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" @@ -1089,11 +1105,12 @@ check-error@^1.0.2: resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82" integrity sha1-V00xLt2Iu13YkS6Sht1sCu1KrII= -check-for-leaks@^1.0.2: - version "1.2.0" - resolved "https://registry.yarnpkg.com/check-for-leaks/-/check-for-leaks-1.2.0.tgz#ea3b50164e975779332c62813195ff8c6af826cc" +check-for-leaks@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/check-for-leaks/-/check-for-leaks-1.2.1.tgz#4ac108ee3f8e6b99f5ad36f6b98cba1d7f4816d0" + integrity sha512-9OdOSRZY6N0w5JCdJpqsC5MkD6EPGYpHmhtf4l5nl3DRETDZshP6C1EGN/vVhHDTY6AsOK3NhdFfrMe3NWZl7g== dependencies: - anymatch "^1.3.0" + anymatch "^3.0.2" minimist "^1.2.0" parse-gitignore "^0.4.0" walk-sync "^0.3.2" @@ -4215,12 +4232,6 @@ object.pick@^1.3.0: dependencies: isobject "^3.0.1" -octicons@^7.3.0: - version "7.4.0" - resolved "https://registry.yarnpkg.com/octicons/-/octicons-7.4.0.tgz#0be0082ed75b81e680800ef978bf47078b670091" - dependencies: - object-assign "^4.1.1" - octokit-pagination-methods@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/octokit-pagination-methods/-/octokit-pagination-methods-1.1.0.tgz#cf472edc9d551055f9ef73f6e42b4dbb4c80bea4" @@ -4563,7 +4574,7 @@ performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" -picomatch@^2.0.5: +picomatch@^2.0.4, picomatch@^2.0.5: version "2.0.7" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.0.7.tgz#514169d8c7cd0bdbeecc8a2609e34a7163de69f6" integrity sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA== From 21d04ed3f42daf0c46281d91aa0b270da8045950 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Mon, 1 Jul 2019 14:03:19 -0700 Subject: [PATCH 24/46] feat: improve callback value for webContents.print() (#19000) Resolves #18980. Adds granularity to the optional callback in webContents.print() by adding a failureType value in addition to the success boolean that differentiates between cancelled and failed print jobs. --- docs/api/web-contents.md | 10 +++++++ patches/chromium/printing.patch | 51 ++++++++++++++++++++------------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 0cdf39b6e495a..a1dd2a4c95dd1 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -1249,6 +1249,7 @@ Returns [`PrinterInfo[]`](structures/printer-info.md). * `vertical` Number (optional) - The vertical dpi. * `callback` Function (optional) * `success` Boolean - Indicates success of the print call. + * `failureReason` String - Called back if the print fails; can be `cancelled` or `failed`. Prints window's web page. When `silent` is set to `true`, Electron will pick the system's default printer if `deviceName` is empty and the default settings @@ -1259,6 +1260,15 @@ Calling `window.print()` in web page is equivalent to calling Use `page-break-before: always;` CSS style to force to print to a new page. +Example usage: + +```js +const options = { silent: true, deviceName: 'My-Printer' } +win.webContents.print(options, (success, errorType) => { + if (!success) console.log(errorType) +}) +``` + #### `contents.printToPDF(options)` * `options` Object diff --git a/patches/chromium/printing.patch b/patches/chromium/printing.patch index ce54404c734ca..1e8d5fa83bbd7 100644 --- a/patches/chromium/printing.patch +++ b/patches/chromium/printing.patch @@ -46,7 +46,7 @@ index 88a6142eea4c7a219c08fe3463c44711f5c9fada..81db315a0036a123658697aa677e2356 void PrintJobWorker::GetSettingsWithUI(int document_page_count, diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc -index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b48926158311aa0 100644 +index 7ba43aada1ac44827cca264d6f37814e4a91f458..1ca9fe408ec9a5129f6cec46daeeee46bab60983 100644 --- a/chrome/browser/printing/print_view_manager_base.cc +++ b/chrome/browser/printing/print_view_manager_base.cc @@ -27,10 +27,7 @@ @@ -68,7 +68,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b489261 #include "mojo/public/cpp/system/buffer.h" #include "printing/buildflags/buildflags.h" #include "printing/metafile_skia.h" -@@ -64,6 +62,8 @@ using PrintSettingsCallback = +@@ -64,6 +64,8 @@ using PrintSettingsCallback = base::OnceCallback)>; void ShowWarningMessageBox(const base::string16& message) { @@ -77,7 +77,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b489261 // Runs always on the UI thread. static bool is_dialog_shown = false; if (is_dialog_shown) -@@ -72,6 +72,7 @@ void ShowWarningMessageBox(const base::string16& message) { +@@ -72,6 +74,7 @@ void ShowWarningMessageBox(const base::string16& message) { base::AutoReset auto_reset(&is_dialog_shown, true); chrome::ShowWarningMessageBox(nullptr, base::string16(), message); @@ -85,7 +85,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b489261 } #if BUILDFLAG(ENABLE_PRINT_PREVIEW) -@@ -109,12 +110,14 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents) +@@ -109,12 +112,14 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents) queue_(g_browser_process->print_job_manager()->queue()), weak_ptr_factory_(this) { DCHECK(queue_); @@ -100,7 +100,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b489261 } PrintViewManagerBase::~PrintViewManagerBase() { -@@ -122,12 +125,14 @@ PrintViewManagerBase::~PrintViewManagerBase() { +@@ -122,12 +127,14 @@ PrintViewManagerBase::~PrintViewManagerBase() { DisconnectFromCurrentPrintJob(); } @@ -118,7 +118,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b489261 } #if BUILDFLAG(ENABLE_PRINT_PREVIEW) -@@ -242,9 +247,9 @@ void PrintViewManagerBase::StartLocalPrintJob( +@@ -242,9 +249,9 @@ void PrintViewManagerBase::StartLocalPrintJob( void PrintViewManagerBase::UpdatePrintingEnabled() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // The Unretained() is safe because ForEachFrame() is synchronous. @@ -131,7 +131,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b489261 } void PrintViewManagerBase::NavigationStopped() { -@@ -336,7 +341,7 @@ void PrintViewManagerBase::OnPrintingFailed(int cookie) { +@@ -336,7 +343,7 @@ void PrintViewManagerBase::OnPrintingFailed(int cookie) { PrintManager::OnPrintingFailed(cookie); #if BUILDFLAG(ENABLE_PRINT_PREVIEW) @@ -140,13 +140,14 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b489261 #endif ReleasePrinterQuery(); -@@ -436,9 +441,12 @@ void PrintViewManagerBase::OnNotifyPrintJobEvent( +@@ -436,9 +443,13 @@ void PrintViewManagerBase::OnNotifyPrintJobEvent( content::NotificationService::NoDetails()); break; } - case JobEventDetails::USER_INIT_DONE: - case JobEventDetails::DEFAULT_INIT_DONE: case JobEventDetails::USER_INIT_CANCELED: { ++ printing_cancelled_ = true; + ReleasePrintJob(); + break; + } @@ -155,7 +156,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b489261 NOTREACHED(); break; } -@@ -532,9 +540,6 @@ bool PrintViewManagerBase::CreateNewPrintJob(PrinterQuery* query) { +@@ -532,9 +543,6 @@ bool PrintViewManagerBase::CreateNewPrintJob(PrinterQuery* query) { DCHECK(!quit_inner_loop_); DCHECK(query); @@ -165,7 +166,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b489261 // We can't print if there is no renderer. if (!web_contents()->GetRenderViewHost() || !web_contents()->GetRenderViewHost()->IsRenderViewLive()) { -@@ -544,8 +549,6 @@ bool PrintViewManagerBase::CreateNewPrintJob(PrinterQuery* query) { +@@ -544,8 +552,6 @@ bool PrintViewManagerBase::CreateNewPrintJob(PrinterQuery* query) { DCHECK(!print_job_); print_job_ = base::MakeRefCounted(); print_job_->Initialize(query, RenderSourceName(), number_pages_); @@ -174,17 +175,21 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b489261 printing_succeeded_ = false; return true; } -@@ -594,6 +597,9 @@ void PrintViewManagerBase::ReleasePrintJob() { +@@ -594,6 +600,13 @@ void PrintViewManagerBase::ReleasePrintJob() { content::RenderFrameHost* rfh = printing_rfh_; printing_rfh_ = nullptr; -+ if (!callback_.is_null()) -+ std::move(callback_).Run(printing_succeeded_); ++ if (!callback_.is_null()) { ++ std::string cb_str = ""; ++ if (!printing_succeeded_) ++ cb_str = printing_cancelled_ ? "cancelled" : "failed"; ++ std::move(callback_).Run(printing_succeeded_, cb_str); ++ } + if (!print_job_) return; -@@ -604,7 +610,7 @@ void PrintViewManagerBase::ReleasePrintJob() { +@@ -604,7 +620,7 @@ void PrintViewManagerBase::ReleasePrintJob() { } registrar_.Remove(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, @@ -193,7 +198,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b489261 // Don't close the worker thread. print_job_ = nullptr; } -@@ -674,6 +680,9 @@ bool PrintViewManagerBase::PrintNowInternal( +@@ -674,6 +690,9 @@ bool PrintViewManagerBase::PrintNowInternal( // Don't print / print preview interstitials or crashed tabs. if (web_contents()->ShowingInterstitialPage() || web_contents()->IsCrashed()) return false; @@ -204,19 +209,19 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..c41b0c24974147e847baa21b9b489261 } diff --git a/chrome/browser/printing/print_view_manager_base.h b/chrome/browser/printing/print_view_manager_base.h -index cf074791d0e2e17bbf8cf0b000b8d63e235b7deb..c12107d0af1291c113e05bc1a9cc87e2466c8610 100644 +index cf074791d0e2e17bbf8cf0b000b8d63e235b7deb..30b6e042b12f23299b3b7eaecb8a8e71c221786d 100644 --- a/chrome/browser/printing/print_view_manager_base.h +++ b/chrome/browser/printing/print_view_manager_base.h -@@ -39,6 +39,8 @@ class PrintJob; +@@ -39,6 +40,8 @@ class PrintJob; class PrintQueriesQueue; class PrinterQuery; -+using CompletionCallback = base::OnceCallback; ++using CompletionCallback = base::OnceCallback; + // Base class for managing the print commands for a WebContents. class PrintViewManagerBase : public content::NotificationObserver, public PrintManager { -@@ -48,7 +50,9 @@ class PrintViewManagerBase : public content::NotificationObserver, +@@ -48,7 +51,9 @@ class PrintViewManagerBase : public content::NotificationObserver, // Prints the current document immediately. Since the rendering is // asynchronous, the actual printing will not be completed on the return of // this function. Returns false if printing is impossible at the moment. @@ -227,7 +232,7 @@ index cf074791d0e2e17bbf8cf0b000b8d63e235b7deb..c12107d0af1291c113e05bc1a9cc87e2 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) // Prints the document in |print_data| with settings specified in -@@ -195,6 +199,9 @@ class PrintViewManagerBase : public content::NotificationObserver, +@@ -195,9 +200,15 @@ class PrintViewManagerBase : public content::NotificationObserver, // The current RFH that is printing with a system printing dialog. content::RenderFrameHost* printing_rfh_; @@ -237,6 +242,12 @@ index cf074791d0e2e17bbf8cf0b000b8d63e235b7deb..c12107d0af1291c113e05bc1a9cc87e2 // Indication of success of the print job. bool printing_succeeded_; ++ // Indication of whether the print job was manually cancelled ++ bool printing_cancelled_ = false; ++ + // Set while running an inner message loop inside RenderAllMissingPagesNow(). + // This means we are _blocking_ until all the necessary pages have been + // rendered or the print settings are being loaded. diff --git a/chrome/browser/printing/printing_message_filter.cc b/chrome/browser/printing/printing_message_filter.cc index 1f79e7b127f35e2eaef923af5c4a5f0a7e5250a5..327b37dfbb84c60d7f0e339c3c4cb8ca3b3c9b26 100644 --- a/chrome/browser/printing/printing_message_filter.cc From 4e2990d3aac52c7b6da65eb5122956d12d70007f Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Mon, 1 Jul 2019 16:53:07 -0700 Subject: [PATCH 25/46] docs: make the dialog example work out of the box on all 3 platforms (#19055) --- docs/api/dialog.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/dialog.md b/docs/api/dialog.md index 1f4a0c97e885c..ac526fa50cd7a 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -4,11 +4,11 @@ Process: [Main](../glossary.md#main-process) -An example of showing a dialog to select multiple files and directories: +An example of showing a dialog to select multiple files: ```javascript const { dialog } = require('electron') -console.log(dialog.showOpenDialog({ properties: ['openFile', 'openDirectory', 'multiSelections'] })) +console.log(dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] })) ``` The Dialog is opened from Electron's main thread. If you want to use the dialog From dee331519cb7bd62928332af3194bbcb6c25987f Mon Sep 17 00:00:00 2001 From: Jerry Wu Date: Tue, 2 Jul 2019 03:36:50 -0700 Subject: [PATCH 26/46] fix: disable nodeIntegration & insecure resource warnings for localhost (#18814) * fix: disable remote host nodeIntegration warning for localhost In warnAboutNodeWithRemoteContent(), add a check to see if the hostname is "localhost" and prevent the warning message if it is. * fix: disable loading insecure resources warning for localhost In warnAboutInsecureResources(), filter out resources from localhost since they are most likely not a threat. * test: add tests for ignoring security warnings when using localhost Add tests for ignoring warning messages for the following scenarios: 1. node integration with remote content from localhost 2. loading insecure resources from localhost * test: fix insecure resource test * test: pass nodeIntegration with remote test on did-finish-load * test: maybe fix node integration test (error w/ conv circular struct) * test: update test description * test: use "load" event to check when nodeIntegration test has finished Instead of relying on the "did-finish-load" event, which may result in a race condition, add an "onload" handler that logs "loaded" to the console. This will execute _after_ the nodeIntegration check, so it can be safely used as a signal to indicate that the test is done. * test: rename base-page-security-load-message.html * fix: ignore enabled remote module warning for localhost * refactor: add isLocalhost() --- lib/renderer/security-warnings.ts | 18 ++++++- .../base-page-security-onload-message.html | 10 ++++ spec/security-warnings-spec.js | 48 +++++++++++++++++++ 3 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 spec/fixtures/pages/base-page-security-onload-message.html diff --git a/lib/renderer/security-warnings.ts b/lib/renderer/security-warnings.ts index 48db42c7fffca..4e0ef4afd83fb 100644 --- a/lib/renderer/security-warnings.ts +++ b/lib/renderer/security-warnings.ts @@ -58,6 +58,19 @@ const getIsRemoteProtocol = function () { } } +/** + * Checks if the current window is from localhost. + * + * @returns {boolean} - Is current window from localhost? + */ +const isLocalhost = function () { + if (!window || !window.location) { + return false + } + + return window.location.hostname === 'localhost' +} + /** * Tries to determine whether a CSP without `unsafe-eval` is set. * @@ -92,6 +105,7 @@ const warnAboutInsecureResources = function () { const resources = window.performance .getEntriesByType('resource') .filter(({ name }) => /^(http|ftp):/gi.test(name || '')) + .filter(({ name }) => new URL(name).hostname !== 'localhost') .map(({ name }) => `- ${name}`) .join('\n') @@ -115,7 +129,7 @@ const warnAboutInsecureResources = function () { * Logs a warning message about Node integration. */ const warnAboutNodeWithRemoteContent = function (nodeIntegration: boolean) { - if (!nodeIntegration) return + if (!nodeIntegration || isLocalhost()) return if (getIsRemoteProtocol()) { const warning = `This renderer process has Node.js integration enabled @@ -254,7 +268,7 @@ const warnAboutAllowedPopups = function () { // Logs a warning message about the remote module const warnAboutRemoteModuleWithRemoteContent = function (webPreferences?: Electron.WebPreferences) { - if (!webPreferences || !webPreferences.enableRemoteModule) return + if (!webPreferences || !webPreferences.enableRemoteModule || isLocalhost()) return if (getIsRemoteProtocol()) { const warning = `This renderer process has "enableRemoteModule" enabled diff --git a/spec/fixtures/pages/base-page-security-onload-message.html b/spec/fixtures/pages/base-page-security-onload-message.html new file mode 100644 index 0000000000000..befc2752cab8e --- /dev/null +++ b/spec/fixtures/pages/base-page-security-onload-message.html @@ -0,0 +1,10 @@ + + + + + + + diff --git a/spec/security-warnings-spec.js b/spec/security-warnings-spec.js index c0fd0fe54f456..45141b4dd966f 100644 --- a/spec/security-warnings-spec.js +++ b/spec/security-warnings-spec.js @@ -78,6 +78,24 @@ describe('security warnings', () => { w.loadURL(`http://127.0.0.1:8881/base-page-security.html`) }) + it('should not warn about Node.js integration with remote content from localhost', (done) => { + w = new BrowserWindow({ + show: false, + webPreferences: { + nodeIntegration: true + } + }) + w.webContents.once('console-message', (e, level, message) => { + expect(message).to.not.include('Node.js Integration with Remote Content') + + if (message === 'loaded') { + done() + } + }) + + w.loadURL(`http://localhost:8881/base-page-security-onload-message.html`) + }) + const generateSpecs = (description, webPreferences) => { describe(description, () => { it('should warn about disabled webSecurity', (done) => { @@ -189,6 +207,20 @@ describe('security warnings', () => { w.webContents.openDevTools() }) + it('should not warn about loading insecure-resources.html from localhost', (done) => { + w = new BrowserWindow({ + show: false, + webPreferences + }) + w.webContents.once('console-message', (e, level, message) => { + expect(message).to.not.include('insecure-resources.html') + done() + }) + + w.loadURL(`http://localhost:8881/insecure-resources.html`) + w.webContents.openDevTools() + }) + it('should warn about enabled remote module with remote content', (done) => { w = new BrowserWindow({ show: false, @@ -201,6 +233,22 @@ describe('security warnings', () => { w.loadURL(`http://127.0.0.1:8881/base-page-security.html`) }) + + it('should not warn about enabled remote module with remote content from localhost', (done) => { + w = new BrowserWindow({ + show: false, + webPreferences + }) + w.webContents.once('console-message', (e, level, message) => { + expect(message).to.not.include('enableRemoteModule') + + if (message === 'loaded') { + done() + } + }) + + w.loadURL(`http://localhost:8881/base-page-security-onload-message.html`) + }) }) } From 9a4e551c8b824cb373e79a928e2c6058ff1dc583 Mon Sep 17 00:00:00 2001 From: Chase Colman <5411+chase@users.noreply.github.com> Date: Tue, 2 Jul 2019 11:09:10 -0400 Subject: [PATCH 27/46] docs: fix undefined isMac in menu example (#19071) * docs: fix undefined isMac in menu example * docs: remove ; in example --- docs/api/menu.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/api/menu.md b/docs/api/menu.md index e067caafffc6c..cd9e177ae08da 100644 --- a/docs/api/menu.md +++ b/docs/api/menu.md @@ -152,9 +152,11 @@ simple template API: ```javascript const { app, Menu } = require('electron') +const isMac = process.platform === 'darwin' + const template = [ // { role: 'appMenu' } - ...(process.platform === 'darwin' ? [{ + ...(isMac ? [{ label: app.name, submenu: [ { role: 'about' }, From 39c4a5411d58439ef10cd0769f0936f8a9191f5a Mon Sep 17 00:00:00 2001 From: Electron Bot Date: Tue, 2 Jul 2019 08:32:51 -0700 Subject: [PATCH 28/46] Bump v7.0.0-nightly.20190702 --- ELECTRON_VERSION | 2 +- package.json | 2 +- shell/browser/resources/win/atom.rc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ELECTRON_VERSION b/ELECTRON_VERSION index 4d08344113d3e..8f80a896d468f 100644 --- a/ELECTRON_VERSION +++ b/ELECTRON_VERSION @@ -1 +1 @@ -7.0.0-nightly.20190701 \ No newline at end of file +7.0.0-nightly.20190702 \ No newline at end of file diff --git a/package.json b/package.json index c2bd5da80fb66..0269e2587822b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron", - "version": "7.0.0-nightly.20190701", + "version": "7.0.0-nightly.20190702", "repository": "https://github.com/electron/electron", "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS", "devDependencies": { diff --git a/shell/browser/resources/win/atom.rc b/shell/browser/resources/win/atom.rc index 0085bd81d5de4..ccc88b118ff3b 100644 --- a/shell/browser/resources/win/atom.rc +++ b/shell/browser/resources/win/atom.rc @@ -50,8 +50,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,0,0,20190701 - PRODUCTVERSION 7,0,0,20190701 + FILEVERSION 7,0,0,20190702 + PRODUCTVERSION 7,0,0,20190702 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L From c2d78deeca3a9ea2034e97b688c51cdabfd86cb2 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Tue, 2 Jul 2019 13:48:26 -0700 Subject: [PATCH 29/46] test: attempt to fix flaky webview.clearHistory test (#19083) --- spec/webview-spec.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/webview-spec.js b/spec/webview-spec.js index 703bb26d05519..c3acbb61295d8 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -917,11 +917,12 @@ describe(' tag', function () { describe('.clearHistory()', () => { it('should clear the navigation history', async () => { - loadWebView(webview, { + const message = waitForEvent(webview, 'ipc-message') + await loadWebView(webview, { nodeintegration: 'on', src: `file://${fixtures}/pages/history.html` }) - const event = await waitForEvent(webview, 'ipc-message') + const event = await message expect(event.channel).to.equal('history') expect(event.args[0]).to.equal(2) From 616856552f1a2098d010419f9391ce923460ffc1 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Tue, 2 Jul 2019 13:48:58 -0700 Subject: [PATCH 30/46] test: fix flaky onbeforeunload tests (#19085) --- spec/fixtures/api/close-beforeunload-empty-string.html | 2 +- spec/fixtures/api/close-beforeunload-false.html | 3 ++- spec/fixtures/api/close-beforeunload-undefined.html | 2 +- spec/fixtures/api/close.html | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spec/fixtures/api/close-beforeunload-empty-string.html b/spec/fixtures/api/close-beforeunload-empty-string.html index 13564fba349ab..644f4f4530bc8 100644 --- a/spec/fixtures/api/close-beforeunload-empty-string.html +++ b/spec/fixtures/api/close-beforeunload-empty-string.html @@ -13,7 +13,7 @@ return ''; } } - window.close(); + window.onload = () => window.close(); diff --git a/spec/fixtures/api/close-beforeunload-false.html b/spec/fixtures/api/close-beforeunload-false.html index 482b8757e4356..5f519ab5598b2 100644 --- a/spec/fixtures/api/close-beforeunload-false.html +++ b/spec/fixtures/api/close-beforeunload-false.html @@ -12,7 +12,8 @@ return false; } } - window.close(); + // unload events don't get run unless load events have run. + window.onload = () => window.close() diff --git a/spec/fixtures/api/close-beforeunload-undefined.html b/spec/fixtures/api/close-beforeunload-undefined.html index b4e4178f6a1d3..910dbc5090fc8 100644 --- a/spec/fixtures/api/close-beforeunload-undefined.html +++ b/spec/fixtures/api/close-beforeunload-undefined.html @@ -6,7 +6,7 @@ require('electron').remote.getCurrentWindow().emit('onbeforeunload'); }, 0); } - window.close(); + window.onload = () => window.close(); diff --git a/spec/fixtures/api/close.html b/spec/fixtures/api/close.html index 24846f7228363..0388b82a73224 100644 --- a/spec/fixtures/api/close.html +++ b/spec/fixtures/api/close.html @@ -4,7 +4,7 @@ window.addEventListener('unload', function (e) { require('fs').writeFileSync(__dirname + '/close', 'close'); }, false); - window.close(); + window.onload = () => window.close(); From 9bef48216f438b318ccc75853f73bd473ae8046b Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 2 Jul 2019 13:54:22 -0700 Subject: [PATCH 31/46] build: update our nan reference to point at the upstream (#19084) The required fix has landed, let's target upstream --- DEPS | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/DEPS b/DEPS index 53368c551830e..00111885ff687 100644 --- a/DEPS +++ b/DEPS @@ -14,7 +14,7 @@ vars = { 'node_version': '0a300f60bce0c8f0cb3d846fcb0e1f55f26013ee', 'nan_version': - '960dd6c70fc9eb136efdf37b4bef18fadbc3436f', + '2ee313aaca52e2b478965ac50eb5082520380d1b', 'boto_version': 'f7574aa6cc2c819430c1f05e9a1a1a666ef8169b', 'pyyaml_version': '3.12', @@ -23,8 +23,7 @@ vars = { 'boto_git': 'https://github.com/boto', 'chromium_git': 'https://chromium.googlesource.com', 'electron_git': 'https://github.com/electron', - # FIXME: Once https://github.com/nodejs/nan/pull/857 lands this should point at nodejs/nan - 'nodejs_git': 'https://github.com/marshallofsound', + 'nodejs_git': 'https://github.com/nodejs', 'requests_git': 'https://github.com/kennethreitz', 'yaml_git': 'https://github.com/yaml', From 50b9c7051ef482bb53ff5227d4e1a94d62442363 Mon Sep 17 00:00:00 2001 From: Electron Bot Date: Tue, 2 Jul 2019 18:22:09 -0700 Subject: [PATCH 32/46] chore: bump chromium to f1d9522c04ca8fa0a906f88ababe9 (master) (#18648) * chore: bump chromium in DEPS to 675d7dc9f3334b15c3ec28c27db3dc19b26bd12e * chore: update patches * chore: bump chromium in DEPS to dce3562696f165a324273fcb6893f0e1fef42ab1 * chore: const interfaces are being removed from //content Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1631749 Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=908139 * chore: update patches * chore: blink::MediaStreamType is now consistent and deduplicated * chore: update patches and printing code for ref -> uniq * chore: bridge_impl() --> GetInProcessNSWindowBridge Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1642988 * fixme: TotalMarkedObjectSize has been removed * chore: fix linting * chore: bump chromium in DEPS to 9503e1a2fcbf17db08094d8caae3e1407e918af3 * chore: fix slightly broken printing patch * chore: update patches for SiteInstanceImpl changes Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1612025 * chore: update patches for SiteInstanceImpl changes * chore: bump chromium in DEPS to 6801e6c1ddd1b7b73e594e97157ddd539ca335d7 * chore: update patches * chore: bump chromium in DEPS to 27e198912d7c1767052ec785c22e2e88b2cb4d8b * chore: remove system_request_context Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1647172 * chore: creation of FtpProtocolHandler needs an auth cache Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1639683 * fixme: disable marked spec * chore: bump chromium in DEPS to 3dcd7fe453ad13a22b114b95f05590eba74c5471 * chore: bump chromium in DEPS to bdc24128b75008743d819e298557a53205706e7c * chore: bump chromium in DEPS to 7da330b58fbe0ba94b9b94abbb8085bead220228 * update patches * remove TotalMarkedObjectSize https://chromium-review.googlesource.com/c/chromium/src/+/1631708 * add libvulkan.so to dist zip manifest on linux * chore: bump chromium in DEPS to 1e85d0f45b52649efd0010cc9dab6d2804f24443 * update patches * add angle features to gpuinfo https://chromium-review.googlesource.com/c/chromium/src/+/1638658 * mark 'marked' property as deprecated * disable webview resize test * FIXME: disable vulkan on 32-bit arm * chore: bump chromium in DEPS to cd0297c6a83fdd2b1f6bc312e7d5acca736a3c56 * Revert "FIXME: disable vulkan on 32-bit arm" This reverts commit 5c1e0ef302a6db1e72231d4e823f91bb08e281af. * backport from upstream: fix swiftshader build on arm https://swiftshader-review.googlesource.com/c/SwiftShader/+/32768/ * update patches * viz: update OutputDeviceWin to new shared memory api https://chromium-review.googlesource.com/c/chromium/src/+/1649574 * base::Contains{Key,Value} => base::Contains https://chromium-review.googlesource.com/c/chromium/src/+/1649478 * fixup! viz: update OutputDeviceWin to new shared memory api * stub out StatusIconLinuxDbus-related delegate methods https://chromium-review.googlesource.com/c/chromium/src/+/1638180 * chore: bump chromium in DEPS to 964ea3fd4bdc006d62533f5755043076220181f1 * Remove the BrowserContext methods to create URLRequestContexts for main/media partitions when a partition_domain is specified https://chromium-review.googlesource.com/c/chromium/src/+/1655087 * fixup! stub out StatusIconLinuxDbus-related delegate methods * add remote_cocoa to chromium_src deps https://chromium-review.googlesource.com/c/chromium/src/+/1657068 * fixup! stub out StatusIconLinuxDbus-related delegate methods * attempt at fix linux-debug build * add swiftshader/libvulkan.so to arm manifest * chore: bump chromium in DEPS to 28688f76afef27c36631aa274691e333ddecdc22 * update patches * chore: bump chromium in DEPS to fe7450e1578a9584189f87d59d0d1a8548bf6b90 * chore: bump chromium in DEPS to f304dfd682dc86a755a6c49a16ee6876e0db45fb * chore: bump chromium in DEPS to f0fd4d6c365aad9edd83bdfff9954c47d271b75c * Update patches * Remove no longer needed WOA patch * Put back IOThread in BrowserProcess We need this until we enable the network service. * move atom.ico to inputs * Update to latest LKGR to fix no template named 'bitset' in namespace 'std' * fixup! Put back IOThread in BrowserProcess * chore: bump chromium in DEPS to dcf9662dc9a896a175d791001350324167b1cad3 * Update patches content_allow_embedder_to_prevent_locking_scheme_registry.patch is no longer necessary as it was upstreamed via https://chromium-review.googlesource.com/c/chromium/src/+/1637040 * Fix renamed enum * Use newer docker container Contains updated dependencies * Try to track down arm test failures * Fix arm tests * chore: bump chromium in DEPS to 8cbceef57b37ee14b9c4c3405a3f7663922c5b5d * Update patches * Add needed dependencies for testing 32-bit linux * Remove arm debugging. * Remove additional debugging * Fix compiler errors * Handle new macOS helper * Fix compile error on Linux * chore: bump chromium in DEPS to 66a93991ddaff6a9f1b13d110959947cb03a1860 * Add new helper files to manifests * fix BUILD.gn for macOS * Fix compile errors * Add patch to put back colors needed for autofill/datalist * chore: bump chromium in DEPS to e89617079f11e33f33cdb3924f719a579c73704b * Updated patches * Remove no longer needed patch * Remove no longer needed patch * Fix compile error with patch * Really fix the patch * chore: bump chromium in DEPS to c70f12476a45840408f1d5ff5968e7f7ceaad9d4 * chore: bump chromium in DEPS to 06d2dd7a8933b41545a7c26349c802f570563fd5 * chore: bump chromium in DEPS to b0b9ff8f727deb519ccbec7cf1c8d9ed543d88ab * Update patches * Fix compiler errors * Fix removed ChromeNetLog * Revert "Fix removed ChromeNetLog" This reverts commit 426dfd90b5ab0a9c1df415d71c88e8aed2bd5bbe. * Remove ChromeNetLog. https://chromium-review.googlesource.com/c/chromium/src/+/1663846 * chore: bump chromium in DEPS to fefcc4926d58dccd59ac95be65eab3a4ebfe2f29 * Update patches * Update v8 patches * Fix lint error * Fix compile errors * chore: bump chromium in DEPS to 4de815ef92ef2eef515506fe09bdc466526a8fd9 * Use custom protocol to test baseURLForDataURL * Use newer SDK (10.0.18362) for Windows * Update patches * Update arm manifest since swiftshader reenabled. * Don't delete dir that isn't ever there. * Fix compile errors. * Need src dir created * Update for removed InspectorFrontendAPI.addExtensions * Revert "Use newer SDK (10.0.18362) for Windows" This reverts commit 68763a0c88cdc44b971462e49662aecc167d3d99. * Revert "Need src dir created" This reverts commit 7daedc29d0844316d4097648dde7f40f1a3848fb. * Revert "Don't delete dir that isn't ever there." This reverts commit bf424bc30ffcb23b1d9a634d4df410342536640e. * chore: bump chromium in DEPS to 97dab6b0124ea53244caf123921b5d14893bcca7 * chore: bump chromium in DEPS to c87d16d49a85dc7122781f6c979d354c20f7f78b * chore: bump chromium in DEPS to 004bcee2ea336687cedfda8f8a151806ac757d15 * chore: bump chromium in DEPS to 24428b26a9d15a013b2a253e1084ec3cb54b660b * chore: bump chromium in DEPS to fd25914e875237df88035a6abf89a70bf1360b57 * Update patches * Update node to fix build error * Fix compile errors * chore: bump chromium in DEPS to 3062b7cf090f1d9522c04ca8fa0a906f88ababe9 * chore: update node ref for pushed tags * chore: update patches for new chromium * chore: fix printing patches * Use new (10.0.18362) Windows SDK * roll node to fix v8 build issues in debug build * Add support for plugin helper * fix: add patch to fix gpu info enumeration Can be removed once CL lands upstream. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1685993 * spec: navigator.requestMIDIAccess now requires a secure origin This test requires a secure origin so we fake one. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1657952 * FIXME: temporarily disable SharedWorker tests * use released version of node-abstractsocket * fix abstract-socket --- .circleci/config.yml | 2 +- BUILD.gn | 70 +++++++---- DEPS | 4 +- Dockerfile | 3 + appveyor.yml | 4 +- chromium_src/BUILD.gn | 4 + docs/api/breaking-changes.md | 4 + lib/browser/chrome-extension.js | 5 +- patches/chromium/.patches | 5 +- patches/chromium/accelerator.patch | 6 +- ...client_precreatemessageloop_callback.patch | 12 +- patches/chromium/add_realloc.patch | 6 +- patches/chromium/allow_webview_file_url.patch | 2 +- ...ink-worker-enable-csp-in-file-scheme.patch | 2 +- patches/chromium/blink_local_frame.patch | 6 +- patches/chromium/blink_world_context.patch | 12 +- patches/chromium/can_create_window.patch | 24 ++-- patches/chromium/chrome_key_systems.patch | 2 +- patches/chromium/command-ismediakey.patch | 4 +- ...r_to_prevent_locking_scheme_registry.patch | 55 -------- .../chromium/content_browser_main_loop.patch | 8 +- ...cross_site_document_resource_handler.patch | 8 +- patches/chromium/dcheck.patch | 8 +- patches/chromium/disable-redraw-lock.patch | 8 +- .../disable_color_correct_rendering.patch | 62 +++++----- .../disable_detach_webview_frame.patch | 2 +- patches/chromium/disable_hidden.patch | 6 +- .../disable_network_services_by_default.patch | 16 +-- ...requirement_for_beforeunload_dialogs.patch | 4 +- patches/chromium/dom_storage_limits.patch | 4 +- .../exclude-a-few-test-files-from-build.patch | 4 +- ...screen_rendering_with_viz_compositor.patch | 100 +++++++-------- ..._usage_of_setapplicationisdaemon_and.patch | 2 +- ...tributes_to_fix_gpu_info_enumeration.patch | 18 +++ patches/chromium/frame_host_manager.patch | 33 ++--- .../gin_enable_disable_v8_platform.patch | 2 +- .../chromium/gritsettings_resource_ids.patch | 4 +- patches/chromium/mas-audiodeviceduck.patch | 2 +- .../mas-cgdisplayusesforcetogray.patch | 8 +- ...launchservicesserverconnectionstatus.patch | 4 +- patches/chromium/mas_no_private_api.patch | 57 ++++----- ...emote_certificate_verification_logic.patch | 20 +-- patches/chromium/no_cache_storage_check.patch | 4 +- .../chromium/notification_provenance.patch | 4 +- .../chromium/out_of_process_instance.patch | 4 +- patches/chromium/pepper_flash.patch | 14 +-- patches/chromium/printing.patch | 115 +++++++++-------- ...put_back_deleted_colors_for_autofill.patch | 117 ++++++++++++++++++ .../render_widget_host_view_base.patch | 9 +- .../render_widget_host_view_mac.patch | 16 +-- patches/chromium/resource_file_conflict.patch | 6 +- .../revert_build_swiftshader_for_arm32.patch | 22 ---- patches/chromium/scroll_bounce_flag.patch | 4 +- .../ssl_security_state_tab_helper.patch | 32 ++--- .../support_mixed_sandbox_with_zygote.patch | 10 +- ...andboxed_ppapi_processes_skip_zygote.patch | 2 +- patches/chromium/web_contents.patch | 8 +- .../chromium/woa_compiler_workaround.patch | 30 ----- .../worker_context_will_destroy.patch | 18 +-- patches/config.json | 2 + patches/swiftshader/.patches | 0 patches/v8/add_realloc.patch | 8 +- patches/v8/build_gn.patch | 6 +- patches/v8/dcheck.patch | 8 +- ...vide_more_v8_backwards_compatibility.patch | 34 ++--- ...export_private_v8_symbols_on_windows.patch | 12 +- ...ort_symbols_needed_for_windows_build.patch | 4 +- patches/v8/expose_mksnapshot.patch | 9 +- ...workaround_an_undefined_symbol_error.patch | 10 +- .../zip_manifests/dist_zip.linux.arm.manifest | 3 + .../dist_zip.linux.arm64.manifest | 1 + .../zip_manifests/dist_zip.linux.x64.manifest | 1 + .../zip_manifests/dist_zip.linux.x86.manifest | 1 + .../zip_manifests/dist_zip.mac.x64.manifest | 12 ++ .../dist_zip.mac_mas.x64.manifest | 12 ++ shell/app/atom_content_client.cc | 10 +- shell/app/atom_content_client.h | 11 +- shell/app/atom_main_delegate_mac.mm | 18 ++- shell/app/uv_task_runner.cc | 2 +- shell/browser/api/atom_api_app.cc | 3 +- shell/browser/api/atom_api_app.h | 2 +- shell/browser/api/atom_api_global_shortcut.cc | 4 +- shell/browser/api/atom_api_net_log.cc | 6 +- shell/browser/api/atom_api_power_monitor.cc | 4 +- shell/browser/api/atom_api_protocol_ns.cc | 14 +-- .../browser/api/atom_api_top_level_window.cc | 4 +- shell/browser/api/atom_api_web_contents.cc | 6 +- shell/browser/api/atom_api_web_contents.h | 4 +- .../browser/api/views/atom_api_box_layout.cc | 4 +- shell/browser/atom_browser_client.cc | 30 +++-- shell/browser/atom_browser_client.h | 7 +- shell/browser/atom_browser_context.cc | 22 +--- shell/browser/atom_browser_context.h | 12 +- shell/browser/atom_browser_main_parts.cc | 5 +- shell/browser/atom_browser_main_parts.h | 3 +- .../browser/atom_web_ui_controller_factory.cc | 8 +- .../browser/atom_web_ui_controller_factory.h | 8 +- shell/browser/browser_process_impl.cc | 40 +----- shell/browser/browser_process_impl.h | 12 +- shell/browser/common_web_contents_delegate.cc | 4 +- shell/browser/common_web_contents_delegate.h | 5 +- shell/browser/io_thread.cc | 59 ++++++++- shell/browser/io_thread.h | 9 -- .../media/media_capture_devices_dispatcher.cc | 4 +- .../media/media_capture_devices_dispatcher.h | 4 +- .../media/media_stream_devices_controller.cc | 53 +++++--- shell/browser/net/atom_network_delegate.cc | 18 +-- .../net/atom_url_request_job_factory.cc | 8 +- .../net/system_network_context_manager.cc | 17 +-- .../net/system_network_context_manager.h | 6 - .../browser/net/url_request_context_getter.cc | 25 +++- shell/browser/osr/osr_host_display_client.cc | 31 ++--- shell/browser/osr/osr_host_display_client.h | 5 +- .../printing/print_preview_message_handler.cc | 10 +- shell/browser/ui/accelerator_util.cc | 2 +- shell/browser/ui/atom_menu_model.cc | 2 +- .../ui/cocoa/atom_ns_window_delegate.mm | 4 +- shell/browser/ui/devtools_ui.cc | 10 +- shell/browser/ui/tray_icon_gtk.cc | 21 +++- shell/browser/ui/tray_icon_gtk.h | 13 +- shell/browser/ui/views/menu_bar.cc | 4 +- shell/browser/ui/win/taskbar_host.cc | 2 +- .../browser/web_contents_permission_helper.cc | 12 +- .../browser/web_contents_permission_helper.h | 2 +- shell/browser/web_view_guest_delegate.cc | 2 +- shell/browser/web_view_guest_delegate.h | 2 +- shell/browser/web_view_manager.cc | 8 +- shell/common/api/atom_api_clipboard.cc | 4 +- shell/common/api/electron_bindings.cc | 2 - shell/common/asar/asar_util.cc | 2 +- shell/common/mac/main_application_bundle.mm | 7 +- shell/common/mouse_util.cc | 90 +++++++------- .../native_mate_converters/blink_converter.cc | 2 +- spec-main/api-browser-window-spec.ts | 16 ++- spec-main/api-session-spec.js | 15 ++- spec/api-process-spec.js | 1 - spec/chromium-spec.js | 59 ++++----- spec/node-spec.js | 2 +- spec/webview-spec.js | 4 +- spec/yarn.lock | 22 ++-- vsts-arm-test-steps.yml | 1 + vsts-arm32v7.yml | 1 + vsts-arm64v8.yml | 1 + 143 files changed, 1037 insertions(+), 923 deletions(-) delete mode 100644 patches/chromium/content_allow_embedder_to_prevent_locking_scheme_registry.patch create mode 100644 patches/chromium/fix_re-add_endauxattributes_to_fix_gpu_info_enumeration.patch create mode 100644 patches/chromium/put_back_deleted_colors_for_autofill.patch delete mode 100644 patches/chromium/revert_build_swiftshader_for_arm32.patch delete mode 100644 patches/chromium/woa_compiler_workaround.patch create mode 100644 patches/swiftshader/.patches diff --git a/.circleci/config.yml b/.circleci/config.yml index a4650e447c414..f4417d9597520 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ # Build machines configs. docker-image: &docker-image docker: - - image: electronbuilds/electron:0.0.9 + - image: electronbuilds/electron:0.0.10 machine-linux-medium: &machine-linux-medium <<: *docker-image diff --git a/BUILD.gn b/BUILD.gn index c2d3ec752b6a0..f67eb9fc52ed3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,6 +1,7 @@ import("//build/config/locales.gni") import("//build/config/ui.gni") import("//build/config/win/manifest.gni") +import("//content/public/app/mac_helpers.gni") import("//pdf/features.gni") import("//printing/buildflags/buildflags.gni") import("//third_party/ffmpeg/ffmpeg_options.gni") @@ -474,6 +475,7 @@ static_library("electron_lib") { if (is_mac) { deps += [ "//components/remote_cocoa/app_shim", + "//content/common:mac_helpers", "//ui/accelerated_widget_mac", ] sources += [ @@ -518,6 +520,7 @@ static_library("electron_lib") { ] configs += [ ":gio_unix" ] include_dirs += [ "//third_party/breakpad" ] + configs += [ "//build/config/linux:x11" ] defines += [ # Disable warnings for g_settings_list_schemas. "GLIB_DISABLE_DEPRECATION_WARNINGS", @@ -800,37 +803,49 @@ if (is_mac) { } } - mac_app_bundle("electron_helper_app") { - output_name = electron_helper_name - deps = [ - ":electron_framework+link", - ] - if (!is_mas_build) { - deps += [ "//sandbox/mac:seatbelt" ] - } - defines = [ "HELPER_EXECUTABLE" ] - sources = filenames.app_sources - sources += [ "shell/common/atom_constants.cc" ] - include_dirs = [ "." ] - info_plist = "shell/renderer/resources/mac/Info.plist" - extra_substitutions = - [ "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.helper" ] - ldflags = [ - "-rpath", - "@executable_path/../../..", - ] - if (is_component_build) { - ldflags += [ + template("electron_helper_app") { + mac_app_bundle(target_name) { + assert(defined(invoker.helper_name_suffix)) + + output_name = electron_helper_name + invoker.helper_name_suffix + deps = [ + ":electron_framework+link", + ] + if (!is_mas_build) { + deps += [ "//sandbox/mac:seatbelt" ] + } + defines = [ "HELPER_EXECUTABLE" ] + sources = filenames.app_sources + sources += [ "shell/common/atom_constants.cc" ] + include_dirs = [ "." ] + info_plist = "shell/renderer/resources/mac/Info.plist" + extra_substitutions = + [ "ELECTRON_BUNDLE_ID=$electron_mac_bundle_id.helper" ] + ldflags = [ "-rpath", - "@executable_path/../../../../../..", + "@executable_path/../../..", ] + if (is_component_build) { + ldflags += [ + "-rpath", + "@executable_path/../../../../../..", + ] + } + } + } + + foreach(helper_params, content_mac_helpers) { + _helper_target = helper_params[0] + _helper_bundle_id = helper_params[1] + _helper_suffix = helper_params[2] + electron_helper_app("electron_helper_app_${_helper_target}") { + helper_name_suffix = _helper_suffix } } bundle_data("electron_app_framework_bundle_data") { sources = [ "$root_out_dir/$electron_framework_name.framework", - "$root_out_dir/$electron_helper_name.app", ] if (!is_mas_build) { sources += [ @@ -844,8 +859,13 @@ if (is_mac) { ] public_deps = [ ":electron_framework+link", - ":electron_helper_app", ] + + foreach(helper_params, content_mac_helpers) { + sources += + [ "$root_out_dir/${electron_helper_name}${helper_params[2]}.app" ] + public_deps += [ ":electron_helper_app_${helper_params[0]}" ] + } } mac_app_bundle("electron_login_helper") { @@ -984,7 +1004,6 @@ if (is_mac) { if (is_win) { sources += [ # TODO: we should be generating our .rc files more like how chrome does - "shell/browser/resources/win/atom.ico", "shell/browser/resources/win/atom.rc", "shell/browser/resources/win/resource.h", ] @@ -1012,6 +1031,7 @@ if (is_mac) { # See https://github.com/nodejs/node-gyp/commit/52ceec3a6d15de3a8f385f43dbe5ecf5456ad07a ldflags += [ "/DEF:" + rebase_path("build/electron.def", root_build_dir) ] inputs = [ + "shell/browser/resources/win/atom.ico", "build/electron.def", ] } diff --git a/DEPS b/DEPS index 00111885ff687..cc330bf0c9642 100644 --- a/DEPS +++ b/DEPS @@ -10,9 +10,9 @@ gclient_gn_args = [ vars = { 'chromium_version': - 'f200986dfaabd6aad6a4b37dad7aae42fec349e9', + '3062b7cf090f1d9522c04ca8fa0a906f88ababe9', 'node_version': - '0a300f60bce0c8f0cb3d846fcb0e1f55f26013ee', + 'f4a3ef181f7e52663034aff129d6b91230a318bd', 'nan_version': '2ee313aaca52e2b478965ac50eb5082520380d1b', diff --git a/Dockerfile b/Dockerfile index bae76aaf3cb7e..31b0633e0c4af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,6 +10,7 @@ RUN chmod a+rwx /tmp # Install Linux packages ADD build/install-build-deps.sh /setup/install-build-deps.sh RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections +RUN dpkg --add-architecture i386 RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ curl \ libnotify-bin \ @@ -22,6 +23,8 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ sudo \ vim-nox \ wget \ + g++-multilib \ + libgl1:i386 \ && /setup/install-build-deps.sh --syms --no-prompt --no-chromeos-fonts --lib32 --arm \ && rm -rf /var/lib/apt/lists/* diff --git a/appveyor.yml b/appveyor.yml index 40cdd5f77f9e4..b2003f4c6825c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: libcc-20 -image: libcc-20-vs2017-15.9 +image: vs2017-15.9-10.0.18362 environment: GIT_CACHE_PATH: C:\Users\electron\libcc_cache ELECTRON_OUT_DIR: Default @@ -52,7 +52,7 @@ build_script: - echo "Building $env:GN_CONFIG build" - git config --global core.longpaths true - cd .. - - ps: if (Test-Path src\electron) { Remove-Item src\electron -Recurse } + - mkdir src - ps: Move-Item $env:APPVEYOR_BUILD_FOLDER -Destination src\electron - ps: $env:CHROMIUM_BUILDTOOLS_PATH="$pwd\src\buildtools" - ps: $env:SCCACHE_PATH="$pwd\src\electron\external_binaries\sccache.exe" diff --git a/chromium_src/BUILD.gn b/chromium_src/BUILD.gn index d6942f80c78e1..ea1114e446964 100644 --- a/chromium_src/BUILD.gn +++ b/chromium_src/BUILD.gn @@ -102,6 +102,10 @@ static_library("chrome") { "//chrome/browser/ui/cocoa/color_chooser_mac.h", "//chrome/browser/ui/cocoa/color_chooser_mac.mm", ] + deps += [ + "//components/remote_cocoa/app_shim", + "//components/remote_cocoa/browser", + ] } if (is_win) { diff --git a/docs/api/breaking-changes.md b/docs/api/breaking-changes.md index e9d2cd1def5c6..cb9c220a3a238 100644 --- a/docs/api/breaking-changes.md +++ b/docs/api/breaking-changes.md @@ -64,6 +64,10 @@ webFrame.setIsolatedWorldInfo( }) ``` +### Removal of deprecated `marked` property on getBlinkMemoryInfo + +This property was removed in Chromium 77, and as such is no longer available. + ## Planned Breaking API Changes (6.0) ### `win.setMenu(null)` diff --git a/lib/browser/chrome-extension.js b/lib/browser/chrome-extension.js index 094ca948fb2d9..797c2df6105ea 100644 --- a/lib/browser/chrome-extension.js +++ b/lib/browser/chrome-extension.js @@ -382,7 +382,10 @@ const loadDevToolsExtensions = function (win, manifests) { extensionInfoArray.forEach((extension) => { win.devToolsWebContents._grantOriginAccess(extension.startPage) }) - win.devToolsWebContents.executeJavaScript(`InspectorFrontendAPI.addExtensions(${JSON.stringify(extensionInfoArray)})`) + + extensionInfoArray.forEach((extensionInfo) => { + win.devToolsWebContents.executeJavaScript(`Extensions.extensionServer._addExtension(${JSON.stringify(extensionInfo)})`) + }) } app.on('web-contents-created', function (event, webContents) { diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 6d7710231a3bc..0c59559b13bc5 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -56,11 +56,9 @@ command-ismediakey.patch tts.patch printing.patch verbose_generate_breakpad_symbols.patch -content_allow_embedder_to_prevent_locking_scheme_registry.patch support_mixed_sandbox_with_zygote.patch disable_color_correct_rendering.patch autofill_size_calculation.patch -revert_build_swiftshader_for_arm32.patch fix_disable_usage_of_abort_report_np_in_mas_builds.patch fix_disable_usage_of_pthread_fchdir_np_and_pthread_chdir_np_in_mas.patch fix_disable_usage_of_setapplicationisdaemon_and.patch @@ -75,7 +73,8 @@ worker_context_will_destroy.patch fix_breakpad_symbol_generation_on_linux_arm.patch frame_host_manager.patch cross_site_document_resource_handler.patch -woa_compiler_workaround.patch crashpad_pid_check.patch chore_add_debounce_on_the_updatewebcontentsvisibility_method_to.patch network_service_allow_remote_certificate_verification_logic.patch +put_back_deleted_colors_for_autofill.patch +fix_re-add_endauxattributes_to_fix_gpu_info_enumeration.patch diff --git a/patches/chromium/accelerator.patch b/patches/chromium/accelerator.patch index 8a2e516312337..6d13b2725c485 100644 --- a/patches/chromium/accelerator.patch +++ b/patches/chromium/accelerator.patch @@ -10,7 +10,7 @@ This patch makes three changes to Accelerator::GetShortcutText to improve shortc 3. Ctrl-Shift-= should show as Ctrl-+ diff --git a/ui/base/accelerators/accelerator.cc b/ui/base/accelerators/accelerator.cc -index dadc140e9429c166ecd4c653c9ef5d0d4c4db2a4..bc93a9ecb28ff6973fc4d15f67a17d545c169a89 100644 +index 841a8ccd1f0ca5073cf0f0621f81561ed6425e0d..ac4c04b74b0a3b8e6d6c375fef021abbd8789a14 100644 --- a/ui/base/accelerators/accelerator.cc +++ b/ui/base/accelerators/accelerator.cc @@ -11,6 +11,7 @@ @@ -32,7 +32,7 @@ index dadc140e9429c166ecd4c653c9ef5d0d4c4db2a4..bc93a9ecb28ff6973fc4d15f67a17d54 namespace ui { @@ -150,7 +149,15 @@ base::string16 Accelerator::GetShortcutText() const { - shortcut = KeyCodeToName(key_code_); + shortcut = KeyCodeToName(); #endif + unsigned int flags = 0; @@ -75,7 +75,7 @@ index dadc140e9429c166ecd4c653c9ef5d0d4c4db2a4..bc93a9ecb28ff6973fc4d15f67a17d54 } // Checking whether the character used for the accelerator is alphanumeric. -@@ -237,7 +237,7 @@ base::string16 Accelerator::ApplyLongFormModifiers( +@@ -356,7 +356,7 @@ base::string16 Accelerator::ApplyLongFormModifiers( // more information. if (IsCtrlDown()) shortcut = ApplyModifierToAcceleratorString(shortcut, IDS_APP_CTRL_KEY); diff --git a/patches/chromium/add_contentgpuclient_precreatemessageloop_callback.patch b/patches/chromium/add_contentgpuclient_precreatemessageloop_callback.patch index c0af335c454b7..6e21418300832 100644 --- a/patches/chromium/add_contentgpuclient_precreatemessageloop_callback.patch +++ b/patches/chromium/add_contentgpuclient_precreatemessageloop_callback.patch @@ -9,10 +9,10 @@ Allows Electron to restore WER when ELECTRON_DEFAULT_ERROR_MODE is set. This should be upstreamed diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc -index 82f0c4f62be2f210db2c3ed1169c2a816c59cf1f..20dcb7dd1ee1172cfbf263f14724dd4701fa6eae 100644 +index ad0d612eb6b87cb320047ebaaff5220f46d8fb8c..9f1fc3a3f1b98d90c5aea07d30616e5180cfa8d5 100644 --- a/content/gpu/gpu_main.cc +++ b/content/gpu/gpu_main.cc -@@ -234,6 +234,10 @@ int GpuMain(const MainFunctionParams& parameters) { +@@ -236,6 +236,10 @@ int GpuMain(const MainFunctionParams& parameters) { logging::SetLogMessageHandler(GpuProcessLogMessageHandler); @@ -21,10 +21,10 @@ index 82f0c4f62be2f210db2c3ed1169c2a816c59cf1f..20dcb7dd1ee1172cfbf263f14724dd47 + client->PreCreateMessageLoop(); + // We are experiencing what appear to be memory-stomp issues in the GPU - // process. These issues seem to be impacting the message loop and listeners - // registered to it. Create the message loop on the heap to guard against -@@ -335,7 +339,6 @@ int GpuMain(const MainFunctionParams& parameters) { - + // process. These issues seem to be impacting the task executor and listeners + // registered to it. Create the task executor on the heap to guard against +@@ -337,7 +341,6 @@ int GpuMain(const MainFunctionParams& parameters) { + : base::ThreadPriority::NORMAL; GpuProcess gpu_process(io_thread_priority); - auto* client = GetContentClient()->gpu(); diff --git a/patches/chromium/add_realloc.patch b/patches/chromium/add_realloc.patch index 78760e4fa16eb..437ec3bd14661 100644 --- a/patches/chromium/add_realloc.patch +++ b/patches/chromium/add_realloc.patch @@ -39,10 +39,10 @@ index 2aef366ac8194aa261cbca6abc051f7da8a988d3..3c7d66c81032636abcca4f1538ce9b7f GIN_EXPORT static ArrayBufferAllocator* SharedInstance(); diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc -index 1f3f5e263585fbec3844b45116797084483006cb..8e13c4edbf98f380ddacad6447c4e0656fcb0bb2 100644 +index 82bfcb5d1d98772fda0e8c5692e8fdc2626fd1c9..ea29d4e0404344be09e9098920d175e7bb80d000 100644 --- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc +++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc -@@ -553,6 +553,10 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { +@@ -582,6 +582,10 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { size, WTF::ArrayBufferContents::kDontInitialize); } @@ -70,7 +70,7 @@ index 0031242152ce5190b0dfc77b53af2d984e5fad82..a6370ec793ce6c38eb7dab189583ea11 Partitions::ArrayBufferPartition()->Free(data); } diff --git a/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_contents.h b/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_contents.h -index 98bda6647e7b1516ab6114ebc63f5c60da3ebbb7..37dacadc262e15714f8e3e090b780c8abf22283e 100644 +index 601046eca671613693d3fc083cf48a0d530c8fd3..a94b7ea29bbd6d5e6cc6fb3a850be7e1ef00c5ad 100644 --- a/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_contents.h +++ b/third_party/blink/renderer/platform/wtf/typed_arrays/array_buffer_contents.h @@ -135,6 +135,7 @@ class WTF_EXPORT ArrayBufferContents { diff --git a/patches/chromium/allow_webview_file_url.patch b/patches/chromium/allow_webview_file_url.patch index f05a2b0664f20..076738c7b2682 100644 --- a/patches/chromium/allow_webview_file_url.patch +++ b/patches/chromium/allow_webview_file_url.patch @@ -6,7 +6,7 @@ Subject: allow_webview_file_url.patch Allow webview to load non-web URLs. diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc -index 89e10f6eba87d08a9e2c6f921aab7d30ed6c4b2b..4cae5745aca6993c82a4a331107bf4d820a6c0a7 100644 +index c4db9c98e4e909cea8ba000402afdb32ff57cb4e..28325e6f6f64922c4ba0daf2c94dcae34d5b4855 100644 --- a/content/browser/loader/resource_dispatcher_host_impl.cc +++ b/content/browser/loader/resource_dispatcher_host_impl.cc @@ -1429,6 +1429,8 @@ void ResourceDispatcherHostImpl::BeginNavigationRequest( diff --git a/patches/chromium/blink-worker-enable-csp-in-file-scheme.patch b/patches/chromium/blink-worker-enable-csp-in-file-scheme.patch index eaeec5d3dc509..50ae58db7fc97 100644 --- a/patches/chromium/blink-worker-enable-csp-in-file-scheme.patch +++ b/patches/chromium/blink-worker-enable-csp-in-file-scheme.patch @@ -5,7 +5,7 @@ Subject: blink-worker-enable-csp-in-file-scheme.patch diff --git a/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc b/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc -index c51ae1141e62ec69a3d3da8e285d89c3b0e04722..57bfcd4c22347f0f4bb9a59598414d50410666a2 100644 +index 873bf34f0f6fff5ee955f84a5019ddf9c6aefc9c..8fca091c4a430f7109aa59400e1ffbea533938d9 100644 --- a/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc +++ b/third_party/blink/renderer/core/workers/worker_classic_script_loader.cc @@ -308,7 +308,6 @@ void WorkerClassicScriptLoader::ProcessContentSecurityPolicy( diff --git a/patches/chromium/blink_local_frame.patch b/patches/chromium/blink_local_frame.patch index 9f07dafd84f42..a9944c795e0a8 100644 --- a/patches/chromium/blink_local_frame.patch +++ b/patches/chromium/blink_local_frame.patch @@ -14,10 +14,10 @@ when there is code doing that. This patch reverts the change to fix the crash in Electron. diff --git a/third_party/blink/renderer/core/frame/local_frame.cc b/third_party/blink/renderer/core/frame/local_frame.cc -index d1922a486fb0143d688a26f954462e3a915af2b5..b1e800f51e44a7a5d3fabd66563d5bdb6a7aa280 100644 +index 2bf09644bdd6bf6f8dd49557f9e707f7bf77c2b4..bc36e8bc9fc1a973c89d52e60bd62e753ef17f15 100644 --- a/third_party/blink/renderer/core/frame/local_frame.cc +++ b/third_party/blink/renderer/core/frame/local_frame.cc -@@ -393,10 +393,6 @@ void LocalFrame::DetachImpl(FrameDetachType type) { +@@ -331,10 +331,6 @@ void LocalFrame::DetachImpl(FrameDetachType type) { } CHECK(!view_ || !view_->IsAttached()); @@ -28,7 +28,7 @@ index d1922a486fb0143d688a26f954462e3a915af2b5..b1e800f51e44a7a5d3fabd66563d5bdb if (!Client()) return; -@@ -414,6 +410,10 @@ void LocalFrame::DetachImpl(FrameDetachType type) { +@@ -352,6 +348,10 @@ void LocalFrame::DetachImpl(FrameDetachType type) { // Notify ScriptController that the frame is closing, since its cleanup ends // up calling back to LocalFrameClient via WindowProxy. GetScriptController().ClearForClose(); diff --git a/patches/chromium/blink_world_context.patch b/patches/chromium/blink_world_context.patch index c4a35160bf46c..15d0e78409586 100644 --- a/patches/chromium/blink_world_context.patch +++ b/patches/chromium/blink_world_context.patch @@ -5,10 +5,10 @@ Subject: blink_world_context.patch diff --git a/third_party/blink/public/web/web_local_frame.h b/third_party/blink/public/web/web_local_frame.h -index 82fb3fdfe6bfa8c8d885ee133270b6f2564325a8..f3bad71eab608d3b9ac0e08446c9e520f47e9b10 100644 +index c41afd046ee882cdb4c9f706c4d08cd05bd133ec..a52f1a86e6aeecb0d704b01746de550125e4358f 100644 --- a/third_party/blink/public/web/web_local_frame.h +++ b/third_party/blink/public/web/web_local_frame.h -@@ -355,6 +355,9 @@ class WebLocalFrame : public WebFrame { +@@ -357,6 +357,9 @@ class WebLocalFrame : public WebFrame { // be calling this API. virtual v8::Local MainWorldScriptContext() const = 0; @@ -19,10 +19,10 @@ index 82fb3fdfe6bfa8c8d885ee133270b6f2564325a8..f3bad71eab608d3b9ac0e08446c9e520 // that the script evaluated to with callback. Script execution can be // suspend. diff --git a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc -index e12642b4703474840a490f426b90c61141f9881e..2610245d88af53e116faa825df264fd9d9babc05 100644 +index e9fda5584f7b0ce69c8ca031f34e9b181a704868..a444ec89dbfd6395e2b182a73572555563861e1d 100644 --- a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc +++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc -@@ -873,6 +873,13 @@ v8::Local WebLocalFrameImpl::GlobalProxy() const { +@@ -867,6 +867,13 @@ v8::Local WebLocalFrameImpl::GlobalProxy() const { return MainWorldScriptContext()->Global(); } @@ -37,10 +37,10 @@ index e12642b4703474840a490f426b90c61141f9881e..2610245d88af53e116faa825df264fd9 return BindingSecurity::ShouldAllowAccessToFrame( CurrentDOMWindow(V8PerIsolateData::MainThreadIsolate()), diff --git a/third_party/blink/renderer/core/frame/web_local_frame_impl.h b/third_party/blink/renderer/core/frame/web_local_frame_impl.h -index b503bf7cef554dfb35c2123cba51c0fba7402c7e..2d38c4cebcd4040bbd417d4ae9189da954d9cfce 100644 +index 15ed90d550941c58ceb375afa9feadc57e4b46c4..8c18516e6957206a4c9ae9365fdf06870c2d3094 100644 --- a/third_party/blink/renderer/core/frame/web_local_frame_impl.h +++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.h -@@ -146,6 +146,8 @@ class CORE_EXPORT WebLocalFrameImpl final +@@ -148,6 +148,8 @@ class CORE_EXPORT WebLocalFrameImpl final int argc, v8::Local argv[]) override; v8::Local MainWorldScriptContext() const override; diff --git a/patches/chromium/can_create_window.patch b/patches/chromium/can_create_window.patch index 4cd45cdf00559..658907e15521a 100644 --- a/patches/chromium/can_create_window.patch +++ b/patches/chromium/can_create_window.patch @@ -5,10 +5,10 @@ Subject: can_create_window.patch diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc -index 0334ac0cfb75a9d99f841aea388c9a3fc960141b..c341ea17c13ec6f63936c1b4d4faba9bc40362d1 100644 +index 36e6f08c3d0ed6ef7f7d071b01c70e99c16efc05..2ada995112fec477e186a9de3e815d3be5dc1292 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc -@@ -3722,6 +3722,7 @@ void RenderFrameHostImpl::CreateNewWindow( +@@ -3807,6 +3807,7 @@ void RenderFrameHostImpl::CreateNewWindow( last_committed_origin_, params->window_container_type, params->target_url, params->referrer.To(), params->frame_name, params->disposition, *params->features, @@ -17,10 +17,10 @@ index 0334ac0cfb75a9d99f841aea388c9a3fc960141b..c341ea17c13ec6f63936c1b4d4faba9b &no_javascript_access); diff --git a/content/common/frame.mojom b/content/common/frame.mojom -index 82882159b0bac6d47d678c485de0aacc7db06c2d..dd2299094b79d82da7ec1cd8f559050b6f0e2af5 100644 +index c5078d23ace270e1e7f479a827712f24aaf729a4..4dab0367f1280b2c9374309c3803436df2929ef0 100644 --- a/content/common/frame.mojom +++ b/content/common/frame.mojom -@@ -291,6 +291,10 @@ struct CreateNewWindowParams { +@@ -303,6 +303,10 @@ struct CreateNewWindowParams { // The window features to use for the new window. blink.mojom.WindowFeatures features; @@ -32,10 +32,10 @@ index 82882159b0bac6d47d678c485de0aacc7db06c2d..dd2299094b79d82da7ec1cd8f559050b // Operation result when the renderer asks the browser to create a new window. diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc -index 53e67715469ce47147b66393ecc6a20d0d657977..2dd31166cc52ccb528b338b63fde7d2fb4bbf63d 100644 +index fae53a985a2adcf7e27ca799ff19bf2032c68529..dfd8bbaed5cfc48a116be63a067d00bb21960e85 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc -@@ -519,6 +519,8 @@ bool ContentBrowserClient::CanCreateWindow( +@@ -517,6 +517,8 @@ bool ContentBrowserClient::CanCreateWindow( const std::string& frame_name, WindowOpenDisposition disposition, const blink::mojom::WindowFeatures& features, @@ -45,7 +45,7 @@ index 53e67715469ce47147b66393ecc6a20d0d657977..2dd31166cc52ccb528b338b63fde7d2f bool opener_suppressed, bool* no_javascript_access) { diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h -index 2b4c2c1004fb98da76eb244db4c35dba84085f45..04bfc1a4a804d1f5aa28f894e2feb816bbe80ffc 100644 +index d1d54b95082f594fdf044f386ccddd7e1ececb1d..19edc738013c360d839575b62ff637e6c26c0f8a 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h @@ -177,6 +177,7 @@ class RenderFrameHost; @@ -56,7 +56,7 @@ index 2b4c2c1004fb98da76eb244db4c35dba84085f45..04bfc1a4a804d1f5aa28f894e2feb816 class SerialDelegate; class SiteInstance; class SpeechRecognitionManagerDelegate; -@@ -805,6 +806,8 @@ class CONTENT_EXPORT ContentBrowserClient { +@@ -807,6 +808,8 @@ class CONTENT_EXPORT ContentBrowserClient { const std::string& frame_name, WindowOpenDisposition disposition, const blink::mojom::WindowFeatures& features, @@ -66,7 +66,7 @@ index 2b4c2c1004fb98da76eb244db4c35dba84085f45..04bfc1a4a804d1f5aa28f894e2feb816 bool opener_suppressed, bool* no_javascript_access); diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc -index 1aa52af90279e16f667cb07677c11141d2efce01..3cb0f9b3e24fb79e43b724d7ad5e6ad99cb7450f 100644 +index dae2f5a0dfedc5f7cd81c479cfab383730e61d9c..960fe49cab461b2f34793959bde0bbd829fe56bd 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -76,6 +76,7 @@ @@ -77,7 +77,7 @@ index 1aa52af90279e16f667cb07677c11141d2efce01..3cb0f9b3e24fb79e43b724d7ad5e6ad9 #include "content/renderer/media/audio/audio_device_factory.h" #include "content/renderer/media/stream/media_stream_device_observer.h" #include "content/renderer/media/video_capture/video_capture_impl_manager.h" -@@ -1356,6 +1357,8 @@ WebView* RenderViewImpl::CreateView( +@@ -1359,6 +1360,8 @@ WebView* RenderViewImpl::CreateView( } params->features = ConvertWebWindowFeaturesToMojoWindowFeatures(features); @@ -87,10 +87,10 @@ index 1aa52af90279e16f667cb07677c11141d2efce01..3cb0f9b3e24fb79e43b724d7ad5e6ad9 // moved on send. bool is_background_tab = diff --git a/content/shell/browser/web_test/web_test_content_browser_client.cc b/content/shell/browser/web_test/web_test_content_browser_client.cc -index 0c8320a60fcfe0bb9353587afcd9e057206fea18..7ae8aec1f042e275ea27911039c18663f22620ea 100644 +index c8aa2f99f40d038b73d0c9dbec2d941b1c652a6f..b8c17c44f3884e1f60ffd42dbae433392dde6307 100644 --- a/content/shell/browser/web_test/web_test_content_browser_client.cc +++ b/content/shell/browser/web_test/web_test_content_browser_client.cc -@@ -304,6 +304,8 @@ bool WebTestContentBrowserClient::CanCreateWindow( +@@ -308,6 +308,8 @@ bool WebTestContentBrowserClient::CanCreateWindow( const std::string& frame_name, WindowOpenDisposition disposition, const blink::mojom::WindowFeatures& features, diff --git a/patches/chromium/chrome_key_systems.patch b/patches/chromium/chrome_key_systems.patch index 4fc7b1dec5734..cc2d4bcd2ad45 100644 --- a/patches/chromium/chrome_key_systems.patch +++ b/patches/chromium/chrome_key_systems.patch @@ -7,7 +7,7 @@ Disable persiste licence support check for widevine cdm, as its not supported in the current version of chrome. diff --git a/chrome/renderer/media/chrome_key_systems.cc b/chrome/renderer/media/chrome_key_systems.cc -index 0ef05eceaa0e42710c6cfa8acb2174cf930f6114..e0356f615f8bae10b5030f038057be027491f96c 100644 +index b1c800648c70e5b81e167dc1697f50508bc20ce9..e5e0b8cb521bd074e193d039e31dfd5d949de05d 100644 --- a/chrome/renderer/media/chrome_key_systems.cc +++ b/chrome/renderer/media/chrome_key_systems.cc @@ -15,7 +15,9 @@ diff --git a/patches/chromium/command-ismediakey.patch b/patches/chromium/command-ismediakey.patch index e6a8d3d56837f..2f7486bf1fe7c 100644 --- a/patches/chromium/command-ismediakey.patch +++ b/patches/chromium/command-ismediakey.patch @@ -88,7 +88,7 @@ index 392cf3d58c64c088596e8d321a2ce37b0ec60b6e..43e30f47240dc10a3a9b950255d4e487 ui::Accelerator accelerator( ui::KeyboardCodeFromXKeyEvent(x_event), modifiers); diff --git a/ui/base/accelerators/media_keys_listener_mac.mm b/ui/base/accelerators/media_keys_listener_mac.mm -index 71b417ee8b64aa2ff7f1b2390851668ec1dcd7cf..1768af408d4cc3075e5bae046649e4955cc400b3 100644 +index f4e3126a4efd66f05c4f13e40ba23db10b8cca96..bb4c1a891dd13855227b39a0e582fd4dbc342ec9 100644 --- a/ui/base/accelerators/media_keys_listener_mac.mm +++ b/ui/base/accelerators/media_keys_listener_mac.mm @@ -33,6 +33,12 @@ KeyboardCode MediaKeyCodeToKeyboardCode(int key_code) { @@ -104,7 +104,7 @@ index 71b417ee8b64aa2ff7f1b2390851668ec1dcd7cf..1768af408d4cc3075e5bae046649e495 } return VKEY_UNKNOWN; } -@@ -192,7 +198,10 @@ static CGEventRef EventTapCallback(CGEventTapProxy proxy, +@@ -193,7 +199,10 @@ static CGEventRef EventTapCallback(CGEventTapProxy proxy, int key_code = (data1 & 0xFFFF0000) >> 16; if (key_code != NX_KEYTYPE_PLAY && key_code != NX_KEYTYPE_NEXT && key_code != NX_KEYTYPE_PREVIOUS && key_code != NX_KEYTYPE_FAST && diff --git a/patches/chromium/content_allow_embedder_to_prevent_locking_scheme_registry.patch b/patches/chromium/content_allow_embedder_to_prevent_locking_scheme_registry.patch deleted file mode 100644 index 975875283f619..0000000000000 --- a/patches/chromium/content_allow_embedder_to_prevent_locking_scheme_registry.patch +++ /dev/null @@ -1,55 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Jeremy Apthorp -Date: Wed, 21 Nov 2018 14:31:34 -0800 -Subject: content: allow embedder to prevent locking scheme registry - -The //content layer requires all schemes to be registered during startup, -because Add*Scheme aren't threadsafe. However, Electron exposes the option to -register additional schemes via JavaScript in the main process before the app -is ready, but after the //content layer has already locked the registry. - -Without this patch, calling `registerStandardSchemes` during initialization -when in debug mode will cause a DCHECK to fire. - -diff --git a/content/app/content_main_runner_impl.cc b/content/app/content_main_runner_impl.cc -index a388e279e9ef62d4484182bdde02de264a263186..4e8c72ad1602f576014ea5c8bb1d572e1490a8ff 100644 ---- a/content/app/content_main_runner_impl.cc -+++ b/content/app/content_main_runner_impl.cc -@@ -752,7 +752,7 @@ int ContentMainRunnerImpl::Initialize(const ContentMainParams& params) { - #endif - - RegisterPathProvider(); -- RegisterContentSchemes(true); -+ RegisterContentSchemes(delegate_->ShouldLockSchemeRegistry()); - - #if defined(OS_ANDROID) && (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE) - int icudata_fd = g_fds->MaybeGet(kAndroidICUDataDescriptor); -diff --git a/content/public/app/content_main_delegate.cc b/content/public/app/content_main_delegate.cc -index 456df421598153bde006ad0ecb0f1031360bb543..af06d78b91fa30e5daf993ad2c65c2c5e35a17a5 100644 ---- a/content/public/app/content_main_delegate.cc -+++ b/content/public/app/content_main_delegate.cc -@@ -55,6 +55,10 @@ int ContentMainDelegate::TerminateForFatalInitializationError() { - return 0; - } - -+bool ContentMainDelegate::ShouldLockSchemeRegistry() { -+ return true; -+} -+ - service_manager::ProcessType ContentMainDelegate::OverrideProcessType() { - return service_manager::ProcessType::kDefault; - } -diff --git a/content/public/app/content_main_delegate.h b/content/public/app/content_main_delegate.h -index d4f3b8097c6aba8e15616c6d00070565064b1e9c..5672f4f1c328d30bb04dd8aaf4af63c51d52b3e6 100644 ---- a/content/public/app/content_main_delegate.h -+++ b/content/public/app/content_main_delegate.h -@@ -88,6 +88,9 @@ class CONTENT_EXPORT ContentMainDelegate { - virtual void ZygoteForked() {} - #endif // defined(OS_LINUX) - -+ // Allows the embedder to prevent locking the scheme registry. -+ virtual bool ShouldLockSchemeRegistry(); -+ - // Fatal errors during initialization are reported by this function, so that - // the embedder can implement graceful exit by displaying some message and - // returning initialization error code. Default behavior is CHECK(false). diff --git a/patches/chromium/content_browser_main_loop.patch b/patches/chromium/content_browser_main_loop.patch index 9e81744555ac5..bd6c4b51915cf 100644 --- a/patches/chromium/content_browser_main_loop.patch +++ b/patches/chromium/content_browser_main_loop.patch @@ -8,12 +8,12 @@ run before shutdown. This is required to cleanup WebContents asynchronously in atom::CommonWebContentsDelegate::ResetManageWebContents. diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc -index dc34314c001aae412b44196805ad202694c180ef..9fd749dcd26555d84bc43aa3df3e8593371330c1 100644 +index d4426f92a066f8f30aa24cc5ad02ae4e75ab0e33..c1f2cb0a239566a279f13cdeec46d4e9f59db965 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc -@@ -1529,7 +1529,7 @@ void BrowserMainLoop::MainMessageLoopRun() { - } - +@@ -1499,7 +1499,7 @@ void BrowserMainLoop::MainMessageLoopRun() { + NOTREACHED(); + #else base::RunLoop run_loop; - parts_->PreDefaultMainMessageLoopRun(run_loop.QuitClosure()); + parts_->PreDefaultMainMessageLoopRun(run_loop.QuitWhenIdleClosure()); diff --git a/patches/chromium/cross_site_document_resource_handler.patch b/patches/chromium/cross_site_document_resource_handler.patch index 36c9c73fac0f4..0775334b5e658 100644 --- a/patches/chromium/cross_site_document_resource_handler.patch +++ b/patches/chromium/cross_site_document_resource_handler.patch @@ -8,10 +8,10 @@ this patch can be removed once we switch to network service, where the embedders have a chance to design their URLLoaders. diff --git a/content/browser/loader/cross_site_document_resource_handler.cc b/content/browser/loader/cross_site_document_resource_handler.cc -index d514c10160dd12f225c42e927977660cacbc9c43..49345f1d4d75c8b96efe485202d89774a05b6e34 100644 +index b9bd89a9c59515ac42702f010a0d3e9802a242fa..7f1e4ec569860e9bd1c608fd33f4fd6486e7fbd2 100644 --- a/content/browser/loader/cross_site_document_resource_handler.cc +++ b/content/browser/loader/cross_site_document_resource_handler.cc -@@ -671,6 +671,9 @@ bool CrossSiteDocumentResourceHandler::ShouldBlockBasedOnHeaders( +@@ -572,6 +572,9 @@ bool CrossSiteDocumentResourceHandler::ShouldBlockBasedOnHeaders( return false; } @@ -22,7 +22,7 @@ index d514c10160dd12f225c42e927977660cacbc9c43..49345f1d4d75c8b96efe485202d89774 } diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc -index ce64276225d5b0acf684e9e70c600a64a56fe96e..2a9661d877fbc09904eb469191523b5cd59eaeda 100644 +index f847cd95b561b45e9ee67ab960d7eb6d0dd1c304..95712234dafc9d6d71c83c1f785cc41a0dc00278 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc @@ -71,6 +71,10 @@ std::unique_ptr ContentBrowserClient::CreateBrowserMainParts( @@ -37,7 +37,7 @@ index ce64276225d5b0acf684e9e70c600a64a56fe96e..2a9661d877fbc09904eb469191523b5c const base::Location& from_here, const scoped_refptr& task_runner, diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h -index 5bf7340b106bd3ce826ff3322106ef94cbe19d29..ba27455e1c0934f77ed2871ee585361807ab701a 100644 +index 991afd44d9f4d9cf52b68909bbcd0f5cc9aedb37..0536e491fb2182db2a46c31cc7004cfb3b215c7c 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h @@ -252,6 +252,9 @@ class CONTENT_EXPORT ContentBrowserClient { diff --git a/patches/chromium/dcheck.patch b/patches/chromium/dcheck.patch index a783c8bc798c7..dece909a320ac 100644 --- a/patches/chromium/dcheck.patch +++ b/patches/chromium/dcheck.patch @@ -17,10 +17,10 @@ only one or two specific checks fail. Then it's better to simply comment out the failing checks and allow the rest of the target to have them enabled. diff --git a/content/browser/frame_host/navigation_controller_impl.cc b/content/browser/frame_host/navigation_controller_impl.cc -index f50c1283c195a9fdffbf737a0368cf4ffe3940d5..c57cda2907fa68d1d8c6095d1bbd7ffb69db7d26 100644 +index 818e8e456c4767987bbe0dbb3ee16669ec09620d..cdce8646f2c6c574aa1258917b77a9657c2dbf0d 100644 --- a/content/browser/frame_host/navigation_controller_impl.cc +++ b/content/browser/frame_host/navigation_controller_impl.cc -@@ -1242,8 +1242,10 @@ NavigationType NavigationControllerImpl::ClassifyNavigation( +@@ -1206,8 +1206,10 @@ NavigationType NavigationControllerImpl::ClassifyNavigation( return NAVIGATION_TYPE_NEW_SUBFRAME; } @@ -33,7 +33,7 @@ index f50c1283c195a9fdffbf737a0368cf4ffe3940d5..c57cda2907fa68d1d8c6095d1bbd7ffb if (rfh->GetParent()) { // All manual subframes would be did_create_new_entry and handled above, so -@@ -1486,7 +1488,10 @@ void NavigationControllerImpl::RendererDidNavigateToNewPage( +@@ -1452,7 +1454,10 @@ void NavigationControllerImpl::RendererDidNavigateToNewPage( new_entry->GetFavicon() = GetLastCommittedEntry()->GetFavicon(); } @@ -46,7 +46,7 @@ index f50c1283c195a9fdffbf737a0368cf4ffe3940d5..c57cda2907fa68d1d8c6095d1bbd7ffb // navigation. Now we know that the renderer has updated its state accordingly // and it is safe to also clear the browser side history. diff --git a/ui/base/clipboard/clipboard_win.cc b/ui/base/clipboard/clipboard_win.cc -index 17dee835d3d473a37e18c5a111426a3899a6ced2..ae01e88dbfbbfe34bb76e4234c17e95d06737663 100644 +index 7ed451db1a95409492f231d6cdde0da4fe2d6123..51dd41bd85bdbbf125747d514ff52ca5debe3638 100644 --- a/ui/base/clipboard/clipboard_win.cc +++ b/ui/base/clipboard/clipboard_win.cc @@ -729,9 +729,9 @@ void ClipboardWin::WriteBitmapFromHandle(HBITMAP source_hbitmap, diff --git a/patches/chromium/disable-redraw-lock.patch b/patches/chromium/disable-redraw-lock.patch index 13904a5ed8978..b84c315e3fd28 100644 --- a/patches/chromium/disable-redraw-lock.patch +++ b/patches/chromium/disable-redraw-lock.patch @@ -15,10 +15,10 @@ the redraw locking mechanism, which fixes these issues. The electron issue can be found at https://github.com/electron/electron/issues/1821 diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc -index de88c769b5be6b7f568d999d8bb92792e0e0ae19..ba47d52fd467e01c3d36db48d3b546bfa8468ed5 100644 +index ef9275f6599391d3e7c0e7f62b6ccc1a8e2e8d7a..e80221b6aedff9487e3b5c4d4ff87a55aa5914a7 100644 --- a/ui/views/win/hwnd_message_handler.cc +++ b/ui/views/win/hwnd_message_handler.cc -@@ -286,6 +286,10 @@ constexpr int kSynthesizedMouseMessagesTimeDifference = 500; +@@ -287,6 +287,10 @@ constexpr int kSynthesizedMouseMessagesTimeDifference = 500; } // namespace @@ -29,7 +29,7 @@ index de88c769b5be6b7f568d999d8bb92792e0e0ae19..ba47d52fd467e01c3d36db48d3b546bf // A scoping class that prevents a window from being able to redraw in response // to invalidations that may occur within it for the lifetime of the object. // -@@ -337,6 +341,7 @@ class HWNDMessageHandler::ScopedRedrawLock { +@@ -338,6 +342,7 @@ class HWNDMessageHandler::ScopedRedrawLock { cancel_unlock_(false), should_lock_(owner_->IsVisible() && !owner->HasChildRenderingWindow() && ::IsWindow(hwnd_) && @@ -37,7 +37,7 @@ index de88c769b5be6b7f568d999d8bb92792e0e0ae19..ba47d52fd467e01c3d36db48d3b546bf (!(GetWindowLong(hwnd_, GWL_STYLE) & WS_CAPTION) || !ui::win::IsAeroGlassEnabled())) { if (should_lock_) -@@ -937,6 +942,10 @@ bool HWNDMessageHandler::HasChildRenderingWindow() { +@@ -938,6 +943,10 @@ bool HWNDMessageHandler::HasChildRenderingWindow() { hwnd()); } diff --git a/patches/chromium/disable_color_correct_rendering.patch b/patches/chromium/disable_color_correct_rendering.patch index f78617cbae32a..4c14e07bc3f19 100644 --- a/patches/chromium/disable_color_correct_rendering.patch +++ b/patches/chromium/disable_color_correct_rendering.patch @@ -19,12 +19,12 @@ to deal with color spaces. That is being tracked at https://crbug.com/634542 and https://crbug.com/711107. diff --git a/cc/trees/layer_tree_settings.h b/cc/trees/layer_tree_settings.h -index 092fb1b7ea3626b7649472c35ec20bf1a6aaf4cd..fed8dd322faba387ebd0508228f847766a76011e 100644 +index e2db0f24f90c44c7bf796308c126276472308dd9..8e064f130458d1fc00e499182e0de10d6026a2ee 100644 --- a/cc/trees/layer_tree_settings.h +++ b/cc/trees/layer_tree_settings.h -@@ -99,6 +99,8 @@ class CC_EXPORT LayerTreeSettings { - - bool enable_mask_tiling = true; +@@ -97,6 +97,8 @@ class CC_EXPORT LayerTreeSettings { + bool use_rgba_4444 = false; + bool unpremultiply_and_dither_low_bit_depth_tiles = false; + bool enable_color_correct_rendering = true; + @@ -32,7 +32,7 @@ index 092fb1b7ea3626b7649472c35ec20bf1a6aaf4cd..fed8dd322faba387ebd0508228f84776 // Image Decode Service and raster tiles without images until the decode is // ready. diff --git a/components/viz/common/display/renderer_settings.h b/components/viz/common/display/renderer_settings.h -index 78041fcb9647f740c6a142ec65f2418712c6286c..04e75ac40c38a38bdec634d1aa645854cb1a80d6 100644 +index d433fb208d4a00cd62534823c95c3f85d286c893..1a098810fe8985dddfc65a602ad6db03fc02c55a 100644 --- a/components/viz/common/display/renderer_settings.h +++ b/components/viz/common/display/renderer_settings.h @@ -23,6 +23,7 @@ class VIZ_COMMON_EXPORT RendererSettings { @@ -44,7 +44,7 @@ index 78041fcb9647f740c6a142ec65f2418712c6286c..04e75ac40c38a38bdec634d1aa645854 bool force_antialiasing = false; bool force_blending_with_shaders = false; diff --git a/components/viz/host/renderer_settings_creation.cc b/components/viz/host/renderer_settings_creation.cc -index 78a6b5739caed8c3925f303c52ed107be8e4ccfe..ddbf660e594c1a991d4e758fa11b1b2ecf603b55 100644 +index 3b99fdc36afc5c5bb97bc8570da39b8edfed70e0..2143644bd748c1390f362fa7f4d8b24a08f83fe8 100644 --- a/components/viz/host/renderer_settings_creation.cc +++ b/components/viz/host/renderer_settings_creation.cc @@ -12,6 +12,7 @@ @@ -63,9 +63,9 @@ index 78a6b5739caed8c3925f303c52ed107be8e4ccfe..ddbf660e594c1a991d4e758fa11b1b2e + !command_line->HasSwitch(switches::kDisableColorCorrectRendering); renderer_settings.partial_swap_enabled = !command_line->HasSwitch(switches::kUIDisablePartialSwap); - #if defined(OS_WIN) + #if defined(OS_MACOSX) diff --git a/components/viz/service/display/gl_renderer.cc b/components/viz/service/display/gl_renderer.cc -index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28ff47771a 100644 +index 782b68bfed162ca4014a2586ba7a26349ca575ee..00ebe013f9a91a2e7140a9b6f071253f918a3e51 100644 --- a/components/viz/service/display/gl_renderer.cc +++ b/components/viz/service/display/gl_renderer.cc @@ -80,6 +80,9 @@ @@ -78,7 +78,7 @@ index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28 namespace viz { namespace { -@@ -554,8 +557,9 @@ void GLRenderer::DoDrawQuad(const DrawQuad* quad, +@@ -555,8 +558,9 @@ void GLRenderer::DoDrawQuad(const DrawQuad* quad, void GLRenderer::DrawDebugBorderQuad(const DebugBorderDrawQuad* quad) { SetBlendEnabled(quad->ShouldDrawWithBlending()); @@ -90,7 +90,7 @@ index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28 // Use the full quad_rect for debug quads to not move the edges based on // partial swaps. -@@ -1353,7 +1357,8 @@ void GLRenderer::ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params, +@@ -1371,7 +1375,8 @@ void GLRenderer::ChooseRPDQProgram(DrawRenderPassDrawQuadParams* params, params->use_aa ? USE_AA : NO_AA, mask_mode, mask_for_background, params->use_color_matrix, tint_gl_composited_content_, ShouldApplyRoundedCorner(params->quad)), @@ -100,7 +100,7 @@ index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28 } void GLRenderer::UpdateRPDQUniforms(DrawRenderPassDrawQuadParams* params) { -@@ -1824,8 +1829,8 @@ void GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad, +@@ -1842,8 +1847,8 @@ void GLRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad, SetUseProgram(ProgramKey::SolidColor(use_aa ? USE_AA : NO_AA, tint_gl_composited_content_, ShouldApplyRoundedCorner(quad)), @@ -111,7 +111,7 @@ index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28 SetShaderColor(color, opacity); if (current_program_->rounded_corner_rect_location() != -1) { SetShaderRoundedCorner( -@@ -1980,8 +1985,8 @@ void GLRenderer::DrawContentQuadAA(const ContentDrawQuadBase* quad, +@@ -1998,8 +2003,8 @@ void GLRenderer::DrawContentQuadAA(const ContentDrawQuadBase* quad, : NON_PREMULTIPLIED_ALPHA, false, false, tint_gl_composited_content_, ShouldApplyRoundedCorner(quad)), @@ -122,7 +122,7 @@ index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28 if (current_program_->tint_color_matrix_location() != -1) { auto matrix = cc::DebugColors::TintCompositedContentColorTransformMatrix(); -@@ -2077,8 +2082,8 @@ void GLRenderer::DrawContentQuadNoAA(const ContentDrawQuadBase* quad, +@@ -2095,8 +2100,8 @@ void GLRenderer::DrawContentQuadNoAA(const ContentDrawQuadBase* quad, !quad->ShouldDrawWithBlending(), has_tex_clamp_rect, tint_gl_composited_content_, ShouldApplyRoundedCorner(quad)), @@ -133,7 +133,7 @@ index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28 if (current_program_->tint_color_matrix_location() != -1) { auto matrix = cc::DebugColors::TintCompositedContentColorTransformMatrix(); -@@ -2181,7 +2186,7 @@ void GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad, +@@ -2199,7 +2204,7 @@ void GLRenderer::DrawYUVVideoQuad(const YUVVideoDrawQuad* quad, DCHECK_NE(src_color_space, src_color_space.GetAsFullRangeRGB()); gfx::ColorSpace dst_color_space = @@ -142,7 +142,7 @@ index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28 // Force sRGB output on Windows for overlay candidate video quads to match // DirectComposition behavior in case these switch between overlays and // compositing. See https://crbug.com/811118 for details. -@@ -2337,8 +2342,8 @@ void GLRenderer::DrawStreamVideoQuad(const StreamVideoDrawQuad* quad, +@@ -2355,8 +2360,8 @@ void GLRenderer::DrawStreamVideoQuad(const StreamVideoDrawQuad* quad, SetUseProgram(ProgramKey::VideoStream(tex_coord_precision, ShouldApplyRoundedCorner(quad)), @@ -153,7 +153,7 @@ index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28 DCHECK_EQ(GL_TEXTURE0, GetActiveTextureUnit(gl_)); gl_->BindTexture(GL_TEXTURE_EXTERNAL_OES, lock.texture_id()); -@@ -2395,8 +2400,8 @@ void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) { +@@ -2413,8 +2418,8 @@ void GLRenderer::FlushTextureQuadCache(BoundGeometry flush_binding) { draw_cache_.nearest_neighbor ? GL_NEAREST : GL_LINEAR); // Bind the program to the GL state. @@ -164,7 +164,7 @@ index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28 if (current_program_->rounded_corner_rect_location() != -1) { SetShaderRoundedCorner( -@@ -3089,7 +3094,9 @@ void GLRenderer::PrepareGeometry(BoundGeometry binding) { +@@ -3107,7 +3112,9 @@ void GLRenderer::PrepareGeometry(BoundGeometry binding) { void GLRenderer::SetUseProgram(const ProgramKey& program_key_no_color, const gfx::ColorSpace& src_color_space, const gfx::ColorSpace& dst_color_space) { @@ -175,7 +175,7 @@ index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28 ProgramKey program_key = program_key_no_color; const gfx::ColorTransform* color_transform = -@@ -3443,7 +3450,7 @@ void GLRenderer::CopyRenderPassDrawQuadToOverlayResource( +@@ -3461,7 +3468,7 @@ void GLRenderer::CopyRenderPassDrawQuadToOverlayResource( *overlay_texture = FindOrCreateOverlayTexture( params.quad->render_pass_id, iosurface_width, iosurface_height, @@ -184,7 +184,7 @@ index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28 *new_bounds = gfx::RectF(updated_dst_rect.origin(), gfx::SizeF((*overlay_texture)->texture.size())); -@@ -3647,8 +3654,9 @@ void GLRenderer::FlushOverdrawFeedback(const gfx::Rect& output_rect) { +@@ -3665,8 +3672,9 @@ void GLRenderer::FlushOverdrawFeedback(const gfx::Rect& output_rect) { PrepareGeometry(SHARED_BINDING); @@ -196,14 +196,14 @@ index b7a65f6dae8f2fcba0ba127cb50f0f338a26b9d0..bc1d0d3dd92d1adc6c94803755a23c28 gfx::Transform render_matrix; render_matrix.Translate(0.5 * output_rect.width() + output_rect.x(), -@@ -3808,3 +3816,5 @@ gfx::Size GLRenderer::GetRenderPassBackingPixelSize( +@@ -3826,3 +3834,5 @@ gfx::Size GLRenderer::GetRenderPassBackingPixelSize( } } // namespace viz + +#undef PATCH_CS diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc -index f34cfb51693648a7b342d21a61c601090209355a..b488efc71edf5d79e16c25d3d7be2d8ea9fa2ec8 100644 +index 4165ba000223c6d13e112a6a9861f015bb9ebbbb..70a9d11bdd1f836215724af18df18876d860ba05 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -191,6 +191,7 @@ GpuTerminationStatus ConvertToGpuTerminationStatus( @@ -215,7 +215,7 @@ index f34cfb51693648a7b342d21a61c601090209355a..b488efc71edf5d79e16c25d3d7be2d8e service_manager::switches::kGpuSandboxAllowSysVShm, service_manager::switches::kGpuSandboxFailuresFatal, diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc -index 4b8c6d7b1a2676df8ef63117785c1aed8341d12e..6930799c5fc0def1248b46884a3da18290e49671 100644 +index 26b1e9e2043cd5576e58ed44c5595c42a58f9f84..b9064efa92653be6e10b78f81b2e50c8f3742657 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -216,6 +216,7 @@ @@ -226,7 +226,7 @@ index 4b8c6d7b1a2676df8ef63117785c1aed8341d12e..6930799c5fc0def1248b46884a3da182 #include "ui/gl/gl_switches.h" #include "ui/native_theme/native_theme_features.h" -@@ -2908,6 +2909,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( +@@ -2898,6 +2899,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( // Propagate the following switches to the renderer command line (along // with any associated values) if present in the browser command line. static const char* const kSwitchNames[] = { @@ -235,10 +235,10 @@ index 4b8c6d7b1a2676df8ef63117785c1aed8341d12e..6930799c5fc0def1248b46884a3da182 network::switches::kExplicitlyAllowedPorts, service_manager::switches::kDisableInProcessStackTraces, diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc -index 33817ba20ae6cbfec8a28313092df9c10b1bf966..ea1a574c1f6d2a0f880391b21397c2cb342cbc77 100644 +index 70a3e142d9f4987c694dced5433611d8e937eb75..7de24a3a7b5bfc66c14d023ea3ec49ca4692f8e5 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc -@@ -2810,6 +2810,9 @@ cc::LayerTreeSettings RenderWidget::GenerateLayerTreeSettings( +@@ -2837,6 +2837,9 @@ cc::LayerTreeSettings RenderWidget::GenerateLayerTreeSettings( settings.main_frame_before_activation_enabled = cmd.HasSwitch(cc::switches::kEnableMainFrameBeforeActivation); @@ -249,7 +249,7 @@ index 33817ba20ae6cbfec8a28313092df9c10b1bf966..ea1a574c1f6d2a0f880391b21397c2cb // is what the renderer uses if its not threaded. settings.enable_checker_imaging = diff --git a/ui/gfx/mac/io_surface.cc b/ui/gfx/mac/io_surface.cc -index 88ec94963569588ed2882193a28197879dcb1090..eae37577bc9b1872c0162f55de218553eed61587 100644 +index 5bcfb34a98957315d0b9bb42a4d18e73f0b9a84a..66802e6806f35fc3761a2e6adf3c72e0fa6c06fc 100644 --- a/ui/gfx/mac/io_surface.cc +++ b/ui/gfx/mac/io_surface.cc @@ -16,6 +16,7 @@ @@ -260,7 +260,7 @@ index 88ec94963569588ed2882193a28197879dcb1090..eae37577bc9b1872c0162f55de218553 namespace gfx { -@@ -189,6 +190,11 @@ IOSurfaceRef CreateIOSurface(const gfx::Size& size, +@@ -191,6 +192,11 @@ IOSurfaceRef CreateIOSurface(const gfx::Size& size, // Ensure that all IOSurfaces start as sRGB. CGColorSpaceRef color_space = base::mac::GetSRGBColorSpace(); @@ -272,7 +272,7 @@ index 88ec94963569588ed2882193a28197879dcb1090..eae37577bc9b1872c0162f55de218553 base::ScopedCFTypeRef color_space_icc( CGColorSpaceCopyICCProfile(color_space)); IOSurfaceSetValue(surface, CFSTR("IOSurfaceColorSpace"), color_space_icc); -@@ -200,6 +206,14 @@ IOSurfaceRef CreateIOSurface(const gfx::Size& size, +@@ -202,6 +208,14 @@ IOSurfaceRef CreateIOSurface(const gfx::Size& size, void IOSurfaceSetColorSpace(IOSurfaceRef io_surface, const ColorSpace& color_space) { @@ -288,7 +288,7 @@ index 88ec94963569588ed2882193a28197879dcb1090..eae37577bc9b1872c0162f55de218553 if (color_space == ColorSpace::CreateSRGB()) { base::ScopedCFTypeRef srgb_icc( diff --git a/ui/gfx/switches.cc b/ui/gfx/switches.cc -index 189e147e908fdab38972f4f9b0ce212347a4ec2e..2a0a480d8513abc609b82f3d1eb24695d4f2146f 100644 +index ba3dbf23d1df7a3b0cc199054f36a88014daa0e7..f8a563a78cee2856da0f2ad556beba19b01a2e59 100644 --- a/ui/gfx/switches.cc +++ b/ui/gfx/switches.cc @@ -7,6 +7,8 @@ @@ -301,7 +301,7 @@ index 189e147e908fdab38972f4f9b0ce212347a4ec2e..2a0a480d8513abc609b82f3d1eb24695 // sharpness, kerning, hinting and layout. const char kDisableFontSubpixelPositioning[] = diff --git a/ui/gfx/switches.h b/ui/gfx/switches.h -index c95989ae7da12585fc417a680aef6c55e4b7a8d7..9e180a6decd72e510cecfec1f43fd1ac70e8b8f7 100644 +index 1f0e63383213ac5ebc67691e5e89b501d7480e1b..14e3d1928f7485684b646629f853ea39a616995e 100644 --- a/ui/gfx/switches.h +++ b/ui/gfx/switches.h @@ -10,6 +10,8 @@ @@ -312,4 +312,4 @@ index c95989ae7da12585fc417a680aef6c55e4b7a8d7..9e180a6decd72e510cecfec1f43fd1ac + GFX_SWITCHES_EXPORT extern const char kDisableFontSubpixelPositioning[]; - GFX_SWITCHES_EXPORT extern const char kHeadless[]; + GFX_SWITCHES_EXPORT extern const char kForcePrefersReducedMotion[]; diff --git a/patches/chromium/disable_detach_webview_frame.patch b/patches/chromium/disable_detach_webview_frame.patch index 82a08521376d4..e62eff830753a 100644 --- a/patches/chromium/disable_detach_webview_frame.patch +++ b/patches/chromium/disable_detach_webview_frame.patch @@ -12,7 +12,7 @@ this patch was introduced in Chrome 66. Update(zcbenz): The bug is still in Chrome 72. diff --git a/content/browser/frame_host/render_frame_proxy_host.cc b/content/browser/frame_host/render_frame_proxy_host.cc -index a28f80496b26f5a833060c88bd25b1e652ca3420..434edc879af6a09dd45630551de8f7b5cc8a3a7e 100644 +index ab3be3430e2d074bbb8b4c2d5fe5a5f98baf6848..acb78da664aae9320e65ffbe3a273025723652d6 100644 --- a/content/browser/frame_host/render_frame_proxy_host.cc +++ b/content/browser/frame_host/render_frame_proxy_host.cc @@ -268,6 +268,12 @@ void RenderFrameProxyHost::BubbleLogicalScroll( diff --git a/patches/chromium/disable_hidden.patch b/patches/chromium/disable_hidden.patch index 54a307994aff1..068c1afe0dffb 100644 --- a/patches/chromium/disable_hidden.patch +++ b/patches/chromium/disable_hidden.patch @@ -5,10 +5,10 @@ Subject: disable_hidden.patch diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc -index d1cf894d19b1cfa5e11dd44844ff15ed6a42dd58..553167fa07a3acee25434cfd71a968a112d56752 100644 +index 4acb400cf4e647c5113460330cd292cbd6563075..56a57239297ffc6d84492ec8b5f5d36e109085d2 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc -@@ -672,6 +672,9 @@ void RenderWidgetHostImpl::WasHidden() { +@@ -673,6 +673,9 @@ void RenderWidgetHostImpl::WasHidden() { if (is_hidden_) return; @@ -19,7 +19,7 @@ index d1cf894d19b1cfa5e11dd44844ff15ed6a42dd58..553167fa07a3acee25434cfd71a968a1 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::WasHidden"); diff --git a/content/browser/renderer_host/render_widget_host_impl.h b/content/browser/renderer_host/render_widget_host_impl.h -index 654c60e7bdecf009f2b837e38e9db50f3409978d..65fb1c070196b814edc6d94012150fa496897577 100644 +index 6dd5029fe645e0bf73063211103374fa4fcc769f..df62b0883e491cd9607d8f6ad1ed21403bc7fa7b 100644 --- a/content/browser/renderer_host/render_widget_host_impl.h +++ b/content/browser/renderer_host/render_widget_host_impl.h @@ -155,6 +155,9 @@ class CONTENT_EXPORT RenderWidgetHostImpl diff --git a/patches/chromium/disable_network_services_by_default.patch b/patches/chromium/disable_network_services_by_default.patch index 45aebd7b112dc..f927e517473a0 100644 --- a/patches/chromium/disable_network_services_by_default.patch +++ b/patches/chromium/disable_network_services_by_default.patch @@ -12,15 +12,15 @@ We should remove this patch after all Electron's code has been migrated to the NetworkService. diff --git a/services/network/public/cpp/features.cc b/services/network/public/cpp/features.cc -index 6d52910b8a248519a5eedad42d4f081840db92e7..89635931c4d45447f82156974a3145394098ef68 100644 +index c4c3a32a9aa6ff379f7c8666de17f9dc057c1d77..bb956ddd8338ccdd83aa678b29f10d1dcbf7706a 100644 --- a/services/network/public/cpp/features.cc +++ b/services/network/public/cpp/features.cc -@@ -18,7 +18,7 @@ const base::Feature kNetworkErrorLogging{"NetworkErrorLogging", - base::FEATURE_ENABLED_BY_DEFAULT}; - // Enables the network service. - const base::Feature kNetworkService{"NetworkService", -- base::FEATURE_ENABLED_BY_DEFAULT}; -+ base::FEATURE_DISABLED_BY_DEFAULT}; +@@ -23,7 +23,7 @@ const base::Feature kNetworkService { + #else + "NetworkServiceNotSupported", + #endif +- base::FEATURE_ENABLED_BY_DEFAULT ++ base::FEATURE_DISABLED_BY_DEFAULT + }; // Out of Blink CORS - const base::Feature kOutOfBlinkCors{"OutOfBlinkCors", diff --git a/patches/chromium/disable_user_gesture_requirement_for_beforeunload_dialogs.patch b/patches/chromium/disable_user_gesture_requirement_for_beforeunload_dialogs.patch index a7d839ea2704b..e037683126314 100644 --- a/patches/chromium/disable_user_gesture_requirement_for_beforeunload_dialogs.patch +++ b/patches/chromium/disable_user_gesture_requirement_for_beforeunload_dialogs.patch @@ -6,10 +6,10 @@ Subject: disable_user_gesture_requirement_for_beforeunload_dialogs.patch See https://github.com/electron/electron/issues/10754 diff --git a/third_party/blink/renderer/core/dom/document.cc b/third_party/blink/renderer/core/dom/document.cc -index b29cd849621a012e06955fdef4970f8d85976002..39ab0f7988c3b8aa16fbc747f0a5b3200fcbb227 100644 +index 9a7175184c094ae1725bb9f58182e17090c0e1f3..90cb0da5405b3b65572fc8afc8b127c031a421e9 100644 --- a/third_party/blink/renderer/core/dom/document.cc +++ b/third_party/blink/renderer/core/dom/document.cc -@@ -3653,7 +3653,9 @@ bool Document::DispatchBeforeUnloadEvent(ChromeClient* chrome_client, +@@ -3676,7 +3676,9 @@ bool Document::DispatchBeforeUnloadEvent(ChromeClient* chrome_client, "frame that never had a user gesture since its load. " "https://www.chromestatus.com/feature/5082396709879808"; Intervention::GenerateReport(frame_, "BeforeUnloadNoGesture", message); diff --git a/patches/chromium/dom_storage_limits.patch b/patches/chromium/dom_storage_limits.patch index 1db5763ce844e..fc46f7b95b190 100644 --- a/patches/chromium/dom_storage_limits.patch +++ b/patches/chromium/dom_storage_limits.patch @@ -61,10 +61,10 @@ index e87afe5b8ee07f7038a7cc9c40832b6cd27884da..61c9a0dfff60f79c7b36ff5c7d741c06 // In the browser process we allow some overage to diff --git a/third_party/blink/renderer/modules/storage/cached_storage_area.cc b/third_party/blink/renderer/modules/storage/cached_storage_area.cc -index 6a3a3718443aebf24fd60e00f8f01ba76575ebfa..fb8250553164ebaf1a5ccae4a1c8e2f660ea6e14 100644 +index 980bb8d7bb5e8a440337f34076dc0d8005a72847..2df47b80f6b7de4ae314e85d36d63c2cc4ddf73c 100644 --- a/third_party/blink/renderer/modules/storage/cached_storage_area.cc +++ b/third_party/blink/renderer/modules/storage/cached_storage_area.cc -@@ -106,11 +106,13 @@ bool CachedStorageArea::SetItem(const String& key, +@@ -107,11 +107,13 @@ bool CachedStorageArea::SetItem(const String& key, Source* source) { DCHECK(areas_->Contains(source)); diff --git a/patches/chromium/exclude-a-few-test-files-from-build.patch b/patches/chromium/exclude-a-few-test-files-from-build.patch index e86402a355a15..6f5374f0e3c75 100644 --- a/patches/chromium/exclude-a-few-test-files-from-build.patch +++ b/patches/chromium/exclude-a-few-test-files-from-build.patch @@ -7,10 +7,10 @@ Compilation of those files fails with the Chromium 68. Remove the patch during the Chromium 69 upgrade. diff --git a/third_party/blink/renderer/platform/BUILD.gn b/third_party/blink/renderer/platform/BUILD.gn -index 64ae02a700342c446aec62756180e25434eea46d..b1da69c1810fc502334dfc26130afec02a1c85db 100644 +index 68644048831277547b1e8348eb512b7990a9f522..d4368acfd5a9127e6d6f6ebe9c98a9db0c926514 100644 --- a/third_party/blink/renderer/platform/BUILD.gn +++ b/third_party/blink/renderer/platform/BUILD.gn -@@ -1715,7 +1715,7 @@ jumbo_source_set("blink_platform_unittests_sources") { +@@ -1710,7 +1710,7 @@ jumbo_source_set("blink_platform_unittests_sources") { "graphics/paint/drawing_display_item_test.cc", "graphics/paint/drawing_recorder_test.cc", "graphics/paint/float_clip_rect_test.cc", diff --git a/patches/chromium/feat_offscreen_rendering_with_viz_compositor.patch b/patches/chromium/feat_offscreen_rendering_with_viz_compositor.patch index 35fa1cc6fc3b5..ebd82c05677d9 100644 --- a/patches/chromium/feat_offscreen_rendering_with_viz_compositor.patch +++ b/patches/chromium/feat_offscreen_rendering_with_viz_compositor.patch @@ -70,11 +70,11 @@ index 5e5c5da4a3cfc927df3fb120fcab647e927271c1..8c6ec95f309660fb83012a13c7b9bb64 #if defined(USE_X11) void DidCompleteSwapWithNewSize(const gfx::Size& size) override; diff --git a/components/viz/host/layered_window_updater_impl.cc b/components/viz/host/layered_window_updater_impl.cc -index d3a49ed8be8dc11b86af67cdd600b05ddc0fc486..88bf86f3938b8267d731b52c8c3baa35d3128c7a 100644 +index 65c26e2f7ae813e50f6740f73a4d145467da4366..39c04c4d6b644a4ad7b13b4e932b085fad0b8293 100644 --- a/components/viz/host/layered_window_updater_impl.cc +++ b/components/viz/host/layered_window_updater_impl.cc -@@ -47,7 +47,9 @@ void LayeredWindowUpdaterImpl::OnAllocatedSharedMemory( - shm_handle.Close(); +@@ -43,7 +43,9 @@ void LayeredWindowUpdaterImpl::OnAllocatedSharedMemory( + // |region|'s handle will close when it goes out of scope. } -void LayeredWindowUpdaterImpl::Draw(DrawCallback draw_callback) { @@ -85,20 +85,20 @@ index d3a49ed8be8dc11b86af67cdd600b05ddc0fc486..88bf86f3938b8267d731b52c8c3baa35 if (!canvas_) { diff --git a/components/viz/host/layered_window_updater_impl.h b/components/viz/host/layered_window_updater_impl.h -index 93c52d2b928cba6e98723e19b005fb7bd7089a58..4dc645e770a2a039ed8e4ff4de555767fee34a3a 100644 +index d9a9730a78b9aec833c64282ca868dbba5594d82..d98426e9f78931bd43061ec994559d594c96151c 100644 --- a/components/viz/host/layered_window_updater_impl.h +++ b/components/viz/host/layered_window_updater_impl.h @@ -33,7 +33,7 @@ class VIZ_HOST_EXPORT LayeredWindowUpdaterImpl - void OnAllocatedSharedMemory( - const gfx::Size& pixel_size, - mojo::ScopedSharedBufferHandle scoped_buffer_handle) override; + // mojom::LayeredWindowUpdater implementation. + void OnAllocatedSharedMemory(const gfx::Size& pixel_size, + base::UnsafeSharedMemoryRegion region) override; - void Draw(DrawCallback draw_callback) override; + void Draw(const gfx::Rect& damage_rect, DrawCallback draw_callback) override; private: const HWND hwnd_; diff --git a/components/viz/service/BUILD.gn b/components/viz/service/BUILD.gn -index f17983a5cc70f8ab1e5c531de8e26fdec04a079b..16aefe38f0c674d97a89d3e511dc104ae0670f26 100644 +index 7ad421457cbd568c2ae18f789905e98dd4a4c747..1539f1f55fd83d8837744cbc318afe30e34b1689 100644 --- a/components/viz/service/BUILD.gn +++ b/components/viz/service/BUILD.gn @@ -117,6 +117,8 @@ viz_component("service") { @@ -111,18 +111,18 @@ index f17983a5cc70f8ab1e5c531de8e26fdec04a079b..16aefe38f0c674d97a89d3e511dc104a "display_embedder/software_output_surface.h", "display_embedder/viz_process_context_provider.cc", diff --git a/components/viz/service/display_embedder/output_surface_provider_impl.cc b/components/viz/service/display_embedder/output_surface_provider_impl.cc -index 8fe397588eb47224d48a8642b814583d11cc9c09..a7072c8e16434d3b15db1599f43d8fab5a97bdf3 100644 +index a7915a8517aae29ec07b525c008bd324eb2381ca..52f118f7989048535f2f0bfaa767cba3cf7e35f9 100644 --- a/components/viz/service/display_embedder/output_surface_provider_impl.cc +++ b/components/viz/service/display_embedder/output_surface_provider_impl.cc -@@ -18,6 +18,7 @@ - #include "components/viz/service/display_embedder/server_shared_bitmap_manager.h" +@@ -21,6 +21,7 @@ + #include "components/viz/service/display_embedder/skia_output_surface_dependency_impl.h" #include "components/viz/service/display_embedder/skia_output_surface_impl.h" #include "components/viz/service/display_embedder/skia_output_surface_impl_non_ddl.h" +#include "components/viz/service/display_embedder/software_output_device_proxy.h" #include "components/viz/service/display_embedder/software_output_surface.h" #include "components/viz/service/display_embedder/viz_process_context_provider.h" #include "components/viz/service/gl/gpu_service_impl.h" -@@ -243,6 +244,19 @@ OutputSurfaceProviderImpl::CreateSoftwareOutputDeviceForPlatform( +@@ -229,6 +230,19 @@ OutputSurfaceProviderImpl::CreateSoftwareOutputDeviceForPlatform( if (headless_) return std::make_unique(); @@ -177,17 +177,17 @@ index f3867356e3d641416e00e6d115ae9ae2a0be90ab..b1d192d2b20ccb63fba07093101d745e diff --git a/components/viz/service/display_embedder/software_output_device_proxy.cc b/components/viz/service/display_embedder/software_output_device_proxy.cc new file mode 100644 -index 0000000000000000000000000000000000000000..bbca3a43b5ba8bcf1e3a4dab4509b903b7117f36 +index 0000000000000000000000000000000000000000..f5fc4f37c10bdc8aca8c1618985d46d10c830437 --- /dev/null +++ b/components/viz/service/display_embedder/software_output_device_proxy.cc -@@ -0,0 +1,168 @@ +@@ -0,0 +1,156 @@ +// Copyright 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 file. + +#include "components/viz/service/display_embedder/software_output_device_proxy.h" + -+#include "base/memory/shared_memory.h" ++#include "base/memory/unsafe_shared_memory_region.h" +#include "base/threading/thread_checker.h" +#include "components/viz/common/resources/resource_sizes.h" +#include "components/viz/service/display_embedder/output_device_backing.h" @@ -280,44 +280,32 @@ index 0000000000000000000000000000000000000000..bbca3a43b5ba8bcf1e3a4dab4509b903 + return; + } + ++ base::UnsafeSharedMemoryRegion region = ++ base::UnsafeSharedMemoryRegion::Create(required_bytes); ++ if (!region.IsValid()) { ++ DLOG(ERROR) << "Failed to allocate " << required_bytes << " bytes"; ++ return; ++ } ++ + #if defined(WIN32) -+ base::SharedMemory shm; -+ if (!shm.CreateAnonymous(required_bytes)) { -+ DLOG(ERROR) << "Failed to allocate " << required_bytes << " bytes"; -+ return; -+ } -+ -+ canvas_ = skia::CreatePlatformCanvasWithSharedSection( -+ viewport_pixel_size_.width(), viewport_pixel_size_.height(), false, -+ shm.handle().GetHandle(), skia::CRASH_ON_FAILURE); -+ -+ // Transfer handle ownership to the browser process. -+ mojo::ScopedSharedBufferHandle scoped_handle = mojo::WrapSharedMemoryHandle( -+ shm.TakeHandle(), required_bytes, -+ mojo::UnwrappedSharedMemoryHandleProtection::kReadWrite); ++ canvas_ = skia::CreatePlatformCanvasWithSharedSection( ++ viewport_pixel_size_.width(), viewport_pixel_size_.height(), false, ++ region.GetPlatformHandle(), skia::CRASH_ON_FAILURE); + #else -+ auto shm = mojo::CreateWritableSharedMemoryRegion(required_bytes); -+ if (!shm.IsValid()) { -+ DLOG(ERROR) << "Failed to allocate " << required_bytes << " bytes"; -+ return; -+ } -+ -+ shm_mapping_ = shm.Map(); -+ if (!shm_mapping_.IsValid()) { -+ DLOG(ERROR) << "Failed to map " << required_bytes << " bytes"; -+ return; -+ } -+ -+ canvas_ = skia::CreatePlatformCanvasWithPixels( -+ viewport_pixel_size_.width(), viewport_pixel_size_.height(), false, -+ static_cast(shm_mapping_.memory()), skia::CRASH_ON_FAILURE); -+ -+ mojo::ScopedSharedBufferHandle scoped_handle = -+ mojo::WrapWritableSharedMemoryRegion(std::move(shm)); ++ shm_mapping_ = region.Map(); ++ if (!shm_mapping_.IsValid()) { ++ DLOG(ERROR) << "Failed to map " << required_bytes << " bytes"; ++ return; ++ } ++ ++ canvas_ = skia::CreatePlatformCanvasWithPixels( ++ viewport_pixel_size_.width(), viewport_pixel_size_.height(), false, ++ static_cast(shm_mapping_.memory()), skia::CRASH_ON_FAILURE); + #endif + ++ // Transfer region ownership to the browser process. + layered_window_updater_->OnAllocatedSharedMemory(viewport_pixel_size_, -+ std::move(scoped_handle)); ++ std::move(region)); +} + +SkCanvas* SoftwareOutputDeviceProxy::BeginPaintDelegated() { @@ -444,7 +432,7 @@ index 0000000000000000000000000000000000000000..ff3c0217812a8370a20aa528f117e928 + +#endif // COMPONENTS_VIZ_SERVICE_DISPLAY_EMBEDDER_SOFTWARE_OUTPUT_DEVICE_PROXY_H_ diff --git a/components/viz/service/display_embedder/software_output_device_win.cc b/components/viz/service/display_embedder/software_output_device_win.cc -index 4e3f0255d5fe4991004a50768932c36c42d999ff..bf352091cef00482e3cec74cd523e469e1bffa0d 100644 +index 73ea1986b2140a3ffb87c5e23c7ab2174bac0a10..3ba3657ba12ec47cc3db3fec218496ffe817d35b 100644 --- a/components/viz/service/display_embedder/software_output_device_win.cc +++ b/components/viz/service/display_embedder/software_output_device_win.cc @@ -11,6 +11,7 @@ @@ -455,7 +443,7 @@ index 4e3f0255d5fe4991004a50768932c36c42d999ff..bf352091cef00482e3cec74cd523e469 #include "mojo/public/cpp/system/platform_handle.h" #include "services/viz/privileged/interfaces/compositing/layered_window_updater.mojom.h" #include "skia/ext/platform_canvas.h" -@@ -268,7 +269,7 @@ void SoftwareOutputDeviceWinProxy::EndPaintDelegated( +@@ -265,7 +266,7 @@ void SoftwareOutputDeviceWinProxy::EndPaintDelegated( if (!canvas_) return; @@ -464,7 +452,7 @@ index 4e3f0255d5fe4991004a50768932c36c42d999ff..bf352091cef00482e3cec74cd523e469 &SoftwareOutputDeviceWinProxy::DrawAck, base::Unretained(this))); waiting_on_draw_ack_ = true; -@@ -300,8 +301,13 @@ std::unique_ptr CreateSoftwareOutputDeviceWin( +@@ -297,8 +298,13 @@ std::unique_ptr CreateSoftwareOutputDeviceWin( display_client->CreateLayeredWindowUpdater( mojo::MakeRequest(&layered_window_updater)); @@ -481,7 +469,7 @@ index 4e3f0255d5fe4991004a50768932c36c42d999ff..bf352091cef00482e3cec74cd523e469 return std::make_unique(hwnd, backing); } diff --git a/services/viz/privileged/interfaces/compositing/display_private.mojom b/services/viz/privileged/interfaces/compositing/display_private.mojom -index deb327b7705462d2cc07edb9d37528035377af8b..bc6958aa7e4dc14d3e0cf040299642825194e2fc 100644 +index cd8dd80230d199eb05c70710aa681c491ead1646..7b61f33156a4e182ee6ddffc267be798af335989 100644 --- a/services/viz/privileged/interfaces/compositing/display_private.mojom +++ b/services/viz/privileged/interfaces/compositing/display_private.mojom @@ -77,12 +77,14 @@ interface DisplayPrivate { @@ -501,10 +489,10 @@ index deb327b7705462d2cc07edb9d37528035377af8b..bc6958aa7e4dc14d3e0cf04029964282 // Notifies that a swap has occurred and provides information about the pixel diff --git a/services/viz/privileged/interfaces/compositing/layered_window_updater.mojom b/services/viz/privileged/interfaces/compositing/layered_window_updater.mojom -index 360cab3eee4c5189a55269d76daa1d78a98ed3d3..6834242f23d27fd6d428c2cd6040206a79d5097b 100644 +index 58a7e221eaabd9e21196496d220c77babe07c56d..dd141b16eace2999380ed137b4adf1f3538a8a70 100644 --- a/services/viz/privileged/interfaces/compositing/layered_window_updater.mojom +++ b/services/viz/privileged/interfaces/compositing/layered_window_updater.mojom -@@ -22,5 +22,5 @@ interface LayeredWindowUpdater { +@@ -26,5 +26,5 @@ interface LayeredWindowUpdater { // Draws to the HWND by copying pixels from shared memory. Callback must be // called after draw operation is complete to signal shared memory can be // modified. @@ -512,7 +500,7 @@ index 360cab3eee4c5189a55269d76daa1d78a98ed3d3..6834242f23d27fd6d428c2cd6040206a + Draw(gfx.mojom.Rect damage_rect) => (); }; diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h -index 494241c374b7ffac0fa89549dc1b8a30359eb17f..5ac7c707374ebcb5510c76017edfcceee97b599e 100644 +index 04e153e9d96c900385e1430561599b6e8496b62d..108453e11a7f296c03c73cdc54746181150641b1 100644 --- a/ui/compositor/compositor.h +++ b/ui/compositor/compositor.h @@ -23,6 +23,7 @@ @@ -549,7 +537,7 @@ index 494241c374b7ffac0fa89549dc1b8a30359eb17f..5ac7c707374ebcb5510c76017edfccee // Sets the root of the layer tree drawn by this Compositor. The root layer // must have no parent. The compositor's root layer is reset if the root layer // is destroyed. NULL can be passed to reset the root layer, in which case the -@@ -454,6 +467,8 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient, +@@ -453,6 +466,8 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient, ui::ContextFactory* context_factory_; ui::ContextFactoryPrivate* context_factory_private_; diff --git a/patches/chromium/fix_disable_usage_of_setapplicationisdaemon_and.patch b/patches/chromium/fix_disable_usage_of_setapplicationisdaemon_and.patch index bbb1e3dddc5dd..cf5b9e86f517c 100644 --- a/patches/chromium/fix_disable_usage_of_setapplicationisdaemon_and.patch +++ b/patches/chromium/fix_disable_usage_of_setapplicationisdaemon_and.patch @@ -5,7 +5,7 @@ Subject: fix: disable usage of SetApplicationIsDaemon and _LSSetApplicationLaunchServicesServerConnectionStatus in MAS builds diff --git a/content/utility/utility_service_factory.cc b/content/utility/utility_service_factory.cc -index 2e098ff3c2d0052984a96ffc72e393a20418b445..bf07ae34c286f03225535f6082a9151f12a3a5f2 100644 +index 35b8382b0215dfc17c67d7215a1a096ffa3cd503..62ac2aa93f4778e029232334729d084ee3c2f6b1 100644 --- a/content/utility/utility_service_factory.cc +++ b/content/utility/utility_service_factory.cc @@ -207,7 +207,7 @@ void UtilityServiceFactory::RunService( diff --git a/patches/chromium/fix_re-add_endauxattributes_to_fix_gpu_info_enumeration.patch b/patches/chromium/fix_re-add_endauxattributes_to_fix_gpu_info_enumeration.patch new file mode 100644 index 0000000000000..b1cdb9bfd800b --- /dev/null +++ b/patches/chromium/fix_re-add_endauxattributes_to_fix_gpu_info_enumeration.patch @@ -0,0 +1,18 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samuel Attard +Date: Tue, 2 Jul 2019 14:53:57 -0700 +Subject: fix: re-add EndAuxAttributes to fix gpu info enumeration + + +diff --git a/gpu/config/gpu_info.cc b/gpu/config/gpu_info.cc +index 963884c9e53d8d619cb076247bc4884ae0a89252..7b9fddb29c10be436857e9f035846a8996ee48a9 100644 +--- a/gpu/config/gpu_info.cc ++++ b/gpu/config/gpu_info.cc +@@ -326,6 +326,7 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const { + enumerator->AddInt64("rgbaVisual", rgba_visual); + #endif + enumerator->AddBool("oopRasterizationSupported", oop_rasterization_supported); ++ enumerator->EndAuxAttributes(); + } + + } // namespace gpu diff --git a/patches/chromium/frame_host_manager.patch b/patches/chromium/frame_host_manager.patch index 060ed069d078c..1f05a4eed9dd8 100644 --- a/patches/chromium/frame_host_manager.patch +++ b/patches/chromium/frame_host_manager.patch @@ -8,10 +8,10 @@ and respond with custom instance. Also allows for us to at-runtime enable or disable this patch. diff --git a/content/browser/browsing_instance.cc b/content/browser/browsing_instance.cc -index 12e1c5cff95aa6d0a907a249208e23371cf29785..3bc26b7870ff3bf6a69cb1e123fb372f763442ee 100644 +index 0d40acea7c2c69003c54cf3ae1e1d15adcb6deee..ba28c8f315b4b89a08659b45eaff485dcb65fc39 100644 --- a/content/browser/browsing_instance.cc +++ b/content/browser/browsing_instance.cc -@@ -79,6 +79,13 @@ scoped_refptr BrowsingInstance::GetSiteInstanceForURL( +@@ -83,6 +83,13 @@ scoped_refptr BrowsingInstance::GetSiteInstanceForURL( return instance; } @@ -26,7 +26,7 @@ index 12e1c5cff95aa6d0a907a249208e23371cf29785..3bc26b7870ff3bf6a69cb1e123fb372f bool allow_default_instance, GURL* site_url, diff --git a/content/browser/browsing_instance.h b/content/browser/browsing_instance.h -index 775b64a8d20f89845812852a2904a1e6875c2b4a..5235b57bbf44fc7b30ca6943c43a290f07f003bf 100644 +index acbf074f6e408cdc3817580b9601ee40c036c4dd..e56456c5b6024b92dbd025a8f25d4bde5f8afe27 100644 --- a/content/browser/browsing_instance.h +++ b/content/browser/browsing_instance.h @@ -136,6 +136,11 @@ class CONTENT_EXPORT BrowsingInstance final @@ -42,15 +42,15 @@ index 775b64a8d20f89845812852a2904a1e6875c2b4a..5235b57bbf44fc7b30ca6943c43a290f // another SiteInstance for the same site. void RegisterSiteInstance(SiteInstanceImpl* site_instance); diff --git a/content/browser/frame_host/render_frame_host_manager.cc b/content/browser/frame_host/render_frame_host_manager.cc -index 297b61198dd46114b3d8c89488a71ed01aa299c4..40b848a8b448bed2d167bf5f6c0f25971b603ed2 100644 +index 84484b0072c2122f2321e629b28f16383a466500..470439f07c5b8afd6d42efdfa27ff74cf08a2bf8 100644 --- a/content/browser/frame_host/render_frame_host_manager.cc +++ b/content/browser/frame_host/render_frame_host_manager.cc -@@ -2127,6 +2127,20 @@ bool RenderFrameHostManager::InitRenderView( +@@ -2123,6 +2123,21 @@ bool RenderFrameHostManager::InitRenderView( scoped_refptr RenderFrameHostManager::GetSiteInstanceForNavigationRequest( const NavigationRequest& request) { + BrowserContext* browser_context = nullptr; -+ scoped_refptr candidate_site_instance; ++ scoped_refptr candidate_site_instance; + if (!GetContentClient()->browser()->CanUseCustomSiteInstance()) { + browser_context = + delegate_->GetControllerForRenderManager().GetBrowserContext(); @@ -63,10 +63,11 @@ index 297b61198dd46114b3d8c89488a71ed01aa299c4..40b848a8b448bed2d167bf5f6c0f2597 + ? speculative_render_frame_host_->GetSiteInstance() + : nullptr; + } - // First, check if the navigation can switch SiteInstances. If not, the - // navigation should use the current SiteInstance. ++ SiteInstance* current_site_instance = render_frame_host_->GetSiteInstance(); -@@ -2158,6 +2172,53 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest( + + // All children of MHTML documents must be MHTML documents. They all live in +@@ -2160,6 +2175,53 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest( request.common_params().url); no_renderer_swap_allowed |= request.from_begin_navigation() && !can_renderer_initiate_transfer; @@ -120,7 +121,7 @@ index 297b61198dd46114b3d8c89488a71ed01aa299c4..40b848a8b448bed2d167bf5f6c0f2597 } else { // Subframe navigations will use the current renderer, unless specifically // allowed to swap processes. -@@ -2169,23 +2230,28 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest( +@@ -2171,23 +2233,28 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest( if (no_renderer_swap_allowed && !should_swap_for_error_isolation) return scoped_refptr(current_site_instance); @@ -129,7 +130,7 @@ index 297b61198dd46114b3d8c89488a71ed01aa299c4..40b848a8b448bed2d167bf5f6c0f2597 // should use. // TODO(clamy): We should also consider as a candidate SiteInstance the // speculative SiteInstance that was computed on redirects. -- SiteInstance* candidate_site_instance = +- SiteInstanceImpl* candidate_site_instance = + candidate_site_instance = speculative_render_frame_host_ ? speculative_render_frame_host_->GetSiteInstance() @@ -152,10 +153,10 @@ index 297b61198dd46114b3d8c89488a71ed01aa299c4..40b848a8b448bed2d167bf5f6c0f2597 } diff --git a/content/browser/site_instance_impl.cc b/content/browser/site_instance_impl.cc -index fd184108a7993094c29be3f7ebde658e259ede2c..75aa4a6b7d58a1bebe34efc923953c69348428a9 100644 +index c6bc3bf3ea5fd936c8d14f07efbf2453da881342..08d0fa5c6dfe3ff46f206f7983d47e9c445c63da 100644 --- a/content/browser/site_instance_impl.cc +++ b/content/browser/site_instance_impl.cc -@@ -342,6 +342,10 @@ bool SiteInstanceImpl::HasRelatedSiteInstance(const GURL& url) { +@@ -356,6 +356,10 @@ bool SiteInstanceImpl::HasRelatedSiteInstance(const GURL& url) { return browsing_instance_->HasSiteInstance(url); } @@ -167,7 +168,7 @@ index fd184108a7993094c29be3f7ebde658e259ede2c..75aa4a6b7d58a1bebe34efc923953c69 const GURL& url) { return browsing_instance_->GetSiteInstanceForURL( diff --git a/content/browser/site_instance_impl.h b/content/browser/site_instance_impl.h -index a46901055bdf17b6b0dab14edf753b234dc04a12..113660b6eeff81d56a0415b0fa16211efd8d8e14 100644 +index 5f57cd47108b85c0e884c1855af2c74b7fd02b9b..6b755ec0f9f76fa91bec975fdcf7094b4d43cea6 100644 --- a/content/browser/site_instance_impl.h +++ b/content/browser/site_instance_impl.h @@ -83,6 +83,7 @@ class CONTENT_EXPORT SiteInstanceImpl final : public SiteInstance, @@ -179,7 +180,7 @@ index a46901055bdf17b6b0dab14edf753b234dc04a12..113660b6eeff81d56a0415b0fa16211e size_t GetRelatedActiveContentsCount() override; bool RequiresDedicatedProcess() override; diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc -index 2dd31166cc52ccb528b338b63fde7d2fb4bbf63d..ce64276225d5b0acf684e9e70c600a64a56fe96e 100644 +index dfd8bbaed5cfc48a116be63a067d00bb21960e85..f847cd95b561b45e9ee67ab960d7eb6d0dd1c304 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc @@ -52,6 +52,20 @@ void OverrideOnBindInterface(const service_manager::BindSourceInfo& remote_info, @@ -204,7 +205,7 @@ index 2dd31166cc52ccb528b338b63fde7d2fb4bbf63d..ce64276225d5b0acf684e9e70c600a64 const MainFunctionParams& parameters) { return nullptr; diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h -index 04bfc1a4a804d1f5aa28f894e2feb816bbe80ffc..5bf7340b106bd3ce826ff3322106ef94cbe19d29 100644 +index 19edc738013c360d839575b62ff637e6c26c0f8a..991afd44d9f4d9cf52b68909bbcd0f5cc9aedb37 100644 --- a/content/public/browser/content_browser_client.h +++ b/content/public/browser/content_browser_client.h @@ -211,8 +211,41 @@ CONTENT_EXPORT void OverrideOnBindInterface( diff --git a/patches/chromium/gin_enable_disable_v8_platform.patch b/patches/chromium/gin_enable_disable_v8_platform.patch index f5b7689c7ab31..22329ebf6cc7e 100644 --- a/patches/chromium/gin_enable_disable_v8_platform.patch +++ b/patches/chromium/gin_enable_disable_v8_platform.patch @@ -36,7 +36,7 @@ index 413e6c5bcc74cd01730c5d4dc66eb92aaf7df8de..6c5d101fef97e880bee20d2f76e4b339 v8::Isolate* isolate() { return isolate_; } diff --git a/gin/v8_initializer.cc b/gin/v8_initializer.cc -index 770f3cb52990e2a4160050234e474889daab751c..ea9817bf4c0ab5d84ca21abcc573956e9f09b5d3 100644 +index aab46a000c5e9081440298ecef4844ead7a40b28..2cee8dee3f70148570613dc17827da19b193ff62 100644 --- a/gin/v8_initializer.cc +++ b/gin/v8_initializer.cc @@ -204,12 +204,14 @@ enum LoadV8FileResult { diff --git a/patches/chromium/gritsettings_resource_ids.patch b/patches/chromium/gritsettings_resource_ids.patch index a4a8d8d0efe54..4b9e2ce4591ca 100644 --- a/patches/chromium/gritsettings_resource_ids.patch +++ b/patches/chromium/gritsettings_resource_ids.patch @@ -6,10 +6,10 @@ Subject: gritsettings_resource_ids.patch Add electron resources file to the list of resource ids generation. diff --git a/tools/gritsettings/resource_ids b/tools/gritsettings/resource_ids -index 2a7cb2dcb562781310062bc93af3a3d2f5f57fa2..8948459732b4a9ba35a394b4c26be566484c2830 100644 +index 0182eedbeefe97c65299d6bb3c705d2fb59d1e44..540457a76abdb9f1dc703e30b7cde138f27b0ea3 100644 --- a/tools/gritsettings/resource_ids +++ b/tools/gritsettings/resource_ids -@@ -452,6 +452,11 @@ +@@ -449,6 +449,11 @@ "includes": [28880], }, diff --git a/patches/chromium/mas-audiodeviceduck.patch b/patches/chromium/mas-audiodeviceduck.patch index c0c829cdcd2df..d1ced734df07f 100644 --- a/patches/chromium/mas-audiodeviceduck.patch +++ b/patches/chromium/mas-audiodeviceduck.patch @@ -6,7 +6,7 @@ Subject: mas-audiodeviceduck.patch Removes usage of the AudioDeviceDuck private API. diff --git a/media/audio/mac/audio_low_latency_input_mac.cc b/media/audio/mac/audio_low_latency_input_mac.cc -index b8e4e68e9b8f6ac040939a97bdf040c3351efa13..abff176679f7dde30a65528be7e9a2568f68972a 100644 +index 7d55649a7e06637bdddf56428936ef8db5793f60..031aa47edb46243e1f6b212f3dbff5ba793e1f3a 100644 --- a/media/audio/mac/audio_low_latency_input_mac.cc +++ b/media/audio/mac/audio_low_latency_input_mac.cc @@ -33,19 +33,23 @@ diff --git a/patches/chromium/mas-cgdisplayusesforcetogray.patch b/patches/chromium/mas-cgdisplayusesforcetogray.patch index 574949c324785..a8b7019128c9e 100644 --- a/patches/chromium/mas-cgdisplayusesforcetogray.patch +++ b/patches/chromium/mas-cgdisplayusesforcetogray.patch @@ -6,10 +6,10 @@ Subject: mas-cgdisplayusesforcetogray.patch Removes usage of the CGDisplayUsesForceToGray private API. diff --git a/ui/display/mac/screen_mac.mm b/ui/display/mac/screen_mac.mm -index 4d5b83a1a4b0c1d03378ab1aae8ef43935c387d3..463ff7105ac329cafed793fd87cfc8423e0a0ed7 100644 +index 170963e32063b82f789692652092501fb2b1bc48..4e0a2cb6991cafa96c1e2077f38ef315544890fc 100644 --- a/ui/display/mac/screen_mac.mm +++ b/ui/display/mac/screen_mac.mm -@@ -107,7 +107,17 @@ Display BuildDisplayForScreen(NSScreen* screen) { +@@ -108,7 +108,17 @@ Display BuildDisplayForScreen(NSScreen* screen) { display.set_color_depth(NSBitsPerPixelFromDepth([screen depth])); display.set_depth_per_component(NSBitsPerSampleFromDepth([screen depth])); @@ -25,5 +25,5 @@ index 4d5b83a1a4b0c1d03378ab1aae8ef43935c387d3..463ff7105ac329cafed793fd87cfc842 display.set_is_monochrome(CGDisplayUsesForceToGray()); +#endif - // CGDisplayRotation returns a double. Display::SetRotationAsDegree will - // handle the unexpected situations were the angle is not a multiple of 90. + if (auto display_link = ui::DisplayLinkMac::GetForDisplay(display_id)) + display.set_display_frequency(display_link->GetRefreshRate()); diff --git a/patches/chromium/mas-lssetapplicationlaunchservicesserverconnectionstatus.patch b/patches/chromium/mas-lssetapplicationlaunchservicesserverconnectionstatus.patch index 04cbeb23f7ee4..5eda96b71afe1 100644 --- a/patches/chromium/mas-lssetapplicationlaunchservicesserverconnectionstatus.patch +++ b/patches/chromium/mas-lssetapplicationlaunchservicesserverconnectionstatus.patch @@ -7,10 +7,10 @@ Removes usage of the _LSSetApplicationLaunchServicesServerConnectionStatus private API. diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc -index f0d320c6772acb67752a997f507c96844e3549b8..82f0c4f62be2f210db2c3ed1169c2a816c59cf1f 100644 +index 35be2f60e8377708a25d1f62b7998311822fda2b..ad0d612eb6b87cb320047ebaaff5220f46d8fb8c 100644 --- a/content/gpu/gpu_main.cc +++ b/content/gpu/gpu_main.cc -@@ -283,8 +283,10 @@ int GpuMain(const MainFunctionParams& parameters) { +@@ -285,8 +285,10 @@ int GpuMain(const MainFunctionParams& parameters) { std::make_unique( base::MessagePump::Type::NS_RUNLOOP); diff --git a/patches/chromium/mas_no_private_api.patch b/patches/chromium/mas_no_private_api.patch index d997edc17a504..e0c6dc08b3583 100644 --- a/patches/chromium/mas_no_private_api.patch +++ b/patches/chromium/mas_no_private_api.patch @@ -38,7 +38,7 @@ index 743d1364bcd13e24ecbe5ced730161d15b8c3e93..a7e81072194c00baa0aa3159a6bfe374 // is concerned. @property(nonatomic, readonly) NSString* subrole; diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm -index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5e04e6d29 100644 +index 981ee74eff92781f9ee2fc95269b13abf128618d..64e5999195c88847f169bf5d8bc5d21782a0f5af 100644 --- a/content/browser/accessibility/browser_accessibility_cocoa.mm +++ b/content/browser/accessibility/browser_accessibility_cocoa.mm @@ -141,6 +141,7 @@ @@ -49,15 +49,15 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 extern "C" { // The following are private accessibility APIs required for cursor navigation -@@ -346,6 +347,7 @@ void AddMisspelledTextAttributes( - AddMisspelledTextAttributes(text_only_objects, attributed_text); - return [attributed_text attributedSubstringFromRange:range]; +@@ -323,6 +324,7 @@ void AddMisspelledTextAttributes( + AddMisspelledTextAttributes(anchor_ranges, attributed_text); + return attributed_text; } +#endif // Returns an autoreleased copy of the AXNodeData's attribute. NSString* NSStringForStringAttribute(BrowserAccessibility* browserAccessibility, -@@ -613,7 +615,9 @@ + (void)initialize { +@@ -590,7 +592,9 @@ + (void)initialize { {NSAccessibilityEditableAncestorAttribute, @"editableAncestor"}, {NSAccessibilityElementBusyAttribute, @"elementBusy"}, {NSAccessibilityEnabledAttribute, @"enabled"}, @@ -67,7 +67,7 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 {NSAccessibilityExpandedAttribute, @"expanded"}, {NSAccessibilityFocusableAncestorAttribute, @"focusableAncestor"}, {NSAccessibilityFocusedAttribute, @"focused"}, -@@ -648,13 +652,17 @@ + (void)initialize { +@@ -625,13 +629,17 @@ + (void)initialize { {NSAccessibilityRowsAttribute, @"rows"}, // TODO(aboxhall): expose // NSAccessibilityServesAsTitleForUIElementsAttribute @@ -85,7 +85,7 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 {NSAccessibilitySizeAttribute, @"size"}, {NSAccessibilitySortDirectionAttribute, @"sortDirection"}, {NSAccessibilitySubroleAttribute, @"subrole"}, -@@ -1145,6 +1153,7 @@ - (NSNumber*)enabled { +@@ -1129,6 +1137,7 @@ - (NSNumber*)enabled { ax::mojom::Restriction::kDisabled]; } @@ -93,7 +93,7 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 // Returns a text marker that points to the last character in the document that // can be selected with VoiceOver. - (id)endTextMarker { -@@ -1155,6 +1164,7 @@ - (id)endTextMarker { +@@ -1139,6 +1148,7 @@ - (id)endTextMarker { BrowserAccessibilityPositionInstance position = root->CreatePositionAt(0); return CreateTextMarker(position->CreatePositionAtEndOfAnchor()); } @@ -101,7 +101,7 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 - (NSNumber*)expanded { if (![self instanceActive]) -@@ -2033,6 +2043,7 @@ - (NSValue*)selectedTextRange { +@@ -2011,6 +2021,7 @@ - (NSValue*)selectedTextRange { return [NSValue valueWithRange:NSMakeRange(selStart, selLength)]; } @@ -109,7 +109,7 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 - (id)selectedTextMarkerRange { if (![self instanceActive]) return nil; -@@ -2065,6 +2076,7 @@ - (id)selectedTextMarkerRange { +@@ -2043,6 +2054,7 @@ - (id)selectedTextMarkerRange { anchorAffinity, *focusObject, focusOffset, focusAffinity)); } @@ -117,7 +117,7 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 - (NSValue*)size { if (![self instanceActive]) -@@ -2097,6 +2109,7 @@ - (NSString*)sortDirection { +@@ -2075,6 +2087,7 @@ - (NSString*)sortDirection { return nil; } @@ -125,7 +125,7 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 // Returns a text marker that points to the first character in the document that // can be selected with VoiceOver. - (id)startTextMarker { -@@ -2107,6 +2120,7 @@ - (id)startTextMarker { +@@ -2085,6 +2098,7 @@ - (id)startTextMarker { BrowserAccessibilityPositionInstance position = root->CreatePositionAt(0); return CreateTextMarker(position->CreatePositionAtStartOfAnchor()); } @@ -133,22 +133,23 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 // Returns a subrole based upon the role. - (NSString*)subrole { -@@ -2407,12 +2421,14 @@ - (NSAttributedString*)attributedValueForRange:(NSRange)range { +@@ -2388,6 +2402,7 @@ - (NSAttributedString*)attributedValueForRange:(NSRange)range { NSMutableAttributedString* attributedValue = [[[NSMutableAttributedString alloc] initWithString:value] autorelease]; +#ifndef MAS_BUILD if (!owner_->IsTextOnlyObject()) { - std::vector textOnlyObjects = - BrowserAccessibilityManager::FindTextOnlyObjectsInRange(*owner_, - *owner_); - AddMisspelledTextAttributes(textOnlyObjects, attributedValue); + const std::vector anchorRanges = + AXPlatformRange(owner_->CreatePositionAt(0), +@@ -2395,6 +2410,7 @@ - (NSAttributedString*)attributedValueForRange:(NSRange)range { + .GetAnchors(); + AddMisspelledTextAttributes(anchorRanges, attributedValue); } +#endif return [attributedValue attributedSubstringFromRange:range]; } -@@ -2495,6 +2511,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute +@@ -2477,6 +2493,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute return ToBrowserAccessibilityCocoa(cell); } @@ -156,7 +157,7 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 if ([attribute isEqualToString:@"AXUIElementForTextMarker"]) { BrowserAccessibilityPositionInstance position = CreatePositionFromTextMarker(parameter); -@@ -2672,6 +2689,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute +@@ -2654,6 +2671,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute NSString* text = GetTextForTextMarkerRange(parameter); return [NSNumber numberWithInt:[text length]]; } @@ -164,7 +165,7 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 if ([attribute isEqualToString: NSAccessibilityBoundsForRangeParameterizedAttribute]) { -@@ -2705,6 +2723,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute +@@ -2687,6 +2705,7 @@ - (id)accessibilityAttributeValue:(NSString*)attribute return nil; } @@ -172,7 +173,7 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 if ([attribute isEqualToString: NSAccessibilityLineTextMarkerRangeForTextMarkerParameterizedAttribute]) { -@@ -2785,6 +2804,7 @@ AXPlatformRange range(position->CreatePreviousLineStartPosition( +@@ -2767,6 +2786,7 @@ AXPlatformRange range(position->CreatePreviousLineStartPosition( return @(child->GetIndexInParent()); } @@ -181,10 +182,10 @@ index 237b07caa5ed7626c3b5b538cbb77f582f884203..cc4cb1ce9308ba8aecd6cc138954a1b5 return nil; } diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.mm b/content/browser/accessibility/browser_accessibility_manager_mac.mm -index e02f5f922ea0eeca39fdf0acc265e1ef9dc254a6..764cac3182c3611e2c1fc4a0aa73b13ac81a9a72 100644 +index ff366b2691c6d72e196b20f224ef0c77f932c301..80de4d4127c723655c0ed62700fdf6e22019815f 100644 --- a/content/browser/accessibility/browser_accessibility_manager_mac.mm +++ b/content/browser/accessibility/browser_accessibility_manager_mac.mm -@@ -491,6 +491,7 @@ void PostAnnouncementNotification(NSString* announcement) { +@@ -492,6 +492,7 @@ void PostAnnouncementNotification(NSString* announcement) { [user_info setObject:native_focus_object forKey:NSAccessibilityTextChangeElement]; @@ -192,7 +193,7 @@ index e02f5f922ea0eeca39fdf0acc265e1ef9dc254a6..764cac3182c3611e2c1fc4a0aa73b13a id selected_text = [native_focus_object selectedTextMarkerRange]; if (selected_text) { NSString* const NSAccessibilitySelectedTextMarkerRangeAttribute = -@@ -498,6 +499,7 @@ void PostAnnouncementNotification(NSString* announcement) { +@@ -499,6 +500,7 @@ void PostAnnouncementNotification(NSString* announcement) { [user_info setObject:selected_text forKey:NSAccessibilitySelectedTextMarkerRangeAttribute]; } @@ -233,7 +234,7 @@ index e59ac93d0e1554a2df5d8c74db2beba25d090228..6657c48664bdec4964b382f80309d1bf } // namespace diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm -index fcf50dc3bd9a94536d7fc457c4e7b413a83dc672..6252cb195ff77aa31295c4958fd6b80c8a0df8bd 100644 +index b6bea74d9f9c2fcfba381477895e4c15741318fc..4a02e5659e85c507d480d7fb9b63ee10bad1fe85 100644 --- a/device/bluetooth/bluetooth_adapter_mac.mm +++ b/device/bluetooth/bluetooth_adapter_mac.mm @@ -36,6 +36,7 @@ @@ -263,7 +264,7 @@ index fcf50dc3bd9a94536d7fc457c4e7b413a83dc672..6252cb195ff77aa31295c4958fd6b80c should_update_name_(true), classic_discovery_manager_( BluetoothDiscoveryManagerMac::CreateClassic(this)), -@@ -319,8 +323,12 @@ CBCentralManagerState GetCBManagerState(CBCentralManager* manager) { +@@ -303,8 +307,12 @@ CBCentralManagerState GetCBManagerState(CBCentralManager* manager) { } bool BluetoothAdapterMac::SetPoweredImpl(bool powered) { @@ -294,7 +295,7 @@ index cb7a5305c2d6cbe7b3aa13efdfe6dcc6dfd857e9..e3f3ee7fee0a8f9cf7b3c1b6bed7c2a6 "AudioToolbox.framework", "AudioUnit.framework", diff --git a/media/audio/mac/audio_manager_mac.cc b/media/audio/mac/audio_manager_mac.cc -index a9d6babb03ca318ccd15b254d3785a9ad45698c0..34ba3bfb738226ed8b53a9c24d15af5a5176642f 100644 +index 7ec6dab821b542cb0096e7f8875ba21703463087..3e26c9dd0a296b8d9c99ca1ee9d9faba14e8d618 100644 --- a/media/audio/mac/audio_manager_mac.cc +++ b/media/audio/mac/audio_manager_mac.cc @@ -882,7 +882,7 @@ AudioParameters AudioManagerMac::GetPreferredOutputStreamParameters( @@ -307,7 +308,7 @@ index a9d6babb03ca318ccd15b254d3785a9ad45698c0..34ba3bfb738226ed8b53a9c24d15af5a } diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc -index 48ee9253d64faba7c1b9a0e77deac05dc149b874..cebc6f40070ff720eaff7013c9c58767c88cdaff 100644 +index 21852feee1ae251f7c0693d26ca4e23ebaa2739c..acaf99c718895bae548b2e4960aa96cfc8dc3494 100644 --- a/net/dns/dns_config_service_posix.cc +++ b/net/dns/dns_config_service_posix.cc @@ -245,6 +245,7 @@ class DnsConfigServicePosix::Watcher { diff --git a/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch b/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch index ddeb623ebedae..c1ba100379d93 100644 --- a/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch +++ b/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch @@ -5,10 +5,10 @@ Subject: network service: allow remote certificate verification logic diff --git a/services/network/network_context.cc b/services/network/network_context.cc -index 5d871fc08218b71c93141963db66465f775b1bc2..97128a6b6223e7fb977b5c9f20bf18da26c8348d 100644 +index 4689fe5c142b7d975fa94f1edb2f00f33201f0b9..6ca068087123a9b8150864ee2b3a4d39bfef007b 100644 --- a/services/network/network_context.cc +++ b/services/network/network_context.cc -@@ -89,6 +89,11 @@ +@@ -91,6 +91,11 @@ #include "services/network/url_loader.h" #include "services/network/url_request_context_builder_mojo.h" @@ -20,7 +20,7 @@ index 5d871fc08218b71c93141963db66465f775b1bc2..97128a6b6223e7fb977b5c9f20bf18da #if BUILDFLAG(IS_CT_SUPPORTED) #include "components/certificate_transparency/chrome_ct_policy_enforcer.h" #include "components/certificate_transparency/chrome_require_ct_delegate.h" -@@ -310,6 +315,75 @@ std::string HashesToBase64String(const net::HashValueVector& hashes) { +@@ -316,6 +321,75 @@ std::string HashesToBase64String(const net::HashValueVector& hashes) { } // namespace @@ -96,7 +96,7 @@ index 5d871fc08218b71c93141963db66465f775b1bc2..97128a6b6223e7fb977b5c9f20bf18da constexpr uint32_t NetworkContext::kMaxOutstandingRequestsPerProcess; constexpr bool NetworkContext::enable_resource_scheduler_; -@@ -668,6 +742,12 @@ void NetworkContext::SetClient(mojom::NetworkContextClientPtr client) { +@@ -676,6 +750,12 @@ void NetworkContext::SetClient(mojom::NetworkContextClientPtr client) { client_ = std::move(client); } @@ -109,7 +109,7 @@ index 5d871fc08218b71c93141963db66465f775b1bc2..97128a6b6223e7fb977b5c9f20bf18da void NetworkContext::CreateURLLoaderFactory( mojom::URLLoaderFactoryRequest request, mojom::URLLoaderFactoryParamsPtr params) { -@@ -2130,12 +2210,19 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext() { +@@ -2137,12 +2217,19 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext() { net::CreateCertVerifyProcBuiltin(cert_net_fetcher_))); } #endif @@ -134,7 +134,7 @@ index 5d871fc08218b71c93141963db66465f775b1bc2..97128a6b6223e7fb977b5c9f20bf18da std::unique_ptr network_delegate = std::make_unique(this); diff --git a/services/network/network_context.h b/services/network/network_context.h -index 0f9e0fe5922c228d96ba7d8668a88d5d31c516e9..9552cfa88d2a45aa6bff24c3e89d080c8aad98a0 100644 +index 704a2401fd2a0b408deee82d1f01827fe41d2db2..58235aea3a520a6e5dd377b9c7080fa0304ebc0b 100644 --- a/services/network/network_context.h +++ b/services/network/network_context.h @@ -74,6 +74,7 @@ class DomainReliabilityMonitor; @@ -153,7 +153,7 @@ index 0f9e0fe5922c228d96ba7d8668a88d5d31c516e9..9552cfa88d2a45aa6bff24c3e89d080c void CreateURLLoaderFactory(mojom::URLLoaderFactoryRequest request, mojom::URLLoaderFactoryParamsPtr params) override; void ResetURLLoaderFactories() override; -@@ -561,6 +563,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext +@@ -556,6 +558,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext std::unique_ptr nss_temp_certs_cache_; #endif @@ -163,10 +163,10 @@ index 0f9e0fe5922c228d96ba7d8668a88d5d31c516e9..9552cfa88d2a45aa6bff24c3e89d080c // CertNetFetcher is not used by the current platform. scoped_refptr cert_net_fetcher_; diff --git a/services/network/public/mojom/network_context.mojom b/services/network/public/mojom/network_context.mojom -index 69885a8bc0e2219ed6c10e684db0ad7d5cd6b87e..bf0750e75e357275f5a569cc8e0680b606b544f6 100644 +index d41870d77155a95f34ca125daaf71bb5f820f3de..5e8acb5e7fb83408d58a59bb755c209133644ab3 100644 --- a/services/network/public/mojom/network_context.mojom +++ b/services/network/public/mojom/network_context.mojom -@@ -160,6 +160,17 @@ interface TrustedURLLoaderHeaderClient { +@@ -161,6 +161,17 @@ interface TrustedURLLoaderHeaderClient { OnLoaderCreated(int32 request_id, TrustedHeaderClient& header_client); }; @@ -184,7 +184,7 @@ index 69885a8bc0e2219ed6c10e684db0ad7d5cd6b87e..bf0750e75e357275f5a569cc8e0680b6 // Parameters for constructing a network context. struct NetworkContextParams { // Name used by memory tools to identify the context. -@@ -541,6 +552,9 @@ interface NetworkContext { +@@ -560,6 +571,9 @@ interface NetworkContext { // Sets a client for this network context. SetClient(NetworkContextClient client); diff --git a/patches/chromium/no_cache_storage_check.patch b/patches/chromium/no_cache_storage_check.patch index a43307d13eef7..f1f97eafcc0e1 100644 --- a/patches/chromium/no_cache_storage_check.patch +++ b/patches/chromium/no_cache_storage_check.patch @@ -7,10 +7,10 @@ Do not check for unique origin in CacheStorage, in Electron we may have scripts running without an origin. diff --git a/content/browser/cache_storage/legacy/legacy_cache_storage.cc b/content/browser/cache_storage/legacy/legacy_cache_storage.cc -index f91df0d1bc58bdc7244c6b248844f2bd51c90fa3..d1935f5a7bc189e9621e83a02c4cf4d1bf72ab60 100644 +index b085b463b104849ea98d0dc306ff6bae24710be5..265b8bf187f5adead105aed86d059ddeff27c4e7 100644 --- a/content/browser/cache_storage/legacy/legacy_cache_storage.cc +++ b/content/browser/cache_storage/legacy/legacy_cache_storage.cc -@@ -106,7 +106,7 @@ class LegacyCacheStorage::CacheLoader { +@@ -104,7 +104,7 @@ class LegacyCacheStorage::CacheLoader { cache_storage_(cache_storage), origin_(origin), owner_(owner) { diff --git a/patches/chromium/notification_provenance.patch b/patches/chromium/notification_provenance.patch index b47bd9300d51f..167fcd9ad414f 100644 --- a/patches/chromium/notification_provenance.patch +++ b/patches/chromium/notification_provenance.patch @@ -109,10 +109,10 @@ index f1710b69a91931021ba56db544fce551fad52f46..b116b89114a431f8e67a68e7f7cc1c65 // Removes |service| from the list of owned services, for example because the diff --git a/content/browser/renderer_interface_binders.cc b/content/browser/renderer_interface_binders.cc -index 3f0c06be2d9afcc02b326097fd99d27434635909..dea30a859da0e00f44d95642a2f469d3aabd2f45 100644 +index 32e5aa4e90083a5b08f69433b93c97c25835209f..2b1674066136b1155c6d58c62e4c7c91c8960f35 100644 --- a/content/browser/renderer_interface_binders.cc +++ b/content/browser/renderer_interface_binders.cc -@@ -197,7 +197,7 @@ void RendererInterfaceBinders::InitializeParameterizedBinderRegistry() { +@@ -198,7 +198,7 @@ void RendererInterfaceBinders::InitializeParameterizedBinderRegistry() { RenderProcessHost* host, const url::Origin& origin) { static_cast(host->GetStoragePartition()) ->GetPlatformNotificationContext() diff --git a/patches/chromium/out_of_process_instance.patch b/patches/chromium/out_of_process_instance.patch index 806987076bf4b..a5e47a553f87b 100644 --- a/patches/chromium/out_of_process_instance.patch +++ b/patches/chromium/out_of_process_instance.patch @@ -5,10 +5,10 @@ Subject: out_of_process_instance.patch diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc -index a33c3391d05bd7cc2346906961baab39d088ca6e..1b8f587dda2f77374b4b01df22a11a03692a3afd 100644 +index 5caf9abe451504ebf4f2cd9b770af188534f13d7..37cc07c74cd046d67ac53891dcf3c7003300549b 100644 --- a/pdf/out_of_process_instance.cc +++ b/pdf/out_of_process_instance.cc -@@ -472,7 +472,9 @@ bool OutOfProcessInstance::Init(uint32_t argc, +@@ -471,7 +471,9 @@ bool OutOfProcessInstance::Init(uint32_t argc, std::string document_url = document_url_var.AsString(); base::StringPiece document_url_piece(document_url); is_print_preview_ = IsPrintPreviewUrl(document_url_piece); diff --git a/patches/chromium/pepper_flash.patch b/patches/chromium/pepper_flash.patch index 516c7efb78152..ec8b25a5027a4 100644 --- a/patches/chromium/pepper_flash.patch +++ b/patches/chromium/pepper_flash.patch @@ -61,7 +61,7 @@ index 83cedb4c9e1323259afd041e571240cd971e1241..3686ae2fab5f400cf119a54aea547a72 + return PP_OK; } diff --git a/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc b/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc -index 9d249be9345202f1022f550f73cb8bdd1b327c56..e63ca22a2ebe3f380f6d06ac4f1b1eb8e5ff7e53 100644 +index 016007f0edad06739a8ad1f9874d5dd5d49e0780..c4ae6ae33d552952e2277255015396cd758344aa 100644 --- a/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc +++ b/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc @@ -8,9 +8,11 @@ @@ -76,7 +76,7 @@ index 9d249be9345202f1022f550f73cb8bdd1b327c56..e63ca22a2ebe3f380f6d06ac4f1b1eb8 #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_ppapi_host.h" #include "content/public/browser/browser_task_traits.h" -@@ -43,6 +45,7 @@ using content::ServiceManagerConnection; +@@ -42,6 +44,7 @@ using content::RenderProcessHost; namespace { @@ -84,7 +84,7 @@ index 9d249be9345202f1022f550f73cb8bdd1b327c56..e63ca22a2ebe3f380f6d06ac4f1b1eb8 // Get the CookieSettings on the UI thread for the given render process ID. scoped_refptr GetCookieSettings( int render_process_id) { -@@ -56,6 +59,7 @@ scoped_refptr GetCookieSettings( +@@ -55,6 +58,7 @@ scoped_refptr GetCookieSettings( } return NULL; } @@ -92,7 +92,7 @@ index 9d249be9345202f1022f550f73cb8bdd1b327c56..e63ca22a2ebe3f380f6d06ac4f1b1eb8 void PepperBindConnectorRequest( service_manager::mojom::ConnectorRequest connector_request) { -@@ -73,7 +77,9 @@ PepperFlashBrowserHost::PepperFlashBrowserHost(BrowserPpapiHost* host, +@@ -70,7 +74,9 @@ PepperFlashBrowserHost::PepperFlashBrowserHost(BrowserPpapiHost* host, PP_Instance instance, PP_Resource resource) : ResourceHost(host->GetPpapiHost(), instance, resource), @@ -102,7 +102,7 @@ index 9d249be9345202f1022f550f73cb8bdd1b327c56..e63ca22a2ebe3f380f6d06ac4f1b1eb8 delay_timer_(FROM_HERE, base::TimeDelta::FromSeconds(45), this, &PepperFlashBrowserHost::OnDelayTimerFired), weak_factory_(this) { -@@ -125,6 +131,7 @@ int32_t PepperFlashBrowserHost::OnGetLocalTimeZoneOffset( +@@ -122,6 +128,7 @@ int32_t PepperFlashBrowserHost::OnGetLocalTimeZoneOffset( int32_t PepperFlashBrowserHost::OnGetLocalDataRestrictions( ppapi::host::HostMessageContext* context) { @@ -110,7 +110,7 @@ index 9d249be9345202f1022f550f73cb8bdd1b327c56..e63ca22a2ebe3f380f6d06ac4f1b1eb8 // Getting the Flash LSO settings requires using the CookieSettings which // belong to the profile which lives on the UI thread. We lazily initialize // |cookie_settings_| by grabbing the reference from the UI thread and then -@@ -145,9 +152,11 @@ int32_t PepperFlashBrowserHost::OnGetLocalDataRestrictions( +@@ -142,9 +149,11 @@ int32_t PepperFlashBrowserHost::OnGetLocalDataRestrictions( context->MakeReplyMessageContext(), document_url, plugin_url)); } @@ -123,7 +123,7 @@ index 9d249be9345202f1022f550f73cb8bdd1b327c56..e63ca22a2ebe3f380f6d06ac4f1b1eb8 void PepperFlashBrowserHost::GetLocalDataRestrictions( ppapi::host::ReplyMessageContext reply_context, const GURL& document_url, -@@ -176,6 +185,7 @@ void PepperFlashBrowserHost::GetLocalDataRestrictions( +@@ -173,6 +182,7 @@ void PepperFlashBrowserHost::GetLocalDataRestrictions( PpapiPluginMsg_Flash_GetLocalDataRestrictionsReply( static_cast(restrictions))); } diff --git a/patches/chromium/printing.patch b/patches/chromium/printing.patch index 1e8d5fa83bbd7..8baf8f02b8721 100644 --- a/patches/chromium/printing.patch +++ b/patches/chromium/printing.patch @@ -46,7 +46,7 @@ index 88a6142eea4c7a219c08fe3463c44711f5c9fada..81db315a0036a123658697aa677e2356 void PrintJobWorker::GetSettingsWithUI(int document_page_count, diff --git a/chrome/browser/printing/print_view_manager_base.cc b/chrome/browser/printing/print_view_manager_base.cc -index 7ba43aada1ac44827cca264d6f37814e4a91f458..1ca9fe408ec9a5129f6cec46daeeee46bab60983 100644 +index a8502fdff8d39b7215f92a393a66d096bd302e25..38f213b0f6d6872d08981d265105cd4fbb2bb75c 100644 --- a/chrome/browser/printing/print_view_manager_base.cc +++ b/chrome/browser/printing/print_view_manager_base.cc @@ -27,10 +27,7 @@ @@ -68,8 +68,8 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..1ca9fe408ec9a5129f6cec46daeeee46 #include "mojo/public/cpp/system/buffer.h" #include "printing/buildflags/buildflags.h" #include "printing/metafile_skia.h" -@@ -64,6 +64,8 @@ using PrintSettingsCallback = - base::OnceCallback)>; +@@ -64,6 +62,8 @@ using PrintSettingsCallback = + base::OnceCallback)>; void ShowWarningMessageBox(const base::string16& message) { + LOG(ERROR) << "Invalid printer settings " << message; @@ -77,30 +77,30 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..1ca9fe408ec9a5129f6cec46daeeee46 // Runs always on the UI thread. static bool is_dialog_shown = false; if (is_dialog_shown) -@@ -72,6 +74,7 @@ void ShowWarningMessageBox(const base::string16& message) { +@@ -72,6 +72,7 @@ void ShowWarningMessageBox(const base::string16& message) { base::AutoReset auto_reset(&is_dialog_shown, true); chrome::ShowWarningMessageBox(nullptr, base::string16(), message); -+ #endif ++#endif } #if BUILDFLAG(ENABLE_PRINT_PREVIEW) -@@ -109,12 +112,14 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents) +@@ -111,12 +112,14 @@ PrintViewManagerBase::PrintViewManagerBase(content::WebContents* web_contents) queue_(g_browser_process->print_job_manager()->queue()), weak_ptr_factory_(this) { DCHECK(queue_); -+ #if 0 ++#if 0 Profile* profile = Profile::FromBrowserContext(web_contents->GetBrowserContext()); printing_enabled_.Init( prefs::kPrintingEnabled, profile->GetPrefs(), - base::Bind(&PrintViewManagerBase::UpdatePrintingEnabled, - weak_ptr_factory_.GetWeakPtr())); -+ #endif + base::BindRepeating(&PrintViewManagerBase::UpdatePrintingEnabled, + weak_ptr_factory_.GetWeakPtr())); ++#endif } PrintViewManagerBase::~PrintViewManagerBase() { -@@ -122,12 +127,14 @@ PrintViewManagerBase::~PrintViewManagerBase() { +@@ -124,12 +127,14 @@ PrintViewManagerBase::~PrintViewManagerBase() { DisconnectFromCurrentPrintJob(); } @@ -118,7 +118,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..1ca9fe408ec9a5129f6cec46daeeee46 } #if BUILDFLAG(ENABLE_PRINT_PREVIEW) -@@ -242,9 +249,9 @@ void PrintViewManagerBase::StartLocalPrintJob( +@@ -245,9 +250,9 @@ void PrintViewManagerBase::StartLocalPrintJob( void PrintViewManagerBase::UpdatePrintingEnabled() { DCHECK_CURRENTLY_ON(content::BrowserThread::UI); // The Unretained() is safe because ForEachFrame() is synchronous. @@ -131,7 +131,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..1ca9fe408ec9a5129f6cec46daeeee46 } void PrintViewManagerBase::NavigationStopped() { -@@ -336,7 +343,7 @@ void PrintViewManagerBase::OnPrintingFailed(int cookie) { +@@ -339,7 +344,7 @@ void PrintViewManagerBase::OnPrintingFailed(int cookie) { PrintManager::OnPrintingFailed(cookie); #if BUILDFLAG(ENABLE_PRINT_PREVIEW) @@ -140,7 +140,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..1ca9fe408ec9a5129f6cec46daeeee46 #endif ReleasePrinterQuery(); -@@ -436,9 +443,13 @@ void PrintViewManagerBase::OnNotifyPrintJobEvent( +@@ -439,9 +444,13 @@ void PrintViewManagerBase::OnNotifyPrintJobEvent( content::NotificationService::NoDetails()); break; } @@ -156,26 +156,25 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..1ca9fe408ec9a5129f6cec46daeeee46 NOTREACHED(); break; } -@@ -532,9 +543,6 @@ bool PrintViewManagerBase::CreateNewPrintJob(PrinterQuery* query) { +@@ -536,8 +545,6 @@ bool PrintViewManagerBase::CreateNewPrintJob( DCHECK(!quit_inner_loop_); DCHECK(query); - // Disconnect the current |print_job_|. - DisconnectFromCurrentPrintJob(); -- + // We can't print if there is no renderer. if (!web_contents()->GetRenderViewHost() || - !web_contents()->GetRenderViewHost()->IsRenderViewLive()) { -@@ -544,8 +552,6 @@ bool PrintViewManagerBase::CreateNewPrintJob(PrinterQuery* query) { +@@ -548,8 +555,6 @@ bool PrintViewManagerBase::CreateNewPrintJob( DCHECK(!print_job_); print_job_ = base::MakeRefCounted(); - print_job_->Initialize(query, RenderSourceName(), number_pages_); + print_job_->Initialize(std::move(query), RenderSourceName(), number_pages_); - registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, - content::Source(print_job_.get())); printing_succeeded_ = false; return true; } -@@ -594,6 +600,13 @@ void PrintViewManagerBase::ReleasePrintJob() { +@@ -598,6 +603,13 @@ void PrintViewManagerBase::ReleasePrintJob() { content::RenderFrameHost* rfh = printing_rfh_; printing_rfh_ = nullptr; @@ -189,7 +188,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..1ca9fe408ec9a5129f6cec46daeeee46 if (!print_job_) return; -@@ -604,7 +620,7 @@ void PrintViewManagerBase::ReleasePrintJob() { +@@ -608,7 +620,7 @@ void PrintViewManagerBase::ReleasePrintJob() { } registrar_.Remove(this, chrome::NOTIFICATION_PRINT_JOB_EVENT, @@ -198,7 +197,7 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..1ca9fe408ec9a5129f6cec46daeeee46 // Don't close the worker thread. print_job_ = nullptr; } -@@ -674,6 +690,9 @@ bool PrintViewManagerBase::PrintNowInternal( +@@ -678,6 +690,9 @@ bool PrintViewManagerBase::PrintNowInternal( // Don't print / print preview interstitials or crashed tabs. if (web_contents()->ShowingInterstitialPage() || web_contents()->IsCrashed()) return false; @@ -209,10 +208,10 @@ index 7ba43aada1ac44827cca264d6f37814e4a91f458..1ca9fe408ec9a5129f6cec46daeeee46 } diff --git a/chrome/browser/printing/print_view_manager_base.h b/chrome/browser/printing/print_view_manager_base.h -index cf074791d0e2e17bbf8cf0b000b8d63e235b7deb..30b6e042b12f23299b3b7eaecb8a8e71c221786d 100644 +index f3e23125001c0eebebdb2e211d069cd3feb523d8..345b1925a7b29152206c6784a2a56f4b96bb89ab 100644 --- a/chrome/browser/printing/print_view_manager_base.h +++ b/chrome/browser/printing/print_view_manager_base.h -@@ -39,6 +40,8 @@ class PrintJob; +@@ -39,6 +39,8 @@ class PrintJob; class PrintQueriesQueue; class PrinterQuery; @@ -221,7 +220,7 @@ index cf074791d0e2e17bbf8cf0b000b8d63e235b7deb..30b6e042b12f23299b3b7eaecb8a8e71 // Base class for managing the print commands for a WebContents. class PrintViewManagerBase : public content::NotificationObserver, public PrintManager { -@@ -48,7 +51,9 @@ class PrintViewManagerBase : public content::NotificationObserver, +@@ -48,7 +50,9 @@ class PrintViewManagerBase : public content::NotificationObserver, // Prints the current document immediately. Since the rendering is // asynchronous, the actual printing will not be completed on the return of // this function. Returns false if printing is impossible at the moment. @@ -232,7 +231,7 @@ index cf074791d0e2e17bbf8cf0b000b8d63e235b7deb..30b6e042b12f23299b3b7eaecb8a8e71 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) // Prints the document in |print_data| with settings specified in -@@ -195,9 +200,15 @@ class PrintViewManagerBase : public content::NotificationObserver, +@@ -195,9 +199,15 @@ class PrintViewManagerBase : public content::NotificationObserver, // The current RFH that is printing with a system printing dialog. content::RenderFrameHost* printing_rfh_; @@ -249,7 +248,7 @@ index cf074791d0e2e17bbf8cf0b000b8d63e235b7deb..30b6e042b12f23299b3b7eaecb8a8e71 // This means we are _blocking_ until all the necessary pages have been // rendered or the print settings are being loaded. diff --git a/chrome/browser/printing/printing_message_filter.cc b/chrome/browser/printing/printing_message_filter.cc -index 1f79e7b127f35e2eaef923af5c4a5f0a7e5250a5..327b37dfbb84c60d7f0e339c3c4cb8ca3b3c9b26 100644 +index 706617b7924cfbf25e4f3a04a40d9ee977e6fd69..6e3c3743e5da782e227e1ec3dba83ed7b401f3de 100644 --- a/chrome/browser/printing/printing_message_filter.cc +++ b/chrome/browser/printing/printing_message_filter.cc @@ -21,6 +21,7 @@ @@ -281,40 +280,40 @@ index 1f79e7b127f35e2eaef923af5c4a5f0a7e5250a5..327b37dfbb84c60d7f0e339c3c4cb8ca base::Unretained(this))); + #if 0 is_printing_enabled_.Init(prefs::kPrintingEnabled, profile->GetPrefs()); - is_printing_enabled_.MoveToThread( + is_printing_enabled_.MoveToSequence( base::CreateSingleThreadTaskRunnerWithTraits({BrowserThread::IO})); + #endif } PrintingMessageFilter::~PrintingMessageFilter() { -@@ -138,11 +142,13 @@ bool PrintingMessageFilter::OnMessageReceived(const IPC::Message& message) { +@@ -137,11 +141,13 @@ bool PrintingMessageFilter::OnMessageReceived(const IPC::Message& message) { + void PrintingMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) { DCHECK_CURRENTLY_ON(BrowserThread::IO); - scoped_refptr printer_query; -+ #if 0 ++#if 0 if (!is_printing_enabled_.GetValue()) { // Reply with NULL query. - OnGetDefaultPrintSettingsReply(printer_query, reply_msg); + OnGetDefaultPrintSettingsReply(nullptr, reply_msg); return; } -+ #endif - printer_query = queue_->PopPrinterQuery(0); - if (!printer_query.get()) { ++#endif + std::unique_ptr printer_query = queue_->PopPrinterQuery(0); + if (!printer_query) { printer_query = -@@ -228,11 +234,13 @@ void PrintingMessageFilter::OnUpdatePrintSettings(int document_cookie, +@@ -227,11 +233,13 @@ void PrintingMessageFilter::OnScriptedPrintReply( + void PrintingMessageFilter::OnUpdatePrintSettings(int document_cookie, base::Value job_settings, IPC::Message* reply_msg) { - scoped_refptr printer_query; -+ #if 0 ++#if 0 if (!is_printing_enabled_.GetValue()) { // Reply with NULL query. - OnUpdatePrintSettingsReply(printer_query, reply_msg); + OnUpdatePrintSettingsReply(nullptr, reply_msg); return; } -+ #endif - printer_query = queue_->PopPrinterQuery(document_cookie); - if (!printer_query.get()) { - printer_query = queue_->CreatePrinterQuery( ++#endif + std::unique_ptr printer_query = + queue_->PopPrinterQuery(document_cookie); + if (!printer_query) { @@ -295,7 +303,7 @@ void PrintingMessageFilter::OnUpdatePrintSettingsReply( #if BUILDFLAG(ENABLE_PRINT_PREVIEW) void PrintingMessageFilter::OnCheckForCancel(const PrintHostMsg_PreviewIds& ids, @@ -325,7 +324,7 @@ index 1f79e7b127f35e2eaef923af5c4a5f0a7e5250a5..327b37dfbb84c60d7f0e339c3c4cb8ca #endif diff --git a/chrome/browser/printing/printing_message_filter.h b/chrome/browser/printing/printing_message_filter.h -index 04b76398ebee1bc3aeaf67ecf5b32272d56d5445..1e21ecb5fb903d56c76f338225b6df6fadc933a2 100644 +index 9fbea6d0a2dbe55b1d600fbc217dee5aa8ae8cd5..de9bd267e408c02fd4da7d903523c0e6305088d5 100644 --- a/chrome/browser/printing/printing_message_filter.h +++ b/chrome/browser/printing/printing_message_filter.h @@ -24,6 +24,10 @@ struct PrintHostMsg_ScriptedPrint_Params; @@ -366,7 +365,7 @@ index 1802034a6e15a6ad8b0d9591cfb79ba5873dc982..a827091facdb4f6b1d74ce826c3492ce // Like PrintMsg_PrintPages, but using the print preview document's frame/node. IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog) diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc -index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad336dd7a9 100644 +index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5bb4ce378f 100644 --- a/components/printing/renderer/print_render_frame_helper.cc +++ b/components/printing/renderer/print_render_frame_helper.cc @@ -37,6 +37,7 @@ @@ -377,7 +376,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad #include "printing/units.h" #include "third_party/blink/public/common/frame/frame_owner_element_type.h" #include "third_party/blink/public/common/frame/sandbox_flags.h" -@@ -1115,7 +1116,9 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) { +@@ -1114,7 +1115,9 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) { web_frame->DispatchBeforePrintEvent(); if (!weak_this) return; @@ -388,7 +387,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad if (weak_this) web_frame->DispatchAfterPrintEvent(); } -@@ -1163,7 +1166,10 @@ void PrintRenderFrameHelper::OnDestruct() { +@@ -1162,7 +1165,10 @@ void PrintRenderFrameHelper::OnDestruct() { delete this; } @@ -400,7 +399,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad if (ipc_nesting_level_ > 1) return; -@@ -1176,7 +1182,8 @@ void PrintRenderFrameHelper::OnPrintPages() { +@@ -1175,7 +1181,8 @@ void PrintRenderFrameHelper::OnPrintPages() { // If we are printing a PDF extension frame, find the plugin node and print // that instead. auto plugin = delegate_->GetPdfElement(frame); @@ -410,7 +409,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad if (weak_this) frame->DispatchAfterPrintEvent(); // WARNING: |this| may be gone at this point. Do not do any more work here and -@@ -1193,7 +1200,7 @@ void PrintRenderFrameHelper::OnPrintForSystemDialog() { +@@ -1192,7 +1199,7 @@ void PrintRenderFrameHelper::OnPrintForSystemDialog() { } auto weak_this = weak_ptr_factory_.GetWeakPtr(); Print(frame, print_preview_context_.source_node(), @@ -419,7 +418,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad if (weak_this) frame->DispatchAfterPrintEvent(); // WARNING: |this| may be gone at this point. Do not do any more work here and -@@ -1229,6 +1236,8 @@ void PrintRenderFrameHelper::OnPrintPreview( +@@ -1228,6 +1235,8 @@ void PrintRenderFrameHelper::OnPrintPreview( if (ipc_nesting_level_ > 1) return; @@ -428,7 +427,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad print_preview_context_.OnPrintPreview(); UMA_HISTOGRAM_ENUMERATION("PrintPreview.PreviewEvent", -@@ -1621,7 +1630,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) { +@@ -1620,7 +1629,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) { auto self = weak_ptr_factory_.GetWeakPtr(); Print(duplicate_node.GetDocument().GetFrame(), duplicate_node, @@ -440,7 +439,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad // Check if |this| is still valid. if (!self) return; -@@ -1632,7 +1644,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) { +@@ -1631,7 +1643,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) { void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, const blink::WebNode& node, @@ -452,7 +451,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad // If still not finished with earlier print request simply ignore. if (prep_frame_view_) return; -@@ -1640,7 +1655,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, +@@ -1639,7 +1654,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, FrameReference frame_ref(frame); int expected_page_count = 0; @@ -461,7 +460,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad DidFinishPrinting(FAIL_PRINT_INIT); return; // Failed to init print page settings. } -@@ -1660,8 +1675,11 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, +@@ -1659,8 +1674,11 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, PrintMsg_PrintPages_Params print_settings; auto self = weak_ptr_factory_.GetWeakPtr(); @@ -475,7 +474,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad // Check if |this| is still valid. if (!self) return; -@@ -1671,6 +1689,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, +@@ -1670,6 +1688,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, ? blink::kWebPrintScalingOptionSourceSize : scaling_option; SetPrintPagesParams(print_settings); @@ -483,7 +482,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad if (print_settings.params.dpi.IsEmpty() || !print_settings.params.document_cookie) { DidFinishPrinting(OK); // Release resources and fail silently on failure. -@@ -1859,10 +1878,24 @@ std::vector PrintRenderFrameHelper::GetPrintedPages( +@@ -1858,10 +1877,24 @@ std::vector PrintRenderFrameHelper::GetPrintedPages( return printed_pages; } @@ -511,7 +510,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad // Check if the printer returned any settings, if the settings is empty, we // can safely assume there are no printer drivers configured. So we safely // terminate. -@@ -1882,12 +1915,14 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) { +@@ -1881,12 +1914,14 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) { return result; } @@ -531,7 +530,7 @@ index 74f26daa76a22c749007f06a7f4eeeafb8bb297b..d842180c0d69b993971b50d5a1dcf8ad Send(new PrintHostMsg_ShowInvalidPrinterSettingsError(routing_id())); return false; diff --git a/components/printing/renderer/print_render_frame_helper.h b/components/printing/renderer/print_render_frame_helper.h -index 1e2777561ba600f8c11a59c79e3e1f6a4e4e696e..b4df0b89bce2ea7bf3a6ad2f02fb3821417cbb87 100644 +index ebe927ebd50270e2a49bf43aeb8ddfcdf99c6b94..4a790772cfb6c1fa911d3fd18e665dcb7e2bd0c1 100644 --- a/components/printing/renderer/print_render_frame_helper.h +++ b/components/printing/renderer/print_render_frame_helper.h @@ -193,7 +193,9 @@ class PrintRenderFrameHelper diff --git a/patches/chromium/put_back_deleted_colors_for_autofill.patch b/patches/chromium/put_back_deleted_colors_for_autofill.patch new file mode 100644 index 0000000000000..193f1a9b4aa56 --- /dev/null +++ b/patches/chromium/put_back_deleted_colors_for_autofill.patch @@ -0,0 +1,117 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: John Kleinschmidt +Date: Thu, 20 Jun 2019 16:49:25 -0400 +Subject: put back deleted colors for autofill + +https://chromium-review.googlesource.com/c/chromium/src/+/1652925 removed colors as they are no longer +needed in chromium but our autofill implementation uses them. This patch can be removed if we refactor +our autofill implementation to work like chromium. + +diff --git a/chrome/browser/ui/libgtkui/native_theme_gtk.cc b/chrome/browser/ui/libgtkui/native_theme_gtk.cc +index c72e78bdc7c1535d48bc13e18c1cc784051eaea8..fe07c0ac7d94cdbb7bef56f651266e63ec06f767 100644 +--- a/chrome/browser/ui/libgtkui/native_theme_gtk.cc ++++ b/chrome/browser/ui/libgtkui/native_theme_gtk.cc +@@ -280,6 +280,27 @@ SkColor SkColorFromColorId(ui::NativeTheme::ColorId color_id) { + case ui::NativeTheme::kColorId_TableHeaderSeparator: + return GetBorderColor("GtkTreeView#treeview.view GtkButton#button"); + ++ // Results Table ++ case ui::NativeTheme::kColorId_ResultsTableNormalBackground: ++ return SkColorFromColorId( ++ ui::NativeTheme::kColorId_TextfieldDefaultBackground); ++ case ui::NativeTheme::kColorId_ResultsTableHoveredBackground: ++ return color_utils::AlphaBlend( ++ SkColorFromColorId( ++ ui::NativeTheme::kColorId_TextfieldDefaultBackground), ++ SkColorFromColorId( ++ ui::NativeTheme::kColorId_TextfieldSelectionBackgroundFocused), ++ 0.5f); ++ case ui::NativeTheme::kColorId_ResultsTableNormalText: ++ return SkColorFromColorId( ++ ui::NativeTheme::kColorId_TextfieldDefaultColor); ++ case ui::NativeTheme::kColorId_ResultsTableDimmedText: ++ return color_utils::AlphaBlend( ++ SkColorFromColorId(ui::NativeTheme::kColorId_TextfieldDefaultColor), ++ SkColorFromColorId( ++ ui::NativeTheme::kColorId_TextfieldDefaultBackground), ++ 0.5f); ++ + // Throbber + // TODO(thomasanderson): Render GtkSpinner directly. + case ui::NativeTheme::kColorId_ThrobberSpinningColor: +diff --git a/ui/native_theme/common_theme.cc b/ui/native_theme/common_theme.cc +index 489369300d48dbfacb8c5489e06b77218f526bf4..340026b3dac4e833d3448d83db7b92c136134726 100644 +--- a/ui/native_theme/common_theme.cc ++++ b/ui/native_theme/common_theme.cc +@@ -51,6 +51,14 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id, + case NativeTheme::kColorId_BubbleFooterBackground: + return SkColorSetRGB(0x32, 0x36, 0x39); + ++ // Results Tables ++ case NativeTheme::kColorId_ResultsTableNormalBackground: ++ return SkColorSetRGB(0x28, 0x28, 0x28); ++ case NativeTheme::kColorId_ResultsTableNormalText: ++ return SK_ColorWHITE; ++ case NativeTheme::kColorId_ResultsTableDimmedText: ++ return SkColorSetA(base_theme->GetSystemColor(NativeTheme::kColorId_ResultsTableNormalText), 0x80); ++ + // FocusableBorder + case NativeTheme::kColorId_FocusedBorderColor: + return SkColorSetA(gfx::kGoogleBlue300, 0x66); +@@ -351,6 +359,18 @@ SkColor GetAuraColor(NativeTheme::ColorId color_id, + case NativeTheme::kColorId_UnfocusedBorderColor: + return SkColorSetA(SK_ColorBLACK, 0x66); + ++ // Results Tables ++ case NativeTheme::kColorId_ResultsTableNormalBackground: ++ return SK_ColorWHITE; ++ case NativeTheme::kColorId_ResultsTableHoveredBackground: ++ return SkColorSetA(base_theme->GetSystemColor( ++ NativeTheme::kColorId_ResultsTableNormalText), ++ 0x0D); ++ case NativeTheme::kColorId_ResultsTableNormalText: ++ return SK_ColorBLACK; ++ case NativeTheme::kColorId_ResultsTableDimmedText: ++ return SkColorSetRGB(0x64, 0x64, 0x64); ++ + // Material spinner/throbber + case NativeTheme::kColorId_ThrobberSpinningColor: + return gfx::kGoogleBlue600; +diff --git a/ui/native_theme/native_theme.h b/ui/native_theme/native_theme.h +index 68d9f2a26a8616d5f4d18c89fa0f8ec7650b8c10..b624f3df1162e0f6ad4ee72bf2bb8bd071744fae 100644 +--- a/ui/native_theme/native_theme.h ++++ b/ui/native_theme/native_theme.h +@@ -367,6 +367,11 @@ class NATIVE_THEME_EXPORT NativeTheme { + kColorId_TableHeaderText, + kColorId_TableHeaderBackground, + kColorId_TableHeaderSeparator, ++ // Results Tables, such as the omnibox ++ kColorId_ResultsTableNormalBackground, ++ kColorId_ResultsTableHoveredBackground, ++ kColorId_ResultsTableNormalText, ++ kColorId_ResultsTableDimmedText, + // Colors for the material spinner (aka throbber). + kColorId_ThrobberSpinningColor, + kColorId_ThrobberWaitingColor, +diff --git a/ui/native_theme/native_theme_win.cc b/ui/native_theme/native_theme_win.cc +index e74d07035ccdb1f54ce85775ac96d8a1be40e6c6..798b96799871aea80301c3b242bc575314cb698c 100644 +--- a/ui/native_theme/native_theme_win.cc ++++ b/ui/native_theme/native_theme_win.cc +@@ -539,6 +539,17 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id) const { + case kColorId_TableGroupingIndicatorColor: + return system_colors_[COLOR_GRAYTEXT]; + ++ // Results Tables ++ case kColorId_ResultsTableNormalBackground: ++ return system_colors_[COLOR_WINDOW]; ++ case kColorId_ResultsTableHoveredBackground: ++ return color_utils::AlphaBlend(system_colors_[COLOR_HIGHLIGHT], ++ system_colors_[COLOR_WINDOW], 0.25f); ++ case kColorId_ResultsTableNormalText: ++ return system_colors_[COLOR_WINDOWTEXT]; ++ case kColorId_ResultsTableDimmedText: ++ return color_utils::AlphaBlend(system_colors_[COLOR_WINDOWTEXT], ++ system_colors_[COLOR_WINDOW], 0.5f); + default: + break; + } diff --git a/patches/chromium/render_widget_host_view_base.patch b/patches/chromium/render_widget_host_view_base.patch index 700c31e052e79..7c0c2b0e3961f 100644 --- a/patches/chromium/render_widget_host_view_base.patch +++ b/patches/chromium/render_widget_host_view_base.patch @@ -25,7 +25,7 @@ index a2902adc59b6b4083334130f3a8e29fca0c440d2..34673d9ab62311c458a581f98865014f const blink::WebMouseEvent& event, const ui::LatencyInfo& latency) { diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h -index 903131f45d4fa82af9a6315227505b54ee0f1560..6450a05a4829731d3dc2338fd51ef6d0720b7fcb 100644 +index 81bdc91eb3513fc9ebf3a5fc93e1cdb02b0ac11a..db980868272e5398d2100d5968d1b35f0d48e3eb 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h @@ -24,9 +24,11 @@ @@ -40,7 +40,7 @@ index 903131f45d4fa82af9a6315227505b54ee0f1560..6450a05a4829731d3dc2338fd51ef6d0 #include "content/public/browser/render_widget_host_view.h" #include "content/public/common/input_event_ack_state.h" #include "content/public/common/screen_info.h" -@@ -75,10 +77,12 @@ class CursorManager; +@@ -75,9 +77,11 @@ class CursorManager; class MouseWheelPhaseHandler; class RenderWidgetHostImpl; class RenderWidgetHostViewBaseObserver; @@ -48,12 +48,11 @@ index 903131f45d4fa82af9a6315227505b54ee0f1560..6450a05a4829731d3dc2338fd51ef6d0 class SyntheticGestureTarget; class TextInputManager; class TouchSelectionControllerClientManager; - class WebContentsAccessibility; +class WebContentsView; class WebCursor; class DelegatedFrameHost; struct TextInputState; -@@ -136,6 +140,9 @@ class CONTENT_EXPORT RenderWidgetHostViewBase +@@ -135,6 +139,9 @@ class CONTENT_EXPORT RenderWidgetHostViewBase bool destination_is_loaded, bool destination_is_frozen) final; @@ -63,7 +62,7 @@ index 903131f45d4fa82af9a6315227505b54ee0f1560..6450a05a4829731d3dc2338fd51ef6d0 // This only needs to be overridden by RenderWidgetHostViewBase subclasses // that handle content embedded within other RenderWidgetHostViews. gfx::PointF TransformPointToRootCoordSpaceF( -@@ -364,6 +371,11 @@ class CONTENT_EXPORT RenderWidgetHostViewBase +@@ -363,6 +370,11 @@ class CONTENT_EXPORT RenderWidgetHostViewBase virtual void ProcessGestureEvent(const blink::WebGestureEvent& event, const ui::LatencyInfo& latency); diff --git a/patches/chromium/render_widget_host_view_mac.patch b/patches/chromium/render_widget_host_view_mac.patch index bd544d0449725..682b328d7d270 100644 --- a/patches/chromium/render_widget_host_view_mac.patch +++ b/patches/chromium/render_widget_host_view_mac.patch @@ -5,10 +5,10 @@ Subject: render_widget_host_view_mac.patch diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm -index 188fe917cb4e60458ca0aff4a467d18b2be915ea..62f8697c4a11a0df3be84ef8efe0ff90399e39ff 100644 +index 88c237934f7f71732e7f5d00474b9e5ab0940b4f..87cc3256aae945b8539ba1e19775d45857b12ff1 100644 --- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm +++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm -@@ -142,6 +142,11 @@ void ExtractUnderlines(NSAttributedString* string, +@@ -143,6 +143,11 @@ void ExtractUnderlines(NSAttributedString* string, } // namespace @@ -20,7 +20,7 @@ index 188fe917cb4e60458ca0aff4a467d18b2be915ea..62f8697c4a11a0df3be84ef8efe0ff90 // These are not documented, so use only after checking -respondsToSelector:. @interface NSApplication (UndocumentedSpeechMethods) - (void)speakString:(NSString*)string; -@@ -403,6 +408,9 @@ - (BOOL)acceptsMouseEventsWhenInactive { +@@ -561,6 +566,9 @@ - (BOOL)acceptsMouseEventsWhenInactive { } - (BOOL)acceptsFirstMouse:(NSEvent*)theEvent { @@ -30,7 +30,7 @@ index 188fe917cb4e60458ca0aff4a467d18b2be915ea..62f8697c4a11a0df3be84ef8efe0ff90 return [self acceptsMouseEventsWhenInactive]; } -@@ -792,6 +800,10 @@ - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv { +@@ -943,6 +951,10 @@ - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv { eventType == NSKeyDown && !(modifierFlags & NSCommandKeyMask); @@ -41,7 +41,7 @@ index 188fe917cb4e60458ca0aff4a467d18b2be915ea..62f8697c4a11a0df3be84ef8efe0ff90 // We only handle key down events and just simply forward other events. if (eventType != NSKeyDown) { hostHelper_->ForwardKeyboardEvent(event, latency_info); -@@ -1505,9 +1517,11 @@ - (NSAccessibilityRole)accessibilityRole { +@@ -1698,9 +1710,11 @@ - (NSAccessibilityRole)accessibilityRole { // Since this implementation doesn't have to wait any IPC calls, this doesn't // make any key-typing jank. --hbono 7/23/09 // @@ -53,7 +53,7 @@ index 188fe917cb4e60458ca0aff4a467d18b2be915ea..62f8697c4a11a0df3be84ef8efe0ff90 - (NSArray*)validAttributesForMarkedText { // This code is just copied from WebKit except renaming variables. -@@ -1516,7 +1530,10 @@ - (NSArray*)validAttributesForMarkedText { +@@ -1709,7 +1723,10 @@ - (NSArray*)validAttributesForMarkedText { initWithObjects:NSUnderlineStyleAttributeName, NSUnderlineColorAttributeName, NSMarkedClauseSegmentAttributeName, @@ -66,10 +66,10 @@ index 188fe917cb4e60458ca0aff4a467d18b2be915ea..62f8697c4a11a0df3be84ef8efe0ff90 return validAttributesForMarkedText_.get(); } diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm -index d450d958e760bd4934f47505d4ff18069f210cfe..a9a043d191e0bc08061879bb3494f3ba1a9bea10 100644 +index 684570762b9574f5f1601dbd0f312c263810df2b..cfe12fd79f6ac347b647303ccae871ade0c0bad2 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm -@@ -62,6 +62,7 @@ +@@ -63,6 +63,7 @@ #include "ui/events/keycodes/dom/dom_keyboard_layout_map.h" #include "ui/gfx/geometry/dip_util.h" #include "ui/gfx/mac/coordinate_conversion.h" diff --git a/patches/chromium/resource_file_conflict.patch b/patches/chromium/resource_file_conflict.patch index 6badf41398558..ee23b207fe9e3 100644 --- a/patches/chromium/resource_file_conflict.patch +++ b/patches/chromium/resource_file_conflict.patch @@ -52,10 +52,10 @@ Some alternatives to this patch: None of these options seems like a substantial maintainability win over this patch to me (@nornagon). diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn -index 7b277dc44034b556594bf47736d3ea95e85d2ac2..3d642578ed329b970e23785c09106b4cfdd9445a 100644 +index a59bacecda9fb2c73d0f27d36330cb75db70992c..7cbf39630fa7de7c4910dd9aff8411150fd7303a 100644 --- a/chrome/BUILD.gn +++ b/chrome/BUILD.gn -@@ -1686,7 +1686,7 @@ if (is_chrome_branded && !is_android) { +@@ -1709,7 +1709,7 @@ if (is_chrome_branded && !is_android) { } } @@ -64,7 +64,7 @@ index 7b277dc44034b556594bf47736d3ea95e85d2ac2..3d642578ed329b970e23785c09106b4c chrome_paks("packed_resources") { if (is_mac) { output_dir = "$root_gen_dir/repack" -@@ -1710,6 +1710,12 @@ if (!is_android) { +@@ -1733,6 +1733,12 @@ if (!is_android) { } } diff --git a/patches/chromium/revert_build_swiftshader_for_arm32.patch b/patches/chromium/revert_build_swiftshader_for_arm32.patch deleted file mode 100644 index d88984d57b750..0000000000000 --- a/patches/chromium/revert_build_swiftshader_for_arm32.patch +++ /dev/null @@ -1,22 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: deepak1556 -Date: Wed, 6 Feb 2019 06:36:32 +0530 -Subject: Revert "Build swiftshader for ARM32." - -This reverts commit e7caa7ca82fc015675aea8cecf178c83a94ab3a7. - -diff --git a/ui/gl/BUILD.gn b/ui/gl/BUILD.gn -index a54c5b0f49a1abd48688ef5359892ac4c4b5af16..ad9bf97a1e948f348b04791638cce9e038342ab2 100644 ---- a/ui/gl/BUILD.gn -+++ b/ui/gl/BUILD.gn -@@ -15,8 +15,8 @@ declare_args() { - enable_swiftshader = (is_win || is_linux || (is_mac && use_egl) || - is_chromeos || is_fuchsia) && - (target_cpu == "x86" || target_cpu == "x64" || -- target_cpu == "arm" || target_cpu == "arm64" || -- target_cpu == "mipsel" || target_cpu == "mips64el") -+ target_cpu == "arm64" || target_cpu == "mipsel" || -+ target_cpu == "mips64el") - - # Whether service side logging (actual calls into the GL driver) is enabled - # or not. diff --git a/patches/chromium/scroll_bounce_flag.patch b/patches/chromium/scroll_bounce_flag.patch index 3bd87d3ee2ed8..508aa9453d61e 100644 --- a/patches/chromium/scroll_bounce_flag.patch +++ b/patches/chromium/scroll_bounce_flag.patch @@ -6,10 +6,10 @@ Subject: scroll_bounce_flag.patch Patch to make scrollBounce option work. diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc -index 0fa36e789411c952bc8b1ccbe6d0164d909ac8f3..5753b9c772541f53b7cec24d0efce63cc9ab8dcc 100644 +index 28b5e17d0914bc4c9bb5bc8c650ba646e9e8f54e..3728ab15d565802d67b980a4995af62fa29c046e 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc -@@ -1509,7 +1509,7 @@ bool RenderThreadImpl::IsGpuMemoryBufferCompositorResourcesEnabled() { +@@ -1499,7 +1499,7 @@ bool RenderThreadImpl::IsGpuMemoryBufferCompositorResourcesEnabled() { } bool RenderThreadImpl::IsElasticOverscrollEnabled() { diff --git a/patches/chromium/ssl_security_state_tab_helper.patch b/patches/chromium/ssl_security_state_tab_helper.patch index c7eb73ad2ca8b..eb9de88695e23 100644 --- a/patches/chromium/ssl_security_state_tab_helper.patch +++ b/patches/chromium/ssl_security_state_tab_helper.patch @@ -6,10 +6,10 @@ Subject: ssl_security_state_tab_helper.patch Allows populating security tab info for devtools in Electron. diff --git a/chrome/browser/ssl/security_state_tab_helper.cc b/chrome/browser/ssl/security_state_tab_helper.cc -index 6ef33c5357cf08c1f17e9f20bd8d659bf4807d1c..a199f0ee15427b4ea45018702048800a21d96fd5 100644 +index 45e0f485363a282e2e0caf227c2a7fbc8309acee..a05e16eba687d34e0cbad8cdc6159156cea59abd 100644 --- a/chrome/browser/ssl/security_state_tab_helper.cc +++ b/chrome/browser/ssl/security_state_tab_helper.cc -@@ -13,13 +13,17 @@ +@@ -13,14 +13,18 @@ #include "base/strings/pattern.h" #include "base/strings/string_util.h" #include "build/build_config.h" @@ -23,11 +23,12 @@ index 6ef33c5357cf08c1f17e9f20bd8d659bf4807d1c..a199f0ee15427b4ea45018702048800a +#if 0 #include "components/omnibox/browser/omnibox_field_trial.h" #include "components/omnibox/common/omnibox_features.h" + #include "components/password_manager/core/browser/password_manager_metrics_util.h" +#endif #include "components/security_state/content/content_utils.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/navigation_entry.h" -@@ -42,8 +46,10 @@ +@@ -43,8 +47,10 @@ #endif // defined(OS_CHROMEOS) #if defined(FULL_SAFE_BROWSING) @@ -38,33 +39,18 @@ index 6ef33c5357cf08c1f17e9f20bd8d659bf4807d1c..a199f0ee15427b4ea45018702048800a namespace { -@@ -63,7 +69,9 @@ void RecordSecurityLevel( +@@ -64,8 +70,9 @@ void RecordSecurityLevel( } // namespace +#if 0 - using safe_browsing::SafeBrowsingUIManager; + using password_manager::metrics_util::PasswordType; +-using safe_browsing::SafeBrowsingUIManager; +#endif SecurityStateTabHelper::SecurityStateTabHelper( content::WebContents* web_contents) -@@ -129,6 +137,7 @@ void SecurityStateTabHelper::DidFinishNavigation( - UMA_HISTOGRAM_BOOLEAN("interstitial.ssl.visited_site_after_warning", true); - } - -+#if 0 - // Security indicator UI study (https://crbug.com/803501): Show a message in - // the console to reduce developer confusion about the experimental UI - // treatments for HTTPS pages with EV certificates. -@@ -156,6 +165,7 @@ void SecurityStateTabHelper::DidFinishNavigation( - "Validation is still valid."); - } - } -+#endif - } - - void SecurityStateTabHelper::DidChangeVisibleSecurityState() { -@@ -179,6 +189,7 @@ SecurityStateTabHelper::GetMaliciousContentStatus() const { +@@ -153,6 +160,7 @@ SecurityStateTabHelper::GetMaliciousContentStatus() const { web_contents()->GetController().GetVisibleEntry(); if (!entry) return security_state::MALICIOUS_CONTENT_STATUS_NONE; @@ -72,7 +58,7 @@ index 6ef33c5357cf08c1f17e9f20bd8d659bf4807d1c..a199f0ee15427b4ea45018702048800a safe_browsing::SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); if (!sb_service) -@@ -246,6 +257,7 @@ SecurityStateTabHelper::GetMaliciousContentStatus() const { +@@ -219,6 +227,7 @@ SecurityStateTabHelper::GetMaliciousContentStatus() const { break; } } diff --git a/patches/chromium/support_mixed_sandbox_with_zygote.patch b/patches/chromium/support_mixed_sandbox_with_zygote.patch index 2ec15b56cb46d..86546922416e1 100644 --- a/patches/chromium/support_mixed_sandbox_with_zygote.patch +++ b/patches/chromium/support_mixed_sandbox_with_zygote.patch @@ -22,10 +22,10 @@ However, the patch would need to be reviewed by the security team, as it does touch a security-sensitive class. diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc -index 515e148c26584b7fc9c3fcd9c266e6a7714ca75d..4b8c6d7b1a2676df8ef63117785c1aed8341d12e 100644 +index dcf3078fc7a07b56a144b93a94b5285fa0583685..26b1e9e2043cd5576e58ed44c5595c42a58f9f84 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc -@@ -416,6 +416,10 @@ class RendererSandboxedProcessLauncherDelegate +@@ -395,6 +395,10 @@ class RendererSandboxedProcessLauncherDelegate : public SandboxedProcessLauncherDelegate { public: RendererSandboxedProcessLauncherDelegate() {} @@ -36,7 +36,7 @@ index 515e148c26584b7fc9c3fcd9c266e6a7714ca75d..4b8c6d7b1a2676df8ef63117785c1aed ~RendererSandboxedProcessLauncherDelegate() override {} -@@ -435,6 +439,9 @@ class RendererSandboxedProcessLauncherDelegate +@@ -414,6 +418,9 @@ class RendererSandboxedProcessLauncherDelegate #if BUILDFLAG(USE_ZYGOTE_HANDLE) service_manager::ZygoteHandle GetZygote() override { @@ -46,7 +46,7 @@ index 515e148c26584b7fc9c3fcd9c266e6a7714ca75d..4b8c6d7b1a2676df8ef63117785c1aed const base::CommandLine& browser_command_line = *base::CommandLine::ForCurrentProcess(); base::CommandLine::StringType renderer_prefix = -@@ -448,6 +455,11 @@ class RendererSandboxedProcessLauncherDelegate +@@ -427,6 +434,11 @@ class RendererSandboxedProcessLauncherDelegate service_manager::SandboxType GetSandboxType() override { return service_manager::SANDBOX_TYPE_RENDERER; } @@ -58,7 +58,7 @@ index 515e148c26584b7fc9c3fcd9c266e6a7714ca75d..4b8c6d7b1a2676df8ef63117785c1aed }; const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey"; -@@ -1728,11 +1740,18 @@ bool RenderProcessHostImpl::Init() { +@@ -1748,11 +1760,18 @@ bool RenderProcessHostImpl::Init() { cmd_line->PrependWrapper(renderer_prefix); AppendRendererCommandLine(cmd_line.get()); diff --git a/patches/chromium/unsandboxed_ppapi_processes_skip_zygote.patch b/patches/chromium/unsandboxed_ppapi_processes_skip_zygote.patch index bacf4c4c21e4c..810799a77235f 100644 --- a/patches/chromium/unsandboxed_ppapi_processes_skip_zygote.patch +++ b/patches/chromium/unsandboxed_ppapi_processes_skip_zygote.patch @@ -5,7 +5,7 @@ Subject: unsandboxed ppapi processes skip zygote diff --git a/content/browser/ppapi_plugin_process_host.cc b/content/browser/ppapi_plugin_process_host.cc -index 37713154ca38166f5abf34f128211e84a9267553..2afb96a4c46d654630c5519b7654b42654a88b5f 100644 +index 56a1b68a0d03f2a5ea7fc809e383a82579ef01a2..70d083de6b6db96c6a2ce8a412f59b824656b29e 100644 --- a/content/browser/ppapi_plugin_process_host.cc +++ b/content/browser/ppapi_plugin_process_host.cc @@ -121,6 +121,9 @@ class PpapiPluginSandboxedProcessLauncherDelegate diff --git a/patches/chromium/web_contents.patch b/patches/chromium/web_contents.patch index 7b9d19e7ee033..bfddcaa4531fa 100644 --- a/patches/chromium/web_contents.patch +++ b/patches/chromium/web_contents.patch @@ -5,10 +5,10 @@ Subject: web_contents.patch diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc -index 9f68ff38beffa5840fc3f037df2d4a71f0cbc36a..f38b9d34f8c29658af6120d5422acb635fd1539c 100644 +index b504f3779cab8a96cd72c1524bcc9795645d6764..d141ed8498c95093d0d697f95aeada958e24d048 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc -@@ -2071,6 +2071,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { +@@ -2090,6 +2090,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { std::string unique_name; frame_tree_.root()->SetFrameName(params.main_frame_name, unique_name); @@ -21,7 +21,7 @@ index 9f68ff38beffa5840fc3f037df2d4a71f0cbc36a..f38b9d34f8c29658af6120d5422acb63 WebContentsViewDelegate* delegate = GetContentClient()->browser()->GetWebContentsViewDelegate(this); -@@ -2086,6 +2092,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { +@@ -2105,6 +2111,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { &render_view_host_delegate_view_); } } @@ -92,7 +92,7 @@ index ecaf30bcb7b916a92a69641dd7b96a3633d407c0..0af625928ca6227a21cd4263a14a42b7 RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForChildWidget( diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h -index 6cf2ca2a0ec5d54eeadd7581eaa2acfd83459965..498d8ed92b6ebbf863a26be91258bb9608e6f31e 100644 +index 06536cf612f149dd6de7cd1b9105e2aa8da1d633..fbbf3d0023ae5900a3c51987e52d18645e5207e3 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -75,9 +75,12 @@ class BrowserPluginGuestDelegate; diff --git a/patches/chromium/woa_compiler_workaround.patch b/patches/chromium/woa_compiler_workaround.patch deleted file mode 100644 index ff4cbebc46e18..0000000000000 --- a/patches/chromium/woa_compiler_workaround.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Richard Townsend -Date: Mon, 3 Jun 2019 09:52:49 +0100 -Subject: build: pull in a fixed compiler for Windows on Arm - -Due to a code-generation defect in the version of Clang used for the M76 -branch related to virtual method thunks, it's necessary to build M76 -with a later version of Clang. This change pulls in a corrected version -by setting ELECTRON_BUILDING_WOA=1 or similar in the environment. - -This PR is only intended to be a temporary workaround and will be -removed when Electron's Chromium updates to a compiler unaffected by -this issue. - -diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py -index c14a188f16c41002088b2f8451ea3cab7f2ff4e9..b067774bc2c1d833142ff848a9faa5d4bac0b4cd 100755 ---- a/tools/clang/scripts/update.py -+++ b/tools/clang/scripts/update.py -@@ -40,6 +40,11 @@ CLANG_REVISION = '67510fac36d27b2e22c7cd955fc167136b737b93' - CLANG_SVN_REVISION = '361212' - CLANG_SUB_REVISION = 3 - -+if os.getenv('ELECTRON_BUILDING_WOA'): -+ CLANG_REVISION = '56bee1a90a71876cb5067b108bf5715fa1c4e843' -+ CLANG_SVN_REVISION = '361657' -+ CLANG_SUB_REVISION = 1 -+ - PACKAGE_VERSION = '%s-%s-%s' % (CLANG_SVN_REVISION, CLANG_REVISION[:8], - CLANG_SUB_REVISION) - RELEASE_VERSION = '9.0.0' diff --git a/patches/chromium/worker_context_will_destroy.patch b/patches/chromium/worker_context_will_destroy.patch index 60cb7dc1a80e8..83db3f1ad44ba 100644 --- a/patches/chromium/worker_context_will_destroy.patch +++ b/patches/chromium/worker_context_will_destroy.patch @@ -5,10 +5,10 @@ Subject: worker_context_will_destroy.patch diff --git a/content/public/renderer/content_renderer_client.h b/content/public/renderer/content_renderer_client.h -index 31fcd7d89bf8f23d32ad385351d272e81aad36a1..373a76a576e2ccdf604036daadf012c24d409858 100644 +index bfc62d1766686981ded5e62ad7da466d3afb9bab..5fa60ba975561626ae3ccecd9968278c547710a0 100644 --- a/content/public/renderer/content_renderer_client.h +++ b/content/public/renderer/content_renderer_client.h -@@ -389,6 +389,11 @@ class CONTENT_EXPORT ContentRendererClient { +@@ -385,6 +385,11 @@ class CONTENT_EXPORT ContentRendererClient { virtual void DidInitializeWorkerContextOnWorkerThread( v8::Local context) {} @@ -21,10 +21,10 @@ index 31fcd7d89bf8f23d32ad385351d272e81aad36a1..373a76a576e2ccdf604036daadf012c2 // An empty URL is returned if the URL is not overriden. virtual GURL OverrideFlashEmbedWithHTML(const GURL& url); diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc -index 8bdf34b7a2fae5941f986434d2ff39d1f6ab332a..c89bcd9d4ed37c68ec19f0d4976fe64f7ebdbb2b 100644 +index e722b084f5aa97510626025ae351a0a994344039..6dff78f0d847c100a48afc2a5d17f98578a74275 100644 --- a/content/renderer/renderer_blink_platform_impl.cc +++ b/content/renderer/renderer_blink_platform_impl.cc -@@ -953,6 +953,12 @@ void RendererBlinkPlatformImpl::WillStopWorkerThread() { +@@ -893,6 +893,12 @@ void RendererBlinkPlatformImpl::WillStopWorkerThread() { WorkerThreadRegistry::Instance()->WillStopCurrentWorkerThread(); } @@ -38,10 +38,10 @@ index 8bdf34b7a2fae5941f986434d2ff39d1f6ab332a..c89bcd9d4ed37c68ec19f0d4976fe64f const v8::Local& worker) { GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread( diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h -index a7cc63d04922b00cd2c65283343a9315e86a6bae..5f315876dce8fc0b695c0aa44da9cc54d9ec0fe1 100644 +index 07344fa37d6ca22a48ec5f0bc7cdce64d4073641..4e84ce9372a7378884a48430cc971ade88c57bb9 100644 --- a/content/renderer/renderer_blink_platform_impl.h +++ b/content/renderer/renderer_blink_platform_impl.h -@@ -188,6 +188,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { +@@ -181,6 +181,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl { void DidStartWorkerThread() override; void WillStopWorkerThread() override; void WorkerContextCreated(const v8::Local& worker) override; @@ -50,10 +50,10 @@ index a7cc63d04922b00cd2c65283343a9315e86a6bae..5f315876dce8fc0b695c0aa44da9cc54 const blink::WebString& header_name) override; diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h -index 19b78466e66fcaf9a1cc44346e2e47f79381bf36..c2c24e3950d647ecd14585e0ed0277c1f8774290 100644 +index e5fdbadee356021390effe7c52bdcfca60ab36af..67a172da86c135152fb8cfaaa45ba4913867a54c 100644 --- a/third_party/blink/public/platform/platform.h +++ b/third_party/blink/public/platform/platform.h -@@ -640,6 +640,7 @@ class BLINK_PLATFORM_EXPORT Platform { +@@ -617,6 +617,7 @@ class BLINK_PLATFORM_EXPORT Platform { virtual void DidStartWorkerThread() {} virtual void WillStopWorkerThread() {} virtual void WorkerContextCreated(const v8::Local& worker) {} @@ -62,7 +62,7 @@ index 19b78466e66fcaf9a1cc44346e2e47f79381bf36..c2c24e3950d647ecd14585e0ed0277c1 const WebSecurityOrigin& script_origin) { return false; diff --git a/third_party/blink/renderer/core/workers/worker_thread.cc b/third_party/blink/renderer/core/workers/worker_thread.cc -index 6c71516b1906fa2cae5440782595af7a2eea8ab7..c150855e51c6623c950c3875a447217ca091ea50 100644 +index 14f6f3f5cce4ee0cb444b271bc4c98868f33d51a..1fbd785e48b5cd885c310861f916150a3e41ee61 100644 --- a/third_party/blink/renderer/core/workers/worker_thread.cc +++ b/third_party/blink/renderer/core/workers/worker_thread.cc @@ -640,6 +640,12 @@ void WorkerThread::PrepareForShutdownOnWorkerThread() { diff --git a/patches/config.json b/patches/config.json index 5788b1c1e6ce1..225a856291df4 100644 --- a/patches/config.json +++ b/patches/config.json @@ -3,5 +3,7 @@ "src/electron/patches/boringssl": "src/third_party/boringssl/src", + "src/electron/patches/swiftshader": "src/third_party/swiftshader", + "src/electron/patches/v8": "src/v8" } diff --git a/patches/swiftshader/.patches b/patches/swiftshader/.patches new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/patches/v8/add_realloc.patch b/patches/v8/add_realloc.patch index 129e2a82510b3..9a011d3ba0db1 100644 --- a/patches/v8/add_realloc.patch +++ b/patches/v8/add_realloc.patch @@ -12,10 +12,10 @@ when we override ReallocateBufferMemory, so we therefore need to implement Realloc on the v8 side. diff --git a/include/v8.h b/include/v8.h -index c54b088404229dccf015e20b6a5bab19d3d94e69..cc603dc4aae69de4b09f06ed0bca48cdae8eebd3 100644 +index 7d1ab73901b02fe4341d2dff14a82edbd505813d..a1043c455e226fd9773dce536748de7bb5779977 100644 --- a/include/v8.h +++ b/include/v8.h -@@ -4624,6 +4624,13 @@ class V8_EXPORT ArrayBuffer : public Object { +@@ -4618,6 +4618,13 @@ class V8_EXPORT ArrayBuffer : public Object { */ virtual void* AllocateUninitialized(size_t length) = 0; @@ -30,10 +30,10 @@ index c54b088404229dccf015e20b6a5bab19d3d94e69..cc603dc4aae69de4b09f06ed0bca48cd * Free the memory block of size |length|, pointed to by |data|. * That memory is guaranteed to be previously allocated by |Allocate|. diff --git a/src/api/api.cc b/src/api/api.cc -index 9b2c117e1ae756e3c9d3f3b0dc36a7b348c53b51..6a501f67ebf900ee30d55bd05ccc58845d71f418 100644 +index 838b388f0b847a5197d2d7c6965841d1e343e508..b0e754852fab7f657aa8fa86d424bd2bbc23b712 100644 --- a/src/api/api.cc +++ b/src/api/api.cc -@@ -515,6 +515,10 @@ void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) { +@@ -507,6 +507,10 @@ void V8::SetSnapshotDataBlob(StartupData* snapshot_blob) { i::V8::SetSnapshotBlob(snapshot_blob); } diff --git a/patches/v8/build_gn.patch b/patches/v8/build_gn.patch index c2431f9d5b02b..e7bb9fa5274e3 100644 --- a/patches/v8/build_gn.patch +++ b/patches/v8/build_gn.patch @@ -5,10 +5,10 @@ Subject: build_gn.patch diff --git a/BUILD.gn b/BUILD.gn -index cf089979d1446b7628ce3a7e634e4e4d2267024e..fc4571440d5e7b8af281b01d9a66cd563f5ab03d 100644 +index 6a5dff6d2281b38a444878ef6b11d9d4bfe49d08..7f5730e3069626a9078a5faf15385bf18519fe12 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -269,7 +269,7 @@ config("internal_config") { +@@ -271,7 +271,7 @@ config("internal_config") { ":v8_header_features", ] @@ -26,7 +26,7 @@ index cf089979d1446b7628ce3a7e634e4e4d2267024e..fc4571440d5e7b8af281b01d9a66cd56 deps = [ ":v8_libbase", -@@ -3819,6 +3819,8 @@ if (v8_use_snapshot && current_toolchain == v8_snapshot_toolchain) { +@@ -3820,6 +3820,8 @@ if (v8_use_snapshot && current_toolchain == v8_snapshot_toolchain) { configs = [ ":internal_config" ] diff --git a/patches/v8/dcheck.patch b/patches/v8/dcheck.patch index e2a0dfdb95821..64edb4988536b 100644 --- a/patches/v8/dcheck.patch +++ b/patches/v8/dcheck.patch @@ -5,10 +5,10 @@ Subject: dcheck.patch diff --git a/src/api/api.cc b/src/api/api.cc -index 1b39655a1221b3df0012f5cc26697841d2c100d6..a6ea06b358f4ff21b3f4313c82b4ec52ca5513b8 100644 +index ed57632474900e2f9ad824d26f62f88737d43638..6805abc94819657a188eb31ea052308e08c4a3e8 100644 --- a/src/api/api.cc +++ b/src/api/api.cc -@@ -8236,7 +8236,7 @@ void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { +@@ -8255,7 +8255,7 @@ void Isolate::SetPromiseRejectCallback(PromiseRejectCallback callback) { } void Isolate::RunMicrotasks() { @@ -18,10 +18,10 @@ index 1b39655a1221b3df0012f5cc26697841d2c100d6..a6ea06b358f4ff21b3f4313c82b4ec52 isolate->default_microtask_queue()->RunMicrotasks(isolate); } diff --git a/src/heap/heap.cc b/src/heap/heap.cc -index 209832dddc21b3c7ef3ab6d8586572b5eaf5f337..7416eda8db13019d8db54bf1a54a9ae4e15982d1 100644 +index 9afda270e601b5a9ab8c1b8355a9124872fb3aa0..8f17ff04911e7f038b6a665375cefd9686b0b947 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc -@@ -5080,9 +5080,9 @@ void Heap::TearDown() { +@@ -5238,9 +5238,9 @@ void Heap::TearDown() { void Heap::AddGCPrologueCallback(v8::Isolate::GCCallbackWithData callback, GCType gc_type, void* data) { DCHECK_NOT_NULL(callback); diff --git a/patches/v8/deps_provide_more_v8_backwards_compatibility.patch b/patches/v8/deps_provide_more_v8_backwards_compatibility.patch index e4011b820fdd3..22b89acb742ed 100644 --- a/patches/v8/deps_provide_more_v8_backwards_compatibility.patch +++ b/patches/v8/deps_provide_more_v8_backwards_compatibility.patch @@ -22,7 +22,7 @@ Reviewed-By: Yang Guo Reviewed-By: Michaël Zasso diff --git a/include/v8.h b/include/v8.h -index cc603dc4aae69de4b09f06ed0bca48cdae8eebd3..c59b0fa69880c237e3b60f190160d8b94862bf36 100644 +index a1043c455e226fd9773dce536748de7bb5779977..aafd041326f1ba85bdba8bc3a16748bad6655710 100644 --- a/include/v8.h +++ b/include/v8.h @@ -1108,6 +1108,10 @@ class V8_EXPORT PrimitiveArray { @@ -134,7 +134,7 @@ index cc603dc4aae69de4b09f06ed0bca48cdae8eebd3..c59b0fa69880c237e3b60f190160d8b9 Value(Isolate* isolate, Local obj); ~Value(); uint16_t* operator*() { return str_; } -@@ -5281,6 +5320,8 @@ class V8_EXPORT BooleanObject : public Object { +@@ -5275,6 +5314,8 @@ class V8_EXPORT BooleanObject : public Object { class V8_EXPORT StringObject : public Object { public: static Local New(Isolate* isolate, Local value); @@ -143,7 +143,7 @@ index cc603dc4aae69de4b09f06ed0bca48cdae8eebd3..c59b0fa69880c237e3b60f190160d8b9 Local ValueOf() const; -@@ -10384,6 +10425,29 @@ template Value* Value::Cast(T* value) { +@@ -10461,6 +10502,29 @@ template Value* Value::Cast(T* value) { } @@ -174,10 +174,10 @@ index cc603dc4aae69de4b09f06ed0bca48cdae8eebd3..c59b0fa69880c237e3b60f190160d8b9 #ifdef V8_ENABLE_CHECKS CheckCast(value); diff --git a/src/api/api.cc b/src/api/api.cc -index 6a501f67ebf900ee30d55bd05ccc58845d71f418..1b39655a1221b3df0012f5cc26697841d2c100d6 100644 +index b0e754852fab7f657aa8fa86d424bd2bbc23b712..ed57632474900e2f9ad824d26f62f88737d43638 100644 --- a/src/api/api.cc +++ b/src/api/api.cc -@@ -2171,6 +2171,10 @@ int PrimitiveArray::Length() const { +@@ -2182,6 +2182,10 @@ int PrimitiveArray::Length() const { return array->length(); } @@ -188,7 +188,7 @@ index 6a501f67ebf900ee30d55bd05ccc58845d71f418..1b39655a1221b3df0012f5cc26697841 void PrimitiveArray::Set(Isolate* v8_isolate, int index, Local item) { i::Isolate* isolate = reinterpret_cast(v8_isolate); -@@ -2184,6 +2188,10 @@ void PrimitiveArray::Set(Isolate* v8_isolate, int index, +@@ -2195,6 +2199,10 @@ void PrimitiveArray::Set(Isolate* v8_isolate, int index, array->set(index, *i_item); } @@ -199,7 +199,7 @@ index 6a501f67ebf900ee30d55bd05ccc58845d71f418..1b39655a1221b3df0012f5cc26697841 Local PrimitiveArray::Get(Isolate* v8_isolate, int index) { i::Isolate* isolate = reinterpret_cast(v8_isolate); i::Handle array = Utils::OpenHandle(this); -@@ -2867,6 +2875,10 @@ void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { +@@ -2890,6 +2898,10 @@ void Message::PrintCurrentStackTrace(Isolate* isolate, FILE* out) { // --- S t a c k T r a c e --- @@ -210,7 +210,7 @@ index 6a501f67ebf900ee30d55bd05ccc58845d71f418..1b39655a1221b3df0012f5cc26697841 Local StackTrace::GetFrame(Isolate* v8_isolate, uint32_t index) const { i::Isolate* isolate = reinterpret_cast(v8_isolate); -@@ -3453,6 +3465,34 @@ MaybeLocal Value::ToBigInt(Local context) const { +@@ -3477,6 +3489,34 @@ MaybeLocal Value::ToBigInt(Local context) const { RETURN_ESCAPED(result); } @@ -245,7 +245,7 @@ index 6a501f67ebf900ee30d55bd05ccc58845d71f418..1b39655a1221b3df0012f5cc26697841 bool Value::BooleanValue(Isolate* v8_isolate) const { return Utils::OpenHandle(this)->BooleanValue( reinterpret_cast(v8_isolate)); -@@ -3801,6 +3841,11 @@ MaybeLocal Value::ToArrayIndex(Local context) const { +@@ -3824,6 +3864,11 @@ MaybeLocal Value::ToArrayIndex(Local context) const { return Local(); } @@ -257,7 +257,7 @@ index 6a501f67ebf900ee30d55bd05ccc58845d71f418..1b39655a1221b3df0012f5cc26697841 Maybe Value::Equals(Local context, Local that) const { i::Isolate* isolate = Utils::OpenHandle(*context)->GetIsolate(); auto self = Utils::OpenHandle(this); -@@ -5033,6 +5078,10 @@ bool String::ContainsOnlyOneByte() const { +@@ -5036,6 +5081,10 @@ bool String::ContainsOnlyOneByte() const { return helper.Check(*str); } @@ -268,7 +268,7 @@ index 6a501f67ebf900ee30d55bd05ccc58845d71f418..1b39655a1221b3df0012f5cc26697841 int String::Utf8Length(Isolate* isolate) const { i::Handle str = Utils::OpenHandle(this); str = i::String::Flatten(reinterpret_cast(isolate), str); -@@ -5185,6 +5234,14 @@ static int WriteUtf8Impl(i::Vector string, char* write_start, +@@ -5188,6 +5237,14 @@ static int WriteUtf8Impl(i::Vector string, char* write_start, } } // anonymous namespace @@ -283,7 +283,7 @@ index 6a501f67ebf900ee30d55bd05ccc58845d71f418..1b39655a1221b3df0012f5cc26697841 int String::WriteUtf8(Isolate* v8_isolate, char* buffer, int capacity, int* nchars_ref, int options) const { i::Handle str = Utils::OpenHandle(this); -@@ -5223,6 +5280,17 @@ static inline int WriteHelper(i::Isolate* isolate, const String* string, +@@ -5226,6 +5283,17 @@ static inline int WriteHelper(i::Isolate* isolate, const String* string, return end - start; } @@ -301,7 +301,7 @@ index 6a501f67ebf900ee30d55bd05ccc58845d71f418..1b39655a1221b3df0012f5cc26697841 int String::WriteOneByte(Isolate* isolate, uint8_t* buffer, int start, int length, int options) const { return WriteHelper(reinterpret_cast(isolate), this, buffer, -@@ -6132,6 +6200,11 @@ MaybeLocal String::NewFromTwoByte(Isolate* isolate, +@@ -6143,6 +6211,11 @@ MaybeLocal String::NewFromTwoByte(Isolate* isolate, return result; } @@ -313,8 +313,8 @@ index 6a501f67ebf900ee30d55bd05ccc58845d71f418..1b39655a1221b3df0012f5cc26697841 Local v8::String::Concat(Isolate* v8_isolate, Local left, Local right) { i::Isolate* isolate = reinterpret_cast(v8_isolate); -@@ -6401,6 +6474,10 @@ bool v8::BooleanObject::ValueOf() const { - return jsvalue->value().IsTrue(isolate); +@@ -6413,6 +6486,10 @@ bool v8::BooleanObject::ValueOf() const { + return js_primitive_wrapper->value().IsTrue(isolate); } +Local v8::StringObject::New(Local value) { @@ -324,7 +324,7 @@ index 6a501f67ebf900ee30d55bd05ccc58845d71f418..1b39655a1221b3df0012f5cc26697841 Local v8::StringObject::New(Isolate* v8_isolate, Local value) { i::Handle string = Utils::OpenHandle(*value); -@@ -8589,6 +8666,9 @@ bool MicrotasksScope::IsRunningMicrotasks(Isolate* v8_isolate) { +@@ -8611,6 +8688,9 @@ bool MicrotasksScope::IsRunningMicrotasks(Isolate* v8_isolate) { return microtask_queue->IsRunningMicrotasks(); } @@ -334,7 +334,7 @@ index 6a501f67ebf900ee30d55bd05ccc58845d71f418..1b39655a1221b3df0012f5cc26697841 String::Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local obj) : str_(nullptr), length_(0) { if (obj.IsEmpty()) return; -@@ -8606,6 +8686,9 @@ String::Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local obj) +@@ -8628,6 +8708,9 @@ String::Utf8Value::Utf8Value(v8::Isolate* isolate, v8::Local obj) String::Utf8Value::~Utf8Value() { i::DeleteArray(str_); } diff --git a/patches/v8/do_not_export_private_v8_symbols_on_windows.patch b/patches/v8/do_not_export_private_v8_symbols_on_windows.patch index e8212ebb02f47..a8832475ebdbe 100644 --- a/patches/v8/do_not_export_private_v8_symbols_on_windows.patch +++ b/patches/v8/do_not_export_private_v8_symbols_on_windows.patch @@ -12,13 +12,13 @@ This patch can be safely removed if, when it is removed, `node.lib` does not contain any standard C++ library exports (e.g. `std::ostringstream`). diff --git a/BUILD.gn b/BUILD.gn -index 315c7079ed488461a456aff799b4d1f17b896150..0f668eae73686c02a7133df31a79e8a0a7b77707 100644 +index 77942b37474195ea07c59c67b1dda8ed8d14d751..d66f61f7c15b5f375aee4643c143f5168858b0ff 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -273,6 +273,10 @@ config("internal_config") { +@@ -271,6 +271,10 @@ config("internal_config") { ":v8_header_features", ] - + + if (!is_component_build && is_electron_build) { + defines += [ "HIDE_PRIVATE_SYMBOLS" ] + } @@ -32,7 +32,7 @@ index ad70e9820ddb4a63639ca7738c1836cb87766db5..d40be9b57294583f74594d88d9b7d7b9 +++ b/src/base/macros.h @@ -414,13 +414,17 @@ bool is_inbounds(float_t v) { #ifdef V8_OS_WIN - + // Setup for Windows shared library export. +#if defined(HIDE_PRIVATE_SYMBOLS) +#define V8_EXPORT_PRIVATE @@ -47,6 +47,6 @@ index ad70e9820ddb4a63639ca7738c1836cb87766db5..d40be9b57294583f74594d88d9b7d7b9 -#endif // BUILDING_V8_SHARED +#endif +#endif - + #else // V8_OS_WIN - + diff --git a/patches/v8/export_symbols_needed_for_windows_build.patch b/patches/v8/export_symbols_needed_for_windows_build.patch index b78dbc01c2753..a7b2b2a0d810d 100644 --- a/patches/v8/export_symbols_needed_for_windows_build.patch +++ b/patches/v8/export_symbols_needed_for_windows_build.patch @@ -6,10 +6,10 @@ Subject: Export symbols needed for Windows build These symbols are required to build v8 with BUILD_V8_SHARED on Windows. diff --git a/src/objects/objects.h b/src/objects/objects.h -index 857f3ed0f6d537cd648f23f04a0ab4c28cce1f96..14c73a0425b4e1e677426eee929910add5615201 100644 +index 47fd04622e1569650db694514931d075e22ced2c..397baf6dd32b3f0c3515c3c3d5400ef10c08a4c1 100644 --- a/src/objects/objects.h +++ b/src/objects/objects.h -@@ -791,7 +791,7 @@ enum class KeyCollectionMode { +@@ -793,7 +793,7 @@ enum class KeyCollectionMode { // Utility superclass for stack-allocated objects that must be updated // on gc. It provides two ways for the gc to update instances, either // iterating or updating after gc. diff --git a/patches/v8/expose_mksnapshot.patch b/patches/v8/expose_mksnapshot.patch index cd28f031715fe..7181f68af2b68 100644 --- a/patches/v8/expose_mksnapshot.patch +++ b/patches/v8/expose_mksnapshot.patch @@ -6,15 +6,14 @@ Subject: expose_mksnapshot.patch Needed in order to target mksnapshot for mksnapshot zip. diff --git a/BUILD.gn b/BUILD.gn -index fc4571440d5e7b8af281b01d9a66cd563f5ab03d..2d35a0b051f4130485c783807132ddcc543f4de4 100644 +index 7f5730e3069626a9078a5faf15385bf18519fe12..77942b37474195ea07c59c67b1dda8ed8d14d751 100644 --- a/BUILD.gn +++ b/BUILD.gn -@@ -3799,8 +3799,6 @@ if (current_toolchain == v8_generator_toolchain) { +@@ -3799,7 +3799,6 @@ if (current_toolchain == v8_generator_toolchain) { if (v8_use_snapshot && current_toolchain == v8_snapshot_toolchain) { v8_executable("mksnapshot") { - visibility = [ ":*" ] # Only targets in this file can depend on this. -- + sources = [ - "src/snapshot/embedded/embedded-file-writer.cc", - "src/snapshot/embedded/embedded-file-writer.h", + "src/diagnostics/crash-key-noop.cc", diff --git a/patches/v8/workaround_an_undefined_symbol_error.patch b/patches/v8/workaround_an_undefined_symbol_error.patch index 12f84182576f0..7a50e2c206533 100644 --- a/patches/v8/workaround_an_undefined_symbol_error.patch +++ b/patches/v8/workaround_an_undefined_symbol_error.patch @@ -12,10 +12,10 @@ By moving some functions out of the the arm64-assembler header file, this error no longer seems to happen. diff --git a/src/codegen/arm64/assembler-arm64.cc b/src/codegen/arm64/assembler-arm64.cc -index 1806f82b461a5f7368281bcd3741fd8195a20f11..53da75760ba31bed3e3cf19397474b353bc83fdf 100644 +index b8cdc44a4d18f39e5623c4173222923de35a09e7..b2b64d447de951729d730c47a608d84c5f70051d 100644 --- a/src/codegen/arm64/assembler-arm64.cc +++ b/src/codegen/arm64/assembler-arm64.cc -@@ -3786,6 +3786,22 @@ void Assembler::MoveWide(const Register& rd, uint64_t imm, int shift, +@@ -3563,6 +3563,22 @@ void Assembler::MoveWide(const Register& rd, uint64_t imm, int shift, ImmMoveWide(static_cast(imm)) | ShiftMoveWide(shift)); } @@ -39,10 +39,10 @@ index 1806f82b461a5f7368281bcd3741fd8195a20f11..53da75760ba31bed3e3cf19397474b35 const Operand& operand, FlagsUpdate S, AddSubOp op) { DCHECK_EQ(rd.SizeInBits(), rn.SizeInBits()); diff --git a/src/codegen/arm64/assembler-arm64.h b/src/codegen/arm64/assembler-arm64.h -index 04cd4222417f5ac88f3c5f3278c45f1d128c7c8c..fb5feb23074ac888e85a3676c1cbbb63126e72d5 100644 +index 6a6bf633c13ec6d94bbc145eae6daa9ce0d9b2ce..42a77d305b17ffaac6fd3f07c5290c1d61f31065 100644 --- a/src/codegen/arm64/assembler-arm64.h +++ b/src/codegen/arm64/assembler-arm64.h -@@ -2148,11 +2148,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { +@@ -2079,11 +2079,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { return rm.code() << Rm_offset; } @@ -55,7 +55,7 @@ index 04cd4222417f5ac88f3c5f3278c45f1d128c7c8c..fb5feb23074ac888e85a3676c1cbbb63 static Instr Ra(CPURegister ra) { DCHECK_NE(ra.code(), kSPRegInternalCode); -@@ -2176,15 +2172,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { +@@ -2107,15 +2103,8 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase { // These encoding functions allow the stack pointer to be encoded, and // disallow the zero register. diff --git a/script/zip_manifests/dist_zip.linux.arm.manifest b/script/zip_manifests/dist_zip.linux.arm.manifest index 7a94c75a7fca4..c4eef9b3dce04 100644 --- a/script/zip_manifests/dist_zip.linux.arm.manifest +++ b/script/zip_manifests/dist_zip.linux.arm.manifest @@ -65,5 +65,8 @@ natives_blob.bin resources.pak resources/default_app.asar snapshot_blob.bin +swiftshader/libEGL.so +swiftshader/libGLESv2.so +swiftshader/libvulkan.so v8_context_snapshot.bin version diff --git a/script/zip_manifests/dist_zip.linux.arm64.manifest b/script/zip_manifests/dist_zip.linux.arm64.manifest index 47c31df6b9e4c..c4eef9b3dce04 100644 --- a/script/zip_manifests/dist_zip.linux.arm64.manifest +++ b/script/zip_manifests/dist_zip.linux.arm64.manifest @@ -67,5 +67,6 @@ resources/default_app.asar snapshot_blob.bin swiftshader/libEGL.so swiftshader/libGLESv2.so +swiftshader/libvulkan.so v8_context_snapshot.bin version diff --git a/script/zip_manifests/dist_zip.linux.x64.manifest b/script/zip_manifests/dist_zip.linux.x64.manifest index 47c31df6b9e4c..c4eef9b3dce04 100644 --- a/script/zip_manifests/dist_zip.linux.x64.manifest +++ b/script/zip_manifests/dist_zip.linux.x64.manifest @@ -67,5 +67,6 @@ resources/default_app.asar snapshot_blob.bin swiftshader/libEGL.so swiftshader/libGLESv2.so +swiftshader/libvulkan.so v8_context_snapshot.bin version diff --git a/script/zip_manifests/dist_zip.linux.x86.manifest b/script/zip_manifests/dist_zip.linux.x86.manifest index 47c31df6b9e4c..c4eef9b3dce04 100644 --- a/script/zip_manifests/dist_zip.linux.x86.manifest +++ b/script/zip_manifests/dist_zip.linux.x86.manifest @@ -67,5 +67,6 @@ resources/default_app.asar snapshot_blob.bin swiftshader/libEGL.so swiftshader/libGLESv2.so +swiftshader/libvulkan.so v8_context_snapshot.bin version diff --git a/script/zip_manifests/dist_zip.mac.x64.manifest b/script/zip_manifests/dist_zip.mac.x64.manifest index d9a2bbc11c96f..1f13f8385f070 100644 --- a/script/zip_manifests/dist_zip.mac.x64.manifest +++ b/script/zip_manifests/dist_zip.mac.x64.manifest @@ -136,6 +136,18 @@ Electron.app/Contents/Frameworks/Electron Helper.app/Contents/Info.plist Electron.app/Contents/Frameworks/Electron Helper.app/Contents/MacOS/ Electron.app/Contents/Frameworks/Electron Helper.app/Contents/MacOS/Electron Helper Electron.app/Contents/Frameworks/Electron Helper.app/Contents/PkgInfo +Electron.app/Contents/Frameworks/Electron Helper (Plugin).app/ +Electron.app/Contents/Frameworks/Electron Helper (Plugin).app/Contents/ +Electron.app/Contents/Frameworks/Electron Helper (Plugin).app/Contents/Info.plist +Electron.app/Contents/Frameworks/Electron Helper (Plugin).app/Contents/MacOS/ +Electron.app/Contents/Frameworks/Electron Helper (Plugin).app/Contents/MacOS/Electron Helper (Plugin) +Electron.app/Contents/Frameworks/Electron Helper (Plugin).app/Contents/PkgInfo +Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/ +Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/ +Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/Info.plist +Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/MacOS/ +Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/MacOS/Electron Helper (Renderer) +Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/PkgInfo Electron.app/Contents/Frameworks/Mantle.framework/ Electron.app/Contents/Frameworks/Mantle.framework/Headers Electron.app/Contents/Frameworks/Mantle.framework/Mantle diff --git a/script/zip_manifests/dist_zip.mac_mas.x64.manifest b/script/zip_manifests/dist_zip.mac_mas.x64.manifest index 4cb148c96670f..7555c63b8188e 100644 --- a/script/zip_manifests/dist_zip.mac_mas.x64.manifest +++ b/script/zip_manifests/dist_zip.mac_mas.x64.manifest @@ -135,6 +135,18 @@ Electron.app/Contents/Frameworks/Electron Helper.app/Contents/Info.plist Electron.app/Contents/Frameworks/Electron Helper.app/Contents/MacOS/ Electron.app/Contents/Frameworks/Electron Helper.app/Contents/MacOS/Electron Helper Electron.app/Contents/Frameworks/Electron Helper.app/Contents/PkgInfo +Electron.app/Contents/Frameworks/Electron Helper (Plugin).app/ +Electron.app/Contents/Frameworks/Electron Helper (Plugin).app/Contents/ +Electron.app/Contents/Frameworks/Electron Helper (Plugin).app/Contents/Info.plist +Electron.app/Contents/Frameworks/Electron Helper (Plugin).app/Contents/MacOS/ +Electron.app/Contents/Frameworks/Electron Helper (Plugin).app/Contents/MacOS/Electron Helper (Plugin) +Electron.app/Contents/Frameworks/Electron Helper (Plugin).app/Contents/PkgInfo +Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/ +Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/ +Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/Info.plist +Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/MacOS/ +Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/MacOS/Electron Helper (Renderer) +Electron.app/Contents/Frameworks/Electron Helper (Renderer).app/Contents/PkgInfo Electron.app/Contents/Info.plist Electron.app/Contents/Library/ Electron.app/Contents/Library/LoginItems/ diff --git a/shell/app/atom_content_client.cc b/shell/app/atom_content_client.cc index 296ee75737231..eaa88601172c2 100644 --- a/shell/app/atom_content_client.cc +++ b/shell/app/atom_content_client.cc @@ -177,24 +177,24 @@ AtomContentClient::AtomContentClient() {} AtomContentClient::~AtomContentClient() {} -base::string16 AtomContentClient::GetLocalizedString(int message_id) const { +base::string16 AtomContentClient::GetLocalizedString(int message_id) { return l10n_util::GetStringUTF16(message_id); } base::StringPiece AtomContentClient::GetDataResource( int resource_id, - ui::ScaleFactor scale_factor) const { + ui::ScaleFactor scale_factor) { return ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale( resource_id, scale_factor); } -gfx::Image& AtomContentClient::GetNativeImageNamed(int resource_id) const { +gfx::Image& AtomContentClient::GetNativeImageNamed(int resource_id) { return ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( resource_id); } base::RefCountedMemory* AtomContentClient::GetDataResourceBytes( - int resource_id) const { + int resource_id) { return ui::ResourceBundle::GetSharedInstance().LoadDataResourceBytes( resource_id); } @@ -268,7 +268,7 @@ void AtomContentClient::AddContentDecryptionModules( } } -bool AtomContentClient::IsDataResourceGzipped(int resource_id) const { +bool AtomContentClient::IsDataResourceGzipped(int resource_id) { return ui::ResourceBundle::GetSharedInstance().IsGzipped(resource_id); } diff --git a/shell/app/atom_content_client.h b/shell/app/atom_content_client.h index a56e5a552cb66..6882385ccf76f 100644 --- a/shell/app/atom_content_client.h +++ b/shell/app/atom_content_client.h @@ -20,18 +20,17 @@ class AtomContentClient : public content::ContentClient { protected: // content::ContentClient: - base::string16 GetLocalizedString(int message_id) const override; - base::StringPiece GetDataResource(int resource_id, - ui::ScaleFactor) const override; - gfx::Image& GetNativeImageNamed(int resource_id) const override; - base::RefCountedMemory* GetDataResourceBytes(int resource_id) const override; + base::string16 GetLocalizedString(int message_id) override; + base::StringPiece GetDataResource(int resource_id, ui::ScaleFactor) override; + gfx::Image& GetNativeImageNamed(int resource_id) override; + base::RefCountedMemory* GetDataResourceBytes(int resource_id) override; void AddAdditionalSchemes(Schemes* schemes) override; void AddPepperPlugins( std::vector* plugins) override; void AddContentDecryptionModules( std::vector* cdms, std::vector* cdm_host_file_paths) override; - bool IsDataResourceGzipped(int resource_id) const override; + bool IsDataResourceGzipped(int resource_id) override; private: DISALLOW_COPY_AND_ASSIGN(AtomContentClient); diff --git a/shell/app/atom_main_delegate_mac.mm b/shell/app/atom_main_delegate_mac.mm index 4ca4f634daedb..abf67879a2e78 100644 --- a/shell/app/atom_main_delegate_mac.mm +++ b/shell/app/atom_main_delegate_mac.mm @@ -13,6 +13,7 @@ #include "base/mac/scoped_nsautorelease_pool.h" #include "base/path_service.h" #include "base/strings/sys_string_conversions.h" +#include "content/common/mac_helpers.h" #include "content/public/common/content_paths.h" #include "shell/browser/mac/atom_application.h" #include "shell/common/application_info.h" @@ -28,10 +29,23 @@ base::FilePath GetHelperAppPath(const base::FilePath& frameworks_path, const std::string& name) { - return frameworks_path.Append(name + " Helper.app") + // Figure out what helper we are running + base::FilePath path; + base::PathService::Get(base::FILE_EXE, &path); + + std::string helper_name = "Helper"; + if (base::EndsWith(path.value(), content::kMacHelperSuffix_renderer, + base::CompareCase::SENSITIVE)) { + helper_name += content::kMacHelperSuffix_renderer; + } else if (base::EndsWith(path.value(), content::kMacHelperSuffix_plugin, + base::CompareCase::SENSITIVE)) { + helper_name += content::kMacHelperSuffix_plugin; + } + + return frameworks_path.Append(name + " " + helper_name + ".app") .Append("Contents") .Append("MacOS") - .Append(name + " Helper"); + .Append(name + " " + helper_name); } } // namespace diff --git a/shell/app/uv_task_runner.cc b/shell/app/uv_task_runner.cc index 8f7ea8498e7c3..c2d135ced68cb 100644 --- a/shell/app/uv_task_runner.cc +++ b/shell/app/uv_task_runner.cc @@ -43,7 +43,7 @@ bool UvTaskRunner::PostNonNestableDelayedTask(const base::Location& from_here, // static void UvTaskRunner::OnTimeout(uv_timer_t* timer) { UvTaskRunner* self = static_cast(timer->data); - if (!ContainsKey(self->tasks_, timer)) + if (!base::Contains(self->tasks_, timer)) return; std::move(self->tasks_[timer]).Run(); diff --git a/shell/browser/api/atom_api_app.cc b/shell/browser/api/atom_api_app.cc index 076f20f64e768..b4fcced61fd8a 100644 --- a/shell/browser/api/atom_api_app.cc +++ b/shell/browser/api/atom_api_app.cc @@ -737,7 +737,7 @@ void App::AllowCertificateError( callback.Run(content::CERTIFICATE_REQUEST_RESULT_TYPE_DENY); } -void App::SelectClientCertificate( +base::OnceClosure App::SelectClientCertificate( content::WebContents* web_contents, net::SSLCertRequestInfo* cert_request_info, net::ClientCertIdentityList identities, @@ -769,6 +769,7 @@ void App::SelectClientCertificate( std::move((*shared_identities)[0]), base::BindRepeating(&GotPrivateKey, shared_delegate, std::move(cert))); } + return base::OnceClosure(); } void App::OnGpuInfoUpdate() { diff --git a/shell/browser/api/atom_api_app.h b/shell/browser/api/atom_api_app.h index df07c14bf3636..89ccf45b31c17 100644 --- a/shell/browser/api/atom_api_app.h +++ b/shell/browser/api/atom_api_app.h @@ -123,7 +123,7 @@ class App : public AtomBrowserClient::Delegate, bool expired_previous_decision, const base::RepeatingCallback< void(content::CertificateRequestResultType)>& callback) override; - void SelectClientCertificate( + base::OnceClosure SelectClientCertificate( content::WebContents* web_contents, net::SSLCertRequestInfo* cert_request_info, net::ClientCertIdentityList client_certs, diff --git a/shell/browser/api/atom_api_global_shortcut.cc b/shell/browser/api/atom_api_global_shortcut.cc index 7cfc821ae21a6..6caaac152a99c 100644 --- a/shell/browser/api/atom_api_global_shortcut.cc +++ b/shell/browser/api/atom_api_global_shortcut.cc @@ -107,7 +107,7 @@ bool GlobalShortcut::Register(const ui::Accelerator& accelerator, } void GlobalShortcut::Unregister(const ui::Accelerator& accelerator) { - if (!ContainsKey(accelerator_callback_map_, accelerator)) + if (!base::Contains(accelerator_callback_map_, accelerator)) return; accelerator_callback_map_.erase(accelerator); @@ -123,7 +123,7 @@ void GlobalShortcut::UnregisterSome( } bool GlobalShortcut::IsRegistered(const ui::Accelerator& accelerator) { - return ContainsKey(accelerator_callback_map_, accelerator); + return base::Contains(accelerator_callback_map_, accelerator); } void GlobalShortcut::UnregisterAll() { diff --git a/shell/browser/api/atom_api_net_log.cc b/shell/browser/api/atom_api_net_log.cc index c27413455c900..2f1e55103c09b 100644 --- a/shell/browser/api/atom_api_net_log.cc +++ b/shell/browser/api/atom_api_net_log.cc @@ -78,9 +78,9 @@ v8::Local NetLog::StartLogging(mate::Arguments* args) { auto command_line_string = base::CommandLine::ForCurrentProcess()->GetCommandLineString(); auto channel_string = std::string("Electron " ELECTRON_VERSION); - base::Value custom_constants = base::Value::FromUniquePtrValue( - net_log::ChromeNetLog::GetPlatformConstants(command_line_string, - channel_string)); + base::Value custom_constants = + base::Value::FromUniquePtrValue(net_log::GetPlatformConstantsForNetLog( + command_line_string, channel_string)); auto* network_context = content::BrowserContext::GetDefaultStoragePartition(browser_context_) diff --git a/shell/browser/api/atom_api_power_monitor.cc b/shell/browser/api/atom_api_power_monitor.cc index 224e39c0ffc14..0ab483055d368 100644 --- a/shell/browser/api/atom_api_power_monitor.cc +++ b/shell/browser/api/atom_api_power_monitor.cc @@ -43,7 +43,7 @@ PowerMonitor::PowerMonitor(v8::Isolate* isolate) { Browser::Get()->SetShutdownHandler(base::BindRepeating( &PowerMonitor::ShouldShutdown, base::Unretained(this))); #endif - base::PowerMonitor::Get()->AddObserver(this); + base::PowerMonitor::AddObserver(this); Init(isolate); #if defined(OS_MACOSX) || defined(OS_WIN) InitPlatformSpecificMonitors(); @@ -51,7 +51,7 @@ PowerMonitor::PowerMonitor(v8::Isolate* isolate) { } PowerMonitor::~PowerMonitor() { - base::PowerMonitor::Get()->RemoveObserver(this); + base::PowerMonitor::RemoveObserver(this); } bool PowerMonitor::ShouldShutdown() { diff --git a/shell/browser/api/atom_api_protocol_ns.cc b/shell/browser/api/atom_api_protocol_ns.cc index 4489f12d279f9..b523a06728844 100644 --- a/shell/browser/api/atom_api_protocol_ns.cc +++ b/shell/browser/api/atom_api_protocol_ns.cc @@ -61,7 +61,7 @@ ProtocolError ProtocolNS::RegisterProtocol(ProtocolType type, const std::string& scheme, const ProtocolHandler& handler) { ProtocolError error = ProtocolError::OK; - if (!base::ContainsKey(handlers_, scheme)) + if (!base::Contains(handlers_, scheme)) handlers_[scheme] = std::make_pair(type, handler); else error = ProtocolError::REGISTERED; @@ -71,7 +71,7 @@ ProtocolError ProtocolNS::RegisterProtocol(ProtocolType type, void ProtocolNS::UnregisterProtocol(const std::string& scheme, mate::Arguments* args) { ProtocolError error = ProtocolError::OK; - if (base::ContainsKey(handlers_, scheme)) + if (base::Contains(handlers_, scheme)) handlers_.erase(scheme); else error = ProtocolError::NOT_REGISTERED; @@ -79,14 +79,14 @@ void ProtocolNS::UnregisterProtocol(const std::string& scheme, } bool ProtocolNS::IsProtocolRegistered(const std::string& scheme) { - return base::ContainsKey(handlers_, scheme); + return base::Contains(handlers_, scheme); } ProtocolError ProtocolNS::InterceptProtocol(ProtocolType type, const std::string& scheme, const ProtocolHandler& handler) { ProtocolError error = ProtocolError::OK; - if (!base::ContainsKey(intercept_handlers_, scheme)) + if (!base::Contains(intercept_handlers_, scheme)) intercept_handlers_[scheme] = std::make_pair(type, handler); else error = ProtocolError::INTERCEPTED; @@ -96,7 +96,7 @@ ProtocolError ProtocolNS::InterceptProtocol(ProtocolType type, void ProtocolNS::UninterceptProtocol(const std::string& scheme, mate::Arguments* args) { ProtocolError error = ProtocolError::OK; - if (base::ContainsKey(intercept_handlers_, scheme)) + if (base::Contains(intercept_handlers_, scheme)) intercept_handlers_.erase(scheme); else error = ProtocolError::NOT_INTERCEPTED; @@ -104,7 +104,7 @@ void ProtocolNS::UninterceptProtocol(const std::string& scheme, } bool ProtocolNS::IsProtocolIntercepted(const std::string& scheme) { - return base::ContainsKey(intercept_handlers_, scheme); + return base::Contains(intercept_handlers_, scheme); } v8::Local ProtocolNS::IsProtocolHandled(const std::string& scheme, @@ -126,7 +126,7 @@ v8::Local ProtocolNS::IsProtocolHandled(const std::string& scheme, // So we have to test against a hard-coded builtin schemes // list make it work with old code. We should deprecate this // API with the new |isProtocolRegistered| API. - base::ContainsValue(kBuiltinSchemes, scheme)); + base::Contains(kBuiltinSchemes, scheme)); return promise.GetHandle(); } diff --git a/shell/browser/api/atom_api_top_level_window.cc b/shell/browser/api/atom_api_top_level_window.cc index 8e93430979f2f..9aeab0821aec6 100644 --- a/shell/browser/api/atom_api_top_level_window.cc +++ b/shell/browser/api/atom_api_top_level_window.cc @@ -943,14 +943,14 @@ bool TopLevelWindow::HookWindowMessage(UINT message, } void TopLevelWindow::UnhookWindowMessage(UINT message) { - if (!ContainsKey(messages_callback_map_, message)) + if (!base::Contains(messages_callback_map_, message)) return; messages_callback_map_.erase(message); } bool TopLevelWindow::IsWindowMessageHooked(UINT message) { - return ContainsKey(messages_callback_map_, message); + return base::Contains(messages_callback_map_, message); } void TopLevelWindow::UnhookAllWindowMessages() { diff --git a/shell/browser/api/atom_api_web_contents.cc b/shell/browser/api/atom_api_web_contents.cc index ae85795e20bb2..1679e6b1e7b0b 100644 --- a/shell/browser/api/atom_api_web_contents.cc +++ b/shell/browser/api/atom_api_web_contents.cc @@ -757,7 +757,7 @@ void WebContents::FindReply(content::WebContents* web_contents, bool WebContents::CheckMediaAccessPermission( content::RenderFrameHost* render_frame_host, const GURL& security_origin, - blink::MediaStreamType type) { + blink::mojom::MediaStreamType type) { auto* web_contents = content::WebContents::FromRenderFrameHost(render_frame_host); auto* permission_helper = @@ -2080,7 +2080,7 @@ v8::Local WebContents::CapturePage(mate::Arguments* args) { void WebContents::OnCursorChange(const content::WebCursor& cursor) { const content::CursorInfo& info = cursor.info(); - if (info.type == blink::WebCursorInfo::kTypeCustom) { + if (info.type == ui::CursorType::kCustom) { Emit("cursor-changed", CursorTypeToString(info), gfx::Image::CreateFrom1xBitmap(info.custom_image), info.image_scale_factor, @@ -2157,7 +2157,7 @@ void WebContents::Invalidate() { } } -gfx::Size WebContents::GetSizeForNewRenderView(content::WebContents* wc) const { +gfx::Size WebContents::GetSizeForNewRenderView(content::WebContents* wc) { if (IsOffScreen() && wc == web_contents()) { auto* relay = NativeWindowRelay::FromWebContents(web_contents()); if (relay) { diff --git a/shell/browser/api/atom_api_web_contents.h b/shell/browser/api/atom_api_web_contents.h index ba5ef185b83d0..7f31652dabd52 100644 --- a/shell/browser/api/atom_api_web_contents.h +++ b/shell/browser/api/atom_api_web_contents.h @@ -262,7 +262,7 @@ class WebContents : public mate::TrackableObject, int GetFrameRate() const; #endif void Invalidate(); - gfx::Size GetSizeForNewRenderView(content::WebContents*) const override; + gfx::Size GetSizeForNewRenderView(content::WebContents*) override; // Methods for zoom handling. void SetZoomLevel(double level); @@ -399,7 +399,7 @@ class WebContents : public mate::TrackableObject, bool final_update) override; bool CheckMediaAccessPermission(content::RenderFrameHost* render_frame_host, const GURL& security_origin, - blink::MediaStreamType type) override; + blink::mojom::MediaStreamType type) override; void RequestMediaAccessPermission( content::WebContents* web_contents, const content::MediaStreamRequest& request, diff --git a/shell/browser/api/views/atom_api_box_layout.cc b/shell/browser/api/views/atom_api_box_layout.cc index d7f8a44156f69..23b4474bf910b 100644 --- a/shell/browser/api/views/atom_api_box_layout.cc +++ b/shell/browser/api/views/atom_api_box_layout.cc @@ -22,9 +22,9 @@ struct Converter { if (!ConvertFromV8(isolate, val, &orientation)) return false; if (orientation == "horizontal") - *out = views::BoxLayout::kHorizontal; + *out = views::BoxLayout::Orientation::kHorizontal; else if (orientation == "vertical") - *out = views::BoxLayout::kVertical; + *out = views::BoxLayout::Orientation::kVertical; else return false; return true; diff --git a/shell/browser/atom_browser_client.cc b/shell/browser/atom_browser_client.cc index 678c03a526a55..047ab0166bed2 100644 --- a/shell/browser/atom_browser_client.cc +++ b/shell/browser/atom_browser_client.cc @@ -114,6 +114,11 @@ #include "chrome/browser/printing/printing_message_filter.h" #endif // BUILDFLAG(ENABLE_PRINTING) +#if defined(OS_MACOSX) +#include "content/common/mac_helpers.h" +#include "content/public/common/child_process_host.h" +#endif + using content::BrowserThread; namespace electron { @@ -182,7 +187,7 @@ content::WebContents* AtomBrowserClient::GetWebContentsFromProcessID( int process_id) { // If the process is a pending process, we should use the web contents // for the frame host passed into RegisterPendingProcess. - if (base::ContainsKey(pending_processes_, process_id)) + if (base::Contains(pending_processes_, process_id)) return pending_processes_[process_id]; // Certain render process will be created with no associated render view, @@ -328,7 +333,7 @@ void AtomBrowserClient::ConsiderSiteInstanceForAffinity( } bool AtomBrowserClient::IsRendererSubFrame(int process_id) const { - return base::ContainsKey(renderer_is_subframe_, process_id); + return base::Contains(renderer_is_subframe_, process_id); } void AtomBrowserClient::RenderProcessWillLaunch( @@ -480,7 +485,17 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches( // Make sure we're about to launch a known executable { base::FilePath child_path; +#if defined(OS_MACOSX) + int flags = content::ChildProcessHost::CHILD_NORMAL; + if (base::EndsWith(command_line->GetProgram().value(), + content::kMacHelperSuffix_renderer, + base::CompareCase::SENSITIVE)) { + flags = content::ChildProcessHost::CHILD_RENDERER; + } + child_path = content::ChildProcessHost::GetChildPath(flags); +#else base::PathService::Get(content::CHILD_PROCESS_EXE, &child_path); +#endif base::ThreadRestrictions::ScopedAllowIO allow_io; CHECK(base::MakeAbsoluteFilePath(command_line->GetProgram()) == child_path); @@ -591,7 +606,7 @@ void AtomBrowserClient::AllowCertificateError( } } -void AtomBrowserClient::SelectClientCertificate( +base::OnceClosure AtomBrowserClient::SelectClientCertificate( content::WebContents* web_contents, net::SSLCertRequestInfo* cert_request_info, net::ClientCertIdentityList client_certs, @@ -601,6 +616,7 @@ void AtomBrowserClient::SelectClientCertificate( std::move(client_certs), std::move(delegate)); } + return base::OnceClosure(); } bool AtomBrowserClient::CanCreateWindow( @@ -729,10 +745,6 @@ AtomBrowserClient::GetExtraServiceManifests() { return GetElectronBuiltinServiceManifests(); } -net::NetLog* AtomBrowserClient::GetNetLog() { - return g_browser_process->net_log(); -} - std::unique_ptr AtomBrowserClient::CreateBrowserMainParts( const content::MainFunctionParams& params) { @@ -907,11 +919,11 @@ bool AtomBrowserClient::ShouldBypassCORB(int render_process_id) const { return it != process_preferences_.end() && !it->second.web_security; } -std::string AtomBrowserClient::GetProduct() const { +std::string AtomBrowserClient::GetProduct() { return "Chrome/" CHROME_VERSION_STRING; } -std::string AtomBrowserClient::GetUserAgent() const { +std::string AtomBrowserClient::GetUserAgent() { if (user_agent_override_.empty()) return GetApplicationUserAgent(); return user_agent_override_; diff --git a/shell/browser/atom_browser_client.h b/shell/browser/atom_browser_client.h index 39af26f7a746a..26ca58d4efb2c 100644 --- a/shell/browser/atom_browser_client.h +++ b/shell/browser/atom_browser_client.h @@ -63,7 +63,7 @@ class AtomBrowserClient : public content::ContentBrowserClient, // content::ContentBrowserClient: bool ShouldEnableStrictSiteIsolation() override; - std::string GetUserAgent() const override; + std::string GetUserAgent() override; void SetUserAgent(const std::string& user_agent); void SetCanUseCustomSiteInstance(bool should_disable); @@ -109,7 +109,7 @@ class AtomBrowserClient : public content::ContentBrowserClient, bool expired_previous_decision, const base::Callback& callback) override; - void SelectClientCertificate( + base::OnceClosure SelectClientCertificate( content::WebContents* web_contents, net::SSLCertRequestInfo* cert_request_info, net::ClientCertIdentityList client_certs, @@ -146,7 +146,6 @@ class AtomBrowserClient : public content::ContentBrowserClient, base::Optional GetServiceManifestOverlay( base::StringPiece name) override; std::vector GetExtraServiceManifests() override; - net::NetLog* GetNetLog() override; content::MediaObserver* GetMediaObserver() override; content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override; content::PlatformNotificationService* GetPlatformNotificationService( @@ -160,7 +159,7 @@ class AtomBrowserClient : public content::ContentBrowserClient, network::mojom::NetworkService* network_service) override; std::vector GetNetworkContextsParentDirectory() override; bool ShouldBypassCORB(int render_process_id) const override; - std::string GetProduct() const override; + std::string GetProduct() override; void RegisterNonNetworkNavigationURLLoaderFactories( int frame_tree_node_id, NonNetworkURLLoaderFactoryMap* factories) override; diff --git a/shell/browser/atom_browser_context.cc b/shell/browser/atom_browser_context.cc index bfbfd26a621d7..d165f593e0bfa 100644 --- a/shell/browser/atom_browser_context.cc +++ b/shell/browser/atom_browser_context.cc @@ -196,11 +196,11 @@ network::mojom::NetworkContextPtr AtomBrowserContext::GetNetworkContext() { } } -base::FilePath AtomBrowserContext::GetPath() const { +base::FilePath AtomBrowserContext::GetPath() { return path_; } -bool AtomBrowserContext::IsOffTheRecord() const { +bool AtomBrowserContext::IsOffTheRecord() { return in_memory_; } @@ -305,24 +305,6 @@ AtomBrowserContext::GetClientHintsControllerDelegate() { return nullptr; } -net::URLRequestContextGetter* -AtomBrowserContext::CreateRequestContextForStoragePartition( - const base::FilePath& partition_path, - bool in_memory, - content::ProtocolHandlerMap* protocol_handlers, - content::URLRequestInterceptorScopedVector request_interceptors) { - NOTREACHED(); - return nullptr; -} - -net::URLRequestContextGetter* -AtomBrowserContext::CreateMediaRequestContextForStoragePartition( - const base::FilePath& partition_path, - bool in_memory) { - NOTREACHED(); - return nullptr; -} - ResolveProxyHelper* AtomBrowserContext::GetResolveProxyHelper() { if (!resolve_proxy_helper_) { resolve_proxy_helper_ = base::MakeRefCounted(this); diff --git a/shell/browser/atom_browser_context.h b/shell/browser/atom_browser_context.h index fa0ce734fa7dc..322e1cc7389db 100644 --- a/shell/browser/atom_browser_context.h +++ b/shell/browser/atom_browser_context.h @@ -60,8 +60,8 @@ class AtomBrowserContext ResolveProxyHelper* GetResolveProxyHelper(); // content::BrowserContext: - base::FilePath GetPath() const override; - bool IsOffTheRecord() const override; + base::FilePath GetPath() override; + bool IsOffTheRecord() override; content::ResourceContext* GetResourceContext() override; std::unique_ptr CreateZoomLevelDelegate( const base::FilePath& partition_path) override; @@ -71,14 +71,6 @@ class AtomBrowserContext content::BackgroundSyncController* GetBackgroundSyncController() override; content::BrowsingDataRemoverDelegate* GetBrowsingDataRemoverDelegate() override; - net::URLRequestContextGetter* CreateRequestContextForStoragePartition( - const base::FilePath& partition_path, - bool in_memory, - content::ProtocolHandlerMap* protocol_handlers, - content::URLRequestInterceptorScopedVector request_interceptors) override; - net::URLRequestContextGetter* CreateMediaRequestContextForStoragePartition( - const base::FilePath& partition_path, - bool in_memory) override; std::string GetMediaDeviceIDSalt() override; content::DownloadManagerDelegate* GetDownloadManagerDelegate() override; content::BrowserPluginGuestManager* GetGuestManager() override; diff --git a/shell/browser/atom_browser_main_parts.cc b/shell/browser/atom_browser_main_parts.cc index 81e52ab230dfb..b3bbd3fa6e6cf 100644 --- a/shell/browser/atom_browser_main_parts.cc +++ b/shell/browser/atom_browser_main_parts.cc @@ -207,8 +207,7 @@ AtomBrowserMainParts::AtomBrowserMainParts( browser_(new Browser), node_bindings_( NodeBindings::Create(NodeBindings::BrowserEnvironment::BROWSER)), - electron_bindings_(new ElectronBindings(uv_default_loop())), - main_function_params_(params) { + electron_bindings_(new ElectronBindings(uv_default_loop())) { DCHECK(!self_) << "Cannot have two AtomBrowserMainParts"; self_ = this; // Register extension scheme as web safe scheme. @@ -339,7 +338,7 @@ int AtomBrowserMainParts::PreCreateThreads() { ui::InitIdleMonitor(); #endif - fake_browser_process_->PreCreateThreads(main_function_params_.command_line); + fake_browser_process_->PreCreateThreads(); return 0; } diff --git a/shell/browser/atom_browser_main_parts.h b/shell/browser/atom_browser_main_parts.h index bfa354b6c768b..9a15d94ae3d5a 100644 --- a/shell/browser/atom_browser_main_parts.h +++ b/shell/browser/atom_browser_main_parts.h @@ -71,6 +71,7 @@ class AtomBrowserMainParts : public content::BrowserMainParts { IconManager* GetIconManager(); Browser* browser() { return browser_.get(); } + BrowserProcessImpl* browser_process() { return fake_browser_process_.get(); } protected: // content::BrowserMainParts: @@ -134,8 +135,6 @@ class AtomBrowserMainParts : public content::BrowserMainParts { device::mojom::GeolocationControlPtr geolocation_control_; - const content::MainFunctionParams main_function_params_; - static AtomBrowserMainParts* self_; DISALLOW_COPY_AND_ASSIGN(AtomBrowserMainParts); diff --git a/shell/browser/atom_web_ui_controller_factory.cc b/shell/browser/atom_web_ui_controller_factory.cc index c810815163ba7..631fd328dc478 100644 --- a/shell/browser/atom_web_ui_controller_factory.cc +++ b/shell/browser/atom_web_ui_controller_factory.cc @@ -38,7 +38,7 @@ AtomWebUIControllerFactory::~AtomWebUIControllerFactory() {} content::WebUI::TypeID AtomWebUIControllerFactory::GetWebUIType( content::BrowserContext* browser_context, - const GURL& url) const { + const GURL& url) { #if BUILDFLAG(ENABLE_PDF_VIEWER) if (url.host() == kPdfViewerUIHost) { return const_cast(this); @@ -53,19 +53,19 @@ content::WebUI::TypeID AtomWebUIControllerFactory::GetWebUIType( bool AtomWebUIControllerFactory::UseWebUIForURL( content::BrowserContext* browser_context, - const GURL& url) const { + const GURL& url) { return GetWebUIType(browser_context, url) != content::WebUI::kNoWebUI; } bool AtomWebUIControllerFactory::UseWebUIBindingsForURL( content::BrowserContext* browser_context, - const GURL& url) const { + const GURL& url) { return UseWebUIForURL(browser_context, url); } std::unique_ptr AtomWebUIControllerFactory::CreateWebUIControllerForURL(content::WebUI* web_ui, - const GURL& url) const { + const GURL& url) { #if BUILDFLAG(ENABLE_PDF_VIEWER) if (url.host() == kPdfViewerUIHost) { base::StringPairs toplevel_params; diff --git a/shell/browser/atom_web_ui_controller_factory.h b/shell/browser/atom_web_ui_controller_factory.h index 6f52740e370d8..6a238595d38d4 100644 --- a/shell/browser/atom_web_ui_controller_factory.h +++ b/shell/browser/atom_web_ui_controller_factory.h @@ -23,14 +23,14 @@ class AtomWebUIControllerFactory : public content::WebUIControllerFactory { // content::WebUIControllerFactory: content::WebUI::TypeID GetWebUIType(content::BrowserContext* browser_context, - const GURL& url) const override; + const GURL& url) override; bool UseWebUIForURL(content::BrowserContext* browser_context, - const GURL& url) const override; + const GURL& url) override; bool UseWebUIBindingsForURL(content::BrowserContext* browser_context, - const GURL& url) const override; + const GURL& url) override; std::unique_ptr CreateWebUIControllerForURL( content::WebUI* web_ui, - const GURL& url) const override; + const GURL& url) override; private: friend struct base::DefaultSingletonTraits; diff --git a/shell/browser/browser_process_impl.cc b/shell/browser/browser_process_impl.cc index 1d182f986ab6c..633c09ef34c80 100644 --- a/shell/browser/browser_process_impl.cc +++ b/shell/browser/browser_process_impl.cc @@ -7,8 +7,6 @@ #include #include "chrome/common/chrome_switches.h" -#include "components/net_log/chrome_net_log.h" -#include "components/net_log/net_export_file_writer.h" #include "components/prefs/in_memory_pref_store.h" #include "components/prefs/overlay_user_pref_store.h" #include "components/prefs/pref_registry.h" @@ -18,7 +16,6 @@ #include "components/proxy_config/proxy_config_dictionary.h" #include "components/proxy_config/proxy_config_pref_names.h" #include "content/public/common/content_switches.h" -#include "net/log/net_log_capture_mode.h" #include "net/proxy_resolution/proxy_config.h" #include "net/proxy_resolution/proxy_config_service.h" #include "net/proxy_resolution/proxy_config_with_annotation.h" @@ -90,33 +87,16 @@ void BrowserProcessImpl::PostEarlyInitialization() { local_state_ = prefs_factory.Create(std::move(pref_registry)); } -void BrowserProcessImpl::PreCreateThreads( - const base::CommandLine& command_line) { +void BrowserProcessImpl::PreCreateThreads() { // Must be created before the IOThread. // Once IOThread class is no longer needed, // this can be created on first use. if (!SystemNetworkContextManager::GetInstance()) SystemNetworkContextManager::CreateInstance(local_state_.get()); - net_log_ = std::make_unique(); - // start net log trace if --log-net-log is passed in the command line. - if (command_line.HasSwitch(network::switches::kLogNetLog)) { - base::FilePath log_file = - command_line.GetSwitchValuePath(network::switches::kLogNetLog); - if (!log_file.empty()) { - net_log_->StartWritingToFile( - log_file, - net::GetNetCaptureModeFromCommandLine( - command_line, network::switches::kNetLogCaptureMode), - command_line.GetCommandLineString(), std::string()); - } - } - // Initialize net log file exporter. - system_network_context_manager()->GetNetExportFileWriter()->Initialize(); - // Manage global state of net and other IO thread related. - io_thread_ = std::make_unique( - net_log_.get(), SystemNetworkContextManager::GetInstance()); + io_thread_ = + std::make_unique(SystemNetworkContextManager::GetInstance()); } void BrowserProcessImpl::PostDestroyThreads() { @@ -157,10 +137,6 @@ PrefService* BrowserProcessImpl::local_state() { return local_state_.get(); } -net::URLRequestContextGetter* BrowserProcessImpl::system_request_context() { - return nullptr; -} - scoped_refptr BrowserProcessImpl::shared_url_loader_factory() { return system_network_context_manager()->GetSharedURLLoaderFactory(); @@ -187,11 +163,6 @@ NotificationPlatformBridge* BrowserProcessImpl::notification_platform_bridge() { return nullptr; } -IOThread* BrowserProcessImpl::io_thread() { - DCHECK(io_thread_.get()); - return io_thread_.get(); -} - SystemNetworkContextManager* BrowserProcessImpl::system_network_context_manager() { DCHECK(SystemNetworkContextManager::GetInstance()); @@ -273,11 +244,6 @@ BrowserProcessImpl::optimization_guide_service() { return nullptr; } -net_log::ChromeNetLog* BrowserProcessImpl::net_log() { - DCHECK(net_log_.get()); - return net_log_.get(); -} - component_updater::ComponentUpdateService* BrowserProcessImpl::component_updater() { return nullptr; diff --git a/shell/browser/browser_process_impl.h b/shell/browser/browser_process_impl.h index 23a4839578195..60f367d6e7ec2 100644 --- a/shell/browser/browser_process_impl.h +++ b/shell/browser/browser_process_impl.h @@ -23,10 +23,6 @@ #include "shell/browser/io_thread.h" #include "shell/browser/net/system_network_context_manager.h" -namespace net_log { -class ChromeNetLog; -} - namespace printing { class PrintJobManager; } @@ -44,7 +40,7 @@ class BrowserProcessImpl : public BrowserProcess { static void ApplyProxyModeFromCommandLine(ValueMapPrefStore* pref_store); void PostEarlyInitialization(); - void PreCreateThreads(const base::CommandLine& command_line); + void PreCreateThreads(); void PostDestroyThreads(); void PostMainMessageLoopRun(); @@ -58,7 +54,6 @@ class BrowserProcessImpl : public BrowserProcess { rappor::RapporServiceImpl* rappor_service() override; ProfileManager* profile_manager() override; PrefService* local_state() override; - net::URLRequestContextGetter* system_request_context() override; scoped_refptr shared_url_loader_factory() override; variations::VariationsService* variations_service() override; @@ -66,7 +61,6 @@ class BrowserProcessImpl : public BrowserProcess { extensions::EventRouterForwarder* extension_event_router_forwarder() override; NotificationUIManager* notification_ui_manager() override; NotificationPlatformBridge* notification_platform_bridge() override; - IOThread* io_thread() override; SystemNetworkContextManager* system_network_context_manager() override; network::NetworkQualityTracker* network_quality_tracker() override; WatchDogThread* watchdog_thread() override; @@ -89,7 +83,6 @@ class BrowserProcessImpl : public BrowserProcess { override; optimization_guide::OptimizationGuideService* optimization_guide_service() override; - net_log::ChromeNetLog* net_log() override; component_updater::ComponentUpdateService* component_updater() override; component_updater::SupervisedUserWhitelistInstaller* supervised_user_whitelist_installer() override; @@ -115,13 +108,14 @@ class BrowserProcessImpl : public BrowserProcess { printing::PrintJobManager* print_job_manager() override; StartupData* startup_data() override; + IOThread* io_thread() const { return io_thread_.get(); } + private: #if BUILDFLAG(ENABLE_PRINTING) std::unique_ptr print_job_manager_; #endif std::unique_ptr local_state_; std::unique_ptr io_thread_; - std::unique_ptr net_log_; std::string locale_; DISALLOW_COPY_AND_ASSIGN(BrowserProcessImpl); diff --git a/shell/browser/common_web_contents_delegate.cc b/shell/browser/common_web_contents_delegate.cc index 6b2b5413e93ab..ffaf692299abe 100644 --- a/shell/browser/common_web_contents_delegate.cc +++ b/shell/browser/common_web_contents_delegate.cc @@ -286,7 +286,7 @@ content::WebContents* CommonWebContentsDelegate::OpenURLFromTab( return source; } -bool CommonWebContentsDelegate::CanOverscrollContent() const { +bool CommonWebContentsDelegate::CanOverscrollContent() { return false; } @@ -343,7 +343,7 @@ void CommonWebContentsDelegate::ExitFullscreenModeForTab( } bool CommonWebContentsDelegate::IsFullscreenForTabOrPending( - const content::WebContents* source) const { + const content::WebContents* source) { return html_fullscreen_; } diff --git a/shell/browser/common_web_contents_delegate.h b/shell/browser/common_web_contents_delegate.h index ee33f78e00bb7..245655d14daab 100644 --- a/shell/browser/common_web_contents_delegate.h +++ b/shell/browser/common_web_contents_delegate.h @@ -81,7 +81,7 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate, content::WebContents* OpenURLFromTab( content::WebContents* source, const content::OpenURLParams& params) override; - bool CanOverscrollContent() const override; + bool CanOverscrollContent() override; content::ColorChooser* OpenColorChooser( content::WebContents* web_contents, SkColor color, @@ -98,8 +98,7 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate, const GURL& origin, const blink::WebFullscreenOptions& options) override; void ExitFullscreenModeForTab(content::WebContents* source) override; - bool IsFullscreenForTabOrPending( - const content::WebContents* source) const override; + bool IsFullscreenForTabOrPending(const content::WebContents* source) override; blink::WebSecurityStyle GetSecurityStyle( content::WebContents* web_contents, content::SecurityStyleExplanations* explanations) override; diff --git a/shell/browser/io_thread.cc b/shell/browser/io_thread.cc index 9e228fa933266..d2984d4eef91b 100644 --- a/shell/browser/io_thread.cc +++ b/shell/browser/io_thread.cc @@ -4,6 +4,7 @@ #include "shell/browser/io_thread.h" +#include #include #include "components/net_log/chrome_net_log.h" @@ -13,18 +14,46 @@ #include "net/cert/cert_verifier.h" #include "net/cert/cert_verify_proc.h" #include "net/cert/multi_threaded_cert_verifier.h" +#include "net/log/net_log_util.h" #include "net/proxy_resolution/proxy_resolution_service.h" #include "net/url_request/url_request_context.h" #include "services/network/network_service.h" #include "services/network/public/cpp/features.h" +#include "services/network/public/cpp/network_switches.h" +#include "services/network/public/mojom/net_log.mojom.h" #include "services/network/url_request_context_builder_mojo.h" #include "shell/browser/net/url_request_context_getter.h" using content::BrowserThread; -IOThread::IOThread(net_log::ChromeNetLog* net_log, - SystemNetworkContextManager* system_network_context_manager) - : net_log_(net_log) { +namespace { + +// Parses the desired granularity of NetLog capturing specified by the command +// line. +net::NetLogCaptureMode GetNetCaptureModeFromCommandLine( + const base::CommandLine& command_line) { + base::StringPiece switch_name = network::switches::kNetLogCaptureMode; + + if (command_line.HasSwitch(switch_name)) { + std::string value = command_line.GetSwitchValueASCII(switch_name); + + if (value == "Default") + return net::NetLogCaptureMode::Default(); + if (value == "IncludeCookiesAndCredentials") + return net::NetLogCaptureMode::IncludeCookiesAndCredentials(); + if (value == "IncludeSocketBytes") + return net::NetLogCaptureMode::IncludeSocketBytes(); + + LOG(ERROR) << "Unrecognized value for --" << switch_name; + } + + return net::NetLogCaptureMode::Default(); +} + +} // namespace + +IOThread::IOThread( + SystemNetworkContextManager* system_network_context_manager) { BrowserThread::SetIOThreadDelegate(this); system_network_context_manager->SetUp( @@ -74,6 +103,27 @@ void IOThread::Init() { network_service->ConfigureHttpAuthPrefs( std::move(http_auth_dynamic_params_)); + const base::CommandLine* command_line = + base::CommandLine::ForCurrentProcess(); + // start net log trace if --log-net-log is passed in the command line. + if (command_line->HasSwitch(network::switches::kLogNetLog)) { + base::FilePath log_file = + command_line->GetSwitchValuePath(network::switches::kLogNetLog); + base::File file(log_file, + base::File::FLAG_CREATE_ALWAYS | base::File::FLAG_WRITE); + if (log_file.empty() || !file.IsValid()) { + LOG(ERROR) << "Failed opening NetLog: " << log_file.value(); + } else { + auto platform_dict = net_log::GetPlatformConstantsForNetLog( + base::CommandLine::ForCurrentProcess()->GetCommandLineString(), + std::string(ELECTRON_PRODUCT_NAME)); + network_service->StartNetLog( + std::move(file), GetNetCaptureModeFromCommandLine(*command_line), + platform_dict ? std::move(*platform_dict) + : base::DictionaryValue()); + } + } + system_network_context_ = network_service->CreateNetworkContextWithBuilder( std::move(network_context_request_), std::move(network_context_params_), std::move(builder), &system_request_context_); @@ -91,7 +141,4 @@ void IOThread::CleanUp() { system_network_context_.reset(); } - - if (net_log_) - net_log_->ShutDownBeforeThreadPool(); } diff --git a/shell/browser/io_thread.h b/shell/browser/io_thread.h index 1c7865641ecf5..5f612d2f5f9c1 100644 --- a/shell/browser/io_thread.h +++ b/shell/browser/io_thread.h @@ -22,14 +22,9 @@ namespace net { class URLRequestContext; } -namespace net_log { -class ChromeNetLog; -} - class IOThread : public content::BrowserThreadDelegate { public: explicit IOThread( - net_log::ChromeNetLog* net_log, SystemNetworkContextManager* system_network_context_manager); ~IOThread() override; @@ -44,10 +39,6 @@ class IOThread : public content::BrowserThreadDelegate { void CleanUp() override; private: - // The NetLog is owned by the browser process, to allow logging from other - // threads during shutdown, but is used most frequently on the IOThread. - net_log::ChromeNetLog* net_log_; - // When the network service is disabled, this holds on to a // content::NetworkContext class that owns |system_request_context_|. std::unique_ptr system_network_context_; diff --git a/shell/browser/media/media_capture_devices_dispatcher.cc b/shell/browser/media/media_capture_devices_dispatcher.cc index 4df83dee3c685..b4e59031842f2 100644 --- a/shell/browser/media/media_capture_devices_dispatcher.cc +++ b/shell/browser/media/media_capture_devices_dispatcher.cc @@ -129,7 +129,7 @@ void MediaCaptureDevicesDispatcher::OnMediaRequestStateChanged( int render_view_id, int page_request_id, const GURL& security_origin, - blink::MediaStreamType stream_type, + blink::mojom::MediaStreamType stream_type, content::MediaRequestState state) {} void MediaCaptureDevicesDispatcher::OnCreatingAudioStream(int render_process_id, @@ -139,7 +139,7 @@ void MediaCaptureDevicesDispatcher::OnSetCapturingLinkSecured( int render_process_id, int render_frame_id, int page_request_id, - blink::MediaStreamType stream_type, + blink::mojom::MediaStreamType stream_type, bool is_secure) {} } // namespace electron diff --git a/shell/browser/media/media_capture_devices_dispatcher.h b/shell/browser/media/media_capture_devices_dispatcher.h index b32e7ed364acb..80410c1469efc 100644 --- a/shell/browser/media/media_capture_devices_dispatcher.h +++ b/shell/browser/media/media_capture_devices_dispatcher.h @@ -57,14 +57,14 @@ class MediaCaptureDevicesDispatcher : public content::MediaObserver { int render_view_id, int page_request_id, const GURL& security_origin, - blink::MediaStreamType stream_type, + blink::mojom::MediaStreamType stream_type, content::MediaRequestState state) override; void OnCreatingAudioStream(int render_process_id, int render_view_id) override; void OnSetCapturingLinkSecured(int render_process_id, int render_frame_id, int page_request_id, - blink::MediaStreamType stream_type, + blink::mojom::MediaStreamType stream_type, bool is_secure) override; private: diff --git a/shell/browser/media/media_stream_devices_controller.cc b/shell/browser/media/media_stream_devices_controller.cc index 0f7b6e4163e02..a646a52ae2ab4 100644 --- a/shell/browser/media/media_stream_devices_controller.cc +++ b/shell/browser/media/media_stream_devices_controller.cc @@ -34,10 +34,12 @@ MediaStreamDevicesController::MediaStreamDevicesController( // For MEDIA_OPEN_DEVICE requests (Pepper) we always request both webcam // and microphone to avoid popping two infobars. microphone_requested_( - request.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE || + request.audio_type == + blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE || request.request_type == blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY), webcam_requested_( - request.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE || + request.video_type == + blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE || request.request_type == blink::MEDIA_OPEN_DEVICE_PEPPER_ONLY) {} MediaStreamDevicesController::~MediaStreamDevicesController() { @@ -51,10 +53,14 @@ MediaStreamDevicesController::~MediaStreamDevicesController() { bool MediaStreamDevicesController::TakeAction() { // Do special handling of desktop screen cast. - if (request_.audio_type == blink::MEDIA_GUM_TAB_AUDIO_CAPTURE || - request_.video_type == blink::MEDIA_GUM_TAB_VIDEO_CAPTURE || - request_.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE || - request_.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) { + if (request_.audio_type == + blink::mojom::MediaStreamType::GUM_TAB_AUDIO_CAPTURE || + request_.video_type == + blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE || + request_.audio_type == + blink::mojom::MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE || + request_.video_type == + blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE) { HandleUserMediaRequest(); return true; } @@ -78,7 +84,8 @@ void MediaStreamDevicesController::Accept() { const blink::MediaStreamDevice* device = nullptr; // For open device request pick the desired device or fall back to the // first available of the given type. - if (request_.audio_type == blink::MEDIA_DEVICE_AUDIO_CAPTURE) { + if (request_.audio_type == + blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE) { device = MediaCaptureDevicesDispatcher::GetInstance() ->GetRequestedAudioDevice(request_.requested_audio_device_id); @@ -87,7 +94,8 @@ void MediaStreamDevicesController::Accept() { device = MediaCaptureDevicesDispatcher::GetInstance() ->GetFirstAvailableAudioDevice(); } - } else if (request_.video_type == blink::MEDIA_DEVICE_VIDEO_CAPTURE) { + } else if (request_.video_type == + blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE) { // Pepper API opens only one device at a time. device = MediaCaptureDevicesDispatcher::GetInstance() @@ -160,19 +168,24 @@ void MediaStreamDevicesController::Deny( void MediaStreamDevicesController::HandleUserMediaRequest() { blink::MediaStreamDevices devices; - if (request_.audio_type == blink::MEDIA_GUM_TAB_AUDIO_CAPTURE) { - devices.push_back( - blink::MediaStreamDevice(blink::MEDIA_GUM_TAB_AUDIO_CAPTURE, "", "")); + if (request_.audio_type == + blink::mojom::MediaStreamType::GUM_TAB_AUDIO_CAPTURE) { + devices.push_back(blink::MediaStreamDevice( + blink::mojom::MediaStreamType::GUM_TAB_AUDIO_CAPTURE, "", "")); } - if (request_.video_type == blink::MEDIA_GUM_TAB_VIDEO_CAPTURE) { - devices.push_back( - blink::MediaStreamDevice(blink::MEDIA_GUM_TAB_VIDEO_CAPTURE, "", "")); + if (request_.video_type == + blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE) { + devices.push_back(blink::MediaStreamDevice( + blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE, "", "")); } - if (request_.audio_type == blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE) { + if (request_.audio_type == + blink::mojom::MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE) { devices.push_back(blink::MediaStreamDevice( - blink::MEDIA_GUM_DESKTOP_AUDIO_CAPTURE, "loopback", "System Audio")); + blink::mojom::MediaStreamType::GUM_DESKTOP_AUDIO_CAPTURE, "loopback", + "System Audio")); } - if (request_.video_type == blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE) { + if (request_.video_type == + blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE) { content::DesktopMediaID screen_id; // If the device id wasn't specified then this is a screen capture request // (i.e. chooseDesktopMedia() API wasn't used to generate device id). @@ -184,9 +197,9 @@ void MediaStreamDevicesController::HandleUserMediaRequest() { content::DesktopMediaID::Parse(request_.requested_video_device_id); } - devices.push_back( - blink::MediaStreamDevice(blink::MEDIA_GUM_DESKTOP_VIDEO_CAPTURE, - screen_id.ToString(), "Screen")); + devices.push_back(blink::MediaStreamDevice( + blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE, + screen_id.ToString(), "Screen")); } std::move(callback_).Run( diff --git a/shell/browser/net/atom_network_delegate.cc b/shell/browser/net/atom_network_delegate.cc index 76515286d0775..b6e06e01e26c2 100644 --- a/shell/browser/net/atom_network_delegate.cc +++ b/shell/browser/net/atom_network_delegate.cc @@ -271,7 +271,7 @@ int AtomNetworkDelegate::OnBeforeURLRequest( net::URLRequest* request, net::CompletionOnceCallback callback, GURL* new_url) { - if (!base::ContainsKey(response_listeners_, kOnBeforeRequest)) { + if (!base::Contains(response_listeners_, kOnBeforeRequest)) { for (const auto& domain : ignore_connections_limit_domains_) { if (request->url().DomainIs(domain)) { // Allow unlimited concurrent connections. @@ -291,7 +291,7 @@ int AtomNetworkDelegate::OnBeforeStartTransaction( net::URLRequest* request, net::CompletionOnceCallback callback, net::HttpRequestHeaders* headers) { - if (!base::ContainsKey(response_listeners_, kOnBeforeSendHeaders)) + if (!base::Contains(response_listeners_, kOnBeforeSendHeaders)) return net::OK; return HandleResponseEvent(kOnBeforeSendHeaders, request, std::move(callback), @@ -301,7 +301,7 @@ int AtomNetworkDelegate::OnBeforeStartTransaction( void AtomNetworkDelegate::OnStartTransaction( net::URLRequest* request, const net::HttpRequestHeaders& headers) { - if (!base::ContainsKey(simple_listeners_, kOnSendHeaders)) + if (!base::Contains(simple_listeners_, kOnSendHeaders)) return; HandleSimpleEvent(kOnSendHeaders, request, headers); @@ -313,7 +313,7 @@ int AtomNetworkDelegate::OnHeadersReceived( const net::HttpResponseHeaders* original, scoped_refptr* override, GURL* allowed) { - if (!base::ContainsKey(response_listeners_, kOnHeadersReceived)) + if (!base::Contains(response_listeners_, kOnHeadersReceived)) return net::OK; return HandleResponseEvent( @@ -323,7 +323,7 @@ int AtomNetworkDelegate::OnHeadersReceived( void AtomNetworkDelegate::OnBeforeRedirect(net::URLRequest* request, const GURL& new_location) { - if (!base::ContainsKey(simple_listeners_, kOnBeforeRedirect)) + if (!base::Contains(simple_listeners_, kOnBeforeRedirect)) return; HandleSimpleEvent( @@ -333,7 +333,7 @@ void AtomNetworkDelegate::OnBeforeRedirect(net::URLRequest* request, void AtomNetworkDelegate::OnResponseStarted(net::URLRequest* request, int net_error) { - if (!base::ContainsKey(simple_listeners_, kOnResponseStarted)) + if (!base::Contains(simple_listeners_, kOnResponseStarted)) return; if (request->status().status() != net::URLRequestStatus::SUCCESS) @@ -363,7 +363,7 @@ void AtomNetworkDelegate::OnCompleted(net::URLRequest* request, return; } - if (!base::ContainsKey(simple_listeners_, kOnCompleted)) + if (!base::Contains(simple_listeners_, kOnCompleted)) return; HandleSimpleEvent(kOnCompleted, request, request->response_headers(), @@ -454,7 +454,7 @@ bool AtomNetworkDelegate::OnCanUseReportingClient(const url::Origin& origin, void AtomNetworkDelegate::OnErrorOccurred(net::URLRequest* request, bool started, int net_error) { - if (!base::ContainsKey(simple_listeners_, kOnErrorOccurred)) + if (!base::Contains(simple_listeners_, kOnErrorOccurred)) return; HandleSimpleEvent(kOnErrorOccurred, request, request->was_cached(), @@ -519,7 +519,7 @@ void AtomNetworkDelegate::OnListenerResultInIO( T out, std::unique_ptr response) { // The request has been destroyed. - if (!base::ContainsKey(callbacks_, id)) + if (!base::Contains(callbacks_, id)) return; ReadFromResponseObject(*response, out); diff --git a/shell/browser/net/atom_url_request_job_factory.cc b/shell/browser/net/atom_url_request_job_factory.cc index 55adf46d5eb39..918646270c155 100644 --- a/shell/browser/net/atom_url_request_job_factory.cc +++ b/shell/browser/net/atom_url_request_job_factory.cc @@ -53,7 +53,7 @@ bool AtomURLRequestJobFactory::SetProtocolHandler( return true; } - if (base::ContainsKey(protocol_handler_map_, scheme)) + if (base::Contains(protocol_handler_map_, scheme)) return false; protocol_handler_map_[scheme] = protocol_handler.release(); return true; @@ -62,8 +62,8 @@ bool AtomURLRequestJobFactory::SetProtocolHandler( bool AtomURLRequestJobFactory::InterceptProtocol( const std::string& scheme, std::unique_ptr protocol_handler) { - if (!base::ContainsKey(protocol_handler_map_, scheme) || - base::ContainsKey(original_protocols_, scheme)) + if (!base::Contains(protocol_handler_map_, scheme) || + base::Contains(original_protocols_, scheme)) return false; ProtocolHandler* original_protocol_handler = protocol_handler_map_[scheme]; protocol_handler_map_[scheme] = protocol_handler.release(); @@ -82,7 +82,7 @@ bool AtomURLRequestJobFactory::UninterceptProtocol(const std::string& scheme) { bool AtomURLRequestJobFactory::HasProtocolHandler( const std::string& scheme) const { - return base::ContainsKey(protocol_handler_map_, scheme); + return base::Contains(protocol_handler_map_, scheme); } void AtomURLRequestJobFactory::Clear() { diff --git a/shell/browser/net/system_network_context_manager.cc b/shell/browser/net/system_network_context_manager.cc index 6e22d700ff7ab..b5eb84eb1f15e 100644 --- a/shell/browser/net/system_network_context_manager.cc +++ b/shell/browser/net/system_network_context_manager.cc @@ -10,7 +10,6 @@ #include "base/command_line.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/net/chrome_mojo_proxy_resolver_factory.h" -#include "components/net_log/net_export_file_writer.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/network_service_instance.h" #include "content/public/common/content_features.h" @@ -158,14 +157,6 @@ SystemNetworkContextManager::GetSharedURLLoaderFactory() { return shared_url_loader_factory_; } -net_log::NetExportFileWriter* -SystemNetworkContextManager::GetNetExportFileWriter() { - if (!net_export_file_writer_) { - net_export_file_writer_ = std::make_unique(); - } - return net_export_file_writer_.get(); -} - network::mojom::NetworkContextParamsPtr SystemNetworkContextManager::CreateDefaultNetworkContextParams() { network::mojom::NetworkContextParamsPtr network_context_params = @@ -178,6 +169,10 @@ SystemNetworkContextManager::CreateDefaultNetworkContextParams() { network_context_params->proxy_resolver_factory = ChromeMojoProxyResolverFactory::CreateWithSelfOwnedReceiver(); +#if !BUILDFLAG(DISABLE_FTP_SUPPORT) + network_context_params->enable_ftp_url_support = true; +#endif + return network_context_params; } @@ -257,10 +252,6 @@ SystemNetworkContextManager::CreateNetworkContextParams() { network_context_params->http_cache_enabled = false; -#if !BUILDFLAG(DISABLE_FTP_SUPPORT) - network_context_params->enable_ftp_url_support = true; -#endif - network_context_params->primary_network_context = true; proxy_config_monitor_.AddToNetworkContextParams(network_context_params.get()); diff --git a/shell/browser/net/system_network_context_manager.h b/shell/browser/net/system_network_context_manager.h index b3e2616a1f6dd..e3cc85949c913 100644 --- a/shell/browser/net/system_network_context_manager.h +++ b/shell/browser/net/system_network_context_manager.h @@ -87,9 +87,6 @@ class SystemNetworkContextManager { // that is backed by the SystemNetworkContext. scoped_refptr GetSharedURLLoaderFactory(); - // Returns a shared global NetExportFileWriter instance. - net_log::NetExportFileWriter* GetNetExportFileWriter(); - // Called when content creates a NetworkService. Creates the // SystemNetworkContext, if the network service is enabled. void OnNetworkServiceCreated(network::mojom::NetworkService* network_service); @@ -119,9 +116,6 @@ class SystemNetworkContextManager { scoped_refptr shared_url_loader_factory_; network::mojom::URLLoaderFactoryPtr url_loader_factory_; - // Initialized on first access. - std::unique_ptr net_export_file_writer_; - DISALLOW_COPY_AND_ASSIGN(SystemNetworkContextManager); }; diff --git a/shell/browser/net/url_request_context_getter.cc b/shell/browser/net/url_request_context_getter.cc index 46279c23c27da..871bc92957427 100644 --- a/shell/browser/net/url_request_context_getter.cc +++ b/shell/browser/net/url_request_context_getter.cc @@ -41,6 +41,7 @@ #include "shell/browser/api/atom_api_protocol.h" #include "shell/browser/atom_browser_client.h" #include "shell/browser/atom_browser_context.h" +#include "shell/browser/atom_browser_main_parts.h" #include "shell/browser/browser_process_impl.h" #include "shell/browser/net/about_protocol_handler.h" #include "shell/browser/net/asar/asar_protocol_handler.h" @@ -100,8 +101,10 @@ void SetupAtomURLRequestJobFactory( #if !BUILDFLAG(DISABLE_FTP_SUPPORT) auto* host_resolver = url_request_context->host_resolver(); + auto* ftp_auth_cache = url_request_context->ftp_auth_cache(); job_factory->SetProtocolHandler( - url::kFtpScheme, net::FtpProtocolHandler::Create(host_resolver)); + url::kFtpScheme, + net::FtpProtocolHandler::Create(host_resolver, ftp_auth_cache)); #endif } @@ -128,13 +131,15 @@ URLRequestContextGetter::Handle::CreateMainRequestContextGetter( content::URLRequestInterceptorScopedVector protocol_interceptors) { DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK(!main_request_context_getter_.get()); - DCHECK(g_browser_process->io_thread()); + DCHECK(AtomBrowserMainParts::Get()->browser_process()->io_thread()); LazyInitialize(); main_request_context_getter_ = new URLRequestContextGetter( this, protocol_handlers, std::move(protocol_interceptors)); - g_browser_process->io_thread()->RegisterURLRequestContextGetter( - main_request_context_getter_.get()); + AtomBrowserMainParts::Get() + ->browser_process() + ->io_thread() + ->RegisterURLRequestContextGetter(main_request_context_getter_.get()); return main_request_context_getter_; } @@ -250,13 +255,16 @@ URLRequestContextGetter::~URLRequestContextGetter() { void URLRequestContextGetter::NotifyContextShuttingDown() { DCHECK_CURRENTLY_ON(BrowserThread::IO); - DCHECK(g_browser_process->io_thread()); + DCHECK(AtomBrowserMainParts::Get()->browser_process()->io_thread()); DCHECK(context_handle_); if (context_shutting_down_) return; - g_browser_process->io_thread()->DeregisterURLRequestContextGetter(this); + AtomBrowserMainParts::Get() + ->browser_process() + ->io_thread() + ->DeregisterURLRequestContextGetter(this); context_shutting_down_ = true; context_handle_->resource_context_.reset(); @@ -302,6 +310,11 @@ net::URLRequestContext* URLRequestContextGetter::GetURLRequestContext() { builder->set_ct_verifier(std::make_unique()); + // Enable FTP, we override it later in SetupAtomURLRequestJobFactory +#if !BUILDFLAG(DISABLE_FTP_SUPPORT) + builder->set_ftp_enabled(true); +#endif + auto* network_service = content::GetNetworkServiceImpl(); network_context_ = network_service->CreateNetworkContextWithBuilder( std::move(context_handle_->main_network_context_request_), diff --git a/shell/browser/osr/osr_host_display_client.cc b/shell/browser/osr/osr_host_display_client.cc index 3023240d9d182..219fb6c5971ef 100644 --- a/shell/browser/osr/osr_host_display_client.cc +++ b/shell/browser/osr/osr_host_display_client.cc @@ -35,9 +35,12 @@ void LayeredWindowUpdater::SetActive(bool active) { void LayeredWindowUpdater::OnAllocatedSharedMemory( const gfx::Size& pixel_size, - mojo::ScopedSharedBufferHandle scoped_buffer_handle) { + base::UnsafeSharedMemoryRegion region) { canvas_.reset(); + if (!region.IsValid()) + return; + // Make sure |pixel_size| is sane. size_t expected_bytes; bool size_result = viz::ResourceSizes::MaybeSizeInBytes( @@ -46,31 +49,11 @@ void LayeredWindowUpdater::OnAllocatedSharedMemory( return; #if defined(WIN32) - base::SharedMemoryHandle shm_handle; - size_t required_bytes; - MojoResult unwrap_result = mojo::UnwrapSharedMemoryHandle( - std::move(scoped_buffer_handle), &shm_handle, &required_bytes, nullptr); - if (unwrap_result != MOJO_RESULT_OK) - return; - - base::SharedMemory shm(shm_handle, false); - if (!shm.Map(required_bytes)) { - DLOG(ERROR) << "Failed to map " << required_bytes << " bytes"; - return; - } - canvas_ = skia::CreatePlatformCanvasWithSharedSection( - pixel_size.width(), pixel_size.height(), false, shm.handle().GetHandle(), - skia::CRASH_ON_FAILURE); + pixel_size.width(), pixel_size.height(), false, + region.GetPlatformHandle(), skia::CRASH_ON_FAILURE); #else - auto shm = - mojo::UnwrapWritableSharedMemoryRegion(std::move(scoped_buffer_handle)); - if (!shm.IsValid()) { - DLOG(ERROR) << "Failed to unwrap shared memory region"; - return; - } - - shm_mapping_ = shm.Map(); + shm_mapping_ = region.Map(); if (!shm_mapping_.IsValid()) { DLOG(ERROR) << "Failed to map shared memory region"; return; diff --git a/shell/browser/osr/osr_host_display_client.h b/shell/browser/osr/osr_host_display_client.h index 944756f55b732..82a7897109148 100644 --- a/shell/browser/osr/osr_host_display_client.h +++ b/shell/browser/osr/osr_host_display_client.h @@ -28,9 +28,8 @@ class LayeredWindowUpdater : public viz::mojom::LayeredWindowUpdater { void SetActive(bool active); // viz::mojom::LayeredWindowUpdater implementation. - void OnAllocatedSharedMemory( - const gfx::Size& pixel_size, - mojo::ScopedSharedBufferHandle scoped_buffer_handle) override; + void OnAllocatedSharedMemory(const gfx::Size& pixel_size, + base::UnsafeSharedMemoryRegion region) override; void Draw(const gfx::Rect& damage_rect, DrawCallback draw_callback) override; private: diff --git a/shell/browser/printing/print_preview_message_handler.cc b/shell/browser/printing/print_preview_message_handler.cc index 20d32a884c7e9..31df5cea40513 100644 --- a/shell/browser/printing/print_preview_message_handler.cc +++ b/shell/browser/printing/print_preview_message_handler.cc @@ -36,12 +36,12 @@ void StopWorker(int document_cookie) { return; scoped_refptr queue = g_browser_process->print_job_manager()->queue(); - scoped_refptr printer_query = + std::unique_ptr printer_query = queue->PopPrinterQuery(document_cookie); if (printer_query.get()) { - base::PostTaskWithTraits( - FROM_HERE, {BrowserThread::IO}, - base::BindOnce(&printing::PrinterQuery::StopWorker, printer_query)); + base::PostTaskWithTraits(FROM_HERE, {BrowserThread::IO}, + base::BindOnce(&printing::PrinterQuery::StopWorker, + std::move(printer_query))); } } @@ -113,7 +113,7 @@ void PrintPreviewMessageHandler::OnCompositePdfDocumentDone( base::ReadOnlySharedMemoryRegion region) { DCHECK_CURRENTLY_ON(BrowserThread::UI); - if (status != printing::mojom::PdfCompositor::Status::SUCCESS) { + if (status != printing::mojom::PdfCompositor::Status::kSuccess) { DLOG(ERROR) << "Compositing pdf failed with error " << status; RejectPromise(ids.request_id); return; diff --git a/shell/browser/ui/accelerator_util.cc b/shell/browser/ui/accelerator_util.cc index 692caf38baef8..2aa22f1717f94 100644 --- a/shell/browser/ui/accelerator_util.cc +++ b/shell/browser/ui/accelerator_util.cc @@ -89,7 +89,7 @@ void GenerateAcceleratorTable(AcceleratorTable* table, bool TriggerAcceleratorTableCommand(AcceleratorTable* table, const ui::Accelerator& accelerator) { - if (base::ContainsKey(*table, accelerator)) { + if (base::Contains(*table, accelerator)) { const accelerator_util::MenuItem& item = (*table)[accelerator]; if (item.model->IsEnabledAt(item.position)) { const auto event_flags = diff --git a/shell/browser/ui/atom_menu_model.cc b/shell/browser/ui/atom_menu_model.cc index 3551a6d80b0e5..423c6d40e1f9e 100644 --- a/shell/browser/ui/atom_menu_model.cc +++ b/shell/browser/ui/atom_menu_model.cc @@ -26,7 +26,7 @@ void AtomMenuModel::SetRole(int index, const base::string16& role) { base::string16 AtomMenuModel::GetRoleAt(int index) { int command_id = GetCommandIdAt(index); - if (base::ContainsKey(roles_, command_id)) + if (base::Contains(roles_, command_id)) return roles_[command_id]; else return base::string16(); diff --git a/shell/browser/ui/cocoa/atom_ns_window_delegate.mm b/shell/browser/ui/cocoa/atom_ns_window_delegate.mm index 371bfd2f13347..4b3bc69ddd21c 100644 --- a/shell/browser/ui/cocoa/atom_ns_window_delegate.mm +++ b/shell/browser/ui/cocoa/atom_ns_window_delegate.mm @@ -28,7 +28,7 @@ - (id)initWithShell:(electron::NativeWindowMac*)shell { // window delegate. auto* bridge_host = views::NativeWidgetMacNSWindowHost::GetFromNativeWindow( shell->GetNativeWindow()); - auto* bridged_view = bridge_host->bridge_impl(); + auto* bridged_view = bridge_host->GetInProcessNSWindowBridge(); if ((self = [super initWithBridgedNativeWidget:bridged_view])) { shell_ = shell; is_zooming_ = false; @@ -249,7 +249,7 @@ - (void)windowWillClose:(NSNotification*)notification { // has been closed. auto* bridge_host = views::NativeWidgetMacNSWindowHost::GetFromNativeWindow( shell_->GetNativeWindow()); - auto* bridged_view = bridge_host->bridge_impl(); + auto* bridged_view = bridge_host->GetInProcessNSWindowBridge(); bridged_view->OnWindowWillClose(); } diff --git a/shell/browser/ui/devtools_ui.cc b/shell/browser/ui/devtools_ui.cc index 7d8c4e6333a7e..b6c5e0fc9213f 100644 --- a/shell/browser/ui/devtools_ui.cc +++ b/shell/browser/ui/devtools_ui.cc @@ -58,7 +58,7 @@ class BundledDataSource : public content::URLDataSource { ~BundledDataSource() override {} // content::URLDataSource implementation. - std::string GetSource() const override { return kChromeUIDevToolsHost; } + std::string GetSource() override { return kChromeUIDevToolsHost; } void StartDataRequest( const std::string& path, @@ -78,15 +78,15 @@ class BundledDataSource : public content::URLDataSource { callback.Run(nullptr); } - std::string GetMimeType(const std::string& path) const override { + std::string GetMimeType(const std::string& path) override { return GetMimeTypeForPath(path); } - bool ShouldAddContentSecurityPolicy() const override { return false; } + bool ShouldAddContentSecurityPolicy() override { return false; } - bool ShouldDenyXFrameOptions() const override { return false; } + bool ShouldDenyXFrameOptions() override { return false; } - bool ShouldServeMimeTypeAsContentTypeHeader() const override { return true; } + bool ShouldServeMimeTypeAsContentTypeHeader() override { return true; } void StartBundledDataRequest(const std::string& path, const GotDataCallback& callback) { diff --git a/shell/browser/ui/tray_icon_gtk.cc b/shell/browser/ui/tray_icon_gtk.cc index 0fa6a21589a12..f9b9709f6549e 100644 --- a/shell/browser/ui/tray_icon_gtk.cc +++ b/shell/browser/ui/tray_icon_gtk.cc @@ -19,14 +19,14 @@ TrayIconGtk::~TrayIconGtk() {} void TrayIconGtk::SetImage(const gfx::Image& image) { if (icon_) { - icon_->SetImage(image.AsImageSkia()); + icon_->SetIcon(image.AsImageSkia()); return; } const auto toolTip = base::UTF8ToUTF16(GetApplicationName()); icon_ = views::LinuxUI::instance()->CreateLinuxStatusIcon( image.AsImageSkia(), toolTip, Browser::Get()->GetName().c_str()); - icon_->set_delegate(this); + icon_->SetDelegate(this); } void TrayIconGtk::SetToolTip(const std::string& tool_tip) { @@ -37,6 +37,23 @@ void TrayIconGtk::SetContextMenu(AtomMenuModel* menu_model) { icon_->UpdatePlatformContextMenu(menu_model); } +const gfx::ImageSkia& TrayIconGtk::GetImage() const { + NOTREACHED(); + return dummy_image_; +} + +const base::string16& TrayIconGtk::GetToolTip() const { + NOTREACHED(); + return dummy_string_; +} + +ui::MenuModel* TrayIconGtk::GetMenuModel() const { + NOTREACHED(); + return nullptr; +} + +void TrayIconGtk::OnImplInitializationFailed() {} + void TrayIconGtk::OnClick() { NotifyClicked(); } diff --git a/shell/browser/ui/tray_icon_gtk.h b/shell/browser/ui/tray_icon_gtk.h index 23af3e4ae989e..009ca88e675bb 100644 --- a/shell/browser/ui/tray_icon_gtk.h +++ b/shell/browser/ui/tray_icon_gtk.h @@ -27,13 +27,22 @@ class TrayIconGtk : public TrayIcon, public views::StatusIconLinux::Delegate { void SetToolTip(const std::string& tool_tip) override; void SetContextMenu(AtomMenuModel* menu_model) override; - private: - // views::StatusIconLinux::Delegate: + // views::StatusIconLinux::Delegate void OnClick() override; bool HasClickAction() override; + // The following four methods are only used by StatusIconLinuxDbus, which we + // aren't yet using, so they are given stub implementations. + const gfx::ImageSkia& GetImage() const override; + const base::string16& GetToolTip() const override; + ui::MenuModel* GetMenuModel() const override; + void OnImplInitializationFailed() override; + private: std::unique_ptr icon_; + gfx::ImageSkia dummy_image_; + base::string16 dummy_string_; + DISALLOW_COPY_AND_ASSIGN(TrayIconGtk); }; diff --git a/shell/browser/ui/views/menu_bar.cc b/shell/browser/ui/views/menu_bar.cc index ad261c37fef26..64a1ae832e43b 100644 --- a/shell/browser/ui/views/menu_bar.cc +++ b/shell/browser/ui/views/menu_bar.cc @@ -58,8 +58,8 @@ MenuBar::MenuBar(RootView* window) RefreshColorCache(); UpdateViewColors(); SetFocusBehavior(FocusBehavior::ALWAYS); - SetLayoutManager( - std::make_unique(views::BoxLayout::kHorizontal)); + SetLayoutManager(std::make_unique( + views::BoxLayout::Orientation::kHorizontal)); window_->GetFocusManager()->AddFocusChangeListener(color_updater_.get()); } diff --git a/shell/browser/ui/win/taskbar_host.cc b/shell/browser/ui/win/taskbar_host.cc index 6b9c26b0442c8..9b58a8e1d3c04 100644 --- a/shell/browser/ui/win/taskbar_host.cc +++ b/shell/browser/ui/win/taskbar_host.cc @@ -199,7 +199,7 @@ bool TaskbarHost::SetThumbnailToolTip(HWND window, const std::string& tooltip) { } bool TaskbarHost::HandleThumbarButtonEvent(int button_id) { - if (ContainsKey(callback_map_, button_id)) { + if (base::Contains(callback_map_, button_id)) { auto callback = callback_map_[button_id]; if (!callback.is_null()) callback.Run(); diff --git a/shell/browser/web_contents_permission_helper.cc b/shell/browser/web_contents_permission_helper.cc index 7ad26be8d3f08..5a40beac68a14 100644 --- a/shell/browser/web_contents_permission_helper.cc +++ b/shell/browser/web_contents_permission_helper.cc @@ -16,11 +16,11 @@ namespace { -std::string MediaStreamTypeToString(blink::MediaStreamType type) { +std::string MediaStreamTypeToString(blink::mojom::MediaStreamType type) { switch (type) { - case blink::MediaStreamType::MEDIA_DEVICE_AUDIO_CAPTURE: + case blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE: return "audio"; - case blink::MediaStreamType::MEDIA_DEVICE_VIDEO_CAPTURE: + case blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE: return "video"; default: return "unknown"; @@ -105,11 +105,11 @@ void WebContentsPermissionHelper::RequestMediaAccessPermission( base::DictionaryValue details; std::unique_ptr media_types(new base::ListValue); if (request.audio_type == - blink::MediaStreamType::MEDIA_DEVICE_AUDIO_CAPTURE) { + blink::mojom::MediaStreamType::DEVICE_AUDIO_CAPTURE) { media_types->AppendString("audio"); } if (request.video_type == - blink::MediaStreamType::MEDIA_DEVICE_VIDEO_CAPTURE) { + blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE) { media_types->AppendString("video"); } details.SetList("mediaTypes", std::move(media_types)); @@ -146,7 +146,7 @@ void WebContentsPermissionHelper::RequestOpenExternalPermission( bool WebContentsPermissionHelper::CheckMediaAccessPermission( const GURL& security_origin, - blink::MediaStreamType type) const { + blink::mojom::MediaStreamType type) const { base::DictionaryValue details; details.SetString("securityOrigin", security_origin.spec()); details.SetString("mediaType", MediaStreamTypeToString(type)); diff --git a/shell/browser/web_contents_permission_helper.h b/shell/browser/web_contents_permission_helper.h index 96c156f72c95d..9469bc7a1a975 100644 --- a/shell/browser/web_contents_permission_helper.h +++ b/shell/browser/web_contents_permission_helper.h @@ -37,7 +37,7 @@ class WebContentsPermissionHelper // Synchronous Checks bool CheckMediaAccessPermission(const GURL& security_origin, - blink::MediaStreamType type) const; + blink::mojom::MediaStreamType type) const; private: explicit WebContentsPermissionHelper(content::WebContents* web_contents); diff --git a/shell/browser/web_view_guest_delegate.cc b/shell/browser/web_view_guest_delegate.cc index 6e927d3836020..15284713ad487 100644 --- a/shell/browser/web_view_guest_delegate.cc +++ b/shell/browser/web_view_guest_delegate.cc @@ -61,7 +61,7 @@ void WebViewGuestDelegate::DidDetach() { ResetZoomController(); } -content::WebContents* WebViewGuestDelegate::GetOwnerWebContents() const { +content::WebContents* WebViewGuestDelegate::GetOwnerWebContents() { return embedder_web_contents_; } diff --git a/shell/browser/web_view_guest_delegate.h b/shell/browser/web_view_guest_delegate.h index fd3abd9b86d2d..ccf4b53c06365 100644 --- a/shell/browser/web_view_guest_delegate.h +++ b/shell/browser/web_view_guest_delegate.h @@ -28,7 +28,7 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate, protected: // content::BrowserPluginGuestDelegate: void DidDetach() final; - content::WebContents* GetOwnerWebContents() const final; + content::WebContents* GetOwnerWebContents() final; content::RenderWidgetHost* GetOwnerRenderWidgetHost() final; content::SiteInstance* GetOwnerSiteInstance() final; content::WebContents* CreateNewGuestWindow( diff --git a/shell/browser/web_view_manager.cc b/shell/browser/web_view_manager.cc index ad37d84e2bffa..baa297dd8bfff 100644 --- a/shell/browser/web_view_manager.cc +++ b/shell/browser/web_view_manager.cc @@ -28,7 +28,7 @@ void WebViewManager::AddGuest(int guest_instance_id, } void WebViewManager::RemoveGuest(int guest_instance_id) { - if (!base::ContainsKey(web_contents_embedder_map_, guest_instance_id)) + if (!base::Contains(web_contents_embedder_map_, guest_instance_id)) return; web_contents_embedder_map_.erase(guest_instance_id); @@ -42,7 +42,7 @@ void WebViewManager::RemoveGuest(int guest_instance_id) { } content::WebContents* WebViewManager::GetEmbedder(int guest_instance_id) { - if (base::ContainsKey(web_contents_embedder_map_, guest_instance_id)) + if (base::Contains(web_contents_embedder_map_, guest_instance_id)) return web_contents_embedder_map_[guest_instance_id].embedder; else return nullptr; @@ -52,11 +52,11 @@ content::WebContents* WebViewManager::GetGuestByInstanceID( int owner_process_id, int element_instance_id) { ElementInstanceKey key(owner_process_id, element_instance_id); - if (!base::ContainsKey(element_instance_id_to_guest_map_, key)) + if (!base::Contains(element_instance_id_to_guest_map_, key)) return nullptr; int guest_instance_id = element_instance_id_to_guest_map_[key]; - if (base::ContainsKey(web_contents_embedder_map_, guest_instance_id)) + if (base::Contains(web_contents_embedder_map_, guest_instance_id)) return web_contents_embedder_map_[guest_instance_id].web_contents; else return nullptr; diff --git a/shell/common/api/atom_api_clipboard.cc b/shell/common/api/atom_api_clipboard.cc index 6a49793852d83..9e19c7dee2e8f 100644 --- a/shell/common/api/atom_api_clipboard.cc +++ b/shell/common/api/atom_api_clipboard.cc @@ -21,9 +21,9 @@ namespace api { ui::ClipboardType Clipboard::GetClipboardType(mate::Arguments* args) { std::string type; if (args->GetNext(&type) && type == "selection") - return ui::CLIPBOARD_TYPE_SELECTION; + return ui::ClipboardType::kSelection; else - return ui::CLIPBOARD_TYPE_COPY_PASTE; + return ui::ClipboardType::kCopyPaste; } std::vector Clipboard::AvailableFormats(mate::Arguments* args) { diff --git a/shell/common/api/electron_bindings.cc b/shell/common/api/electron_bindings.cc index 1f2ae47c36c22..178ef19399f51 100644 --- a/shell/common/api/electron_bindings.cc +++ b/shell/common/api/electron_bindings.cc @@ -258,13 +258,11 @@ v8::Local ElectronBindings::GetProcessMemoryInfo( v8::Local ElectronBindings::GetBlinkMemoryInfo( v8::Isolate* isolate) { auto allocated = blink::ProcessHeap::TotalAllocatedObjectSize(); - auto marked = blink::ProcessHeap::TotalMarkedObjectSize(); auto total = blink::ProcessHeap::TotalAllocatedSpace(); mate::Dictionary dict = mate::Dictionary::CreateEmpty(isolate); dict.SetHidden("simple", true); dict.Set("allocated", static_cast(allocated >> 10)); - dict.Set("marked", static_cast(marked >> 10)); dict.Set("total", static_cast(total >> 10)); return dict.GetHandle(); } diff --git a/shell/common/asar/asar_util.cc b/shell/common/asar/asar_util.cc index 62f0b9bc125bc..e4a6cb9abc094 100644 --- a/shell/common/asar/asar_util.cc +++ b/shell/common/asar/asar_util.cc @@ -31,7 +31,7 @@ std::shared_ptr GetOrCreateAsarArchive(const base::FilePath& path) { if (!g_archive_map_tls.Pointer()->Get()) g_archive_map_tls.Pointer()->Set(new ArchiveMap); ArchiveMap& archive_map = *g_archive_map_tls.Pointer()->Get(); - if (!ContainsKey(archive_map, path)) { + if (!base::Contains(archive_map, path)) { std::shared_ptr archive(new Archive(path)); if (!archive->Init()) return nullptr; diff --git a/shell/common/mac/main_application_bundle.mm b/shell/common/mac/main_application_bundle.mm index b015b01e10658..73d3c302f5612 100644 --- a/shell/common/mac/main_application_bundle.mm +++ b/shell/common/mac/main_application_bundle.mm @@ -10,6 +10,7 @@ #include "base/mac/foundation_util.h" #include "base/path_service.h" #include "base/strings/string_util.h" +#include "content/common/mac_helpers.h" namespace electron { @@ -30,7 +31,11 @@ bool HasMainProcessKey() { // Up to Contents. if (!HasMainProcessKey() && - base::EndsWith(path.value(), " Helper", base::CompareCase::SENSITIVE)) { + (base::EndsWith(path.value(), " Helper", base::CompareCase::SENSITIVE) || + base::EndsWith(path.value(), content::kMacHelperSuffix_renderer, + base::CompareCase::SENSITIVE) || + base::EndsWith(path.value(), content::kMacHelperSuffix_plugin, + base::CompareCase::SENSITIVE))) { // The running executable is the helper. Go up five steps: // Contents/Frameworks/Helper.app/Contents/MacOS/Helper // ^ to here ^ from here diff --git a/shell/common/mouse_util.cc b/shell/common/mouse_util.cc index 73c6224a6f737..e2d85e4959f5e 100644 --- a/shell/common/mouse_util.cc +++ b/shell/common/mouse_util.cc @@ -5,99 +5,99 @@ #include "shell/common/mouse_util.h" #include -using Cursor = blink::WebCursorInfo::Type; +using Cursor = ui::CursorType; namespace electron { std::string CursorTypeToString(const content::CursorInfo& info) { switch (info.type) { - case Cursor::kTypePointer: + case Cursor::kPointer: return "default"; - case Cursor::kTypeCross: + case Cursor::kCross: return "crosshair"; - case Cursor::kTypeHand: + case Cursor::kHand: return "pointer"; - case Cursor::kTypeIBeam: + case Cursor::kIBeam: return "text"; - case Cursor::kTypeWait: + case Cursor::kWait: return "wait"; - case Cursor::kTypeHelp: + case Cursor::kHelp: return "help"; - case Cursor::kTypeEastResize: + case Cursor::kEastResize: return "e-resize"; - case Cursor::kTypeNorthResize: + case Cursor::kNorthResize: return "n-resize"; - case Cursor::kTypeNorthEastResize: + case Cursor::kNorthEastResize: return "ne-resize"; - case Cursor::kTypeNorthWestResize: + case Cursor::kNorthWestResize: return "nw-resize"; - case Cursor::kTypeSouthResize: + case Cursor::kSouthResize: return "s-resize"; - case Cursor::kTypeSouthEastResize: + case Cursor::kSouthEastResize: return "se-resize"; - case Cursor::kTypeSouthWestResize: + case Cursor::kSouthWestResize: return "sw-resize"; - case Cursor::kTypeWestResize: + case Cursor::kWestResize: return "w-resize"; - case Cursor::kTypeNorthSouthResize: + case Cursor::kNorthSouthResize: return "ns-resize"; - case Cursor::kTypeEastWestResize: + case Cursor::kEastWestResize: return "ew-resize"; - case Cursor::kTypeNorthEastSouthWestResize: + case Cursor::kNorthEastSouthWestResize: return "nesw-resize"; - case Cursor::kTypeNorthWestSouthEastResize: + case Cursor::kNorthWestSouthEastResize: return "nwse-resize"; - case Cursor::kTypeColumnResize: + case Cursor::kColumnResize: return "col-resize"; - case Cursor::kTypeRowResize: + case Cursor::kRowResize: return "row-resize"; - case Cursor::kTypeMiddlePanning: + case Cursor::kMiddlePanning: return "m-panning"; - case Cursor::kTypeEastPanning: + case Cursor::kEastPanning: return "e-panning"; - case Cursor::kTypeNorthPanning: + case Cursor::kNorthPanning: return "n-panning"; - case Cursor::kTypeNorthEastPanning: + case Cursor::kNorthEastPanning: return "ne-panning"; - case Cursor::kTypeNorthWestPanning: + case Cursor::kNorthWestPanning: return "nw-panning"; - case Cursor::kTypeSouthPanning: + case Cursor::kSouthPanning: return "s-panning"; - case Cursor::kTypeSouthEastPanning: + case Cursor::kSouthEastPanning: return "se-panning"; - case Cursor::kTypeSouthWestPanning: + case Cursor::kSouthWestPanning: return "sw-panning"; - case Cursor::kTypeWestPanning: + case Cursor::kWestPanning: return "w-panning"; - case Cursor::kTypeMove: + case Cursor::kMove: return "move"; - case Cursor::kTypeVerticalText: + case Cursor::kVerticalText: return "vertical-text"; - case Cursor::kTypeCell: + case Cursor::kCell: return "cell"; - case Cursor::kTypeContextMenu: + case Cursor::kContextMenu: return "context-menu"; - case Cursor::kTypeAlias: + case Cursor::kAlias: return "alias"; - case Cursor::kTypeProgress: + case Cursor::kProgress: return "progress"; - case Cursor::kTypeNoDrop: + case Cursor::kNoDrop: return "nodrop"; - case Cursor::kTypeCopy: + case Cursor::kCopy: return "copy"; - case Cursor::kTypeNone: + case Cursor::kNone: return "none"; - case Cursor::kTypeNotAllowed: + case Cursor::kNotAllowed: return "not-allowed"; - case Cursor::kTypeZoomIn: + case Cursor::kZoomIn: return "zoom-in"; - case Cursor::kTypeZoomOut: + case Cursor::kZoomOut: return "zoom-out"; - case Cursor::kTypeGrab: + case Cursor::kGrab: return "grab"; - case Cursor::kTypeGrabbing: + case Cursor::kGrabbing: return "grabbing"; - case Cursor::kTypeCustom: + case Cursor::kCustom: return "custom"; default: return "default"; diff --git a/shell/common/native_mate_converters/blink_converter.cc b/shell/common/native_mate_converters/blink_converter.cc index bd1feb2660196..590b6e9af5705 100644 --- a/shell/common/native_mate_converters/blink_converter.cc +++ b/shell/common/native_mate_converters/blink_converter.cc @@ -417,7 +417,7 @@ v8::Local EditFlagsToV8(v8::Isolate* isolate, int editFlags) { std::vector types; bool ignore; ui::Clipboard::GetForCurrentThread()->ReadAvailableTypes( - ui::CLIPBOARD_TYPE_COPY_PASTE, &types, &ignore); + ui::ClipboardType::kCopyPaste, &types, &ignore); pasteFlag = !types.empty(); } dict.Set("canPaste", pasteFlag); diff --git a/spec-main/api-browser-window-spec.ts b/spec-main/api-browser-window-spec.ts index 0335e1d0131c1..3346e09abd503 100644 --- a/spec-main/api-browser-window-spec.ts +++ b/spec-main/api-browser-window-spec.ts @@ -5,7 +5,7 @@ import * as fs from 'fs' import * as qs from 'querystring' import * as http from 'http' import { AddressInfo } from 'net' -import { app, BrowserWindow, ipcMain, OnBeforeSendHeadersListenerDetails, screen } from 'electron' +import { app, BrowserWindow, ipcMain, OnBeforeSendHeadersListenerDetails, screen, protocol } from 'electron' import { emittedOnce } from './events-helpers'; import { closeWindow } from './window-helpers'; @@ -214,6 +214,18 @@ describe('BrowserWindow module', () => { describe('BrowserWindow.loadURL(url)', () => { let w = null as unknown as BrowserWindow + const scheme = 'other' + const srcPath = path.join(fixtures, 'api', 'loaded-from-dataurl.js') + before((done) => { + protocol.registerFileProtocol(scheme, (request, callback) => { + callback(srcPath) + }, (error) => done(error)) + }) + + after(() => { + protocol.unregisterProtocol(scheme) + }) + beforeEach(() => { w = new BrowserWindow({show: false, webPreferences: {nodeIntegration: true}}) }) @@ -398,7 +410,7 @@ describe('BrowserWindow module', () => { expect(test).to.equal('test') done() }) - w.loadURL('data:text/html,', { baseURLForDataURL: `file://${path.join(fixtures, 'api')}${path.sep}` }) + w.loadURL('data:text/html,', { baseURLForDataURL: `other://${path.join(fixtures, 'api')}${path.sep}` }) }) }) diff --git a/spec-main/api-session-spec.js b/spec-main/api-session-spec.js index 7d73a3420574b..98a3f9226997d 100644 --- a/spec-main/api-session-spec.js +++ b/spec-main/api-session-spec.js @@ -812,11 +812,24 @@ describe('session module', () => { describe('ses.setPermissionRequestHandler(handler)', () => { it('cancels any pending requests when cleared', async () => { + if (w != null) w.destroy() + w = new BrowserWindow({ + show: false, + webPreferences: { + partition: `very-temp-permision-handler`, + nodeIntegration: true, + } + }) + const ses = w.webContents.session ses.setPermissionRequestHandler(() => { ses.setPermissionRequestHandler(null) }) + ses.protocol.interceptStringProtocol('https', (req, cb) => { + cb(``) + }) + const result = emittedOnce(require('electron').ipcMain, 'message') function remote() { @@ -825,7 +838,7 @@ describe('session module', () => { }); } - await w.loadURL(`data:text/html,`) + await w.loadURL('https://myfakesite') const [,name] = await result expect(name).to.deep.equal('SecurityError') diff --git a/spec/api-process-spec.js b/spec/api-process-spec.js index e9f873354403e..d49bbe3fff78b 100644 --- a/spec/api-process-spec.js +++ b/spec/api-process-spec.js @@ -42,7 +42,6 @@ describe('process module', () => { it('returns blink memory information object', () => { const heapStats = process.getBlinkMemoryInfo() expect(heapStats.allocated).to.be.a('number') - expect(heapStats.marked).to.be.a('number') expect(heapStats.total).to.be.a('number') }) }) diff --git a/spec/chromium-spec.js b/spec/chromium-spec.js index 9cea8388d18fa..950bf9b76b402 100644 --- a/spec/chromium-spec.js +++ b/spec/chromium-spec.js @@ -859,37 +859,40 @@ describe('chromium feature', () => { document.body.appendChild(webview) }) - it('SharedWorker can work', (done) => { - const worker = new SharedWorker('../fixtures/workers/shared_worker.js') - const message = 'ping' - worker.port.onmessage = (event) => { - expect(event.data).to.equal(message) - done() - } - worker.port.postMessage(message) - }) - - it('SharedWorker has no node integration by default', (done) => { - const worker = new SharedWorker('../fixtures/workers/shared_worker_node.js') - worker.port.onmessage = (event) => { - expect(event.data).to.equal('undefined undefined undefined undefined') - done() - } - }) + // FIXME: disabled during chromium update due to crash in content::WorkerScriptFetchInitiator::CreateScriptLoaderOnIO + xdescribe('SharedWorker', () => { + it('can work', (done) => { + const worker = new SharedWorker('../fixtures/workers/shared_worker.js') + const message = 'ping' + worker.port.onmessage = (event) => { + expect(event.data).to.equal(message) + done() + } + worker.port.postMessage(message) + }) - it('SharedWorker has node integration with nodeIntegrationInWorker', (done) => { - const webview = new WebView() - webview.addEventListener('console-message', (e) => { - console.log(e) + it('has no node integration by default', (done) => { + const worker = new SharedWorker('../fixtures/workers/shared_worker_node.js') + worker.port.onmessage = (event) => { + expect(event.data).to.equal('undefined undefined undefined undefined') + done() + } }) - webview.addEventListener('ipc-message', (e) => { - expect(e.channel).to.equal('object function object function') - webview.remove() - done() + + it('has node integration with nodeIntegrationInWorker', (done) => { + const webview = new WebView() + webview.addEventListener('console-message', (e) => { + console.log(e) + }) + webview.addEventListener('ipc-message', (e) => { + expect(e.channel).to.equal('object function object function') + webview.remove() + done() + }) + webview.src = `file://${fixtures}/pages/shared_worker.html` + webview.setAttribute('webpreferences', 'nodeIntegration, nodeIntegrationInWorker') + document.body.appendChild(webview) }) - webview.src = `file://${fixtures}/pages/shared_worker.html` - webview.setAttribute('webpreferences', 'nodeIntegration, nodeIntegrationInWorker') - document.body.appendChild(webview) }) }) diff --git a/spec/node-spec.js b/spec/node-spec.js index befab8e9e5037..318b47b87c8f5 100644 --- a/spec/node-spec.js +++ b/spec/node-spec.js @@ -382,7 +382,7 @@ describe('node feature', () => { function dataListener (data) { output += data - if (output.trim().startsWith('Debugger listening on ws://') && output.endsWith('\n')) { + if (output.trim().indexOf('Debugger listening on ws://') > -1 && output.indexOf('\n') > -1) { const socketMatch = output.trim().match(/(ws:\/\/.+:[0-9]+\/.+?)\n/gm) if (socketMatch && socketMatch[0]) { child.stderr.removeListener('data', dataListener) diff --git a/spec/webview-spec.js b/spec/webview-spec.js index c3acbb61295d8..c0b84572255cd 100644 --- a/spec/webview-spec.js +++ b/spec/webview-spec.js @@ -1427,7 +1427,9 @@ describe(' tag', function () { const generateSpecs = (description, sandbox) => { describe(description, () => { - it('emits resize events', async () => { + // TODO(nornagon): disabled during chromium roll 2019-06-11 due to a + // 'ResizeObserver loop limit exceeded' error on Windows + xit('emits resize events', async () => { const firstResizeSignal = waitForEvent(webview, 'resize') const domReadySignal = waitForEvent(webview, 'dom-ready') diff --git a/spec/yarn.lock b/spec/yarn.lock index 3b039e7c957cb..6c791870cb153 100644 --- a/spec/yarn.lock +++ b/spec/yarn.lock @@ -8,19 +8,19 @@ integrity sha512-ugvXJjwF5ldtUpa7D95kruNJ41yFQDEKyF5CW4TgKJnh+W/zmlBzXXeKTyqIgwMFrkePN2JqOBqcF0M0oOunow== abstract-socket@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/abstract-socket/-/abstract-socket-2.0.0.tgz#d83c93e7df30d27e23f3e82a763e7f5e78d916f9" - integrity sha1-2DyT598w0n4j8+gqdj5/XnjZFvk= + version "2.1.0" + resolved "https://registry.yarnpkg.com/abstract-socket/-/abstract-socket-2.1.0.tgz#a57193dbbf585991b0dc811d7b18e053ff846f8a" + integrity sha512-rZ3G6Eqkdi/9PzYu03Xt1QEZ9aHYTnUpxLyV5EtjM/06BCDzYORTAfmCRAL6jIj98YqVviKGgt1qXcFUsM4e0w== dependencies: bindings "^1.2.1" - nan "^2.0.9" + nan "^2.12.1" "abstract-socket@github:nornagon/node-abstractsocket#v8-compat": - version "2.0.0" - resolved "https://codeload.github.com/nornagon/node-abstractsocket/tar.gz/7d9c770f9ffef14373349034f8820ff059879845" + version "2.1.0" + resolved "https://codeload.github.com/nornagon/node-abstractsocket/tar.gz/10c40472a0132c14451d1d8e4fdf534b00dc3797" dependencies: bindings "^1.2.1" - nan "^2.0.9" + nan "^2.12.1" ansi-regex@^2.0.0: version "2.1.1" @@ -739,10 +739,10 @@ multiparty@^4.2.1: safe-buffer "5.1.2" uid-safe "2.1.5" -nan@2.x, nan@^2.0.9, nan@^2.2.1: - version "2.13.2" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.13.2.tgz#f51dc7ae66ba7d5d55e1e6d4d8092e802c9aefe7" - integrity sha512-TghvYc72wlMGMVMluVo9WRJc0mB8KxxF/gZ4YYFy7V2ZQX9l7rgbPg7vjS9mt6U5HXODVFVI2bOduCzwOMv/lw== +nan@2.x, nan@^2.12.1, nan@^2.2.1: + version "2.14.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.0.tgz#7818f722027b2459a86f0295d434d1fc2336c52c" + integrity sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg== nice-try@^1.0.4: version "1.0.5" diff --git a/vsts-arm-test-steps.yml b/vsts-arm-test-steps.yml index 6c2a2accf3d36..4154c12553ac3 100644 --- a/vsts-arm-test-steps.yml +++ b/vsts-arm-test-steps.yml @@ -74,6 +74,7 @@ steps: timeoutInMinutes: 10 env: ELECTRON_DISABLE_SANDBOX: 1 + ELECTRON_DISABLE_SECURITY_WARNINGS: 1 - bash: | cd src diff --git a/vsts-arm32v7.yml b/vsts-arm32v7.yml index 2da9b5c5e0250..ce476714c72e3 100644 --- a/vsts-arm32v7.yml +++ b/vsts-arm32v7.yml @@ -2,6 +2,7 @@ resources: containers: - container: arm32v7-test-container image: electronbuilds/arm32v7:0.0.2 + options: --shm-size 128m jobs: - job: Test_Arm32v7 diff --git a/vsts-arm64v8.yml b/vsts-arm64v8.yml index f9ae3718eded7..5dd8c5fe1905e 100644 --- a/vsts-arm64v8.yml +++ b/vsts-arm64v8.yml @@ -2,6 +2,7 @@ resources: containers: - container: arm64v8-test-container image: electronbuilds/arm64v8:0.0.4 + options: --shm-size 128m env: RUN_NATIVE_MKSNAPSHOT: true From 69ea0b4ebf896fc063a4c0eb76aa91c407053077 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Wed, 3 Jul 2019 17:05:45 +0200 Subject: [PATCH 33/46] fix: ignore non-absolute session preload script paths when sandboxed (#19066) --- lib/browser/rpc-server.js | 15 +++---- shell/browser/api/atom_api_web_contents.cc | 12 ++++-- shell/browser/api/atom_api_web_contents.h | 2 +- shell/browser/atom_browser_client.cc | 14 +++++- shell/browser/session_preferences.cc | 45 ++++++-------------- shell/browser/session_preferences.h | 8 +--- spec/api-browser-window-spec.js | 6 ++- spec/fixtures/api/preloads.html | 7 --- spec/fixtures/module/get-global-preload.js | 2 +- spec/fixtures/module/set-global-preload-3.js | 1 + 10 files changed, 47 insertions(+), 65 deletions(-) delete mode 100644 spec/fixtures/api/preloads.html create mode 100644 spec/fixtures/module/set-global-preload-3.js diff --git a/lib/browser/rpc-server.js b/lib/browser/rpc-server.js index af2f13ce23caf..19a7674f28f10 100644 --- a/lib/browser/rpc-server.js +++ b/lib/browser/rpc-server.js @@ -519,12 +519,10 @@ if (features.isDesktopCapturerEnabled()) { const getPreloadScript = async function (preloadPath) { let preloadSrc = null let preloadError = null - if (preloadPath) { - try { - preloadSrc = (await fs.promises.readFile(preloadPath)).toString() - } catch (err) { - preloadError = errorUtils.serialize(err) - } + try { + preloadSrc = (await fs.promises.readFile(preloadPath)).toString() + } catch (err) { + preloadError = errorUtils.serialize(err) } return { preloadPath, preloadSrc, preloadError } } @@ -532,10 +530,7 @@ const getPreloadScript = async function (preloadPath) { ipcMainUtils.handle('ELECTRON_GET_CONTENT_SCRIPTS', () => getContentScripts()) ipcMainUtils.handle('ELECTRON_BROWSER_SANDBOX_LOAD', async function (event) { - const preloadPaths = [ - ...(event.sender.session ? event.sender.session.getPreloads() : []), - event.sender._getPreloadPath() - ] + const preloadPaths = event.sender._getPreloadPaths() return { contentScripts: getContentScripts(), diff --git a/shell/browser/api/atom_api_web_contents.cc b/shell/browser/api/atom_api_web_contents.cc index 1679e6b1e7b0b..06a01900d6675 100644 --- a/shell/browser/api/atom_api_web_contents.cc +++ b/shell/browser/api/atom_api_web_contents.cc @@ -60,6 +60,7 @@ #include "shell/browser/lib/bluetooth_chooser.h" #include "shell/browser/native_window.h" #include "shell/browser/net/atom_network_delegate.h" +#include "shell/browser/session_preferences.h" #include "shell/browser/ui/drag_util.h" #include "shell/browser/ui/inspectable_web_contents.h" #include "shell/browser/ui/inspectable_web_contents_view.h" @@ -2206,14 +2207,17 @@ void WebContents::HideAutofillPopup() { CommonWebContentsDelegate::HideAutofillPopup(); } -v8::Local WebContents::GetPreloadPath(v8::Isolate* isolate) const { +std::vector WebContents::GetPreloadPaths() const { + auto result = SessionPreferences::GetValidPreloads(GetBrowserContext()); + if (auto* web_preferences = WebContentsPreferences::From(web_contents())) { base::FilePath::StringType preload; if (web_preferences->GetPreloadPath(&preload)) { - return mate::ConvertToV8(isolate, preload); + result.emplace_back(preload); } } - return v8::Null(isolate); + + return result; } v8::Local WebContents::GetWebPreferences( @@ -2437,7 +2441,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate, .SetMethod("setZoomFactor", &WebContents::SetZoomFactor) .SetMethod("getZoomFactor", &WebContents::GetZoomFactor) .SetMethod("getType", &WebContents::GetType) - .SetMethod("_getPreloadPath", &WebContents::GetPreloadPath) + .SetMethod("_getPreloadPaths", &WebContents::GetPreloadPaths) .SetMethod("getWebPreferences", &WebContents::GetWebPreferences) .SetMethod("getLastWebPreferences", &WebContents::GetLastWebPreferences) .SetMethod("_isRemoteModuleEnabled", &WebContents::IsRemoteModuleEnabled) diff --git a/shell/browser/api/atom_api_web_contents.h b/shell/browser/api/atom_api_web_contents.h index 7f31652dabd52..c9067a4b6b238 100644 --- a/shell/browser/api/atom_api_web_contents.h +++ b/shell/browser/api/atom_api_web_contents.h @@ -285,7 +285,7 @@ class WebContents : public mate::TrackableObject, const scoped_refptr& body); // Returns the preload script path of current WebContents. - v8::Local GetPreloadPath(v8::Isolate* isolate) const; + std::vector GetPreloadPaths() const; // Returns the web preferences of current WebContents. v8::Local GetWebPreferences(v8::Isolate* isolate) const; diff --git a/shell/browser/atom_browser_client.cc b/shell/browser/atom_browser_client.cc index 047ab0166bed2..11dea7624dfac 100644 --- a/shell/browser/atom_browser_client.cc +++ b/shell/browser/atom_browser_client.cc @@ -151,6 +151,12 @@ void SetApplicationLocaleOnIOThread(const std::string& locale) { g_io_thread_application_locale.Get() = locale; } +#if defined(OS_WIN) +const base::FilePath::StringPieceType kPathDelimiter = FILE_PATH_LITERAL(";"); +#else +const base::FilePath::StringPieceType kPathDelimiter = FILE_PATH_LITERAL(":"); +#endif + } // namespace // static @@ -539,8 +545,12 @@ void AtomBrowserClient::AppendExtraCommandLineSwitches( if (web_preferences) web_preferences->AppendCommandLineSwitches( command_line, IsRendererSubFrame(process_id)); - SessionPreferences::AppendExtraCommandLineSwitches( - web_contents->GetBrowserContext(), command_line); + auto preloads = + SessionPreferences::GetValidPreloads(web_contents->GetBrowserContext()); + if (!preloads.empty()) + command_line->AppendSwitchNative( + switches::kPreloadScripts, + base::JoinString(preloads, kPathDelimiter)); if (CanUseCustomSiteInstance()) { command_line->AppendSwitch( switches::kDisableElectronSiteInstanceOverrides); diff --git a/shell/browser/session_preferences.cc b/shell/browser/session_preferences.cc index eaa8498df0ee4..1aca5265e6147 100644 --- a/shell/browser/session_preferences.cc +++ b/shell/browser/session_preferences.cc @@ -4,22 +4,8 @@ #include "shell/browser/session_preferences.h" -#include "base/command_line.h" -#include "base/memory/ptr_util.h" -#include "shell/common/options_switches.h" - namespace electron { -namespace { - -#if defined(OS_WIN) -const base::FilePath::CharType kPathDelimiter = FILE_PATH_LITERAL(';'); -#else -const base::FilePath::CharType kPathDelimiter = FILE_PATH_LITERAL(':'); -#endif - -} // namespace - // static int SessionPreferences::kLocatorKey = 0; @@ -36,26 +22,21 @@ SessionPreferences* SessionPreferences::FromBrowserContext( } // static -void SessionPreferences::AppendExtraCommandLineSwitches( - content::BrowserContext* context, - base::CommandLine* command_line) { - SessionPreferences* self = FromBrowserContext(context); - if (!self) - return; - - base::FilePath::StringType preloads; - for (const auto& preload : self->preloads()) { - if (!base::FilePath(preload).IsAbsolute()) { - LOG(ERROR) << "preload script must have absolute path: " << preload; - continue; +std::vector SessionPreferences::GetValidPreloads( + content::BrowserContext* context) { + std::vector result; + + if (auto* self = FromBrowserContext(context)) { + for (const auto& preload : self->preloads()) { + if (base::FilePath(preload).IsAbsolute()) { + result.emplace_back(preload); + } else { + LOG(ERROR) << "preload script must have absolute path: " << preload; + } } - if (preloads.empty()) - preloads = preload; - else - preloads += kPathDelimiter + preload; } - if (!preloads.empty()) - command_line->AppendSwitchNative(switches::kPreloadScripts, preloads); + + return result; } } // namespace electron diff --git a/shell/browser/session_preferences.h b/shell/browser/session_preferences.h index 78cc52d37b9d6..914f9d7b440e2 100644 --- a/shell/browser/session_preferences.h +++ b/shell/browser/session_preferences.h @@ -11,18 +11,14 @@ #include "base/supports_user_data.h" #include "content/public/browser/browser_context.h" -namespace base { -class CommandLine; -} - namespace electron { class SessionPreferences : public base::SupportsUserData::Data { public: static SessionPreferences* FromBrowserContext( content::BrowserContext* context); - static void AppendExtraCommandLineSwitches(content::BrowserContext* context, - base::CommandLine* command_line); + static std::vector GetValidPreloads( + content::BrowserContext* context); explicit SessionPreferences(content::BrowserContext* context); ~SessionPreferences() override; diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index 8dd37d158b3ab..f4cbbda32d5af 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -545,7 +545,8 @@ describe('BrowserWindow module', () => { describe('session preload scripts', function () { const preloads = [ path.join(fixtures, 'module', 'set-global-preload-1.js'), - path.join(fixtures, 'module', 'set-global-preload-2.js') + path.join(fixtures, 'module', 'set-global-preload-2.js'), + path.relative(process.cwd(), path.join(fixtures, 'module', 'set-global-preload-3.js')) ] const defaultSession = session.defaultSession @@ -564,9 +565,10 @@ describe('BrowserWindow module', () => { const generateSpecs = (description, sandbox) => { describe(description, () => { it('loads the script before other scripts in window including normal preloads', function (done) { - ipcMain.once('vars', function (event, preload1, preload2) { + ipcMain.once('vars', function (event, preload1, preload2, preload3) { expect(preload1).to.equal('preload-1') expect(preload2).to.equal('preload-1-2') + expect(preload3).to.be.null() done() }) w.destroy() diff --git a/spec/fixtures/api/preloads.html b/spec/fixtures/api/preloads.html deleted file mode 100644 index f13510b1b2124..0000000000000 --- a/spec/fixtures/api/preloads.html +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/spec/fixtures/module/get-global-preload.js b/spec/fixtures/module/get-global-preload.js index 438397f37073d..c1010dd472b2b 100644 --- a/spec/fixtures/module/get-global-preload.js +++ b/spec/fixtures/module/get-global-preload.js @@ -1 +1 @@ -require('electron').ipcRenderer.send('vars', window.preload1, window.preload2) +require('electron').ipcRenderer.send('vars', window.preload1, window.preload2, window.preload3) diff --git a/spec/fixtures/module/set-global-preload-3.js b/spec/fixtures/module/set-global-preload-3.js new file mode 100644 index 0000000000000..9cfef949277ed --- /dev/null +++ b/spec/fixtures/module/set-global-preload-3.js @@ -0,0 +1 @@ +window.preload3 = window.preload2 + '-3' From de072c6ef59dc0ad1b9ac7df7f0180bcf9f7a906 Mon Sep 17 00:00:00 2001 From: Electron Bot Date: Wed, 3 Jul 2019 08:31:34 -0700 Subject: [PATCH 34/46] Bump v7.0.0-nightly.20190703 --- ELECTRON_VERSION | 2 +- package.json | 2 +- shell/browser/resources/win/atom.rc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ELECTRON_VERSION b/ELECTRON_VERSION index 8f80a896d468f..5d22ec1687c3d 100644 --- a/ELECTRON_VERSION +++ b/ELECTRON_VERSION @@ -1 +1 @@ -7.0.0-nightly.20190702 \ No newline at end of file +7.0.0-nightly.20190703 \ No newline at end of file diff --git a/package.json b/package.json index 0269e2587822b..b874947562198 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron", - "version": "7.0.0-nightly.20190702", + "version": "7.0.0-nightly.20190703", "repository": "https://github.com/electron/electron", "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS", "devDependencies": { diff --git a/shell/browser/resources/win/atom.rc b/shell/browser/resources/win/atom.rc index ccc88b118ff3b..8f756a5f46509 100644 --- a/shell/browser/resources/win/atom.rc +++ b/shell/browser/resources/win/atom.rc @@ -50,8 +50,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,0,0,20190702 - PRODUCTVERSION 7,0,0,20190702 + FILEVERSION 7,0,0,20190703 + PRODUCTVERSION 7,0,0,20190703 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L From 8782d06ed610e346f70862561aa033905c93a86c Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 3 Jul 2019 08:57:10 -0700 Subject: [PATCH 35/46] feat: convert webContents primitives to properties (#18998) * feat: convert webContents primitives to properties * address feedback from review --- docs/api/modernization/property-updates.md | 19 +++------ docs/api/web-contents.md | 47 ++++++++++++++++++++++ lib/browser/api/menu-item-roles.js | 8 ++-- lib/browser/api/web-contents.js | 7 ++++ shell/browser/api/atom_api_web_contents.cc | 30 +++++++++----- spec-main/api-session-spec.js | 14 ++++++- spec/api-browser-window-spec.js | 23 +++++++++++ spec/api-web-contents-spec.js | 45 ++++++++++++++------- spec/ts-smoke/electron/main.ts | 8 ++-- 9 files changed, 152 insertions(+), 49 deletions(-) diff --git a/docs/api/modernization/property-updates.md b/docs/api/modernization/property-updates.md index f75fdfdb95fdd..7df49c26a43f2 100644 --- a/docs/api/modernization/property-updates.md +++ b/docs/api/modernization/property-updates.md @@ -4,11 +4,6 @@ The Electron team is currently undergoing an initiative to convert separate gett ## Candidates -* `app` module - * `dock` - * `badge` -* `autoUpdater` module - * `feedUrl` * `BrowserWindow` * `fullscreen` * `simpleFullscreen` @@ -20,14 +15,6 @@ The Electron team is currently undergoing an initiative to convert separate gett * `visibleOnAllWorkspaces` * `crashReporter` module * `uploadToServer` -* `Session` module - * `preloads` -* `webContents` module - * `zoomFactor` - * `zoomLevel` - * `audioMuted` - * `userAgent` - * `frameRate` * `webFrame` modules * `zoomFactor` * `zoomLevel` @@ -58,3 +45,9 @@ The Electron team is currently undergoing an initiative to convert separate gett * `isMacTemplateImage` * `SystemPreferences` module * `appLevelAppearance` +* `webContents` module + * `audioMuted` + * `frameRate` + * `userAgent` + * `zoomFactor` + * `zoomLevel` diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index a1dd2a4c95dd1..bba6bd6e2b9c3 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -979,10 +979,14 @@ Returns `Boolean` - Whether the renderer process has crashed. Overrides the user agent for this web page. +**[Deprecated](modernization/property-updates.md)** + #### `contents.getUserAgent()` Returns `String` - The user agent for this web page. +**[Deprecated](modernization/property-updates.md)** + #### `contents.insertCSS(css)` * `css` String @@ -1049,10 +1053,14 @@ Ignore application menu shortcuts while this web contents is focused. Mute the audio on the current web page. +**[Deprecated](modernization/property-updates.md)** + #### `contents.isAudioMuted()` Returns `Boolean` - Whether this page has been muted. +**[Deprecated](modernization/property-updates.md)** + #### `contents.isCurrentlyAudible()` Returns `Boolean` - Whether audio is currently playing. @@ -1064,10 +1072,14 @@ Returns `Boolean` - Whether audio is currently playing. Changes the zoom factor to the specified factor. Zoom factor is zoom percent divided by 100, so 300% = 3.0. +**[Deprecated](modernization/property-updates.md)** + #### `contents.getZoomFactor()` Returns `Number` - the current zoom factor. +**[Deprecated](modernization/property-updates.md)** + #### `contents.setZoomLevel(level)` * `level` Number - Zoom level. @@ -1077,10 +1089,14 @@ increment above or below represents zooming 20% larger or smaller to default limits of 300% and 50% of original size, respectively. The formula for this is `scale := 1.2 ^ level`. +**[Deprecated](modernization/property-updates.md)** + #### `contents.getZoomLevel()` Returns `Number` - the current zoom level. +**[Deprecated](modernization/property-updates.md)** + #### `contents.setVisualZoomLevelLimits(minimumLevel, maximumLevel)` * `minimumLevel` Number @@ -1672,10 +1688,14 @@ Returns `Boolean` - If *offscreen rendering* is enabled returns whether it is cu If *offscreen rendering* is enabled sets the frame rate to the specified number. Only values between 1 and 60 are accepted. +**[Deprecated](modernization/property-updates.md)** + #### `contents.getFrameRate()` Returns `Integer` - If *offscreen rendering* is enabled returns the current frame rate. +**[Deprecated](modernization/property-updates.md)** + #### `contents.invalidate()` Schedules a full repaint of the window this web contents is in. @@ -1740,6 +1760,33 @@ Returns `String` - the type of the webContent. Can be `backgroundPage`, `window` ### Instance Properties +#### `contents.audioMuted` + +A `Boolean` property that determines whether this page is muted. + +#### `contents.userAgent` + +A `String` property that determines the user agent for this web page. + +#### `contents.zoomLevel` + +A `Number` property that determines the zoom level for this web contents. + +The original size is 0 and each increment above or below represents zooming 20% larger or smaller to default limits of 300% and 50% of original size, respectively. The formula for this is `scale := 1.2 ^ level`. + +#### `contents.zoomFactor` + +A `Number` property that determines the zoom factor for this web contents. + +The zoom factor is the zoom percent divided by 100, so 300% = 3.0. + +#### `contents.frameRate` + +An `Integer` property that sets the frame rate of the web contents to the specified number. +Only values between 1 and 60 are accepted. + +Only applicable if *offscreen rendering* is enabled. + #### `contents.id` A `Integer` representing the unique ID of this WebContents. diff --git a/lib/browser/api/menu-item-roles.js b/lib/browser/api/menu-item-roles.js index 447edd8ed164a..e9ad52daa2670 100644 --- a/lib/browser/api/menu-item-roles.js +++ b/lib/browser/api/menu-item-roles.js @@ -101,7 +101,7 @@ const roles = { accelerator: 'CommandOrControl+0', nonNativeMacOSRole: true, webContentsMethod: (webContents) => { - webContents.setZoomLevel(0) + webContents.zoomLevel = 0 } }, selectall: { @@ -156,8 +156,7 @@ const roles = { accelerator: 'CommandOrControl+Plus', nonNativeMacOSRole: true, webContentsMethod: (webContents) => { - const zoomLevel = webContents.getZoomLevel() - webContents.setZoomLevel(zoomLevel + 0.5) + webContents.zoomLevel += 0.5 } }, zoomout: { @@ -165,8 +164,7 @@ const roles = { accelerator: 'CommandOrControl+-', nonNativeMacOSRole: true, webContentsMethod: (webContents) => { - const zoomLevel = webContents.getZoomLevel() - webContents.setZoomLevel(zoomLevel - 0.5) + webContents.zoomLevel -= 0.5 } }, // App submenu should be used for Mac only diff --git a/lib/browser/api/web-contents.js b/lib/browser/api/web-contents.js index 09213075ecd3d..f7b8997a20986 100644 --- a/lib/browser/api/web-contents.js +++ b/lib/browser/api/web-contents.js @@ -416,6 +416,13 @@ WebContents.prototype._init = function () { app.emit('web-contents-created', {}, this) } +// Deprecations +deprecate.fnToProperty(WebContents.prototype, 'audioMuted', '_isAudioMuted', '_setAudioMuted') +deprecate.fnToProperty(WebContents.prototype, 'userAgent', '_getUserAgent', '_setUserAgent') +deprecate.fnToProperty(WebContents.prototype, 'zoomLevel', '_getZoomLevel', '_setZoomLevel') +deprecate.fnToProperty(WebContents.prototype, 'zoomFactor', '_getZoomFactor', '_setZoomFactor') +deprecate.fnToProperty(WebContents.prototype, 'frameRate', '_getFrameRate', '_setFrameRate') + // JavaScript wrapper of Debugger. const { Debugger } = process.electronBinding('debugger') Object.setPrototypeOf(Debugger.prototype, EventEmitter.prototype) diff --git a/shell/browser/api/atom_api_web_contents.cc b/shell/browser/api/atom_api_web_contents.cc index 06a01900d6675..8fa4f8ccca4e4 100644 --- a/shell/browser/api/atom_api_web_contents.cc +++ b/shell/browser/api/atom_api_web_contents.cc @@ -2388,8 +2388,10 @@ void WebContents::BuildPrototype(v8::Isolate* isolate, .SetMethod("_goForward", &WebContents::GoForward) .SetMethod("_goToOffset", &WebContents::GoToOffset) .SetMethod("isCrashed", &WebContents::IsCrashed) - .SetMethod("setUserAgent", &WebContents::SetUserAgent) - .SetMethod("getUserAgent", &WebContents::GetUserAgent) + .SetMethod("_setUserAgent", &WebContents::SetUserAgent) + .SetMethod("_getUserAgent", &WebContents::GetUserAgent) + .SetProperty("userAgent", &WebContents::GetUserAgent, + &WebContents::SetUserAgent) .SetMethod("savePage", &WebContents::SavePage) .SetMethod("openDevTools", &WebContents::OpenDevTools) .SetMethod("closeDevTools", &WebContents::CloseDevTools) @@ -2400,8 +2402,10 @@ void WebContents::BuildPrototype(v8::Isolate* isolate, .SetMethod("toggleDevTools", &WebContents::ToggleDevTools) .SetMethod("inspectElement", &WebContents::InspectElement) .SetMethod("setIgnoreMenuShortcuts", &WebContents::SetIgnoreMenuShortcuts) - .SetMethod("setAudioMuted", &WebContents::SetAudioMuted) - .SetMethod("isAudioMuted", &WebContents::IsAudioMuted) + .SetMethod("_setAudioMuted", &WebContents::SetAudioMuted) + .SetMethod("_isAudioMuted", &WebContents::IsAudioMuted) + .SetProperty("audioMuted", &WebContents::IsAudioMuted, + &WebContents::SetAudioMuted) .SetMethod("isCurrentlyAudible", &WebContents::IsCurrentlyAudible) .SetMethod("undo", &WebContents::Undo) .SetMethod("redo", &WebContents::Redo) @@ -2432,14 +2436,20 @@ void WebContents::BuildPrototype(v8::Isolate* isolate, .SetMethod("startPainting", &WebContents::StartPainting) .SetMethod("stopPainting", &WebContents::StopPainting) .SetMethod("isPainting", &WebContents::IsPainting) - .SetMethod("setFrameRate", &WebContents::SetFrameRate) - .SetMethod("getFrameRate", &WebContents::GetFrameRate) + .SetMethod("_setFrameRate", &WebContents::SetFrameRate) + .SetMethod("_getFrameRate", &WebContents::GetFrameRate) + .SetProperty("frameRate", &WebContents::GetFrameRate, + &WebContents::SetFrameRate) #endif .SetMethod("invalidate", &WebContents::Invalidate) - .SetMethod("setZoomLevel", &WebContents::SetZoomLevel) - .SetMethod("getZoomLevel", &WebContents::GetZoomLevel) - .SetMethod("setZoomFactor", &WebContents::SetZoomFactor) - .SetMethod("getZoomFactor", &WebContents::GetZoomFactor) + .SetMethod("_setZoomLevel", &WebContents::SetZoomLevel) + .SetMethod("_getZoomLevel", &WebContents::GetZoomLevel) + .SetProperty("zoomLevel", &WebContents::GetZoomLevel, + &WebContents::SetZoomLevel) + .SetMethod("_setZoomFactor", &WebContents::SetZoomFactor) + .SetMethod("_getZoomFactor", &WebContents::GetZoomFactor) + .SetProperty("zoomFactor", &WebContents::GetZoomFactor, + &WebContents::SetZoomFactor) .SetMethod("getType", &WebContents::GetType) .SetMethod("_getPreloadPaths", &WebContents::GetPreloadPaths) .SetMethod("getWebPreferences", &WebContents::GetWebPreferences) diff --git a/spec-main/api-session-spec.js b/spec-main/api-session-spec.js index 98a3f9226997d..36066927594b7 100644 --- a/spec-main/api-session-spec.js +++ b/spec-main/api-session-spec.js @@ -47,7 +47,8 @@ describe('session module', () => { expect(session.fromPartition('test')).to.equal(session.fromPartition('test')) }) - it('created session is ref-counted', () => { + // TODO(codebytere): remove in Electron v8.0.0 + it('created session is ref-counted (functions)', () => { const partition = 'test2' const userAgent = 'test-agent' const ses1 = session.fromPartition(partition) @@ -57,6 +58,17 @@ describe('session module', () => { const ses2 = session.fromPartition(partition) expect(ses2.getUserAgent()).to.not.equal(userAgent) }) + + it('created session is ref-counted', () => { + const partition = 'test2' + const userAgent = 'test-agent' + const ses1 = session.fromPartition(partition) + ses1.userAgent = userAgent + expect(ses1.userAgent).to.equal(userAgent) + ses1.destroy() + const ses2 = session.fromPartition(partition) + expect(ses2.userAgent).to.not.equal(userAgent) + }) }) describe('ses.cookies', () => { diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index f4cbbda32d5af..e47694423abae 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -3034,6 +3034,7 @@ describe('BrowserWindow module', () => { }) }) + // TODO(codebytere): remove in Electron v8.0.0 describe('window.webContents.getFrameRate()', () => { it('has default frame rate', (done) => { w.webContents.once('paint', function (event, rect, data) { @@ -3044,6 +3045,7 @@ describe('BrowserWindow module', () => { }) }) + // TODO(codebytere): remove in Electron v8.0.0 describe('window.webContents.setFrameRate(frameRate)', () => { it('sets custom frame rate', (done) => { w.webContents.on('dom-ready', () => { @@ -3056,6 +3058,27 @@ describe('BrowserWindow module', () => { w.loadFile(path.join(fixtures, 'api', 'offscreen-rendering.html')) }) }) + + describe('window.webContents.FrameRate', () => { + it('has default frame rate', (done) => { + w.webContents.once('paint', function (event, rect, data) { + expect(w.webContents.frameRate).to.equal(60) + done() + }) + w.loadFile(path.join(fixtures, 'api', 'offscreen-rendering.html')) + }) + + it('sets custom frame rate', (done) => { + w.webContents.on('dom-ready', () => { + w.webContents.frameRate = 30 + w.webContents.once('paint', function (event, rect, data) { + expect(w.webContents.frameRate).to.equal(30) + done() + }) + }) + w.loadFile(path.join(fixtures, 'api', 'offscreen-rendering.html')) + }) + }) }) }) diff --git a/spec/api-web-contents-spec.js b/spec/api-web-contents-spec.js index aed83a59bf06a..d709463f1c47e 100644 --- a/spec/api-web-contents-spec.js +++ b/spec/api-web-contents-spec.js @@ -589,7 +589,7 @@ describe('webContents module', () => { const {ipcRenderer, remote} = require('electron') ipcRenderer.send('set-zoom', window.location.hostname) ipcRenderer.on(window.location.hostname + '-zoom-set', () => { - const zoomLevel = remote.getCurrentWebContents().getZoomLevel() + const { zoomLevel } = remote.getCurrentWebContents() ipcRenderer.send(window.location.hostname + '-zoom-level', zoomLevel) }) ` @@ -602,7 +602,8 @@ describe('webContents module', () => { protocol.unregisterProtocol(zoomScheme, (error) => done(error)) }) - it('can set the correct zoom level', async () => { + // TODO(codebytere): remove in Electron v8.0.0 + it('can set the correct zoom level (functions)', async () => { try { await w.loadURL('about:blank') const zoomLevel = w.webContents.getZoomLevel() @@ -615,11 +616,25 @@ describe('webContents module', () => { } }) + it('can set the correct zoom level', async () => { + try { + await w.loadURL('about:blank') + const zoomLevel = w.webContents.zoomLevel + expect(zoomLevel).to.eql(0.0) + w.webContents.zoomLevel = 0.5 + const newZoomLevel = w.webContents.zoomLevel + expect(newZoomLevel).to.eql(0.5) + } finally { + w.webContents.zoomLevel = 0 + } + }) + it('can persist zoom level across navigation', (done) => { let finalNavigation = false ipcMain.on('set-zoom', (e, host) => { const zoomLevel = hostZoomMap[host] - if (!finalNavigation) w.webContents.setZoomLevel(zoomLevel) + if (!finalNavigation) w.webContents.zoomLevel = zoomLevel + console.log() e.sender.send(`${host}-zoom-set`) }) ipcMain.on('host1-zoom-level', (e, zoomLevel) => { @@ -645,17 +660,17 @@ describe('webContents module', () => { show: false }) w2.webContents.on('did-finish-load', () => { - const zoomLevel1 = w.webContents.getZoomLevel() + const zoomLevel1 = w.webContents.zoomLevel expect(zoomLevel1).to.equal(hostZoomMap.host3) - const zoomLevel2 = w2.webContents.getZoomLevel() + const zoomLevel2 = w2.webContents.zoomLevel expect(zoomLevel1).to.equal(zoomLevel2) w2.setClosable(true) w2.close() done() }) w.webContents.on('did-finish-load', () => { - w.webContents.setZoomLevel(hostZoomMap.host3) + w.webContents.zoomLevel = hostZoomMap.host3 w2.loadURL(`${zoomScheme}://host3`) }) w.loadURL(`${zoomScheme}://host3`) @@ -674,10 +689,10 @@ describe('webContents module', () => { }, (error) => { if (error) return done(error) w2.webContents.on('did-finish-load', () => { - const zoomLevel1 = w.webContents.getZoomLevel() + const zoomLevel1 = w.webContents.zoomLevel expect(zoomLevel1).to.equal(hostZoomMap.host3) - const zoomLevel2 = w2.webContents.getZoomLevel() + const zoomLevel2 = w2.webContents.zoomLevel expect(zoomLevel2).to.equal(0) expect(zoomLevel1).to.not.equal(zoomLevel2) @@ -689,7 +704,7 @@ describe('webContents module', () => { }) }) w.webContents.on('did-finish-load', () => { - w.webContents.setZoomLevel(hostZoomMap.host3) + w.webContents.zoomLevel = hostZoomMap.host3 w2.loadURL(`${zoomScheme}://host3`) }) w.loadURL(`${zoomScheme}://host3`) @@ -707,16 +722,16 @@ describe('webContents module', () => { const content = `` w.webContents.on('did-frame-finish-load', (e, isMainFrame) => { if (!isMainFrame) { - const zoomLevel = w.webContents.getZoomLevel() + const zoomLevel = w.webContents.zoomLevel expect(zoomLevel).to.equal(2.0) - w.webContents.setZoomLevel(0) + w.webContents.zoomLevel = 0 server.close() done() } }) w.webContents.on('dom-ready', () => { - w.webContents.setZoomLevel(2.0) + w.webContents.zoomLevel = 2.0 }) w.loadURL(`data:text/html,${content}`) }) @@ -728,10 +743,10 @@ describe('webContents module', () => { show: false }) w2.webContents.on('did-finish-load', () => { - const zoomLevel1 = w.webContents.getZoomLevel() + const zoomLevel1 = w.webContents.zoomLevel expect(zoomLevel1).to.equal(finalZoomLevel) - const zoomLevel2 = w2.webContents.getZoomLevel() + const zoomLevel2 = w2.webContents.zoomLevel expect(zoomLevel2).to.equal(0) expect(zoomLevel1).to.not.equal(zoomLevel2) @@ -757,7 +772,7 @@ describe('webContents module', () => { if (initialNavigation) { w.webContents.executeJavaScript(source) } else { - const zoomLevel = w.webContents.getZoomLevel() + const zoomLevel = w.webContents.zoomLevel expect(zoomLevel).to.equal(0) done() } diff --git a/spec/ts-smoke/electron/main.ts b/spec/ts-smoke/electron/main.ts index a991c50be1d1d..2bc4e8959a0c3 100644 --- a/spec/ts-smoke/electron/main.ts +++ b/spec/ts-smoke/electron/main.ts @@ -679,7 +679,7 @@ const template = [ accelerator: 'CmdOrCtrl+0', click: (item, focusedWindow) => { if (focusedWindow) { - focusedWindow.webContents.setZoomLevel(0) + focusedWindow.webContents.zoomLevel = 0 } } }, @@ -689,8 +689,7 @@ const template = [ click: (item, focusedWindow) => { if (focusedWindow) { const { webContents } = focusedWindow - const zoomLevel = webContents.getZoomLevel() - webContents.setZoomLevel(zoomLevel + 0.5) + webContents.zoomLevel += 0.5 } } }, @@ -700,8 +699,7 @@ const template = [ click: (item, focusedWindow) => { if (focusedWindow) { const { webContents } = focusedWindow - const zoomLevel = webContents.getZoomLevel() - webContents.setZoomLevel(zoomLevel - 0.5) + webContents.zoomLevel -= 0.5 } } } From d1292833e924fc80043a937a85fcb8f49cf67c30 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Wed, 3 Jul 2019 12:07:47 -0700 Subject: [PATCH 36/46] chore: remove unused BrowserWindow.fromDevToolsWebContents (#19090) --- lib/browser/api/browser-window.js | 9 --------- spec/api-browser-window-spec.js | 18 ------------------ 2 files changed, 27 deletions(-) diff --git a/lib/browser/api/browser-window.js b/lib/browser/api/browser-window.js index 9904a893ed8c9..05fe450786d14 100644 --- a/lib/browser/api/browser-window.js +++ b/lib/browser/api/browser-window.js @@ -127,15 +127,6 @@ BrowserWindow.fromBrowserView = (browserView) => { return null } -BrowserWindow.fromDevToolsWebContents = (webContents) => { - for (const window of BrowserWindow.getAllWindows()) { - const { devToolsWebContents } = window - if (devToolsWebContents != null && devToolsWebContents.equal(webContents)) { - return window - } - } -} - // Helpers. Object.assign(BrowserWindow.prototype, { loadURL (...args) { diff --git a/spec/api-browser-window-spec.js b/spec/api-browser-window-spec.js index e47694423abae..fe4bb8886dd5d 100644 --- a/spec/api-browser-window-spec.js +++ b/spec/api-browser-window-spec.js @@ -233,24 +233,6 @@ describe('BrowserWindow module', () => { }) }) - describe('BrowserWindow.fromDevToolsWebContents(webContents)', () => { - let contents = null - - beforeEach(() => { contents = webContents.create({}) }) - - afterEach(() => { contents.destroy() }) - - it('returns the window with the webContents', (done) => { - w.webContents.once('devtools-opened', () => { - expect(BrowserWindow.fromDevToolsWebContents(w.devToolsWebContents).id).to.equal(w.id) - expect(BrowserWindow.fromDevToolsWebContents(w.webContents)).to.be.undefined() - expect(BrowserWindow.fromDevToolsWebContents(contents)).to.be.undefined() - done() - }) - w.webContents.openDevTools() - }) - }) - describe('BrowserWindow.openDevTools()', () => { it('does not crash for frameless window', () => { w.destroy() From ae01a48fca7da5a42339df2b03be5f593cd004b7 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Wed, 3 Jul 2019 14:08:21 -0700 Subject: [PATCH 37/46] chore: fix node ref to point to the ref that was merged (#19098) --- DEPS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DEPS b/DEPS index cc330bf0c9642..e8dbd2797194a 100644 --- a/DEPS +++ b/DEPS @@ -12,7 +12,7 @@ vars = { 'chromium_version': '3062b7cf090f1d9522c04ca8fa0a906f88ababe9', 'node_version': - 'f4a3ef181f7e52663034aff129d6b91230a318bd', + '780436005ffc7f317abfba48b236428858284e99', 'nan_version': '2ee313aaca52e2b478965ac50eb5082520380d1b', From d362be5cd9deabdc8d5a489125b8ee0ec702ff27 Mon Sep 17 00:00:00 2001 From: Electron Bot Date: Wed, 3 Jul 2019 14:48:55 -0700 Subject: [PATCH 38/46] chore: bump chromium to f156cb7658ec5382f5623a05841c6 (master) (#19096) * chore: bump chromium in DEPS to 37cd06a295cf156cb7658ec5382f5623a05841c6 * update patches * fix: replace NO_TRAFFIC_ANNOTATION_YET with MISSING_TRAFFIC_ANNOTATION Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1653256 --- DEPS | 2 +- patches/chromium/.patches | 1 - ...client_precreatemessageloop_callback.patch | 4 +-- patches/chromium/add_realloc.patch | 4 +-- patches/chromium/blink_local_frame.patch | 6 ++--- patches/chromium/blink_world_context.patch | 4 +-- patches/chromium/can_create_window.patch | 4 +-- .../chromium/content_browser_main_loop.patch | 4 +-- .../disable_color_correct_rendering.patch | 6 ++--- ...requirement_for_beforeunload_dialogs.patch | 4 +-- ...tributes_to_fix_gpu_info_enumeration.patch | 18 ------------- ...launchservicesserverconnectionstatus.patch | 2 +- ...emote_certificate_verification_logic.patch | 6 ++--- patches/chromium/printing.patch | 26 +++++++++---------- .../render_widget_host_view_base.patch | 8 +++--- patches/chromium/resource_file_conflict.patch | 2 +- patches/chromium/scroll_bounce_flag.patch | 2 +- .../support_mixed_sandbox_with_zygote.patch | 10 +++---- patches/chromium/web_contents.patch | 6 ++--- shell/browser/api/atom_api_web_contents.cc | 2 +- shell/browser/net/atom_url_request.cc | 5 ++-- shell/browser/net/url_request_fetch_job.cc | 3 ++- .../ui/inspectable_web_contents_impl.cc | 2 +- shell/browser/ui/webui/pdf_viewer_ui.cc | 4 +-- 24 files changed, 59 insertions(+), 76 deletions(-) delete mode 100644 patches/chromium/fix_re-add_endauxattributes_to_fix_gpu_info_enumeration.patch diff --git a/DEPS b/DEPS index e8dbd2797194a..11b8c697c8d8b 100644 --- a/DEPS +++ b/DEPS @@ -10,7 +10,7 @@ gclient_gn_args = [ vars = { 'chromium_version': - '3062b7cf090f1d9522c04ca8fa0a906f88ababe9', + '37cd06a295cf156cb7658ec5382f5623a05841c6', 'node_version': '780436005ffc7f317abfba48b236428858284e99', 'nan_version': diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 0c59559b13bc5..352b8bf3ef95e 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -77,4 +77,3 @@ crashpad_pid_check.patch chore_add_debounce_on_the_updatewebcontentsvisibility_method_to.patch network_service_allow_remote_certificate_verification_logic.patch put_back_deleted_colors_for_autofill.patch -fix_re-add_endauxattributes_to_fix_gpu_info_enumeration.patch diff --git a/patches/chromium/add_contentgpuclient_precreatemessageloop_callback.patch b/patches/chromium/add_contentgpuclient_precreatemessageloop_callback.patch index 6e21418300832..24e16384b65f7 100644 --- a/patches/chromium/add_contentgpuclient_precreatemessageloop_callback.patch +++ b/patches/chromium/add_contentgpuclient_precreatemessageloop_callback.patch @@ -9,7 +9,7 @@ Allows Electron to restore WER when ELECTRON_DEFAULT_ERROR_MODE is set. This should be upstreamed diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc -index ad0d612eb6b87cb320047ebaaff5220f46d8fb8c..9f1fc3a3f1b98d90c5aea07d30616e5180cfa8d5 100644 +index 877495568fddbc7dae5835ead41faf37be77208a..362c01039826ee5764d170da17cc7111617a8de2 100644 --- a/content/gpu/gpu_main.cc +++ b/content/gpu/gpu_main.cc @@ -236,6 +236,10 @@ int GpuMain(const MainFunctionParams& parameters) { @@ -23,7 +23,7 @@ index ad0d612eb6b87cb320047ebaaff5220f46d8fb8c..9f1fc3a3f1b98d90c5aea07d30616e51 // We are experiencing what appear to be memory-stomp issues in the GPU // process. These issues seem to be impacting the task executor and listeners // registered to it. Create the task executor on the heap to guard against -@@ -337,7 +341,6 @@ int GpuMain(const MainFunctionParams& parameters) { +@@ -339,7 +343,6 @@ int GpuMain(const MainFunctionParams& parameters) { : base::ThreadPriority::NORMAL; GpuProcess gpu_process(io_thread_priority); diff --git a/patches/chromium/add_realloc.patch b/patches/chromium/add_realloc.patch index 437ec3bd14661..e52731bf55aff 100644 --- a/patches/chromium/add_realloc.patch +++ b/patches/chromium/add_realloc.patch @@ -39,10 +39,10 @@ index 2aef366ac8194aa261cbca6abc051f7da8a988d3..3c7d66c81032636abcca4f1538ce9b7f GIN_EXPORT static ArrayBufferAllocator* SharedInstance(); diff --git a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc -index 82bfcb5d1d98772fda0e8c5692e8fdc2626fd1c9..ea29d4e0404344be09e9098920d175e7bb80d000 100644 +index d4fcac361f99e52a4a0e9e90abe639816cf51fc1..8d7c531de5e9016da6cd2d823f7d7f3270b9abf6 100644 --- a/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc +++ b/third_party/blink/renderer/bindings/core/v8/v8_initializer.cc -@@ -582,6 +582,10 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { +@@ -632,6 +632,10 @@ class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator { size, WTF::ArrayBufferContents::kDontInitialize); } diff --git a/patches/chromium/blink_local_frame.patch b/patches/chromium/blink_local_frame.patch index a9944c795e0a8..3478031e71b87 100644 --- a/patches/chromium/blink_local_frame.patch +++ b/patches/chromium/blink_local_frame.patch @@ -14,10 +14,10 @@ when there is code doing that. This patch reverts the change to fix the crash in Electron. diff --git a/third_party/blink/renderer/core/frame/local_frame.cc b/third_party/blink/renderer/core/frame/local_frame.cc -index 2bf09644bdd6bf6f8dd49557f9e707f7bf77c2b4..bc36e8bc9fc1a973c89d52e60bd62e753ef17f15 100644 +index b4e75c8bc63c30c4d0dde96912aee87260662103..3a61f37a05fb5e626a0898b53600b79ab3c20f88 100644 --- a/third_party/blink/renderer/core/frame/local_frame.cc +++ b/third_party/blink/renderer/core/frame/local_frame.cc -@@ -331,10 +331,6 @@ void LocalFrame::DetachImpl(FrameDetachType type) { +@@ -332,10 +332,6 @@ void LocalFrame::DetachImpl(FrameDetachType type) { } CHECK(!view_ || !view_->IsAttached()); @@ -28,7 +28,7 @@ index 2bf09644bdd6bf6f8dd49557f9e707f7bf77c2b4..bc36e8bc9fc1a973c89d52e60bd62e75 if (!Client()) return; -@@ -352,6 +348,10 @@ void LocalFrame::DetachImpl(FrameDetachType type) { +@@ -353,6 +349,10 @@ void LocalFrame::DetachImpl(FrameDetachType type) { // Notify ScriptController that the frame is closing, since its cleanup ends // up calling back to LocalFrameClient via WindowProxy. GetScriptController().ClearForClose(); diff --git a/patches/chromium/blink_world_context.patch b/patches/chromium/blink_world_context.patch index 15d0e78409586..be6d5331d5e42 100644 --- a/patches/chromium/blink_world_context.patch +++ b/patches/chromium/blink_world_context.patch @@ -19,7 +19,7 @@ index c41afd046ee882cdb4c9f706c4d08cd05bd133ec..a52f1a86e6aeecb0d704b01746de5501 // that the script evaluated to with callback. Script execution can be // suspend. diff --git a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc -index e9fda5584f7b0ce69c8ca031f34e9b181a704868..a444ec89dbfd6395e2b182a73572555563861e1d 100644 +index e55ac9152cfdd35e0d5e0cc99ec8d8abe5bac5f1..cb1881473d452e3454977d9277551ad693f3a90c 100644 --- a/third_party/blink/renderer/core/frame/web_local_frame_impl.cc +++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.cc @@ -867,6 +867,13 @@ v8::Local WebLocalFrameImpl::GlobalProxy() const { @@ -37,7 +37,7 @@ index e9fda5584f7b0ce69c8ca031f34e9b181a704868..a444ec89dbfd6395e2b182a735725555 return BindingSecurity::ShouldAllowAccessToFrame( CurrentDOMWindow(V8PerIsolateData::MainThreadIsolate()), diff --git a/third_party/blink/renderer/core/frame/web_local_frame_impl.h b/third_party/blink/renderer/core/frame/web_local_frame_impl.h -index 15ed90d550941c58ceb375afa9feadc57e4b46c4..8c18516e6957206a4c9ae9365fdf06870c2d3094 100644 +index 043afe0005af3e4271f2b0c8e490e4e4141fc1b5..3a937e1a451ddf1e99ef4322ebc21044d48ad537 100644 --- a/third_party/blink/renderer/core/frame/web_local_frame_impl.h +++ b/third_party/blink/renderer/core/frame/web_local_frame_impl.h @@ -148,6 +148,8 @@ class CORE_EXPORT WebLocalFrameImpl final diff --git a/patches/chromium/can_create_window.patch b/patches/chromium/can_create_window.patch index 658907e15521a..d1c6349d7dd57 100644 --- a/patches/chromium/can_create_window.patch +++ b/patches/chromium/can_create_window.patch @@ -5,10 +5,10 @@ Subject: can_create_window.patch diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc -index 36e6f08c3d0ed6ef7f7d071b01c70e99c16efc05..2ada995112fec477e186a9de3e815d3be5dc1292 100644 +index ad82e3695847dcb3f71b3a26d4609029b6201ee8..01c3c1ece91a6478d1a7d075d304359de9050cb2 100644 --- a/content/browser/frame_host/render_frame_host_impl.cc +++ b/content/browser/frame_host/render_frame_host_impl.cc -@@ -3807,6 +3807,7 @@ void RenderFrameHostImpl::CreateNewWindow( +@@ -3809,6 +3809,7 @@ void RenderFrameHostImpl::CreateNewWindow( last_committed_origin_, params->window_container_type, params->target_url, params->referrer.To(), params->frame_name, params->disposition, *params->features, diff --git a/patches/chromium/content_browser_main_loop.patch b/patches/chromium/content_browser_main_loop.patch index bd6c4b51915cf..f4c68137ed468 100644 --- a/patches/chromium/content_browser_main_loop.patch +++ b/patches/chromium/content_browser_main_loop.patch @@ -8,10 +8,10 @@ run before shutdown. This is required to cleanup WebContents asynchronously in atom::CommonWebContentsDelegate::ResetManageWebContents. diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc -index d4426f92a066f8f30aa24cc5ad02ae4e75ab0e33..c1f2cb0a239566a279f13cdeec46d4e9f59db965 100644 +index 777e9ccf6da4da4924b2e35bff8e7b84fb18a9aa..f04fd728df749100a4699dd922f7a4b17f1fd98c 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc -@@ -1499,7 +1499,7 @@ void BrowserMainLoop::MainMessageLoopRun() { +@@ -1501,7 +1501,7 @@ void BrowserMainLoop::MainMessageLoopRun() { NOTREACHED(); #else base::RunLoop run_loop; diff --git a/patches/chromium/disable_color_correct_rendering.patch b/patches/chromium/disable_color_correct_rendering.patch index 4c14e07bc3f19..2a0f6e36f5929 100644 --- a/patches/chromium/disable_color_correct_rendering.patch +++ b/patches/chromium/disable_color_correct_rendering.patch @@ -215,10 +215,10 @@ index 4165ba000223c6d13e112a6a9861f015bb9ebbbb..70a9d11bdd1f836215724af18df18876 service_manager::switches::kGpuSandboxAllowSysVShm, service_manager::switches::kGpuSandboxFailuresFatal, diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc -index 26b1e9e2043cd5576e58ed44c5595c42a58f9f84..b9064efa92653be6e10b78f81b2e50c8f3742657 100644 +index ce456a679fe94077c1a69b5eb697eba746ddba85..880d0e759659c62b3401d46fa962abadf8146a95 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc -@@ -216,6 +216,7 @@ +@@ -217,6 +217,7 @@ #include "ui/base/ui_base_switches.h" #include "ui/base/ui_base_switches_util.h" #include "ui/display/display_switches.h" @@ -226,7 +226,7 @@ index 26b1e9e2043cd5576e58ed44c5595c42a58f9f84..b9064efa92653be6e10b78f81b2e50c8 #include "ui/gl/gl_switches.h" #include "ui/native_theme/native_theme_features.h" -@@ -2898,6 +2899,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( +@@ -2908,6 +2909,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer( // Propagate the following switches to the renderer command line (along // with any associated values) if present in the browser command line. static const char* const kSwitchNames[] = { diff --git a/patches/chromium/disable_user_gesture_requirement_for_beforeunload_dialogs.patch b/patches/chromium/disable_user_gesture_requirement_for_beforeunload_dialogs.patch index e037683126314..664bc54ef7c68 100644 --- a/patches/chromium/disable_user_gesture_requirement_for_beforeunload_dialogs.patch +++ b/patches/chromium/disable_user_gesture_requirement_for_beforeunload_dialogs.patch @@ -6,10 +6,10 @@ Subject: disable_user_gesture_requirement_for_beforeunload_dialogs.patch See https://github.com/electron/electron/issues/10754 diff --git a/third_party/blink/renderer/core/dom/document.cc b/third_party/blink/renderer/core/dom/document.cc -index 9a7175184c094ae1725bb9f58182e17090c0e1f3..90cb0da5405b3b65572fc8afc8b127c031a421e9 100644 +index a532335fbe025ca34a1f2df8803225b7a4943bd0..2b2439bae4a1989c94026976d157522a3274aafb 100644 --- a/third_party/blink/renderer/core/dom/document.cc +++ b/third_party/blink/renderer/core/dom/document.cc -@@ -3676,7 +3676,9 @@ bool Document::DispatchBeforeUnloadEvent(ChromeClient* chrome_client, +@@ -3992,7 +3992,9 @@ bool Document::DispatchBeforeUnloadEvent(ChromeClient* chrome_client, "frame that never had a user gesture since its load. " "https://www.chromestatus.com/feature/5082396709879808"; Intervention::GenerateReport(frame_, "BeforeUnloadNoGesture", message); diff --git a/patches/chromium/fix_re-add_endauxattributes_to_fix_gpu_info_enumeration.patch b/patches/chromium/fix_re-add_endauxattributes_to_fix_gpu_info_enumeration.patch deleted file mode 100644 index b1cdb9bfd800b..0000000000000 --- a/patches/chromium/fix_re-add_endauxattributes_to_fix_gpu_info_enumeration.patch +++ /dev/null @@ -1,18 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Samuel Attard -Date: Tue, 2 Jul 2019 14:53:57 -0700 -Subject: fix: re-add EndAuxAttributes to fix gpu info enumeration - - -diff --git a/gpu/config/gpu_info.cc b/gpu/config/gpu_info.cc -index 963884c9e53d8d619cb076247bc4884ae0a89252..7b9fddb29c10be436857e9f035846a8996ee48a9 100644 ---- a/gpu/config/gpu_info.cc -+++ b/gpu/config/gpu_info.cc -@@ -326,6 +326,7 @@ void GPUInfo::EnumerateFields(Enumerator* enumerator) const { - enumerator->AddInt64("rgbaVisual", rgba_visual); - #endif - enumerator->AddBool("oopRasterizationSupported", oop_rasterization_supported); -+ enumerator->EndAuxAttributes(); - } - - } // namespace gpu diff --git a/patches/chromium/mas-lssetapplicationlaunchservicesserverconnectionstatus.patch b/patches/chromium/mas-lssetapplicationlaunchservicesserverconnectionstatus.patch index 5eda96b71afe1..cd359f133fc2b 100644 --- a/patches/chromium/mas-lssetapplicationlaunchservicesserverconnectionstatus.patch +++ b/patches/chromium/mas-lssetapplicationlaunchservicesserverconnectionstatus.patch @@ -7,7 +7,7 @@ Removes usage of the _LSSetApplicationLaunchServicesServerConnectionStatus private API. diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc -index 35be2f60e8377708a25d1f62b7998311822fda2b..ad0d612eb6b87cb320047ebaaff5220f46d8fb8c 100644 +index 5433738c34d60f07d17567a24448f9147bf18adc..877495568fddbc7dae5835ead41faf37be77208a 100644 --- a/content/gpu/gpu_main.cc +++ b/content/gpu/gpu_main.cc @@ -285,8 +285,10 @@ int GpuMain(const MainFunctionParams& parameters) { diff --git a/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch b/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch index c1ba100379d93..2799c44610524 100644 --- a/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch +++ b/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch @@ -5,7 +5,7 @@ Subject: network service: allow remote certificate verification logic diff --git a/services/network/network_context.cc b/services/network/network_context.cc -index 4689fe5c142b7d975fa94f1edb2f00f33201f0b9..6ca068087123a9b8150864ee2b3a4d39bfef007b 100644 +index 59306bf01c17e252d9ab11d0883fc94ec4736a84..e4a733bd0f46e326afb3efa1f29206bc8aef1637 100644 --- a/services/network/network_context.cc +++ b/services/network/network_context.cc @@ -91,6 +91,11 @@ @@ -109,8 +109,8 @@ index 4689fe5c142b7d975fa94f1edb2f00f33201f0b9..6ca068087123a9b8150864ee2b3a4d39 void NetworkContext::CreateURLLoaderFactory( mojom::URLLoaderFactoryRequest request, mojom::URLLoaderFactoryParamsPtr params) { -@@ -2137,12 +2217,19 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext() { - net::CreateCertVerifyProcBuiltin(cert_net_fetcher_))); +@@ -2138,12 +2218,19 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext() { + cert_net_fetcher_, /*system_trust_store_provider=*/nullptr))); } #endif - if (!cert_verifier) diff --git a/patches/chromium/printing.patch b/patches/chromium/printing.patch index 8baf8f02b8721..c85f07c47abe8 100644 --- a/patches/chromium/printing.patch +++ b/patches/chromium/printing.patch @@ -365,7 +365,7 @@ index 1802034a6e15a6ad8b0d9591cfb79ba5873dc982..a827091facdb4f6b1d74ce826c3492ce // Like PrintMsg_PrintPages, but using the print preview document's frame/node. IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog) diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc -index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5bb4ce378f 100644 +index a462682154a33d0a20c07d4d7b6d5a584c553d47..96efa4b2f977f090de426c61268d6e1740b31637 100644 --- a/components/printing/renderer/print_render_frame_helper.cc +++ b/components/printing/renderer/print_render_frame_helper.cc @@ -37,6 +37,7 @@ @@ -376,7 +376,7 @@ index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5b #include "printing/units.h" #include "third_party/blink/public/common/frame/frame_owner_element_type.h" #include "third_party/blink/public/common/frame/sandbox_flags.h" -@@ -1114,7 +1115,9 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) { +@@ -1118,7 +1119,9 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) { web_frame->DispatchBeforePrintEvent(); if (!weak_this) return; @@ -387,7 +387,7 @@ index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5b if (weak_this) web_frame->DispatchAfterPrintEvent(); } -@@ -1162,7 +1165,10 @@ void PrintRenderFrameHelper::OnDestruct() { +@@ -1166,7 +1169,10 @@ void PrintRenderFrameHelper::OnDestruct() { delete this; } @@ -399,7 +399,7 @@ index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5b if (ipc_nesting_level_ > 1) return; -@@ -1175,7 +1181,8 @@ void PrintRenderFrameHelper::OnPrintPages() { +@@ -1179,7 +1185,8 @@ void PrintRenderFrameHelper::OnPrintPages() { // If we are printing a PDF extension frame, find the plugin node and print // that instead. auto plugin = delegate_->GetPdfElement(frame); @@ -409,7 +409,7 @@ index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5b if (weak_this) frame->DispatchAfterPrintEvent(); // WARNING: |this| may be gone at this point. Do not do any more work here and -@@ -1192,7 +1199,7 @@ void PrintRenderFrameHelper::OnPrintForSystemDialog() { +@@ -1196,7 +1203,7 @@ void PrintRenderFrameHelper::OnPrintForSystemDialog() { } auto weak_this = weak_ptr_factory_.GetWeakPtr(); Print(frame, print_preview_context_.source_node(), @@ -418,7 +418,7 @@ index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5b if (weak_this) frame->DispatchAfterPrintEvent(); // WARNING: |this| may be gone at this point. Do not do any more work here and -@@ -1228,6 +1235,8 @@ void PrintRenderFrameHelper::OnPrintPreview( +@@ -1232,6 +1239,8 @@ void PrintRenderFrameHelper::OnPrintPreview( if (ipc_nesting_level_ > 1) return; @@ -427,7 +427,7 @@ index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5b print_preview_context_.OnPrintPreview(); UMA_HISTOGRAM_ENUMERATION("PrintPreview.PreviewEvent", -@@ -1620,7 +1629,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) { +@@ -1624,7 +1633,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) { auto self = weak_ptr_factory_.GetWeakPtr(); Print(duplicate_node.GetDocument().GetFrame(), duplicate_node, @@ -439,7 +439,7 @@ index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5b // Check if |this| is still valid. if (!self) return; -@@ -1631,7 +1643,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) { +@@ -1635,7 +1647,10 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) { void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, const blink::WebNode& node, @@ -451,7 +451,7 @@ index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5b // If still not finished with earlier print request simply ignore. if (prep_frame_view_) return; -@@ -1639,7 +1654,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, +@@ -1643,7 +1658,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, FrameReference frame_ref(frame); int expected_page_count = 0; @@ -460,7 +460,7 @@ index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5b DidFinishPrinting(FAIL_PRINT_INIT); return; // Failed to init print page settings. } -@@ -1659,8 +1674,11 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, +@@ -1663,8 +1678,11 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, PrintMsg_PrintPages_Params print_settings; auto self = weak_ptr_factory_.GetWeakPtr(); @@ -474,7 +474,7 @@ index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5b // Check if |this| is still valid. if (!self) return; -@@ -1670,6 +1688,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, +@@ -1674,6 +1692,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame, ? blink::kWebPrintScalingOptionSourceSize : scaling_option; SetPrintPagesParams(print_settings); @@ -482,7 +482,7 @@ index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5b if (print_settings.params.dpi.IsEmpty() || !print_settings.params.document_cookie) { DidFinishPrinting(OK); // Release resources and fail silently on failure. -@@ -1858,10 +1877,24 @@ std::vector PrintRenderFrameHelper::GetPrintedPages( +@@ -1862,10 +1881,24 @@ std::vector PrintRenderFrameHelper::GetPrintedPages( return printed_pages; } @@ -510,7 +510,7 @@ index a1b05e5b3d433b03b9459e024ae9a5a4422ec590..b0c5939afc065b37f3318236303a2f5b // Check if the printer returned any settings, if the settings is empty, we // can safely assume there are no printer drivers configured. So we safely // terminate. -@@ -1881,12 +1914,14 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) { +@@ -1885,12 +1918,14 @@ bool PrintRenderFrameHelper::InitPrintSettings(bool fit_to_paper_size) { return result; } diff --git a/patches/chromium/render_widget_host_view_base.patch b/patches/chromium/render_widget_host_view_base.patch index 7c0c2b0e3961f..dfe4503782773 100644 --- a/patches/chromium/render_widget_host_view_base.patch +++ b/patches/chromium/render_widget_host_view_base.patch @@ -5,10 +5,10 @@ Subject: render_widget_host_view_base.patch diff --git a/content/browser/renderer_host/render_widget_host_view_base.cc b/content/browser/renderer_host/render_widget_host_view_base.cc -index a2902adc59b6b4083334130f3a8e29fca0c440d2..34673d9ab62311c458a581f98865014f01c4bcc0 100644 +index 5a3b90ecf7360ee1f484ac430afb649f022279c8..35470301d6a20c2652284c679dde6cff47cedfec 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.cc +++ b/content/browser/renderer_host/render_widget_host_view_base.cc -@@ -660,6 +660,15 @@ viz::FrameSinkId RenderWidgetHostViewBase::FrameSinkIdAtPoint( +@@ -665,6 +665,15 @@ viz::FrameSinkId RenderWidgetHostViewBase::FrameSinkIdAtPoint( return frame_sink_id.is_valid() ? frame_sink_id : GetFrameSinkId(); } @@ -25,7 +25,7 @@ index a2902adc59b6b4083334130f3a8e29fca0c440d2..34673d9ab62311c458a581f98865014f const blink::WebMouseEvent& event, const ui::LatencyInfo& latency) { diff --git a/content/browser/renderer_host/render_widget_host_view_base.h b/content/browser/renderer_host/render_widget_host_view_base.h -index 81bdc91eb3513fc9ebf3a5fc93e1cdb02b0ac11a..db980868272e5398d2100d5968d1b35f0d48e3eb 100644 +index a5f11d99f8f6c4302adfe0feee161b5472006a62..a7791bceff8ebf9725c2b830e36dbb06b2b61b1f 100644 --- a/content/browser/renderer_host/render_widget_host_view_base.h +++ b/content/browser/renderer_host/render_widget_host_view_base.h @@ -24,9 +24,11 @@ @@ -62,7 +62,7 @@ index 81bdc91eb3513fc9ebf3a5fc93e1cdb02b0ac11a..db980868272e5398d2100d5968d1b35f // This only needs to be overridden by RenderWidgetHostViewBase subclasses // that handle content embedded within other RenderWidgetHostViews. gfx::PointF TransformPointToRootCoordSpaceF( -@@ -363,6 +370,11 @@ class CONTENT_EXPORT RenderWidgetHostViewBase +@@ -371,6 +378,11 @@ class CONTENT_EXPORT RenderWidgetHostViewBase virtual void ProcessGestureEvent(const blink::WebGestureEvent& event, const ui::LatencyInfo& latency); diff --git a/patches/chromium/resource_file_conflict.patch b/patches/chromium/resource_file_conflict.patch index ee23b207fe9e3..f94f4ba905034 100644 --- a/patches/chromium/resource_file_conflict.patch +++ b/patches/chromium/resource_file_conflict.patch @@ -52,7 +52,7 @@ Some alternatives to this patch: None of these options seems like a substantial maintainability win over this patch to me (@nornagon). diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn -index a59bacecda9fb2c73d0f27d36330cb75db70992c..7cbf39630fa7de7c4910dd9aff8411150fd7303a 100644 +index 515cc0e0bad7795489e1a3c09887008f6ada2216..3c4191304b48c43999aebc8d96ebbbc01873f2d2 100644 --- a/chrome/BUILD.gn +++ b/chrome/BUILD.gn @@ -1709,7 +1709,7 @@ if (is_chrome_branded && !is_android) { diff --git a/patches/chromium/scroll_bounce_flag.patch b/patches/chromium/scroll_bounce_flag.patch index 508aa9453d61e..b596cb866a026 100644 --- a/patches/chromium/scroll_bounce_flag.patch +++ b/patches/chromium/scroll_bounce_flag.patch @@ -6,7 +6,7 @@ Subject: scroll_bounce_flag.patch Patch to make scrollBounce option work. diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc -index 28b5e17d0914bc4c9bb5bc8c650ba646e9e8f54e..3728ab15d565802d67b980a4995af62fa29c046e 100644 +index b37f47d3e7b8711b4f8226a83b37934686e0ad9a..ef3ccd1b592e30db88055cc827659562e989d08a 100644 --- a/content/renderer/render_thread_impl.cc +++ b/content/renderer/render_thread_impl.cc @@ -1499,7 +1499,7 @@ bool RenderThreadImpl::IsGpuMemoryBufferCompositorResourcesEnabled() { diff --git a/patches/chromium/support_mixed_sandbox_with_zygote.patch b/patches/chromium/support_mixed_sandbox_with_zygote.patch index 86546922416e1..8496e57fcb5ce 100644 --- a/patches/chromium/support_mixed_sandbox_with_zygote.patch +++ b/patches/chromium/support_mixed_sandbox_with_zygote.patch @@ -22,10 +22,10 @@ However, the patch would need to be reviewed by the security team, as it does touch a security-sensitive class. diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc -index dcf3078fc7a07b56a144b93a94b5285fa0583685..26b1e9e2043cd5576e58ed44c5595c42a58f9f84 100644 +index f1ada24a428765ed52174598c736b25e89a1e7d2..ce456a679fe94077c1a69b5eb697eba746ddba85 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc -@@ -395,6 +395,10 @@ class RendererSandboxedProcessLauncherDelegate +@@ -396,6 +396,10 @@ class RendererSandboxedProcessLauncherDelegate : public SandboxedProcessLauncherDelegate { public: RendererSandboxedProcessLauncherDelegate() {} @@ -36,7 +36,7 @@ index dcf3078fc7a07b56a144b93a94b5285fa0583685..26b1e9e2043cd5576e58ed44c5595c42 ~RendererSandboxedProcessLauncherDelegate() override {} -@@ -414,6 +418,9 @@ class RendererSandboxedProcessLauncherDelegate +@@ -415,6 +419,9 @@ class RendererSandboxedProcessLauncherDelegate #if BUILDFLAG(USE_ZYGOTE_HANDLE) service_manager::ZygoteHandle GetZygote() override { @@ -46,7 +46,7 @@ index dcf3078fc7a07b56a144b93a94b5285fa0583685..26b1e9e2043cd5576e58ed44c5595c42 const base::CommandLine& browser_command_line = *base::CommandLine::ForCurrentProcess(); base::CommandLine::StringType renderer_prefix = -@@ -427,6 +434,11 @@ class RendererSandboxedProcessLauncherDelegate +@@ -428,6 +435,11 @@ class RendererSandboxedProcessLauncherDelegate service_manager::SandboxType GetSandboxType() override { return service_manager::SANDBOX_TYPE_RENDERER; } @@ -58,7 +58,7 @@ index dcf3078fc7a07b56a144b93a94b5285fa0583685..26b1e9e2043cd5576e58ed44c5595c42 }; const char kSessionStorageHolderKey[] = "kSessionStorageHolderKey"; -@@ -1748,11 +1760,18 @@ bool RenderProcessHostImpl::Init() { +@@ -1749,11 +1761,18 @@ bool RenderProcessHostImpl::Init() { cmd_line->PrependWrapper(renderer_prefix); AppendRendererCommandLine(cmd_line.get()); diff --git a/patches/chromium/web_contents.patch b/patches/chromium/web_contents.patch index bfddcaa4531fa..d641ed48a7135 100644 --- a/patches/chromium/web_contents.patch +++ b/patches/chromium/web_contents.patch @@ -5,10 +5,10 @@ Subject: web_contents.patch diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc -index b504f3779cab8a96cd72c1524bcc9795645d6764..d141ed8498c95093d0d697f95aeada958e24d048 100644 +index ba964827ded606182e3254eaf26947802b2d9ec0..a5385fb69fb6df931341a04a6f29add6f09352be 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc -@@ -2090,6 +2090,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { +@@ -2089,6 +2089,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { std::string unique_name; frame_tree_.root()->SetFrameName(params.main_frame_name, unique_name); @@ -21,7 +21,7 @@ index b504f3779cab8a96cd72c1524bcc9795645d6764..d141ed8498c95093d0d697f95aeada95 WebContentsViewDelegate* delegate = GetContentClient()->browser()->GetWebContentsViewDelegate(this); -@@ -2105,6 +2111,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { +@@ -2104,6 +2110,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) { &render_view_host_delegate_view_); } } diff --git a/shell/browser/api/atom_api_web_contents.cc b/shell/browser/api/atom_api_web_contents.cc index 8fa4f8ccca4e4..85a948a499f95 100644 --- a/shell/browser/api/atom_api_web_contents.cc +++ b/shell/browser/api/atom_api_web_contents.cc @@ -1355,7 +1355,7 @@ void WebContents::DownloadURL(const GURL& url) { content::BrowserContext::GetDownloadManager(browser_context); std::unique_ptr download_params( content::DownloadRequestUtils::CreateDownloadForWebContentsMainFrame( - web_contents(), url, NO_TRAFFIC_ANNOTATION_YET)); + web_contents(), url, MISSING_TRAFFIC_ANNOTATION)); download_manager->DownloadUrl(std::move(download_params)); } diff --git a/shell/browser/net/atom_url_request.cc b/shell/browser/net/atom_url_request.cc index 4de254e88e590..fbd41cf12fef8 100644 --- a/shell/browser/net/atom_url_request.cc +++ b/shell/browser/net/atom_url_request.cc @@ -115,8 +115,9 @@ void AtomURLRequest::DoInitialize( } DCHECK(context); - request_ = context->CreateRequest( - GURL(url), net::RequestPriority::DEFAULT_PRIORITY, this); + request_ = + context->CreateRequest(GURL(url), net::RequestPriority::DEFAULT_PRIORITY, + this, MISSING_TRAFFIC_ANNOTATION); if (!request_) { DoCancelWithError("Failed to create a net::URLRequest.", true); return; diff --git a/shell/browser/net/url_request_fetch_job.cc b/shell/browser/net/url_request_fetch_job.cc index 51b7aa265ad6f..ca86724bdd53f 100644 --- a/shell/browser/net/url_request_fetch_job.cc +++ b/shell/browser/net/url_request_fetch_job.cc @@ -188,7 +188,8 @@ void URLRequestFetchJob::StartAsync( else request_type = GetRequestType(method); - fetcher_ = net::URLFetcher::Create(formated_url, request_type, this); + fetcher_ = net::URLFetcher::Create(formated_url, request_type, this, + MISSING_TRAFFIC_ANNOTATION); fetcher_->SaveResponseWithWriter(base::WrapUnique(new ResponsePiper(this))); // A request context getter is passed by the user. diff --git a/shell/browser/ui/inspectable_web_contents_impl.cc b/shell/browser/ui/inspectable_web_contents_impl.cc index 03dd06e3864af..037921a817af4 100644 --- a/shell/browser/ui/inspectable_web_contents_impl.cc +++ b/shell/browser/ui/inspectable_web_contents_impl.cc @@ -536,7 +536,7 @@ void InspectableWebContentsImpl::LoadNetworkResource( auto factory = partition->GetURLLoaderFactoryForBrowserProcess(); auto simple_url_loader = network::SimpleURLLoader::Create( - std::move(resource_request), NO_TRAFFIC_ANNOTATION_YET); + std::move(resource_request), MISSING_TRAFFIC_ANNOTATION); auto resource_loader = std::make_unique( stream_id, this, std::move(simple_url_loader), factory.get(), callback); loaders_.insert(std::move(resource_loader)); diff --git a/shell/browser/ui/webui/pdf_viewer_ui.cc b/shell/browser/ui/webui/pdf_viewer_ui.cc index 77aa4cb3eb8dd..3a65cc1cccdbf 100644 --- a/shell/browser/ui/webui/pdf_viewer_ui.cc +++ b/shell/browser/ui/webui/pdf_viewer_ui.cc @@ -133,8 +133,8 @@ class PdfViewerUI::ResourceRequester const net::URLRequestContext* request_context = resource_context->GetRequestContext(); - std::unique_ptr request( - request_context->CreateRequest(url, net::DEFAULT_PRIORITY, nullptr)); + std::unique_ptr request(request_context->CreateRequest( + url, net::DEFAULT_PRIORITY, nullptr, MISSING_TRAFFIC_ANNOTATION)); request->set_method("GET"); content::ResourceDispatcherHostImpl::Get()->InitializeURLRequest( From 43b4a3ae6a6cbd1cf2c1ebf39d11080a0a043582 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 3 Jul 2019 14:56:03 -0700 Subject: [PATCH 39/46] chore: deprecate some NSVisualEffectMaterial types (#19072) --- docs/api/browser-window.md | 12 +++++++----- shell/browser/native_window_mac.mm | 23 ++++++++++++++++++++--- spec/ts-smoke/electron/main.ts | 4 +++- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/docs/api/browser-window.md b/docs/api/browser-window.md index 930f624ab0ef6..b948822877bde 100644 --- a/docs/api/browser-window.md +++ b/docs/api/browser-window.md @@ -233,10 +233,9 @@ It creates a new `BrowserWindow` with native properties as set by the `options`. Windows, which adds standard window frame. Setting it to `false` will remove window shadow and window animations. Default is `true`. * `vibrancy` String (optional) - Add a type of vibrancy effect to the window, only on - macOS. Can be `appearance-based`, `light`, `dark`, `titlebar`, `selection`, - `menu`, `popover`, `sidebar`, `medium-light` or `ultra-dark`. Please note that - using `frame: false` in combination with a vibrancy value requires that you use a - non-default `titleBarStyle` as well. + macOS. Can be `appearance-based`, `light`, `dark`, `titlebar`, `selection`, `menu`, + `popover`, `sidebar`, `medium-light` or `ultra-dark`. Please note that using `frame: false` in combination with a vibrancy value requires that you use a non-default `titleBarStyle` as well. + Also note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` have been deprecated and will be removed in an upcoming version of macOS. * `zoomToPageWidth` Boolean (optional) - Controls the behavior on macOS when option-clicking the green stoplight button on the toolbar or by clicking the Window > Zoom menu item. If `true`, the window will grow to the preferred @@ -1613,12 +1612,15 @@ Adds a window as a tab on this window, after the tab for the window instance. #### `win.setVibrancy(type)` _macOS_ * `type` String - Can be `appearance-based`, `light`, `dark`, `titlebar`, - `selection`, `menu`, `popover`, `sidebar`, `medium-light` or `ultra-dark`. See +`selection`, `menu`, `popover`, `sidebar`, `medium-light` or `ultra-dark`. See the [macOS documentation][vibrancy-docs] for more details. Adds a vibrancy effect to the browser window. Passing `null` or an empty string will remove the vibrancy effect on the window. +Note that `appearance-based`, `light`, `dark`, `medium-light`, and `ultra-dark` have been +deprecated and will be removed in an upcoming version of macOS. + #### `win.setTouchBar(touchBar)` _macOS_ _Experimental_ * `touchBar` TouchBar diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index f0693079d84a7..630ee6451c356 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -26,6 +26,7 @@ #include "shell/browser/ui/inspectable_web_contents.h" #include "shell/browser/ui/inspectable_web_contents_view.h" #include "shell/browser/window_list.h" +#include "shell/common/deprecate_util.h" #include "shell/common/options_switches.h" #include "skia/ext/skia_utils_mac.h" #include "ui/gfx/skia_util.h" @@ -1288,20 +1289,31 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { relativeTo:nil]; } - NSVisualEffectMaterial vibrancyType = NSVisualEffectMaterialLight; + std::string dep_warn = + " has been deprecated and will be removed in a future version of macOS."; + node::Environment* env = + node::Environment::GetCurrent(v8::Isolate::GetCurrent()); + + NSVisualEffectMaterial vibrancyType; if (type == "appearance-based") { + EmitDeprecationWarning( + env, "NSVisualEffectMaterialAppearanceBased" + dep_warn, "electron"); vibrancyType = NSVisualEffectMaterialAppearanceBased; } else if (type == "light") { + EmitDeprecationWarning(env, "NSVisualEffectMaterialLight" + dep_warn, + "electron"); vibrancyType = NSVisualEffectMaterialLight; } else if (type == "dark") { + EmitDeprecationWarning(env, "NSVisualEffectMaterialDark" + dep_warn, + "electron"); vibrancyType = NSVisualEffectMaterialDark; } else if (type == "titlebar") { vibrancyType = NSVisualEffectMaterialTitlebar; } if (@available(macOS 10.11, *)) { - // TODO(kevinsawicki): Use NSVisualEffectMaterial* constants directly once + // TODO(codebytere): Use NSVisualEffectMaterial* constants directly once // they are available in the minimum SDK version if (type == "selection") { // NSVisualEffectMaterialSelection @@ -1317,14 +1329,19 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) { vibrancyType = static_cast(7); } else if (type == "medium-light") { // NSVisualEffectMaterialMediumLight + EmitDeprecationWarning( + env, "NSVisualEffectMaterialMediumLight" + dep_warn, "electron"); vibrancyType = static_cast(8); } else if (type == "ultra-dark") { // NSVisualEffectMaterialUltraDark + EmitDeprecationWarning(env, "NSVisualEffectMaterialUltraDark" + dep_warn, + "electron"); vibrancyType = static_cast(9); } } - [effect_view setMaterial:vibrancyType]; + if (vibrancyType) + [effect_view setMaterial:vibrancyType]; } void NativeWindowMac::SetTouchBar( diff --git a/spec/ts-smoke/electron/main.ts b/spec/ts-smoke/electron/main.ts index 2bc4e8959a0c3..c143b9e675ead 100644 --- a/spec/ts-smoke/electron/main.ts +++ b/spec/ts-smoke/electron/main.ts @@ -324,8 +324,10 @@ window.setRepresentedFilename('/etc/passwd') window.setDocumentEdited(true) window.previewFile('/path/to/file') window.previewFile('/path/to/file', 'Displayed Name') -window.setVibrancy('light') +window.setVibrancy('menu') window.setVibrancy('titlebar') +window.setVibrancy('selection') +window.setVibrancy('popover') // Online/Offline Event Detection // https://github.com/atom/electron/blob/master/docs/tutorial/online-offline-events.md From da64fae690fc1143ce0fb0d007424d2ba3912275 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp Date: Wed, 3 Jul 2019 15:41:37 -0700 Subject: [PATCH 40/46] test: disable IAP tests that hit Apple servers (#19100) --- spec/api-in-app-purchase-spec.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/spec/api-in-app-purchase-spec.js b/spec/api-in-app-purchase-spec.js index b241e4a1fdb2f..816fc706b7084 100644 --- a/spec/api-in-app-purchase-spec.js +++ b/spec/api-in-app-purchase-spec.js @@ -38,17 +38,22 @@ describe('inAppPurchase module', function () { expect(correctUrlEnd).to.be.true() }) - it('purchaseProduct() fails when buying invalid product', async () => { + // The following three tests are disabled because they hit Apple servers, and + // Apple started blocking requests from AWS IPs (we think), so they fail on + // CI. + // TODO: find a way to mock out the server requests so we can test these APIs + // without relying on a remote service. + xit('purchaseProduct() fails when buying invalid product', async () => { const success = await inAppPurchase.purchaseProduct('non-exist', 1) expect(success).to.be.false() }) - it('purchaseProduct() accepts optional arguments', async () => { + xit('purchaseProduct() accepts optional arguments', async () => { const success = await inAppPurchase.purchaseProduct('non-exist') expect(success).to.be.false() }) - it('getProducts() returns an empty list when getting invalid product', async () => { + xit('getProducts() returns an empty list when getting invalid product', async () => { const products = await inAppPurchase.getProducts(['non-exist']) expect(products).to.be.an('array').of.length(0) }) From e6108740c0361946cf386950524e1c879f57e72e Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Wed, 3 Jul 2019 15:42:06 -0700 Subject: [PATCH 41/46] fix: handle no env in externsion world set up (#19101) Previously when GetEnvironment returned null this extension setup crashed. --- shell/renderer/atom_renderer_client.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/shell/renderer/atom_renderer_client.cc b/shell/renderer/atom_renderer_client.cc index ce59027d3ed15..f8b0c0c02ee20 100644 --- a/shell/renderer/atom_renderer_client.cc +++ b/shell/renderer/atom_renderer_client.cc @@ -202,8 +202,11 @@ void AtomRendererClient::SetupMainWorldOverrides( node::FIXED_ONE_BYTE_STRING(isolate, "nodeProcess"), node::FIXED_ONE_BYTE_STRING(isolate, "isolatedWorld")}; + auto* env = GetEnvironment(render_frame); + DCHECK(env); + std::vector> isolated_bundle_args = { - GetEnvironment(render_frame)->process_object(), + env->process_object(), GetContext(render_frame->GetWebFrame(), isolate)->Global()}; node::per_process::native_module_loader.CompileAndCall( @@ -222,8 +225,12 @@ void AtomRendererClient::SetupExtensionWorldOverrides( node::FIXED_ONE_BYTE_STRING(isolate, "isolatedWorld"), node::FIXED_ONE_BYTE_STRING(isolate, "worldId")}; + auto* env = GetEnvironment(render_frame); + if (!env) + return; + std::vector> isolated_bundle_args = { - GetEnvironment(render_frame)->process_object(), + env->process_object(), GetContext(render_frame->GetWebFrame(), isolate)->Global(), v8::Integer::New(isolate, world_id)}; From 5a1b661f420d5fcd15daaabf2f6a3cdd76ec9927 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Wed, 3 Jul 2019 16:36:44 -0700 Subject: [PATCH 42/46] fix: use bidning.ipc instead of binding.sendTo which is undefined (#19103) --- lib/renderer/ipc-renderer-internal.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/renderer/ipc-renderer-internal.ts b/lib/renderer/ipc-renderer-internal.ts index 7d4884c226bb5..4e0c55b9b14ff 100644 --- a/lib/renderer/ipc-renderer-internal.ts +++ b/lib/renderer/ipc-renderer-internal.ts @@ -14,9 +14,9 @@ ipcRendererInternal.sendSync = function (channel, ...args) { } ipcRendererInternal.sendTo = function (webContentsId, channel, ...args) { - return binding.sendTo(internal, false, webContentsId, channel, args) + return binding.ipc.sendTo(internal, false, webContentsId, channel, args) } ipcRendererInternal.sendToAll = function (webContentsId, channel, ...args) { - return binding.sendTo(internal, true, webContentsId, channel, args) + return binding.ipc.sendTo(internal, true, webContentsId, channel, args) } From 4b674c1daf2c291c2459925ed417dfdbd930ddb8 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Wed, 3 Jul 2019 16:36:59 -0700 Subject: [PATCH 43/46] build: ensure that we bundle the correct version of @types/node (#19102) --- npm/package.json | 2 +- spec-main/types-spec.ts | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 spec-main/types-spec.ts diff --git a/npm/package.json b/npm/package.json index 43bb4a698256f..694e63385f7fb 100644 --- a/npm/package.json +++ b/npm/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "@electron/get": "^1.0.1", - "@types/node": "^10.12.18", + "@types/node": "^12.0.12", "extract-zip": "^1.0.3" }, "engines": { diff --git a/spec-main/types-spec.ts b/spec-main/types-spec.ts new file mode 100644 index 0000000000000..b0de8df6f133a --- /dev/null +++ b/spec-main/types-spec.ts @@ -0,0 +1,10 @@ +import { expect } from 'chai' + +describe('bundled @types/node', () => { + it('should match the major version of bundled node', () => { + expect(require('../npm/package.json').dependencies).to.have.property('@types/node') + const range = require('../npm/package.json').dependencies['@types/node'] + expect(range).to.match(/^\^.+/, 'should allow any type dep in a major range') + expect(range.slice(1).split('.')[0]).to.equal(process.versions.node.split('.')[0]) + }) +}) From 2a3793485f71b8ec102a324ab61804c8c093a21e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 4 Jul 2019 10:56:19 +0900 Subject: [PATCH 44/46] feat: implement net module with NetworkService (#19094) * Stub class for NetworkService-based URLRequest * Create SimpleURLLoader * Implement downloading * Implement response event * Only write data afte previous one finished * Use DataPipeGetter for uploading data * Support chunked upload data * Call size callback at last * Simplify UploadDataPipeGetter * Implement cancelling and closing * Handle redirection * Fix uploading large data * Emit error when request fails * Emit error for redirection error * Simplify emitting error * "follow" should also emit "redirect" event * SetLoadFlags is not really used * Implement GetUploadProgress * Implement FollowRedirect * Fix exception with multiple redirections * Reduce number of EmitEvent methods * Emit response errors * FetchRedirectMode => RedirectMode --- filenames.gni | 2 + shell/browser/api/atom_api_net.cc | 21 +- shell/browser/api/atom_api_url_request.h | 3 +- shell/browser/api/atom_api_url_request_ns.cc | 544 +++++++++++++++++++ shell/browser/api/atom_api_url_request_ns.h | 143 +++++ 5 files changed, 708 insertions(+), 5 deletions(-) create mode 100644 shell/browser/api/atom_api_url_request_ns.cc create mode 100644 shell/browser/api/atom_api_url_request_ns.h diff --git a/filenames.gni b/filenames.gni index ef18228df675f..901c768f7c175 100644 --- a/filenames.gni +++ b/filenames.gni @@ -93,6 +93,8 @@ filenames = { "shell/browser/api/atom_api_tray.h", "shell/browser/api/atom_api_url_request.cc", "shell/browser/api/atom_api_url_request.h", + "shell/browser/api/atom_api_url_request_ns.cc", + "shell/browser/api/atom_api_url_request_ns.h", "shell/browser/api/atom_api_view.cc", "shell/browser/api/atom_api_view.h", "shell/browser/api/atom_api_web_contents.cc", diff --git a/shell/browser/api/atom_api_net.cc b/shell/browser/api/atom_api_net.cc index 3282f3f44ab79..df0c481a0b9ed 100644 --- a/shell/browser/api/atom_api_net.cc +++ b/shell/browser/api/atom_api_net.cc @@ -3,8 +3,12 @@ // found in the LICENSE file. #include "shell/browser/api/atom_api_net.h" + #include "native_mate/dictionary.h" +#include "services/network/public/cpp/features.h" #include "shell/browser/api/atom_api_url_request.h" +#include "shell/browser/api/atom_api_url_request_ns.h" + #include "shell/common/node_includes.h" namespace electron { @@ -31,8 +35,12 @@ void Net::BuildPrototype(v8::Isolate* isolate, } v8::Local Net::URLRequest(v8::Isolate* isolate) { - return URLRequest::GetConstructor(isolate) - ->GetFunction(isolate->GetCurrentContext()) + v8::Local constructor; + if (base::FeatureList::IsEnabled(network::features::kNetworkService)) + constructor = URLRequestNS::GetConstructor(isolate); + else + constructor = URLRequest::GetConstructor(isolate); + return constructor->GetFunction(isolate->GetCurrentContext()) .ToLocalChecked(); } @@ -44,6 +52,7 @@ namespace { using electron::api::Net; using electron::api::URLRequest; +using electron::api::URLRequestNS; void Initialize(v8::Local exports, v8::Local unused, @@ -51,12 +60,18 @@ void Initialize(v8::Local exports, void* priv) { v8::Isolate* isolate = context->GetIsolate(); - URLRequest::SetConstructor(isolate, base::BindRepeating(URLRequest::New)); + if (base::FeatureList::IsEnabled(network::features::kNetworkService)) + URLRequestNS::SetConstructor(isolate, + base::BindRepeating(URLRequestNS::New)); + else + URLRequest::SetConstructor(isolate, base::BindRepeating(URLRequest::New)); mate::Dictionary dict(isolate, exports); dict.Set("net", Net::Create(isolate)); dict.Set("Net", Net::GetConstructor(isolate)->GetFunction(context).ToLocalChecked()); + dict.Set("isNetworkServiceEnabled", + base::FeatureList::IsEnabled(network::features::kNetworkService)); } } // namespace diff --git a/shell/browser/api/atom_api_url_request.h b/shell/browser/api/atom_api_url_request.h index 8cf182a5c1415..de45ab08225a5 100644 --- a/shell/browser/api/atom_api_url_request.h +++ b/shell/browser/api/atom_api_url_request.h @@ -25,7 +25,6 @@ class AtomURLRequest; namespace api { -// // The URLRequest class implements the V8 binding between the JavaScript API // and Chromium native net library. It is responsible for handling HTTP/HTTPS // requests. @@ -114,7 +113,7 @@ class URLRequest : public mate::EventEmitter { mate::Dictionary GetUploadProgress(v8::Isolate* isolate); protected: - explicit URLRequest(v8::Isolate* isolate, v8::Local wrapper); + URLRequest(v8::Isolate* isolate, v8::Local wrapper); ~URLRequest() override; private: diff --git a/shell/browser/api/atom_api_url_request_ns.cc b/shell/browser/api/atom_api_url_request_ns.cc new file mode 100644 index 0000000000000..cb307e87d317e --- /dev/null +++ b/shell/browser/api/atom_api_url_request_ns.cc @@ -0,0 +1,544 @@ +// Copyright (c) 2019 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "shell/browser/api/atom_api_url_request_ns.h" + +#include + +#include "content/public/browser/storage_partition.h" +#include "native_mate/dictionary.h" +#include "native_mate/object_template_builder.h" +#include "shell/browser/api/atom_api_session.h" +#include "shell/browser/atom_browser_context.h" +#include "shell/common/native_mate_converters/gurl_converter.h" +#include "shell/common/native_mate_converters/net_converter.h" + +#include "shell/common/node_includes.h" + +namespace mate { + +template <> +struct Converter { + static bool FromV8(v8::Isolate* isolate, + v8::Local val, + network::mojom::RedirectMode* out) { + std::string mode; + if (!ConvertFromV8(isolate, val, &mode)) + return false; + if (mode == "follow") + *out = network::mojom::RedirectMode::kFollow; + else if (mode == "error") + *out = network::mojom::RedirectMode::kError; + else if (mode == "manual") + *out = network::mojom::RedirectMode::kManual; + else + return false; + return true; + } +}; + +} // namespace mate + +namespace electron { + +namespace api { + +namespace { + +// Network state for request and response. +enum State { + STATE_STARTED = 1 << 0, + STATE_FINISHED = 1 << 1, + STATE_CANCELED = 1 << 2, + STATE_FAILED = 1 << 3, + STATE_CLOSED = 1 << 4, + STATE_ERROR = STATE_CANCELED | STATE_FAILED | STATE_CLOSED, +}; + +// Annotation tag passed to NetworkService. +const net::NetworkTrafficAnnotationTag kTrafficAnnotation = + net::DefineNetworkTrafficAnnotation("electron_net_module", R"( + semantics { + sender: "Electron Net module" + description: + "Issue HTTP/HTTPS requests using Chromium's native networking " + "library." + trigger: "Using the Net module" + data: "Anything the user wants to send." + destination: OTHER + } + policy { + cookies_allowed: YES + cookies_store: "user" + setting: "This feature cannot be disabled." + })"); + +} // namespace + +// Common class for streaming data. +class UploadDataPipeGetter { + public: + explicit UploadDataPipeGetter(URLRequestNS* request) : request_(request) {} + virtual ~UploadDataPipeGetter() = default; + + virtual void AttachToRequestBody(network::ResourceRequestBody* body) = 0; + + protected: + void SetCallback(network::mojom::DataPipeGetter::ReadCallback callback) { + request_->size_callback_ = std::move(callback); + } + + void SetPipe(mojo::ScopedDataPipeProducerHandle pipe) { + request_->producer_ = + std::make_unique(std::move(pipe)); + request_->StartWriting(); + } + + private: + URLRequestNS* request_; + + DISALLOW_COPY_AND_ASSIGN(UploadDataPipeGetter); +}; + +// Streaming multipart data to NetworkService. +class MultipartDataPipeGetter : public UploadDataPipeGetter, + public network::mojom::DataPipeGetter { + public: + explicit MultipartDataPipeGetter(URLRequestNS* request) + : UploadDataPipeGetter(request) {} + ~MultipartDataPipeGetter() override = default; + + void AttachToRequestBody(network::ResourceRequestBody* body) override { + network::mojom::DataPipeGetterPtr data_pipe_getter; + binding_set_.AddBinding(this, mojo::MakeRequest(&data_pipe_getter)); + body->AppendDataPipe(std::move(data_pipe_getter)); + } + + private: + // network::mojom::DataPipeGetter: + void Read(mojo::ScopedDataPipeProducerHandle pipe, + ReadCallback callback) override { + SetCallback(std::move(callback)); + SetPipe(std::move(pipe)); + } + + void Clone(network::mojom::DataPipeGetterRequest request) override { + binding_set_.AddBinding(this, std::move(request)); + } + + mojo::BindingSet binding_set_; +}; + +// Streaming chunked data to NetworkService. +class ChunkedDataPipeGetter : public UploadDataPipeGetter, + public network::mojom::ChunkedDataPipeGetter { + public: + explicit ChunkedDataPipeGetter(URLRequestNS* request) + : UploadDataPipeGetter(request) {} + ~ChunkedDataPipeGetter() override = default; + + void AttachToRequestBody(network::ResourceRequestBody* body) override { + network::mojom::ChunkedDataPipeGetterPtr data_pipe_getter; + binding_set_.AddBinding(this, mojo::MakeRequest(&data_pipe_getter)); + body->SetToChunkedDataPipe(std::move(data_pipe_getter)); + } + + private: + // network::mojom::ChunkedDataPipeGetter: + void GetSize(GetSizeCallback callback) override { + SetCallback(std::move(callback)); + } + + void StartReading(mojo::ScopedDataPipeProducerHandle pipe) override { + SetPipe(std::move(pipe)); + } + + mojo::BindingSet binding_set_; +}; + +URLRequestNS::URLRequestNS(mate::Arguments* args) : weak_factory_(this) { + request_ = std::make_unique(); + mate::Dictionary dict; + if (args->GetNext(&dict)) { + dict.Get("method", &request_->method); + dict.Get("url", &request_->url); + dict.Get("redirect", &redirect_mode_); + request_->redirect_mode = redirect_mode_; + } + + std::string partition; + mate::Handle session; + if (!dict.Get("session", &session)) { + if (dict.Get("partition", &partition)) + session = Session::FromPartition(args->isolate(), partition); + else // default session + session = Session::FromPartition(args->isolate(), ""); + } + + auto* browser_context = session->browser_context(); + url_loader_factory_ = + content::BrowserContext::GetDefaultStoragePartition(browser_context) + ->GetURLLoaderFactoryForBrowserProcess(); + + InitWith(args->isolate(), args->GetThis()); +} + +URLRequestNS::~URLRequestNS() {} + +bool URLRequestNS::NotStarted() const { + return request_state_ == 0; +} + +bool URLRequestNS::Finished() const { + return request_state_ & STATE_FINISHED; +} + +void URLRequestNS::Cancel() { + // Cancel only once. + if (request_state_ & (STATE_CANCELED | STATE_CLOSED)) + return; + + // Mark as canceled. + request_state_ |= STATE_CANCELED; + EmitEvent(EventType::kRequest, true, "abort"); + + if ((response_state_ & STATE_STARTED) && !(response_state_ & STATE_FINISHED)) + EmitEvent(EventType::kResponse, true, "aborted"); + + Close(); +} + +void URLRequestNS::Close() { + if (!(request_state_ & STATE_CLOSED)) { + request_state_ |= STATE_CLOSED; + if (response_state_ & STATE_STARTED) { + // Emit a close event if we really have a response object. + EmitEvent(EventType::kResponse, true, "close"); + } + EmitEvent(EventType::kRequest, true, "close"); + } + Unpin(); + loader_.reset(); +} + +bool URLRequestNS::Write(v8::Local data, bool is_last) { + if (request_state_ & (STATE_FINISHED | STATE_ERROR)) + return false; + + size_t length = node::Buffer::Length(data); + + if (!loader_) { + // Pin on first write. + request_state_ = STATE_STARTED; + Pin(); + + // Create the loader. + network::ResourceRequest* request_ref = request_.get(); + loader_ = network::SimpleURLLoader::Create(std::move(request_), + kTrafficAnnotation); + loader_->SetOnResponseStartedCallback(base::Bind( + &URLRequestNS::OnResponseStarted, weak_factory_.GetWeakPtr())); + loader_->SetOnRedirectCallback( + base::Bind(&URLRequestNS::OnRedirect, weak_factory_.GetWeakPtr())); + loader_->SetOnUploadProgressCallback(base::Bind( + &URLRequestNS::OnUploadProgress, weak_factory_.GetWeakPtr())); + + // Create upload data pipe if we have data to write. + if (length > 0) { + request_ref->request_body = new network::ResourceRequestBody(); + if (is_chunked_upload_) + data_pipe_getter_ = std::make_unique(this); + else + data_pipe_getter_ = std::make_unique(this); + data_pipe_getter_->AttachToRequestBody(request_ref->request_body.get()); + } + + // Start downloading. + loader_->DownloadAsStream(url_loader_factory_.get(), this); + } + + if (length > 0) + pending_writes_.emplace_back(node::Buffer::Data(data), length); + + if (is_last) { + // The ElementsUploadDataStream requires the knowledge of content length + // before doing upload, while Node's stream does not give us any size + // information. So the only option left for us is to keep all the write + // data in memory and flush them after the write is done. + // + // While this looks frustrating, it is actually the behavior of the non- + // NetworkService implementation, and we are not breaking anything. + if (!pending_writes_.empty()) { + last_chunk_written_ = true; + StartWriting(); + } + + request_state_ |= STATE_FINISHED; + EmitEvent(EventType::kRequest, true, "finish"); + } + return true; +} + +void URLRequestNS::FollowRedirect() { + if (request_state_ & (STATE_CANCELED | STATE_CLOSED)) + return; + follow_redirect_ = true; +} + +bool URLRequestNS::SetExtraHeader(const std::string& name, + const std::string& value) { + if (!request_) + return false; + if (!net::HttpUtil::IsValidHeaderName(name)) + return false; + if (!net::HttpUtil::IsValidHeaderValue(value)) + return false; + request_->headers.SetHeader(name, value); + return true; +} + +void URLRequestNS::RemoveExtraHeader(const std::string& name) { + if (request_) + request_->headers.RemoveHeader(name); +} + +void URLRequestNS::SetChunkedUpload(bool is_chunked_upload) { + if (request_) + is_chunked_upload_ = is_chunked_upload; +} + +mate::Dictionary URLRequestNS::GetUploadProgress() { + mate::Dictionary progress = mate::Dictionary::CreateEmpty(isolate()); + if (loader_) { + if (request_) + progress.Set("started", false); + else + progress.Set("started", true); + progress.Set("current", upload_position_); + progress.Set("total", upload_total_); + progress.Set("active", true); + } else { + progress.Set("active", false); + } + return progress; +} + +int URLRequestNS::StatusCode() const { + if (response_headers_) + return response_headers_->response_code(); + return -1; +} + +std::string URLRequestNS::StatusMessage() const { + if (response_headers_) + return response_headers_->GetStatusText(); + return ""; +} + +net::HttpResponseHeaders* URLRequestNS::RawResponseHeaders() const { + return response_headers_.get(); +} + +uint32_t URLRequestNS::ResponseHttpVersionMajor() const { + if (response_headers_) + return response_headers_->GetHttpVersion().major_value(); + return 0; +} + +uint32_t URLRequestNS::ResponseHttpVersionMinor() const { + if (response_headers_) + return response_headers_->GetHttpVersion().minor_value(); + return 0; +} + +void URLRequestNS::OnDataReceived(base::StringPiece data, + base::OnceClosure resume) { + // In case we received an unexpected event from Chromium net, don't emit any + // data event after request cancel/error/close. + if (!(request_state_ & STATE_ERROR) && !(response_state_ & STATE_ERROR)) { + v8::HandleScope handle_scope(isolate()); + v8::Local buffer; + auto maybe = node::Buffer::Copy(isolate(), data.data(), data.size()); + if (maybe.ToLocal(&buffer)) + Emit("data", buffer); + } + std::move(resume).Run(); +} + +void URLRequestNS::OnRetry(base::OnceClosure start_retry) {} + +void URLRequestNS::OnComplete(bool success) { + if (success) { + // In case we received an unexpected event from Chromium net, don't emit any + // data event after request cancel/error/close. + if (!(request_state_ & STATE_ERROR) && !(response_state_ & STATE_ERROR)) { + response_state_ |= STATE_FINISHED; + Emit("end"); + } + } else { // failed + // If response is started then emit response event, else emit request error. + // + // Error is only emitted when there is no previous failure. This is to align + // with the behavior of non-NetworkService implementation. + std::string error = net::ErrorToString(loader_->NetError()); + if (response_state_ & STATE_STARTED) { + if (!(response_state_ & STATE_FAILED)) + EmitError(EventType::kResponse, error); + } else { + if (!(request_state_ & STATE_FAILED)) + EmitError(EventType::kRequest, error); + } + } + + Close(); +} + +void URLRequestNS::OnResponseStarted( + const GURL& final_url, + const network::ResourceResponseHead& response_head) { + // Don't emit any event after request cancel. + if (request_state_ & STATE_ERROR) + return; + + response_headers_ = response_head.headers; + response_state_ |= STATE_STARTED; + Emit("response"); +} + +void URLRequestNS::OnRedirect( + const net::RedirectInfo& redirect_info, + const network::ResourceResponseHead& response_head, + std::vector* to_be_removed_headers) { + if (!loader_) + return; + + if (request_state_ & (STATE_CLOSED | STATE_CANCELED)) { + NOTREACHED(); + Cancel(); + return; + } + + switch (redirect_mode_) { + case network::mojom::RedirectMode::kError: + EmitError( + EventType::kRequest, + "Request cannot follow redirect with the current redirect mode"); + break; + case network::mojom::RedirectMode::kManual: + // When redirect mode is "manual", the user has to explicitly call the + // FollowRedirect method to continue redirecting, otherwise the request + // would be cancelled. + // + // Note that the SimpleURLLoader always calls FollowRedirect and does not + // provide a formal way for us to cancel redirection, we have to cancel + // the request to prevent the redirection. + follow_redirect_ = false; + EmitEvent(EventType::kRequest, false, "redirect", + redirect_info.status_code, redirect_info.new_method, + redirect_info.new_url, response_head.headers.get()); + if (!follow_redirect_) + Cancel(); + break; + case network::mojom::RedirectMode::kFollow: + EmitEvent(EventType::kRequest, false, "redirect", + redirect_info.status_code, redirect_info.new_method, + redirect_info.new_url, response_head.headers.get()); + break; + } +} + +void URLRequestNS::OnUploadProgress(uint64_t position, uint64_t total) { + upload_position_ = position; + upload_total_ = total; +} + +void URLRequestNS::OnWrite(MojoResult result) { + if (result != MOJO_RESULT_OK) + return; + + // Continue the pending writes. + pending_writes_.pop_front(); + if (!pending_writes_.empty()) + DoWrite(); +} + +void URLRequestNS::DoWrite() { + DCHECK(producer_); + DCHECK(!pending_writes_.empty()); + producer_->Write( + pending_writes_.front(), + mojo::StringDataPipeProducer::AsyncWritingMode:: + STRING_STAYS_VALID_UNTIL_COMPLETION, + base::BindOnce(&URLRequestNS::OnWrite, weak_factory_.GetWeakPtr())); +} + +void URLRequestNS::StartWriting() { + if (!last_chunk_written_ || size_callback_.is_null()) + return; + + size_t size = 0; + for (const auto& data : pending_writes_) + size += data.size(); + std::move(size_callback_).Run(net::OK, size); + DoWrite(); +} + +void URLRequestNS::Pin() { + if (wrapper_.IsEmpty()) { + wrapper_.Reset(isolate(), GetWrapper()); + } +} + +void URLRequestNS::Unpin() { + wrapper_.Reset(); +} + +void URLRequestNS::EmitError(EventType type, base::StringPiece message) { + if (type == EventType::kRequest) + request_state_ |= STATE_FAILED; + else + response_state_ |= STATE_FAILED; + v8::HandleScope handle_scope(isolate()); + auto error = v8::Exception::Error(mate::StringToV8(isolate(), message)); + EmitEvent(type, false, "error", error); +} + +template +void URLRequestNS::EmitEvent(EventType type, Args... args) { + const char* method = + type == EventType::kRequest ? "_emitRequestEvent" : "_emitResponseEvent"; + v8::HandleScope handle_scope(isolate()); + mate::CustomEmit(isolate(), GetWrapper(), method, args...); +} + +// static +mate::WrappableBase* URLRequestNS::New(mate::Arguments* args) { + return new URLRequestNS(args); +} + +// static +void URLRequestNS::BuildPrototype(v8::Isolate* isolate, + v8::Local prototype) { + prototype->SetClassName(mate::StringToV8(isolate, "URLRequest")); + mate::ObjectTemplateBuilder(isolate, prototype->PrototypeTemplate()) + .MakeDestroyable() + .SetMethod("write", &URLRequestNS::Write) + .SetMethod("cancel", &URLRequestNS::Cancel) + .SetMethod("setExtraHeader", &URLRequestNS::SetExtraHeader) + .SetMethod("removeExtraHeader", &URLRequestNS::RemoveExtraHeader) + .SetMethod("setChunkedUpload", &URLRequestNS::SetChunkedUpload) + .SetMethod("followRedirect", &URLRequestNS::FollowRedirect) + .SetMethod("getUploadProgress", &URLRequestNS::GetUploadProgress) + .SetProperty("notStarted", &URLRequestNS::NotStarted) + .SetProperty("finished", &URLRequestNS::Finished) + .SetProperty("statusCode", &URLRequestNS::StatusCode) + .SetProperty("statusMessage", &URLRequestNS::StatusMessage) + .SetProperty("rawResponseHeaders", &URLRequestNS::RawResponseHeaders) + .SetProperty("httpVersionMajor", &URLRequestNS::ResponseHttpVersionMajor) + .SetProperty("httpVersionMinor", &URLRequestNS::ResponseHttpVersionMinor); +} + +} // namespace api + +} // namespace electron diff --git a/shell/browser/api/atom_api_url_request_ns.h b/shell/browser/api/atom_api_url_request_ns.h new file mode 100644 index 0000000000000..bd15ce536f7c6 --- /dev/null +++ b/shell/browser/api/atom_api_url_request_ns.h @@ -0,0 +1,143 @@ +// Copyright (c) 2019 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef SHELL_BROWSER_API_ATOM_API_URL_REQUEST_NS_H_ +#define SHELL_BROWSER_API_ATOM_API_URL_REQUEST_NS_H_ + +#include +#include +#include +#include + +#include "mojo/public/cpp/system/string_data_pipe_producer.h" +#include "native_mate/dictionary.h" +#include "services/network/public/cpp/shared_url_loader_factory.h" +#include "services/network/public/cpp/simple_url_loader.h" +#include "services/network/public/cpp/simple_url_loader_stream_consumer.h" +#include "services/network/public/mojom/data_pipe_getter.mojom.h" +#include "shell/browser/api/event_emitter.h" + +namespace electron { + +namespace api { + +class UploadDataPipeGetter; + +class URLRequestNS : public mate::EventEmitter, + public network::SimpleURLLoaderStreamConsumer { + public: + static mate::WrappableBase* New(mate::Arguments* args); + + static void BuildPrototype(v8::Isolate* isolate, + v8::Local prototype); + + protected: + explicit URLRequestNS(mate::Arguments* args); + ~URLRequestNS() override; + + bool NotStarted() const; + bool Finished() const; + + void Cancel(); + void Close(); + + bool Write(v8::Local data, bool is_last); + void FollowRedirect(); + bool SetExtraHeader(const std::string& name, const std::string& value); + void RemoveExtraHeader(const std::string& name); + void SetChunkedUpload(bool is_chunked_upload); + mate::Dictionary GetUploadProgress(); + int StatusCode() const; + std::string StatusMessage() const; + net::HttpResponseHeaders* RawResponseHeaders() const; + uint32_t ResponseHttpVersionMajor() const; + uint32_t ResponseHttpVersionMinor() const; + + // SimpleURLLoaderStreamConsumer: + void OnDataReceived(base::StringPiece string_piece, + base::OnceClosure resume) override; + void OnComplete(bool success) override; + void OnRetry(base::OnceClosure start_retry) override; + + private: + friend class UploadDataPipeGetter; + + void OnResponseStarted(const GURL& final_url, + const network::ResourceResponseHead& response_head); + void OnRedirect(const net::RedirectInfo& redirect_info, + const network::ResourceResponseHead& response_head, + std::vector* to_be_removed_headers); + void OnUploadProgress(uint64_t position, uint64_t total); + void OnWrite(MojoResult result); + + // Write the first data of |pending_writes_|. + void DoWrite(); + + // Start streaming. + void StartWriting(); + + // Manage lifetime of wrapper. + void Pin(); + void Unpin(); + + // Emit events. + enum class EventType { + kRequest, + kResponse, + }; + void EmitError(EventType type, base::StringPiece error); + template + void EmitEvent(EventType type, Args... args); + + std::unique_ptr request_; + std::unique_ptr loader_; + scoped_refptr url_loader_factory_; + scoped_refptr response_headers_; + + // Redirect mode. + // + // Note that we store it ourselves instead of reading from the one stored in + // |request_|, this is because with multiple redirections, the original one + // might be modified. + network::mojom::RedirectMode redirect_mode_ = + network::mojom::RedirectMode::kFollow; + + // The DataPipeGetter passed to reader. + bool is_chunked_upload_ = false; + std::unique_ptr data_pipe_getter_; + + // Passed from DataPipeGetter for streaming data. + network::mojom::DataPipeGetter::ReadCallback size_callback_; + std::unique_ptr producer_; + + // Whether request.end() has been called. + bool last_chunk_written_ = false; + + // Whether the redirect should be followed. + bool follow_redirect_ = true; + + // Upload progress. + uint64_t upload_position_ = 0; + uint64_t upload_total_ = 0; + + // Current status. + int request_state_ = 0; + int response_state_ = 0; + + // Pending writes that not yet sent to NetworkService. + std::list pending_writes_; + + // Used by pin/unpin to manage lifetime. + v8::Global wrapper_; + + base::WeakPtrFactory weak_factory_; + + DISALLOW_COPY_AND_ASSIGN(URLRequestNS); +}; + +} // namespace api + +} // namespace electron + +#endif // SHELL_BROWSER_API_ATOM_API_URL_REQUEST_NS_H_ From c933d19a1b7d98be69878ef66801e9c8fa68e4ef Mon Sep 17 00:00:00 2001 From: Electron Bot Date: Thu, 4 Jul 2019 08:32:21 -0700 Subject: [PATCH 45/46] Bump v7.0.0-nightly.20190704 --- ELECTRON_VERSION | 2 +- package.json | 2 +- shell/browser/resources/win/atom.rc | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ELECTRON_VERSION b/ELECTRON_VERSION index 5d22ec1687c3d..488d787aff033 100644 --- a/ELECTRON_VERSION +++ b/ELECTRON_VERSION @@ -1 +1 @@ -7.0.0-nightly.20190703 \ No newline at end of file +7.0.0-nightly.20190704 \ No newline at end of file diff --git a/package.json b/package.json index b874947562198..53f19a7e33d8b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "electron", - "version": "7.0.0-nightly.20190703", + "version": "7.0.0-nightly.20190704", "repository": "https://github.com/electron/electron", "description": "Build cross platform desktop apps with JavaScript, HTML, and CSS", "devDependencies": { diff --git a/shell/browser/resources/win/atom.rc b/shell/browser/resources/win/atom.rc index 8f756a5f46509..81f64f35e8990 100644 --- a/shell/browser/resources/win/atom.rc +++ b/shell/browser/resources/win/atom.rc @@ -50,8 +50,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 7,0,0,20190703 - PRODUCTVERSION 7,0,0,20190703 + FILEVERSION 7,0,0,20190704 + PRODUCTVERSION 7,0,0,20190704 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L From 87b1dab4972a859be53afedba2369a3a5abe7da0 Mon Sep 17 00:00:00 2001 From: Milan Burda Date: Thu, 4 Jul 2019 18:22:08 +0200 Subject: [PATCH 46/46] fix: check parent-child relationship in canAccessWindow (#19077) --- lib/browser/guest-window-manager.js | 31 ++++++++++++++++++----------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/browser/guest-window-manager.js b/lib/browser/guest-window-manager.js index fb8b8ddd5e3e6..68987ddb9db0c 100644 --- a/lib/browser/guest-window-manager.js +++ b/lib/browser/guest-window-manager.js @@ -156,20 +156,27 @@ const getGuestWindow = function (guestContents) { return guestWindow } +const isChildWindow = function (sender, target) { + return target.getLastWebPreferences().openerId === sender.id +} + +const isRelatedWindow = function (sender, target) { + return isChildWindow(sender, target) || isChildWindow(target, sender) +} + +const isScriptableWindow = function (sender, target) { + return isRelatedWindow(sender, target) && isSameOrigin(sender.getURL(), target.getURL()) +} + +const isNodeIntegrationEnabled = function (sender) { + return sender.getLastWebPreferences().nodeIntegration === true +} + // Checks whether |sender| can access the |target|: -// 1. Check whether |sender| is the parent of |target|. -// 2. Check whether |sender| has node integration, if so it is allowed to -// do anything it wants. -// 3. Check whether the origins match. -// -// However it allows a child window without node integration but with same -// origin to do anything it wants, when its opener window has node integration. -// The W3C does not have anything on this, but from my understanding of the -// security model of |window.opener|, this should be fine. const canAccessWindow = function (sender, target) { - return (target.getLastWebPreferences().openerId === sender.id) || - (sender.getLastWebPreferences().nodeIntegration === true) || - isSameOrigin(sender.getURL(), target.getURL()) + return isChildWindow(sender, target) || + isScriptableWindow(sender, target) || + isNodeIntegrationEnabled(sender) } // Routed window.open messages with raw options