mirror of
https://github.com/electron/electron.git
synced 2026-02-26 03:01:17 -05:00
Compare commits
158 Commits
v18.0.0-be
...
v18.3.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6165f6afc9 | ||
|
|
35f871c702 | ||
|
|
8c3c382673 | ||
|
|
16ae9e16cf | ||
|
|
1d14d15d8c | ||
|
|
32df7f58bb | ||
|
|
66c3319458 | ||
|
|
49955512a8 | ||
|
|
977dc2527e | ||
|
|
4f70332460 | ||
|
|
d8e1f4f73b | ||
|
|
ec40581e83 | ||
|
|
22cdcf400c | ||
|
|
1b36d1d175 | ||
|
|
4578597dea | ||
|
|
20deb65058 | ||
|
|
7b7d22fa7c | ||
|
|
851350b9f3 | ||
|
|
7162f641b5 | ||
|
|
88e3f4a1e6 | ||
|
|
0d1900048d | ||
|
|
af65324717 | ||
|
|
6d1cc18322 | ||
|
|
4d73469ed5 | ||
|
|
ca17f574de | ||
|
|
a5fdd272b1 | ||
|
|
15f3c45fe9 | ||
|
|
3f01fb3110 | ||
|
|
96789ee78b | ||
|
|
4b8885ffc8 | ||
|
|
c47b196d02 | ||
|
|
d67c319642 | ||
|
|
6839dd92b8 | ||
|
|
d468a73edb | ||
|
|
e4dbd1407e | ||
|
|
37a422d05b | ||
|
|
26e7f27110 | ||
|
|
707e8d5b7b | ||
|
|
6fda94858d | ||
|
|
1eece7ada0 | ||
|
|
c33bfffeec | ||
|
|
02bf71fb43 | ||
|
|
74b85afca4 | ||
|
|
fbc398f9bc | ||
|
|
4c32d141d8 | ||
|
|
88bedfcf25 | ||
|
|
f4ba63536a | ||
|
|
f024af603c | ||
|
|
9c669210c4 | ||
|
|
1bd99405ad | ||
|
|
ef939db944 | ||
|
|
e7e8b324ff | ||
|
|
b4533d19e6 | ||
|
|
2ecc68621f | ||
|
|
0971add78a | ||
|
|
ebd134881b | ||
|
|
448069cd04 | ||
|
|
7afc5ab88e | ||
|
|
601ca745c1 | ||
|
|
ba3a6c1193 | ||
|
|
af3e3ff0cb | ||
|
|
85e19bd0ad | ||
|
|
cc428fdea2 | ||
|
|
553573e6ff | ||
|
|
f057e0669d | ||
|
|
4ae399e4eb | ||
|
|
418c957e13 | ||
|
|
fe96879a9d | ||
|
|
8acf68c980 | ||
|
|
11a0e2a402 | ||
|
|
fabdfb2c18 | ||
|
|
eca4b1325f | ||
|
|
3bc25c997d | ||
|
|
b715e8714a | ||
|
|
2a0828e69a | ||
|
|
5d46db1839 | ||
|
|
9d482f438a | ||
|
|
7630fc801e | ||
|
|
6b2375cba0 | ||
|
|
c017200e85 | ||
|
|
daf55a81b1 | ||
|
|
067314ec32 | ||
|
|
a128449e3d | ||
|
|
de74dce663 | ||
|
|
0e3a558913 | ||
|
|
e2d4a98c76 | ||
|
|
015e9a8843 | ||
|
|
1fc8f72126 | ||
|
|
6a91276172 | ||
|
|
32ab3297fa | ||
|
|
3b4e17e7e2 | ||
|
|
6c314dc08b | ||
|
|
cd6a17db08 | ||
|
|
b6d6f86ee8 | ||
|
|
178688fe61 | ||
|
|
40f6e2ee7e | ||
|
|
f747f071fb | ||
|
|
8476bfbcaa | ||
|
|
d1abb62943 | ||
|
|
86bf9ea252 | ||
|
|
ffb8749243 | ||
|
|
feea88600a | ||
|
|
89188cd4e9 | ||
|
|
45c1d22489 | ||
|
|
3f39d85501 | ||
|
|
2dd7749181 | ||
|
|
5634ddc665 | ||
|
|
6de6d3966a | ||
|
|
02562e903b | ||
|
|
718ef5269f | ||
|
|
ddaa4a9686 | ||
|
|
f646744d32 | ||
|
|
75ccd1fb65 | ||
|
|
f30034d1a9 | ||
|
|
00b6524793 | ||
|
|
f8f08814a2 | ||
|
|
0a758c418c | ||
|
|
daff2057a4 | ||
|
|
67f2f9e024 | ||
|
|
3ee1a45d76 | ||
|
|
652d87282a | ||
|
|
923788b4e4 | ||
|
|
541504c8a4 | ||
|
|
490584834e | ||
|
|
a269ebd1d8 | ||
|
|
0f073186ff | ||
|
|
73e216f182 | ||
|
|
0a80eb4a9c | ||
|
|
50e386ead4 | ||
|
|
5f0810a177 | ||
|
|
65f3729bfb | ||
|
|
b5bdd26a45 | ||
|
|
9ac2ee317d | ||
|
|
a600027384 | ||
|
|
7f82836d67 | ||
|
|
769088f8dc | ||
|
|
c85bc3c932 | ||
|
|
3cd795a927 | ||
|
|
6179b03fa1 | ||
|
|
72c48aa400 | ||
|
|
befe53e5ad | ||
|
|
41aaed307d | ||
|
|
0d17fac455 | ||
|
|
5c3d6aaa81 | ||
|
|
da6996dc63 | ||
|
|
4cfa648a2e | ||
|
|
86294aa1d0 | ||
|
|
50d9fd215e | ||
|
|
06b3615e30 | ||
|
|
8680415128 | ||
|
|
35bf159cd3 | ||
|
|
f8c7408279 | ||
|
|
9b1e7a8963 | ||
|
|
765e1025f4 | ||
|
|
a5d2a56105 | ||
|
|
d8f43ed7bd | ||
|
|
f1b30c26f9 | ||
|
|
c80f701085 |
1
.circleci/.gitignore
vendored
Normal file
1
.circleci/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
config-staging
|
||||
@@ -6,6 +6,7 @@ setup: true
|
||||
# Orbs
|
||||
orbs:
|
||||
path-filtering: circleci/path-filtering@0.1.0
|
||||
continuation: circleci/continuation@0.2.0
|
||||
|
||||
# All input parameters to pass to build config
|
||||
parameters:
|
||||
@@ -13,7 +14,7 @@ parameters:
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
upload-to-s3:
|
||||
upload-to-storage:
|
||||
type: string
|
||||
default: '1'
|
||||
|
||||
@@ -43,103 +44,33 @@ parameters:
|
||||
default: all
|
||||
enum: ["all", "osx-x64", "osx-arm64", "mas-x64", "mas-arm64"]
|
||||
|
||||
# Envs
|
||||
env-global: &env-global
|
||||
ELECTRON_OUT_DIR: Default
|
||||
|
||||
env-linux-medium: &env-linux-medium
|
||||
<<: *env-global
|
||||
NUMBER_OF_NINJA_PROCESSES: 3
|
||||
|
||||
# Executors
|
||||
executors:
|
||||
linux-docker:
|
||||
parameters:
|
||||
size:
|
||||
description: "Docker executor size"
|
||||
default: 2xlarge+
|
||||
type: enum
|
||||
enum: ["medium", "xlarge", "2xlarge+"]
|
||||
docker:
|
||||
- image: ghcr.io/electron/build:27db4a3e3512bfd2e47f58cea69922da0835f1d9
|
||||
resource_class: << parameters.size >>
|
||||
|
||||
# List of always run steps
|
||||
step-checkout-electron: &step-checkout-electron
|
||||
checkout:
|
||||
path: src/electron
|
||||
|
||||
steps-lint: &steps-lint
|
||||
steps:
|
||||
- *step-checkout-electron
|
||||
- run:
|
||||
name: Setup third_party Depot Tools
|
||||
command: |
|
||||
# "depot_tools" has to be checkout into "//third_party/depot_tools" so pylint.py can a "pylintrc" file.
|
||||
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git src/third_party/depot_tools
|
||||
echo 'export PATH="$PATH:'"$PWD"'/src/third_party/depot_tools"' >> $BASH_ENV
|
||||
- run:
|
||||
name: Download GN Binary
|
||||
command: |
|
||||
chromium_revision="$(grep -A1 chromium_version src/electron/DEPS | tr -d '\n' | cut -d\' -f4)"
|
||||
gn_version="$(curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/DEPS?format=TEXT" | base64 -d | grep gn_version | head -n1 | cut -d\' -f4)"
|
||||
|
||||
cipd ensure -ensure-file - -root . \<<-CIPD
|
||||
\$ServiceURL https://chrome-infra-packages.appspot.com/
|
||||
@Subdir src/buildtools/linux64
|
||||
gn/gn/linux-amd64 $gn_version
|
||||
CIPD
|
||||
|
||||
echo 'export CHROMIUM_BUILDTOOLS_PATH="'"$PWD"'/src/buildtools"' >> $BASH_ENV
|
||||
- run:
|
||||
name: Download clang-format Binary
|
||||
command: |
|
||||
chromium_revision="$(grep -A1 chromium_version src/electron/DEPS | tr -d '\n' | cut -d\' -f4)"
|
||||
|
||||
sha1_path='buildtools/linux64/clang-format.sha1'
|
||||
curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/${sha1_path}?format=TEXT" | base64 -d > "src/${sha1_path}"
|
||||
|
||||
download_from_google_storage.py --no_resume --no_auth --bucket chromium-clang-format -s "src/${sha1_path}"
|
||||
- run:
|
||||
name: Run Lint
|
||||
command: |
|
||||
# gn.py tries to find a gclient root folder starting from the current dir.
|
||||
# When it fails and returns "None" path, the whole script fails. Let's "fix" it.
|
||||
touch .gclient
|
||||
# Another option would be to checkout "buildtools" inside the Electron checkout,
|
||||
# but then we would lint its contents (at least gn format), and it doesn't pass it.
|
||||
|
||||
cd src/electron
|
||||
node script/yarn install --frozen-lockfile
|
||||
node script/yarn lint
|
||||
- run:
|
||||
name: Run Script Typechecker
|
||||
command: |
|
||||
cd src/electron
|
||||
node script/yarn tsc -p tsconfig.script.json
|
||||
|
||||
# List of always run jobs.
|
||||
jobs:
|
||||
lint:
|
||||
executor:
|
||||
name: linux-docker
|
||||
size: medium
|
||||
environment:
|
||||
<<: *env-linux-medium
|
||||
<<: *steps-lint
|
||||
|
||||
# Initial setup workflow
|
||||
workflows:
|
||||
lint:
|
||||
jobs:
|
||||
# Job inherited from path-filtering orb
|
||||
- path-filtering/filter:
|
||||
generate-config:
|
||||
docker:
|
||||
- image: cimg/node:16.14
|
||||
steps:
|
||||
- checkout
|
||||
- path-filtering/set-parameters:
|
||||
base-revision: main
|
||||
# Params for mapping; `path-to-test parameter-to-set value-for-parameter` for each row
|
||||
mapping: |
|
||||
^((?!docs/).)*$ run-build-mac true
|
||||
^((?!docs/).)*$ run-build-linux true
|
||||
docs/.* run-docs-only true
|
||||
^((?!docs/).)*$ run-docs-only false
|
||||
config-path: .circleci/build_config.yml
|
||||
- lint
|
||||
- run:
|
||||
command: |
|
||||
cd .circleci/config
|
||||
yarn
|
||||
export CIRCLECI_BINARY="$HOME/circleci"
|
||||
curl -fLSs https://raw.githubusercontent.com/CircleCI-Public/circleci-cli/master/install.sh | DESTDIR=$CIRCLECI_BINARY bash
|
||||
node build.js
|
||||
name: Pack config.yml
|
||||
- continuation/continue:
|
||||
configuration_path: .circleci/config-staging/built.yml
|
||||
parameters: /tmp/pipeline-parameters.json
|
||||
|
||||
# Initial setup workflow
|
||||
workflows:
|
||||
setup:
|
||||
jobs:
|
||||
- generate-config
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
34
.circleci/config/build.js
Normal file
34
.circleci/config/build.js
Normal file
@@ -0,0 +1,34 @@
|
||||
const cp = require('child_process');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const yaml = require('js-yaml');
|
||||
|
||||
const STAGING_DIR = path.resolve(__dirname, '..', 'config-staging');
|
||||
|
||||
function copyAndExpand(dir = './') {
|
||||
const absDir = path.resolve(__dirname, dir);
|
||||
const targetDir = path.resolve(STAGING_DIR, dir);
|
||||
|
||||
if (!fs.existsSync(targetDir)) {
|
||||
fs.mkdirSync(targetDir);
|
||||
}
|
||||
|
||||
for (const file of fs.readdirSync(absDir)) {
|
||||
if (!file.endsWith('.yml')) {
|
||||
if (fs.statSync(path.resolve(absDir, file)).isDirectory()) {
|
||||
copyAndExpand(path.join(dir, file));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
fs.writeFileSync(path.resolve(targetDir, file), yaml.dump(yaml.load(fs.readFileSync(path.resolve(absDir, file), 'utf8')), {
|
||||
noRefs: true,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
if (fs.pathExists(STAGING_DIR)) fs.removeSync(STAGING_DIR);
|
||||
copyAndExpand();
|
||||
|
||||
const output = cp.spawnSync(process.env.CIRCLECI_BINARY || 'circleci', ['config', 'pack', STAGING_DIR]);
|
||||
fs.writeFileSync(path.resolve(STAGING_DIR, 'built.yml'), output.stdout.toString());
|
||||
51
.circleci/config/jobs/lint.yml
Normal file
51
.circleci/config/jobs/lint.yml
Normal file
@@ -0,0 +1,51 @@
|
||||
executor:
|
||||
name: linux-docker
|
||||
size: medium
|
||||
steps:
|
||||
- checkout:
|
||||
path: src/electron
|
||||
- run:
|
||||
name: Setup third_party Depot Tools
|
||||
command: |
|
||||
# "depot_tools" has to be checkout into "//third_party/depot_tools" so pylint.py can a "pylintrc" file.
|
||||
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git src/third_party/depot_tools
|
||||
echo 'export PATH="$PATH:'"$PWD"'/src/third_party/depot_tools"' >> $BASH_ENV
|
||||
- run:
|
||||
name: Download GN Binary
|
||||
command: |
|
||||
chromium_revision="$(grep -A1 chromium_version src/electron/DEPS | tr -d '\n' | cut -d\' -f4)"
|
||||
gn_version="$(curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/DEPS?format=TEXT" | base64 -d | grep gn_version | head -n1 | cut -d\' -f4)"
|
||||
|
||||
cipd ensure -ensure-file - -root . \<<-CIPD
|
||||
\$ServiceURL https://chrome-infra-packages.appspot.com/
|
||||
@Subdir src/buildtools/linux64
|
||||
gn/gn/linux-amd64 $gn_version
|
||||
CIPD
|
||||
|
||||
echo 'export CHROMIUM_BUILDTOOLS_PATH="'"$PWD"'/src/buildtools"' >> $BASH_ENV
|
||||
- run:
|
||||
name: Download clang-format Binary
|
||||
command: |
|
||||
chromium_revision="$(grep -A1 chromium_version src/electron/DEPS | tr -d '\n' | cut -d\' -f4)"
|
||||
|
||||
sha1_path='buildtools/linux64/clang-format.sha1'
|
||||
curl -sL "https://chromium.googlesource.com/chromium/src/+/${chromium_revision}/${sha1_path}?format=TEXT" | base64 -d > "src/${sha1_path}"
|
||||
|
||||
download_from_google_storage.py --no_resume --no_auth --bucket chromium-clang-format -s "src/${sha1_path}"
|
||||
- run:
|
||||
name: Run Lint
|
||||
command: |
|
||||
# gn.py tries to find a gclient root folder starting from the current dir.
|
||||
# When it fails and returns "None" path, the whole script fails. Let's "fix" it.
|
||||
touch .gclient
|
||||
# Another option would be to checkout "buildtools" inside the Electron checkout,
|
||||
# but then we would lint its contents (at least gn format), and it doesn't pass it.
|
||||
|
||||
cd src/electron
|
||||
node script/yarn install --frozen-lockfile
|
||||
node script/yarn lint
|
||||
- run:
|
||||
name: Run Script Typechecker
|
||||
command: |
|
||||
cd src/electron
|
||||
node script/yarn tsc -p tsconfig.script.json
|
||||
10
.circleci/config/package.json
Normal file
10
.circleci/config/package.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "@electron/circleci-config",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fs-extra": "^10.1.0",
|
||||
"js-yaml": "^4.1.0"
|
||||
}
|
||||
}
|
||||
43
.circleci/config/yarn.lock
Normal file
43
.circleci/config/yarn.lock
Normal file
@@ -0,0 +1,43 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
argparse@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
|
||||
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
|
||||
|
||||
fs-extra@^10.1.0:
|
||||
version "10.1.0"
|
||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf"
|
||||
integrity sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==
|
||||
dependencies:
|
||||
graceful-fs "^4.2.0"
|
||||
jsonfile "^6.0.1"
|
||||
universalify "^2.0.0"
|
||||
|
||||
graceful-fs@^4.1.6, graceful-fs@^4.2.0:
|
||||
version "4.2.10"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c"
|
||||
integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==
|
||||
|
||||
js-yaml@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
|
||||
integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
|
||||
dependencies:
|
||||
argparse "^2.0.1"
|
||||
|
||||
jsonfile@^6.0.1:
|
||||
version "6.1.0"
|
||||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
|
||||
integrity sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==
|
||||
dependencies:
|
||||
universalify "^2.0.0"
|
||||
optionalDependencies:
|
||||
graceful-fs "^4.1.6"
|
||||
|
||||
universalify@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
|
||||
integrity sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==
|
||||
20
.github/workflows/semantic.yml
vendored
Normal file
20
.github/workflows/semantic.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: "Check Semantic Commit"
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types:
|
||||
- opened
|
||||
- edited
|
||||
- synchronize
|
||||
|
||||
jobs:
|
||||
main:
|
||||
name: Validate PR Title
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: semantic-pull-request
|
||||
uses: amannn/action-semantic-pull-request@v4
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
validateSingleCommit: false
|
||||
70
BUILD.gn
70
BUILD.gn
@@ -43,6 +43,7 @@ if (is_mac) {
|
||||
|
||||
if (is_linux) {
|
||||
import("//build/config/linux/pkg_config.gni")
|
||||
import("//tools/generate_stubs/rules.gni")
|
||||
|
||||
pkg_config("gio_unix") {
|
||||
packages = [ "gio-unix-2.0" ]
|
||||
@@ -54,6 +55,41 @@ if (is_linux) {
|
||||
"gdk-pixbuf-2.0",
|
||||
]
|
||||
}
|
||||
|
||||
generate_library_loader("libnotify_loader") {
|
||||
name = "LibNotifyLoader"
|
||||
output_h = "libnotify_loader.h"
|
||||
output_cc = "libnotify_loader.cc"
|
||||
header = "<libnotify/notify.h>"
|
||||
config = ":libnotify_config"
|
||||
|
||||
functions = [
|
||||
"notify_is_initted",
|
||||
"notify_init",
|
||||
"notify_get_server_caps",
|
||||
"notify_get_server_info",
|
||||
"notify_notification_new",
|
||||
"notify_notification_add_action",
|
||||
"notify_notification_set_image_from_pixbuf",
|
||||
"notify_notification_set_timeout",
|
||||
"notify_notification_set_urgency",
|
||||
"notify_notification_set_hint_string",
|
||||
"notify_notification_show",
|
||||
"notify_notification_close",
|
||||
]
|
||||
}
|
||||
|
||||
generate_stubs("electron_gtk_stubs") {
|
||||
sigs = [
|
||||
"shell/browser/ui/electron_gdk_pixbuf.sigs",
|
||||
"shell/browser/ui/electron_gtk.sigs",
|
||||
]
|
||||
extra_header = "shell/browser/ui/electron_gtk.fragment"
|
||||
output_name = "electron_gtk_stubs"
|
||||
public_deps = [ "//ui/gtk:gtk_config" ]
|
||||
logging_function = "LogNoop()"
|
||||
logging_include = "ui/gtk/log_noop.h"
|
||||
}
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
@@ -253,31 +289,6 @@ copy("copy_shell_devtools_discovery_page") {
|
||||
outputs = [ "$target_gen_dir/shell_devtools_discovery_page.html" ]
|
||||
}
|
||||
|
||||
if (is_linux) {
|
||||
generate_library_loader("libnotify_loader") {
|
||||
name = "LibNotifyLoader"
|
||||
output_h = "libnotify_loader.h"
|
||||
output_cc = "libnotify_loader.cc"
|
||||
header = "<libnotify/notify.h>"
|
||||
config = ":libnotify_config"
|
||||
|
||||
functions = [
|
||||
"notify_is_initted",
|
||||
"notify_init",
|
||||
"notify_get_server_caps",
|
||||
"notify_get_server_info",
|
||||
"notify_notification_new",
|
||||
"notify_notification_add_action",
|
||||
"notify_notification_set_image_from_pixbuf",
|
||||
"notify_notification_set_timeout",
|
||||
"notify_notification_set_urgency",
|
||||
"notify_notification_set_hint_string",
|
||||
"notify_notification_show",
|
||||
"notify_notification_close",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
npm_action("electron_version_args") {
|
||||
script = "generate-version-json"
|
||||
|
||||
@@ -535,6 +546,7 @@ source_set("electron_lib") {
|
||||
if (is_linux) {
|
||||
libs = [ "xshmfence" ]
|
||||
deps += [
|
||||
":electron_gtk_stubs",
|
||||
":libnotify_loader",
|
||||
"//build/config/linux/gtk",
|
||||
"//dbus",
|
||||
@@ -557,7 +569,6 @@ source_set("electron_lib") {
|
||||
defines += [
|
||||
# Disable warnings for g_settings_list_schemas.
|
||||
"GLIB_DISABLE_DEPRECATION_WARNINGS",
|
||||
"USE_X11=1",
|
||||
]
|
||||
|
||||
sources += [
|
||||
@@ -695,6 +706,8 @@ source_set("electron_lib") {
|
||||
deps += [
|
||||
"//chrome/browser/resources/pdf:resources",
|
||||
"//components/pdf/browser",
|
||||
"//components/pdf/browser:interceptors",
|
||||
"//components/pdf/common",
|
||||
"//components/pdf/renderer",
|
||||
"//pdf:pdf_ppapi",
|
||||
]
|
||||
@@ -1049,7 +1062,6 @@ if (is_mac) {
|
||||
"shell/app/electron_main_mac.cc",
|
||||
"shell/app/uv_stdio_fix.cc",
|
||||
"shell/app/uv_stdio_fix.h",
|
||||
"shell/common/electron_constants.cc",
|
||||
]
|
||||
include_dirs = [ "." ]
|
||||
deps = [
|
||||
@@ -1266,6 +1278,10 @@ if (is_mac) {
|
||||
if (!is_component_build && is_component_ffmpeg) {
|
||||
configs += [ "//build/config/gcc:rpath_for_built_shared_libraries" ]
|
||||
}
|
||||
|
||||
if (is_linux) {
|
||||
deps += [ "//sandbox/linux:chrome_sandbox" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
DEPS
2
DEPS
@@ -15,7 +15,7 @@ gclient_gn_args = [
|
||||
|
||||
vars = {
|
||||
'chromium_version':
|
||||
'100.0.4894.0',
|
||||
'100.0.4896.160',
|
||||
'node_version':
|
||||
'v16.13.2',
|
||||
'nan_version':
|
||||
|
||||
@@ -1 +1 @@
|
||||
18.0.0-beta.6
|
||||
18.3.5
|
||||
@@ -11,7 +11,7 @@
|
||||
# - "TARGET_ARCH" Choose from {'ia32', 'x64', 'arm', 'arm64', 'mips64el'}.
|
||||
# Is used in some publishing scripts, but does NOT affect the Electron binary.
|
||||
# Must match 'target_cpu' passed to "GN_EXTRA_ARGS" and "NPM_CONFIG_ARCH" value.
|
||||
# - "UPLOAD_TO_S3" Set it to '1' upload a release to the S3 bucket.
|
||||
# - "UPLOAD_TO_STORAGE" Set it to '1' upload a release to the Azure bucket.
|
||||
# Otherwise the release will be uploaded to the Github Releases.
|
||||
# (The value is only checked if "ELECTRON_RELEASE" is defined.)
|
||||
#
|
||||
@@ -235,9 +235,9 @@ deploy_script:
|
||||
- cd electron
|
||||
- ps: >-
|
||||
if (Test-Path Env:\ELECTRON_RELEASE) {
|
||||
if (Test-Path Env:\UPLOAD_TO_S3) {
|
||||
Write-Output "Uploading Electron release distribution to s3"
|
||||
& python script\release\uploaders\upload.py --verbose --upload_to_s3
|
||||
if (Test-Path Env:\UPLOAD_TO_STORAGE) {
|
||||
Write-Output "Uploading Electron release distribution to azure"
|
||||
& python script\release\uploaders\upload.py --verbose --upload_to_storage
|
||||
} else {
|
||||
Write-Output "Uploading Electron release distribution to github releases"
|
||||
& python script\release\uploaders\upload.py --verbose
|
||||
|
||||
@@ -5,7 +5,6 @@ root_extra_deps = [ "//electron" ]
|
||||
node_module_version = 103
|
||||
|
||||
v8_promise_internal_field_count = 1
|
||||
v8_typed_array_max_size_in_heap = 0
|
||||
v8_embedder_string = "-electron.0"
|
||||
|
||||
# TODO: this breaks mksnapshot
|
||||
@@ -22,6 +21,9 @@ proprietary_codecs = true
|
||||
ffmpeg_branding = "Chrome"
|
||||
|
||||
enable_basic_printing = true
|
||||
|
||||
# Removes DLLs from the build, which are only meant to be used for Chromium development.
|
||||
# See https://github.com/electron/electron/pull/17985
|
||||
angle_enable_vulkan_validation_layers = false
|
||||
dawn_enable_vulkan_validation_layers = false
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
@@ -298,13 +298,21 @@ static_library("chrome") {
|
||||
|
||||
if (enable_pdf_viewer) {
|
||||
sources += [
|
||||
"//chrome/browser/pdf/chrome_pdf_stream_delegate.cc",
|
||||
"//chrome/browser/pdf/chrome_pdf_stream_delegate.h",
|
||||
"//chrome/browser/pdf/pdf_extension_util.cc",
|
||||
"//chrome/browser/pdf/pdf_extension_util.h",
|
||||
"//chrome/browser/pdf/pdf_frame_util.cc",
|
||||
"//chrome/browser/pdf/pdf_frame_util.h",
|
||||
"//chrome/browser/plugins/pdf_iframe_navigation_throttle.cc",
|
||||
"//chrome/browser/plugins/pdf_iframe_navigation_throttle.h",
|
||||
"//chrome/renderer/pepper/chrome_pdf_print_client.cc",
|
||||
"//chrome/renderer/pepper/chrome_pdf_print_client.h",
|
||||
]
|
||||
deps += [
|
||||
"//components/pdf/browser",
|
||||
"//components/pdf/renderer",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,15 +340,6 @@ source_set("plugins") {
|
||||
"//chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.cc",
|
||||
"//chrome/browser/renderer_host/pepper/pepper_isolated_file_system_message_filter.h",
|
||||
]
|
||||
deps += [
|
||||
"//media:media_buildflags",
|
||||
"//ppapi/buildflags",
|
||||
"//ppapi/proxy:ipc",
|
||||
"//services/device/public/mojom",
|
||||
]
|
||||
if (enable_pdf_viewer) {
|
||||
deps += [ "//components/pdf/browser" ]
|
||||
}
|
||||
|
||||
# renderer side
|
||||
sources += [
|
||||
@@ -351,17 +350,18 @@ source_set("plugins") {
|
||||
"//chrome/renderer/pepper/pepper_shared_memory_message_filter.cc",
|
||||
"//chrome/renderer/pepper/pepper_shared_memory_message_filter.h",
|
||||
]
|
||||
if (enable_pdf_viewer) {
|
||||
deps += [ "//components/pdf/renderer" ]
|
||||
}
|
||||
|
||||
deps += [
|
||||
"//components/strings",
|
||||
"//media:media_buildflags",
|
||||
"//ppapi/buildflags",
|
||||
"//ppapi/host",
|
||||
"//ppapi/proxy",
|
||||
"//ppapi/proxy:ipc",
|
||||
"//ppapi/shared_impl",
|
||||
"//services/device/public/mojom",
|
||||
"//skia",
|
||||
"//storage/browser",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -484,7 +484,6 @@ Returns:
|
||||
* `argv` string[] - An array of the second instance's command line arguments
|
||||
* `workingDirectory` string - The second instance's working directory
|
||||
* `additionalData` unknown - A JSON object of additional data passed from the second instance
|
||||
* `ackCallback` unknown - A function that can be used to send data back to the second instance
|
||||
|
||||
This event will be emitted inside the primary instance of your application
|
||||
when a second instance has been executed and calls `app.requestSingleInstanceLock()`.
|
||||
@@ -496,35 +495,12 @@ non-minimized.
|
||||
|
||||
**Note:** If the second instance is started by a different user than the first, the `argv` array will not include the arguments.
|
||||
|
||||
**Note:** `ackCallback` allows the user to send data back to the
|
||||
second instance during the `app.requestSingleInstanceLock()` flow.
|
||||
This callback can be used for cases where the second instance
|
||||
needs to obtain additional information from the first instance
|
||||
before quitting.
|
||||
|
||||
Currently, the limit on the message size is kMaxMessageLength,
|
||||
or around 32kB. To be safe, keep the amount of data passed to 31kB at most.
|
||||
|
||||
In order to call the callback, `event.preventDefault()` must be called, first.
|
||||
If the callback is not called in either case, `null` will be sent back.
|
||||
If `event.preventDefault()` is not called, but `ackCallback` is called
|
||||
by the user in the event, then the behaviour is undefined.
|
||||
|
||||
This event is guaranteed to be emitted after the `ready` event of `app`
|
||||
gets emitted.
|
||||
|
||||
**Note:** Extra command line arguments might be added by Chromium,
|
||||
such as `--original-process-start-time`.
|
||||
|
||||
### Event: 'first-instance-ack'
|
||||
|
||||
Returns:
|
||||
|
||||
* `event` Event
|
||||
* `additionalData` unknown - A JSON object of additional data passed from the first instance, in response to the first instance's `second-instance` event.
|
||||
|
||||
This event will be emitted within the second instance during the call to `app.requestSingleInstanceLock()`, when the first instance calls the `ackCallback` provided by the `second-instance` event handler.
|
||||
|
||||
## Methods
|
||||
|
||||
The `app` object has the following methods:
|
||||
@@ -861,6 +837,8 @@ Returns `Object`:
|
||||
|
||||
* `categories` [JumpListCategory[]](structures/jump-list-category.md) | `null` - Array of `JumpListCategory` objects.
|
||||
|
||||
Returns `string`
|
||||
|
||||
Sets or removes a custom Jump List for the application, and returns one of the
|
||||
following strings:
|
||||
|
||||
@@ -983,13 +961,6 @@ starts:
|
||||
const { app } = require('electron')
|
||||
let myWindow = null
|
||||
|
||||
app.on('first-instance-ack', (event, additionalData) => {
|
||||
// Print out the ack received from the first instance.
|
||||
// Note this event handler must come before the requestSingleInstanceLock call.
|
||||
// Expected output: '{"myAckKey":"myAckValue"}'
|
||||
console.log(JSON.stringify(additionalData))
|
||||
})
|
||||
|
||||
const additionalData = { myKey: 'myValue' }
|
||||
const gotTheLock = app.requestSingleInstanceLock(additionalData)
|
||||
|
||||
@@ -997,19 +968,14 @@ if (!gotTheLock) {
|
||||
app.quit()
|
||||
} else {
|
||||
app.on('second-instance', (event, commandLine, workingDirectory, additionalData) => {
|
||||
// We must call preventDefault if we're sending back data.
|
||||
event.preventDefault()
|
||||
// Print out data received from the second instance.
|
||||
// Expected output: '{"myKey":"myValue"}'
|
||||
console.log(JSON.stringify(additionalData))
|
||||
console.log(additionalData)
|
||||
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
if (myWindow) {
|
||||
if (myWindow.isMinimized()) myWindow.restore()
|
||||
myWindow.focus()
|
||||
}
|
||||
const ackData = { myAckKey: 'myAckValue' }
|
||||
ackCallback(ackData)
|
||||
})
|
||||
|
||||
// Create myWindow, load the rest of the app, etc...
|
||||
|
||||
@@ -464,7 +464,7 @@ window.onbeforeunload = (e) => {
|
||||
// a non-void value will silently cancel the close.
|
||||
// It is recommended to use the dialog API to let the user confirm closing the
|
||||
// application.
|
||||
e.returnValue = false // equivalent to `return false` but not recommended
|
||||
e.returnValue = false
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1842,6 +1842,16 @@ with `addBrowserView` or `setBrowserView`.
|
||||
**Note:** The BrowserView API is currently experimental and may change or be
|
||||
removed in future Electron releases.
|
||||
|
||||
#### `win.setTitleBarOverlay(options)` _Windows_
|
||||
|
||||
* `options` Object
|
||||
* `color` String (optional) _Windows_ - The CSS color of the Window Controls Overlay when enabled.
|
||||
* `symbolColor` String (optional) _Windows_ - The CSS color of the symbols on the Window Controls Overlay when enabled.
|
||||
* `height` Integer (optional) _Windows_ - The height of the title bar and Window Controls Overlay in pixels.
|
||||
|
||||
On a Window with Window Controls Overlay already enabled, this method updates
|
||||
the style of the title bar overlay.
|
||||
|
||||
[runtime-enabled-features]: https://cs.chromium.org/chromium/src/third_party/blink/renderer/platform/runtime_enabled_features.json5?l=70
|
||||
[page-visibility-api]: https://developer.mozilla.org/en-US/docs/Web/API/Page_Visibility_API
|
||||
[quick-look]: https://en.wikipedia.org/wiki/Quick_Look
|
||||
|
||||
@@ -99,6 +99,7 @@ Only `chrome.storage.local` is supported; `chrome.storage.sync` and
|
||||
The following methods of `chrome.tabs` are supported:
|
||||
|
||||
- `chrome.tabs.sendMessage`
|
||||
- `chrome.tabs.reload`
|
||||
- `chrome.tabs.executeScript`
|
||||
- `chrome.tabs.update` (partial support)
|
||||
- supported properties: `url`, `muted`.
|
||||
|
||||
@@ -18,9 +18,9 @@ The `safeStorage` module has the following methods:
|
||||
|
||||
Returns `boolean` - Whether encryption is available.
|
||||
|
||||
On Linux, returns true if the secret key is
|
||||
available. On MacOS, returns true if Keychain is available.
|
||||
On Windows, returns true with no other preconditions.
|
||||
On Linux, returns true if the app has emitted the `ready` event and the secret key is available.
|
||||
On MacOS, returns true if Keychain is available.
|
||||
On Windows, returns true once the app has emitted the `ready` event.
|
||||
|
||||
### `safeStorage.encryptString(plainText)`
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ that contains the user information dictionary sent along with the notification.
|
||||
|
||||
### `systemPreferences.subscribeNotification(event, callback)` _macOS_
|
||||
|
||||
* `event` string
|
||||
* `event` string | null
|
||||
* `callback` Function
|
||||
* `event` string
|
||||
* `userInfo` Record<string, unknown>
|
||||
@@ -109,9 +109,11 @@ example values of `event` are:
|
||||
* `AppleColorPreferencesChangedNotification`
|
||||
* `AppleShowScrollBarsSettingChanged`
|
||||
|
||||
If `event` is null, the `NSDistributedNotificationCenter` doesn’t use it as criteria for delivery to the observer. See [docs](https://developer.apple.com/documentation/foundation/nsnotificationcenter/1411723-addobserverforname?language=objc) for more information.
|
||||
|
||||
### `systemPreferences.subscribeLocalNotification(event, callback)` _macOS_
|
||||
|
||||
* `event` string
|
||||
* `event` string | null
|
||||
* `callback` Function
|
||||
* `event` string
|
||||
* `userInfo` Record<string, unknown>
|
||||
@@ -122,9 +124,11 @@ Returns `number` - The ID of this subscription
|
||||
Same as `subscribeNotification`, but uses `NSNotificationCenter` for local defaults.
|
||||
This is necessary for events such as `NSUserDefaultsDidChangeNotification`.
|
||||
|
||||
If `event` is null, the `NSNotificationCenter` doesn’t use it as criteria for delivery to the observer. See [docs](https://developer.apple.com/documentation/foundation/nsnotificationcenter/1411723-addobserverforname?language=objc) for more information.
|
||||
|
||||
### `systemPreferences.subscribeWorkspaceNotification(event, callback)` _macOS_
|
||||
|
||||
* `event` string
|
||||
* `event` string | null
|
||||
* `callback` Function
|
||||
* `event` string
|
||||
* `userInfo` Record<string, unknown>
|
||||
@@ -135,6 +139,8 @@ Returns `number` - The ID of this subscription
|
||||
Same as `subscribeNotification`, but uses `NSWorkspace.sharedWorkspace.notificationCenter`.
|
||||
This is necessary for events such as `NSWorkspaceDidActivateApplicationNotification`.
|
||||
|
||||
If `event` is null, the `NSWorkspaceNotificationCenter` doesn’t use it as criteria for delivery to the observer. See [docs](https://developer.apple.com/documentation/foundation/nsnotificationcenter/1411723-addobserverforname?language=objc) for more information.
|
||||
|
||||
### `systemPreferences.unsubscribeNotification(id)` _macOS_
|
||||
|
||||
* `id` Integer
|
||||
|
||||
@@ -16,7 +16,7 @@ win.loadURL('https://twitter.com')
|
||||
|
||||
win.webContents.on(
|
||||
'did-frame-navigate',
|
||||
(event, url, isMainFrame, frameProcessId, frameRoutingId) => {
|
||||
(event, url, httpResponseCode, httpStatusText, isMainFrame, frameProcessId, frameRoutingId) => {
|
||||
const frame = webFrameMain.fromId(frameProcessId, frameRoutingId)
|
||||
if (frame) {
|
||||
const code = 'document.body.innerHTML = document.body.innerHTML.replaceAll("heck", "h*ck")'
|
||||
|
||||
@@ -27,6 +27,13 @@ preload scripts _do_ depend on Node, either refactor them to remove Node usage
|
||||
from the renderer, or explicitly specify `sandbox: false` for the relevant
|
||||
renderers.
|
||||
|
||||
### Removed: `skipTaskbar` on Linux
|
||||
|
||||
On X11, `skipTaskbar` sends a `_NET_WM_STATE_SKIP_TASKBAR` message to the X11
|
||||
window manager. There is not a direct equivalent for Wayland, and the known
|
||||
workarounds have unacceptable tradeoffs (e.g. Window.is_skip_taskbar in GNOME
|
||||
requires unsafe mode), so Electron is unable to support this feature on Linux.
|
||||
|
||||
## Planned Breaking API Changes (19.0)
|
||||
|
||||
*None (yet)*
|
||||
|
||||
@@ -7,21 +7,7 @@ Follow the guidelines below for building **Electron itself** on Linux, for the p
|
||||
## Prerequisites
|
||||
|
||||
* At least 25GB disk space and 8GB RAM.
|
||||
* Python 2.7.x. Some distributions like CentOS 6.x still use Python 2.6.x
|
||||
so you may need to check your Python version with `python -V`.
|
||||
|
||||
Please also ensure that your system and Python version support at least TLS 1.2.
|
||||
For a quick test, run the following script:
|
||||
|
||||
```sh
|
||||
$ npx @electron/check-python-tls
|
||||
```
|
||||
|
||||
If the script returns that your configuration is using an outdated security
|
||||
protocol, use your system's package manager to update Python to the latest
|
||||
version in the 2.7.x branch. Alternatively, visit https://www.python.org/downloads/
|
||||
for detailed instructions.
|
||||
|
||||
* Python >= 3.7.
|
||||
* Node.js. There are various ways to install Node. You can download
|
||||
source code from [nodejs.org](https://nodejs.org) and compile it.
|
||||
Doing so permits installing Node on your own home directory as a standard user.
|
||||
|
||||
@@ -6,45 +6,12 @@ Follow the guidelines below for building **Electron itself** on macOS, for the p
|
||||
|
||||
## Prerequisites
|
||||
|
||||
* macOS >= 10.11.6
|
||||
* [Xcode](https://developer.apple.com/technologies/tools/) >= 9.0.0
|
||||
* macOS >= 11.6.0
|
||||
* [Xcode](https://developer.apple.com/technologies/tools/). The exact version
|
||||
needed depends on what branch you are building, but the latest version of
|
||||
Xcode is generally a good bet for building `main`.
|
||||
* [node.js](https://nodejs.org) (external)
|
||||
* Python 2.7 with support for TLS 1.2
|
||||
|
||||
## Python
|
||||
|
||||
Please also ensure that your system and Python version support at least TLS 1.2.
|
||||
This depends on both your version of macOS and Python. For a quick test, run:
|
||||
|
||||
```sh
|
||||
$ npx @electron/check-python-tls
|
||||
```
|
||||
|
||||
If the script returns that your configuration is using an outdated security
|
||||
protocol, you can either update macOS to High Sierra or install a new version
|
||||
of Python 2.7.x. To upgrade Python, use [Homebrew](https://brew.sh/):
|
||||
|
||||
```sh
|
||||
$ brew install python@2 && brew link python@2 --force
|
||||
```
|
||||
|
||||
If you are using Python as provided by Homebrew, you also need to install
|
||||
the following Python modules:
|
||||
|
||||
* [pyobjc](https://pypi.org/project/pyobjc/#description)
|
||||
|
||||
You can use `pip` to install it:
|
||||
|
||||
```sh
|
||||
$ pip install pyobjc
|
||||
```
|
||||
|
||||
## macOS SDK
|
||||
|
||||
If you're developing Electron and don't plan to redistribute your
|
||||
custom Electron build, you may skip this section.
|
||||
|
||||
Official Electron builds are built with [Xcode 12.2](https://download.developer.apple.com/Developer_Tools/Xcode_12.2/Xcode_12.2.xip), and the macOS 11.0 SDK. Building with a newer SDK works too, but the releases currently use the 11.0 SDK.
|
||||
* Python >= 3.7
|
||||
|
||||
## Building Electron
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ For C++ and Python, we follow Chromium's [Coding
|
||||
Style](https://chromium.googlesource.com/chromium/src/+/refs/heads/main/styleguide/styleguide.md).
|
||||
There is also a script `script/cpplint.py` to check whether all files conform.
|
||||
|
||||
The Python version we are using now is Python 2.7.
|
||||
The Python version we are using now is Python 3.9.
|
||||
|
||||
The C++ code uses a lot of Chromium's abstractions and types, so it's
|
||||
recommended to get acquainted with them. A good place to start is
|
||||
|
||||
14
docs/fiddles/ipc/pattern-1/index.html
Normal file
14
docs/fiddles/ipc/pattern-1/index.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<title>Hello World!</title>
|
||||
</head>
|
||||
<body>
|
||||
Title: <input id="title"/>
|
||||
<button id="btn" type="button">Set</button>
|
||||
<script src="./renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
30
docs/fiddles/ipc/pattern-1/main.js
Normal file
30
docs/fiddles/ipc/pattern-1/main.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const {app, BrowserWindow, ipcMain} = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.on('set-title', (event, title) => {
|
||||
const webContents = event.sender
|
||||
const win = BrowserWindow.fromWebContents(webContents)
|
||||
win.setTitle(title)
|
||||
})
|
||||
|
||||
mainWindow.loadFile('index.html')
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
createWindow()
|
||||
|
||||
app.on('activate', function () {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
||||
5
docs/fiddles/ipc/pattern-1/preload.js
Normal file
5
docs/fiddles/ipc/pattern-1/preload.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
setTitle: (title) => ipcRenderer.send('set-title', title)
|
||||
})
|
||||
6
docs/fiddles/ipc/pattern-1/renderer.js
Normal file
6
docs/fiddles/ipc/pattern-1/renderer.js
Normal file
@@ -0,0 +1,6 @@
|
||||
const setButton = document.getElementById('btn')
|
||||
const titleInput = document.getElementById('title')
|
||||
setButton.addEventListener('click', () => {
|
||||
const title = titleInput.value
|
||||
window.electronAPI.setTitle(title)
|
||||
});
|
||||
14
docs/fiddles/ipc/pattern-2/index.html
Normal file
14
docs/fiddles/ipc/pattern-2/index.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<title>Dialog</title>
|
||||
</head>
|
||||
<body>
|
||||
<button type="button" id="btn">Open a File</button>
|
||||
File path: <strong id="filePath"></strong>
|
||||
<script src='./renderer.js'></script>
|
||||
</body>
|
||||
</html>
|
||||
32
docs/fiddles/ipc/pattern-2/main.js
Normal file
32
docs/fiddles/ipc/pattern-2/main.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const {app, BrowserWindow, ipcMain, dialog} = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
async function handleFileOpen() {
|
||||
const { canceled, filePaths } = await dialog.showOpenDialog()
|
||||
if (canceled) {
|
||||
return
|
||||
} else {
|
||||
return filePaths[0]
|
||||
}
|
||||
}
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
})
|
||||
mainWindow.loadFile('index.html')
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
ipcMain.handle('dialog:openFile', handleFileOpen)
|
||||
createWindow()
|
||||
app.on('activate', function () {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
||||
5
docs/fiddles/ipc/pattern-2/preload.js
Normal file
5
docs/fiddles/ipc/pattern-2/preload.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI',{
|
||||
openFile: () => ipcRenderer.invoke('dialog:openFile')
|
||||
})
|
||||
7
docs/fiddles/ipc/pattern-2/renderer.js
Normal file
7
docs/fiddles/ipc/pattern-2/renderer.js
Normal file
@@ -0,0 +1,7 @@
|
||||
const btn = document.getElementById('btn')
|
||||
const filePathElement = document.getElementById('filePath')
|
||||
|
||||
btn.addEventListener('click', async () => {
|
||||
const filePath = await window.electronAPI.openFile()
|
||||
filePathElement.innerText = filePath
|
||||
})
|
||||
13
docs/fiddles/ipc/pattern-3/index.html
Normal file
13
docs/fiddles/ipc/pattern-3/index.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<title>Menu Counter</title>
|
||||
</head>
|
||||
<body>
|
||||
Current value: <strong id="counter">0</strong>
|
||||
<script src="./renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
48
docs/fiddles/ipc/pattern-3/main.js
Normal file
48
docs/fiddles/ipc/pattern-3/main.js
Normal file
@@ -0,0 +1,48 @@
|
||||
const {app, BrowserWindow, Menu, ipcMain} = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
})
|
||||
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: app.name,
|
||||
submenu: [
|
||||
{
|
||||
click: () => mainWindow.webContents.send('update-counter', 1),
|
||||
label: 'Increment',
|
||||
},
|
||||
{
|
||||
click: () => mainWindow.webContents.send('update-counter', -1),
|
||||
label: 'Decrement',
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
])
|
||||
|
||||
Menu.setApplicationMenu(menu)
|
||||
mainWindow.loadFile('index.html')
|
||||
|
||||
// Open the DevTools.
|
||||
mainWindow.webContents.openDevTools()
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
ipcMain.on('counter-value', (_event, value) => {
|
||||
console.log(value) // will print value to Node console
|
||||
})
|
||||
createWindow()
|
||||
|
||||
app.on('activate', function () {
|
||||
if (BrowserWindow.getAllWindows().length === 0) createWindow()
|
||||
})
|
||||
})
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
if (process.platform !== 'darwin') app.quit()
|
||||
})
|
||||
5
docs/fiddles/ipc/pattern-3/preload.js
Normal file
5
docs/fiddles/ipc/pattern-3/preload.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
handleCounter: (callback) => ipcRenderer.on('update-counter', callback)
|
||||
})
|
||||
8
docs/fiddles/ipc/pattern-3/renderer.js
Normal file
8
docs/fiddles/ipc/pattern-3/renderer.js
Normal file
@@ -0,0 +1,8 @@
|
||||
const counter = document.getElementById('counter')
|
||||
|
||||
window.electronAPI.handleCounter((event, value) => {
|
||||
const oldValue = Number(counter.innerText)
|
||||
const newValue = oldValue + value
|
||||
counter.innerText = newValue
|
||||
event.sender.send('counter-value', newValue)
|
||||
})
|
||||
571
docs/tutorial/ipc.md
Normal file
571
docs/tutorial/ipc.md
Normal file
@@ -0,0 +1,571 @@
|
||||
---
|
||||
title: Inter-Process Communication
|
||||
description: Use the ipcMain and ipcRenderer modules to communicate between Electron processes
|
||||
slug: ipc
|
||||
hide_title: false
|
||||
---
|
||||
|
||||
# Inter-Process Communication
|
||||
|
||||
Inter-process communication (IPC) is a key part of building feature-rich desktop applications
|
||||
in Electron. Because the main and renderer processes have different responsibilities in
|
||||
Electron's process model, IPC is the only way to perform many common tasks, such as calling a
|
||||
native API from your UI or triggering changes in your web contents from native menus.
|
||||
|
||||
## IPC channels
|
||||
|
||||
In Electron, processes communicate by passing messages through developer-defined "channels"
|
||||
with the [`ipcMain`] and [`ipcRenderer`] modules. These channels are
|
||||
**arbitrary** (you can name them anything you want) and **bidirectional** (you can use the
|
||||
same channel name for both modules).
|
||||
|
||||
In this guide, we'll be going over some fundamental IPC patterns with concrete examples that
|
||||
you can use as a reference for your app code.
|
||||
|
||||
## Understanding context-isolated processes
|
||||
|
||||
Before proceeding to implementation details, you should be familiar with the idea of using a
|
||||
[preload script] to import Node.js and Electron modules in a context-isolated renderer process.
|
||||
|
||||
* For a full overview of Electron's process model, you can read the [process model docs].
|
||||
* For a primer into exposing APIs from your preload script using the `contextBridge` module, check
|
||||
out the [context isolation tutorial].
|
||||
|
||||
## Pattern 1: Renderer to main (one-way)
|
||||
|
||||
To fire a one-way IPC message from a renderer process to the main process, you can use the
|
||||
[`ipcRenderer.send`] API to send a message that is then received by the [`ipcMain.on`] API.
|
||||
|
||||
You usually use this pattern to call a main process API from your web contents. We'll demonstrate
|
||||
this pattern by creating a simple app that can programmatically change its window title.
|
||||
|
||||
For this demo, you'll need to add code to your main process, your renderer process, and a preload
|
||||
script. The full code is below, but we'll be explaining each file individually in the following
|
||||
sections.
|
||||
|
||||
```fiddle docs/fiddles/ipc/pattern-1
|
||||
```
|
||||
|
||||
### 1. Listen for events with `ipcMain.on`
|
||||
|
||||
In the main process, set an IPC listener on the `set-title` channel with the `ipcMain.on` API:
|
||||
|
||||
```javascript {6-10,22} title='main.js (Main Process)'
|
||||
const {app, BrowserWindow, ipcMain} = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
//...
|
||||
|
||||
function handleSetTitle (event, title) {
|
||||
const webContents = event.sender
|
||||
const win = BrowserWindow.fromWebContents(webContents)
|
||||
win.setTitle(title)
|
||||
}
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
})
|
||||
mainWindow.loadFile('index.html')
|
||||
}
|
||||
|
||||
app.whenReady().then(() => {
|
||||
ipcMain.on('set-title', handleSetTitle)
|
||||
createWindow()
|
||||
}
|
||||
//...
|
||||
```
|
||||
|
||||
The above `handleSetTitle` callback has two parameters: an [IpcMainEvent] structure and a
|
||||
`title` string. Whenever a message comes through the `set-title` channel, this function will
|
||||
find the BrowserWindow instance attached to the message sender and use the `win.setTitle`
|
||||
API on it.
|
||||
|
||||
:::info
|
||||
Make sure you're loading the `index.html` and `preload.js` entry points for the following steps!
|
||||
:::
|
||||
|
||||
### 2. Expose `ipcRenderer.send` via preload
|
||||
|
||||
To send messages to the listener created above, you can use the `ipcRenderer.send` API.
|
||||
By default, the renderer process has no Node.js or Electron module access. As an app developer,
|
||||
you need to choose which APIs to expose from your preload script using the `contextBridge` API.
|
||||
|
||||
In your preload script, add the following code, which will expose a global `window.electronAPI`
|
||||
variable to your renderer process.
|
||||
|
||||
```javascript title='preload.js (Preload Script)'
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
setTitle: (title) => ipcRenderer.send('set-title', title)
|
||||
})
|
||||
```
|
||||
|
||||
At this point, you'll be able to use the `window.electronAPI.setTitle()` function in the renderer
|
||||
process.
|
||||
|
||||
:::caution Security warning
|
||||
We don't directly expose the whole `ipcRenderer.send` API for [security reasons]. Make sure to
|
||||
limit the renderer's access to Electron APIs as much as possible.
|
||||
:::
|
||||
|
||||
### 3. Build the renderer process UI
|
||||
|
||||
In our BrowserWindow's loaded HTML file, add a basic user interface consisting of a text input
|
||||
and a button:
|
||||
|
||||
```html {11-12} title='index.html'
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<title>Hello World!</title>
|
||||
</head>
|
||||
<body>
|
||||
Title: <input id="title"/>
|
||||
<button id="btn" type="button">Set</button>
|
||||
<script src="./renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
To make these elements interactive, we'll be adding a few lines of code in the imported
|
||||
`renderer.js` file that leverages the `window.electronAPI` functionality exposed from the preload
|
||||
script:
|
||||
|
||||
```javascript title='renderer.js (Renderer Process)'
|
||||
const setButton = document.getElementById('btn')
|
||||
const titleInput = document.getElementById('title')
|
||||
setButton.addEventListener('click', () => {
|
||||
const title = titleInput.value
|
||||
window.electronAPI.setTitle(title)
|
||||
});
|
||||
```
|
||||
|
||||
At this point, your demo should be fully functional. Try using the input field and see what happens
|
||||
to your BrowserWindow title!
|
||||
|
||||
## Pattern 2: Renderer to main (two-way)
|
||||
|
||||
A common application for two-way IPC is calling a main process module from your renderer process
|
||||
code and waiting for a result. This can be done by using [`ipcRenderer.invoke`] paired with
|
||||
[`ipcMain.handle`].
|
||||
|
||||
In the following example, we'll be opening a native file dialog from the renderer process and
|
||||
returning the selected file's path.
|
||||
|
||||
For this demo, you'll need to add code to your main process, your renderer process, and a preload
|
||||
script. The full code is below, but we'll be explaining each file individually in the following
|
||||
sections.
|
||||
|
||||
```fiddle docs/fiddles/ipc/pattern-2
|
||||
```
|
||||
|
||||
### 1. Listen for events with `ipcMain.handle`
|
||||
|
||||
In the main process, we'll be creating a `handleFileOpen()` function that calls
|
||||
`dialog.showOpenDialog` and returns the value of the file path selected by the user. This function
|
||||
is used as a callback whenever an `ipcRender.invoke` message is sent through the `dialog:openFile`
|
||||
channel from the renderer process. The return value is then returned as a Promise to the original
|
||||
`invoke` call.
|
||||
|
||||
:::caution A word on error handling
|
||||
Errors thrown through `handle` in the main process are not transparent as they
|
||||
are serialized and only the `message` property from the original error is
|
||||
provided to the renderer process. Please refer to
|
||||
[#24427](https://github.com/electron/electron/issues/24427) for details.
|
||||
:::
|
||||
|
||||
```javascript {6-13,25} title='main.js (Main Process)'
|
||||
const { BrowserWindow, dialog, ipcMain } = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
//...
|
||||
|
||||
async function handleFileOpen() {
|
||||
const { canceled, filePaths } = await dialog.showOpenDialog()
|
||||
if (canceled) {
|
||||
return
|
||||
} else {
|
||||
return filePaths[0]
|
||||
}
|
||||
}
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
})
|
||||
mainWindow.loadFile('index.html')
|
||||
}
|
||||
|
||||
app.whenReady(() => {
|
||||
ipcMain.handle('dialog:openFile', handleFileOpen)
|
||||
createWindow()
|
||||
})
|
||||
//...
|
||||
```
|
||||
|
||||
:::tip on channel names
|
||||
The `dialog:` prefix on the IPC channel name has no effect on the code. It only serves
|
||||
as a namespace that helps with code readability.
|
||||
:::
|
||||
|
||||
:::info
|
||||
Make sure you're loading the `index.html` and `preload.js` entry points for the following steps!
|
||||
:::
|
||||
|
||||
### 2. Expose `ipcRenderer.invoke` via preload
|
||||
|
||||
In the preload script, we expose a one-line `openFile` function that calls and returns the value of
|
||||
`ipcRenderer.invoke('dialog:openFile')`. We'll be using this API in the next step to call the
|
||||
native dialog from our renderer's user interface.
|
||||
|
||||
```javascript title='preload.js (Preload Script)'
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
openFile: () => ipcRenderer.invoke('dialog:openFile')
|
||||
})
|
||||
```
|
||||
|
||||
:::caution Security warning
|
||||
We don't directly expose the whole `ipcRenderer.invoke` API for [security reasons]. Make sure to
|
||||
limit the renderer's access to Electron APIs as much as possible.
|
||||
:::
|
||||
|
||||
### 3. Build the renderer process UI
|
||||
|
||||
Finally, let's build the HTML file that we load into our BrowserWindow.
|
||||
|
||||
```html {10-11} title='index.html'
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<title>Dialog</title>
|
||||
</head>
|
||||
<body>
|
||||
<button type="button" id="btn">Open a File</button>
|
||||
File path: <strong id="filePath"></strong>
|
||||
<script src='./renderer.js'></script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
The UI consists of a single `#btn` button element that will be used to trigger our preload API, and
|
||||
a `#filePath` element that will be used to display the path of the selected file. Making these
|
||||
pieces work will take a few lines of code in the renderer process script:
|
||||
|
||||
```javascript title='renderer.js (Renderer Process)'
|
||||
const btn = document.getElementById('btn')
|
||||
const filePathElement = document.getElementById('filePath')
|
||||
|
||||
btn.addEventListener('click', async () => {
|
||||
const filePath = await window.electronAPI.openFile()
|
||||
filePathElement.innerText = filePath
|
||||
})
|
||||
```
|
||||
|
||||
In the above snippet, we listen for clicks on the `#btn` button, and call our
|
||||
`window.electronAPI.openFile()` API to activate the native Open File dialog. We then display the
|
||||
selected file path in the `#filePath` element.
|
||||
|
||||
### Note: legacy approaches
|
||||
|
||||
The `ipcRenderer.invoke` API was added in Electron 7 as a developer-friendly way to tackle two-way
|
||||
IPC from the renderer process. However, there exist a couple alternative approaches to this IPC
|
||||
pattern.
|
||||
|
||||
:::warning Avoid legacy approaches if possible
|
||||
We recommend using `ipcRenderer.invoke` whenever possible. The following two-way renderer-to-main
|
||||
patterns are documented for historical purposes.
|
||||
:::
|
||||
|
||||
:::info
|
||||
For the following examples, we're calling `ipcRenderer` directly from the preload script to keep
|
||||
the code samples small.
|
||||
:::
|
||||
|
||||
#### Using `ipcRenderer.send`
|
||||
|
||||
The `ipcRenderer.send` API that we used for single-way communication can also be leveraged to
|
||||
perform two-way communication. This was the recommended way for asynchronous two-way communication
|
||||
via IPC prior to Electron 7.
|
||||
|
||||
```javascript title='preload.js (Preload Script)'
|
||||
// You can also put expose this code to the renderer
|
||||
// process with the `contextBridge` API
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
ipcRenderer.on('asynchronous-reply', (_event, arg) => {
|
||||
console.log(arg) // prints "pong" in the DevTools console
|
||||
})
|
||||
ipcRenderer.send('asynchronous-message', 'ping')
|
||||
```
|
||||
|
||||
```javascript title='main.js (Main Process)'
|
||||
ipcMain.on('asynchronous-message', (event, arg) => {
|
||||
console.log(arg) // prints "ping" in the Node console
|
||||
// works like `send`, but returning a message back
|
||||
// to the renderer that sent the original message
|
||||
event.reply('asynchronous-reply', 'pong')
|
||||
})
|
||||
```
|
||||
|
||||
There are a couple downsides to this approach:
|
||||
|
||||
* You need to set up a second `ipcRenderer.on` listener to handle the response in the renderer
|
||||
process. With `invoke`, you get the response value returned as a Promise to the original API call.
|
||||
* There's no obvious way to pair the `asynchronous-reply` message to the original
|
||||
`asynchronous-message` one. If you have very frequent messages going back and forth through these
|
||||
channels, you would need to add additional app code to track each call and response individually.
|
||||
|
||||
#### Using `ipcRenderer.sendSync`
|
||||
|
||||
The `ipcRenderer.sendSync` API sends a message to the main process and waits _synchronously_ for a
|
||||
response.
|
||||
|
||||
```javascript title='main.js (Main Process)'
|
||||
const { ipcMain } = require('electron')
|
||||
ipcMain.on('synchronous-message', (event, arg) => {
|
||||
console.log(arg) // prints "ping" in the Node console
|
||||
event.returnValue = 'pong'
|
||||
})
|
||||
```
|
||||
|
||||
```javascript title='preload.js (Preload Script)'
|
||||
// You can also put expose this code to the renderer
|
||||
// process with the `contextBridge` API
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
const result = ipcRenderer.sendSync('synchronous-message', 'ping')
|
||||
console.log(result) // prints "pong" in the DevTools console
|
||||
```
|
||||
|
||||
The structure of this code is very similar to the `invoke` model, but we recommend
|
||||
**avoiding this API** for performance reasons. Its synchronous nature means that it'll block the
|
||||
renderer process until a reply is received.
|
||||
|
||||
## Pattern 3: Main to renderer
|
||||
|
||||
When sending a message from the main process to a renderer process, you need to specify which
|
||||
renderer is receiving the message. Messages need to be sent to a renderer process
|
||||
via its [`WebContents`] instance. This WebContents instance contains a [`send`][webcontents-send] method
|
||||
that can be used in the same way as `ipcRenderer.send`.
|
||||
|
||||
To demonstrate this pattern, we'll be building a number counter controlled by the native operating
|
||||
system menu.
|
||||
|
||||
For this demo, you'll need to add code to your main process, your renderer process, and a preload
|
||||
script. The full code is below, but we'll be explaining each file individually in the following
|
||||
sections.
|
||||
|
||||
```fiddle docs/fiddles/ipc/pattern-3
|
||||
```
|
||||
|
||||
### 1. Send messages with the `webContents` module
|
||||
|
||||
For this demo, we'll need to first build a custom menu in the main process using Electron's `Menu`
|
||||
module that uses the `webContents.send` API to send an IPC message from the main process to the
|
||||
target renderer.
|
||||
|
||||
```javascript {11-26} title='main.js (Main Process)'
|
||||
const {app, BrowserWindow, Menu, ipcMain} = require('electron')
|
||||
const path = require('path')
|
||||
|
||||
function createWindow () {
|
||||
const mainWindow = new BrowserWindow({
|
||||
webPreferences: {
|
||||
preload: path.join(__dirname, 'preload.js')
|
||||
}
|
||||
})
|
||||
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{
|
||||
label: app.name,
|
||||
submenu: [
|
||||
{
|
||||
click: () => mainWindow.webContents.send('update-counter', 1),
|
||||
label: 'Increment',
|
||||
},
|
||||
{
|
||||
click: () => mainWindow.webContents.send('update-counter', -1),
|
||||
label: 'Decrement',
|
||||
}
|
||||
]
|
||||
}
|
||||
])
|
||||
Menu.setApplicationMenu(menu)
|
||||
|
||||
mainWindow.loadFile('index.html')
|
||||
}
|
||||
//...
|
||||
|
||||
```
|
||||
|
||||
For the purposes of the tutorial, it's important to note that the `click` handler
|
||||
sends a message (either `1` or `-1`) to the renderer process through the `update-counter` channel.
|
||||
|
||||
```javascript
|
||||
click: () => mainWindow.webContents.send('update-counter', -1)
|
||||
```
|
||||
|
||||
:::info
|
||||
Make sure you're loading the `index.html` and `preload.js` entry points for the following steps!
|
||||
:::
|
||||
|
||||
### 2. Expose `ipcRenderer.on` via preload
|
||||
|
||||
Like in the previous renderer-to-main example, we use the `contextBridge` and `ipcRenderer`
|
||||
modules in the preload script to expose IPC functionality to the renderer process:
|
||||
|
||||
```javascript title='preload.js (Preload Script)'
|
||||
const { contextBridge, ipcRenderer } = require('electron')
|
||||
|
||||
contextBridge.exposeInMainWorld('electronAPI', {
|
||||
onUpdateCounter: (callback) => ipcRenderer.on('update-counter', callback)
|
||||
})
|
||||
```
|
||||
|
||||
After loading the preload script, your renderer process should have access to the
|
||||
`window.electronAPI.onUpdateCounter()` listener function.
|
||||
|
||||
:::caution Security warning
|
||||
We don't directly expose the whole `ipcRenderer.on` API for [security reasons]. Make sure to
|
||||
limit the renderer's access to Electron APIs as much as possible.
|
||||
:::
|
||||
|
||||
:::info
|
||||
In the case of this minimal example, you can call `ipcRenderer.on` directly in the preload script
|
||||
rather than exposing it over the context bridge.
|
||||
|
||||
```javascript title='preload.js (Preload Script)'
|
||||
const { ipcRenderer } = require('electron')
|
||||
|
||||
window.addEventListener('DOMContentLoaded', () => {
|
||||
const counter = document.getElementById('counter')
|
||||
ipcRenderer.on('update-counter', (_event, value) => {
|
||||
const oldValue = Number(counter.innerText)
|
||||
const newValue = oldValue + value
|
||||
counter.innerText = newValue
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
However, this approach has limited flexibility compared to exposing your preload APIs
|
||||
over the context bridge, since your listener can't directly interact with your renderer code.
|
||||
:::
|
||||
|
||||
### 3. Build the renderer process UI
|
||||
|
||||
To tie it all together, we'll create an interface in the loaded HTML file that contains a
|
||||
`#counter` element that we'll use to display the values:
|
||||
|
||||
```html {10} title='index.html'
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<title>Menu Counter</title>
|
||||
</head>
|
||||
<body>
|
||||
Current value: <strong id="counter">0</strong>
|
||||
<script src="./renderer.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
Finally, to make the values update in the HTML document, we'll add a few lines of DOM manipulation
|
||||
so that the value of the `#counter` element is updated whenever we fire an `update-counter` event.
|
||||
|
||||
```javascript title='renderer.js (Renderer Process)'
|
||||
const counter = document.getElementById('counter')
|
||||
|
||||
window.electronAPI.onUpdateCounter((_event, value) => {
|
||||
const oldValue = Number(counter.innerText)
|
||||
const newValue = oldValue + value
|
||||
counter.innerText = newValue
|
||||
})
|
||||
```
|
||||
|
||||
In the above code, we're passing in a callback to the `window.electronAPI.onUpdateCounter` function
|
||||
exposed from our preload script. The second `value` parameter corresponds to the `1` or `-1` we
|
||||
were passing in from the `webContents.send` call from the native menu.
|
||||
|
||||
### Optional: returning a reply
|
||||
|
||||
There's no equivalent for `ipcRenderer.invoke` for main-to-renderer IPC. Instead, you can
|
||||
send a reply back to the main process from within the `ipcRenderer.on` callback.
|
||||
|
||||
We can demonstrate this with slight modifications to the code from the previous example. In the
|
||||
renderer process, use the `event` parameter to send a reply back to the main process through the
|
||||
`counter-value` channel.
|
||||
|
||||
```javascript title='renderer.js (Renderer Process)'
|
||||
const counter = document.getElementById('counter')
|
||||
|
||||
window.electronAPI.onUpdateCounter((event, value) => {
|
||||
const oldValue = Number(counter.innerText)
|
||||
const newValue = oldValue + value
|
||||
counter.innerText = newValue
|
||||
event.sender.send('counter-value', newValue)
|
||||
})
|
||||
```
|
||||
|
||||
In the main process, listen for `counter-value` events and handle them appropriately.
|
||||
|
||||
```javascript title='main.js (Main Process)'
|
||||
//...
|
||||
ipcMain.on('counter-value', (_event, value) => {
|
||||
console.log(value) // will print value to Node console
|
||||
})
|
||||
//...
|
||||
```
|
||||
|
||||
## Pattern 4: Renderer to renderer
|
||||
|
||||
There's no direct way to send messages between renderer processes in Electron using the `ipcMain`
|
||||
and `ipcRenderer` modules. To achieve this, you have two options:
|
||||
|
||||
* Use the main process as a message broker between renderers. This would involve sending a message
|
||||
from one renderer to the main process, which would forward the message to the other renderer.
|
||||
* Pass a [MessagePort] from the main process to both renderers. This will allow direct communication
|
||||
between renderers after the initial setup.
|
||||
|
||||
## Object serialization
|
||||
|
||||
Electron's IPC implementation uses the HTML standard
|
||||
[Structured Clone Algorithm][sca] to serialize objects passed between processes, meaning that
|
||||
only certain types of objects can be passed through IPC channels.
|
||||
|
||||
In particular, DOM objects (e.g. `Element`, `Location` and `DOMMatrix`), Node.js objects
|
||||
backed by C++ classes (e.g. `process.env`, some members of `Stream`), and Electron objects
|
||||
backed by C++ classes (e.g. `WebContents`, `BrowserWindow` and `WebFrame`) are not serializable
|
||||
with Structured Clone.
|
||||
|
||||
[context isolation tutorial]: context-isolation.md
|
||||
[security reasons]: ./context-isolation.md#security-considerations
|
||||
[`ipcMain`]: ../api/ipc-main.md
|
||||
[`ipcMain.handle`]: ../api/ipc-main.md#ipcmainhandlechannel-listener
|
||||
[`ipcMain.on`]: ../api/ipc-main.md
|
||||
[IpcMainEvent]: ../api/structures/ipc-main-event.md
|
||||
[`ipcRenderer`]: ../api/ipc-renderer.md
|
||||
[`ipcRenderer.invoke`]: ../api/ipc-renderer.md#ipcrendererinvokechannel-args
|
||||
[`ipcRenderer.send`]: ../api/ipc-renderer.md
|
||||
[MessagePort]: ./message-ports.md
|
||||
[preload script]: process-model.md#preload-scripts
|
||||
[process model docs]: process-model.md
|
||||
[sca]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm
|
||||
[`WebContents`]: ../api/web-contents.md
|
||||
[webcontents-send]: ../api/web-contents.md#contentssendchannel-args
|
||||
@@ -131,7 +131,6 @@ folder of your project:
|
||||
<meta charset="UTF-8">
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<title>Hello World!</title>
|
||||
</head>
|
||||
<body>
|
||||
@@ -427,7 +426,6 @@ window.addEventListener('DOMContentLoaded', () => {
|
||||
<meta charset="UTF-8">
|
||||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
|
||||
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<meta http-equiv="X-Content-Security-Policy" content="default-src 'self'; script-src 'self'">
|
||||
<title>Hello World!</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -175,8 +175,10 @@ template("electron_paks") {
|
||||
source_patterns = [
|
||||
"${root_gen_dir}/chrome/platform_locale_settings_",
|
||||
"${root_gen_dir}/components/strings/components_strings_",
|
||||
"${root_gen_dir}/third_party/blink/public/strings/blink_accessibility_strings_",
|
||||
"${root_gen_dir}/third_party/blink/public/strings/blink_strings_",
|
||||
"${root_gen_dir}/device/bluetooth/strings/bluetooth_strings_",
|
||||
"${root_gen_dir}/extensions/strings/extensions_strings_",
|
||||
"${root_gen_dir}/services/strings/services_strings_",
|
||||
"${root_gen_dir}/ui/strings/app_locale_settings_",
|
||||
"${root_gen_dir}/ui/strings/ax_strings_",
|
||||
@@ -186,8 +188,10 @@ template("electron_paks") {
|
||||
"//chrome/app/resources:platform_locale_settings",
|
||||
"//components/strings:components_strings",
|
||||
"//device/bluetooth/strings",
|
||||
"//extensions/strings",
|
||||
"//services/strings",
|
||||
"//third_party/blink/public/strings",
|
||||
"//third_party/blink/public/strings:accessibility_strings",
|
||||
"//ui/strings:app_locale_settings",
|
||||
"//ui/strings:ax_strings",
|
||||
"//ui/strings:ui_strings",
|
||||
|
||||
@@ -145,4 +145,16 @@
|
||||
</message>
|
||||
<message name="IDS_HID_CHOOSER_ITEM_WITHOUT_NAME" desc="User option displaying the device IDs for a Human Interface Device (HID) without a device name.">
|
||||
Unknown Device (<ph name="DEVICE_ID">$1<ex>1234:abcd</ex></ph>) </message>
|
||||
<if expr="is_win">
|
||||
<then>
|
||||
<message name="IDS_AX_UNLABELED_IMAGE_ROLE_DESCRIPTION" desc="Accessibility role description for a graphic (image) on a web page or PDF that does not have a description for blind users." is_accessibility_with_no_ui="true">
|
||||
Unlabeled graphic
|
||||
</message>
|
||||
</then>
|
||||
<else>
|
||||
<message name="IDS_AX_UNLABELED_IMAGE_ROLE_DESCRIPTION" desc="Accessibility role description for an image on a web page or PDF that does not have a description for blind users." is_accessibility_with_no_ui="true">
|
||||
Unlabeled image
|
||||
</message>
|
||||
</else>
|
||||
</if>
|
||||
</grit-part>
|
||||
|
||||
@@ -53,8 +53,6 @@ filenames = {
|
||||
"shell/browser/ui/views/global_menu_bar_x11.h",
|
||||
"shell/browser/ui/x/event_disabler.cc",
|
||||
"shell/browser/ui/x/event_disabler.h",
|
||||
"shell/browser/ui/x/window_state_watcher.cc",
|
||||
"shell/browser/ui/x/window_state_watcher.h",
|
||||
"shell/browser/ui/x/x_window_utils.cc",
|
||||
"shell/browser/ui/x/x_window_utils.h",
|
||||
]
|
||||
|
||||
@@ -72,7 +72,10 @@ BrowserWindow.getAllWindows = () => {
|
||||
|
||||
BrowserWindow.getFocusedWindow = () => {
|
||||
for (const window of BrowserWindow.getAllWindows()) {
|
||||
if (window.isFocused() || window.isDevToolsFocused()) return window;
|
||||
const hasWC = window.webContents && !window.webContents.isDestroyed();
|
||||
if (!window.isDestroyed() && hasWC) {
|
||||
if (window.isFocused() || window.isDevToolsFocused()) return window;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
@@ -500,6 +500,7 @@ WebContents.prototype._callWindowOpenHandler = function (event: Electron.Event,
|
||||
if (!this._windowOpenHandler) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const response = this._windowOpenHandler(details);
|
||||
|
||||
if (typeof response !== 'object') {
|
||||
@@ -617,6 +618,7 @@ WebContents.prototype._init = function () {
|
||||
});
|
||||
|
||||
this.on('-ipc-ports' as any, function (event: Electron.IpcMainEvent, internal: boolean, channel: string, message: any, ports: any[]) {
|
||||
addSenderFrameToEvent(event);
|
||||
event.ports = ports.map(p => new MessagePortMain(p));
|
||||
ipcMain.emit(channel, event, message);
|
||||
});
|
||||
@@ -655,7 +657,15 @@ WebContents.prototype._init = function () {
|
||||
postBody,
|
||||
disposition
|
||||
};
|
||||
const options = this._callWindowOpenHandler(event, details);
|
||||
|
||||
let options: ReturnType<typeof this._callWindowOpenHandler>;
|
||||
try {
|
||||
options = this._callWindowOpenHandler(event, details);
|
||||
} catch (err) {
|
||||
event.preventDefault();
|
||||
throw err;
|
||||
}
|
||||
|
||||
if (!event.defaultPrevented) {
|
||||
openGuestWindow({
|
||||
event,
|
||||
@@ -683,7 +693,16 @@ WebContents.prototype._init = function () {
|
||||
referrer,
|
||||
postBody
|
||||
};
|
||||
windowOpenOverriddenOptions = this._callWindowOpenHandler(event, details);
|
||||
|
||||
let result: ReturnType<typeof this._callWindowOpenHandler>;
|
||||
try {
|
||||
result = this._callWindowOpenHandler(event, details);
|
||||
} catch (err) {
|
||||
event.preventDefault();
|
||||
throw err;
|
||||
}
|
||||
|
||||
windowOpenOverriddenOptions = result;
|
||||
if (!event.defaultPrevented) {
|
||||
const secureOverrideWebPreferences = windowOpenOverriddenOptions ? {
|
||||
// Allow setting of backgroundColor as a webPreference even though
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
// Rip global off of window (which is also global) so that webpack doesn't
|
||||
// auto replace it with a looped reference to this file
|
||||
const _global = typeof globalThis !== 'undefined' ? globalThis.global : (self as any || window as any).global as NodeJS.Global;
|
||||
const _global = typeof globalThis !== 'undefined' ? globalThis.global : (self || window).global;
|
||||
const process = _global.process;
|
||||
const Buffer = _global.Buffer;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@electron/get": "^1.13.0",
|
||||
"@types/node": "^14.6.2",
|
||||
"@types/node": "^16.11.26",
|
||||
"extract-zip": "^1.0.3"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
17
package.json
17
package.json
@@ -1,9 +1,10 @@
|
||||
{
|
||||
"name": "electron",
|
||||
"version": "18.0.0-beta.6",
|
||||
"version": "18.3.5",
|
||||
"repository": "https://github.com/electron/electron",
|
||||
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
||||
"devDependencies": {
|
||||
"@azure/storage-blob": "^12.9.0",
|
||||
"@electron/docs-parser": "^0.12.3",
|
||||
"@electron/typescript-definitions": "^8.9.5",
|
||||
"@octokit/auth-app": "^2.10.0",
|
||||
@@ -14,12 +15,12 @@
|
||||
"@types/chai": "^4.2.12",
|
||||
"@types/chai-as-promised": "^7.1.3",
|
||||
"@types/dirty-chai": "^2.0.2",
|
||||
"@types/express": "^4.17.7",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/fs-extra": "^9.0.1",
|
||||
"@types/klaw": "^3.0.1",
|
||||
"@types/minimist": "^1.2.0",
|
||||
"@types/mocha": "^7.0.2",
|
||||
"@types/node": "^14.6.2",
|
||||
"@types/node": "^16.11.26",
|
||||
"@types/semver": "^7.3.3",
|
||||
"@types/send": "^0.14.5",
|
||||
"@types/split": "^1.0.0",
|
||||
@@ -27,7 +28,7 @@
|
||||
"@types/temp": "^0.8.34",
|
||||
"@types/uuid": "^3.4.6",
|
||||
"@types/webpack": "^4.41.21",
|
||||
"@types/webpack-env": "^1.15.2",
|
||||
"@types/webpack-env": "^1.16.3",
|
||||
"@typescript-eslint/eslint-plugin": "^4.4.1",
|
||||
"@typescript-eslint/parser": "^4.4.1",
|
||||
"asar": "^3.1.0",
|
||||
@@ -78,14 +79,14 @@
|
||||
"generate-version-json": "node script/generate-version-json.js",
|
||||
"lint": "node ./script/lint.js && npm run lint:clang-format && npm run lint:docs",
|
||||
"lint:js": "node ./script/lint.js --js",
|
||||
"lint:clang-format": "python script/run-clang-format.py -r -c shell/ || (echo \"\\nCode not formatted correctly.\" && exit 1)",
|
||||
"lint:clang-format": "python3 script/run-clang-format.py -r -c shell/ || (echo \"\\nCode not formatted correctly.\" && exit 1)",
|
||||
"lint:clang-tidy": "ts-node ./script/run-clang-tidy.ts",
|
||||
"lint:cpp": "node ./script/lint.js --cc",
|
||||
"lint:objc": "node ./script/lint.js --objc",
|
||||
"lint:py": "node ./script/lint.js --py",
|
||||
"lint:gn": "node ./script/lint.js --gn",
|
||||
"lint:docs": "remark docs -qf && npm run lint:js-in-markdown && npm run create-typescript-definitions && npm run lint:docs-relative-links && npm run lint:markdownlint",
|
||||
"lint:docs-relative-links": "python ./script/check-relative-doc-links.py",
|
||||
"lint:docs-relative-links": "python3 ./script/check-relative-doc-links.py",
|
||||
"lint:markdownlint": "markdownlint \"*.md\" \"docs/**/*.md\"",
|
||||
"lint:js-in-markdown": "standard-markdown docs",
|
||||
"create-api-json": "electron-docs-parser --dir=./",
|
||||
@@ -116,14 +117,14 @@
|
||||
"ts-node script/gen-filenames.ts"
|
||||
],
|
||||
"*.{cc,mm,c,h}": [
|
||||
"python script/run-clang-format.py -r -c --fix"
|
||||
"python3 script/run-clang-format.py -r -c --fix"
|
||||
],
|
||||
"*.md": [
|
||||
"npm run lint:docs"
|
||||
],
|
||||
"*.{gn,gni}": [
|
||||
"npm run gn-check",
|
||||
"python script/run-gn-format.py"
|
||||
"python3 script/run-gn-format.py"
|
||||
],
|
||||
"*.py": [
|
||||
"node script/lint.js --py --fix --only --"
|
||||
|
||||
4
patches/angle/.patches
Normal file
4
patches/angle/.patches
Normal file
@@ -0,0 +1,4 @@
|
||||
cherry-pick-9768648fffc9.patch
|
||||
cherry-pick-801b904aea7d.patch
|
||||
cherry-pick-03aa5ae75c29.patch
|
||||
cherry-pick-6661eb4900da.patch
|
||||
76
patches/angle/cherry-pick-03aa5ae75c29.patch
Normal file
76
patches/angle/cherry-pick-03aa5ae75c29.patch
Normal file
@@ -0,0 +1,76 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Geoff Lang <geofflang@google.com>
|
||||
Date: Wed, 1 Jun 2022 11:22:42 -0400
|
||||
Subject: M102: Ignore eglBind/ReleaseTexImage calls for lost contexts.
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
eglBindTexImage and eglReleaseTexImage no-op when no context is
|
||||
current. Extend this to lost contexts to match the behaviour of making
|
||||
a GL call on a lost context.
|
||||
|
||||
This avoids potential unexpected bad accesses in the backends.
|
||||
|
||||
Bug: chromium:1316578
|
||||
Change-Id: I7b309c297e0c803019720733dee2950abb4c4b5f
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3683869
|
||||
Reviewed-by: Jamie Madill <jmadill@chromium.org>
|
||||
Reviewed-by: Alexis Hétu <sugoi@google.com>
|
||||
Reviewed-by: Alexis Hétu <sugoi@chromium.org>
|
||||
Commit-Queue: Geoff Lang <geofflang@chromium.org>
|
||||
(cherry picked from commit bfab7e60a15dc6f72e34406d3f2a3996cd8d0be2)
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3691180
|
||||
|
||||
diff --git a/src/libANGLE/validationEGL.cpp b/src/libANGLE/validationEGL.cpp
|
||||
index 7e4b3adb8db7ea32c98228155e0a702796f0da4c..4309fd84e74fbb4a21edfb9b90bfc1fcda5a9d4a 100644
|
||||
--- a/src/libANGLE/validationEGL.cpp
|
||||
+++ b/src/libANGLE/validationEGL.cpp
|
||||
@@ -4863,7 +4863,7 @@ bool ValidateBindTexImage(const ValidationContext *val,
|
||||
}
|
||||
|
||||
gl::Context *context = val->eglThread->getContext();
|
||||
- if (context)
|
||||
+ if (context && !context->isContextLost())
|
||||
{
|
||||
gl::TextureType type = egl_gl::EGLTextureTargetToTextureType(surface->getTextureTarget());
|
||||
gl::Texture *textureObject = context->getTextureByType(type);
|
||||
diff --git a/src/libGLESv2/egl_stubs.cpp b/src/libGLESv2/egl_stubs.cpp
|
||||
index 0554b7f40c65d6a2690380fe7483818886e20533..645f53ba038e3a5ad580eead0d9135cd274c57f8 100644
|
||||
--- a/src/libGLESv2/egl_stubs.cpp
|
||||
+++ b/src/libGLESv2/egl_stubs.cpp
|
||||
@@ -61,7 +61,7 @@ EGLBoolean BindTexImage(Thread *thread, Display *display, Surface *eglSurface, E
|
||||
GetDisplayIfValid(display), EGL_FALSE);
|
||||
|
||||
gl::Context *context = thread->getContext();
|
||||
- if (context)
|
||||
+ if (context && !context->isContextLost())
|
||||
{
|
||||
gl::TextureType type =
|
||||
egl_gl::EGLTextureTargetToTextureType(eglSurface->getTextureTarget());
|
||||
@@ -573,15 +573,18 @@ EGLBoolean ReleaseTexImage(Thread *thread, Display *display, Surface *eglSurface
|
||||
{
|
||||
ANGLE_EGL_TRY_RETURN(thread, display->prepareForCall(), "eglReleaseTexImage",
|
||||
GetDisplayIfValid(display), EGL_FALSE);
|
||||
- gl::Texture *texture = eglSurface->getBoundTexture();
|
||||
-
|
||||
- if (texture)
|
||||
+ gl::Context *context = thread->getContext();
|
||||
+ if (context && !context->isContextLost())
|
||||
{
|
||||
- ANGLE_EGL_TRY_RETURN(thread, eglSurface->releaseTexImage(thread->getContext(), buffer),
|
||||
- "eglReleaseTexImage", GetSurfaceIfValid(display, eglSurface),
|
||||
- EGL_FALSE);
|
||||
- }
|
||||
+ gl::Texture *texture = eglSurface->getBoundTexture();
|
||||
|
||||
+ if (texture)
|
||||
+ {
|
||||
+ ANGLE_EGL_TRY_RETURN(thread, eglSurface->releaseTexImage(thread->getContext(), buffer),
|
||||
+ "eglReleaseTexImage", GetSurfaceIfValid(display, eglSurface),
|
||||
+ EGL_FALSE);
|
||||
+ }
|
||||
+ }
|
||||
thread->setSuccess();
|
||||
return EGL_TRUE;
|
||||
}
|
||||
27
patches/angle/cherry-pick-6661eb4900da.patch
Normal file
27
patches/angle/cherry-pick-6661eb4900da.patch
Normal file
@@ -0,0 +1,27 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jamie Madill <jmadill@chromium.org>
|
||||
Date: Mon, 2 May 2022 15:42:23 -0400
|
||||
Subject: Fix validation cache when deleting a Transform Feedback.
|
||||
|
||||
Bug: chromium:1320024
|
||||
Change-Id: I76ef85a3c65c663c138d8caebd4ef2c0da53cd4f
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3621780
|
||||
Commit-Queue: Jamie Madill <jmadill@chromium.org>
|
||||
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
|
||||
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
|
||||
(cherry picked from commit 84e42c3b04da9e2c9d93d35bb6f2b1830fef22f4)
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3650697
|
||||
Reviewed-by: Geoff Lang <geofflang@chromium.org>
|
||||
|
||||
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
|
||||
index 390f7bc6790abe5d84b05f97160966eca46fee05..86da3fd82fff38c911e8678a1f6c415583b38381 100755
|
||||
--- a/src/libANGLE/Context.cpp
|
||||
+++ b/src/libANGLE/Context.cpp
|
||||
@@ -3075,6 +3075,7 @@ void Context::detachTransformFeedback(TransformFeedbackID transformFeedback)
|
||||
if (mState.removeTransformFeedbackBinding(this, transformFeedback))
|
||||
{
|
||||
bindTransformFeedback(GL_TRANSFORM_FEEDBACK, {0});
|
||||
+ mStateCache.onActiveTransformFeedbackChange(this);
|
||||
}
|
||||
}
|
||||
|
||||
238
patches/angle/cherry-pick-801b904aea7d.patch
Normal file
238
patches/angle/cherry-pick-801b904aea7d.patch
Normal file
@@ -0,0 +1,238 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jamie Madill <jmadill@chromium.org>
|
||||
Date: Fri, 20 May 2022 10:26:15 -0400
|
||||
Subject: D3D: Fix race condition with parallel shader compile.
|
||||
|
||||
Bug: chromium:1317673
|
||||
Change-Id: I0fb7c9a66248852e41e8700e80c295393ef941e8
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3651153
|
||||
Reviewed-by: Jie A Chen <jie.a.chen@intel.com>
|
||||
Reviewed-by: Lingfeng Yang <lfy@google.com>
|
||||
Commit-Queue: Jamie Madill <jmadill@chromium.org>
|
||||
(cherry picked from commit 4a20c9143abbf29c649cf643182735e8952089e3)
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3691050
|
||||
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
|
||||
|
||||
diff --git a/src/libANGLE/renderer/d3d/ProgramD3D.cpp b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
|
||||
index 59fe34fc46a1bfbc7b4be1aad6ad84b6da303b5b..3256357a80d69739661ec1fd32220d3037145875 100644
|
||||
--- a/src/libANGLE/renderer/d3d/ProgramD3D.cpp
|
||||
+++ b/src/libANGLE/renderer/d3d/ProgramD3D.cpp
|
||||
@@ -1687,12 +1687,6 @@ class ProgramD3D::GetVertexExecutableTask : public ProgramD3D::GetExecutableTask
|
||||
angle::Result run() override
|
||||
{
|
||||
ANGLE_TRACE_EVENT0("gpu.angle", "ProgramD3D::GetVertexExecutableTask::run");
|
||||
- if (!mProgram->mState.getAttachedShader(gl::ShaderType::Vertex))
|
||||
- {
|
||||
- return angle::Result::Continue;
|
||||
- }
|
||||
-
|
||||
- mProgram->updateCachedInputLayoutFromShader();
|
||||
|
||||
ANGLE_TRY(mProgram->getVertexExecutableForCachedInputLayout(this, &mExecutable, &mInfoLog));
|
||||
|
||||
@@ -2147,6 +2141,11 @@ std::unique_ptr<LinkEvent> ProgramD3D::link(const gl::Context *context,
|
||||
|
||||
linkResources(resources);
|
||||
|
||||
+ if (mState.getAttachedShader(gl::ShaderType::Vertex))
|
||||
+ {
|
||||
+ updateCachedInputLayoutFromShader();
|
||||
+ }
|
||||
+
|
||||
return compileProgramExecutables(context, infoLog);
|
||||
}
|
||||
}
|
||||
diff --git a/src/tests/gl_tests/ParallelShaderCompileTest.cpp b/src/tests/gl_tests/ParallelShaderCompileTest.cpp
|
||||
index bcd88ef01308759085c8244ad2058efe68686f2b..a98aff540c642617bba366b2e238519942d7e349 100644
|
||||
--- a/src/tests/gl_tests/ParallelShaderCompileTest.cpp
|
||||
+++ b/src/tests/gl_tests/ParallelShaderCompileTest.cpp
|
||||
@@ -58,9 +58,10 @@ class ParallelShaderCompileTest : public ANGLETest
|
||||
Task(int id) : mID(id) {}
|
||||
virtual ~Task() {}
|
||||
|
||||
- virtual bool compile() = 0;
|
||||
- virtual bool isCompileCompleted() = 0;
|
||||
- virtual bool link() = 0;
|
||||
+ virtual bool compile() = 0;
|
||||
+ virtual bool isCompileCompleted() = 0;
|
||||
+ virtual bool link() = 0;
|
||||
+ virtual void postLink() {}
|
||||
virtual void runAndVerify(ParallelShaderCompileTest *test) = 0;
|
||||
|
||||
bool isLinkCompleted()
|
||||
@@ -71,7 +72,7 @@ class ParallelShaderCompileTest : public ANGLETest
|
||||
}
|
||||
|
||||
protected:
|
||||
- std::string insertRandomString(const std::string &source)
|
||||
+ static std::string InsertRandomString(const std::string &source)
|
||||
{
|
||||
RNG rng;
|
||||
std::ostringstream ostream;
|
||||
@@ -80,7 +81,7 @@ class ParallelShaderCompileTest : public ANGLETest
|
||||
return ostream.str();
|
||||
}
|
||||
|
||||
- GLuint CompileShader(GLenum type, const std::string &source)
|
||||
+ static GLuint CompileShader(GLenum type, const std::string &source)
|
||||
{
|
||||
GLuint shader = glCreateShader(type);
|
||||
|
||||
@@ -90,7 +91,14 @@ class ParallelShaderCompileTest : public ANGLETest
|
||||
return shader;
|
||||
}
|
||||
|
||||
- bool checkShader(GLuint shader)
|
||||
+ static void RecompileShader(GLuint shader, const std::string &source)
|
||||
+ {
|
||||
+ const char *sourceArray[1] = {source.c_str()};
|
||||
+ glShaderSource(shader, 1, sourceArray, nullptr);
|
||||
+ glCompileShader(shader);
|
||||
+ }
|
||||
+
|
||||
+ static bool CheckShader(GLuint shader)
|
||||
{
|
||||
GLint compileResult;
|
||||
glGetShaderiv(shader, GL_COMPILE_STATUS, &compileResult);
|
||||
@@ -129,7 +137,7 @@ class ParallelShaderCompileTest : public ANGLETest
|
||||
TaskRunner() {}
|
||||
~TaskRunner() {}
|
||||
|
||||
- void run(ParallelShaderCompileTest *test)
|
||||
+ void run(ParallelShaderCompileTest *test, unsigned int pollInterval)
|
||||
{
|
||||
|
||||
std::vector<std::unique_ptr<T>> compileTasks;
|
||||
@@ -151,6 +159,7 @@ class ParallelShaderCompileTest : public ANGLETest
|
||||
if (task->isCompileCompleted())
|
||||
{
|
||||
bool isLinking = task->link();
|
||||
+ task->postLink();
|
||||
ASSERT_TRUE(isLinking);
|
||||
linkTasks.push_back(std::move(task));
|
||||
compileTasks.erase(compileTasks.begin() + i);
|
||||
@@ -158,7 +167,10 @@ class ParallelShaderCompileTest : public ANGLETest
|
||||
}
|
||||
++i;
|
||||
}
|
||||
- angle::Sleep(kPollInterval);
|
||||
+ if (pollInterval != 0)
|
||||
+ {
|
||||
+ angle::Sleep(pollInterval);
|
||||
+ }
|
||||
}
|
||||
|
||||
while (!linkTasks.empty())
|
||||
@@ -173,9 +185,16 @@ class ParallelShaderCompileTest : public ANGLETest
|
||||
linkTasks.erase(linkTasks.begin() + i);
|
||||
continue;
|
||||
}
|
||||
+ else
|
||||
+ {
|
||||
+ task->postLink();
|
||||
+ }
|
||||
++i;
|
||||
}
|
||||
- angle::Sleep(kPollInterval);
|
||||
+ if (pollInterval != 0)
|
||||
+ {
|
||||
+ angle::Sleep(pollInterval);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -192,9 +211,9 @@ class ParallelShaderCompileTest : public ANGLETest
|
||||
bool compile() override
|
||||
{
|
||||
mVertexShader =
|
||||
- CompileShader(GL_VERTEX_SHADER, insertRandomString(essl1_shaders::vs::Simple()));
|
||||
+ CompileShader(GL_VERTEX_SHADER, InsertRandomString(essl1_shaders::vs::Simple()));
|
||||
mFragmentShader = CompileShader(GL_FRAGMENT_SHADER,
|
||||
- insertRandomString(essl1_shaders::fs::UniformColor()));
|
||||
+ InsertRandomString(essl1_shaders::fs::UniformColor()));
|
||||
return (mVertexShader != 0 && mFragmentShader != 0);
|
||||
}
|
||||
|
||||
@@ -213,7 +232,7 @@ class ParallelShaderCompileTest : public ANGLETest
|
||||
bool link() override
|
||||
{
|
||||
mProgram = 0;
|
||||
- if (checkShader(mVertexShader) && checkShader(mFragmentShader))
|
||||
+ if (CheckShader(mVertexShader) && CheckShader(mFragmentShader))
|
||||
{
|
||||
mProgram = glCreateProgram();
|
||||
glAttachShader(mProgram, mVertexShader);
|
||||
@@ -244,10 +263,25 @@ class ParallelShaderCompileTest : public ANGLETest
|
||||
ASSERT_GL_NO_ERROR();
|
||||
}
|
||||
|
||||
+ protected:
|
||||
+ void recompile()
|
||||
+ {
|
||||
+ RecompileShader(mVertexShader, essl1_shaders::vs::Simple());
|
||||
+ RecompileShader(mFragmentShader, essl1_shaders::fs::UniformColor());
|
||||
+ }
|
||||
+
|
||||
private:
|
||||
- GLColor mColor;
|
||||
GLuint mVertexShader;
|
||||
GLuint mFragmentShader;
|
||||
+ GLColor mColor;
|
||||
+ };
|
||||
+
|
||||
+ class ClearColorWithDrawRecompile : public ClearColorWithDraw
|
||||
+ {
|
||||
+ public:
|
||||
+ ClearColorWithDrawRecompile(int taskID) : ClearColorWithDraw(taskID) {}
|
||||
+
|
||||
+ void postLink() override { recompile(); }
|
||||
};
|
||||
|
||||
class ImageLoadStore : public Task
|
||||
@@ -268,7 +302,7 @@ void main()
|
||||
imageStore(uImage_2, ivec2(gl_LocalInvocationID.xy), value);
|
||||
})";
|
||||
|
||||
- mShader = CompileShader(GL_COMPUTE_SHADER, insertRandomString(kCSSource));
|
||||
+ mShader = CompileShader(GL_COMPUTE_SHADER, InsertRandomString(kCSSource));
|
||||
return mShader != 0;
|
||||
}
|
||||
|
||||
@@ -282,7 +316,7 @@ void main()
|
||||
bool link() override
|
||||
{
|
||||
mProgram = 0;
|
||||
- if (checkShader(mShader))
|
||||
+ if (CheckShader(mShader))
|
||||
{
|
||||
mProgram = glCreateProgram();
|
||||
glAttachShader(mProgram, mShader);
|
||||
@@ -370,7 +404,18 @@ TEST_P(ParallelShaderCompileTest, LinkAndDrawManyPrograms)
|
||||
ANGLE_SKIP_TEST_IF(!ensureParallelShaderCompileExtensionAvailable());
|
||||
|
||||
TaskRunner<ClearColorWithDraw> runner;
|
||||
- runner.run(this);
|
||||
+ runner.run(this, kPollInterval);
|
||||
+}
|
||||
+
|
||||
+// Tests no crash in case that the Shader starts another compile while the Program being attached
|
||||
+// to is still linking.
|
||||
+// crbug.com/1317673
|
||||
+TEST_P(ParallelShaderCompileTest, LinkProgramAndRecompileShader)
|
||||
+{
|
||||
+ ANGLE_SKIP_TEST_IF(!ensureParallelShaderCompileExtensionAvailable());
|
||||
+
|
||||
+ TaskRunner<ClearColorWithDrawRecompile> runner;
|
||||
+ runner.run(this, 0);
|
||||
}
|
||||
|
||||
class ParallelShaderCompileTestES31 : public ParallelShaderCompileTest
|
||||
@@ -389,7 +434,7 @@ TEST_P(ParallelShaderCompileTestES31, LinkAndDispatchManyPrograms)
|
||||
ANGLE_SKIP_TEST_IF(!ensureParallelShaderCompileExtensionAvailable());
|
||||
|
||||
TaskRunner<ImageLoadStore> runner;
|
||||
- runner.run(this);
|
||||
+ runner.run(this, kPollInterval);
|
||||
}
|
||||
|
||||
ANGLE_INSTANTIATE_TEST_ES2(ParallelShaderCompileTest);
|
||||
26
patches/angle/cherry-pick-9768648fffc9.patch
Normal file
26
patches/angle/cherry-pick-9768648fffc9.patch
Normal file
@@ -0,0 +1,26 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: SeongHwan Park <ggabu423@gmail.com>
|
||||
Date: Tue, 31 May 2022 02:41:32 +0900
|
||||
Subject: Fix to invalidate cache when binding Transform Feedback.
|
||||
|
||||
Bug: chromium:1330379
|
||||
Change-Id: I091116286ac511c50f9abcffa4d3cf350be920b4
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3677115
|
||||
Commit-Queue: Jamie Madill <jmadill@chromium.org>
|
||||
Reviewed-by: Jamie Madill <jmadill@chromium.org>
|
||||
(cherry picked from commit d96cee6685099f6bcc392a4d20d28c8ec484673a)
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3691799
|
||||
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
|
||||
|
||||
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
|
||||
index 685b235cc5962c4f55f539e387dda8c7edb023bc..390f7bc6790abe5d84b05f97160966eca46fee05 100755
|
||||
--- a/src/libANGLE/Context.cpp
|
||||
+++ b/src/libANGLE/Context.cpp
|
||||
@@ -1323,6 +1323,7 @@ void Context::bindTransformFeedback(GLenum target, TransformFeedbackID transform
|
||||
TransformFeedback *transformFeedback =
|
||||
checkTransformFeedbackAllocation(transformFeedbackHandle);
|
||||
mState.setTransformFeedbackBinding(this, transformFeedback);
|
||||
+ mStateCache.onActiveTransformFeedbackChange(this);
|
||||
}
|
||||
|
||||
void Context::bindProgramPipeline(ProgramPipelineID pipelineHandle)
|
||||
@@ -66,7 +66,6 @@ feat_enable_offscreen_rendering_with_viz_compositor.patch
|
||||
gpu_notify_when_dxdiag_request_fails.patch
|
||||
feat_allow_embedders_to_add_observers_on_created_hunspell.patch
|
||||
feat_add_onclose_to_messageport.patch
|
||||
ui_gtk_public_header.patch
|
||||
allow_in-process_windows_to_have_different_web_prefs.patch
|
||||
refactor_expose_cursor_changes_to_the_webcontentsobserver.patch
|
||||
crash_allow_setting_more_options.patch
|
||||
@@ -103,14 +102,30 @@ chore_do_not_use_chrome_windows_in_cryptotoken_webrequestsender.patch
|
||||
process_singleton.patch
|
||||
fix_expose_decrementcapturercount_in_web_contents_impl.patch
|
||||
add_ui_scopedcliboardwriter_writeunsaferawdata.patch
|
||||
feat_add_data_parameter_to_processsingleton.patch
|
||||
mas_gate_private_enterprise_APIs.patch
|
||||
load_v8_snapshot_in_browser_process.patch
|
||||
fix_patch_out_permissions_checks_in_exclusive_access.patch
|
||||
fix_adapt_exclusive_access_for_electron_needs.patch
|
||||
fix_aspect_ratio_with_max_size.patch
|
||||
fix_dont_delete_SerialPortManager_on_main_thread.patch
|
||||
feat_add_data_transfer_to_requestsingleinstancelock.patch
|
||||
fix_crash_when_saving_edited_pdf_files.patch
|
||||
port_autofill_colors_to_the_color_pipeline.patch
|
||||
build_disable_partition_alloc_on_mac.patch
|
||||
fix_non-client_mouse_tracking_and_message_bubbling_on_windows.patch
|
||||
remove_incorrect_width_height_adjustments.patch
|
||||
introduce_ozoneplatform_electron_can_call_x11_property.patch
|
||||
make_gtk_getlibgtk_public.patch
|
||||
cherry-pick-cf64617c1cc5.patch
|
||||
cherry-pick-e2b8856012e0.patch
|
||||
cherry-pick-6b66a45021a0.patch
|
||||
fix_xkb_keysym_reverse_look_up_for_lacros.patch
|
||||
custom_protocols_plzserviceworker.patch
|
||||
pa_support_16kb_pagesize_on_linux_arm64.patch
|
||||
cherry-pick-f1504440487f.patch
|
||||
cherry-pick-21139756239b.patch
|
||||
cherry-pick-2782c7bc5bbe.patch
|
||||
cherry-pick-f3d01ff794dc.patch
|
||||
cherry-pick-919b1ffe1fe7.patch
|
||||
cherry-pick-f1dd785e021e.patch
|
||||
cherry-pick-b03797bdb1df.patch
|
||||
posix_replace_doubleforkandexec_with_forkandspawn.patch
|
||||
|
||||
@@ -85,10 +85,10 @@ index 14d4a00293ab0b11e733676844ce483992d6cd8e..c6c2dbb9dddd1eaa21e8c7b276d871a3
|
||||
// Visibility -----------------------------------------------------------
|
||||
|
||||
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
index 8cdffac8ecb9ed2c6892f1e975a953846e7e3a5c..7e7927c7258963bd95a2c064ef85e410f4d2571d 100644
|
||||
index b9d5a13bcdf981064f9970fdb8017fed5f93b35e..182f70b2b3bd9cbc6548d4c17caad797e5dad0ce 100644
|
||||
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
@@ -3659,6 +3659,13 @@ PageScheduler* WebViewImpl::Scheduler() const {
|
||||
@@ -3668,6 +3668,13 @@ PageScheduler* WebViewImpl::Scheduler() const {
|
||||
return GetPage()->GetPageScheduler();
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ index 8cdffac8ecb9ed2c6892f1e975a953846e7e3a5c..7e7927c7258963bd95a2c064ef85e410
|
||||
void WebViewImpl::SetVisibilityState(
|
||||
mojom::blink::PageVisibilityState visibility_state,
|
||||
bool is_initial_state) {
|
||||
@@ -3670,7 +3677,8 @@ void WebViewImpl::SetVisibilityState(
|
||||
@@ -3679,7 +3686,8 @@ void WebViewImpl::SetVisibilityState(
|
||||
}
|
||||
GetPage()->SetVisibilityState(visibility_state, is_initial_state);
|
||||
GetPage()->GetPageScheduler()->SetPageVisible(
|
||||
|
||||
@@ -15,7 +15,7 @@ Refs changes in:
|
||||
This patch reverts the changes to fix associated crashes in Electron.
|
||||
|
||||
diff --git a/third_party/blink/renderer/core/frame/frame.cc b/third_party/blink/renderer/core/frame/frame.cc
|
||||
index 2b0c8720866b45c2a83d639533cb4c3e5dbb70e0..97c251cdc310eb22859efb1ba3ca6312a3236fa5 100644
|
||||
index 09e6436422169ac05d5f0561f12984c86dc7af5e..7b2263f4c7fa2dffbaf5b630f4d5a83d9b68f9a5 100644
|
||||
--- a/third_party/blink/renderer/core/frame/frame.cc
|
||||
+++ b/third_party/blink/renderer/core/frame/frame.cc
|
||||
@@ -122,14 +122,6 @@ bool Frame::Detach(FrameDetachType type) {
|
||||
|
||||
@@ -9,7 +9,7 @@ and can be removed when the crash in fork is resolved.
|
||||
Related issue: https://github.com/electron/electron/issues/32718
|
||||
|
||||
diff --git a/base/allocator/allocator.gni b/base/allocator/allocator.gni
|
||||
index 56acfed89ec4ad4ee568a1b517923efa4b4e9c1f..a1da35a84f896d158ac88368ff6d95025a23ff95 100644
|
||||
index 8fa0c36007a0ae0e4553709d27a8231efb08459b..3c4f93fc98b5002572adc78cb9a21b3e78c9f3e0 100644
|
||||
--- a/base/allocator/allocator.gni
|
||||
+++ b/base/allocator/allocator.gni
|
||||
@@ -20,7 +20,7 @@ _disable_partition_alloc = is_component_build || (is_win && is_debug)
|
||||
|
||||
@@ -11,7 +11,7 @@ if we ever align our .pak file generation with Chrome we can remove this
|
||||
patch.
|
||||
|
||||
diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn
|
||||
index 7caaf66cad9d5b9f787cea0d49c32c26801571c2..f45691888b74643189b956928fdc796bfc5bcee3 100644
|
||||
index f2c4feac76e96575de3627b7e8f2373b4fb30411..f5fa6b21594c97a08d1aefd790a4846d9b3e1a45 100644
|
||||
--- a/chrome/BUILD.gn
|
||||
+++ b/chrome/BUILD.gn
|
||||
@@ -171,11 +171,16 @@ if (!is_android && !is_mac) {
|
||||
@@ -33,10 +33,10 @@ index 7caaf66cad9d5b9f787cea0d49c32c26801571c2..f45691888b74643189b956928fdc796b
|
||||
"//base",
|
||||
"//build:branding_buildflags",
|
||||
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
|
||||
index 6a40a73520a951d7c6fd06cbd07329a40ff41544..9ca837d995160d57c7efb51c54cf27283b11b20e 100644
|
||||
index 492cd8e11e28e0b427aca227665295a3052af765..760d2171c5083820fbbf66ce5d7d3c80930b9e88 100644
|
||||
--- a/chrome/browser/BUILD.gn
|
||||
+++ b/chrome/browser/BUILD.gn
|
||||
@@ -4502,7 +4502,7 @@ static_library("browser") {
|
||||
@@ -4501,7 +4501,7 @@ static_library("browser") {
|
||||
|
||||
# On Windows, the hashes are embedded in //chrome:chrome_initial rather
|
||||
# than here in :chrome_dll.
|
||||
@@ -46,10 +46,10 @@ index 6a40a73520a951d7c6fd06cbd07329a40ff41544..9ca837d995160d57c7efb51c54cf2728
|
||||
sources += [ "certificate_viewer_stub.cc" ]
|
||||
}
|
||||
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
|
||||
index 7be0809cfd3a08a87b29256241bc11a33abd3d17..e3c85fd9f550da204e36091bad256b1c2400ade8 100644
|
||||
index 028d269850e66db444591cda7005a0f8434193e9..cc0d14cd9798c6bbee80581c95eb8281ce7fb6ba 100644
|
||||
--- a/chrome/test/BUILD.gn
|
||||
+++ b/chrome/test/BUILD.gn
|
||||
@@ -5719,7 +5719,6 @@ test("unit_tests") {
|
||||
@@ -5722,7 +5722,6 @@ test("unit_tests") {
|
||||
|
||||
deps += [
|
||||
"//chrome:other_version",
|
||||
@@ -57,7 +57,7 @@ index 7be0809cfd3a08a87b29256241bc11a33abd3d17..e3c85fd9f550da204e36091bad256b1c
|
||||
"//chrome//services/util_win:unit_tests",
|
||||
"//chrome/app:chrome_dll_resources",
|
||||
"//chrome/browser:chrome_process_finder",
|
||||
@@ -5742,6 +5741,10 @@ test("unit_tests") {
|
||||
@@ -5745,6 +5744,10 @@ test("unit_tests") {
|
||||
"//ui/resources",
|
||||
]
|
||||
|
||||
@@ -68,7 +68,7 @@ index 7be0809cfd3a08a87b29256241bc11a33abd3d17..e3c85fd9f550da204e36091bad256b1c
|
||||
ldflags = [
|
||||
"/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll",
|
||||
"/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll",
|
||||
@@ -6428,7 +6431,6 @@ test("unit_tests") {
|
||||
@@ -6438,7 +6441,6 @@ test("unit_tests") {
|
||||
}
|
||||
|
||||
deps += [
|
||||
@@ -76,7 +76,7 @@ index 7be0809cfd3a08a87b29256241bc11a33abd3d17..e3c85fd9f550da204e36091bad256b1c
|
||||
"//chrome/browser:cart_db_content_proto",
|
||||
"//chrome/browser:coupon_db_content_proto",
|
||||
"//chrome/browser/media/router:test_support",
|
||||
@@ -6473,6 +6475,11 @@ test("unit_tests") {
|
||||
@@ -6483,6 +6485,11 @@ test("unit_tests") {
|
||||
"//ui/native_theme:test_support",
|
||||
"//ui/webui/resources/js/browser_command:mojo_bindings",
|
||||
]
|
||||
|
||||
@@ -32,7 +32,7 @@ index 7915346430db72d18474d7a011b8dc7637c3f281..cd736d988f9c5e37dc24c724268fe115
|
||||
]
|
||||
if (is_linux && !is_chromeos) {
|
||||
diff --git a/buildtools/third_party/libc++abi/BUILD.gn b/buildtools/third_party/libc++abi/BUILD.gn
|
||||
index 1b0bea340d6e8aec153add6f184e382172916f8b..f5a8193e6b72f4cc039b95783be7d254b93911d8 100644
|
||||
index 40f1285f14c0843405e0ee51879b8742285a006d..5be895d3e36df53a5960006a1513f1322400fd23 100644
|
||||
--- a/buildtools/third_party/libc++abi/BUILD.gn
|
||||
+++ b/buildtools/third_party/libc++abi/BUILD.gn
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
@@ -9,10 +9,10 @@ potentially prevent a window from being created.
|
||||
TODO(loc): this patch is currently broken.
|
||||
|
||||
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
index eba372243a31d08c251ad3367d24999277a8289b..713e2883139bca4bb56dcc7e3efcf6d6dfc4a02b 100644
|
||||
index 36a8fa8d3e981707e6688379813560ba94209ab3..e36a19c847912b007a94464321bb83b15bdcdafd 100644
|
||||
--- a/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
@@ -6703,6 +6703,7 @@ void RenderFrameHostImpl::CreateNewWindow(
|
||||
@@ -6706,6 +6706,7 @@ void RenderFrameHostImpl::CreateNewWindow(
|
||||
last_committed_origin_, params->window_container_type,
|
||||
params->target_url, params->referrer.To<Referrer>(),
|
||||
params->frame_name, params->disposition, *params->features,
|
||||
@@ -21,10 +21,10 @@ index eba372243a31d08c251ad3367d24999277a8289b..713e2883139bca4bb56dcc7e3efcf6d6
|
||||
&no_javascript_access);
|
||||
|
||||
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
|
||||
index 3fe9e1e4918ef65194621661c9c7c650089229fa..c8e49eeaca8b31479aa908be9c349ccd625e9e51 100644
|
||||
index 2b2d267bcaac7eaaf63055d2108e03835f94ea3d..b406cd71133062618258a7d56e69b5e258687e12 100644
|
||||
--- a/content/browser/web_contents/web_contents_impl.cc
|
||||
+++ b/content/browser/web_contents/web_contents_impl.cc
|
||||
@@ -3925,6 +3925,14 @@ FrameTree* WebContentsImpl::CreateNewWindow(
|
||||
@@ -3934,6 +3934,14 @@ FrameTree* WebContentsImpl::CreateNewWindow(
|
||||
}
|
||||
auto* new_contents_impl = new_contents.get();
|
||||
|
||||
@@ -39,7 +39,7 @@ index 3fe9e1e4918ef65194621661c9c7c650089229fa..c8e49eeaca8b31479aa908be9c349ccd
|
||||
new_contents_impl->GetController().SetSessionStorageNamespace(
|
||||
partition_config, session_storage_namespace);
|
||||
|
||||
@@ -3967,12 +3975,6 @@ FrameTree* WebContentsImpl::CreateNewWindow(
|
||||
@@ -3976,12 +3984,6 @@ FrameTree* WebContentsImpl::CreateNewWindow(
|
||||
AddWebContentsDestructionObserver(new_contents_impl);
|
||||
}
|
||||
|
||||
@@ -68,10 +68,10 @@ index ace032dc2ffac27fbdddee5a4b13c3c3e36ba5ae..80f7dd56fdaa94a9880995b2b5393af0
|
||||
|
||||
// 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 85ed8b5e84813c10f97c5785d906a87455f8f67e..a11d5ba888c1489870875c859ec9eb79c67f94b7 100644
|
||||
index a0a9f51b7e62b13f62467f14e3e9245cb6fc8d84..329cbc6f8c822c6f6deac4f341baec41228dca7b 100644
|
||||
--- a/content/public/browser/content_browser_client.cc
|
||||
+++ b/content/public/browser/content_browser_client.cc
|
||||
@@ -571,6 +571,8 @@ bool ContentBrowserClient::CanCreateWindow(
|
||||
@@ -577,6 +577,8 @@ bool ContentBrowserClient::CanCreateWindow(
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
@@ -81,10 +81,10 @@ index 85ed8b5e84813c10f97c5785d906a87455f8f67e..a11d5ba888c1489870875c859ec9eb79
|
||||
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 47527cb2e434f771f5aeb5099432ae86a0ad06ea..2fe1462a2cd92a731a5816b5fc22b059bad92fe8 100644
|
||||
index 3bbb6a39eeb719b94d0e212ea8da5051ff55d441..ceb2bb900e122840505aa8d3911923cffc9a907e 100644
|
||||
--- a/content/public/browser/content_browser_client.h
|
||||
+++ b/content/public/browser/content_browser_client.h
|
||||
@@ -168,6 +168,7 @@ class NetworkService;
|
||||
@@ -169,6 +169,7 @@ class NetworkService;
|
||||
class TrustedURLLoaderHeaderClient;
|
||||
} // namespace mojom
|
||||
struct ResourceRequest;
|
||||
@@ -92,7 +92,7 @@ index 47527cb2e434f771f5aeb5099432ae86a0ad06ea..2fe1462a2cd92a731a5816b5fc22b059
|
||||
} // namespace network
|
||||
|
||||
namespace sandbox {
|
||||
@@ -950,6 +951,8 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
@@ -960,6 +961,8 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
const std::string& frame_name,
|
||||
WindowOpenDisposition disposition,
|
||||
const blink::mojom::WindowFeatures& features,
|
||||
@@ -220,10 +220,10 @@ index 84d32491a56528a84b4395fba1d54cdbb38d522b..09998a83c449ef8cd9f360fbcdcf7edc
|
||||
|
||||
} // namespace blink
|
||||
diff --git a/third_party/blink/renderer/core/frame/local_dom_window.cc b/third_party/blink/renderer/core/frame/local_dom_window.cc
|
||||
index 12658b5c9ca6bc10cffd2c9e8ddf45bac697e75c..284f3ed1513009092ecdf2be6ff87641cc404cd9 100644
|
||||
index 030cc373443766b6485a888f5627885f535e06fc..7bc60b17a0f1aeb208f6d7d85cd6fa537c44c54a 100644
|
||||
--- a/third_party/blink/renderer/core/frame/local_dom_window.cc
|
||||
+++ b/third_party/blink/renderer/core/frame/local_dom_window.cc
|
||||
@@ -2051,6 +2051,7 @@ DOMWindow* LocalDOMWindow::open(v8::Isolate* isolate,
|
||||
@@ -2050,6 +2050,7 @@ DOMWindow* LocalDOMWindow::open(v8::Isolate* isolate,
|
||||
|
||||
WebWindowFeatures window_features =
|
||||
GetWindowFeaturesFromString(features, incumbent_window);
|
||||
|
||||
114
patches/chromium/cherry-pick-21139756239b.patch
Normal file
114
patches/chromium/cherry-pick-21139756239b.patch
Normal file
@@ -0,0 +1,114 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Ari Chivukula <arichiv@chromium.org>
|
||||
Date: Tue, 17 May 2022 18:17:07 +0000
|
||||
Subject: {M102 PICK} [IndexedDB] Use-After-Free Fix
|
||||
|
||||
We can't guarantee order in the task the constructor dispatches the same
|
||||
way we could before due to all the async changes. Let's be sure all the
|
||||
objects exist before using them now. Long term, we need to address
|
||||
ownership of the idb context.
|
||||
|
||||
Bug: 1324864, 1218100
|
||||
Change-Id: Id5753297a4c966432028a1e7e063c5f1bed6f619
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3646994
|
||||
Reviewed-by: Ayu Ishii <ayui@chromium.org>
|
||||
Commit-Queue: Srinivas Sista <srinivassista@chromium.org>
|
||||
Cr-Commit-Position: refs/branch-heads/5005@{#812}
|
||||
Cr-Branched-From: 5b4d9450fee01f821b6400e947b3839727643a71-refs/heads/main@{#992738}
|
||||
|
||||
diff --git a/content/browser/indexed_db/indexed_db_context_impl.cc b/content/browser/indexed_db/indexed_db_context_impl.cc
|
||||
index 9472e762729312bf68073c95056ce09e324148da..219904d80798f71f0be23ee9ffeb5c58d030fb55 100644
|
||||
--- a/content/browser/indexed_db/indexed_db_context_impl.cc
|
||||
+++ b/content/browser/indexed_db/indexed_db_context_impl.cc
|
||||
@@ -167,38 +167,32 @@ IndexedDBContextImpl::IndexedDBContextImpl(
|
||||
std::move(quota_client_remote),
|
||||
storage::QuotaClientType::kIndexedDatabase,
|
||||
{blink::mojom::StorageType::kTemporary});
|
||||
+ IDBTaskRunner()->PostTask(
|
||||
+ FROM_HERE, base::BindOnce(&IndexedDBContextImpl::BindPipesOnIDBSequence,
|
||||
+ weak_factory_.GetWeakPtr(),
|
||||
+ std::move(quota_client_receiver),
|
||||
+ std::move(blob_storage_context),
|
||||
+ std::move(file_system_access_context)));
|
||||
+}
|
||||
|
||||
- // This is safe because the IndexedDBContextImpl must be destructed on the
|
||||
- // IDBTaskRunner, and this task will always happen before that.
|
||||
- idb_task_runner_->PostTask(
|
||||
- FROM_HERE,
|
||||
- base::BindOnce(
|
||||
- [](mojo::Remote<storage::mojom::BlobStorageContext>*
|
||||
- blob_storage_context,
|
||||
- mojo::Remote<storage::mojom::FileSystemAccessContext>*
|
||||
- file_system_access_context,
|
||||
- mojo::Receiver<storage::mojom::QuotaClient>* quota_client_receiver,
|
||||
- mojo::PendingRemote<storage::mojom::BlobStorageContext>
|
||||
- pending_blob_storage_context,
|
||||
- mojo::PendingRemote<storage::mojom::FileSystemAccessContext>
|
||||
- pending_file_system_access_context,
|
||||
- mojo::PendingReceiver<storage::mojom::QuotaClient>
|
||||
- quota_client_pending_receiver) {
|
||||
- quota_client_receiver->Bind(
|
||||
- std::move(quota_client_pending_receiver));
|
||||
- if (pending_blob_storage_context) {
|
||||
- blob_storage_context->Bind(
|
||||
- std::move(pending_blob_storage_context));
|
||||
- }
|
||||
- if (pending_file_system_access_context) {
|
||||
- file_system_access_context->Bind(
|
||||
- std::move(pending_file_system_access_context));
|
||||
- }
|
||||
- },
|
||||
- &blob_storage_context_, &file_system_access_context_,
|
||||
- "a_client_receiver_, std::move(blob_storage_context),
|
||||
- std::move(file_system_access_context),
|
||||
- std::move(quota_client_receiver)));
|
||||
+void IndexedDBContextImpl::BindPipesOnIDBSequence(
|
||||
+ mojo::PendingReceiver<storage::mojom::QuotaClient>
|
||||
+ pending_quota_client_receiver,
|
||||
+ mojo::PendingRemote<storage::mojom::BlobStorageContext>
|
||||
+ pending_blob_storage_context,
|
||||
+ mojo::PendingRemote<storage::mojom::FileSystemAccessContext>
|
||||
+ pending_file_system_access_context) {
|
||||
+ DCHECK(IDBTaskRunner()->RunsTasksInCurrentSequence());
|
||||
+ if (pending_quota_client_receiver) {
|
||||
+ quota_client_receiver_.Bind(std::move(pending_quota_client_receiver));
|
||||
+ }
|
||||
+ if (pending_blob_storage_context) {
|
||||
+ blob_storage_context_.Bind(std::move(pending_blob_storage_context));
|
||||
+ }
|
||||
+ if (pending_file_system_access_context) {
|
||||
+ file_system_access_context_.Bind(
|
||||
+ std::move(pending_file_system_access_context));
|
||||
+ }
|
||||
}
|
||||
|
||||
void IndexedDBContextImpl::Bind(
|
||||
diff --git a/content/browser/indexed_db/indexed_db_context_impl.h b/content/browser/indexed_db/indexed_db_context_impl.h
|
||||
index 4b874b244778d831e0fa8ca3bbfd7e751897923e..ad2f984e130ece867c0f0dc7ca9ae52b8ec12ae9 100644
|
||||
--- a/content/browser/indexed_db/indexed_db_context_impl.h
|
||||
+++ b/content/browser/indexed_db/indexed_db_context_impl.h
|
||||
@@ -224,6 +224,14 @@ class CONTENT_EXPORT IndexedDBContextImpl
|
||||
|
||||
~IndexedDBContextImpl() override;
|
||||
|
||||
+ void BindPipesOnIDBSequence(
|
||||
+ mojo::PendingReceiver<storage::mojom::QuotaClient>
|
||||
+ pending_quota_client_receiver,
|
||||
+ mojo::PendingRemote<storage::mojom::BlobStorageContext>
|
||||
+ pending_blob_storage_context,
|
||||
+ mojo::PendingRemote<storage::mojom::FileSystemAccessContext>
|
||||
+ pending_file_system_access_context);
|
||||
+
|
||||
// Binds receiver on bucket retrieval to ensure that a bucket always exists
|
||||
// for a storage key.
|
||||
void BindIndexedDBWithBucket(
|
||||
@@ -282,6 +290,8 @@ class CONTENT_EXPORT IndexedDBContextImpl
|
||||
mojo::Receiver<storage::mojom::QuotaClient> quota_client_receiver_;
|
||||
const std::unique_ptr<storage::FilesystemProxy> filesystem_proxy_;
|
||||
|
||||
+ // weak_factory_->GetWeakPtr() may be used on any thread, but the resulting
|
||||
+ // pointer must only be checked/used on idb_task_runner_.
|
||||
base::WeakPtrFactory<IndexedDBContextImpl> weak_factory_{this};
|
||||
};
|
||||
|
||||
139
patches/chromium/cherry-pick-2782c7bc5bbe.patch
Normal file
139
patches/chromium/cherry-pick-2782c7bc5bbe.patch
Normal file
@@ -0,0 +1,139 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Marijn Kruisselbrink <mek@chromium.org>
|
||||
Date: Wed, 27 Apr 2022 20:51:50 +0000
|
||||
Subject: Reland "Close a MessagePort if it is created in a destroyed context."
|
||||
|
||||
This is a reland of commit 068f13cc5aa5f7a6e9faf28d8731275e64cb657b
|
||||
|
||||
This reland changes the timeout in the test from 3 to 2 seconds, because
|
||||
two 3 second timeouts is too long for chrome's default overall test
|
||||
timeout of 6 seconds on non-dcheck release builds.
|
||||
|
||||
Original change's description:
|
||||
> Close a MessagePort if it is created in a destroyed context.
|
||||
>
|
||||
> MessagePort assumes it is only destroyed either after ContextDestroyed,
|
||||
> or after the port has been closed explicitly. As it turns out ports that
|
||||
> were created in an already detached iframe would violate this invariant,
|
||||
> causing issues.
|
||||
>
|
||||
> Bug: 1228661
|
||||
> Change-Id: Ib1abce15f1d1d15f044de19fe0534767db488af0
|
||||
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3561845
|
||||
> Reviewed-by: Jeremy Roman <jbroman@chromium.org>
|
||||
> Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
|
||||
> Cr-Commit-Position: refs/heads/main@{#988859}
|
||||
|
||||
Bug: 1228661
|
||||
Change-Id: Ifc5ec866678667b0d81438e2a2c8e5ada6e19d8c
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3609249
|
||||
Commit-Queue: Jeremy Roman <jbroman@chromium.org>
|
||||
Reviewed-by: Jeremy Roman <jbroman@chromium.org>
|
||||
Auto-Submit: Marijn Kruisselbrink <mek@chromium.org>
|
||||
Cr-Commit-Position: refs/heads/main@{#996880}
|
||||
|
||||
diff --git a/third_party/blink/renderer/core/messaging/message_port.cc b/third_party/blink/renderer/core/messaging/message_port.cc
|
||||
index 6f67b21803fcdc2498ef207878d1541e04822fca..7f3df8ea567f91cd063122aab63a5c5424ab7919 100644
|
||||
--- a/third_party/blink/renderer/core/messaging/message_port.cc
|
||||
+++ b/third_party/blink/renderer/core/messaging/message_port.cc
|
||||
@@ -55,7 +55,11 @@
|
||||
namespace blink {
|
||||
|
||||
MessagePort::MessagePort(ExecutionContext& execution_context)
|
||||
- : ExecutionContextLifecycleObserver(&execution_context),
|
||||
+ : ExecutionContextLifecycleObserver(execution_context.IsContextDestroyed()
|
||||
+ ? nullptr
|
||||
+ : &execution_context),
|
||||
+ // Ports in a destroyed context start out in a closed state.
|
||||
+ closed_(execution_context.IsContextDestroyed()),
|
||||
task_runner_(execution_context.GetTaskRunner(TaskType::kPostedMessage)) {}
|
||||
|
||||
MessagePort::~MessagePort() {
|
||||
@@ -168,10 +172,21 @@ void MessagePort::Entangle(MessagePortDescriptor port) {
|
||||
DCHECK(port.IsValid());
|
||||
DCHECK(!connector_);
|
||||
|
||||
+ // If the context was already destroyed, there is no reason to actually
|
||||
+ // entangle the port and create a Connector. No messages will ever be able to
|
||||
+ // be sent or received anyway, as StartReceiving will never be called.
|
||||
+ if (!GetExecutionContext())
|
||||
+ return;
|
||||
+
|
||||
port_ = std::move(port);
|
||||
connector_ = std::make_unique<mojo::Connector>(
|
||||
port_.TakeHandleToEntangle(GetExecutionContext()),
|
||||
mojo::Connector::SINGLE_THREADED_SEND);
|
||||
+ // The raw `this` is safe despite `this` being a garbage collected object
|
||||
+ // because we make sure that:
|
||||
+ // 1. This object will not be garbage collected while it is connected and
|
||||
+ // the execution context is not destroyed, and
|
||||
+ // 2. when the execution context is destroyed, the connector_ is reset.
|
||||
connector_->set_incoming_receiver(this);
|
||||
connector_->set_connection_error_handler(
|
||||
WTF::Bind(&MessagePort::close, WrapWeakPersistent(this)));
|
||||
diff --git a/third_party/blink/renderer/core/messaging/message_port.h b/third_party/blink/renderer/core/messaging/message_port.h
|
||||
index 83d7901d99ad01ba039ea1ffa3dbee2595fc31ff..f9baba3c6d13992508da48a13c97bb10c8ec56e0 100644
|
||||
--- a/third_party/blink/renderer/core/messaging/message_port.h
|
||||
+++ b/third_party/blink/renderer/core/messaging/message_port.h
|
||||
@@ -148,7 +148,7 @@ class CORE_EXPORT MessagePort : public EventTargetWithInlineData,
|
||||
std::unique_ptr<mojo::Connector> connector_;
|
||||
|
||||
bool started_ = false;
|
||||
- bool closed_ = false;
|
||||
+ bool closed_;
|
||||
|
||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
||||
|
||||
diff --git a/third_party/blink/web_tests/external/wpt/webmessaging/message-channels/detached-iframe.window.js b/third_party/blink/web_tests/external/wpt/webmessaging/message-channels/detached-iframe.window.js
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c1effaf141b7246320883e293b58dabbc3572123
|
||||
--- /dev/null
|
||||
+++ b/third_party/blink/web_tests/external/wpt/webmessaging/message-channels/detached-iframe.window.js
|
||||
@@ -0,0 +1,47 @@
|
||||
+// META: title=MessageChannel in a detached iframe test
|
||||
+// META: script=/service-workers/service-worker/resources/test-helpers.sub.js
|
||||
+// Pull in the with_iframe helper function from the service worker tests
|
||||
+
|
||||
+
|
||||
+const IframeAction = {
|
||||
+ REMOVE_BEFORE_CREATION: 'remove-before-creation',
|
||||
+ REMOVE_AFTER_CREATION: 'remove-after-creation',
|
||||
+};
|
||||
+
|
||||
+async function detached_frame_test(t, action) {
|
||||
+ const iframe = await with_iframe('about:blank');
|
||||
+ const iframe_MessageChannel = iframe.contentWindow.MessageChannel;
|
||||
+
|
||||
+ if (action === IframeAction.REMOVE_BEFORE_CREATION) {
|
||||
+ iframe.remove();
|
||||
+ }
|
||||
+
|
||||
+ (() => {
|
||||
+ const mc = new iframe_MessageChannel();
|
||||
+ mc.port1.postMessage("boo");
|
||||
+ mc.port2.onmessage = t.unreached_func("message event received");
|
||||
+ mc.port2.onmessageerror = t.unreached_func("message event received");
|
||||
+ })();
|
||||
+
|
||||
+ if (action === IframeAction.REMOVE_AFTER_CREATION) {
|
||||
+ iframe.remove();
|
||||
+ }
|
||||
+
|
||||
+ // TODO(https://github.com/web-platform-tests/wpt/issues/7899): Change to
|
||||
+ // some sort of cross-browser GC trigger.
|
||||
+ if (self.gc) self.gc();
|
||||
+
|
||||
+ // We are testing that neither of the above two events fire. We assume that a 2 second timeout
|
||||
+ // is good enough. We can't use any other API for an end condition because each MessagePort has
|
||||
+ // its own independent port message queue, which has no ordering guarantees relative to other
|
||||
+ // APIs.
|
||||
+ await new Promise(resolve => t.step_timeout(resolve, 2000));
|
||||
+}
|
||||
+
|
||||
+promise_test(async (t) => {
|
||||
+ return detached_frame_test(t, IframeAction.REMOVE_AFTER_CREATION);
|
||||
+}, 'MessageChannel created from a detached iframe should not send messages (remove after create)');
|
||||
+
|
||||
+promise_test(async (t) => {
|
||||
+ return detached_frame_test(t, IframeAction.REMOVE_BEFORE_CREATION);
|
||||
+}, 'MessageChannel created from a detached iframe should not send messages (remove before create)');
|
||||
259
patches/chromium/cherry-pick-6b66a45021a0.patch
Normal file
259
patches/chromium/cherry-pick-6b66a45021a0.patch
Normal file
@@ -0,0 +1,259 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Garrett Tanzer <gtanzer@chromium.org>
|
||||
Date: Wed, 2 Mar 2022 18:33:42 +0000
|
||||
Subject: Reland "Fix noopener case for user activation consumption"
|
||||
|
||||
This is a reland of e9828a82b5c182dc9a7fb0ae7226c35ba1726e7d
|
||||
|
||||
The MSAN error is from checking status before err in
|
||||
content/renderer/render_view_impl.cc .
|
||||
https://ci.chromium.org/ui/p/chromium/builders/ci/Linux%20ChromiumOS%20MSan%20Tests/b8821495655905086193/overview
|
||||
|
||||
The fix is to split the check for err and kIgnore into two checks,
|
||||
and put the err check before kBlocked.
|
||||
|
||||
It is probably possible for the browser to consume user activation
|
||||
but then eventually mojo returns an error and the renderer doesn't
|
||||
consume activation, but that seems pretty marginal.
|
||||
|
||||
Original change's description:
|
||||
> Fix noopener case for user activation consumption
|
||||
>
|
||||
>
|
||||
> The flow for user activation consumption in window.open was as follows:
|
||||
>
|
||||
> Renderer: ask the browser to create a new window
|
||||
> Browser: consume transient user activation (in the browser, and via RPC
|
||||
> to remote frames only)
|
||||
> Browser: return success for opener, return ignore for noopener
|
||||
> Renderer: consume transient user activation upon success
|
||||
>
|
||||
> So in the noopener case, the renderer with the local frame where the
|
||||
> window.open originated didn't have its transient user activation
|
||||
> consumed.
|
||||
>
|
||||
>
|
||||
> The new behavior is to consume user activation in the calling renderer
|
||||
> whenever it is consumed in the browser. We accomplish this by returning
|
||||
> a distinct value kBlocked to represent failure before the browser
|
||||
> consumes user activation.
|
||||
>
|
||||
> Bug: 1264543, 1291210
|
||||
> Change-Id: Iffb6e3fd772bef625d3d28e600e6fb73d70ab29f
|
||||
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3468171
|
||||
> Reviewed-by: Dominic Farolino <dom@chromium.org>
|
||||
> Reviewed-by: Ken Buchanan <kenrb@chromium.org>
|
||||
> Reviewed-by: Mustaq Ahmed <mustaq@chromium.org>
|
||||
> Reviewed-by: Charles Reis <creis@chromium.org>
|
||||
> Reviewed-by: Jonathan Ross <jonross@chromium.org>
|
||||
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
|
||||
> Commit-Queue: Garrett Tanzer <gtanzer@chromium.org>
|
||||
> Cr-Commit-Position: refs/heads/main@{#973876}
|
||||
|
||||
Bug: 1264543, 1291210
|
||||
Change-Id: Ie27c4d68db34dfd98adee7cc5c743953dad59834
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3481666
|
||||
Reviewed-by: Jonathan Ross <jonross@chromium.org>
|
||||
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
|
||||
Reviewed-by: Mustaq Ahmed <mustaq@chromium.org>
|
||||
Reviewed-by: Ken Buchanan <kenrb@chromium.org>
|
||||
Reviewed-by: Charles Reis <creis@chromium.org>
|
||||
Commit-Queue: Garrett Tanzer <gtanzer@chromium.org>
|
||||
Cr-Commit-Position: refs/heads/main@{#976745}
|
||||
|
||||
diff --git a/chrome/browser/site_isolation/chrome_site_per_process_browsertest.cc b/chrome/browser/site_isolation/chrome_site_per_process_browsertest.cc
|
||||
index 4c7d9a3fc2d90b751b8b6dd109f223132eb27fe6..2c6ec16e1700882a0ea30c022e1bb0b5eb3a88f8 100644
|
||||
--- a/chrome/browser/site_isolation/chrome_site_per_process_browsertest.cc
|
||||
+++ b/chrome/browser/site_isolation/chrome_site_per_process_browsertest.cc
|
||||
@@ -1187,6 +1187,52 @@ IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessTest,
|
||||
EXPECT_FALSE(frame_c_popup_opened);
|
||||
}
|
||||
|
||||
+// Test that opening a window with `noopener` consumes user activation.
|
||||
+// crbug.com/1264543, crbug.com/1291210
|
||||
+IN_PROC_BROWSER_TEST_F(ChromeSitePerProcessTest,
|
||||
+ UserActivationConsumptionNoopener) {
|
||||
+ // Start on a page a.com.
|
||||
+ GURL main_url(embedded_test_server()->GetURL(
|
||||
+ "a.com", "/cross_site_iframe_factory.html?a"));
|
||||
+ ASSERT_TRUE(ui_test_utils::NavigateToURL(browser(), main_url));
|
||||
+ content::WebContents* web_contents =
|
||||
+ browser()->tab_strip_model()->GetActiveWebContents();
|
||||
+
|
||||
+ // Activate the frame by executing a dummy script.
|
||||
+ const std::string no_op_script = "// No-op script";
|
||||
+ EXPECT_TRUE(ExecuteScript(web_contents, no_op_script));
|
||||
+
|
||||
+ // Add a popup observer.
|
||||
+ content::TestNavigationObserver popup_observer(nullptr);
|
||||
+ popup_observer.StartWatchingNewWebContents();
|
||||
+
|
||||
+ // Open a popup from the frame, with `noopener`. This should consume
|
||||
+ // transient user activation.
|
||||
+ GURL popup_url(embedded_test_server()->GetURL("popup.com", "/"));
|
||||
+ EXPECT_TRUE(ExecuteScriptWithoutUserGesture(
|
||||
+ web_contents,
|
||||
+ base::StringPrintf(
|
||||
+ "window.w = window.open('%s'+'title1.html', '_blank', 'noopener');",
|
||||
+ popup_url.spec().c_str())));
|
||||
+
|
||||
+ // Try to open another popup.
|
||||
+ EXPECT_TRUE(ExecuteScriptWithoutUserGesture(
|
||||
+ web_contents,
|
||||
+ base::StringPrintf(
|
||||
+ "window.w = window.open('%s'+'title2.html', '_blank', 'noopener');",
|
||||
+ popup_url.spec().c_str())));
|
||||
+
|
||||
+ // Wait and check that only one popup was opened.
|
||||
+ popup_observer.Wait();
|
||||
+ EXPECT_EQ(2, browser()->tab_strip_model()->count());
|
||||
+
|
||||
+ content::WebContents* popup =
|
||||
+ browser()->tab_strip_model()->GetActiveWebContents();
|
||||
+ EXPECT_EQ(embedded_test_server()->GetURL("popup.com", "/title1.html"),
|
||||
+ popup->GetLastCommittedURL());
|
||||
+ EXPECT_NE(popup, web_contents);
|
||||
+}
|
||||
+
|
||||
// TODO(crbug.com/1021895): Flaky.
|
||||
// Tests that a cross-site iframe runs its beforeunload handler when closing a
|
||||
// tab. See https://crbug.com/853021.
|
||||
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
index afd175d35096b0a50ccee3f2b14c632adbfec58a..b346e9adcb73d80c260e4095b140acd319f69e89 100644
|
||||
--- a/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
@@ -6719,17 +6719,22 @@ void RenderFrameHostImpl::CreateNewWindow(
|
||||
effective_transient_activation_state, params->opener_suppressed,
|
||||
&no_javascript_access);
|
||||
|
||||
- bool was_consumed = false;
|
||||
- if (can_create_window) {
|
||||
- // Consume activation even w/o User Activation v2, to sync other renderers
|
||||
- // with calling renderer.
|
||||
- was_consumed = frame_tree_node_->UpdateUserActivationState(
|
||||
- blink::mojom::UserActivationUpdateType::kConsumeTransientActivation,
|
||||
- blink::mojom::UserActivationNotificationType::kNone);
|
||||
- } else {
|
||||
- std::move(callback).Run(mojom::CreateNewWindowStatus::kIgnore, nullptr);
|
||||
- return;
|
||||
- }
|
||||
+ // If this frame isn't allowed to create a window, return early (before we
|
||||
+ // consume transient user activation).
|
||||
+ if (!can_create_window) {
|
||||
+ std::move(callback).Run(mojom::CreateNewWindowStatus::kBlocked, nullptr);
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ // Otherwise, consume user activation before we proceed. In particular, it is
|
||||
+ // important to do this before we return from the |opener_suppressed| case
|
||||
+ // below.
|
||||
+ // NB: This call will consume activations in the browser and the remote frame
|
||||
+ // proxies for this frame. The initiating renderer will consume its view of
|
||||
+ // the activations after we return.
|
||||
+ bool was_consumed = frame_tree_node_->UpdateUserActivationState(
|
||||
+ blink::mojom::UserActivationUpdateType::kConsumeTransientActivation,
|
||||
+ blink::mojom::UserActivationNotificationType::kNone);
|
||||
|
||||
// For Android WebView, we support a pop-up like behavior for window.open()
|
||||
// even if the embedding app doesn't support multiple windows. In this case,
|
||||
diff --git a/content/common/frame.mojom b/content/common/frame.mojom
|
||||
index 80f7dd56fdaa94a9880995b2b5393af0414eef29..f3d13fc719324e064f70077deb5d95cb9e467820 100644
|
||||
--- a/content/common/frame.mojom
|
||||
+++ b/content/common/frame.mojom
|
||||
@@ -558,8 +558,10 @@ struct CreateNewWindowParams {
|
||||
|
||||
// Operation result when the renderer asks the browser to create a new window.
|
||||
enum CreateNewWindowStatus {
|
||||
- // Ignore creation of the new window. This can happen because creation is
|
||||
- // blocked or because the new window should have no opener relationship.
|
||||
+ // Creation of the new window was blocked, e.g. because the source frame
|
||||
+ // doesn't have user activation.
|
||||
+ kBlocked,
|
||||
+ // Ignore creation of the new window, e.g. because noopener is in effect.
|
||||
kIgnore,
|
||||
// Reuse the current window rather than creating a new window.
|
||||
kReuse,
|
||||
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
|
||||
index aa65517a568aa0b324b2c8cca8f60bb532ba085a..11815bca2741002dd8595af026ef402bc2af999e 100644
|
||||
--- a/content/renderer/render_view_impl.cc
|
||||
+++ b/content/renderer/render_view_impl.cc
|
||||
@@ -311,8 +311,27 @@ WebView* RenderViewImpl::CreateView(
|
||||
mojom::CreateNewWindowStatus status;
|
||||
mojom::CreateNewWindowReplyPtr reply;
|
||||
auto* frame_host = creator_frame->GetFrameHost();
|
||||
- bool err = !frame_host->CreateNewWindow(std::move(params), &status, &reply);
|
||||
- if (err || status == mojom::CreateNewWindowStatus::kIgnore)
|
||||
+ if (!frame_host->CreateNewWindow(std::move(params), &status, &reply)) {
|
||||
+ // The sync IPC failed, e.g. maybe the render process is in the middle of
|
||||
+ // shutting down. Can't create a new window without the browser process,
|
||||
+ // so just bail out.
|
||||
+ return nullptr;
|
||||
+ }
|
||||
+
|
||||
+ // If creation of the window was blocked (e.g. because this frame doesn't
|
||||
+ // have user activation), return before consuming user activation. A frame
|
||||
+ // that isn't allowed to open a window shouldn't be able to consume the
|
||||
+ // activation for the rest of the frame tree.
|
||||
+ if (status == mojom::CreateNewWindowStatus::kBlocked)
|
||||
+ return nullptr;
|
||||
+
|
||||
+ // Consume the transient user activation in the current renderer.
|
||||
+ consumed_user_gesture = creator->ConsumeTransientUserActivation(
|
||||
+ blink::UserActivationUpdateSource::kBrowser);
|
||||
+
|
||||
+ // If we should ignore the new window (e.g. because of `noopener`), return
|
||||
+ // now that user activation was consumed.
|
||||
+ if (status == mojom::CreateNewWindowStatus::kIgnore)
|
||||
return nullptr;
|
||||
|
||||
// For Android WebView, we support a pop-up like behavior for window.open()
|
||||
@@ -332,11 +351,6 @@ WebView* RenderViewImpl::CreateView(
|
||||
DCHECK_NE(MSG_ROUTING_NONE, reply->main_frame_route_id);
|
||||
DCHECK_NE(MSG_ROUTING_NONE, reply->widget_params->routing_id);
|
||||
|
||||
- // The browser allowed creation of a new window and consumed the user
|
||||
- // activation.
|
||||
- consumed_user_gesture = creator->ConsumeTransientUserActivation(
|
||||
- blink::UserActivationUpdateSource::kBrowser);
|
||||
-
|
||||
// While this view may be a background extension page, it can spawn a visible
|
||||
// render view. So we just assume that the new one is not another background
|
||||
// page instead of passing on our own value.
|
||||
diff --git a/third_party/blink/web_tests/wpt_internal/fenced_frame/consume-user-activation.https.html b/third_party/blink/web_tests/wpt_internal/fenced_frame/consume-user-activation.https.html
|
||||
index d78d08e18a803f66d5136b193abfa26fd7ab087a..e4ad20d17b7fdcec69f25e652dab967f9b52cf65 100644
|
||||
--- a/third_party/blink/web_tests/wpt_internal/fenced_frame/consume-user-activation.https.html
|
||||
+++ b/third_party/blink/web_tests/wpt_internal/fenced_frame/consume-user-activation.https.html
|
||||
@@ -88,11 +88,7 @@ promise_test(async () => {
|
||||
|
||||
// Check that B's transient user activation was consumed.
|
||||
assert_activations(true, true, "A");
|
||||
- // TODO(crbug.com/1291210): B should be inactive after consuming the
|
||||
- // transient user activation, but due to a preexisting bug it isn't.
|
||||
- // Replace with this once fixed:
|
||||
- // await B.execute(assert_activations, [true, false, "B"]);
|
||||
- await B.execute(assert_activations, [true, true, "B"]);
|
||||
+ await B.execute(assert_activations, [true, false, "B"]);
|
||||
|
||||
}, 'user-activation');
|
||||
</script>
|
||||
diff --git a/third_party/blink/web_tests/wpt_internal/fenced_frame/restrict-size.https.html b/third_party/blink/web_tests/wpt_internal/fenced_frame/restrict-size.https.html
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..5668407d7e1e6ac7840fc47b76869787cb3f3d63
|
||||
--- /dev/null
|
||||
+++ b/third_party/blink/web_tests/wpt_internal/fenced_frame/restrict-size.https.html
|
||||
@@ -0,0 +1,15 @@
|
||||
+<!DOCTYPE html>
|
||||
+<title>Test fencedframe size restrictions in opaque ads mode.</title>
|
||||
+<script src="/resources/testharness.js"></script>
|
||||
+<script src="/resources/testharnessreport.js"></script>
|
||||
+<script src="/common/utils.js"></script>
|
||||
+<script src="/common/dispatcher/dispatcher.js"></script>
|
||||
+<script src="resources/utils.js"></script>
|
||||
+
|
||||
+<body>
|
||||
+<script>
|
||||
+promise_test(async () => {
|
||||
+ const frame = attachFencedFrameContext();
|
||||
+}, 'restrict fencedframe size');
|
||||
+</script>
|
||||
+</body>
|
||||
393
patches/chromium/cherry-pick-919b1ffe1fe7.patch
Normal file
393
patches/chromium/cherry-pick-919b1ffe1fe7.patch
Normal file
@@ -0,0 +1,393 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alex Rudenko <alexrudenko@chromium.org>
|
||||
Date: Tue, 26 Apr 2022 05:53:56 +0000
|
||||
Subject: DevTools: store weak references to nodes in inspect_tools
|
||||
MIME-Version: 1.0
|
||||
Content-Type: text/plain; charset=UTF-8
|
||||
Content-Transfer-Encoding: 8bit
|
||||
|
||||
This CL changes how the configuration for persistent overlays is stored.
|
||||
Instead of trying to save a strong reference to a DOM node, we can
|
||||
store weak references instead. This requires using a HeapHashMap as
|
||||
vectors don't support weak reference elements.
|
||||
|
||||
(cherry picked from commit 2e0a0b83e1340e948a27cdc319bea8f32849d414)
|
||||
|
||||
Fixed: 1314310
|
||||
Change-Id: I27ce12730d7598bc84d01adf421923af9a53dc67
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3593092
|
||||
Reviewed-by: Danil Somsikov <dsv@chromium.org>
|
||||
Reviewed-by: Changhao Han <changhaohan@chromium.org>
|
||||
Reviewed-by: Andrey Kosyakov <caseq@chromium.org>
|
||||
Commit-Queue: Alex Rudenko <alexrudenko@chromium.org>
|
||||
Cr-Original-Commit-Position: refs/heads/main@{#994866}
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3604262
|
||||
Auto-Submit: Alex Rudenko <alexrudenko@chromium.org>
|
||||
Reviewed-by: Simon Zünd <szuend@chromium.org>
|
||||
Commit-Queue: Simon Zünd <szuend@chromium.org>
|
||||
Cr-Commit-Position: refs/branch-heads/5005@{#163}
|
||||
Cr-Branched-From: 5b4d9450fee01f821b6400e947b3839727643a71-refs/heads/main@{#992738}
|
||||
|
||||
diff --git a/third_party/blink/renderer/core/inspector/inspect_tools.cc b/third_party/blink/renderer/core/inspector/inspect_tools.cc
|
||||
index b3c08bd77e792481ee7ce5754e48a0d429ef0595..6a43cc041e1adefcfca56dac86eb138c0b118127 100644
|
||||
--- a/third_party/blink/renderer/core/inspector/inspect_tools.cc
|
||||
+++ b/third_party/blink/renderer/core/inspector/inspect_tools.cc
|
||||
@@ -477,14 +477,14 @@ bool PersistentTool::HideOnMouseMove() {
|
||||
void PersistentTool::Draw(float scale) {
|
||||
for (auto& entry : grid_node_highlights_) {
|
||||
std::unique_ptr<protocol::Value> highlight =
|
||||
- InspectorGridHighlight(entry.first.Get(), *(entry.second));
|
||||
+ InspectorGridHighlight(entry.key, *(entry.value));
|
||||
if (!highlight)
|
||||
continue;
|
||||
overlay_->EvaluateInOverlay("drawGridHighlight", std::move(highlight));
|
||||
}
|
||||
for (auto& entry : flex_container_configs_) {
|
||||
std::unique_ptr<protocol::Value> highlight =
|
||||
- InspectorFlexContainerHighlight(entry.first.Get(), *(entry.second));
|
||||
+ InspectorFlexContainerHighlight(entry.key, *(entry.value));
|
||||
if (!highlight)
|
||||
continue;
|
||||
overlay_->EvaluateInOverlay("drawFlexContainerHighlight",
|
||||
@@ -492,7 +492,7 @@ void PersistentTool::Draw(float scale) {
|
||||
}
|
||||
for (auto& entry : scroll_snap_configs_) {
|
||||
std::unique_ptr<protocol::Value> highlight =
|
||||
- InspectorScrollSnapHighlight(entry.first.Get(), *(entry.second));
|
||||
+ InspectorScrollSnapHighlight(entry.key, *(entry.value));
|
||||
if (!highlight)
|
||||
continue;
|
||||
overlay_->EvaluateInOverlay("drawScrollSnapHighlight",
|
||||
@@ -500,17 +500,15 @@ void PersistentTool::Draw(float scale) {
|
||||
}
|
||||
for (auto& entry : container_query_configs_) {
|
||||
std::unique_ptr<protocol::Value> highlight =
|
||||
- InspectorContainerQueryHighlight(entry.first.Get(), *(entry.second));
|
||||
+ InspectorContainerQueryHighlight(entry.key, *(entry.value));
|
||||
if (!highlight)
|
||||
continue;
|
||||
overlay_->EvaluateInOverlay("drawContainerQueryHighlight",
|
||||
std::move(highlight));
|
||||
}
|
||||
- for (wtf_size_t i = 0; i < isolated_element_configs_.size(); ++i) {
|
||||
- auto& entry = isolated_element_configs_.at(i);
|
||||
+ for (auto& entry : isolated_element_configs_) {
|
||||
std::unique_ptr<protocol::Value> highlight =
|
||||
- InspectorIsolatedElementHighlight(entry.first.Get(), *(entry.second),
|
||||
- i);
|
||||
+ InspectorIsolatedElementHighlight(entry.key, *(entry.value));
|
||||
if (!highlight)
|
||||
continue;
|
||||
overlay_->EvaluateInOverlay("drawIsolatedElementHighlight",
|
||||
@@ -548,9 +546,11 @@ void PersistentTool::Dispatch(const ScriptValue& message,
|
||||
|
||||
Element* element = nullptr;
|
||||
if (highlight_type == "isolatedElement") {
|
||||
- if (index < static_cast<int>(isolated_element_configs_.size()) &&
|
||||
- index >= 0) {
|
||||
- element = isolated_element_configs_.at(index).first.Get();
|
||||
+ for (auto& entry : isolated_element_configs_) {
|
||||
+ if (entry.value->highlight_index == index) {
|
||||
+ element = entry.key;
|
||||
+ break;
|
||||
+ }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ PersistentTool::GetGridInspectorHighlightsAsJson() const {
|
||||
protocol::ListValue::create();
|
||||
for (auto& entry : grid_node_highlights_) {
|
||||
std::unique_ptr<protocol::Value> highlight =
|
||||
- InspectorGridHighlight(entry.first.Get(), *(entry.second));
|
||||
+ InspectorGridHighlight(entry.key, *(entry.value));
|
||||
if (!highlight)
|
||||
continue;
|
||||
highlights->pushValue(std::move(highlight));
|
||||
@@ -584,6 +584,15 @@ PersistentTool::GetGridInspectorHighlightsAsJson() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
+void PersistentTool::Trace(Visitor* visitor) const {
|
||||
+ InspectTool::Trace(visitor);
|
||||
+ visitor->Trace(grid_node_highlights_);
|
||||
+ visitor->Trace(flex_container_configs_);
|
||||
+ visitor->Trace(scroll_snap_configs_);
|
||||
+ visitor->Trace(container_query_configs_);
|
||||
+ visitor->Trace(isolated_element_configs_);
|
||||
+}
|
||||
+
|
||||
// SourceOrderTool -----------------------------------------------------------
|
||||
|
||||
SourceOrderTool::SourceOrderTool(
|
||||
diff --git a/third_party/blink/renderer/core/inspector/inspect_tools.h b/third_party/blink/renderer/core/inspector/inspect_tools.h
|
||||
index dd55eacf154da0895e04b6113d28e52085dcff6d..92abdca382bd8edd95714be6194eddc84bee7e06 100644
|
||||
--- a/third_party/blink/renderer/core/inspector/inspect_tools.h
|
||||
+++ b/third_party/blink/renderer/core/inspector/inspect_tools.h
|
||||
@@ -145,23 +145,20 @@ class SourceOrderTool : public InspectTool {
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
-
|
||||
-using GridConfigs = Vector<
|
||||
- std::pair<Member<Node>, std::unique_ptr<InspectorGridHighlightConfig>>>;
|
||||
+using GridConfigs = HeapHashMap<WeakMember<Node>,
|
||||
+ std::unique_ptr<InspectorGridHighlightConfig>>;
|
||||
using FlexContainerConfigs =
|
||||
- Vector<std::pair<Member<Node>,
|
||||
- std::unique_ptr<InspectorFlexContainerHighlightConfig>>>;
|
||||
-using ScrollSnapConfigs = Vector<
|
||||
- std::pair<Member<Node>,
|
||||
- std::unique_ptr<InspectorScrollSnapContainerHighlightConfig>>>;
|
||||
-
|
||||
-using ContainerQueryConfigs = Vector<std::pair<
|
||||
- Member<Node>,
|
||||
- std::unique_ptr<InspectorContainerQueryContainerHighlightConfig>>>;
|
||||
-
|
||||
+ HeapHashMap<WeakMember<Node>,
|
||||
+ std::unique_ptr<InspectorFlexContainerHighlightConfig>>;
|
||||
+using ScrollSnapConfigs =
|
||||
+ HeapHashMap<WeakMember<Node>,
|
||||
+ std::unique_ptr<InspectorScrollSnapContainerHighlightConfig>>;
|
||||
+using ContainerQueryConfigs = HeapHashMap<
|
||||
+ WeakMember<Node>,
|
||||
+ std::unique_ptr<InspectorContainerQueryContainerHighlightConfig>>;
|
||||
using IsolatedElementConfigs =
|
||||
- Vector<std::pair<Member<Element>,
|
||||
- std::unique_ptr<InspectorIsolationModeHighlightConfig>>>;
|
||||
+ HeapHashMap<WeakMember<Element>,
|
||||
+ std::unique_ptr<InspectorIsolationModeHighlightConfig>>;
|
||||
|
||||
class PersistentTool : public InspectTool {
|
||||
using InspectTool::InspectTool;
|
||||
@@ -181,6 +178,8 @@ class PersistentTool : public InspectTool {
|
||||
std::unique_ptr<protocol::DictionaryValue> GetGridInspectorHighlightsAsJson()
|
||||
const;
|
||||
|
||||
+ void Trace(Visitor* visitor) const override;
|
||||
+
|
||||
private:
|
||||
bool ForwardEventsToOverlay() override;
|
||||
bool HideOnMouseMove() override;
|
||||
diff --git a/third_party/blink/renderer/core/inspector/inspector_highlight.cc b/third_party/blink/renderer/core/inspector/inspector_highlight.cc
|
||||
index 3ad3081f4f6143c1b38fa1ffc5892eb810344d93..1abb20541977adcece43f7e61db8d34f5170e6c6 100644
|
||||
--- a/third_party/blink/renderer/core/inspector/inspector_highlight.cc
|
||||
+++ b/third_party/blink/renderer/core/inspector/inspector_highlight.cc
|
||||
@@ -2415,8 +2415,7 @@ std::unique_ptr<protocol::DictionaryValue> InspectorContainerQueryHighlight(
|
||||
|
||||
std::unique_ptr<protocol::DictionaryValue> InspectorIsolatedElementHighlight(
|
||||
Element* element,
|
||||
- const InspectorIsolationModeHighlightConfig& config,
|
||||
- int highlight_index) {
|
||||
+ const InspectorIsolationModeHighlightConfig& config) {
|
||||
LocalFrameView* frame_view = element->GetDocument().View();
|
||||
if (!frame_view)
|
||||
return nullptr;
|
||||
@@ -2428,7 +2427,7 @@ std::unique_ptr<protocol::DictionaryValue> InspectorIsolatedElementHighlight(
|
||||
if (!isolated_element_info)
|
||||
return nullptr;
|
||||
|
||||
- isolated_element_info->setInteger("highlightIndex", highlight_index);
|
||||
+ isolated_element_info->setInteger("highlightIndex", config.highlight_index);
|
||||
return isolated_element_info;
|
||||
}
|
||||
|
||||
diff --git a/third_party/blink/renderer/core/inspector/inspector_highlight.h b/third_party/blink/renderer/core/inspector/inspector_highlight.h
|
||||
index ba4e3f9487b05140aef0068bbafc209a2047235b..4c6423063a4f3ee4ace988fd4e45b41592308c03 100644
|
||||
--- a/third_party/blink/renderer/core/inspector/inspector_highlight.h
|
||||
+++ b/third_party/blink/renderer/core/inspector/inspector_highlight.h
|
||||
@@ -145,6 +145,7 @@ struct CORE_EXPORT InspectorIsolationModeHighlightConfig {
|
||||
Color resizer_color;
|
||||
Color resizer_handle_color;
|
||||
Color mask_color;
|
||||
+ int highlight_index = 0;
|
||||
};
|
||||
|
||||
struct CORE_EXPORT InspectorHighlightConfig {
|
||||
@@ -300,8 +301,7 @@ std::unique_ptr<protocol::DictionaryValue> InspectorContainerQueryHighlight(
|
||||
|
||||
std::unique_ptr<protocol::DictionaryValue> InspectorIsolatedElementHighlight(
|
||||
Element* element,
|
||||
- const InspectorIsolationModeHighlightConfig& config,
|
||||
- int highlight_index);
|
||||
+ const InspectorIsolationModeHighlightConfig& config);
|
||||
|
||||
// CORE_EXPORT is required to make these functions available for unit tests.
|
||||
std::unique_ptr<protocol::DictionaryValue> CORE_EXPORT
|
||||
diff --git a/third_party/blink/renderer/core/inspector/inspector_overlay_agent.cc b/third_party/blink/renderer/core/inspector/inspector_overlay_agent.cc
|
||||
index 6bdf410f2d7606ebc946dba903ed6094d8c7cfb4..17ba8a9fc32d6d8d4573aec0d352889dce8fe15e 100644
|
||||
--- a/third_party/blink/renderer/core/inspector/inspector_overlay_agent.cc
|
||||
+++ b/third_party/blink/renderer/core/inspector/inspector_overlay_agent.cc
|
||||
@@ -707,7 +707,7 @@ Response InspectorOverlayAgent::setShowGridOverlays(
|
||||
MakeGarbageCollected<PersistentTool>(this, GetFrontend());
|
||||
}
|
||||
|
||||
- Vector<std::pair<Member<Node>, std::unique_ptr<InspectorGridHighlightConfig>>>
|
||||
+ HeapHashMap<WeakMember<Node>, std::unique_ptr<InspectorGridHighlightConfig>>
|
||||
configs;
|
||||
for (std::unique_ptr<protocol::Overlay::GridNodeHighlightConfig>& config :
|
||||
*grid_node_highlight_configs) {
|
||||
@@ -715,9 +715,8 @@ Response InspectorOverlayAgent::setShowGridOverlays(
|
||||
Response response = dom_agent_->AssertNode(config->getNodeId(), node);
|
||||
if (!response.IsSuccess())
|
||||
return response;
|
||||
- configs.push_back(
|
||||
- std::make_pair(node, InspectorOverlayAgent::ToGridHighlightConfig(
|
||||
- config->getGridHighlightConfig())));
|
||||
+ configs.insert(node, InspectorOverlayAgent::ToGridHighlightConfig(
|
||||
+ config->getGridHighlightConfig()));
|
||||
}
|
||||
|
||||
persistent_tool_->SetGridConfigs(std::move(configs));
|
||||
@@ -735,8 +734,8 @@ Response InspectorOverlayAgent::setShowFlexOverlays(
|
||||
MakeGarbageCollected<PersistentTool>(this, GetFrontend());
|
||||
}
|
||||
|
||||
- Vector<std::pair<Member<Node>,
|
||||
- std::unique_ptr<InspectorFlexContainerHighlightConfig>>>
|
||||
+ HeapHashMap<WeakMember<Node>,
|
||||
+ std::unique_ptr<InspectorFlexContainerHighlightConfig>>
|
||||
configs;
|
||||
|
||||
for (std::unique_ptr<protocol::Overlay::FlexNodeHighlightConfig>& config :
|
||||
@@ -745,9 +744,8 @@ Response InspectorOverlayAgent::setShowFlexOverlays(
|
||||
Response response = dom_agent_->AssertNode(config->getNodeId(), node);
|
||||
if (!response.IsSuccess())
|
||||
return response;
|
||||
- configs.push_back(std::make_pair(
|
||||
- node, InspectorOverlayAgent::ToFlexContainerHighlightConfig(
|
||||
- config->getFlexContainerHighlightConfig())));
|
||||
+ configs.insert(node, InspectorOverlayAgent::ToFlexContainerHighlightConfig(
|
||||
+ config->getFlexContainerHighlightConfig()));
|
||||
}
|
||||
|
||||
persistent_tool_->SetFlexContainerConfigs(std::move(configs));
|
||||
@@ -766,9 +764,8 @@ Response InspectorOverlayAgent::setShowScrollSnapOverlays(
|
||||
MakeGarbageCollected<PersistentTool>(this, GetFrontend());
|
||||
}
|
||||
|
||||
- Vector<
|
||||
- std::pair<Member<Node>,
|
||||
- std::unique_ptr<InspectorScrollSnapContainerHighlightConfig>>>
|
||||
+ HeapHashMap<WeakMember<Node>,
|
||||
+ std::unique_ptr<InspectorScrollSnapContainerHighlightConfig>>
|
||||
configs;
|
||||
|
||||
for (std::unique_ptr<protocol::Overlay::ScrollSnapHighlightConfig>& config :
|
||||
@@ -777,9 +774,9 @@ Response InspectorOverlayAgent::setShowScrollSnapOverlays(
|
||||
Response response = dom_agent_->AssertNode(config->getNodeId(), node);
|
||||
if (!response.IsSuccess())
|
||||
return response;
|
||||
- configs.push_back(std::make_pair(
|
||||
- node, InspectorOverlayAgent::ToScrollSnapContainerHighlightConfig(
|
||||
- config->getScrollSnapContainerHighlightConfig())));
|
||||
+ configs.insert(node,
|
||||
+ InspectorOverlayAgent::ToScrollSnapContainerHighlightConfig(
|
||||
+ config->getScrollSnapContainerHighlightConfig()));
|
||||
}
|
||||
|
||||
persistent_tool_->SetScrollSnapConfigs(std::move(configs));
|
||||
@@ -798,9 +795,8 @@ Response InspectorOverlayAgent::setShowContainerQueryOverlays(
|
||||
MakeGarbageCollected<PersistentTool>(this, GetFrontend());
|
||||
}
|
||||
|
||||
- Vector<std::pair<
|
||||
- Member<Node>,
|
||||
- std::unique_ptr<InspectorContainerQueryContainerHighlightConfig>>>
|
||||
+ HeapHashMap<WeakMember<Node>,
|
||||
+ std::unique_ptr<InspectorContainerQueryContainerHighlightConfig>>
|
||||
configs;
|
||||
|
||||
for (std::unique_ptr<protocol::Overlay::ContainerQueryHighlightConfig>&
|
||||
@@ -809,9 +805,9 @@ Response InspectorOverlayAgent::setShowContainerQueryOverlays(
|
||||
Response response = dom_agent_->AssertNode(config->getNodeId(), node);
|
||||
if (!response.IsSuccess())
|
||||
return response;
|
||||
- configs.push_back(std::make_pair(
|
||||
+ configs.insert(
|
||||
node, InspectorOverlayAgent::ToContainerQueryContainerHighlightConfig(
|
||||
- config->getContainerQueryContainerHighlightConfig())));
|
||||
+ config->getContainerQueryContainerHighlightConfig()));
|
||||
}
|
||||
|
||||
persistent_tool_->SetContainerQueryConfigs(std::move(configs));
|
||||
@@ -830,10 +826,11 @@ Response InspectorOverlayAgent::setShowIsolatedElements(
|
||||
MakeGarbageCollected<PersistentTool>(this, GetFrontend());
|
||||
}
|
||||
|
||||
- Vector<std::pair<Member<Element>,
|
||||
- std::unique_ptr<InspectorIsolationModeHighlightConfig>>>
|
||||
+ HeapHashMap<WeakMember<Element>,
|
||||
+ std::unique_ptr<InspectorIsolationModeHighlightConfig>>
|
||||
configs;
|
||||
|
||||
+ int idx = 0;
|
||||
for (std::unique_ptr<protocol::Overlay::IsolatedElementHighlightConfig>&
|
||||
config : *isolated_element_highlight_configs) {
|
||||
Element* element = nullptr;
|
||||
@@ -841,9 +838,10 @@ Response InspectorOverlayAgent::setShowIsolatedElements(
|
||||
Response response = dom_agent_->AssertElement(config->getNodeId(), element);
|
||||
if (!response.IsSuccess())
|
||||
return response;
|
||||
- configs.push_back(std::make_pair(
|
||||
- element, InspectorOverlayAgent::ToIsolationModeHighlightConfig(
|
||||
- config->getIsolationModeHighlightConfig())));
|
||||
+ configs.insert(element,
|
||||
+ InspectorOverlayAgent::ToIsolationModeHighlightConfig(
|
||||
+ config->getIsolationModeHighlightConfig(), idx));
|
||||
+ idx++;
|
||||
}
|
||||
|
||||
persistent_tool_->SetIsolatedElementConfigs(std::move(configs));
|
||||
@@ -947,16 +945,16 @@ Response InspectorOverlayAgent::getGridHighlightObjectsForTest(
|
||||
std::unique_ptr<protocol::Array<int>> node_ids,
|
||||
std::unique_ptr<protocol::DictionaryValue>* highlights) {
|
||||
PersistentTool persistent_tool(this, GetFrontend());
|
||||
- Vector<std::pair<Member<Node>, std::unique_ptr<InspectorGridHighlightConfig>>>
|
||||
+
|
||||
+ HeapHashMap<WeakMember<Node>, std::unique_ptr<InspectorGridHighlightConfig>>
|
||||
configs;
|
||||
for (const int node_id : *node_ids) {
|
||||
Node* node = nullptr;
|
||||
Response response = dom_agent_->AssertNode(node_id, node);
|
||||
if (!response.IsSuccess())
|
||||
return response;
|
||||
- configs.push_back(
|
||||
- std::make_pair(node, std::make_unique<InspectorGridHighlightConfig>(
|
||||
- InspectorHighlight::DefaultGridConfig())));
|
||||
+ configs.insert(node, std::make_unique<InspectorGridHighlightConfig>(
|
||||
+ InspectorHighlight::DefaultGridConfig()));
|
||||
}
|
||||
persistent_tool.SetGridConfigs(std::move(configs));
|
||||
*highlights = persistent_tool.GetGridInspectorHighlightsAsJson();
|
||||
@@ -1748,7 +1746,8 @@ InspectorOverlayAgent::ToFlexItemHighlightConfig(
|
||||
// static
|
||||
std::unique_ptr<InspectorIsolationModeHighlightConfig>
|
||||
InspectorOverlayAgent::ToIsolationModeHighlightConfig(
|
||||
- protocol::Overlay::IsolationModeHighlightConfig* config) {
|
||||
+ protocol::Overlay::IsolationModeHighlightConfig* config,
|
||||
+ int idx) {
|
||||
if (!config) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1760,6 +1759,7 @@ InspectorOverlayAgent::ToIsolationModeHighlightConfig(
|
||||
InspectorDOMAgent::ParseColor(config->getResizerHandleColor(nullptr));
|
||||
highlight_config->mask_color =
|
||||
InspectorDOMAgent::ParseColor(config->getMaskColor(nullptr));
|
||||
+ highlight_config->highlight_index = idx;
|
||||
|
||||
return highlight_config;
|
||||
}
|
||||
diff --git a/third_party/blink/renderer/core/inspector/inspector_overlay_agent.h b/third_party/blink/renderer/core/inspector/inspector_overlay_agent.h
|
||||
index 00226ea419fbd6c8004635c5adf205e8e1bbbd4e..7cb62900eedcb7c6de9666a92b701a57ec31f52d 100644
|
||||
--- a/third_party/blink/renderer/core/inspector/inspector_overlay_agent.h
|
||||
+++ b/third_party/blink/renderer/core/inspector/inspector_overlay_agent.h
|
||||
@@ -161,7 +161,8 @@ class CORE_EXPORT InspectorOverlayAgent final
|
||||
ToFlexItemHighlightConfig(protocol::Overlay::FlexItemHighlightConfig*);
|
||||
static std::unique_ptr<InspectorIsolationModeHighlightConfig>
|
||||
ToIsolationModeHighlightConfig(
|
||||
- protocol::Overlay::IsolationModeHighlightConfig*);
|
||||
+ protocol::Overlay::IsolationModeHighlightConfig*,
|
||||
+ int highlight_index);
|
||||
static absl::optional<LineStyle> ToLineStyle(protocol::Overlay::LineStyle*);
|
||||
static absl::optional<BoxStyle> ToBoxStyle(protocol::Overlay::BoxStyle*);
|
||||
static std::unique_ptr<InspectorHighlightConfig> ToHighlightConfig(
|
||||
195
patches/chromium/cherry-pick-b03797bdb1df.patch
Normal file
195
patches/chromium/cherry-pick-b03797bdb1df.patch
Normal file
@@ -0,0 +1,195 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Xiaocheng Hu <xiaochengh@chromium.org>
|
||||
Date: Mon, 2 May 2022 23:43:40 +0000
|
||||
Subject: Markup sanitization should iterate until markup is stable
|
||||
|
||||
There are cases where parsing a markup and then serializing it does not
|
||||
round trip, which can be used to inject XSS. Current sanitization code
|
||||
only does one round of parsing and serializing, which does not remove
|
||||
XSS injections that hide deeper.
|
||||
|
||||
Hence this patch makes sanitization algorithm iterate until the markup
|
||||
is stable, or declares failure if it doesn't stabilize after many tries.
|
||||
|
||||
(cherry picked from commit 19280353fb92d0ff7d048d7cec28d6a23befbce0)
|
||||
|
||||
Fixed: 1315563
|
||||
Change-Id: I4a3ebe1fda6df0e04a24d863b2b48df2110af209
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3611826
|
||||
Commit-Queue: Xiaocheng Hu <xiaochengh@chromium.org>
|
||||
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
|
||||
Cr-Original-Commit-Position: refs/heads/main@{#997032}
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3621618
|
||||
Auto-Submit: Xiaocheng Hu <xiaochengh@chromium.org>
|
||||
Reviewed-by: Joey Arhar <jarhar@chromium.org>
|
||||
Commit-Queue: Joey Arhar <jarhar@chromium.org>
|
||||
Cr-Commit-Position: refs/branch-heads/5005@{#363}
|
||||
Cr-Branched-From: 5b4d9450fee01f821b6400e947b3839727643a71-refs/heads/main@{#992738}
|
||||
|
||||
diff --git a/third_party/blink/renderer/core/editing/serializers/serialization.cc b/third_party/blink/renderer/core/editing/serializers/serialization.cc
|
||||
index 4ee332fa16a1bda54e6ba99c8063876fb046adaa..463fd9a37671b92c9af68ff5f3c0e8ddd5f1c62c 100644
|
||||
--- a/third_party/blink/renderer/core/editing/serializers/serialization.cc
|
||||
+++ b/third_party/blink/renderer/core/editing/serializers/serialization.cc
|
||||
@@ -835,6 +835,12 @@ static bool StripSVGUseDataURLs(Node& node) {
|
||||
return stripped;
|
||||
}
|
||||
|
||||
+namespace {
|
||||
+
|
||||
+constexpr unsigned kMaxSanitizationIterations = 16;
|
||||
+
|
||||
+} // namespace
|
||||
+
|
||||
DocumentFragment* CreateSanitizedFragmentFromMarkupWithContext(
|
||||
Document& document,
|
||||
const String& raw_markup,
|
||||
@@ -844,42 +850,56 @@ DocumentFragment* CreateSanitizedFragmentFromMarkupWithContext(
|
||||
if (raw_markup.IsEmpty())
|
||||
return nullptr;
|
||||
|
||||
- Document* staging_document = CreateStagingDocumentForMarkupSanitization(
|
||||
- *document.GetFrame()->GetFrameScheduler()->GetAgentGroupScheduler());
|
||||
- Element* body = staging_document->body();
|
||||
-
|
||||
- DocumentFragment* fragment = CreateFragmentFromMarkupWithContext(
|
||||
- *staging_document, raw_markup, fragment_start, fragment_end, KURL(),
|
||||
- kDisallowScriptingAndPluginContent);
|
||||
- if (!fragment) {
|
||||
- staging_document->GetPage()->WillBeDestroyed();
|
||||
- return nullptr;
|
||||
- }
|
||||
+ // Iterate on parsing, sanitization and serialization until the markup is
|
||||
+ // stable, or if we have exceeded the maximum allowed number of iterations.
|
||||
+ String last_markup;
|
||||
+ String markup = raw_markup;
|
||||
+ for (unsigned iteration = 0;
|
||||
+ iteration < kMaxSanitizationIterations && last_markup != markup;
|
||||
+ ++iteration) {
|
||||
+ last_markup = markup;
|
||||
+
|
||||
+ Document* staging_document = CreateStagingDocumentForMarkupSanitization(
|
||||
+ *document.GetFrame()->GetFrameScheduler()->GetAgentGroupScheduler());
|
||||
+ Element* body = staging_document->body();
|
||||
+
|
||||
+ DocumentFragment* fragment = CreateFragmentFromMarkupWithContext(
|
||||
+ *staging_document, last_markup, fragment_start, fragment_end, KURL(),
|
||||
+ kDisallowScriptingAndPluginContent);
|
||||
+ if (!fragment) {
|
||||
+ staging_document->GetPage()->WillBeDestroyed();
|
||||
+ return nullptr;
|
||||
+ }
|
||||
|
||||
- bool needs_sanitization = false;
|
||||
- if (ContainsStyleElements(*fragment))
|
||||
- needs_sanitization = true;
|
||||
- if (StripSVGUseDataURLs(*fragment))
|
||||
- needs_sanitization = true;
|
||||
+ bool needs_sanitization = false;
|
||||
+ if (ContainsStyleElements(*fragment))
|
||||
+ needs_sanitization = true;
|
||||
+ if (StripSVGUseDataURLs(*fragment))
|
||||
+ needs_sanitization = true;
|
||||
|
||||
- if (!needs_sanitization) {
|
||||
+ if (!needs_sanitization) {
|
||||
+ markup = CreateMarkup(fragment);
|
||||
+ } else {
|
||||
+ body->appendChild(fragment);
|
||||
+ staging_document->UpdateStyleAndLayout(DocumentUpdateReason::kEditing);
|
||||
+
|
||||
+ // This sanitizes stylesheets in the markup into element inline styles
|
||||
+ markup = CreateMarkup(Position::FirstPositionInNode(*body),
|
||||
+ Position::LastPositionInNode(*body),
|
||||
+ CreateMarkupOptions::Builder()
|
||||
+ .SetShouldAnnotateForInterchange(true)
|
||||
+ .SetIsForMarkupSanitization(true)
|
||||
+ .Build());
|
||||
+ }
|
||||
staging_document->GetPage()->WillBeDestroyed();
|
||||
- return CreateFragmentFromMarkupWithContext(
|
||||
- document, raw_markup, fragment_start, fragment_end, base_url,
|
||||
- kDisallowScriptingAndPluginContent);
|
||||
+
|
||||
+ fragment_start = 0;
|
||||
+ fragment_end = markup.length();
|
||||
}
|
||||
|
||||
- body->appendChild(fragment);
|
||||
- staging_document->UpdateStyleAndLayout(DocumentUpdateReason::kEditing);
|
||||
-
|
||||
- // This sanitizes stylesheets in the markup into element inline styles
|
||||
- String markup = CreateMarkup(Position::FirstPositionInNode(*body),
|
||||
- Position::LastPositionInNode(*body),
|
||||
- CreateMarkupOptions::Builder()
|
||||
- .SetShouldAnnotateForInterchange(true)
|
||||
- .SetIsForMarkupSanitization(true)
|
||||
- .Build());
|
||||
- staging_document->GetPage()->WillBeDestroyed();
|
||||
+ // Sanitization failed because markup can't stabilize.
|
||||
+ if (last_markup != markup)
|
||||
+ return nullptr;
|
||||
|
||||
return CreateFragmentFromMarkup(document, markup, base_url,
|
||||
kDisallowScriptingAndPluginContent);
|
||||
diff --git a/third_party/blink/web_tests/editing/pasteboard/paste-svg-use.html b/third_party/blink/web_tests/editing/pasteboard/paste-svg-use.html
|
||||
index c03ca90d492a5e2af883f68811baa7660ef1cdc2..1af77f8faa4501f577e28297f013e170775bc86a 100644
|
||||
--- a/third_party/blink/web_tests/editing/pasteboard/paste-svg-use.html
|
||||
+++ b/third_party/blink/web_tests/editing/pasteboard/paste-svg-use.html
|
||||
@@ -32,6 +32,6 @@ selection_test(
|
||||
<use href=data:application/xml;base64,PHN2ZyBpZD0neCcgeG1sbnM9J2h0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnJz4KPGEgaHJlZj0namF2YXNjcmlwdDphbGVydCgxMjMpJz4KICAgIDxyZWN0IHdpZHRoPScxMDAlJyBoZWlnaHQ9JzEwMCUnIGZpbGw9J2xpZ2h0Ymx1ZScgLz4KICAgICA8dGV4dCB4PScwJyB5PScwJyBmaWxsPSdibGFjayc+CiAgICAgICA8dHNwYW4geD0nMCcgZHk9JzEuMmVtJz5Pb3BzLCB0aGVyZSdzIHNvbWV0aGluZyB3cm9uZyB3aXRoIHRoZSBwYWdlITwvdHNwYW4+CiAgICAgPHRzcGFuIHg9JzAnIGR5PScxLjJlbSc+UGxlYXNlIGNsaWNrIGhlcmUgdG8gcmVsb2FkLjwvdHNwYW4+Cjwvc3ZnPg==#x>"></noscript>asdasd`);
|
||||
selection.document.execCommand('paste');
|
||||
},
|
||||
- '<div contenteditable>|<noscript><u title="</noscript><div contenteditable="false"><svg></svg></div></div>',
|
||||
+ '<div contenteditable><div><br></div><div> <u title="</div><div> </div><div> ">asdasd|</div></div>',
|
||||
'Paste blocks data URI in SVG use element injection via <noscript>');
|
||||
</script>
|
||||
diff --git a/third_party/blink/web_tests/external/wpt/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html b/third_party/blink/web_tests/external/wpt/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..9e0ab2ee740f85ea4e9de9d3f1d2ac43bee5a985
|
||||
--- /dev/null
|
||||
+++ b/third_party/blink/web_tests/external/wpt/clipboard-apis/async-navigator-clipboard-read-sanitize.https.html
|
||||
@@ -0,0 +1,44 @@
|
||||
+<!doctype html>
|
||||
+<meta charset="utf-8">
|
||||
+<title>Async Clipboard.read() should sanitize text/html</title>
|
||||
+<link rel="help" href="https://w3c.github.io/clipboard-apis/#dom-clipboard-read">
|
||||
+<link rel="help" href="https://bugs.chromium.org/p/chromium/issues/detail?id=1315563">
|
||||
+<script src="/resources/testharness.js"></script>
|
||||
+<script src="/resources/testharnessreport.js"></script>
|
||||
+<script src="/resources/testdriver.js"></script>
|
||||
+<script src="/resources/testdriver-vendor.js"></script>
|
||||
+
|
||||
+<p><button id="button">Put payload in the clipboard</button></p>
|
||||
+<div id="output"></div>
|
||||
+
|
||||
+<script>
|
||||
+let testFailed = false;
|
||||
+function fail() {
|
||||
+ testFailed = true;
|
||||
+}
|
||||
+
|
||||
+button.onclick = () => document.execCommand('copy');
|
||||
+document.oncopy = ev => {
|
||||
+ ev.preventDefault();
|
||||
+ ev.clipboardData.setData(
|
||||
+ 'text/html',
|
||||
+ `<form><math><mtext></form><form><mglyph><xmp></math><img src=invalid onerror=fail()></xmp>`);
|
||||
+};
|
||||
+
|
||||
+promise_test(async test => {
|
||||
+ await test_driver.set_permission({name: 'clipboard-read'}, 'granted');
|
||||
+ await test_driver.click(button);
|
||||
+
|
||||
+ const items = await navigator.clipboard.read();
|
||||
+ const htmlBlob = await items[0].getType("text/html");
|
||||
+ const html = await htmlBlob.text();
|
||||
+
|
||||
+ // This inserts an image with `onerror` handler if `html` is not properly sanitized
|
||||
+ output.innerHTML = html;
|
||||
+
|
||||
+ // Allow the 'error' event to be dispatched asynchronously
|
||||
+ await new Promise(resolve => test.step_timeout(resolve, 100));
|
||||
+
|
||||
+ assert_false(testFailed);
|
||||
+});
|
||||
+</script>
|
||||
404
patches/chromium/cherry-pick-cf64617c1cc5.patch
Normal file
404
patches/chromium/cherry-pick-cf64617c1cc5.patch
Normal file
@@ -0,0 +1,404 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Austin Sullivan <asully@chromium.org>
|
||||
Date: Fri, 11 Mar 2022 10:08:55 +0000
|
||||
Subject: FSA: Pass File ownership to worker for async FSARFD file operations
|
||||
|
||||
We cannot access the backing file as a member of the
|
||||
FileSystemAccessRegularFileDelegate since WrapCrossThreadPersistent
|
||||
does NOT cancel the task posted to the worker pool if delegate is
|
||||
destroyed. Passing ownership to the worker task ensures the file must
|
||||
be alive when used. After the operation, ownership of the file is
|
||||
passed back to the delegate.
|
||||
|
||||
This pattern was already used for the SetLength operation on old Macs.
|
||||
|
||||
Bug: 1299743
|
||||
Change-Id: Ie00c09e8f77dc353f280af726a68ed6c572b750b
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3498864
|
||||
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
|
||||
Commit-Queue: Austin Sullivan <asully@chromium.org>
|
||||
Cr-Commit-Position: refs/heads/main@{#980167}
|
||||
|
||||
diff --git a/third_party/blink/renderer/modules/file_system_access/file_system_access_regular_file_delegate.cc b/third_party/blink/renderer/modules/file_system_access/file_system_access_regular_file_delegate.cc
|
||||
index 19516a1c3cca7b521c68a266389aa0544cf721d8..b25747a92f21e334e49846e59f03a3312605f2dc 100644
|
||||
--- a/third_party/blink/renderer/modules/file_system_access/file_system_access_regular_file_delegate.cc
|
||||
+++ b/third_party/blink/renderer/modules/file_system_access/file_system_access_regular_file_delegate.cc
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "third_party/blink/renderer/platform/scheduler/public/worker_pool.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/cross_thread_functional.h"
|
||||
#include "third_party/blink/renderer/platform/wtf/functional.h"
|
||||
+#include "third_party/blink/renderer/platform/wtf/wtf.h"
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
#include "base/mac/mac_util.h"
|
||||
@@ -65,6 +66,8 @@ FileSystemAccessRegularFileDelegate::FileSystemAccessRegularFileDelegate(
|
||||
base::FileErrorOr<int> FileSystemAccessRegularFileDelegate::Read(
|
||||
int64_t offset,
|
||||
base::span<uint8_t> data) {
|
||||
+ DCHECK_GE(offset, 0);
|
||||
+
|
||||
int size = base::checked_cast<int>(data.size());
|
||||
int result =
|
||||
backing_file_.Read(offset, reinterpret_cast<char*>(data.data()), size);
|
||||
@@ -75,13 +78,14 @@ base::FileErrorOr<int> FileSystemAccessRegularFileDelegate::Read(
|
||||
}
|
||||
|
||||
base::FileErrorOr<int> FileSystemAccessRegularFileDelegate::Write(
|
||||
- int64_t write_offset,
|
||||
+ int64_t offset,
|
||||
const base::span<uint8_t> data) {
|
||||
+ DCHECK_GE(offset, 0);
|
||||
+
|
||||
int write_size = base::checked_cast<int>(data.size());
|
||||
|
||||
int64_t write_end_offset;
|
||||
- if (!base::CheckAdd(write_offset, write_size)
|
||||
- .AssignIfValid(&write_end_offset)) {
|
||||
+ if (!base::CheckAdd(offset, write_size).AssignIfValid(&write_end_offset)) {
|
||||
return base::File::FILE_ERROR_NO_SPACE;
|
||||
}
|
||||
|
||||
@@ -89,8 +93,8 @@ base::FileErrorOr<int> FileSystemAccessRegularFileDelegate::Write(
|
||||
return base::File::FILE_ERROR_NO_SPACE;
|
||||
}
|
||||
|
||||
- int result = backing_file_.Write(
|
||||
- write_offset, reinterpret_cast<char*>(data.data()), write_size);
|
||||
+ int result = backing_file_.Write(offset, reinterpret_cast<char*>(data.data()),
|
||||
+ write_size);
|
||||
if (write_size == result) {
|
||||
capacity_tracker_->CommitFileSizeChange(write_end_offset);
|
||||
return result;
|
||||
@@ -113,16 +117,19 @@ void FileSystemAccessRegularFileDelegate::GetLength(
|
||||
FROM_HERE, {base::MayBlock()},
|
||||
CrossThreadBindOnce(&FileSystemAccessRegularFileDelegate::DoGetLength,
|
||||
WrapCrossThreadPersistent(this),
|
||||
- std::move(wrapped_callback), task_runner_));
|
||||
+ std::move(wrapped_callback), std::move(backing_file_),
|
||||
+ task_runner_));
|
||||
}
|
||||
|
||||
// static
|
||||
void FileSystemAccessRegularFileDelegate::DoGetLength(
|
||||
CrossThreadPersistent<FileSystemAccessRegularFileDelegate> delegate,
|
||||
- WTF::CrossThreadOnceFunction<void(base::FileErrorOr<int64_t>)>
|
||||
- wrapped_callback,
|
||||
+ CrossThreadOnceFunction<void(base::FileErrorOr<int64_t>)> callback,
|
||||
+ base::File file,
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner) {
|
||||
- int64_t length = delegate->backing_file_.GetLength();
|
||||
+ DCHECK(!IsMainThread());
|
||||
+
|
||||
+ int64_t length = file.GetLength();
|
||||
|
||||
// If the length is negative, the file operation failed. Get the last error
|
||||
// now before another file operation might run.
|
||||
@@ -131,7 +138,19 @@ void FileSystemAccessRegularFileDelegate::DoGetLength(
|
||||
|
||||
PostCrossThreadTask(
|
||||
*task_runner, FROM_HERE,
|
||||
- CrossThreadBindOnce(std::move(wrapped_callback), std::move(result)));
|
||||
+ CrossThreadBindOnce(&FileSystemAccessRegularFileDelegate::DidGetLength,
|
||||
+ std::move(delegate), std::move(callback),
|
||||
+ std::move(file), std::move(result)));
|
||||
+}
|
||||
+
|
||||
+void FileSystemAccessRegularFileDelegate::DidGetLength(
|
||||
+ CrossThreadOnceFunction<void(base::FileErrorOr<int64_t>)> callback,
|
||||
+ base::File file,
|
||||
+ base::FileErrorOr<int64_t> error_or_length) {
|
||||
+ DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
+ backing_file_ = std::move(file);
|
||||
+
|
||||
+ std::move(callback).Run(std::move(error_or_length));
|
||||
}
|
||||
|
||||
void FileSystemAccessRegularFileDelegate::SetLength(
|
||||
@@ -162,6 +181,9 @@ void FileSystemAccessRegularFileDelegate::DidCheckSetLengthCapacity(
|
||||
return;
|
||||
}
|
||||
|
||||
+ auto wrapped_callback =
|
||||
+ CrossThreadOnceFunction<void(bool)>(std::move(callback));
|
||||
+
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
// On macOS < 10.15, a sandboxing limitation causes failures in ftruncate()
|
||||
// syscalls issued from renderers. For this reason, base::File::SetLength()
|
||||
@@ -174,81 +196,57 @@ void FileSystemAccessRegularFileDelegate::DidCheckSetLengthCapacity(
|
||||
}
|
||||
file_utilities_host_->SetLength(
|
||||
std::move(backing_file_), new_length,
|
||||
- WTF::Bind(&FileSystemAccessRegularFileDelegate::DidSetLengthIPC,
|
||||
- WrapPersistent(this), std::move(callback), new_length));
|
||||
+ WTF::Bind(&FileSystemAccessRegularFileDelegate::DidSetLength,
|
||||
+ WrapPersistent(this), std::move(wrapped_callback),
|
||||
+ new_length));
|
||||
return;
|
||||
}
|
||||
#endif // BUILDFLAG(IS_MAC)
|
||||
|
||||
- auto wrapped_callback =
|
||||
- CrossThreadOnceFunction<void(bool)>(std::move(callback));
|
||||
-
|
||||
// Truncate file on a worker thread and reply back to this sequence.
|
||||
worker_pool::PostTask(
|
||||
FROM_HERE, {base::MayBlock()},
|
||||
CrossThreadBindOnce(&FileSystemAccessRegularFileDelegate::DoSetLength,
|
||||
WrapCrossThreadPersistent(this),
|
||||
- std::move(wrapped_callback), task_runner_,
|
||||
- new_length));
|
||||
+ std::move(wrapped_callback), std::move(backing_file_),
|
||||
+ task_runner_, new_length));
|
||||
}
|
||||
|
||||
// static
|
||||
void FileSystemAccessRegularFileDelegate::DoSetLength(
|
||||
CrossThreadPersistent<FileSystemAccessRegularFileDelegate> delegate,
|
||||
- CrossThreadOnceFunction<void(bool)> wrapped_callback,
|
||||
+ CrossThreadOnceFunction<void(bool)> callback,
|
||||
+ base::File file,
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner,
|
||||
int64_t length) {
|
||||
- bool result = delegate->backing_file_.SetLength(length);
|
||||
-
|
||||
- if (!result) {
|
||||
- // If the operation failed, the previously requested capacity is not
|
||||
- // returned and no change in file size is recorded. This assumes that
|
||||
- // setLength operations either succeed or do not change the file's length,
|
||||
- // which is consistent with the way other file operations are implemented in
|
||||
- // File System Access.
|
||||
- PostCrossThreadTask(
|
||||
- *task_runner, FROM_HERE,
|
||||
- CrossThreadBindOnce(std::move(wrapped_callback), std::move(result)));
|
||||
- return;
|
||||
- }
|
||||
+ DCHECK(!IsMainThread());
|
||||
+
|
||||
+ bool success = file.SetLength(length);
|
||||
+
|
||||
PostCrossThreadTask(
|
||||
*task_runner, FROM_HERE,
|
||||
- CrossThreadBindOnce(
|
||||
- &FileSystemAccessRegularFileDelegate::DidSuccessfulSetLength,
|
||||
- std::move(delegate), length, std::move(wrapped_callback)));
|
||||
-}
|
||||
-
|
||||
-void FileSystemAccessRegularFileDelegate::DidSuccessfulSetLength(
|
||||
- int64_t new_length,
|
||||
- CrossThreadOnceFunction<void(bool)> callback) {
|
||||
- DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
- capacity_tracker_->CommitFileSizeChange(new_length);
|
||||
- std::move(callback).Run(true);
|
||||
+ CrossThreadBindOnce(&FileSystemAccessRegularFileDelegate::DidSetLength,
|
||||
+ std::move(delegate), std::move(callback), length,
|
||||
+ std::move(file), success));
|
||||
}
|
||||
|
||||
-#if BUILDFLAG(IS_MAC)
|
||||
-void FileSystemAccessRegularFileDelegate::DidSetLengthIPC(
|
||||
- base::OnceCallback<void(bool)> callback,
|
||||
+void FileSystemAccessRegularFileDelegate::DidSetLength(
|
||||
+ CrossThreadOnceFunction<void(bool)> callback,
|
||||
int64_t new_length,
|
||||
base::File file,
|
||||
bool success) {
|
||||
DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
backing_file_ = std::move(file);
|
||||
|
||||
- if (!success) {
|
||||
- // If the operation failed, the previously requested capacity is not
|
||||
- // returned and no change in file size is recorded. This assumes that
|
||||
- // setLength operations either succeed or do not change the file's length,
|
||||
- // which is consistent with the way other file operations are implemented in
|
||||
- // File System Access.
|
||||
- std::move(callback).Run(success);
|
||||
- return;
|
||||
- }
|
||||
- auto wrapped_callback =
|
||||
- CrossThreadOnceFunction<void(bool)>(std::move(callback));
|
||||
- DidSuccessfulSetLength(new_length, std::move(wrapped_callback));
|
||||
+ // If the operation failed, no change in file size is recorded. This assumes
|
||||
+ // that setLength operations either succeed or do not change the file's
|
||||
+ // length, which is consistent with the way other file operations are
|
||||
+ // implemented in File System Access.
|
||||
+ if (success)
|
||||
+ capacity_tracker_->CommitFileSizeChange(new_length);
|
||||
+
|
||||
+ std::move(callback).Run(success);
|
||||
}
|
||||
-#endif // BUILDFLAG(IS_MAC)
|
||||
|
||||
void FileSystemAccessRegularFileDelegate::Flush(
|
||||
base::OnceCallback<void(bool)> callback) {
|
||||
@@ -260,17 +258,34 @@ void FileSystemAccessRegularFileDelegate::Flush(
|
||||
FROM_HERE, {base::MayBlock()},
|
||||
CrossThreadBindOnce(&FileSystemAccessRegularFileDelegate::DoFlush,
|
||||
WrapCrossThreadPersistent(this),
|
||||
- std::move(wrapped_callback), task_runner_));
|
||||
+ std::move(wrapped_callback), std::move(backing_file_),
|
||||
+ task_runner_));
|
||||
}
|
||||
|
||||
// static
|
||||
void FileSystemAccessRegularFileDelegate::DoFlush(
|
||||
CrossThreadPersistent<FileSystemAccessRegularFileDelegate> delegate,
|
||||
- CrossThreadOnceFunction<void(bool)> wrapped_callback,
|
||||
+ CrossThreadOnceFunction<void(bool)> callback,
|
||||
+ base::File file,
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner) {
|
||||
- bool result = delegate->backing_file_.Flush();
|
||||
- PostCrossThreadTask(*task_runner, FROM_HERE,
|
||||
- CrossThreadBindOnce(std::move(wrapped_callback), result));
|
||||
+ DCHECK(!IsMainThread());
|
||||
+
|
||||
+ bool success = file.Flush();
|
||||
+ PostCrossThreadTask(
|
||||
+ *task_runner, FROM_HERE,
|
||||
+ CrossThreadBindOnce(&FileSystemAccessRegularFileDelegate::DidFlush,
|
||||
+ std::move(delegate), std::move(callback),
|
||||
+ std::move(file), success));
|
||||
+}
|
||||
+
|
||||
+void FileSystemAccessRegularFileDelegate::DidFlush(
|
||||
+ CrossThreadOnceFunction<void(bool)> callback,
|
||||
+ base::File file,
|
||||
+ bool success) {
|
||||
+ DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
+ backing_file_ = std::move(file);
|
||||
+
|
||||
+ std::move(callback).Run(success);
|
||||
}
|
||||
|
||||
void FileSystemAccessRegularFileDelegate::Close(base::OnceClosure callback) {
|
||||
@@ -281,16 +296,33 @@ void FileSystemAccessRegularFileDelegate::Close(base::OnceClosure callback) {
|
||||
FROM_HERE, {base::MayBlock()},
|
||||
CrossThreadBindOnce(&FileSystemAccessRegularFileDelegate::DoClose,
|
||||
WrapCrossThreadPersistent(this),
|
||||
- std::move(wrapped_callback), task_runner_));
|
||||
+ std::move(wrapped_callback), std::move(backing_file_),
|
||||
+ task_runner_));
|
||||
}
|
||||
|
||||
// static
|
||||
void FileSystemAccessRegularFileDelegate::DoClose(
|
||||
CrossThreadPersistent<FileSystemAccessRegularFileDelegate> delegate,
|
||||
- CrossThreadOnceClosure wrapped_callback,
|
||||
+ CrossThreadOnceClosure callback,
|
||||
+ base::File file,
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner) {
|
||||
- delegate->backing_file_.Close();
|
||||
- PostCrossThreadTask(*task_runner, FROM_HERE, std::move(wrapped_callback));
|
||||
+ DCHECK(!IsMainThread());
|
||||
+
|
||||
+ file.Close();
|
||||
+ PostCrossThreadTask(
|
||||
+ *task_runner, FROM_HERE,
|
||||
+ CrossThreadBindOnce(&FileSystemAccessRegularFileDelegate::DidClose,
|
||||
+ std::move(delegate), std::move(callback),
|
||||
+ std::move(file)));
|
||||
+}
|
||||
+
|
||||
+void FileSystemAccessRegularFileDelegate::DidClose(
|
||||
+ CrossThreadOnceClosure callback,
|
||||
+ base::File file) {
|
||||
+ DCHECK(task_runner_->RunsTasksInCurrentSequence());
|
||||
+ backing_file_ = std::move(file);
|
||||
+
|
||||
+ std::move(callback).Run();
|
||||
}
|
||||
|
||||
} // namespace blink
|
||||
diff --git a/third_party/blink/renderer/modules/file_system_access/file_system_access_regular_file_delegate.h b/third_party/blink/renderer/modules/file_system_access/file_system_access_regular_file_delegate.h
|
||||
index dc894059a12f4bcb8a36a1b6f443265dee42789a..880d6880f855d98f8d4102270c06923e9b3dc738 100644
|
||||
--- a/third_party/blink/renderer/modules/file_system_access/file_system_access_regular_file_delegate.h
|
||||
+++ b/third_party/blink/renderer/modules/file_system_access/file_system_access_regular_file_delegate.h
|
||||
@@ -28,6 +28,11 @@ namespace blink {
|
||||
|
||||
// Non-incognito implementation of the FileSystemAccessFileDelegate. This class
|
||||
// is a thin wrapper around an OS-level file descriptor.
|
||||
+//
|
||||
+// For async file operations, ownership of the file descriptor is passed to
|
||||
+// `task_runner_` to ensure it stays alive while being used. Ownership is passed
|
||||
+// back to the delegate once the operation completes. The delegate must not be
|
||||
+// used while there is an in-progress operation.
|
||||
class FileSystemAccessRegularFileDelegate final
|
||||
: public FileSystemAccessFileDelegate {
|
||||
public:
|
||||
@@ -71,24 +76,55 @@ class FileSystemAccessRegularFileDelegate final
|
||||
bool IsValid() const override { return backing_file_.IsValid(); }
|
||||
|
||||
private:
|
||||
+ // All async file operations perform I/O via a worker pool, off the main
|
||||
+ // thread. To keep `backing_file_` from being garbage-collected, ownership is
|
||||
+ // passed to the worker thread during the file operation. Concurrent file
|
||||
+ // operations is NOT supported.
|
||||
+
|
||||
+ // Performs the file I/O part of getSize(), off the main thread.
|
||||
static void DoGetLength(
|
||||
CrossThreadPersistent<FileSystemAccessRegularFileDelegate> delegate,
|
||||
- CrossThreadOnceFunction<void(base::FileErrorOr<int64_t>)>
|
||||
- wrapped_callback,
|
||||
+ CrossThreadOnceFunction<void(base::FileErrorOr<int64_t>)> callback,
|
||||
+ base::File file,
|
||||
scoped_refptr<base::SequencedTaskRunner> file_task_runner);
|
||||
+ // Performs the post file I/O part of getSize(), on the main thread.
|
||||
+ void DidGetLength(
|
||||
+ CrossThreadOnceFunction<void(base::FileErrorOr<int64_t>)> callback,
|
||||
+ base::File file,
|
||||
+ base::FileErrorOr<int64_t> error_or_length);
|
||||
+
|
||||
+ // Performs the file I/O part of truncate(), off the main thread.
|
||||
static void DoSetLength(
|
||||
CrossThreadPersistent<FileSystemAccessRegularFileDelegate> delegate,
|
||||
- CrossThreadOnceFunction<void(bool)> wrapped_callback,
|
||||
+ CrossThreadOnceFunction<void(bool)> callback,
|
||||
+ base::File file,
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner,
|
||||
int64_t length);
|
||||
+ // Performs the post file I/O part of truncate(), on the main thread.
|
||||
+ void DidSetLength(CrossThreadOnceFunction<void(bool)> callback,
|
||||
+ int64_t new_length,
|
||||
+ base::File file,
|
||||
+ bool success);
|
||||
+
|
||||
+ // Performs the file I/O part of flush(), off the main thread.
|
||||
static void DoFlush(
|
||||
CrossThreadPersistent<FileSystemAccessRegularFileDelegate> delegate,
|
||||
- CrossThreadOnceFunction<void(bool)> wrapped_callback,
|
||||
+ CrossThreadOnceFunction<void(bool)> callback,
|
||||
+ base::File file,
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner);
|
||||
+ // Performs the post file I/O part of flush(), on the main thread.
|
||||
+ void DidFlush(CrossThreadOnceFunction<void(bool)> callback,
|
||||
+ base::File file,
|
||||
+ bool success);
|
||||
+
|
||||
+ // Performs the file I/O part of close(), off the main thread.
|
||||
static void DoClose(
|
||||
CrossThreadPersistent<FileSystemAccessRegularFileDelegate> delegate,
|
||||
- CrossThreadOnceClosure wrapped_callback,
|
||||
+ CrossThreadOnceClosure callback,
|
||||
+ base::File file,
|
||||
scoped_refptr<base::SequencedTaskRunner> task_runner);
|
||||
+ // Performs the post file I/O part of close(), on the main thread.
|
||||
+ void DidClose(CrossThreadOnceClosure callback, base::File file);
|
||||
|
||||
// Called after preconditions for SetLength, including the requesting
|
||||
// additional capacity (if needed), have been performed.
|
||||
@@ -98,16 +134,7 @@ class FileSystemAccessRegularFileDelegate final
|
||||
int64_t new_length,
|
||||
bool request_capacity_result);
|
||||
|
||||
- // Called after SetLength was successfully performed.
|
||||
- void DidSuccessfulSetLength(int64_t new_length,
|
||||
- CrossThreadOnceFunction<void(bool)> callback);
|
||||
-
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
- void DidSetLengthIPC(base::OnceCallback<void(bool)> callback,
|
||||
- int64_t new_length,
|
||||
- base::File file,
|
||||
- bool result);
|
||||
-
|
||||
// We need the FileUtilitiesHost only on Mac, where we have to execute
|
||||
// base::File::SetLength on the browser process, see crbug.com/1084565.
|
||||
// We need the context_ to create the instance of FileUtilitiesHost lazily.
|
||||
88
patches/chromium/cherry-pick-e2b8856012e0.patch
Normal file
88
patches/chromium/cherry-pick-e2b8856012e0.patch
Normal file
@@ -0,0 +1,88 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Xiaocheng Hu <xiaochengh@chromium.org>
|
||||
Date: Mon, 18 Apr 2022 01:14:45 +0000
|
||||
Subject: Sanitize DragData markup before inserting it into document
|
||||
|
||||
(cherry picked from commit 5164a0fe3391283663e1196cf4576ec233985e89)
|
||||
|
||||
Fixed: 1315040
|
||||
Change-Id: I8a0ddfb983d12c185f7e943d3d5277788199b011
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3579670
|
||||
Quick-Run: Xiaocheng Hu <xiaochengh@chromium.org>
|
||||
Auto-Submit: Xiaocheng Hu <xiaochengh@chromium.org>
|
||||
Reviewed-by: Kent Tamura <tkent@chromium.org>
|
||||
Commit-Queue: Kent Tamura <tkent@chromium.org>
|
||||
Cr-Original-Commit-Position: refs/heads/main@{#991324}
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3588887
|
||||
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
|
||||
Cr-Commit-Position: refs/branch-heads/4951@{#831}
|
||||
Cr-Branched-From: 27de6227ca357da0d57ae2c7b18da170c4651438-refs/heads/main@{#982481}
|
||||
|
||||
diff --git a/third_party/blink/renderer/core/page/drag_data.cc b/third_party/blink/renderer/core/page/drag_data.cc
|
||||
index 2ce56b1fefe016ac34a1a3011a595fab342abfa5..4fb86bc645386ee806544ee3647b0a333cd8afc4 100644
|
||||
--- a/third_party/blink/renderer/core/page/drag_data.cc
|
||||
+++ b/third_party/blink/renderer/core/page/drag_data.cc
|
||||
@@ -131,8 +131,8 @@ DocumentFragment* DragData::AsFragment(LocalFrame* frame) const {
|
||||
platform_drag_data_->HtmlAndBaseURL(html, base_url);
|
||||
DCHECK(frame->GetDocument());
|
||||
if (DocumentFragment* fragment =
|
||||
- CreateFragmentFromMarkup(*frame->GetDocument(), html, base_url,
|
||||
- kDisallowScriptingAndPluginContent))
|
||||
+ CreateSanitizedFragmentFromMarkupWithContext(
|
||||
+ *frame->GetDocument(), html, 0, html.length(), base_url))
|
||||
return fragment;
|
||||
}
|
||||
|
||||
diff --git a/third_party/blink/web_tests/editing/pasteboard/drag-and-drop-svg-use-sanitize.html b/third_party/blink/web_tests/editing/pasteboard/drag-and-drop-svg-use-sanitize.html
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..58551d28341d851dbd99322e2a5d3af68b3b0c72
|
||||
--- /dev/null
|
||||
+++ b/third_party/blink/web_tests/editing/pasteboard/drag-and-drop-svg-use-sanitize.html
|
||||
@@ -0,0 +1,47 @@
|
||||
+<!doctype html>
|
||||
+<script src="../../resources/testharness.js"></script>
|
||||
+<script src="../../resources/testharnessreport.js"></script>
|
||||
+
|
||||
+<div id="drag-from" draggable=true>Drag from</div>
|
||||
+<div id="drag-to" contenteditable>Drag to</div>
|
||||
+
|
||||
+<script>
|
||||
+function computePoint(element) {
|
||||
+ return {
|
||||
+ x: element.offsetLeft + element.offsetWidth / 2,
|
||||
+ y: element.offsetTop + element.offsetHeight / 2
|
||||
+ };
|
||||
+}
|
||||
+
|
||||
+let dragged = false;
|
||||
+let executed = false;
|
||||
+const payload = `
|
||||
+ <svg><use href="data:image/svg+xml,<svg id='x' xmlns='http://www.w3.org/2000/svg'><image href='fake' onerror='executed=true' /></svg>#x" />
|
||||
+`;
|
||||
+
|
||||
+const dragFrom = document.getElementById('drag-from');
|
||||
+dragFrom.ondragstart = event => {
|
||||
+ dragged = true;
|
||||
+ event.dataTransfer.setData('text/html', payload);
|
||||
+}
|
||||
+
|
||||
+const dragTo = document.getElementById('drag-to');
|
||||
+
|
||||
+promise_test(async test => {
|
||||
+ assert_own_property(window, 'eventSender', 'This test requires eventSender to simulate drag and drop');
|
||||
+
|
||||
+ const fromPoint = computePoint(dragFrom);
|
||||
+ eventSender.mouseMoveTo(fromPoint.x, fromPoint.y);
|
||||
+ eventSender.mouseDown();
|
||||
+
|
||||
+ const toPoint = computePoint(dragTo);
|
||||
+ eventSender.mouseMoveTo(toPoint.x, toPoint.y);
|
||||
+ eventSender.mouseUp();
|
||||
+
|
||||
+ assert_true(dragged, 'Element should be dragged');
|
||||
+
|
||||
+ // The 'error' event is dispatched asynchronously.
|
||||
+ await new Promise(resolve => test.step_timeout(resolve, 100));
|
||||
+ assert_false(executed, 'Script should be blocked');
|
||||
+}, 'Script in SVG use href should be sanitized');
|
||||
+</script>
|
||||
68
patches/chromium/cherry-pick-f1504440487f.patch
Normal file
68
patches/chromium/cherry-pick-f1504440487f.patch
Normal file
@@ -0,0 +1,68 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Justin Novosad <junov@chromium.org>
|
||||
Date: Thu, 2 Jun 2022 19:35:57 +0000
|
||||
Subject: PaintOpReader: Harden PaintImage deserialization
|
||||
|
||||
This fix prevents the deserialization of PaintImage pixel data from
|
||||
reading data out of bounds when the block of serialized pixel data isn't
|
||||
large enough to cover the expected amount of data, given the size and
|
||||
format of the image.
|
||||
|
||||
(cherry picked from commit e89ea1489429a9a9e49e70d5d4e8d018fbafb6ac)
|
||||
|
||||
Bug: 1325298
|
||||
Change-Id: Icbeb405d2031d7d8ce4537836d7996ce7885f6d1
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3669596
|
||||
Commit-Queue: Justin Novosad <junov@chromium.org>
|
||||
Reviewed-by: Jonathan Ross <jonross@chromium.org>
|
||||
Cr-Original-Commit-Position: refs/heads/main@{#1007804}
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3687975
|
||||
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
|
||||
Reviewed-by: Justin Novosad <junov@chromium.org>
|
||||
Auto-Submit: Srinivas Sista <srinivassista@chromium.org>
|
||||
Commit-Queue: Srinivas Sista <srinivassista@chromium.org>
|
||||
Cr-Commit-Position: refs/branch-heads/5005@{#1093}
|
||||
Cr-Branched-From: 5b4d9450fee01f821b6400e947b3839727643a71-refs/heads/main@{#992738}
|
||||
|
||||
diff --git a/cc/paint/paint_op_reader.cc b/cc/paint/paint_op_reader.cc
|
||||
index c56e2ea7a641d679feb348b808519dd17b861081..ecc736b61defabd7cea081b3017bbeda9aeaf0e9 100644
|
||||
--- a/cc/paint/paint_op_reader.cc
|
||||
+++ b/cc/paint/paint_op_reader.cc
|
||||
@@ -329,6 +329,10 @@ void PaintOpReader::Read(PaintImage* image) {
|
||||
|
||||
SkImageInfo image_info =
|
||||
SkImageInfo::Make(width, height, color_type, kPremul_SkAlphaType);
|
||||
+ if (pixel_size < image_info.computeMinByteSize()) {
|
||||
+ SetInvalid(DeserializationError::kInsufficientPixelData);
|
||||
+ return;
|
||||
+ }
|
||||
const volatile void* pixel_data = ExtractReadableMemory(pixel_size);
|
||||
if (!valid_)
|
||||
return;
|
||||
diff --git a/cc/paint/paint_op_reader.h b/cc/paint/paint_op_reader.h
|
||||
index 201cdfde5eea3a07e31a3d6a50a5119485d5c1fc..af784145a9365ea2f776a1020145c0b83c63f16d 100644
|
||||
--- a/cc/paint/paint_op_reader.h
|
||||
+++ b/cc/paint/paint_op_reader.h
|
||||
@@ -180,8 +180,9 @@ class CC_PAINT_EXPORT PaintOpReader {
|
||||
kSharedImageProviderNoAccess = 50,
|
||||
kSharedImageProviderSkImageCreationFailed = 51,
|
||||
kZeroSkColorFilterBytes = 52,
|
||||
+ kInsufficientPixelData = 53,
|
||||
|
||||
- kMaxValue = kZeroSkColorFilterBytes,
|
||||
+ kMaxValue = kInsufficientPixelData
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml
|
||||
index 0a822d8a7d59debfb250b98f2a2079f256715b52..34569a0fcd539bca6b465e0555c8d44677f57447 100644
|
||||
--- a/tools/metrics/histograms/enums.xml
|
||||
+++ b/tools/metrics/histograms/enums.xml
|
||||
@@ -68766,6 +68766,7 @@ Called by update_net_trust_anchors.py.-->
|
||||
<int value="50" label="SharedImageProvider no access"/>
|
||||
<int value="51" label="SharedImageProvider SkImage creation failed"/>
|
||||
<int value="52" label="Zero SkColorFilter bytes"/>
|
||||
+ <int value="53" label="Insufficient Pixel Data"/>
|
||||
</enum>
|
||||
|
||||
<enum name="PaletteModeCancelType">
|
||||
230
patches/chromium/cherry-pick-f1dd785e021e.patch
Normal file
230
patches/chromium/cherry-pick-f1dd785e021e.patch
Normal file
@@ -0,0 +1,230 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Austin Sullivan <asully@chromium.org>
|
||||
Date: Mon, 16 May 2022 18:20:27 +0000
|
||||
Subject: M102: FSA: Sanitize .scf files
|
||||
|
||||
.scf files can be used to execute code without opening the file.
|
||||
Sanitize these files the same way we sanitize .lnk files.
|
||||
|
||||
Also updates filename sanitization logic to be consistent in blocking
|
||||
.lnk and .local extensions on all OSes.
|
||||
|
||||
(cherry picked from commit 988164c6c4a563c3d4c0dedba295d09472dfc15f)
|
||||
|
||||
Bug: 1227995
|
||||
Change-Id: I4b018f1ba524c783547e18630db9addc9fb126e6
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3089422
|
||||
Reviewed-by: Marijn Kruisselbrink <mek@chromium.org>
|
||||
Commit-Queue: Marijn Kruisselbrink <mek@chromium.org>
|
||||
Cr-Original-Commit-Position: refs/heads/main@{#1002147}
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3648322
|
||||
Auto-Submit: Austin Sullivan <asully@chromium.org>
|
||||
Commit-Queue: Austin Sullivan <asully@chromium.org>
|
||||
Cr-Commit-Position: refs/branch-heads/5005@{#759}
|
||||
Cr-Branched-From: 5b4d9450fee01f821b6400e947b3839727643a71-refs/heads/main@{#992738}
|
||||
|
||||
diff --git a/content/browser/file_system_access/file_system_access_directory_handle_impl.cc b/content/browser/file_system_access/file_system_access_directory_handle_impl.cc
|
||||
index 56863d50d543470de597e8df62e2f5b43b7b0fbe..df922b5a6cb917457570bb0f11a48d7a1710c627 100644
|
||||
--- a/content/browser/file_system_access/file_system_access_directory_handle_impl.cc
|
||||
+++ b/content/browser/file_system_access/file_system_access_directory_handle_impl.cc
|
||||
@@ -438,10 +438,13 @@ namespace {
|
||||
bool IsShellIntegratedExtension(const base::FilePath::StringType& extension) {
|
||||
base::FilePath::StringType extension_lower = base::ToLowerASCII(extension);
|
||||
|
||||
- // .lnk files may be used to execute arbitrary code (see
|
||||
- // https://nvd.nist.gov/vuln/detail/CVE-2010-2568).
|
||||
- if (extension_lower == FILE_PATH_LITERAL("lnk"))
|
||||
+ // .lnk and .scf files may be used to execute arbitrary code (see
|
||||
+ // https://nvd.nist.gov/vuln/detail/CVE-2010-2568 and
|
||||
+ // https://crbug.com/1227995, respectively).
|
||||
+ if (extension_lower == FILE_PATH_LITERAL("lnk") ||
|
||||
+ extension_lower == FILE_PATH_LITERAL("scf")) {
|
||||
return true;
|
||||
+ }
|
||||
|
||||
// Setting a file's extension to a CLSID may conceal its actual file type on
|
||||
// some Windows versions (see https://nvd.nist.gov/vuln/detail/CVE-2004-0420).
|
||||
diff --git a/content/browser/file_system_access/file_system_access_manager_impl.cc b/content/browser/file_system_access/file_system_access_manager_impl.cc
|
||||
index b265ba0f405cecc03cbcc1c0b217204d3e7b25f6..689f7fc7093b5483fa36af5fd7832a25adf9c23b 100644
|
||||
--- a/content/browser/file_system_access/file_system_access_manager_impl.cc
|
||||
+++ b/content/browser/file_system_access/file_system_access_manager_impl.cc
|
||||
@@ -530,6 +530,16 @@ void FileSystemAccessManagerImpl::SetDefaultPathAndShowPicker(
|
||||
suggested_name_path =
|
||||
net::GenerateFileName(GURL(), std::string(), std::string(),
|
||||
suggested_name, std::string(), std::string());
|
||||
+
|
||||
+ auto suggested_extension = suggested_name_path.Extension();
|
||||
+ // Our version of `IsShellIntegratedExtension()` is more stringent than
|
||||
+ // the version used in `net::GenerateFileName()`. See
|
||||
+ // `FileSystemChooser::IsShellIntegratedExtension()` for details.
|
||||
+ if (FileSystemChooser::IsShellIntegratedExtension(suggested_extension)) {
|
||||
+ suggested_extension = FILE_PATH_LITERAL("download");
|
||||
+ suggested_name_path =
|
||||
+ suggested_name_path.ReplaceExtension(suggested_extension);
|
||||
+ }
|
||||
}
|
||||
|
||||
FileSystemChooser::Options file_system_chooser_options(
|
||||
diff --git a/content/browser/file_system_access/file_system_chooser.cc b/content/browser/file_system_access/file_system_chooser.cc
|
||||
index 6f0acccd3458ed758dbe14c8a3008a52569d8055..86b9af148a86e64f9f4aedb6e39998bf83668745 100644
|
||||
--- a/content/browser/file_system_access/file_system_chooser.cc
|
||||
+++ b/content/browser/file_system_access/file_system_chooser.cc
|
||||
@@ -71,33 +71,6 @@ base::FilePath::StringType GetLastExtension(
|
||||
: extension;
|
||||
}
|
||||
|
||||
-// Returns whether the specified extension receives special handling by the
|
||||
-// Windows shell.
|
||||
-bool IsShellIntegratedExtension(const base::FilePath::StringType& extension) {
|
||||
- // TODO(https://crbug.com/1154757): Figure out some way to unify this with
|
||||
- // net::IsSafePortablePathComponent, with the result probably ending up in
|
||||
- // base/i18n/file_util_icu.h.
|
||||
- base::FilePath::StringType extension_lower = base::ToLowerASCII(extension);
|
||||
-
|
||||
- // .lnk files may be used to execute arbitrary code (see
|
||||
- // https://nvd.nist.gov/vuln/detail/CVE-2010-2568). .local files are used by
|
||||
- // Windows to determine which DLLs to load for an application.
|
||||
- if ((extension_lower == FILE_PATH_LITERAL("local")) ||
|
||||
- (extension_lower == FILE_PATH_LITERAL("lnk"))) {
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
- // Setting a file's extension to a CLSID may conceal its actual file type on
|
||||
- // some Windows versions (see https://nvd.nist.gov/vuln/detail/CVE-2004-0420).
|
||||
- if (!extension_lower.empty() &&
|
||||
- (extension_lower.front() == FILE_PATH_LITERAL('{')) &&
|
||||
- (extension_lower.back() == FILE_PATH_LITERAL('}'))) {
|
||||
- return true;
|
||||
- }
|
||||
-
|
||||
- return false;
|
||||
-}
|
||||
-
|
||||
// Extension validation primarily takes place in the renderer. This checks for a
|
||||
// subset of invalid extensions in the event the renderer is compromised.
|
||||
bool IsInvalidExtension(base::FilePath::StringType& extension) {
|
||||
@@ -105,7 +78,7 @@ bool IsInvalidExtension(base::FilePath::StringType& extension) {
|
||||
auto extension16 = base::UTF8ToUTF16(component8);
|
||||
|
||||
return !base::i18n::IsFilenameLegal(extension16) ||
|
||||
- IsShellIntegratedExtension(GetLastExtension(extension));
|
||||
+ FileSystemChooser::IsShellIntegratedExtension(extension);
|
||||
}
|
||||
|
||||
// Converts the accepted mime types and extensions from `option` into a list
|
||||
@@ -290,6 +263,40 @@ void FileSystemChooser::CreateAndShow(
|
||||
/*params=*/nullptr);
|
||||
}
|
||||
|
||||
+// static
|
||||
+bool FileSystemChooser::IsShellIntegratedExtension(
|
||||
+ const base::FilePath::StringType& extension) {
|
||||
+ // TODO(https://crbug.com/1154757): Figure out some way to unify this with
|
||||
+ // net::IsSafePortablePathComponent, with the result probably ending up in
|
||||
+ // base/i18n/file_util_icu.h.
|
||||
+ // - For the sake of consistency across platforms, we sanitize '.lnk' and
|
||||
+ // '.local' files on all platforms (not just Windows)
|
||||
+ // - There are some extensions (i.e. '.scf') we would like to sanitize which
|
||||
+ // `net::GenerateFileName()` does not
|
||||
+ base::FilePath::StringType extension_lower =
|
||||
+ base::ToLowerASCII(GetLastExtension(extension));
|
||||
+
|
||||
+ // .lnk and .scf files may be used to execute arbitrary code (see
|
||||
+ // https://nvd.nist.gov/vuln/detail/CVE-2010-2568 and
|
||||
+ // https://crbug.com/1227995, respectively). .local files are used by Windows
|
||||
+ // to determine which DLLs to load for an application.
|
||||
+ if ((extension_lower == FILE_PATH_LITERAL("lnk")) ||
|
||||
+ (extension_lower == FILE_PATH_LITERAL("local")) ||
|
||||
+ (extension_lower == FILE_PATH_LITERAL("scf"))) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ // Setting a file's extension to a CLSID may conceal its actual file type on
|
||||
+ // some Windows versions (see https://nvd.nist.gov/vuln/detail/CVE-2004-0420).
|
||||
+ if (!extension_lower.empty() &&
|
||||
+ (extension_lower.front() == FILE_PATH_LITERAL('{')) &&
|
||||
+ (extension_lower.back() == FILE_PATH_LITERAL('}'))) {
|
||||
+ return true;
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
FileSystemChooser::FileSystemChooser(ui::SelectFileDialog::Type type,
|
||||
ResultCallback callback,
|
||||
base::ScopedClosureRunner fullscreen_block)
|
||||
diff --git a/content/browser/file_system_access/file_system_chooser.h b/content/browser/file_system_access/file_system_chooser.h
|
||||
index 07c8e7fda7d96496f58ed9a9e6cba6558c8c37df..925df7f5ef1d1bb94926afbe29beda248ae5aabc 100644
|
||||
--- a/content/browser/file_system_access/file_system_chooser.h
|
||||
+++ b/content/browser/file_system_access/file_system_chooser.h
|
||||
@@ -68,6 +68,12 @@ class CONTENT_EXPORT FileSystemChooser : public ui::SelectFileDialog::Listener {
|
||||
ResultCallback callback,
|
||||
base::ScopedClosureRunner fullscreen_block);
|
||||
|
||||
+ // Returns whether the specified extension receives special handling by the
|
||||
+ // Windows shell. These extensions should be sanitized before being shown in
|
||||
+ // the "save as" file picker.
|
||||
+ static bool IsShellIntegratedExtension(
|
||||
+ const base::FilePath::StringType& extension);
|
||||
+
|
||||
FileSystemChooser(ui::SelectFileDialog::Type type,
|
||||
ResultCallback callback,
|
||||
base::ScopedClosureRunner fullscreen_block);
|
||||
diff --git a/content/browser/file_system_access/file_system_chooser_browsertest.cc b/content/browser/file_system_access/file_system_chooser_browsertest.cc
|
||||
index dc310d04fb29ed4fa9c9cdac7ab726d4ca9f9f37..9ea4db7807f6bbac799452fd138848b2a650d6fd 100644
|
||||
--- a/content/browser/file_system_access/file_system_chooser_browsertest.cc
|
||||
+++ b/content/browser/file_system_access/file_system_chooser_browsertest.cc
|
||||
@@ -1556,22 +1556,28 @@ IN_PROC_BROWSER_TEST_F(FileSystemChooserBrowserTest, SuggestedName) {
|
||||
name_infos.push_back({"not_matching.jpg", ListValueOf(".txt"), false,
|
||||
"not_matching.jpg", false});
|
||||
|
||||
-#if BUILDFLAG(IS_WIN)
|
||||
- // ".local" and ".lnk" extensions should be sanitized on Windows.
|
||||
+ // ".lnk", ".local", and ".scf" extensions should be sanitized.
|
||||
name_infos.push_back({"dangerous_extension.local", ListValueOf(".local"),
|
||||
true, "dangerous_extension.download", false});
|
||||
name_infos.push_back({"dangerous_extension.lnk", ListValueOf(".lnk"), true,
|
||||
"dangerous_extension.download", false});
|
||||
-#else
|
||||
- // ".local" and ".lnk" extensions should be allowed on other OSes.
|
||||
- // TODO(https://crbug.com/1154757): `expected_exclude_accept_all_option` is
|
||||
- // false here because ".local" and ".lnk" extensions are not allowed in
|
||||
- // `accepts`, but are only sanitized by net::GenerateSafeFileName on Windows.
|
||||
- name_infos.push_back({"dangerous_extension.local", ListValueOf(".local"),
|
||||
- true, "dangerous_extension.local", false});
|
||||
- name_infos.push_back({"dangerous_extension.lnk", ListValueOf(".lnk"), true,
|
||||
- "dangerous_extension.lnk", false});
|
||||
-#endif
|
||||
+ name_infos.push_back({"dangerous_extension.scf", ListValueOf(".scf"), true,
|
||||
+ "dangerous_extension.download", false});
|
||||
+ // Compound extensions ending in a dangerous extension should be sanitized.
|
||||
+ name_infos.push_back({"dangerous_extension.png.local", ListValueOf(".local"),
|
||||
+ true, "dangerous_extension.png.download", false});
|
||||
+ name_infos.push_back({"dangerous_extension.png.lnk", ListValueOf(".lnk"),
|
||||
+ true, "dangerous_extension.png.download", false});
|
||||
+ name_infos.push_back({"dangerous_extension.png.scf", ListValueOf(".scf"),
|
||||
+ true, "dangerous_extension.png.download", false});
|
||||
+ // Compound extensions not ending in a dangerous extension should not be
|
||||
+ // sanitized.
|
||||
+ name_infos.push_back({"dangerous_extension.local.png", ListValueOf(".png"),
|
||||
+ true, "dangerous_extension.local.png", true});
|
||||
+ name_infos.push_back({"dangerous_extension.lnk.png", ListValueOf(".png"),
|
||||
+ true, "dangerous_extension.lnk.png", true});
|
||||
+ name_infos.push_back({"dangerous_extension.scf.png", ListValueOf(".png"),
|
||||
+ true, "dangerous_extension.scf.png", true});
|
||||
// Invalid characters should be sanitized.
|
||||
name_infos.push_back({R"(inv*l:d\\ch%rבאמת!a<ters🤓.txt)",
|
||||
ListValueOf(".txt"), true,
|
||||
diff --git a/content/browser/file_system_access/file_system_chooser_unittest.cc b/content/browser/file_system_access/file_system_chooser_unittest.cc
|
||||
index 373de41cf5ddead27b5e036c1cc14448a731250a..9b27d6305bd00a19d94b5ec49f21a7ecff7ddc48 100644
|
||||
--- a/content/browser/file_system_access/file_system_chooser_unittest.cc
|
||||
+++ b/content/browser/file_system_access/file_system_chooser_unittest.cc
|
||||
@@ -189,7 +189,7 @@ TEST_F(FileSystemChooserTest, IgnoreShellIntegratedExtensions) {
|
||||
accepts.emplace_back(blink::mojom::ChooseFileSystemEntryAcceptsOption::New(
|
||||
u"", std::vector<std::string>({}),
|
||||
std::vector<std::string>(
|
||||
- {"lnk", "foo.lnk", "foo.bar.local", "text", "local"})));
|
||||
+ {"lnk", "foo.lnk", "foo.bar.local", "text", "local", "scf"})));
|
||||
SyncShowDialog(std::move(accepts), /*include_accepts_all=*/false);
|
||||
|
||||
ASSERT_TRUE(dialog_params.file_types);
|
||||
123
patches/chromium/cherry-pick-f3d01ff794dc.patch
Normal file
123
patches/chromium/cherry-pick-f3d01ff794dc.patch
Normal file
@@ -0,0 +1,123 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Alvin Ji <alvinji@chromium.org>
|
||||
Date: Thu, 28 Apr 2022 00:44:28 +0000
|
||||
Subject: Introduce isLowEnergyDevice() for safely downward static_cast from
|
||||
BluetoothDeviceMac to BluetoothLowEnergyDeviceMac
|
||||
|
||||
device/bluetooth/bluetooth_adapter_mac.mm has two non safely downward static_cast BluetoothDevice to BluetoothLowEnergyDeviceMac
|
||||
|
||||
To avoid it, we introduce isLowEnergyDevice() to BluetoothDeviceMac so we could identify LE bluetooth device from classic bluetooth device then safely cast it downward.
|
||||
|
||||
(cherry picked from commit 2582158fc555edee390a050a64c1b89994a6b349)
|
||||
|
||||
Bug: 1318610
|
||||
Change-Id: Iaf082fc2c40270237bbc0b000b80faa7f94b1026
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3601727
|
||||
Reviewed-by: Reilly Grant <reillyg@chromium.org>
|
||||
Commit-Queue: Alvin Ji <alvinji@chromium.org>
|
||||
Cr-Original-Commit-Position: refs/heads/main@{#995419}
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3606585
|
||||
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
|
||||
Cr-Commit-Position: refs/branch-heads/5005@{#217}
|
||||
Cr-Branched-From: 5b4d9450fee01f821b6400e947b3839727643a71-refs/heads/main@{#992738}
|
||||
|
||||
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
|
||||
index 11d8419791f3e45d5242081422d452d4fc703833..012f9ce97d9ed6b00deb718a88f432e053cb3bd1 100644
|
||||
--- a/device/bluetooth/bluetooth_adapter_mac.mm
|
||||
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
|
||||
@@ -774,6 +774,11 @@ CBCentralManagerState GetCBManagerState(CBCentralManager* manager) {
|
||||
DVLOG(1)
|
||||
<< "Central no longer powered on. Notifying of device disconnection.";
|
||||
for (BluetoothDevice* device : GetDevices()) {
|
||||
+ // GetDevices() returns instances of BluetoothClassicDeviceMac and
|
||||
+ // BluetoothLowEnergyDeviceMac. The DidDisconnectPeripheral() method is
|
||||
+ // only available on BluetoothLowEnergyDeviceMac.
|
||||
+ if (!static_cast<BluetoothDeviceMac*>(device)->IsLowEnergyDevice())
|
||||
+ continue;
|
||||
BluetoothLowEnergyDeviceMac* device_mac =
|
||||
static_cast<BluetoothLowEnergyDeviceMac*>(device);
|
||||
if (device_mac->IsGattConnected()) {
|
||||
@@ -911,9 +916,16 @@ CBCentralManagerState GetCBManagerState(CBCentralManager* manager) {
|
||||
BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
|
||||
auto iter = devices_.find(device_address);
|
||||
if (iter == devices_.end()) {
|
||||
- return nil;
|
||||
- }
|
||||
- return static_cast<BluetoothLowEnergyDeviceMac*>(iter->second.get());
|
||||
+ return nullptr;
|
||||
+ }
|
||||
+ // device_mac can be BluetoothClassicDeviceMac* or
|
||||
+ // BluetoothLowEnergyDeviceMac* To return valid BluetoothLowEnergyDeviceMac*
|
||||
+ // we need to first check with IsLowEnergyDevice()
|
||||
+ BluetoothDeviceMac* device_mac =
|
||||
+ static_cast<BluetoothDeviceMac*>(iter->second.get());
|
||||
+ return device_mac->IsLowEnergyDevice()
|
||||
+ ? static_cast<BluetoothLowEnergyDeviceMac*>(device_mac)
|
||||
+ : nullptr;
|
||||
}
|
||||
|
||||
bool BluetoothAdapterMac::DoesCollideWithKnownDevice(
|
||||
diff --git a/device/bluetooth/bluetooth_classic_device_mac.h b/device/bluetooth/bluetooth_classic_device_mac.h
|
||||
index b11dbbdec75ca276c6e9df50a00e4e3a97d5be8c..a7deb96690e2b64ed82ede5ade5591935ec0f308 100644
|
||||
--- a/device/bluetooth/bluetooth_classic_device_mac.h
|
||||
+++ b/device/bluetooth/bluetooth_classic_device_mac.h
|
||||
@@ -82,6 +82,7 @@ class BluetoothClassicDeviceMac : public BluetoothDeviceMac {
|
||||
// Returns the Bluetooth address for the |device|. The returned address has a
|
||||
// normalized format (see below).
|
||||
static std::string GetDeviceAddress(IOBluetoothDevice* device);
|
||||
+ bool IsLowEnergyDevice() override;
|
||||
|
||||
protected:
|
||||
// BluetoothDevice override
|
||||
diff --git a/device/bluetooth/bluetooth_classic_device_mac.mm b/device/bluetooth/bluetooth_classic_device_mac.mm
|
||||
index 210802eec420807c36f5cd95408bb00d9052ea1b..ceeeab4f102ceb1078e9a2b463170a04773404cf 100644
|
||||
--- a/device/bluetooth/bluetooth_classic_device_mac.mm
|
||||
+++ b/device/bluetooth/bluetooth_classic_device_mac.mm
|
||||
@@ -305,4 +305,8 @@ BluetoothUUID ExtractUuid(IOBluetoothSDPDataElement* service_class_data) {
|
||||
base::SysNSStringToUTF8([device addressString]));
|
||||
}
|
||||
|
||||
+bool BluetoothClassicDeviceMac::IsLowEnergyDevice() {
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
} // namespace device
|
||||
diff --git a/device/bluetooth/bluetooth_device_mac.h b/device/bluetooth/bluetooth_device_mac.h
|
||||
index 10245db6516b08a8e50e6637011a3a960440625c..0213e20aee170aae0a4b73e93f47c418110ef289 100644
|
||||
--- a/device/bluetooth/bluetooth_device_mac.h
|
||||
+++ b/device/bluetooth/bluetooth_device_mac.h
|
||||
@@ -30,6 +30,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDeviceMac : public BluetoothDevice {
|
||||
BluetoothGattService::GattErrorCode error_code);
|
||||
static BluetoothGattService::GattErrorCode GetGattErrorCodeFromNSError(
|
||||
NSError* error);
|
||||
+ virtual bool IsLowEnergyDevice() = 0;
|
||||
|
||||
protected:
|
||||
BluetoothDeviceMac(BluetoothAdapterMac* adapter);
|
||||
diff --git a/device/bluetooth/bluetooth_low_energy_device_mac.h b/device/bluetooth/bluetooth_low_energy_device_mac.h
|
||||
index 6db4f57489d65f3363b716c49037c4fac1389f0c..1e5ce4777b37c6a65a64ba5f7d5bb630b2ebe687 100644
|
||||
--- a/device/bluetooth/bluetooth_low_energy_device_mac.h
|
||||
+++ b/device/bluetooth/bluetooth_low_energy_device_mac.h
|
||||
@@ -83,6 +83,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyDeviceMac
|
||||
const device::BluetoothUUID& uuid,
|
||||
ConnectToServiceCallback callback,
|
||||
ConnectToServiceErrorCallback error_callback) override;
|
||||
+ bool IsLowEnergyDevice() override;
|
||||
|
||||
protected:
|
||||
// BluetoothDevice override.
|
||||
diff --git a/device/bluetooth/bluetooth_low_energy_device_mac.mm b/device/bluetooth/bluetooth_low_energy_device_mac.mm
|
||||
index 9a89728b0fc47cd7ca6e20d2ffbe7483010cbe39..73b1bee8e64664bdc98e45869accdf0ade2250b0 100644
|
||||
--- a/device/bluetooth/bluetooth_low_energy_device_mac.mm
|
||||
+++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm
|
||||
@@ -207,6 +207,10 @@ @interface CBPeripheral (HighSierraSDK)
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
+bool BluetoothLowEnergyDeviceMac::IsLowEnergyDevice() {
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
void BluetoothLowEnergyDeviceMac::CreateGattConnectionImpl(
|
||||
absl::optional<BluetoothUUID> serivce_uuid) {
|
||||
if (!IsGattConnected()) {
|
||||
@@ -246,10 +246,10 @@ index c6bd5c19f8a7ceec17c9e32af5296a9617f3a619..02199b439fba7fdc617b7f7980d958b7
|
||||
void AddNewContents(content::WebContents* source,
|
||||
std::unique_ptr<content::WebContents> new_contents,
|
||||
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
|
||||
index 5c63a024827359ccf697d0b7fc8fa2092eb107b7..3da88b5831717c979373c064b4c1520c28d4fd98 100644
|
||||
index 4e78c10d21e08fef2b25ef5a13987c13bc8c204a..d157b82514bc8eec76b9a06f67bb581c5bf24d56 100644
|
||||
--- a/content/browser/web_contents/web_contents_impl.cc
|
||||
+++ b/content/browser/web_contents/web_contents_impl.cc
|
||||
@@ -3873,8 +3873,7 @@ FrameTree* WebContentsImpl::CreateNewWindow(
|
||||
@@ -3882,8 +3882,7 @@ FrameTree* WebContentsImpl::CreateNewWindow(
|
||||
|
||||
if (delegate_ && delegate_->IsWebContentsCreationOverridden(
|
||||
source_site_instance, params.window_container_type,
|
||||
|
||||
@@ -7,7 +7,7 @@ spellchecker uses a few IDS_ resources. We need to load these from
|
||||
Electrons grit header instead of Chromes
|
||||
|
||||
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
|
||||
index ec55c3f97988a7de06a738e61e389ba07712ad4e..6a40a73520a951d7c6fd06cbd07329a40ff41544 100644
|
||||
index 9917fcf771ecbfceaba4c02164de620d2aaf0775..492cd8e11e28e0b427aca227665295a3052af765 100644
|
||||
--- a/chrome/browser/BUILD.gn
|
||||
+++ b/chrome/browser/BUILD.gn
|
||||
@@ -7088,6 +7088,7 @@ static_library("browser") {
|
||||
|
||||
43
patches/chromium/custom_protocols_plzserviceworker.patch
Normal file
43
patches/chromium/custom_protocols_plzserviceworker.patch
Normal file
@@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: deepak1556 <hop2deep@gmail.com>
|
||||
Date: Fri, 20 May 2022 00:29:34 +0900
|
||||
Subject: custom_protocols_plzserviceworker.patch
|
||||
|
||||
Allow registering custom protocols to handle service worker main script fetching with PlzServiceWorker.
|
||||
|
||||
Refs https://bugs.chromium.org/p/chromium/issues/detail?id=996511
|
||||
|
||||
diff --git a/content/browser/service_worker/service_worker_context_wrapper.cc b/content/browser/service_worker/service_worker_context_wrapper.cc
|
||||
index 4ce769314c6dddae41d915c7f05916f77f26a86e..d8f6882f2dee93fc127e7617abbcc7b71a65775d 100644
|
||||
--- a/content/browser/service_worker/service_worker_context_wrapper.cc
|
||||
+++ b/content/browser/service_worker/service_worker_context_wrapper.cc
|
||||
@@ -1600,6 +1600,29 @@ ServiceWorkerContextWrapper::GetLoaderFactoryForBrowserInitiatedRequest(
|
||||
std::unique_ptr<network::PendingSharedURLLoaderFactory>
|
||||
loader_factory_bundle_info =
|
||||
context()->loader_factory_bundle_for_update_check()->Clone();
|
||||
+
|
||||
+ // Give the embedder a chance to register custom schemes that can
|
||||
+ // handle loading the service worker main script.
|
||||
+ // Previous registration triggered by
|
||||
+ // ServiceWorkerContextWrapper::CreateNonNetworkPendingURLLoaderFactoryBundleForUpdateCheck
|
||||
+ // happens early on browser startup before the JS in the main process
|
||||
+ // is run by the embedder.
|
||||
+ auto* factory_bundle = static_cast<blink::PendingURLLoaderFactoryBundle*>(
|
||||
+ loader_factory_bundle_info.get());
|
||||
+ ContentBrowserClient::NonNetworkURLLoaderFactoryMap non_network_factories;
|
||||
+ GetContentClient()
|
||||
+ ->browser()
|
||||
+ ->RegisterNonNetworkServiceWorkerUpdateURLLoaderFactories(
|
||||
+ storage_partition_->browser_context(), &non_network_factories);
|
||||
+ for (auto& pair : non_network_factories) {
|
||||
+ const std::string& scheme = pair.first;
|
||||
+ mojo::PendingRemote<network::mojom::URLLoaderFactory>& factory_remote =
|
||||
+ pair.second;
|
||||
+
|
||||
+ factory_bundle->pending_scheme_specific_factories().emplace(
|
||||
+ scheme, std::move(factory_remote));
|
||||
+ }
|
||||
+
|
||||
static_cast<blink::PendingURLLoaderFactoryBundle*>(
|
||||
loader_factory_bundle_info.get())
|
||||
->pending_default_factory() = std::move(remote);
|
||||
@@ -20,10 +20,10 @@ 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_host_impl.cc b/cc/trees/layer_tree_host_impl.cc
|
||||
index 61ab59e0d97a392ae18c1d7ad7dd606b5cd1c567..2a899818ebb67ba4fc06ccbcff3ee03f6b83c0e6 100644
|
||||
index 3824e500fd88105e9c6d459f23097b2b4f0686ed..927ede7608a5c6992e9f9fb05e4b8e43b7e10cf8 100644
|
||||
--- a/cc/trees/layer_tree_host_impl.cc
|
||||
+++ b/cc/trees/layer_tree_host_impl.cc
|
||||
@@ -1882,6 +1882,9 @@ void LayerTreeHostImpl::SetIsLikelyToRequireADraw(
|
||||
@@ -1889,6 +1889,9 @@ void LayerTreeHostImpl::SetIsLikelyToRequireADraw(
|
||||
TargetColorParams LayerTreeHostImpl::GetTargetColorParams(
|
||||
gfx::ContentColorUsage content_color_usage) const {
|
||||
TargetColorParams params;
|
||||
@@ -240,10 +240,10 @@ index f5d73922086b5b27907fd393d4d4204a574c3b25..5b09f5ef5f04b519ed4148498c82d003
|
||||
sandbox::policy::switches::kGpuSandboxAllowSysVShm,
|
||||
sandbox::policy::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 ac9570fa3d9cb3b0026f70465e5b21ac7778c3df..acc0e121e7746da397cfab07b3707de7ae9a3143 100644
|
||||
index 5f2451eefad211c85460eb457ad3d6e184540d59..d9d8352c6b1b8db8d86ad1ed1d4a3d300a999fa6 100644
|
||||
--- a/content/browser/renderer_host/render_process_host_impl.cc
|
||||
+++ b/content/browser/renderer_host/render_process_host_impl.cc
|
||||
@@ -194,6 +194,7 @@
|
||||
@@ -196,6 +196,7 @@
|
||||
#include "ui/accessibility/accessibility_switches.h"
|
||||
#include "ui/base/ui_base_switches.h"
|
||||
#include "ui/display/display_switches.h"
|
||||
@@ -251,7 +251,7 @@ index ac9570fa3d9cb3b0026f70465e5b21ac7778c3df..acc0e121e7746da397cfab07b3707de7
|
||||
#include "ui/gl/gl_switches.h"
|
||||
#include "url/gurl.h"
|
||||
#include "url/origin.h"
|
||||
@@ -3283,6 +3284,7 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
|
||||
@@ -3293,6 +3294,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[] = {
|
||||
|
||||
@@ -6,7 +6,7 @@ Subject: disable_hidden.patch
|
||||
Electron uses this to disable background throttling for hidden windows.
|
||||
|
||||
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
|
||||
index 03e318b14025f3c971d471351068986f8a1dd14d..59437e69e25fe85cffc9b558dec2284123ac48be 100644
|
||||
index f127b930806bc8e7b6fe8efb89eab6c43466326f..59dda38e5781132472991979d90317dfaa96028f 100644
|
||||
--- a/content/browser/renderer_host/render_widget_host_impl.cc
|
||||
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
|
||||
@@ -803,6 +803,9 @@ void RenderWidgetHostImpl::WasHidden() {
|
||||
|
||||
@@ -33,7 +33,7 @@ index 14c71cc69388da46f62d9835e2a06fef0870da02..9481ea08401ae29ae9c1d960491b05b3
|
||||
|
||||
} // namespace net
|
||||
diff --git a/services/network/network_context.cc b/services/network/network_context.cc
|
||||
index 20373c0e86852446569c401c4a993512cb388fc7..9b6dbdad1a17148303ddecaada17a57d4ea22bb2 100644
|
||||
index a4cd97599e2f131fe0d97ee49a44ed5b748739b7..074ce8a372ad4d54661071cfa37632b5d1bbf067 100644
|
||||
--- a/services/network/network_context.cc
|
||||
+++ b/services/network/network_context.cc
|
||||
@@ -1343,6 +1343,13 @@ void NetworkContext::SetNetworkConditions(
|
||||
@@ -51,7 +51,7 @@ index 20373c0e86852446569c401c4a993512cb388fc7..9b6dbdad1a17148303ddecaada17a57d
|
||||
// This may only be called on NetworkContexts created with the constructor
|
||||
// that calls MakeURLRequestContext().
|
||||
diff --git a/services/network/network_context.h b/services/network/network_context.h
|
||||
index e412608e7720004462c48698c8ec39602b2b900e..46c00e0da6beb0c2e689475fc4b9927085414e1a 100644
|
||||
index 06a36a156501b252e91037ebac45c29c2995f624..cb5435028a537baa5e1dbbab9137e6547b9ed712 100644
|
||||
--- a/services/network/network_context.h
|
||||
+++ b/services/network/network_context.h
|
||||
@@ -282,6 +282,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
|
||||
@@ -63,10 +63,10 @@ index e412608e7720004462c48698c8ec39602b2b900e..46c00e0da6beb0c2e689475fc4b99270
|
||||
void SetEnableReferrers(bool enable_referrers) override;
|
||||
#if BUILDFLAG(IS_CHROMEOS)
|
||||
diff --git a/services/network/public/mojom/network_context.mojom b/services/network/public/mojom/network_context.mojom
|
||||
index fa56cfed3703664232843ad26028096d95dca253..9852498e93939796e7ba6f80efcc7b2d827187ac 100644
|
||||
index ae0a20a7a33e5a313f5545985a34e9cb93220996..aeb0ac8731689e5495ab039d30ac3e88acab9293 100644
|
||||
--- a/services/network/public/mojom/network_context.mojom
|
||||
+++ b/services/network/public/mojom/network_context.mojom
|
||||
@@ -1067,6 +1067,9 @@ interface NetworkContext {
|
||||
@@ -1081,6 +1081,9 @@ interface NetworkContext {
|
||||
SetNetworkConditions(mojo_base.mojom.UnguessableToken throttling_profile_id,
|
||||
NetworkConditions? conditions);
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ Ideally we could add an embedder observer pattern here but that can be
|
||||
done in future work.
|
||||
|
||||
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
index 7e7927c7258963bd95a2c064ef85e410f4d2571d..05353bda1169df38499e6f789bb632307d7bcfde 100644
|
||||
index 182f70b2b3bd9cbc6548d4c17caad797e5dad0ce..f78d5246a9e5f17089d47f95da22e922b6699057 100644
|
||||
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
@@ -158,6 +158,7 @@
|
||||
|
||||
@@ -1,25 +1,19 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Raymond Zhao <raymondzhao@microsoft.com>
|
||||
Date: Tue, 7 Sep 2021 14:54:25 -0700
|
||||
Subject: feat: Add data transfer mechanism to requestSingleInstanceLock flow
|
||||
Subject: feat: Add data parameter to ProcessSingleton
|
||||
|
||||
This patch adds code that allows for the second instance to send
|
||||
additional data to the first instance, and for the first instance
|
||||
to send additional data back to the second instance, during the
|
||||
app.requestSingleInstanceLock call.
|
||||
This patch adds an additional_data parameter to the constructor of
|
||||
ProcessSingleton, so that the second instance can send additional
|
||||
data over to the first instance while requesting the ProcessSingleton
|
||||
lock.
|
||||
|
||||
Firstly, this patch adds an additional_data parameter
|
||||
to the constructor of ProcessSingleton, so that the second instance
|
||||
can send additional data over to the first instance
|
||||
while requesting the ProcessSingleton lock.
|
||||
|
||||
Then, we add additional processing to the second-instance event, both
|
||||
so the first instance can receive additional data from the second
|
||||
instance, but also so the second instance can send back additional
|
||||
data to the first instance if needed.
|
||||
On the Electron side, we then expose an extra parameter to the
|
||||
app.requestSingleInstanceLock API so that users can pass in a JSON
|
||||
object for the second instance to send to the first instance.
|
||||
|
||||
diff --git a/chrome/browser/process_singleton.h b/chrome/browser/process_singleton.h
|
||||
index 5a64220aaf1309832dc0ad543e353de67fe0a779..a568dd10d1ef8679d66f4cdc6a471c251cbcd4eb 100644
|
||||
index 5a64220aaf1309832dc0ad543e353de67fe0a779..e75c4f0d7cf1cac2e5862eb858800359e2001eb6 100644
|
||||
--- a/chrome/browser/process_singleton.h
|
||||
+++ b/chrome/browser/process_singleton.h
|
||||
@@ -18,6 +18,7 @@
|
||||
@@ -30,39 +24,26 @@ index 5a64220aaf1309832dc0ad543e353de67fe0a779..a568dd10d1ef8679d66f4cdc6a471c25
|
||||
#include "ui/gfx/native_widget_types.h"
|
||||
|
||||
#if BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)
|
||||
@@ -93,6 +94,9 @@ class ProcessSingleton {
|
||||
|
||||
static constexpr int kNumNotifyResults = LAST_VALUE + 1;
|
||||
|
||||
+ using NotificationAckCallback =
|
||||
+ base::RepeatingCallback<void(const base::span<const uint8_t>* ack_data)>;
|
||||
+
|
||||
// Implement this callback to handle notifications from other processes. The
|
||||
// callback will receive the command line and directory with which the other
|
||||
// Chrome process was launched. Return true if the command line will be
|
||||
@@ -100,21 +104,27 @@ class ProcessSingleton {
|
||||
@@ -99,22 +100,25 @@ class ProcessSingleton {
|
||||
// handled within the current browser instance or false if the remote process
|
||||
// should handle it (i.e., because the current process is shutting down).
|
||||
using NotificationCallback =
|
||||
base::RepeatingCallback<bool(const base::CommandLine& command_line,
|
||||
- base::RepeatingCallback<bool(const base::CommandLine& command_line,
|
||||
- const base::FilePath& current_directory)>;
|
||||
+ base::RepeatingCallback<bool(const base::CommandLine& command_line,
|
||||
+ const base::FilePath& current_directory,
|
||||
+ const std::vector<const uint8_t> additional_data,
|
||||
+ const NotificationAckCallback& ack_callback)>;
|
||||
+ const std::vector<const uint8_t> additional_data)>;
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
ProcessSingleton(const std::string& program_name,
|
||||
const base::FilePath& user_data_dir,
|
||||
+ const base::span<const uint8_t> additional_data,
|
||||
bool is_sandboxed,
|
||||
- const NotificationCallback& notification_callback);
|
||||
+ const NotificationCallback& notification_callback,
|
||||
+ const NotificationAckCallback& ack_notification_callback);
|
||||
const NotificationCallback& notification_callback);
|
||||
#else
|
||||
ProcessSingleton(const base::FilePath& user_data_dir,
|
||||
- const NotificationCallback& notification_callback);
|
||||
+ const base::span<const uint8_t> additional_data,
|
||||
+ const NotificationCallback& notification_callback,
|
||||
+ const NotificationAckCallback& ack_notification_callback);
|
||||
const NotificationCallback& notification_callback);
|
||||
+#endif
|
||||
|
||||
ProcessSingleton(const ProcessSingleton&) = delete;
|
||||
@@ -72,42 +53,22 @@ index 5a64220aaf1309832dc0ad543e353de67fe0a779..a568dd10d1ef8679d66f4cdc6a471c25
|
||||
~ProcessSingleton();
|
||||
|
||||
// Notify another process, if available. Otherwise sets ourselves as the
|
||||
@@ -177,7 +187,13 @@ class ProcessSingleton {
|
||||
@@ -177,7 +181,10 @@ class ProcessSingleton {
|
||||
#endif
|
||||
|
||||
private:
|
||||
- NotificationCallback notification_callback_; // Handler for notifications.
|
||||
+ // A callback to run when the first instance receives data from the second.
|
||||
+ NotificationCallback notification_callback_;
|
||||
+ // A callback to run when the second instance
|
||||
+ // receives an acknowledgement from the first.
|
||||
+ NotificationAckCallback notification_ack_callback_;
|
||||
+ // Custom data to pass to the other instance during notify.
|
||||
+ base::span<const uint8_t> additional_data_;
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
bool EscapeVirtualization(const base::FilePath& user_data_dir);
|
||||
@@ -190,6 +206,7 @@ class ProcessSingleton {
|
||||
HANDLE lock_file_;
|
||||
base::FilePath user_data_dir_;
|
||||
ShouldKillRemoteProcessCallback should_kill_remote_process_callback_;
|
||||
+ HANDLE ack_pipe_;
|
||||
#elif BUILDFLAG(IS_POSIX) && !BUILDFLAG(IS_ANDROID)
|
||||
// Return true if the given pid is one of our child processes.
|
||||
// Assumes that the current pid is the root of all pids of the current
|
||||
diff --git a/chrome/browser/process_singleton_posix.cc b/chrome/browser/process_singleton_posix.cc
|
||||
index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..b23c16fde275fdba559abb1f30e42f65ddbfc332 100644
|
||||
index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..a3e45e9baa09bfc87be5b7ff589ac76841c686d4 100644
|
||||
--- a/chrome/browser/process_singleton_posix.cc
|
||||
+++ b/chrome/browser/process_singleton_posix.cc
|
||||
@@ -148,7 +148,7 @@ const char kACKToken[] = "ACK";
|
||||
const char kShutdownToken[] = "SHUTDOWN";
|
||||
const char kTokenDelimiter = '\0';
|
||||
const int kMaxMessageLength = 32 * 1024;
|
||||
-const int kMaxACKMessageLength = base::size(kShutdownToken) - 1;
|
||||
+const int kMaxACKMessageLength = kMaxMessageLength;
|
||||
|
||||
bool g_disable_prompt = false;
|
||||
bool g_skip_is_chrome_process_check = false;
|
||||
@@ -614,6 +614,7 @@ class ProcessSingleton::LinuxWatcher
|
||||
// |reader| is for sending back ACK message.
|
||||
void HandleMessage(const std::string& current_dir,
|
||||
@@ -116,17 +77,7 @@ index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..b23c16fde275fdba559abb1f30e42f65
|
||||
SocketReader* reader);
|
||||
|
||||
private:
|
||||
@@ -638,6 +639,9 @@ class ProcessSingleton::LinuxWatcher
|
||||
// The ProcessSingleton that owns us.
|
||||
ProcessSingleton* const parent_;
|
||||
|
||||
+ bool ack_callback_called_ = false;
|
||||
+ void AckCallback(SocketReader* reader, const base::span<const uint8_t>* response);
|
||||
+
|
||||
std::set<std::unique_ptr<SocketReader>, base::UniquePtrComparator> readers_;
|
||||
};
|
||||
|
||||
@@ -668,16 +672,21 @@ void ProcessSingleton::LinuxWatcher::StartListening(int socket) {
|
||||
@@ -668,13 +669,16 @@ void ProcessSingleton::LinuxWatcher::StartListening(int socket) {
|
||||
}
|
||||
|
||||
void ProcessSingleton::LinuxWatcher::HandleMessage(
|
||||
@@ -138,46 +89,14 @@ index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..b23c16fde275fdba559abb1f30e42f65
|
||||
DCHECK(ui_task_runner_->BelongsToCurrentThread());
|
||||
DCHECK(reader);
|
||||
|
||||
- if (parent_->notification_callback_.Run(base::CommandLine(argv),
|
||||
if (parent_->notification_callback_.Run(base::CommandLine(argv),
|
||||
- base::FilePath(current_dir))) {
|
||||
- // Send back "ACK" message to prevent the client process from starting up.
|
||||
- reader->FinishWithACK(kACKToken, base::size(kACKToken) - 1);
|
||||
- } else {
|
||||
+ auto wrapped_ack_callback =
|
||||
+ base::BindRepeating(&ProcessSingleton::LinuxWatcher::AckCallback,
|
||||
+ base::Unretained(this), reader);
|
||||
+ ack_callback_called_ = false;
|
||||
+ if (!parent_->notification_callback_.Run(base::CommandLine(argv),
|
||||
+ base::FilePath(current_dir),
|
||||
+ std::move(additional_data),
|
||||
+ wrapped_ack_callback)) {
|
||||
LOG(WARNING) << "Not handling interprocess notification as browser"
|
||||
" is shutting down";
|
||||
// Send back "SHUTDOWN" message, so that the client process can start up
|
||||
@@ -687,6 +696,22 @@ void ProcessSingleton::LinuxWatcher::HandleMessage(
|
||||
}
|
||||
}
|
||||
|
||||
+void ProcessSingleton::LinuxWatcher::AckCallback(
|
||||
+ SocketReader* reader,
|
||||
+ const base::span<const uint8_t>* response) {
|
||||
+ // Send back "ACK" message to prevent the client process from starting up.
|
||||
+ if (!ack_callback_called_) {
|
||||
+ ack_callback_called_ = true;
|
||||
+ std::string ack_message;
|
||||
+ ack_message.append(kACKToken, base::size(kACKToken) - 1);
|
||||
+ if (response && response->size_bytes()) {
|
||||
+ ack_message.append(reinterpret_cast<const char*>(response->data()),
|
||||
+ response->size_bytes());
|
||||
+ }
|
||||
+ reader->FinishWithACK(ack_message.c_str(), ack_message.size());
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
void ProcessSingleton::LinuxWatcher::RemoveSocketReader(SocketReader* reader) {
|
||||
DCHECK_CURRENTLY_ON(BrowserThread::IO);
|
||||
DCHECK(reader);
|
||||
@@ -722,7 +747,8 @@ void ProcessSingleton::LinuxWatcher::SocketReader::
|
||||
+ std::move(additional_data))) {
|
||||
// Send back "ACK" message to prevent the client process from starting up.
|
||||
reader->FinishWithACK(kACKToken, base::size(kACKToken) - 1);
|
||||
} else {
|
||||
@@ -722,7 +726,8 @@ void ProcessSingleton::LinuxWatcher::SocketReader::
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,7 +106,7 @@ index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..b23c16fde275fdba559abb1f30e42f65
|
||||
const size_t kMinMessageLength = base::size(kStartToken) + 4;
|
||||
if (bytes_read_ < kMinMessageLength) {
|
||||
buf_[bytes_read_] = 0;
|
||||
@@ -752,10 +778,28 @@ void ProcessSingleton::LinuxWatcher::SocketReader::
|
||||
@@ -752,10 +757,28 @@ void ProcessSingleton::LinuxWatcher::SocketReader::
|
||||
tokens.erase(tokens.begin());
|
||||
tokens.erase(tokens.begin());
|
||||
|
||||
@@ -204,8 +123,8 @@ index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..b23c16fde275fdba559abb1f30e42f65
|
||||
+ std::string(1, kTokenDelimiter));
|
||||
+ const uint8_t* additional_data_bits =
|
||||
+ reinterpret_cast<const uint8_t*>(remaining_args.c_str());
|
||||
+ additional_data = std::vector<const uint8_t>(additional_data_bits,
|
||||
+ additional_data_bits + additional_data_size);
|
||||
+ additional_data = std::vector<const uint8_t>(
|
||||
+ additional_data_bits, additional_data_bits + additional_data_size);
|
||||
+ }
|
||||
+
|
||||
// Return to the UI thread to handle opening a new browser tab.
|
||||
@@ -217,21 +136,18 @@ index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..b23c16fde275fdba559abb1f30e42f65
|
||||
fd_watch_controller_.reset();
|
||||
|
||||
// LinuxWatcher::HandleMessage() is in charge of destroying this SocketReader
|
||||
@@ -784,8 +828,12 @@ void ProcessSingleton::LinuxWatcher::SocketReader::FinishWithACK(
|
||||
@@ -784,8 +807,10 @@ void ProcessSingleton::LinuxWatcher::SocketReader::FinishWithACK(
|
||||
//
|
||||
ProcessSingleton::ProcessSingleton(
|
||||
const base::FilePath& user_data_dir,
|
||||
- const NotificationCallback& notification_callback)
|
||||
+ const base::span<const uint8_t> additional_data,
|
||||
+ const NotificationCallback& notification_callback,
|
||||
+ const NotificationAckCallback& notification_ack_callback)
|
||||
const NotificationCallback& notification_callback)
|
||||
: notification_callback_(notification_callback),
|
||||
+ notification_ack_callback_(notification_ack_callback),
|
||||
+ additional_data_(additional_data),
|
||||
current_pid_(base::GetCurrentProcId()),
|
||||
watcher_(new LinuxWatcher(this)) {
|
||||
socket_path_ = user_data_dir.Append(chrome::kSingletonSocketFilename);
|
||||
@@ -904,7 +952,8 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
|
||||
@@ -904,7 +929,8 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
|
||||
sizeof(socket_timeout));
|
||||
|
||||
// Found another process, prepare our command line
|
||||
@@ -241,7 +157,7 @@ index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..b23c16fde275fdba559abb1f30e42f65
|
||||
std::string to_send(kStartToken);
|
||||
to_send.push_back(kTokenDelimiter);
|
||||
|
||||
@@ -914,11 +963,21 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
|
||||
@@ -914,11 +940,21 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
|
||||
to_send.append(current_dir.value());
|
||||
|
||||
const std::vector<std::string>& argv = cmd_line.argv();
|
||||
@@ -263,52 +179,11 @@ index 7d3a441bdb64268ed5fbfa7bf589fb35a2fd1b75..b23c16fde275fdba559abb1f30e42f65
|
||||
// Send the message
|
||||
if (!WriteToSocket(socket.fd(), to_send.data(), to_send.length())) {
|
||||
// Try to kill the other process, because it might have been dead.
|
||||
@@ -960,6 +1019,17 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcessWithTimeout(
|
||||
linux_ui->NotifyWindowManagerStartupComplete();
|
||||
#endif
|
||||
|
||||
+ size_t ack_data_len = len - (base::size(kACKToken) - 1);
|
||||
+ if (ack_data_len) {
|
||||
+ const uint8_t* raw_ack_data =
|
||||
+ reinterpret_cast<const uint8_t*>(buf + base::size(kACKToken) - 1);
|
||||
+ base::span<const uint8_t> ack_data =
|
||||
+ base::make_span(raw_ack_data, raw_ack_data + ack_data_len);
|
||||
+ notification_ack_callback_.Run(&ack_data);
|
||||
+ } else {
|
||||
+ notification_ack_callback_.Run(nullptr);
|
||||
+ }
|
||||
+
|
||||
// Assume the other process is handling the request.
|
||||
return PROCESS_NOTIFIED;
|
||||
}
|
||||
diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc
|
||||
index 0ea5eb3e3cf055d981ab73486115bac53287f2d7..268be8c0334a4bc051ff08792ea0dc3d0c912034 100644
|
||||
index 0ea5eb3e3cf055d981ab73486115bac53287f2d7..fe68beb4b2522d27e07dbbb3341f100f14494680 100644
|
||||
--- a/chrome/browser/process_singleton_win.cc
|
||||
+++ b/chrome/browser/process_singleton_win.cc
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/time/time.h"
|
||||
+#include "base/timer/timer.h"
|
||||
#include "base/trace_event/base_tracing.h"
|
||||
#include "base/win/registry.h"
|
||||
#include "base/win/scoped_handle.h"
|
||||
@@ -45,6 +46,14 @@
|
||||
namespace {
|
||||
|
||||
const char kLockfile[] = "lockfile";
|
||||
+const LPCWSTR kPipeName = L"\\\\.\\pipe\\electronAckPipe";
|
||||
+const DWORD kPipeTimeout = 10000;
|
||||
+const DWORD kMaxMessageLength = 32 * 1024;
|
||||
+
|
||||
+std::unique_ptr<std::vector<const uint8_t>> g_ack_data;
|
||||
+base::OneShotTimer g_ack_timer;
|
||||
+HANDLE g_write_ack_pipe;
|
||||
+bool g_write_ack_callback_called = false;
|
||||
|
||||
// A helper class that acquires the given |mutex| while the AutoLockMutex is in
|
||||
// scope.
|
||||
@@ -80,10 +89,12 @@ BOOL CALLBACK BrowserWindowEnumeration(HWND window, LPARAM param) {
|
||||
@@ -80,10 +80,12 @@ BOOL CALLBACK BrowserWindowEnumeration(HWND window, LPARAM param) {
|
||||
|
||||
bool ParseCommandLine(const COPYDATASTRUCT* cds,
|
||||
base::CommandLine* parsed_command_line,
|
||||
@@ -323,7 +198,7 @@ index 0ea5eb3e3cf055d981ab73486115bac53287f2d7..268be8c0334a4bc051ff08792ea0dc3d
|
||||
static const int min_message_size = 7;
|
||||
if (cds->cbData < min_message_size * sizeof(wchar_t) ||
|
||||
cds->cbData % sizeof(wchar_t) != 0) {
|
||||
@@ -133,11 +144,82 @@ bool ParseCommandLine(const COPYDATASTRUCT* cds,
|
||||
@@ -133,6 +135,37 @@ bool ParseCommandLine(const COPYDATASTRUCT* cds,
|
||||
const std::wstring cmd_line =
|
||||
msg.substr(second_null + 1, third_null - second_null);
|
||||
*parsed_command_line = base::CommandLine::FromString(cmd_line);
|
||||
@@ -361,175 +236,50 @@ index 0ea5eb3e3cf055d981ab73486115bac53287f2d7..268be8c0334a4bc051ff08792ea0dc3d
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -154,13 +187,14 @@ bool ProcessLaunchNotification(
|
||||
|
||||
+void StoreAck(const base::span<const uint8_t>* ack_data) {
|
||||
+ if (ack_data) {
|
||||
+ g_ack_data = std::make_unique<std::vector<const uint8_t>>(ack_data->begin(),
|
||||
+ ack_data->end());
|
||||
+ } else {
|
||||
+ g_ack_data = nullptr;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void SendBackAck() {
|
||||
+ // This is the first instance sending the ack back to the second instance.
|
||||
+ if (!g_write_ack_callback_called) {
|
||||
+ g_write_ack_callback_called = true;
|
||||
+ const uint8_t* data_buffer = nullptr;
|
||||
+ DWORD data_to_send_size = 0;
|
||||
+ if (g_ack_data) {
|
||||
+ data_buffer = g_ack_data->data();
|
||||
+ DWORD ack_data_size = g_ack_data->size() * sizeof(uint8_t);
|
||||
+ data_to_send_size = (ack_data_size < kMaxMessageLength) ? ack_data_size : kMaxMessageLength;
|
||||
+ }
|
||||
+
|
||||
+ ::ConnectNamedPipe(g_write_ack_pipe, NULL);
|
||||
+
|
||||
+ DWORD bytes_written = 0;
|
||||
+ ::WriteFile(g_write_ack_pipe,
|
||||
+ (LPCVOID)data_buffer,
|
||||
+ data_to_send_size,
|
||||
+ &bytes_written,
|
||||
+ NULL);
|
||||
+ DCHECK(bytes_written == data_to_send_size);
|
||||
+
|
||||
+ ::FlushFileBuffers(g_write_ack_pipe);
|
||||
+ ::DisconnectNamedPipe(g_write_ack_pipe);
|
||||
+
|
||||
+ if (g_ack_data) {
|
||||
+ g_ack_data.reset();
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
bool ProcessLaunchNotification(
|
||||
const ProcessSingleton::NotificationCallback& notification_callback,
|
||||
UINT message,
|
||||
@@ -151,16 +233,23 @@ bool ProcessLaunchNotification(
|
||||
|
||||
// Handle the WM_COPYDATA message from another process.
|
||||
const COPYDATASTRUCT* cds = reinterpret_cast<COPYDATASTRUCT*>(lparam);
|
||||
-
|
||||
base::CommandLine parsed_command_line(base::CommandLine::NO_PROGRAM);
|
||||
base::FilePath current_directory;
|
||||
- if (!ParseCommandLine(cds, &parsed_command_line, ¤t_directory)) {
|
||||
+ std::vector<const uint8_t> additional_data;
|
||||
+ if (!ParseCommandLine(cds, &parsed_command_line, ¤t_directory,
|
||||
+ &additional_data)) {
|
||||
+ if (!ParseCommandLine(cds, &parsed_command_line, ¤t_directory, &additional_data)) {
|
||||
*result = TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
- *result = notification_callback.Run(parsed_command_line, current_directory) ?
|
||||
- TRUE : FALSE;
|
||||
+ g_write_ack_callback_called = false;
|
||||
+ *result = notification_callback.Run(parsed_command_line, current_directory,
|
||||
+ std::move(additional_data),
|
||||
+ base::BindRepeating(&StoreAck))
|
||||
+ ? TRUE
|
||||
+ : FALSE;
|
||||
+ g_ack_timer.Start(FROM_HERE, base::Seconds(0),
|
||||
+ base::BindOnce(&SendBackAck));
|
||||
+ *result = notification_callback.Run(parsed_command_line,
|
||||
+ current_directory, std::move(additional_data)) ? TRUE : FALSE;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -254,9 +343,13 @@ bool ProcessSingleton::EscapeVirtualization(
|
||||
@@ -254,9 +288,11 @@ bool ProcessSingleton::EscapeVirtualization(
|
||||
ProcessSingleton::ProcessSingleton(
|
||||
const std::string& program_name,
|
||||
const base::FilePath& user_data_dir,
|
||||
+ const base::span<const uint8_t> additional_data,
|
||||
bool is_app_sandboxed,
|
||||
- const NotificationCallback& notification_callback)
|
||||
+ const NotificationCallback& notification_callback,
|
||||
+ const NotificationAckCallback& notification_ack_callback)
|
||||
const NotificationCallback& notification_callback)
|
||||
: notification_callback_(notification_callback),
|
||||
+ notification_ack_callback_(notification_ack_callback),
|
||||
+ additional_data_(additional_data),
|
||||
program_name_(program_name),
|
||||
is_app_sandboxed_(is_app_sandboxed),
|
||||
is_virtualized_(false),
|
||||
@@ -271,6 +364,37 @@ ProcessSingleton::~ProcessSingleton() {
|
||||
::CloseHandle(lock_file_);
|
||||
}
|
||||
|
||||
+void ReadAck(const ProcessSingleton::NotificationAckCallback& ack_callback) {
|
||||
+ // We are reading the ack from the first instance.
|
||||
+ // First, wait for the pipe.
|
||||
+ ::WaitNamedPipe(kPipeName, NMPWAIT_USE_DEFAULT_WAIT);
|
||||
+
|
||||
+ HANDLE read_ack_pipe = ::CreateFile(kPipeName,
|
||||
+ GENERIC_READ,
|
||||
+ FILE_SHARE_READ,
|
||||
+ NULL,
|
||||
+ OPEN_EXISTING,
|
||||
+ FILE_ATTRIBUTE_NORMAL,
|
||||
+ NULL);
|
||||
+ CHECK(read_ack_pipe != INVALID_HANDLE_VALUE);
|
||||
+
|
||||
+ DWORD bytes_read;
|
||||
+ uint8_t read_ack_buffer[kMaxMessageLength];
|
||||
+ ::ReadFile(read_ack_pipe,
|
||||
+ (LPVOID)read_ack_buffer,
|
||||
+ kMaxMessageLength,
|
||||
+ &bytes_read,
|
||||
+ NULL);
|
||||
+
|
||||
+ if (!bytes_read) {
|
||||
+ ack_callback.Run(nullptr);
|
||||
+ } else {
|
||||
+ base::span<const uint8_t> out_span(read_ack_buffer, read_ack_buffer + bytes_read);
|
||||
+ ack_callback.Run(&out_span);
|
||||
+ }
|
||||
+ ::CloseHandle(read_ack_pipe);
|
||||
+}
|
||||
+
|
||||
// Code roughly based on Mozilla.
|
||||
ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() {
|
||||
TRACE_EVENT0("startup", "ProcessSingleton::NotifyOtherProcess");
|
||||
@@ -283,8 +407,9 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() {
|
||||
@@ -283,7 +319,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() {
|
||||
return PROCESS_NONE;
|
||||
}
|
||||
|
||||
- switch (chrome::AttemptToNotifyRunningChrome(remote_window_)) {
|
||||
+ switch (chrome::AttemptToNotifyRunningChrome(remote_window_, additional_data_)) {
|
||||
case chrome::NOTIFY_SUCCESS:
|
||||
+ ReadAck(notification_ack_callback_);
|
||||
return PROCESS_NOTIFIED;
|
||||
case chrome::NOTIFY_FAILED:
|
||||
remote_window_ = NULL;
|
||||
@@ -422,6 +547,18 @@ bool ProcessSingleton::Create() {
|
||||
<< "Lock file can not be created! Error code: " << error;
|
||||
|
||||
if (lock_file_ != INVALID_HANDLE_VALUE) {
|
||||
+ // We are the first instance. Create a pipe to send out ack data.
|
||||
+ ack_pipe_ = ::CreateNamedPipe(kPipeName,
|
||||
+ PIPE_ACCESS_OUTBOUND,
|
||||
+ PIPE_TYPE_BYTE | PIPE_REJECT_REMOTE_CLIENTS,
|
||||
+ PIPE_UNLIMITED_INSTANCES,
|
||||
+ kMaxMessageLength,
|
||||
+ 0,
|
||||
+ kPipeTimeout,
|
||||
+ NULL);
|
||||
+ CHECK(ack_pipe_ != INVALID_HANDLE_VALUE);
|
||||
+ g_write_ack_pipe = ack_pipe_;
|
||||
+
|
||||
// Set the window's title to the path of our user data directory so
|
||||
// other Chrome instances can decide if they should forward to us.
|
||||
TRACE_EVENT0("startup", "ProcessSingleton::Create:CreateWindow");
|
||||
@@ -449,6 +586,7 @@ bool ProcessSingleton::Create() {
|
||||
}
|
||||
|
||||
void ProcessSingleton::Cleanup() {
|
||||
+ ::CloseHandle(ack_pipe_);
|
||||
}
|
||||
|
||||
void ProcessSingleton::OverrideShouldKillRemoteProcessCallbackForTesting(
|
||||
diff --git a/chrome/browser/win/chrome_process_finder.cc b/chrome/browser/win/chrome_process_finder.cc
|
||||
index b64ed1d155a30582e48c9cdffcee9d0f25a53a6a..ce851d09d501ebcc6d6c4065e746e869d5275b2b 100644
|
||||
index b64ed1d155a30582e48c9cdffcee9d0f25a53a6a..cfdb2d75532d270e3dd548eb7475a6cdbddf1016 100644
|
||||
--- a/chrome/browser/win/chrome_process_finder.cc
|
||||
+++ b/chrome/browser/win/chrome_process_finder.cc
|
||||
@@ -36,9 +36,10 @@ HWND FindRunningChromeWindow(const base::FilePath& user_data_dir) {
|
||||
@@ -36,7 +36,9 @@ HWND FindRunningChromeWindow(const base::FilePath& user_data_dir) {
|
||||
return base::win::MessageWindow::FindWindow(user_data_dir.value());
|
||||
}
|
||||
|
||||
@@ -538,11 +288,9 @@ index b64ed1d155a30582e48c9cdffcee9d0f25a53a6a..ce851d09d501ebcc6d6c4065e746e869
|
||||
+ HWND remote_window,
|
||||
+ const base::span<const uint8_t> additional_data) {
|
||||
TRACE_EVENT0("startup", "AttemptToNotifyRunningChrome");
|
||||
-
|
||||
|
||||
DCHECK(remote_window);
|
||||
DWORD process_id = 0;
|
||||
DWORD thread_id = GetWindowThreadProcessId(remote_window, &process_id);
|
||||
@@ -50,7 +51,8 @@ NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window) {
|
||||
@@ -50,7 +52,8 @@ NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window) {
|
||||
}
|
||||
|
||||
// Send the command line to the remote chrome window.
|
||||
@@ -552,7 +300,7 @@ index b64ed1d155a30582e48c9cdffcee9d0f25a53a6a..ce851d09d501ebcc6d6c4065e746e869
|
||||
std::wstring to_send(L"START\0", 6); // want the NULL in the string.
|
||||
base::FilePath cur_dir;
|
||||
if (!base::GetCurrentDirectory(&cur_dir)) {
|
||||
@@ -64,6 +66,22 @@ NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window) {
|
||||
@@ -64,6 +67,22 @@ NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window) {
|
||||
base::CommandLine::ForCurrentProcess()->GetCommandLineString());
|
||||
to_send.append(L"\0", 1); // Null separator.
|
||||
|
||||
@@ -81,7 +81,7 @@ index 309422bcf85810db88a048bd0930c4072b41f234..759549f3046f4a897b597409b670bb1c
|
||||
private:
|
||||
const HWND hwnd_;
|
||||
diff --git a/components/viz/service/BUILD.gn b/components/viz/service/BUILD.gn
|
||||
index eff91b68cf4b72de41b7b2ad09c029b8b5dcf3c6..c736f772e3714c6a80703c41c8a2f0dab36b166d 100644
|
||||
index 03a9986ff94bc57e82a95e7a2a3fcc1415f28da0..79283e753512855360127471d40e145c325649ca 100644
|
||||
--- a/components/viz/service/BUILD.gn
|
||||
+++ b/components/viz/service/BUILD.gn
|
||||
@@ -139,6 +139,8 @@ viz_component("service") {
|
||||
@@ -501,7 +501,7 @@ index 583e3e2525c753a0962d481fc67a3582df75d0e9..9416ec929bebcff7f07088e635376ef2
|
||||
waiting_on_draw_ack_ = true;
|
||||
|
||||
diff --git a/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc b/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc
|
||||
index 4b6712b2a4f3c56a6d243ff9d93539505a5c7b86..7f62362ab27abd3497d23e8db8c8bb5a2e3392f9 100644
|
||||
index 7607a49cdc1a6028e272ce76b78806ec13415f42..e2f4350edeae766916716345327d0bbefb561e4c 100644
|
||||
--- a/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc
|
||||
+++ b/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.cc
|
||||
@@ -84,7 +84,8 @@ RootCompositorFrameSinkImpl::Create(
|
||||
@@ -619,7 +619,7 @@ index 8b74e1d2a463156f62e983f535ff68a53215f648..6ef04da46c8b097b01d5ee40dcadf222
|
||||
raw_ptr<Layer> root_layer_ = nullptr;
|
||||
|
||||
diff --git a/ui/gfx/ca_layer_params.h b/ui/gfx/ca_layer_params.h
|
||||
index 12e115cd6a128d8d150abc786d4d38b1d5119d91..b6320de28750333bee7ee83393849f4eb0a956ac 100644
|
||||
index c5fb29b30b9c5b7483998c567ed9a479d8743939..dc10d78315f76a3914ccd6e2e99af97fa909918b 100644
|
||||
--- a/ui/gfx/ca_layer_params.h
|
||||
+++ b/ui/gfx/ca_layer_params.h
|
||||
@@ -6,6 +6,7 @@
|
||||
@@ -630,7 +630,7 @@ index 12e115cd6a128d8d150abc786d4d38b1d5119d91..b6320de28750333bee7ee83393849f4e
|
||||
#include "ui/gfx/geometry/size.h"
|
||||
#include "ui/gfx/gfx_export.h"
|
||||
|
||||
@@ -51,6 +52,8 @@ struct GFX_EXPORT CALayerParams {
|
||||
@@ -41,6 +42,8 @@ struct GFX_EXPORT CALayerParams {
|
||||
gfx::ScopedRefCountedIOSurfaceMachPort io_surface_mach_port;
|
||||
#endif
|
||||
|
||||
|
||||
@@ -103,10 +103,10 @@ index 4c4cc16db82d7434573f7740855fbe72d68815e6..f71290800b6bb51a39b1f86be36f02d6
|
||||
string mime_type;
|
||||
|
||||
diff --git a/services/network/url_loader.cc b/services/network/url_loader.cc
|
||||
index 5c5aeeda64b244ab1f58556f28d2ca3c133d03a8..2f9aa4d49693a22507f668b2738c54be59802b8f 100644
|
||||
index 73b90e9b575b94f009ae3b87bd0ad76d69803bc3..e08bb784a11209f1531e8d981bd238d67db31e22 100644
|
||||
--- a/services/network/url_loader.cc
|
||||
+++ b/services/network/url_loader.cc
|
||||
@@ -469,6 +469,7 @@ URLLoader::URLLoader(
|
||||
@@ -462,6 +462,7 @@ URLLoader::URLLoader(
|
||||
mojo::SimpleWatcher::ArmingPolicy::MANUAL,
|
||||
base::SequencedTaskRunnerHandle::Get()),
|
||||
per_factory_corb_state_(context.GetMutableCorbState()),
|
||||
@@ -114,7 +114,7 @@ index 5c5aeeda64b244ab1f58556f28d2ca3c133d03a8..2f9aa4d49693a22507f668b2738c54be
|
||||
devtools_request_id_(request.devtools_request_id),
|
||||
request_mode_(request.mode),
|
||||
request_credentials_mode_(request.credentials_mode),
|
||||
@@ -636,7 +637,7 @@ URLLoader::URLLoader(
|
||||
@@ -629,7 +630,7 @@ URLLoader::URLLoader(
|
||||
url_request_->SetRequestHeadersCallback(base::BindRepeating(
|
||||
&URLLoader::SetRawRequestHeadersAndNotify, base::Unretained(this)));
|
||||
|
||||
@@ -123,7 +123,7 @@ index 5c5aeeda64b244ab1f58556f28d2ca3c133d03a8..2f9aa4d49693a22507f668b2738c54be
|
||||
url_request_->SetResponseHeadersCallback(base::BindRepeating(
|
||||
&URLLoader::SetRawResponseHeaders, base::Unretained(this)));
|
||||
}
|
||||
@@ -1395,6 +1396,19 @@ void URLLoader::OnResponseStarted(net::URLRequest* url_request, int net_error) {
|
||||
@@ -1388,6 +1389,19 @@ void URLLoader::OnResponseStarted(net::URLRequest* url_request, int net_error) {
|
||||
}
|
||||
|
||||
response_ = BuildResponseHead();
|
||||
|
||||
@@ -1,20 +1,22 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Shelley Vohr <shelley.vohr@gmail.com>
|
||||
Date: Mon, 25 Oct 2021 21:45:57 +0200
|
||||
Subject: fix: patch out permissions checks in exclusive_access
|
||||
Subject: fix: adapt exclusive_access for electron needs
|
||||
|
||||
This patch is necessary in order to properly enable
|
||||
navigator.keyboard.{(un)?lock}() functionality. We don't have a concept
|
||||
of PermissionManager nor of a Profile, so this would not affect usage of
|
||||
the API.
|
||||
|
||||
We might consider potentially using our own permissions handler,
|
||||
but it's not strictly necessary for this API to work to spec.
|
||||
|
||||
Profile check has been upstreamed at https://chromium-review.googlesource.com/c/chromium/src/+/3247196
|
||||
We also need to ensure that NotifyExclusiveTabAccessLost is called
|
||||
on all platforms in FullscreenController::ExitFullscreenModeInternal()
|
||||
and not just macOS, since Electron's native window impls report state
|
||||
change fairly instantly as well, and so pressing escape won't work on
|
||||
Linux or Windows to un-fullscreen in some circumstances without this
|
||||
change.
|
||||
|
||||
diff --git a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
|
||||
index 9b2c91d39324b61afa49ccea6be2eda8308473ff..1652b52c5c752809348b3ab44d3703ac343c829d 100644
|
||||
index 9b2c91d39324b61afa49ccea6be2eda8308473ff..6817a9cd22ebb8adba2118a1bd8a32cfc065e8ea 100644
|
||||
--- a/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
|
||||
+++ b/chrome/browser/ui/exclusive_access/fullscreen_controller.cc
|
||||
@@ -382,13 +382,9 @@ void FullscreenController::EnterFullscreenModeInternal(
|
||||
@@ -49,3 +51,19 @@ index 9b2c91d39324b61afa49ccea6be2eda8308473ff..1652b52c5c752809348b3ab44d3703ac
|
||||
|
||||
if (option == BROWSER)
|
||||
base::RecordAction(base::UserMetricsAction("ToggleFullscreen"));
|
||||
@@ -439,12 +437,12 @@ void FullscreenController::ExitFullscreenModeInternal() {
|
||||
|
||||
RecordExitingUMA();
|
||||
toggled_into_fullscreen_ = false;
|
||||
-#if BUILDFLAG(IS_MAC)
|
||||
- // Mac windows report a state change instantly, and so we must also clear
|
||||
+
|
||||
+ // Electron native windows report a state change instantly, and so we must also clear
|
||||
// state_prior_to_tab_fullscreen_ to match them else other logic using
|
||||
// state_prior_to_tab_fullscreen_ will be incorrect.
|
||||
NotifyTabExclusiveAccessLost();
|
||||
-#endif
|
||||
+
|
||||
exclusive_access_manager()->context()->ExitFullscreen();
|
||||
extension_caused_fullscreen_ = GURL();
|
||||
|
||||
@@ -8,10 +8,10 @@ we invoke it in order to expose contents.decrementCapturerCount([stayHidden, sta
|
||||
to users. We should try to upstream this.
|
||||
|
||||
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
|
||||
index 7440f2025701ccde0ade36cda22467dd0614109b..3c6ee78454dc9154a37ec9046e382878ffda0c82 100644
|
||||
index e1ac23f3adf38591ae220ea84c5c0717a28e64bb..fad1663512cf30b270289ecfa9c336b08fe67836 100644
|
||||
--- a/content/browser/web_contents/web_contents_impl.h
|
||||
+++ b/content/browser/web_contents/web_contents_impl.h
|
||||
@@ -1830,7 +1830,7 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
|
||||
@@ -1831,7 +1831,7 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
|
||||
// IncrementCapturerCount() is destructed.
|
||||
void DecrementCapturerCount(bool stay_hidden,
|
||||
bool stay_awake,
|
||||
@@ -21,7 +21,7 @@ index 7440f2025701ccde0ade36cda22467dd0614109b..3c6ee78454dc9154a37ec9046e382878
|
||||
// Calculates the PageVisibilityState for |visibility|, taking the capturing
|
||||
// state into account.
|
||||
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
|
||||
index cd1b44d4ff5ce8924749ba9e41b3f599108bb8fd..72bc509b0506fafd026aa858864623886142b5f0 100644
|
||||
index be92a83de1a5ccdc106277d67b706e9b109298a9..7a8c2efda1b2c85341d518cc96279a80ab7e91c7 100644
|
||||
--- a/content/public/browser/web_contents.h
|
||||
+++ b/content/public/browser/web_contents.h
|
||||
@@ -673,6 +673,10 @@ class WebContents : public PageNavigator,
|
||||
|
||||
@@ -13,7 +13,7 @@ messages in the legacy window handle layer.
|
||||
These conditions are regularly hit with WCO-enabled windows on Windows.
|
||||
|
||||
diff --git a/content/browser/renderer_host/legacy_render_widget_host_win.cc b/content/browser/renderer_host/legacy_render_widget_host_win.cc
|
||||
index 4a894ef70eeb1d8489049aef552c9bae4f24ae62..f5049d730a850f2947023f976b25fb772e42107a 100644
|
||||
index 4a894ef70eeb1d8489049aef552c9bae4f24ae62..df101c53861a83f107d459270c37b3b497a00cb0 100644
|
||||
--- a/content/browser/renderer_host/legacy_render_widget_host_win.cc
|
||||
+++ b/content/browser/renderer_host/legacy_render_widget_host_win.cc
|
||||
@@ -288,12 +288,12 @@ LRESULT LegacyRenderWidgetHostHWND::OnMouseRange(UINT message,
|
||||
@@ -31,19 +31,15 @@ index 4a894ef70eeb1d8489049aef552c9bae4f24ae62..f5049d730a850f2947023f976b25fb77
|
||||
tme.hwndTrack = hwnd();
|
||||
tme.dwHoverTime = 0;
|
||||
TrackMouseEvent(&tme);
|
||||
@@ -319,12 +319,11 @@ LRESULT LegacyRenderWidgetHostHWND::OnMouseRange(UINT message,
|
||||
message, w_param, l_param, &msg_handled);
|
||||
handled = msg_handled;
|
||||
// If the parent did not handle non client mouse messages, we call
|
||||
- // DefWindowProc on the message with the parent window handle. This
|
||||
- // ensures that WM_SYSCOMMAND is generated for the parent and we are
|
||||
- // out of the picture.
|
||||
+ // DefWindowProc on the message. This ensures that WM_SYSCOMMAND is
|
||||
+ // generated.
|
||||
@@ -324,7 +324,10 @@ LRESULT LegacyRenderWidgetHostHWND::OnMouseRange(UINT message,
|
||||
// out of the picture.
|
||||
if (!handled &&
|
||||
(message >= WM_NCMOUSEMOVE && message <= WM_NCXBUTTONDBLCLK)) {
|
||||
- ret = ::DefWindowProc(GetParent(), message, w_param, l_param);
|
||||
+ ret = ::DefWindowProc(hwnd(), message, w_param, l_param);
|
||||
+ // Send WM_NCMOUSEMOVE messages using the LegacyRenderWidgetHostHWND's
|
||||
+ // handle so mouse tracking on non-client areas doesn't break.
|
||||
+ HWND target = message == WM_NCMOUSEMOVE ? hwnd() : GetParent();
|
||||
+ ret = ::DefWindowProc(target, message, w_param, l_param);
|
||||
handled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
265
patches/chromium/fix_xkb_keysym_reverse_look_up_for_lacros.patch
Normal file
265
patches/chromium/fix_xkb_keysym_reverse_look_up_for_lacros.patch
Normal file
@@ -0,0 +1,265 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Hidehiko Abe <hidehiko@chromium.org>
|
||||
Date: Wed, 2 Mar 2022 16:17:43 +0000
|
||||
Subject: Fix xkb_keysym reverse look up for Lacros.
|
||||
|
||||
In crrev.com/c/3422444, we introduced
|
||||
xkb_keymap_key_get_mods_for_level in order to construct a reverse map.
|
||||
However, unlike its name, and unlike its document, it returns a "mask"
|
||||
of modifiers, rather than the modifiers to trigger the level.
|
||||
As a result, the CL introduced a regression on some key events,
|
||||
such as SHIFT+SPACE.
|
||||
|
||||
This CL fixes the issue by giving up creating a simple reverse map.
|
||||
Instead, on keymap setting, it creates a reverse map from keysym
|
||||
to a list of (keycode/layout) pairs. And, on look up, we iterate
|
||||
all the candidates, and find the first one (min keycode entry).
|
||||
In order to runtime look up, we assume the current key layout,
|
||||
as the wayland keysym event does not provide any layout info.
|
||||
|
||||
diff --git a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc
|
||||
index d8b0594442b2708a03532312b62c4c3481da3b23..d30045bce1af98f68d19e3b01a7a06f67682af16 100644
|
||||
--- a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc
|
||||
+++ b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.cc
|
||||
@@ -31,14 +31,6 @@
|
||||
#include "ui/events/keycodes/keyboard_code_conversion.h"
|
||||
#include "ui/events/keycodes/keyboard_code_conversion_xkb.h"
|
||||
|
||||
-// xkb_keymap_key_get_mods_for_level is relatively new (introduced in ver 1.0,
|
||||
-// Sep 6, 2020), thus it is not available on some platform, such as Ubuntu
|
||||
-// 18.04, which we still supports.
|
||||
-// Thus declare the function as weak here, so we can check the availability on
|
||||
-// runtime.
|
||||
-extern "C" __attribute__((weak)) decltype(
|
||||
- xkb_keymap_key_get_mods_for_level) xkb_keymap_key_get_mods_for_level;
|
||||
-
|
||||
namespace ui {
|
||||
|
||||
namespace {
|
||||
@@ -901,17 +893,7 @@ void XkbKeyboardLayoutEngine::SetKeymap(xkb_keymap* keymap) {
|
||||
}
|
||||
|
||||
// Reconstruct keysym map.
|
||||
- std::vector<std::pair<XkbKeysymMapKey, uint32_t>> keysym_map;
|
||||
- auto AddEntries = [&keysym_map](base::span<const xkb_keysym_t> keysyms,
|
||||
- base::span<const xkb_mod_mask_t> masks,
|
||||
- xkb_keycode_t keycode) {
|
||||
- if (keysyms.empty() || masks.empty())
|
||||
- return;
|
||||
- for (xkb_keysym_t keysym : keysyms) {
|
||||
- for (xkb_mod_mask_t mask : masks)
|
||||
- keysym_map.emplace_back(XkbKeysymMapKey(keysym, mask), keycode);
|
||||
- }
|
||||
- };
|
||||
+ std::vector<XkbKeysymMapEntry> keysym_map;
|
||||
|
||||
const xkb_keycode_t min_key = xkb_keymap_min_keycode(keymap);
|
||||
const xkb_keycode_t max_key = xkb_keymap_max_keycode(keymap);
|
||||
@@ -925,34 +907,33 @@ void XkbKeyboardLayoutEngine::SetKeymap(xkb_keymap* keymap) {
|
||||
const xkb_keysym_t* keysyms;
|
||||
int num_syms = xkb_keymap_key_get_syms_by_level(keymap, keycode, layout,
|
||||
level, &keysyms);
|
||||
- if (xkb_keymap_key_get_mods_for_level) {
|
||||
- xkb_mod_mask_t masks[100]; // Large enough buffer.
|
||||
- int num_mods = xkb_keymap_key_get_mods_for_level(
|
||||
- keymap, keycode, layout, level, masks, std::size(masks));
|
||||
- AddEntries(base::make_span(keysyms, num_syms),
|
||||
- base::make_span(masks, num_mods), keycode);
|
||||
- } else {
|
||||
- // If not, unfortunately, there's no convenient/efficient way
|
||||
- // to take the possible masks. Thus, use mask 0 always.
|
||||
- constexpr xkb_mod_mask_t kMask[] = {0};
|
||||
- AddEntries(base::make_span(keysyms, num_syms), kMask, keycode);
|
||||
- }
|
||||
+ for (int i = 0; i < num_syms; ++i)
|
||||
+ keysym_map.emplace_back(
|
||||
+ XkbKeysymMapEntry{keysyms[i], keycode, layout});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- // Sort here. If there are multiple entries for a (keysym, mask) pair,
|
||||
- // min keycode wins.
|
||||
- std::sort(keysym_map.begin(), keysym_map.end());
|
||||
+ // Then sort and unique here. On tie break, smaller keycode comes first.
|
||||
+ std::sort(
|
||||
+ keysym_map.begin(), keysym_map.end(),
|
||||
+ [](const XkbKeysymMapEntry& entry1, const XkbKeysymMapEntry& entry2) {
|
||||
+ return std::tie(entry1.xkb_keysym, entry1.xkb_keycode,
|
||||
+ entry1.xkb_layout) < std::tie(entry2.xkb_keysym,
|
||||
+ entry2.xkb_keycode,
|
||||
+ entry2.xkb_layout);
|
||||
+ });
|
||||
keysym_map.erase(
|
||||
- std::unique(keysym_map.begin(), keysym_map.end(),
|
||||
- [](const std::pair<XkbKeysymMapKey, uint32_t>& entry1,
|
||||
- const std::pair<XkbKeysymMapKey, uint32_t>& entry2) {
|
||||
- return entry1.first == entry2.first;
|
||||
- }),
|
||||
+ std::unique(
|
||||
+ keysym_map.begin(), keysym_map.end(),
|
||||
+ [](const XkbKeysymMapEntry& entry1, const XkbKeysymMapEntry& entry2) {
|
||||
+ return std::tie(entry1.xkb_keysym, entry1.xkb_keycode,
|
||||
+ entry1.xkb_layout) == std::tie(entry2.xkb_keysym,
|
||||
+ entry2.xkb_keycode,
|
||||
+ entry2.xkb_layout);
|
||||
+ }),
|
||||
keysym_map.end());
|
||||
- xkb_keysym_map_ = base::flat_map<XkbKeysymMapKey, uint32_t>(
|
||||
- base::sorted_unique, std::move(keysym_map));
|
||||
+ xkb_keysym_map_ = std::move(keysym_map);
|
||||
|
||||
layout_index_ = 0;
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
@@ -1000,18 +981,38 @@ int XkbKeyboardLayoutEngine::UpdateModifiers(uint32_t depressed,
|
||||
|
||||
DomCode XkbKeyboardLayoutEngine::GetDomCodeByKeysym(uint32_t keysym,
|
||||
uint32_t modifiers) const {
|
||||
- // If xkb_keymap_key_get_mods_for_level is not available, all entries are
|
||||
- // stored with modifiers mask is 0.
|
||||
- if (!xkb_keymap_key_get_mods_for_level)
|
||||
- modifiers = 0;
|
||||
-
|
||||
- auto iter = xkb_keysym_map_.find(XkbKeysymMapKey(keysym, modifiers));
|
||||
- if (iter == xkb_keysym_map_.end()) {
|
||||
- VLOG(1) << "No Keycode found for the keysym: " << keysym
|
||||
- << ", modifiers: " << modifiers;
|
||||
- return DomCode::NONE;
|
||||
+ // Look up all candidates.
|
||||
+ auto range = std::equal_range(
|
||||
+ xkb_keysym_map_.begin(), xkb_keysym_map_.end(), XkbKeysymMapEntry{keysym},
|
||||
+ [](const XkbKeysymMapEntry& entry1, const XkbKeysymMapEntry& entry2) {
|
||||
+ return entry1.xkb_keysym < entry2.xkb_keysym;
|
||||
+ });
|
||||
+ if (range.first != range.second) {
|
||||
+ // Note: value is already in the lexicographical order, so smaller keycode
|
||||
+ // comes first.
|
||||
+ for (std::unique_ptr<xkb_state, XkbStateDeleter> xkb_state(
|
||||
+ xkb_state_new(xkb_state_get_keymap(xkb_state_.get())));
|
||||
+ range.first != range.second; ++range.first) {
|
||||
+ xkb_keycode_t xkb_keycode = range.first->xkb_keycode;
|
||||
+ xkb_layout_index_t xkb_layout = range.first->xkb_layout;
|
||||
+ // The argument does not have any info about the layout, so we assume the
|
||||
+ // current layout here.
|
||||
+ if (xkb_layout != layout_index_)
|
||||
+ continue;
|
||||
+ xkb_state_update_mask(xkb_state.get(), modifiers, 0, 0, 0, 0, xkb_layout);
|
||||
+ const xkb_keysym_t* out_keysyms;
|
||||
+ int num_syms =
|
||||
+ xkb_state_key_get_syms(xkb_state.get(), xkb_keycode, &out_keysyms);
|
||||
+ for (int i = 0; i < num_syms; ++i) {
|
||||
+ if (out_keysyms[i] == keysym)
|
||||
+ return KeycodeConverter::NativeKeycodeToDomCode(xkb_keycode);
|
||||
+ }
|
||||
+ }
|
||||
}
|
||||
- return KeycodeConverter::NativeKeycodeToDomCode(iter->second);
|
||||
+
|
||||
+ VLOG(1) << "No Keycode found for the keysym: " << keysym
|
||||
+ << ", modifiers: " << modifiers;
|
||||
+ return DomCode::NONE;
|
||||
}
|
||||
|
||||
bool XkbKeyboardLayoutEngine::XkbLookup(xkb_keycode_t xkb_keycode,
|
||||
diff --git a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
|
||||
index 4fcbce540e4f4dc419f13be9a45fd97c52f8d2b5..3ed6a030d393a927663e1486efef09cf6add589c 100644
|
||||
--- a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
|
||||
+++ b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h
|
||||
@@ -74,14 +74,19 @@ class COMPONENT_EXPORT(EVENTS_OZONE_LAYOUT) XkbKeyboardLayoutEngine
|
||||
};
|
||||
std::vector<XkbFlagMapEntry> xkb_flag_map_;
|
||||
|
||||
- // Table from (xkb_keysym, xkb_modifier) to xkb_keycode for the current
|
||||
- // keymap. Note that there could be multiple keycodes mapped to the same
|
||||
- // keysym. In the case, the first one (smallest keycode) will be
|
||||
- // kept.
|
||||
- // The first element is keysym value. The second element is a bit-mask of
|
||||
- // modifiers.
|
||||
- using XkbKeysymMapKey = std::pair<uint32_t, uint32_t>;
|
||||
- base::flat_map<XkbKeysymMapKey, uint32_t> xkb_keysym_map_;
|
||||
+ // The data to reverse look up xkb_keycode/xkb_layout from xkb_keysym.
|
||||
+ // The data is sorted in the (xkb_keysym, xkb_keycode, xkb_layout) dictionary
|
||||
+ // order. Note that there can be multiple keycode/layout for a keysym, so
|
||||
+ // this is a multi map.
|
||||
+ // We can binary search on this vector by keysym as the key, and iterate from
|
||||
+ // the begin to the end of the range linearly. Then, on tie break, smaller
|
||||
+ // keycode wins.
|
||||
+ struct XkbKeysymMapEntry {
|
||||
+ xkb_keysym_t xkb_keysym;
|
||||
+ xkb_keycode_t xkb_keycode;
|
||||
+ xkb_layout_index_t xkb_layout;
|
||||
+ };
|
||||
+ std::vector<XkbKeysymMapEntry> xkb_keysym_map_;
|
||||
|
||||
#if BUILDFLAG(IS_CHROMEOS_ASH)
|
||||
// Flag mask for num lock, which is always considered enabled in ChromeOS.
|
||||
diff --git a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine_unittest.cc b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine_unittest.cc
|
||||
index 3f9223e6c2aad19309d8d3a9367b58a310023d21..18ea942e5b785e037e3fbbd10d1ff4393cf068d0 100644
|
||||
--- a/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine_unittest.cc
|
||||
+++ b/ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine_unittest.cc
|
||||
@@ -18,9 +18,6 @@
|
||||
#include "ui/events/keycodes/keyboard_code_conversion.h"
|
||||
#include "ui/events/ozone/layout/scoped_keyboard_layout_engine.h"
|
||||
|
||||
-extern "C" __attribute__((weak)) decltype(
|
||||
- xkb_keymap_key_get_mods_for_level) xkb_keymap_key_get_mods_for_level;
|
||||
-
|
||||
namespace ui {
|
||||
|
||||
namespace {
|
||||
@@ -946,35 +943,31 @@ TEST_F(XkbLayoutEngineVkTest, GetDomCodeByKeysym) {
|
||||
constexpr struct {
|
||||
uint32_t keysym;
|
||||
uint32_t modifiers;
|
||||
- DomCode dom_code;
|
||||
+ DomCode expected_dom_code;
|
||||
} kTestCases[] = {
|
||||
- {65307, 0, ui::DomCode::ESCAPE}, {65288, 0, ui::DomCode::BACKSPACE},
|
||||
- {65293, 0, ui::DomCode::ENTER}, {65289, 0, ui::DomCode::TAB},
|
||||
+ {65307, 0, ui::DomCode::ESCAPE},
|
||||
+ {65288, 0, ui::DomCode::BACKSPACE},
|
||||
+ {65293, 0, ui::DomCode::ENTER},
|
||||
+ {65289, 0, ui::DomCode::TAB},
|
||||
{65056, kShiftMask, ui::DomCode::TAB},
|
||||
+
|
||||
+ // Test conflict keysym case. We use '<' as a testing example.
|
||||
+ // On pc101 layout, intl_backslash is expected without SHIFT modifier.
|
||||
+ {60, 0, ui::DomCode::INTL_BACKSLASH},
|
||||
+ // And, if SHIFT is pressed, comma key is expected.
|
||||
+ {60, kShiftMask, ui::DomCode::COMMA},
|
||||
+
|
||||
+ // Test for space key. The keysym mapping has only one keycode entry.
|
||||
+ // It expects all modifiers are ignored. Used SHIFT as testing example.
|
||||
+ {32, 0, ui::DomCode::SPACE},
|
||||
+ {32, kShiftMask, ui::DomCode::SPACE},
|
||||
};
|
||||
|
||||
for (const auto& test_case : kTestCases) {
|
||||
- SCOPED_TRACE(test_case.keysym);
|
||||
- EXPECT_EQ(test_case.dom_code, layout_engine_->GetDomCodeByKeysym(
|
||||
- test_case.keysym, test_case.modifiers));
|
||||
- }
|
||||
-
|
||||
- // Test conflict keysym case. We use '<' as a testing sample.
|
||||
- constexpr uint32_t kLessThanCode = 60;
|
||||
- if (xkb_keymap_key_get_mods_for_level) {
|
||||
- // If there's no modifier, on pc101 us layout, intl_backslash is expected.
|
||||
- EXPECT_EQ(ui::DomCode::INTL_BACKSLASH,
|
||||
- layout_engine_->GetDomCodeByKeysym(kLessThanCode, 0));
|
||||
- // If there's shift modifier, comma key is expected.
|
||||
- EXPECT_EQ(ui::DomCode::COMMA,
|
||||
- layout_engine_->GetDomCodeByKeysym(kLessThanCode, kShiftMask));
|
||||
- } else {
|
||||
- // If xkb_keymap_key_get_mods_for_level is unavailable, fallback to older
|
||||
- // implementation, which ignores modifiers.
|
||||
- EXPECT_EQ(ui::DomCode::COMMA,
|
||||
- layout_engine_->GetDomCodeByKeysym(kLessThanCode, 0));
|
||||
- EXPECT_EQ(ui::DomCode::COMMA,
|
||||
- layout_engine_->GetDomCodeByKeysym(kLessThanCode, kShiftMask));
|
||||
+ EXPECT_EQ(test_case.expected_dom_code,
|
||||
+ layout_engine_->GetDomCodeByKeysym(test_case.keysym,
|
||||
+ test_case.modifiers))
|
||||
+ << "input: " << test_case.keysym << ", " << test_case.modifiers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ Subject: frame_host_manager.patch
|
||||
Allows embedder to intercept site instances created by chromium.
|
||||
|
||||
diff --git a/content/browser/renderer_host/render_frame_host_manager.cc b/content/browser/renderer_host/render_frame_host_manager.cc
|
||||
index 1ca418461788e5b7d58c14b03c456d2c21f1305b..7a65b6713e3d0547f1990f8c59d0d11459532477 100644
|
||||
index 988290f88894157458641d2d201a060820813358..e19b30fc7a88c981d0dad3ed739f3219980b5aeb 100644
|
||||
--- a/content/browser/renderer_host/render_frame_host_manager.cc
|
||||
+++ b/content/browser/renderer_host/render_frame_host_manager.cc
|
||||
@@ -3089,6 +3089,9 @@ RenderFrameHostManager::GetSiteInstanceForNavigationRequest(
|
||||
@@ -20,10 +20,10 @@ index 1ca418461788e5b7d58c14b03c456d2c21f1305b..7a65b6713e3d0547f1990f8c59d0d114
|
||||
}
|
||||
|
||||
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
|
||||
index 2fe1462a2cd92a731a5816b5fc22b059bad92fe8..a4dfa54a7844983262cc0fa635433131382e4d14 100644
|
||||
index ceb2bb900e122840505aa8d3911923cffc9a907e..c135db6a148e1d1b4af8d5a1d6a80e11ad99d9fe 100644
|
||||
--- a/content/public/browser/content_browser_client.h
|
||||
+++ b/content/public/browser/content_browser_client.h
|
||||
@@ -275,6 +275,11 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
@@ -276,6 +276,11 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
|
||||
virtual ~ContentBrowserClient() = default;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ If removing this patch causes no sync failures, it's safe to delete :+1:
|
||||
Ref https://chromium-review.googlesource.com/c/chromium/src/+/2953903
|
||||
|
||||
diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py
|
||||
index ee41efe814da161cafb49229e1f02c8b82749e7c..494bbdeea2725e4b1218ba534fd126203012c100 100755
|
||||
index 0fb53bbaf4174594b46ecba6d4d28f7436ef9a72..9951fc52f06be5199b93d29d18a1b5582299f334 100755
|
||||
--- a/tools/clang/scripts/update.py
|
||||
+++ b/tools/clang/scripts/update.py
|
||||
@@ -298,6 +298,8 @@ def GetDefaultHostOs():
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Marek Rusinowski <marekrusinowski@gmail.com>
|
||||
Date: Wed, 23 Mar 2022 21:09:37 +0100
|
||||
Subject: introduce OzonePlatform::electron_can_call_x11 property
|
||||
|
||||
We expose this additonal property in the OzonePlatform to be able to easily
|
||||
determine whatever we can call X11 functions without crashing the application
|
||||
at rutime. It would be best if eventually all usages of this property were
|
||||
replaced with clean ozone native implementations.
|
||||
|
||||
diff --git a/ui/ozone/platform/x11/ozone_platform_x11.cc b/ui/ozone/platform/x11/ozone_platform_x11.cc
|
||||
index 9008af973427d7dab8170449bc5767cebc9d2e9e..e312287e4aca61b51a69c8413088f56f9f704b5e 100644
|
||||
--- a/ui/ozone/platform/x11/ozone_platform_x11.cc
|
||||
+++ b/ui/ozone/platform/x11/ozone_platform_x11.cc
|
||||
@@ -200,6 +200,7 @@ class OzonePlatformX11 : public OzonePlatform,
|
||||
properties->supports_vulkan_swap_chain = true;
|
||||
properties->uses_external_vulkan_image_factory = true;
|
||||
properties->skia_can_fall_back_to_x11 = true;
|
||||
+ properties->electron_can_call_x11 = true;
|
||||
properties->platform_shows_drag_image = false;
|
||||
properties->supports_global_application_menus = true;
|
||||
properties->app_modal_dialogs_use_event_blocker = true;
|
||||
diff --git a/ui/ozone/public/ozone_platform.h b/ui/ozone/public/ozone_platform.h
|
||||
index 22ba32317a74df24249d1528dcaaa28ff18bd0f4..fa57f97520a0327be2c7f5179591ca61b801c8b0 100644
|
||||
--- a/ui/ozone/public/ozone_platform.h
|
||||
+++ b/ui/ozone/public/ozone_platform.h
|
||||
@@ -132,6 +132,10 @@ class COMPONENT_EXPORT(OZONE) OzonePlatform {
|
||||
// Linux only: determines if Skia can fall back to the X11 output device.
|
||||
bool skia_can_fall_back_to_x11 = false;
|
||||
|
||||
+ // Linux only: determines is Electron can call selected X11 functions while
|
||||
+ // it migrates to pure ozone abstractions.
|
||||
+ bool electron_can_call_x11 = false;
|
||||
+
|
||||
// Wayland only: determines whether windows which are not top level ones
|
||||
// should be given parents explicitly.
|
||||
bool set_parent_for_non_top_level_windows = false;
|
||||
72
patches/chromium/make_gtk_getlibgtk_public.patch
Normal file
72
patches/chromium/make_gtk_getlibgtk_public.patch
Normal file
@@ -0,0 +1,72 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: deepak1556 <hop2deep@gmail.com>
|
||||
Date: Thu, 7 Apr 2022 20:30:16 +0900
|
||||
Subject: Make gtk::GetLibGtk and gtk::GetLibGdkPixbuf public
|
||||
|
||||
Allows embedders to get a handle to the gtk and
|
||||
gdk_pixbuf libraries already loaded in the process.
|
||||
|
||||
diff --git a/ui/gtk/gtk_compat.cc b/ui/gtk/gtk_compat.cc
|
||||
index 7104a0d5f4489c687f3cb9e63bc7cbef59d2fa62..7449c0b7bdb0cac7340cb73292e70e6aa0336657 100644
|
||||
--- a/ui/gtk/gtk_compat.cc
|
||||
+++ b/ui/gtk/gtk_compat.cc
|
||||
@@ -66,11 +66,6 @@ void* GetLibGio() {
|
||||
return libgio;
|
||||
}
|
||||
|
||||
-void* GetLibGdkPixbuf() {
|
||||
- static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0");
|
||||
- return libgdk_pixbuf;
|
||||
-}
|
||||
-
|
||||
void* GetLibGdk3() {
|
||||
static void* libgdk3 = DlOpen("libgdk-3.so.0");
|
||||
return libgdk3;
|
||||
@@ -86,12 +81,6 @@ void* GetLibGtk4(bool check = true) {
|
||||
return libgtk4;
|
||||
}
|
||||
|
||||
-void* GetLibGtk() {
|
||||
- if (GtkCheckVersion(4))
|
||||
- return GetLibGtk4();
|
||||
- return GetLibGtk3();
|
||||
-}
|
||||
-
|
||||
bool LoadGtk3() {
|
||||
if (!GetLibGtk3(false))
|
||||
return false;
|
||||
@@ -133,6 +122,17 @@ gfx::Insets InsetsFromGtkBorder(const GtkBorder& border) {
|
||||
|
||||
} // namespace
|
||||
|
||||
+void* GetLibGdkPixbuf() {
|
||||
+ static void* libgdk_pixbuf = DlOpen("libgdk_pixbuf-2.0.so.0");
|
||||
+ return libgdk_pixbuf;
|
||||
+}
|
||||
+
|
||||
+void* GetLibGtk() {
|
||||
+ if (GtkCheckVersion(4))
|
||||
+ return GetLibGtk4();
|
||||
+ return GetLibGtk3();
|
||||
+}
|
||||
+
|
||||
bool LoadGtk() {
|
||||
static bool loaded = LoadGtkImpl();
|
||||
return loaded;
|
||||
diff --git a/ui/gtk/gtk_compat.h b/ui/gtk/gtk_compat.h
|
||||
index 72981270fe26579211afcaf3c596a412f69f5fac..2ead29619e9f69f50699970546bf048686ca643f 100644
|
||||
--- a/ui/gtk/gtk_compat.h
|
||||
+++ b/ui/gtk/gtk_compat.h
|
||||
@@ -37,6 +37,12 @@ using SkColor = uint32_t;
|
||||
|
||||
namespace gtk {
|
||||
|
||||
+// Get handle to the currently loaded gdk_pixbuf library in the process.
|
||||
+void* GetLibGdkPixbuf();
|
||||
+
|
||||
+// Get handle to the currently loaded gtk library in the process.
|
||||
+void* GetLibGtk();
|
||||
+
|
||||
// Loads libgtk and related libraries and returns true on success.
|
||||
bool LoadGtk();
|
||||
|
||||
@@ -44,7 +44,7 @@ index 9734fb620a9a4010083af41a9e5cea038556eef5..05c95fb9b15f5ccbfecaee29d360dd27
|
||||
|
||||
} // namespace
|
||||
diff --git a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
|
||||
index fedefafc9837f681ad1c3fc48d06a333fea893e2..f07a090c24382c9330e8bd8baa3de47ec76da956 100644
|
||||
index cb82b91eb2e62453bcf2e3dd47f1b44d927e37d9..a35a14928d63a25284768de2ef67f2de2bedd133 100644
|
||||
--- a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
|
||||
+++ b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm
|
||||
@@ -561,10 +561,12 @@ NSUInteger CountBridgedWindows(NSArray* child_windows) {
|
||||
@@ -167,7 +167,7 @@ index 09ada3b859e1862cbf365960422871a56af54983..58002d37ba340f84f47e2522c0d7bf7c
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn
|
||||
index 37f37c3a8e8a00cf9d4b8959ac2d97fe31629ad8..fa06bafbbaa69a20ce5a3260ca92947cb2bb9228 100644
|
||||
index 0d7d47d1260d47959b0fa9f116a039c8b8307c96..15cc28a9bbc7b33a727e7c172207262902835ccc 100644
|
||||
--- a/ui/base/BUILD.gn
|
||||
+++ b/ui/base/BUILD.gn
|
||||
@@ -317,6 +317,13 @@ component("base") {
|
||||
|
||||
@@ -6,6 +6,33 @@ Subject: mas: avoid some private APIs
|
||||
Guard usages in blink of private Mac APIs by MAS_BUILD, so they can be
|
||||
excluded for people who want to submit their apps to the Mac App store.
|
||||
|
||||
diff --git a/base/process/process_info_mac.cc b/base/process/process_info_mac.cc
|
||||
index 368405f29313d51a6eee16517b634c6d0ea95281..2553a7fbf1e8b4dea796dec3b3e906d265d3ad76 100644
|
||||
--- a/base/process/process_info_mac.cc
|
||||
+++ b/base/process/process_info_mac.cc
|
||||
@@ -5,18 +5,22 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
+#ifndef MAS_BUILD
|
||||
extern "C" {
|
||||
pid_t responsibility_get_pid_responsible_for_pid(pid_t)
|
||||
API_AVAILABLE(macosx(10.12));
|
||||
}
|
||||
+#endif
|
||||
|
||||
namespace base {
|
||||
|
||||
bool IsProcessSelfResponsible() {
|
||||
+#ifndef MAS_BUILD
|
||||
if (__builtin_available(macOS 10.14, *)) {
|
||||
const pid_t pid = getpid();
|
||||
return responsibility_get_pid_responsible_for_pid(pid) == pid;
|
||||
}
|
||||
+#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
diff --git a/content/common/pseudonymization_salt.cc b/content/common/pseudonymization_salt.cc
|
||||
index 28e003bef910abff022def659fe18d4cd0549f8a..530bcbdb5d350f6486dc1e8536f7b279be69e241 100644
|
||||
--- a/content/common/pseudonymization_salt.cc
|
||||
|
||||
@@ -7,7 +7,7 @@ This adds a callback from the network service that's used to implement
|
||||
session.setCertificateVerifyCallback.
|
||||
|
||||
diff --git a/services/network/network_context.cc b/services/network/network_context.cc
|
||||
index 8ff62f92ed6efdbfc18db53db3c5bb59c1acfe34..20373c0e86852446569c401c4a993512cb388fc7 100644
|
||||
index 2ee1a3da9ca1543d032c2e05c9b340a231f0f495..a4cd97599e2f131fe0d97ee49a44ed5b748739b7 100644
|
||||
--- a/services/network/network_context.cc
|
||||
+++ b/services/network/network_context.cc
|
||||
@@ -126,6 +126,11 @@
|
||||
@@ -128,7 +128,7 @@ index 8ff62f92ed6efdbfc18db53db3c5bb59c1acfe34..20373c0e86852446569c401c4a993512
|
||||
void NetworkContext::CreateURLLoaderFactory(
|
||||
mojo::PendingReceiver<mojom::URLLoaderFactory> receiver,
|
||||
mojom::URLLoaderFactoryParamsPtr params) {
|
||||
@@ -2226,6 +2323,9 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext(
|
||||
@@ -2235,6 +2332,9 @@ URLRequestContextOwner NetworkContext::MakeURLRequestContext(
|
||||
std::move(cert_verifier));
|
||||
cert_verifier = base::WrapUnique(cert_verifier_with_trust_anchors_);
|
||||
#endif // BUILDFLAG(IS_CHROMEOS)
|
||||
@@ -139,7 +139,7 @@ index 8ff62f92ed6efdbfc18db53db3c5bb59c1acfe34..20373c0e86852446569c401c4a993512
|
||||
|
||||
builder.SetCertVerifier(IgnoreErrorsCertVerifier::MaybeWrapCertVerifier(
|
||||
diff --git a/services/network/network_context.h b/services/network/network_context.h
|
||||
index 6de81678e62d6921d0df5944ab01705402caa568..e412608e7720004462c48698c8ec39602b2b900e 100644
|
||||
index 01befea8b354ed1dd143aa895d0d9efb0d26fd35..06a36a156501b252e91037ebac45c29c2995f624 100644
|
||||
--- a/services/network/network_context.h
|
||||
+++ b/services/network/network_context.h
|
||||
@@ -105,6 +105,7 @@ class URLMatcher;
|
||||
@@ -159,7 +159,7 @@ index 6de81678e62d6921d0df5944ab01705402caa568..e412608e7720004462c48698c8ec3960
|
||||
void ResetURLLoaderFactories() override;
|
||||
void GetCookieManager(
|
||||
mojo::PendingReceiver<mojom::CookieManager> receiver) override;
|
||||
@@ -793,6 +796,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
|
||||
@@ -795,6 +798,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
|
||||
CertVerifierWithTrustAnchors* cert_verifier_with_trust_anchors_ = nullptr;
|
||||
#endif
|
||||
|
||||
@@ -169,7 +169,7 @@ index 6de81678e62d6921d0df5944ab01705402caa568..e412608e7720004462c48698c8ec3960
|
||||
// CertNetFetcher is not used by the current platform, or if the actual
|
||||
// net::CertVerifier is instantiated outside of the network service.
|
||||
diff --git a/services/network/public/mojom/network_context.mojom b/services/network/public/mojom/network_context.mojom
|
||||
index 9cd06ee552f8e592dd9efd1e73b10e5998559c04..fa56cfed3703664232843ad26028096d95dca253 100644
|
||||
index 0b1afd416381c28e5bc96fa44562c061f44a7121..ae0a20a7a33e5a313f5545985a34e9cb93220996 100644
|
||||
--- a/services/network/public/mojom/network_context.mojom
|
||||
+++ b/services/network/public/mojom/network_context.mojom
|
||||
@@ -277,6 +277,17 @@ struct NetworkContextFilePaths {
|
||||
@@ -190,7 +190,7 @@ index 9cd06ee552f8e592dd9efd1e73b10e5998559c04..fa56cfed3703664232843ad26028096d
|
||||
// Parameters for constructing a network context.
|
||||
struct NetworkContextParams {
|
||||
// The user agent string.
|
||||
@@ -807,6 +818,9 @@ interface NetworkContext {
|
||||
@@ -821,6 +832,9 @@ interface NetworkContext {
|
||||
// Sets a client for this network context.
|
||||
SetClient(pending_remote<NetworkContextClient> client);
|
||||
|
||||
|
||||
@@ -131,10 +131,10 @@ index 951075749b24814606f494c5a89ee2adf527f512..7036323ff8ee38ae92790dfd2e216df6
|
||||
const GURL& document_url,
|
||||
mojo::PendingReceiver<blink::mojom::NotificationService> receiver);
|
||||
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
|
||||
index a1a3683b8da459a5859a2953536f3400a7fda213..602525302cfdd89bf2ddc2924076e7349de7562a 100644
|
||||
index a002e3972f1ed8ea8ff2a7febe1c6b7a8ffbe657..eebe90092c65dd9160a394b9b6eb2273b03de503 100644
|
||||
--- a/content/browser/renderer_host/render_process_host_impl.cc
|
||||
+++ b/content/browser/renderer_host/render_process_host_impl.cc
|
||||
@@ -2125,7 +2125,7 @@ void RenderProcessHostImpl::CreateNotificationService(
|
||||
@@ -2135,7 +2135,7 @@ void RenderProcessHostImpl::CreateNotificationService(
|
||||
document_url = rfh->GetLastCommittedURL();
|
||||
|
||||
storage_partition_impl_->GetPlatformNotificationContext()->CreateService(
|
||||
|
||||
250
patches/chromium/pa_support_16kb_pagesize_on_linux_arm64.patch
Normal file
250
patches/chromium/pa_support_16kb_pagesize_on_linux_arm64.patch
Normal file
@@ -0,0 +1,250 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jorrit Jongma <jorrit@jongma.org>
|
||||
Date: Tue, 12 Apr 2022 17:09:34 +0000
|
||||
Subject: Support 16kb pagesize on Linux+ARM64
|
||||
|
||||
This makes the system pagesize a run-time property.
|
||||
|
||||
ARM64 supports 4kb, 16kb, and 64kb page sizes. Previously, only 4kb
|
||||
was supported by Chromium. This patch adds 16kb support, as is used
|
||||
for example by Asahi Linux on M1 Macs. The rare 64kb case is still
|
||||
not supported due to further changes needed to SlotSpanMetadata.
|
||||
|
||||
The implementation follows the changes made to support run-time page
|
||||
size on macOS. On macOS, the required constants are conveniently
|
||||
injected before any code runs, while on Linux a function call is
|
||||
needed, complicating initialization.
|
||||
|
||||
The new PageCharacteristics structure holds the page size and shift
|
||||
as std::atomic<int> which are initialized on first use.
|
||||
|
||||
Bug: 1301788
|
||||
Change-Id: I8ceead40de53ba7a2ec248bd6ef46f2a521dd29c
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3545665
|
||||
Reviewed-by: Benoit Lize <lizeb@chromium.org>
|
||||
Reviewed-by: Mark Mentovai <mark@chromium.org>
|
||||
Commit-Queue: Mark Mentovai <mark@chromium.org>
|
||||
Cr-Commit-Position: refs/heads/main@{#991588}
|
||||
|
||||
diff --git a/AUTHORS b/AUTHORS
|
||||
index 364df55a2888c221523023facd8873fa010d40d6..f2b8d8c0d2a4474ded579212327f00489da00623 100644
|
||||
--- a/AUTHORS
|
||||
+++ b/AUTHORS
|
||||
@@ -572,6 +572,7 @@ Jongsoo Lee <leejongsoo@gmail.com>
|
||||
Joone Hur <joone.hur@intel.com>
|
||||
Joonghun Park <pjh0718@gmail.com>
|
||||
Jorge Villatoro <jorge@tomatocannon.com>
|
||||
+Jorrit Jongma <jorrit@jongma.org>
|
||||
Joseph Gentle <josephg@gmail.com>
|
||||
Joseph Lolak <joseph.lolak@samsung.com>
|
||||
Josh Triplett <josh.triplett@intel.com>
|
||||
diff --git a/base/allocator/partition_allocator/address_space_randomization.h b/base/allocator/partition_allocator/address_space_randomization.h
|
||||
index 43033d728050a8d8b03f5e4a69fa1593190d30f1..e77757c3ad512f03cd21127ebd780e7a19f12672 100644
|
||||
--- a/base/allocator/partition_allocator/address_space_randomization.h
|
||||
+++ b/base/allocator/partition_allocator/address_space_randomization.h
|
||||
@@ -121,6 +121,21 @@ AslrMask(uintptr_t bits) {
|
||||
return AslrAddress(0x20000000ULL);
|
||||
}
|
||||
|
||||
+ #elif BUILDFLAG(IS_LINUX)
|
||||
+
|
||||
+ // Linux on arm64 can use 39, 42, 48, or 52-bit user space, depending on
|
||||
+ // page size and number of levels of translation pages used. We use
|
||||
+ // 39-bit as base as all setups should support this, lowered to 38-bit
|
||||
+ // as ASLROffset() could cause a carry.
|
||||
+ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t
|
||||
+ ASLRMask() {
|
||||
+ return AslrMask(38);
|
||||
+ }
|
||||
+ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE uintptr_t
|
||||
+ ASLROffset() {
|
||||
+ return AslrAddress(0x1000000000ULL);
|
||||
+ }
|
||||
+
|
||||
#else
|
||||
|
||||
// ARM64 on Linux has 39-bit user space. Use 38 bits since ASLROffset()
|
||||
diff --git a/base/allocator/partition_allocator/page_allocator_constants.h b/base/allocator/partition_allocator/page_allocator_constants.h
|
||||
index 12515b9a02865eb8a4b2a7c15b0fcce06a8ec7f9..0a996cfdcc4a42005ffad8922f3cc55547c47d20 100644
|
||||
--- a/base/allocator/partition_allocator/page_allocator_constants.h
|
||||
+++ b/base/allocator/partition_allocator/page_allocator_constants.h
|
||||
@@ -24,6 +24,31 @@
|
||||
// elimination.
|
||||
#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const))
|
||||
|
||||
+#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
|
||||
+// This should work for all POSIX (if needed), but currently all other
|
||||
+// supported OS/architecture combinations use either hard-coded values
|
||||
+// (such as x86) or have means to determine these values without needing
|
||||
+// atomics (such as macOS on arm64).
|
||||
+
|
||||
+// Page allocator constants are run-time constant
|
||||
+#define PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR __attribute__((const))
|
||||
+
|
||||
+#include <unistd.h>
|
||||
+#include <atomic>
|
||||
+
|
||||
+namespace partition_alloc::internal {
|
||||
+
|
||||
+// Holds the current page size and shift, where size = 1 << shift
|
||||
+// Use PageAllocationGranularity(), PageAllocationGranularityShift()
|
||||
+// to initialize and retrieve these values safely.
|
||||
+struct PageCharacteristics {
|
||||
+ std::atomic<int> size;
|
||||
+ std::atomic<int> shift;
|
||||
+};
|
||||
+extern PageCharacteristics page_characteristics;
|
||||
+
|
||||
+} // namespace partition_alloc::internal
|
||||
+
|
||||
#else
|
||||
|
||||
// When defined, page size constants are fixed at compile time. When not
|
||||
@@ -38,6 +63,10 @@
|
||||
|
||||
namespace partition_alloc::internal {
|
||||
|
||||
+// Forward declaration, implementation below
|
||||
+PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
|
||||
+PageAllocationGranularity();
|
||||
+
|
||||
PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
|
||||
PageAllocationGranularityShift() {
|
||||
#if BUILDFLAG(IS_WIN) || defined(ARCH_CPU_PPC64)
|
||||
@@ -50,6 +79,15 @@ PageAllocationGranularityShift() {
|
||||
return 14; // 16kB
|
||||
#elif BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS)
|
||||
return vm_page_shift;
|
||||
+#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
|
||||
+ // arm64 supports 4kb (shift = 12), 16kb (shift = 14), and 64kb (shift = 16)
|
||||
+ // page sizes. Retrieve from or initialize cache.
|
||||
+ int shift = page_characteristics.shift.load(std::memory_order_relaxed);
|
||||
+ if (UNLIKELY(shift == 0)) {
|
||||
+ shift = __builtin_ctz((int)PageAllocationGranularity());
|
||||
+ page_characteristics.shift.store(shift, std::memory_order_relaxed);
|
||||
+ }
|
||||
+ return shift;
|
||||
#else
|
||||
return 12; // 4kB
|
||||
#endif
|
||||
@@ -59,8 +97,17 @@ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
|
||||
PageAllocationGranularity() {
|
||||
#if BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS)
|
||||
// This is literally equivalent to |1 << PageAllocationGranularityShift()|
|
||||
- // below, but was separated out for OS_APPLE to avoid << on a non-constexpr.
|
||||
+ // below, but was separated out for IS_APPLE to avoid << on a non-constexpr.
|
||||
return vm_page_size;
|
||||
+#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
|
||||
+ // arm64 supports 4kb, 16kb, and 64kb page sizes. Retrieve from or
|
||||
+ // initialize cache.
|
||||
+ int size = page_characteristics.size.load(std::memory_order_relaxed);
|
||||
+ if (UNLIKELY(size == 0)) {
|
||||
+ size = getpagesize();
|
||||
+ page_characteristics.size.store(size, std::memory_order_relaxed);
|
||||
+ }
|
||||
+ return size;
|
||||
#else
|
||||
return 1 << PageAllocationGranularityShift();
|
||||
#endif
|
||||
@@ -90,9 +137,11 @@ SystemPageShift() {
|
||||
|
||||
PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
|
||||
SystemPageSize() {
|
||||
-#if BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS)
|
||||
+#if (BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS)) || \
|
||||
+ (BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64))
|
||||
// This is literally equivalent to |1 << SystemPageShift()| below, but was
|
||||
- // separated out for 64-bit OS_APPLE to avoid << on a non-constexpr.
|
||||
+ // separated out for 64-bit IS_APPLE and arm64 on Linux to avoid << on a
|
||||
+ // non-constexpr.
|
||||
return PageAllocationGranularity();
|
||||
#else
|
||||
return 1 << SystemPageShift();
|
||||
diff --git a/base/allocator/partition_allocator/partition_address_space.cc b/base/allocator/partition_allocator/partition_address_space.cc
|
||||
index 71075090cc64bfac2d443a3ee4e210d7aca8a3e5..1e9dc5d312e154ef7a1c66aaef4de3c45a69c912 100644
|
||||
--- a/base/allocator/partition_allocator/partition_address_space.cc
|
||||
+++ b/base/allocator/partition_allocator/partition_address_space.cc
|
||||
@@ -167,6 +167,12 @@ void PartitionAddressSpace::UninitConfigurablePoolForTesting() {
|
||||
setup_.configurable_pool_ = 0;
|
||||
}
|
||||
|
||||
+#if BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
|
||||
+
|
||||
+PageCharacteristics page_characteristics;
|
||||
+
|
||||
+#endif // BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
|
||||
+
|
||||
#endif // defined(PA_HAS_64_BITS_POINTERS)
|
||||
|
||||
} // namespace partition_alloc::internal
|
||||
diff --git a/base/allocator/partition_allocator/partition_alloc_constants.h b/base/allocator/partition_allocator/partition_alloc_constants.h
|
||||
index e54a9a4a3bfafc1a174ed3f3b3cfa98e9d0794f3..1a1c110dc7b49f59e1b9cb7fa0297b90f70880ec 100644
|
||||
--- a/base/allocator/partition_allocator/partition_alloc_constants.h
|
||||
+++ b/base/allocator/partition_allocator/partition_alloc_constants.h
|
||||
@@ -59,10 +59,11 @@ PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
|
||||
PartitionPageShift() {
|
||||
return 18; // 256 KiB
|
||||
}
|
||||
-#elif BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS)
|
||||
+#elif (BUILDFLAG(IS_APPLE) && defined(ARCH_CPU_64_BITS)) || \
|
||||
+ (BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64))
|
||||
PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
|
||||
PartitionPageShift() {
|
||||
- return vm_page_shift + 2;
|
||||
+ return PageAllocationGranularityShift() + 2;
|
||||
}
|
||||
#else
|
||||
PAGE_ALLOCATOR_CONSTANTS_DECLARE_CONSTEXPR ALWAYS_INLINE size_t
|
||||
diff --git a/base/allocator/partition_allocator/partition_page.h b/base/allocator/partition_allocator/partition_page.h
|
||||
index 5ee5e2c3843a6fa7d8717a619b5d8ccec2edd8f3..efaf910f2b4e9db812402db6566bb7b6aeb354f2 100644
|
||||
--- a/base/allocator/partition_allocator/partition_page.h
|
||||
+++ b/base/allocator/partition_allocator/partition_page.h
|
||||
@@ -134,6 +134,12 @@ struct __attribute__((packed)) SlotSpanMetadata {
|
||||
// PartitionPageSize() is 4 times the OS page size.
|
||||
static constexpr size_t kMaxSlotsPerSlotSpan =
|
||||
4 * (1 << 14) / kSmallestBucket;
|
||||
+#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
|
||||
+ // System page size can be 4, 16, or 64 kiB on Linux on arm64. 64 kiB is
|
||||
+ // currently (kMaxSlotsPerSlotSpanBits == 13) not supported by the code,
|
||||
+ // so we use the 16 kiB maximum (64 kiB will crash).
|
||||
+ static constexpr size_t kMaxSlotsPerSlotSpan =
|
||||
+ 4 * (1 << 14) / kSmallestBucket;
|
||||
#else
|
||||
// A slot span can "span" multiple PartitionPages, but then its slot size is
|
||||
// larger, so it doesn't have as many slots.
|
||||
diff --git a/base/allocator/partition_allocator/partition_root.cc b/base/allocator/partition_allocator/partition_root.cc
|
||||
index 98e3940c44cb7460b91305aab0fcc24ef739b979..31f6519227c0c6c5d6235cff8567e46ebe010d24 100644
|
||||
--- a/base/allocator/partition_allocator/partition_root.cc
|
||||
+++ b/base/allocator/partition_allocator/partition_root.cc
|
||||
@@ -309,11 +309,12 @@ static size_t PartitionPurgeSlotSpan(
|
||||
constexpr size_t kMaxSlotCount =
|
||||
(PartitionPageSize() * kMaxPartitionPagesPerRegularSlotSpan) /
|
||||
SystemPageSize();
|
||||
-#elif BUILDFLAG(IS_APPLE)
|
||||
+#elif BUILDFLAG(IS_APPLE) || (BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64))
|
||||
// It's better for slot_usage to be stack-allocated and fixed-size, which
|
||||
- // demands that its size be constexpr. On OS_APPLE, PartitionPageSize() is
|
||||
- // always SystemPageSize() << 2, so regardless of what the run time page size
|
||||
- // is, kMaxSlotCount can always be simplified to this expression.
|
||||
+ // demands that its size be constexpr. On OS_APPLE and Linux on arm64,
|
||||
+ // PartitionPageSize() is always SystemPageSize() << 2, so regardless of
|
||||
+ // what the run time page size is, kMaxSlotCount can always be simplified
|
||||
+ // to this expression.
|
||||
constexpr size_t kMaxSlotCount = 4 * kMaxPartitionPagesPerRegularSlotSpan;
|
||||
PA_CHECK(kMaxSlotCount ==
|
||||
(PartitionPageSize() * kMaxPartitionPagesPerRegularSlotSpan) /
|
||||
@@ -633,6 +634,14 @@ void PartitionRoot<thread_safe>::Init(PartitionOptions opts) {
|
||||
// apple OSes.
|
||||
PA_CHECK((SystemPageSize() == (size_t{1} << 12)) ||
|
||||
(SystemPageSize() == (size_t{1} << 14)));
|
||||
+#elif BUILDFLAG(IS_LINUX) && defined(ARCH_CPU_ARM64)
|
||||
+ // Check runtime pagesize. Though the code is currently the same, it is
|
||||
+ // not merged with the IS_APPLE case above as a 1 << 16 case needs to be
|
||||
+ // added here in the future, to allow 64 kiB pagesize. That is only
|
||||
+ // supported on Linux on arm64, not on IS_APPLE, but not yet present here
|
||||
+ // as the rest of the partition allocator does not currently support it.
|
||||
+ PA_CHECK((SystemPageSize() == (size_t{1} << 12)) ||
|
||||
+ (SystemPageSize() == (size_t{1} << 14)));
|
||||
#endif
|
||||
|
||||
::partition_alloc::internal::ScopedGuard guard{lock_};
|
||||
@@ -61,10 +61,10 @@ index 1d8415814c6245e3f2dfd01de7a2de11f09cdc7a..6db48efe454820e242b862edbfaf4d40
|
||||
}
|
||||
|
||||
diff --git a/ui/color/win/native_color_mixers_win.cc b/ui/color/win/native_color_mixers_win.cc
|
||||
index 5faab22f665829e04cc07125f2486b9cb35f1f56..9776dbcc576c62ee44cbdd0d59542856363fb8f4 100644
|
||||
index 0620a389750649218865de06ed5d66f9ffe71871..575dcd925807263a9a5657d5156a3772421a0ed5 100644
|
||||
--- a/ui/color/win/native_color_mixers_win.cc
|
||||
+++ b/ui/color/win/native_color_mixers_win.cc
|
||||
@@ -136,16 +136,22 @@ void AddNativeUiColorMixer(ColorProvider* provider,
|
||||
@@ -136,6 +136,10 @@ void AddNativeUiColorMixer(ColorProvider* provider,
|
||||
SetAlpha(kColorNotificationInputForeground, gfx::kGoogleGreyAlpha700);
|
||||
mixer[kColorSliderTrack] = AlphaBlend(
|
||||
kColorNativeHighlight, kColorNativeWindow, gfx::kGoogleGreyAlpha400);
|
||||
@@ -75,8 +75,10 @@ index 5faab22f665829e04cc07125f2486b9cb35f1f56..9776dbcc576c62ee44cbdd0d59542856
|
||||
|
||||
// Window Background
|
||||
mixer[kColorBubbleFooterBackground] = {kColorNativeWindow};
|
||||
@@ -143,11 +147,13 @@ void AddNativeUiColorMixer(ColorProvider* provider,
|
||||
mixer[kColorFrameActive] = {ui::kColorNativeWindow};
|
||||
mixer[kColorFrameInactive] = {ui::kColorNativeWindow};
|
||||
mixer[kColorTooltipBackground] = {kColorNativeWindow};
|
||||
mixer[kColorButtonBackgroundProminentDisabled] = {kColorNativeWindow};
|
||||
+ mixer[kColorResultsTableNormalBackground] = {kColorNativeWindow};
|
||||
|
||||
// Window Text
|
||||
@@ -87,7 +89,7 @@ index 5faab22f665829e04cc07125f2486b9cb35f1f56..9776dbcc576c62ee44cbdd0d59542856
|
||||
|
||||
// Hyperlinks
|
||||
mixer[kColorLinkForeground] = {kColorNativeHotlight};
|
||||
@@ -179,6 +185,7 @@ void AddNativeUiColorMixer(ColorProvider* provider,
|
||||
@@ -181,6 +187,7 @@ void AddNativeUiColorMixer(ColorProvider* provider,
|
||||
mixer[kColorTextfieldForeground] = {kColorNativeBtnText};
|
||||
mixer[kColorTextfieldForegroundPlaceholder] = {kColorNativeBtnText};
|
||||
mixer[kColorTextfieldForegroundDisabled] = {kColorNativeBtnText};
|
||||
|
||||
@@ -0,0 +1,641 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Darshan Sen <raisinten@gmail.com>
|
||||
Date: Fri, 17 Jun 2022 13:19:32 +0530
|
||||
Subject: posix: Replace DoubleForkAndExec() with ForkAndSpawn()
|
||||
|
||||
The DoubleForkAndExec() function was taking over 622 milliseconds to run
|
||||
on macOS 11 (BigSur) on Intel i5-1038NG7. I did some debugging by adding
|
||||
some custom traces and found that the fork() syscall is the bottleneck
|
||||
here, i.e., the first fork() takes around 359 milliseconds and the
|
||||
nested fork() takes around 263 milliseconds. Replacing the nested fork()
|
||||
and exec() with posix_spawn() reduces the time consumption to 257
|
||||
milliseconds!
|
||||
|
||||
See https://github.com/libuv/libuv/pull/3064 to know why fork() is so
|
||||
slow on macOS and why posix_spawn() is a better replacement.
|
||||
|
||||
Another point to note is that even base::LaunchProcess() from Chromium
|
||||
calls posix_spawnp() on macOS -
|
||||
https://source.chromium.org/chromium/chromium/src/+/8f8d82dea0fa8f11f57c74dbb65126f8daba58f7:base/process/launch_mac.cc;l=295-296
|
||||
|
||||
Change-Id: I25c6ee9629a1ae5d0c32b361b56a1ce0b4b0fd26
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3641386
|
||||
Reviewed-by: Mark Mentovai <mark@chromium.org>
|
||||
Commit-Queue: Mark Mentovai <mark@chromium.org>
|
||||
|
||||
diff --git a/third_party/crashpad/crashpad/AUTHORS b/third_party/crashpad/crashpad/AUTHORS
|
||||
index 8dcac3238870920d374b86033d05d77ebde351e9..02103924332eddbd158c04f8a395bb4a247e8bd9 100644
|
||||
--- a/third_party/crashpad/crashpad/AUTHORS
|
||||
+++ b/third_party/crashpad/crashpad/AUTHORS
|
||||
@@ -12,3 +12,4 @@ Opera Software ASA
|
||||
Vewd Software AS
|
||||
LG Electronics, Inc.
|
||||
MIPS Technologies, Inc.
|
||||
+Darshan Sen <raisinten@gmail.com>
|
||||
diff --git a/third_party/crashpad/crashpad/client/crashpad_client_linux.cc b/third_party/crashpad/crashpad/client/crashpad_client_linux.cc
|
||||
index 35742be01f2c5c9f834bb7d2f03b261193bc69f2..2769936403ca6d4a1bb6c1f61ac6db776feba6d6 100644
|
||||
--- a/third_party/crashpad/crashpad/client/crashpad_client_linux.cc
|
||||
+++ b/third_party/crashpad/crashpad/client/crashpad_client_linux.cc
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "util/linux/socket.h"
|
||||
#include "util/misc/address_sanitizer.h"
|
||||
#include "util/misc/from_pointer_cast.h"
|
||||
-#include "util/posix/double_fork_and_exec.h"
|
||||
+#include "util/posix/fork_and_spawn.h"
|
||||
#include "util/posix/scoped_mmap.h"
|
||||
#include "util/posix/signals.h"
|
||||
|
||||
@@ -445,7 +445,7 @@ bool CrashpadClient::StartHandler(
|
||||
|
||||
argv.push_back(FormatArgumentInt("initial-client-fd", handler_sock.get()));
|
||||
argv.push_back("--shared-client-connection");
|
||||
- if (!DoubleForkAndExec(argv, nullptr, handler_sock.get(), false, nullptr)) {
|
||||
+ if (!ForkAndSpawn(argv, nullptr, handler_sock.get(), false, nullptr)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -600,7 +600,7 @@ bool CrashpadClient::StartJavaHandlerForClient(
|
||||
int socket) {
|
||||
std::vector<std::string> argv = BuildAppProcessArgs(
|
||||
class_name, database, metrics_dir, url, annotations, arguments, socket);
|
||||
- return DoubleForkAndExec(argv, env, socket, false, nullptr);
|
||||
+ return ForkAndSpawn(argv, env, socket, false, nullptr);
|
||||
}
|
||||
|
||||
bool CrashpadClient::StartHandlerWithLinkerAtCrash(
|
||||
@@ -649,7 +649,7 @@ bool CrashpadClient::StartHandlerWithLinkerForClient(
|
||||
annotations,
|
||||
arguments,
|
||||
socket);
|
||||
- return DoubleForkAndExec(argv, env, socket, false, nullptr);
|
||||
+ return ForkAndSpawn(argv, env, socket, false, nullptr);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -683,7 +683,7 @@ bool CrashpadClient::StartHandlerForClient(
|
||||
|
||||
argv.push_back(FormatArgumentInt("initial-client-fd", socket));
|
||||
|
||||
- return DoubleForkAndExec(argv, nullptr, socket, true, nullptr);
|
||||
+ return ForkAndSpawn(argv, nullptr, socket, true, nullptr);
|
||||
}
|
||||
|
||||
// static
|
||||
diff --git a/third_party/crashpad/crashpad/client/crashpad_client_mac.cc b/third_party/crashpad/crashpad/client/crashpad_client_mac.cc
|
||||
index d25bfb71638a4837d40950df770b461d8beac351..585bac910a4b6d3fef10ab23b86a04c2985173b8 100644
|
||||
--- a/third_party/crashpad/crashpad/client/crashpad_client_mac.cc
|
||||
+++ b/third_party/crashpad/crashpad/client/crashpad_client_mac.cc
|
||||
@@ -36,7 +36,7 @@
|
||||
#include "util/mach/notify_server.h"
|
||||
#include "util/misc/clock.h"
|
||||
#include "util/misc/implicit_cast.h"
|
||||
-#include "util/posix/double_fork_and_exec.h"
|
||||
+#include "util/posix/fork_and_spawn.h"
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
@@ -343,7 +343,7 @@ class HandlerStarter final : public NotifyServer::DefaultInterface {
|
||||
// this parent process, which was probably using the exception server now
|
||||
// being restarted. The handler can’t monitor itself for its own crashes via
|
||||
// this interface.
|
||||
- if (!DoubleForkAndExec(
|
||||
+ if (!ForkAndSpawn(
|
||||
argv,
|
||||
nullptr,
|
||||
server_write_fd.get(),
|
||||
diff --git a/third_party/crashpad/crashpad/handler/linux/cros_crash_report_exception_handler.cc b/third_party/crashpad/crashpad/handler/linux/cros_crash_report_exception_handler.cc
|
||||
index 9e58d94aa499fdb7271a78ea21a1dcc1b12e3a52..3caa3b987b35be575558a312026cf6f19485c418 100644
|
||||
--- a/third_party/crashpad/crashpad/handler/linux/cros_crash_report_exception_handler.cc
|
||||
+++ b/third_party/crashpad/crashpad/handler/linux/cros_crash_report_exception_handler.cc
|
||||
@@ -29,7 +29,7 @@
|
||||
#include "util/linux/ptrace_client.h"
|
||||
#include "util/misc/metrics.h"
|
||||
#include "util/misc/uuid.h"
|
||||
-#include "util/posix/double_fork_and_exec.h"
|
||||
+#include "util/posix/fork_and_spawn.h"
|
||||
|
||||
namespace crashpad {
|
||||
|
||||
@@ -266,12 +266,11 @@ bool CrosCrashReportExceptionHandler::HandleExceptionWithConnection(
|
||||
argv.push_back("--always_allow_feedback");
|
||||
}
|
||||
|
||||
- if (!DoubleForkAndExec(argv,
|
||||
- nullptr /* envp */,
|
||||
- file_writer.fd() /* preserve_fd */,
|
||||
- false /* use_path */,
|
||||
- nullptr /* child_function */)) {
|
||||
- LOG(ERROR) << "DoubleForkAndExec failed";
|
||||
+ if (!ForkAndSpawn(argv,
|
||||
+ nullptr /* envp */,
|
||||
+ file_writer.fd() /* preserve_fd */,
|
||||
+ false /* use_path */,
|
||||
+ nullptr /* child_function */)) {
|
||||
Metrics::ExceptionCaptureResult(
|
||||
Metrics::CaptureResult::kFinishedWritingCrashReportFailed);
|
||||
return false;
|
||||
diff --git a/third_party/crashpad/crashpad/util/BUILD.gn b/third_party/crashpad/crashpad/util/BUILD.gn
|
||||
index 8251312c78e1c1bfc4aff8fa8b7ade1f5c191e33..81c2484461843268bd8a6c21de3d7fd2ea504ac4 100644
|
||||
--- a/third_party/crashpad/crashpad/util/BUILD.gn
|
||||
+++ b/third_party/crashpad/crashpad/util/BUILD.gn
|
||||
@@ -296,10 +296,10 @@ crashpad_static_library("util") {
|
||||
sources += [
|
||||
"posix/close_multiple.cc",
|
||||
"posix/close_multiple.h",
|
||||
- "posix/double_fork_and_exec.cc",
|
||||
- "posix/double_fork_and_exec.h",
|
||||
"posix/drop_privileges.cc",
|
||||
"posix/drop_privileges.h",
|
||||
+ "posix/fork_and_spawn.cc",
|
||||
+ "posix/fork_and_spawn.h",
|
||||
"posix/process_info.h",
|
||||
|
||||
# These map signals to and from strings. While Fuchsia defines some of
|
||||
diff --git a/third_party/crashpad/crashpad/util/posix/double_fork_and_exec.cc b/third_party/crashpad/crashpad/util/posix/double_fork_and_exec.cc
|
||||
deleted file mode 100644
|
||||
index 1960430954d3f6459dce688493db5c42047567b0..0000000000000000000000000000000000000000
|
||||
--- a/third_party/crashpad/crashpad/util/posix/double_fork_and_exec.cc
|
||||
+++ /dev/null
|
||||
@@ -1,166 +0,0 @@
|
||||
-// Copyright 2017 The Crashpad Authors. All rights reserved.
|
||||
-//
|
||||
-// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
-// you may not use this file except in compliance with the License.
|
||||
-// You may obtain a copy of the License at
|
||||
-//
|
||||
-// http://www.apache.org/licenses/LICENSE-2.0
|
||||
-//
|
||||
-// Unless required by applicable law or agreed to in writing, software
|
||||
-// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
-// See the License for the specific language governing permissions and
|
||||
-// limitations under the License.
|
||||
-
|
||||
-#include "util/posix/double_fork_and_exec.h"
|
||||
-
|
||||
-#include <stdlib.h>
|
||||
-#include <string.h>
|
||||
-#include <sys/wait.h>
|
||||
-#include <unistd.h>
|
||||
-
|
||||
-#include "base/check_op.h"
|
||||
-#include "base/logging.h"
|
||||
-#include "base/posix/eintr_wrapper.h"
|
||||
-#include "base/strings/stringprintf.h"
|
||||
-#include "util/posix/close_multiple.h"
|
||||
-
|
||||
-namespace crashpad {
|
||||
-
|
||||
-bool DoubleForkAndExec(const std::vector<std::string>& argv,
|
||||
- const std::vector<std::string>* envp,
|
||||
- int preserve_fd,
|
||||
- bool use_path,
|
||||
- void (*child_function)()) {
|
||||
- DCHECK(!envp || !use_path);
|
||||
-
|
||||
- // argv_c contains const char* pointers and is terminated by nullptr. This is
|
||||
- // suitable for passing to execv(). Although argv_c is not used in the parent
|
||||
- // process, it must be built in the parent process because it’s unsafe to do
|
||||
- // so in the child or grandchild process.
|
||||
- std::vector<const char*> argv_c;
|
||||
- argv_c.reserve(argv.size() + 1);
|
||||
- for (const std::string& argument : argv) {
|
||||
- argv_c.push_back(argument.c_str());
|
||||
- }
|
||||
- argv_c.push_back(nullptr);
|
||||
-
|
||||
- std::vector<const char*> envp_c;
|
||||
- if (envp) {
|
||||
- envp_c.reserve(envp->size() + 1);
|
||||
- for (const std::string& variable : *envp) {
|
||||
- envp_c.push_back(variable.c_str());
|
||||
- }
|
||||
- envp_c.push_back(nullptr);
|
||||
- }
|
||||
-
|
||||
- // Double-fork(). The three processes involved are parent, child, and
|
||||
- // grandchild. The grandchild will call execv(). The child exits immediately
|
||||
- // after spawning the grandchild, so the grandchild becomes an orphan and its
|
||||
- // parent process ID becomes 1. This relieves the parent and child of the
|
||||
- // responsibility to reap the grandchild with waitpid() or similar. The
|
||||
- // grandchild is expected to outlive the parent process, so the parent
|
||||
- // shouldn’t be concerned with reaping it. This approach means that accidental
|
||||
- // early termination of the handler process will not result in a zombie
|
||||
- // process.
|
||||
- pid_t pid = fork();
|
||||
- if (pid < 0) {
|
||||
- PLOG(ERROR) << "fork";
|
||||
- return false;
|
||||
- }
|
||||
-
|
||||
- if (pid == 0) {
|
||||
- // Child process.
|
||||
-
|
||||
- if (child_function) {
|
||||
- child_function();
|
||||
- }
|
||||
-
|
||||
- // Call setsid(), creating a new process group and a new session, both led
|
||||
- // by this process. The new process group has no controlling terminal. This
|
||||
- // disconnects it from signals generated by the parent process’ terminal.
|
||||
- //
|
||||
- // setsid() is done in the child instead of the grandchild so that the
|
||||
- // grandchild will not be a session leader. If it were a session leader, an
|
||||
- // accidental open() of a terminal device without O_NOCTTY would make that
|
||||
- // terminal the controlling terminal.
|
||||
- //
|
||||
- // It’s not desirable for the grandchild to have a controlling terminal. The
|
||||
- // grandchild manages its own lifetime, such as by monitoring clients on its
|
||||
- // own and exiting when it loses all clients and when it deems it
|
||||
- // appropraite to do so. It may serve clients in different process groups or
|
||||
- // sessions than its original client, and receiving signals intended for its
|
||||
- // original client’s process group could be harmful in that case.
|
||||
- PCHECK(setsid() != -1) << "setsid";
|
||||
-
|
||||
- pid = fork();
|
||||
- if (pid < 0) {
|
||||
- PLOG(FATAL) << "fork";
|
||||
- }
|
||||
-
|
||||
- if (pid > 0) {
|
||||
- // Child process.
|
||||
-
|
||||
- // _exit() instead of exit(), because fork() was called.
|
||||
- _exit(EXIT_SUCCESS);
|
||||
- }
|
||||
-
|
||||
- // Grandchild process.
|
||||
-
|
||||
- CloseMultipleNowOrOnExec(STDERR_FILENO + 1, preserve_fd);
|
||||
-
|
||||
- // &argv_c[0] is a pointer to a pointer to const char data, but because of
|
||||
- // how C (not C++) works, execvp() wants a pointer to a const pointer to
|
||||
- // char data. It modifies neither the data nor the pointers, so the
|
||||
- // const_cast is safe.
|
||||
- char* const* argv_for_execv = const_cast<char* const*>(&argv_c[0]);
|
||||
-
|
||||
- if (envp) {
|
||||
- // This cast is safe for the same reason that the argv_for_execv cast is.
|
||||
- char* const* envp_for_execv = const_cast<char* const*>(&envp_c[0]);
|
||||
- execve(argv_for_execv[0], argv_for_execv, envp_for_execv);
|
||||
- PLOG(FATAL) << "execve " << argv_for_execv[0];
|
||||
- }
|
||||
-
|
||||
- if (use_path) {
|
||||
- execvp(argv_for_execv[0], argv_for_execv);
|
||||
- PLOG(FATAL) << "execvp " << argv_for_execv[0];
|
||||
- }
|
||||
-
|
||||
- execv(argv_for_execv[0], argv_for_execv);
|
||||
- PLOG(FATAL) << "execv " << argv_for_execv[0];
|
||||
- }
|
||||
-
|
||||
- // waitpid() for the child, so that it does not become a zombie process. The
|
||||
- // child normally exits quickly.
|
||||
- //
|
||||
- // Failures from this point on may result in the accumulation of a zombie, but
|
||||
- // should not be considered fatal. Log only warnings, but don’t treat these
|
||||
- // failures as a failure of the function overall.
|
||||
- int status;
|
||||
- pid_t wait_pid = HANDLE_EINTR(waitpid(pid, &status, 0));
|
||||
- if (wait_pid == -1) {
|
||||
- PLOG(WARNING) << "waitpid";
|
||||
- return true;
|
||||
- }
|
||||
- DCHECK_EQ(wait_pid, pid);
|
||||
-
|
||||
- if (WIFSIGNALED(status)) {
|
||||
- int sig = WTERMSIG(status);
|
||||
- LOG(WARNING) << base::StringPrintf(
|
||||
- "intermediate process terminated by signal %d (%s)%s",
|
||||
- sig,
|
||||
- strsignal(sig),
|
||||
- WCOREDUMP(status) ? " (core dumped)" : "");
|
||||
- } else if (!WIFEXITED(status)) {
|
||||
- LOG(WARNING) << base::StringPrintf(
|
||||
- "intermediate process: unknown termination 0x%x", status);
|
||||
- } else if (WEXITSTATUS(status) != EXIT_SUCCESS) {
|
||||
- LOG(WARNING) << "intermediate process exited with code "
|
||||
- << WEXITSTATUS(status);
|
||||
- }
|
||||
-
|
||||
- return true;
|
||||
-}
|
||||
-
|
||||
-} // namespace crashpad
|
||||
diff --git a/third_party/crashpad/crashpad/util/posix/fork_and_spawn.cc b/third_party/crashpad/crashpad/util/posix/fork_and_spawn.cc
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..c6a95bbfdcba45995b0034789c8bdb4423a25642
|
||||
--- /dev/null
|
||||
+++ b/third_party/crashpad/crashpad/util/posix/fork_and_spawn.cc
|
||||
@@ -0,0 +1,235 @@
|
||||
+// Copyright 2017 The Crashpad Authors. All rights reserved.
|
||||
+//
|
||||
+// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
+// you may not use this file except in compliance with the License.
|
||||
+// You may obtain a copy of the License at
|
||||
+//
|
||||
+// http://www.apache.org/licenses/LICENSE-2.0
|
||||
+//
|
||||
+// Unless required by applicable law or agreed to in writing, software
|
||||
+// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
+// See the License for the specific language governing permissions and
|
||||
+// limitations under the License.
|
||||
+
|
||||
+#include "util/posix/fork_and_spawn.h"
|
||||
+
|
||||
+#include <errno.h>
|
||||
+#include <spawn.h>
|
||||
+#include <stdlib.h>
|
||||
+#include <string.h>
|
||||
+#include <sys/wait.h>
|
||||
+#include <unistd.h>
|
||||
+
|
||||
+#include "base/check.h"
|
||||
+#include "base/check_op.h"
|
||||
+#include "base/logging.h"
|
||||
+#include "base/posix/eintr_wrapper.h"
|
||||
+#include "base/strings/stringprintf.h"
|
||||
+#include "build/build_config.h"
|
||||
+#include "util/posix/close_multiple.h"
|
||||
+
|
||||
+extern char** environ;
|
||||
+
|
||||
+namespace crashpad {
|
||||
+
|
||||
+namespace {
|
||||
+
|
||||
+#if BUILDFLAG(IS_APPLE)
|
||||
+
|
||||
+class PosixSpawnAttr {
|
||||
+ public:
|
||||
+ PosixSpawnAttr() {
|
||||
+ PCHECK((errno = posix_spawnattr_init(&attr_)) == 0)
|
||||
+ << "posix_spawnattr_init";
|
||||
+ }
|
||||
+
|
||||
+ PosixSpawnAttr(const PosixSpawnAttr&) = delete;
|
||||
+ PosixSpawnAttr& operator=(const PosixSpawnAttr&) = delete;
|
||||
+
|
||||
+ ~PosixSpawnAttr() {
|
||||
+ PCHECK((errno = posix_spawnattr_destroy(&attr_)) == 0)
|
||||
+ << "posix_spawnattr_destroy";
|
||||
+ }
|
||||
+
|
||||
+ void SetFlags(short flags) {
|
||||
+ PCHECK((errno = posix_spawnattr_setflags(&attr_, flags)) == 0)
|
||||
+ << "posix_spawnattr_setflags";
|
||||
+ }
|
||||
+
|
||||
+ const posix_spawnattr_t* Get() const { return &attr_; }
|
||||
+
|
||||
+ private:
|
||||
+ posix_spawnattr_t attr_;
|
||||
+};
|
||||
+
|
||||
+class PosixSpawnFileActions {
|
||||
+ public:
|
||||
+ PosixSpawnFileActions() {
|
||||
+ PCHECK((errno = posix_spawn_file_actions_init(&file_actions_)) == 0)
|
||||
+ << "posix_spawn_file_actions_init";
|
||||
+ }
|
||||
+
|
||||
+ PosixSpawnFileActions(const PosixSpawnFileActions&) = delete;
|
||||
+ PosixSpawnFileActions& operator=(const PosixSpawnFileActions&) = delete;
|
||||
+
|
||||
+ ~PosixSpawnFileActions() {
|
||||
+ PCHECK((errno = posix_spawn_file_actions_destroy(&file_actions_)) == 0)
|
||||
+ << "posix_spawn_file_actions_destroy";
|
||||
+ }
|
||||
+
|
||||
+ void AddInheritedFileDescriptor(int fd) {
|
||||
+ PCHECK((errno = posix_spawn_file_actions_addinherit_np(&file_actions_,
|
||||
+ fd)) == 0)
|
||||
+ << "posix_spawn_file_actions_addinherit_np";
|
||||
+ }
|
||||
+
|
||||
+ const posix_spawn_file_actions_t* Get() const { return &file_actions_; }
|
||||
+
|
||||
+ private:
|
||||
+ posix_spawn_file_actions_t file_actions_;
|
||||
+};
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
+} // namespace
|
||||
+
|
||||
+bool ForkAndSpawn(const std::vector<std::string>& argv,
|
||||
+ const std::vector<std::string>* envp,
|
||||
+ int preserve_fd,
|
||||
+ bool use_path,
|
||||
+ void (*child_function)()) {
|
||||
+ // argv_c contains const char* pointers and is terminated by nullptr. This is
|
||||
+ // suitable for passing to posix_spawn() or posix_spawnp(). Although argv_c is
|
||||
+ // not used in the parent process, it must be built in the parent process
|
||||
+ // because it’s unsafe to do so in the child.
|
||||
+ std::vector<const char*> argv_c;
|
||||
+ argv_c.reserve(argv.size() + 1);
|
||||
+ for (const std::string& argument : argv) {
|
||||
+ argv_c.push_back(argument.c_str());
|
||||
+ }
|
||||
+ argv_c.push_back(nullptr);
|
||||
+
|
||||
+ std::vector<const char*> envp_c;
|
||||
+ if (envp) {
|
||||
+ envp_c.reserve(envp->size() + 1);
|
||||
+ for (const std::string& variable : *envp) {
|
||||
+ envp_c.push_back(variable.c_str());
|
||||
+ }
|
||||
+ envp_c.push_back(nullptr);
|
||||
+ }
|
||||
+
|
||||
+ // The three processes involved are parent, child, and grandchild. The child
|
||||
+ // exits immediately after spawning the grandchild, so the grandchild becomes
|
||||
+ // an orphan and its parent process ID becomes 1. This relieves the parent and
|
||||
+ // child of the responsibility to reap the grandchild with waitpid() or
|
||||
+ // similar. The grandchild is expected to outlive the parent process, so the
|
||||
+ // parent shouldn’t be concerned with reaping it. This approach means that
|
||||
+ // accidental early termination of the handler process will not result in a
|
||||
+ // zombie process.
|
||||
+ pid_t pid = fork();
|
||||
+ if (pid < 0) {
|
||||
+ PLOG(ERROR) << "fork";
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ if (pid == 0) {
|
||||
+ // Child process.
|
||||
+
|
||||
+ if (child_function) {
|
||||
+ child_function();
|
||||
+ }
|
||||
+
|
||||
+ // Call setsid(), creating a new process group and a new session, both led
|
||||
+ // by this process. The new process group has no controlling terminal. This
|
||||
+ // disconnects it from signals generated by the parent process’ terminal.
|
||||
+ //
|
||||
+ // setsid() is done in the child instead of the grandchild so that the
|
||||
+ // grandchild will not be a session leader. If it were a session leader, an
|
||||
+ // accidental open() of a terminal device without O_NOCTTY would make that
|
||||
+ // terminal the controlling terminal.
|
||||
+ //
|
||||
+ // It’s not desirable for the grandchild to have a controlling terminal. The
|
||||
+ // grandchild manages its own lifetime, such as by monitoring clients on its
|
||||
+ // own and exiting when it loses all clients and when it deems it
|
||||
+ // appropraite to do so. It may serve clients in different process groups or
|
||||
+ // sessions than its original client, and receiving signals intended for its
|
||||
+ // original client’s process group could be harmful in that case.
|
||||
+ PCHECK(setsid() != -1) << "setsid";
|
||||
+
|
||||
+ // &argv_c[0] is a pointer to a pointer to const char data, but because of
|
||||
+ // how C (not C++) works, posix_spawn() and posix_spawnp() want a pointer to
|
||||
+ // a const pointer to char data. They modifies neither the data nor the
|
||||
+ // pointers, so the const_cast is safe.
|
||||
+ char* const* argv_for_spawn = const_cast<char* const*>(argv_c.data());
|
||||
+
|
||||
+ // This cast is safe for the same reason that the argv_for_spawn cast is.
|
||||
+ char* const* envp_for_spawn =
|
||||
+ envp ? const_cast<char* const*>(envp_c.data()) : environ;
|
||||
+
|
||||
+#if BUILDFLAG(IS_APPLE)
|
||||
+ PosixSpawnAttr attr;
|
||||
+ attr.SetFlags(POSIX_SPAWN_CLOEXEC_DEFAULT);
|
||||
+
|
||||
+ PosixSpawnFileActions file_actions;
|
||||
+ for (int fd = 0; fd <= STDERR_FILENO; ++fd) {
|
||||
+ file_actions.AddInheritedFileDescriptor(fd);
|
||||
+ }
|
||||
+ file_actions.AddInheritedFileDescriptor(preserve_fd);
|
||||
+
|
||||
+ const posix_spawnattr_t* attr_p = attr.Get();
|
||||
+ const posix_spawn_file_actions_t* file_actions_p = file_actions.Get();
|
||||
+#else
|
||||
+ CloseMultipleNowOrOnExec(STDERR_FILENO + 1, preserve_fd);
|
||||
+
|
||||
+ const posix_spawnattr_t* attr_p = nullptr;
|
||||
+ const posix_spawn_file_actions_t* file_actions_p = nullptr;
|
||||
+#endif
|
||||
+
|
||||
+ auto posix_spawn_fp = use_path ? posix_spawnp : posix_spawn;
|
||||
+ if ((errno = posix_spawn_fp(&pid,
|
||||
+ argv_for_spawn[0],
|
||||
+ file_actions_p,
|
||||
+ attr_p,
|
||||
+ argv_for_spawn,
|
||||
+ envp_for_spawn)) != 0) {
|
||||
+ PLOG(FATAL) << (use_path ? "posix_spawnp" : "posix_spawn");
|
||||
+ }
|
||||
+
|
||||
+ // _exit() instead of exit(), because fork() was called.
|
||||
+ _exit(EXIT_SUCCESS);
|
||||
+ }
|
||||
+
|
||||
+ // waitpid() for the child, so that it does not become a zombie process. The
|
||||
+ // child normally exits quickly.
|
||||
+ //
|
||||
+ // Failures from this point on may result in the accumulation of a zombie, but
|
||||
+ // should not be considered fatal. Log only warnings, but don’t treat these
|
||||
+ // failures as a failure of the function overall.
|
||||
+ int status;
|
||||
+ pid_t wait_pid = HANDLE_EINTR(waitpid(pid, &status, 0));
|
||||
+ if (wait_pid == -1) {
|
||||
+ PLOG(WARNING) << "waitpid";
|
||||
+ return true;
|
||||
+ }
|
||||
+ DCHECK_EQ(wait_pid, pid);
|
||||
+
|
||||
+ if (WIFSIGNALED(status)) {
|
||||
+ int sig = WTERMSIG(status);
|
||||
+ LOG(WARNING) << base::StringPrintf(
|
||||
+ "intermediate process terminated by signal %d (%s)%s",
|
||||
+ sig,
|
||||
+ strsignal(sig),
|
||||
+ WCOREDUMP(status) ? " (core dumped)" : "");
|
||||
+ } else if (!WIFEXITED(status)) {
|
||||
+ LOG(WARNING) << base::StringPrintf(
|
||||
+ "intermediate process: unknown termination 0x%x", status);
|
||||
+ } else if (WEXITSTATUS(status) != EXIT_SUCCESS) {
|
||||
+ LOG(WARNING) << "intermediate process exited with code "
|
||||
+ << WEXITSTATUS(status);
|
||||
+ }
|
||||
+
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+} // namespace crashpad
|
||||
diff --git a/third_party/crashpad/crashpad/util/posix/double_fork_and_exec.h b/third_party/crashpad/crashpad/util/posix/fork_and_spawn.h
|
||||
similarity index 76%
|
||||
rename from third_party/crashpad/crashpad/util/posix/double_fork_and_exec.h
|
||||
rename to third_party/crashpad/crashpad/util/posix/fork_and_spawn.h
|
||||
index 02fc0f28f196b447132a2dcfaebdaaa5a916a38a..fc55aa3a37652e4ba18c66db90124abd9cad2e51 100644
|
||||
--- a/third_party/crashpad/crashpad/util/posix/double_fork_and_exec.h
|
||||
+++ b/third_party/crashpad/crashpad/util/posix/fork_and_spawn.h
|
||||
@@ -12,8 +12,8 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
-#ifndef CRASHPAD_UTIL_POSIX_DOUBLE_FORK_AND_EXEC_H_
|
||||
-#define CRASHPAD_UTIL_POSIX_DOUBLE_FORK_AND_EXEC_H_
|
||||
+#ifndef CRASHPAD_UTIL_POSIX_FORK_AND_SPAWN_H_
|
||||
+#define CRASHPAD_UTIL_POSIX_FORK_AND_SPAWN_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -23,7 +23,7 @@ namespace crashpad {
|
||||
//! \brief Executes a (grand-)child process.
|
||||
//!
|
||||
//! The grandchild process will be started through the
|
||||
-//! double-`fork()`-and-`execv()` pattern. This allows the grandchild to fully
|
||||
+//! `fork()`-and-`posix_spawn()` pattern. This allows the grandchild to fully
|
||||
//! disassociate from the parent. The grandchild will not be a member of the
|
||||
//! parent’s process group or session and will not have a controlling terminal,
|
||||
//! providing isolation from signals not intended for it. The grandchild’s
|
||||
@@ -37,7 +37,7 @@ namespace crashpad {
|
||||
//! \param[in] argv The argument vector to start the grandchild process with.
|
||||
//! `argv[0]` is used as the path to the executable.
|
||||
//! \param[in] envp A vector of environment variables of the form `var=value` to
|
||||
-//! be passed to `execve()`. If this value is `nullptr`, the current
|
||||
+//! be passed to `posix_spawn()`. If this value is `nullptr`, the current
|
||||
//! environment is used.
|
||||
//! \param[in] preserve_fd A file descriptor to be inherited by the grandchild
|
||||
//! process. This file descriptor is inherited in addition to the three file
|
||||
@@ -45,16 +45,13 @@ namespace crashpad {
|
||||
//! if no additional file descriptors are to be inherited.
|
||||
//! \param[in] use_path Whether to consult the `PATH` environment variable when
|
||||
//! requested to start an executable at a non-absolute path. If `false`,
|
||||
-//! `execv()`, which does not consult `PATH`, will be used. If `true`,
|
||||
-//! `execvp()`, which does consult `PATH`, will be used.
|
||||
+//! `posix_spawn()`, which does not consult `PATH`, will be used. If `true`,
|
||||
+//! `posix_spawnp()`, which does consult `PATH`, will be used.
|
||||
//! \param[in] child_function If not `nullptr`, this function will be called in
|
||||
-//! the intermediate child process, prior to the second `fork()`. Take note
|
||||
+//! the intermediate child process, prior to the `posix_spawn()`. Take note
|
||||
//! that this function will run in the context of a forked process, and must
|
||||
//! be safe for that purpose.
|
||||
//!
|
||||
-//! Setting both \a envp to a value other than `nullptr` and \a use_path to
|
||||
-//! `true` is not currently supported.
|
||||
-//!
|
||||
//! \return `true` on success, and `false` on failure with a message logged.
|
||||
//! Only failures that occur in the parent process that indicate a definite
|
||||
//! failure to start the the grandchild are reported in the return value.
|
||||
@@ -63,12 +60,12 @@ namespace crashpad {
|
||||
//! terminating. The caller assumes the responsibility for detecting such
|
||||
//! failures, for example, by observing a failure to perform a successful
|
||||
//! handshake with the grandchild process.
|
||||
-bool DoubleForkAndExec(const std::vector<std::string>& argv,
|
||||
- const std::vector<std::string>* envp,
|
||||
- int preserve_fd,
|
||||
- bool use_path,
|
||||
- void (*child_function)());
|
||||
+bool ForkAndSpawn(const std::vector<std::string>& argv,
|
||||
+ const std::vector<std::string>* envp,
|
||||
+ int preserve_fd,
|
||||
+ bool use_path,
|
||||
+ void (*child_function)());
|
||||
|
||||
} // namespace crashpad
|
||||
|
||||
-#endif // CRASHPAD_UTIL_POSIX_DOUBLE_FORK_AND_EXEC_H_
|
||||
+#endif // CRASHPAD_UTIL_POSIX_FORK_AND_SPAWN_H_
|
||||
@@ -483,7 +483,7 @@ index 51ebcb4ae399018d3fd8566656596a7ef1f148af..c0fbff95137e2e5bccb9702a8cc858df
|
||||
// Tells the browser that there are invalid printer settings.
|
||||
ShowInvalidPrinterSettingsError();
|
||||
diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc
|
||||
index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9c832bf5a 100644
|
||||
index 0d5c467e59c85589872a41b3783110b9d84ffbdb..75a0c6c1ee04cb655261d9d385e486cbd1345f33 100644
|
||||
--- a/components/printing/renderer/print_render_frame_helper.cc
|
||||
+++ b/components/printing/renderer/print_render_frame_helper.cc
|
||||
@@ -40,6 +40,7 @@
|
||||
@@ -494,7 +494,7 @@ index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9
|
||||
#include "printing/units.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
|
||||
@@ -1254,7 +1255,8 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) {
|
||||
@@ -1259,7 +1260,8 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) {
|
||||
if (!weak_this)
|
||||
return;
|
||||
|
||||
@@ -504,7 +504,7 @@ index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9
|
||||
if (!weak_this)
|
||||
return;
|
||||
|
||||
@@ -1285,7 +1287,7 @@ void PrintRenderFrameHelper::BindPrintRenderFrameReceiver(
|
||||
@@ -1290,7 +1292,7 @@ void PrintRenderFrameHelper::BindPrintRenderFrameReceiver(
|
||||
receivers_.Add(this, std::move(receiver));
|
||||
}
|
||||
|
||||
@@ -513,7 +513,7 @@ index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9
|
||||
ScopedIPC scoped_ipc(weak_ptr_factory_.GetWeakPtr());
|
||||
if (ipc_nesting_level_ > kAllowedIpcDepthForPrint)
|
||||
return;
|
||||
@@ -1300,7 +1302,7 @@ void PrintRenderFrameHelper::PrintRequestedPages() {
|
||||
@@ -1305,7 +1307,7 @@ void PrintRenderFrameHelper::PrintRequestedPages() {
|
||||
// plugin node and print that instead.
|
||||
auto plugin = delegate_->GetPdfElement(frame);
|
||||
|
||||
@@ -522,7 +522,7 @@ index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9
|
||||
|
||||
if (!render_frame_gone_)
|
||||
frame->DispatchAfterPrintEvent();
|
||||
@@ -1331,7 +1333,8 @@ void PrintRenderFrameHelper::PrintForSystemDialog() {
|
||||
@@ -1336,7 +1338,8 @@ void PrintRenderFrameHelper::PrintForSystemDialog() {
|
||||
}
|
||||
|
||||
Print(frame, print_preview_context_.source_node(),
|
||||
@@ -532,7 +532,7 @@ index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9
|
||||
if (!render_frame_gone_)
|
||||
print_preview_context_.DispatchAfterPrintEvent();
|
||||
// WARNING: |this| may be gone at this point. Do not do any more work here and
|
||||
@@ -1378,6 +1381,8 @@ void PrintRenderFrameHelper::PrintPreview(base::Value settings) {
|
||||
@@ -1383,6 +1386,8 @@ void PrintRenderFrameHelper::PrintPreview(base::Value settings) {
|
||||
if (ipc_nesting_level_ > kAllowedIpcDepthForPrint)
|
||||
return;
|
||||
|
||||
@@ -541,7 +541,7 @@ index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9
|
||||
print_preview_context_.OnPrintPreview();
|
||||
|
||||
if (print_preview_context_.IsForArc()) {
|
||||
@@ -1915,7 +1920,8 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
||||
@@ -1920,7 +1925,8 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
||||
return;
|
||||
|
||||
Print(duplicate_node.GetDocument().GetFrame(), duplicate_node,
|
||||
@@ -551,7 +551,7 @@ index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9
|
||||
// Check if |this| is still valid.
|
||||
if (!weak_this)
|
||||
return;
|
||||
@@ -1930,7 +1936,9 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
||||
@@ -1935,7 +1941,9 @@ void PrintRenderFrameHelper::PrintNode(const blink::WebNode& node) {
|
||||
|
||||
void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
const blink::WebNode& node,
|
||||
@@ -562,7 +562,7 @@ index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9
|
||||
// If still not finished with earlier print request simply ignore.
|
||||
if (prep_frame_view_)
|
||||
return;
|
||||
@@ -1938,7 +1946,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
@@ -1943,7 +1951,7 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
FrameReference frame_ref(frame);
|
||||
|
||||
uint32_t expected_page_count = 0;
|
||||
@@ -571,7 +571,7 @@ index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9
|
||||
DidFinishPrinting(FAIL_PRINT_INIT);
|
||||
return; // Failed to init print page settings.
|
||||
}
|
||||
@@ -1957,8 +1965,15 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
@@ -1962,8 +1970,15 @@ void PrintRenderFrameHelper::Print(blink::WebLocalFrame* frame,
|
||||
print_pages_params_->params->print_scaling_option;
|
||||
|
||||
auto self = weak_ptr_factory_.GetWeakPtr();
|
||||
@@ -588,7 +588,7 @@ index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9
|
||||
// Check if |this| is still valid.
|
||||
if (!self)
|
||||
return;
|
||||
@@ -2206,36 +2221,51 @@ void PrintRenderFrameHelper::IPCProcessed() {
|
||||
@@ -2211,36 +2226,51 @@ void PrintRenderFrameHelper::IPCProcessed() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -652,7 +652,7 @@ index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9
|
||||
notify_browser_of_print_failure_ = false;
|
||||
GetPrintManagerHost()->ShowInvalidPrinterSettingsError();
|
||||
return false;
|
||||
@@ -2380,7 +2410,7 @@ mojom::PrintPagesParamsPtr PrintRenderFrameHelper::GetPrintSettingsFromUser(
|
||||
@@ -2385,7 +2415,7 @@ mojom::PrintPagesParamsPtr PrintRenderFrameHelper::GetPrintSettingsFromUser(
|
||||
std::move(params),
|
||||
base::BindOnce(
|
||||
[](base::OnceClosure quit_closure, mojom::PrintPagesParamsPtr* output,
|
||||
@@ -661,7 +661,7 @@ index 553b199325714b2ac91c996ef5d32abf76169573..93821dc9c6d79d2c13e6c8db12a75cd9
|
||||
*output = std::move(input);
|
||||
std::move(quit_closure).Run();
|
||||
},
|
||||
@@ -2625,18 +2655,7 @@ void PrintRenderFrameHelper::RequestPrintPreview(PrintPreviewRequestType type,
|
||||
@@ -2630,18 +2660,7 @@ void PrintRenderFrameHelper::RequestPrintPreview(PrintPreviewRequestType type,
|
||||
}
|
||||
|
||||
bool PrintRenderFrameHelper::CheckForCancel() {
|
||||
|
||||
@@ -30,7 +30,7 @@ index 059ff2b47e7aa8b9707e71ae9a1793bfdd86d319..529637f8b6af6b8b45f9de61d27b5e9c
|
||||
// RenderWidgetHost on the primary main frame, and false otherwise.
|
||||
virtual bool IsWidgetForPrimaryMainFrame(RenderWidgetHostImpl*);
|
||||
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
|
||||
index 59437e69e25fe85cffc9b558dec2284123ac48be..d3af2aed32f6047cbb86bd2b4ce1df9fee80437c 100644
|
||||
index 59dda38e5781132472991979d90317dfaa96028f..7d51b1d678b9b11c0dfc48a0a890a43d21830530 100644
|
||||
--- a/content/browser/renderer_host/render_widget_host_impl.cc
|
||||
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
|
||||
@@ -2082,6 +2082,8 @@ void RenderWidgetHostImpl::FilterDropData(DropData* drop_data) {
|
||||
@@ -43,10 +43,10 @@ index 59437e69e25fe85cffc9b558dec2284123ac48be..d3af2aed32f6047cbb86bd2b4ce1df9f
|
||||
|
||||
void RenderWidgetHostImpl::ShowContextMenuAtPoint(
|
||||
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
|
||||
index c8e49eeaca8b31479aa908be9c349ccd625e9e51..5c63a024827359ccf697d0b7fc8fa2092eb107b7 100644
|
||||
index b406cd71133062618258a7d56e69b5e258687e12..4e78c10d21e08fef2b25ef5a13987c13bc8c204a 100644
|
||||
--- a/content/browser/web_contents/web_contents_impl.cc
|
||||
+++ b/content/browser/web_contents/web_contents_impl.cc
|
||||
@@ -4486,6 +4486,11 @@ TextInputManager* WebContentsImpl::GetTextInputManager() {
|
||||
@@ -4495,6 +4495,11 @@ TextInputManager* WebContentsImpl::GetTextInputManager() {
|
||||
return text_input_manager_.get();
|
||||
}
|
||||
|
||||
@@ -59,10 +59,10 @@ index c8e49eeaca8b31479aa908be9c349ccd625e9e51..5c63a024827359ccf697d0b7fc8fa209
|
||||
RenderWidgetHostImpl* render_widget_host) {
|
||||
return render_widget_host == GetMainFrame()->GetRenderWidgetHost();
|
||||
diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h
|
||||
index 85b426a7552cf925157a76fcd1ed7de47cd27a54..7440f2025701ccde0ade36cda22467dd0614109b 100644
|
||||
index 5020c6674ba692c15d75d5eec981ac7b60f61bbe..e1ac23f3adf38591ae220ea84c5c0717a28e64bb 100644
|
||||
--- a/content/browser/web_contents/web_contents_impl.h
|
||||
+++ b/content/browser/web_contents/web_contents_impl.h
|
||||
@@ -965,6 +965,7 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
|
||||
@@ -966,6 +966,7 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents,
|
||||
blink::mojom::FrameVisibility visibility) override;
|
||||
void SendScreenRects() override;
|
||||
TextInputManager* GetTextInputManager() override;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user