mirror of
https://github.com/electron/electron.git
synced 2026-02-26 03:01:17 -05:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b804177fa | ||
|
|
77478353c6 | ||
|
|
30e8011b9f | ||
|
|
54432ab8b2 | ||
|
|
37558a6215 | ||
|
|
d5ba5c8e0a | ||
|
|
b1b83f79b7 | ||
|
|
a85b38847e | ||
|
|
ade9151181 | ||
|
|
9d2961868c | ||
|
|
cdd6fc93b2 | ||
|
|
1e21b7c910 | ||
|
|
c224431ae8 | ||
|
|
9e0fda8393 | ||
|
|
36b72ba5ee | ||
|
|
dd8c63e15a | ||
|
|
6bfa54fcf2 | ||
|
|
6d9f3a4945 | ||
|
|
a20396588a |
@@ -330,6 +330,19 @@ step-setup-goma-for-build: &step-setup-goma-for-build
|
||||
echo 'export LOCAL_GOMA_DIR='`node -e "console.log(require('./src/utils/goma.js').dir)"` >> $BASH_ENV
|
||||
echo 'export GOMA_FALLBACK_ON_AUTH_FAILURE=true' >> $BASH_ENV
|
||||
cd ..
|
||||
touch "${TMPDIR:=/tmp}"/.goma-ready
|
||||
background: true
|
||||
|
||||
step-wait-for-goma: &step-wait-for-goma
|
||||
run:
|
||||
name: Wait for Goma
|
||||
command: |
|
||||
until [ -f "${TMPDIR:=/tmp}"/.goma-ready ]
|
||||
do
|
||||
sleep 5
|
||||
done
|
||||
echo "Goma ready"
|
||||
no_output_timeout: 2m
|
||||
|
||||
step-restore-brew-cache: &step-restore-brew-cache
|
||||
restore_cache:
|
||||
@@ -543,14 +556,6 @@ step-electron-build: &step-electron-build
|
||||
cp out/Default/.ninja_log out/electron_ninja_log
|
||||
node electron/script/check-symlinks.js
|
||||
|
||||
step-native-unittests-build: &step-native-unittests-build
|
||||
run:
|
||||
name: Build native test targets
|
||||
no_output_timeout: 30m
|
||||
command: |
|
||||
cd src
|
||||
ninja -C out/Default shell_browser_ui_unittests -j $NUMBER_OF_NINJA_PROCESSES
|
||||
|
||||
step-maybe-electron-dist-strip: &step-maybe-electron-dist-strip
|
||||
run:
|
||||
name: Strip electron binaries
|
||||
@@ -569,40 +574,6 @@ step-maybe-electron-dist-strip: &step-maybe-electron-dist-strip
|
||||
electron/script/add-debug-link.py --target-cpu="$target_cpu" --debug-dir=out/Default/debug
|
||||
fi
|
||||
|
||||
step-electron-dist-build: &step-electron-dist-build
|
||||
run:
|
||||
name: Build dist.zip
|
||||
command: |
|
||||
cd src
|
||||
if [ "$SKIP_DIST_ZIP" != "1" ]; then
|
||||
ninja -C out/Default electron:electron_dist_zip
|
||||
if [ "$CHECK_DIST_MANIFEST" == "1" ]; then
|
||||
if [ "`uname`" == "Darwin" ]; then
|
||||
target_os=mac
|
||||
target_cpu=x64
|
||||
if [ x"$MAS_BUILD" == x"true" ]; then
|
||||
target_os=mac_mas
|
||||
fi
|
||||
if [ "$TARGET_ARCH" == "arm64" ]; then
|
||||
target_cpu=arm64
|
||||
fi
|
||||
elif [ "`uname`" == "Linux" ]; then
|
||||
target_os=linux
|
||||
if [ x"$TARGET_ARCH" == x ]; then
|
||||
target_cpu=x64
|
||||
elif [ "$TARGET_ARCH" == "ia32" ]; then
|
||||
target_cpu=x86
|
||||
else
|
||||
target_cpu="$TARGET_ARCH"
|
||||
fi
|
||||
else
|
||||
echo "Unknown system: `uname`"
|
||||
exit 1
|
||||
fi
|
||||
electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.$target_os.$target_cpu.manifest
|
||||
fi
|
||||
fi
|
||||
|
||||
step-electron-chromedriver-build: &step-electron-chromedriver-build
|
||||
run:
|
||||
name: Build chromedriver.zip
|
||||
@@ -655,7 +626,6 @@ step-persist-data-for-tests: &step-persist-data-for-tests
|
||||
- src/out/Default/dist.zip
|
||||
- src/out/Default/mksnapshot.zip
|
||||
- src/out/Default/chromedriver.zip
|
||||
- src/out/Default/shell_browser_ui_unittests
|
||||
- src/out/Default/gen/node_headers
|
||||
- src/out/ffmpeg/ffmpeg.zip
|
||||
- src/electron
|
||||
@@ -766,6 +736,7 @@ step-show-goma-stats: &step-show-goma-stats
|
||||
$LOCAL_GOMA_DIR/diagnose_goma_log.py
|
||||
true
|
||||
when: always
|
||||
background: true
|
||||
|
||||
step-mksnapshot-build: &step-mksnapshot-build
|
||||
run:
|
||||
@@ -1008,11 +979,15 @@ step-ts-compile: &step-ts-compile
|
||||
# List of all steps.
|
||||
steps-electron-gn-check: &steps-electron-gn-check
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: .
|
||||
- *step-checkout-electron
|
||||
- *step-depot-tools-get
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-setup-env-for-build
|
||||
- *step-setup-goma-for-build
|
||||
- *step-generate-deps-hash
|
||||
- *step-touch-sync-done
|
||||
- maybe-restore-portaled-src-cache
|
||||
- *step-wait-for-goma
|
||||
- *step-gn-gen-default
|
||||
- *step-gn-check
|
||||
|
||||
@@ -1025,6 +1000,7 @@ steps-electron-ts-compile-for-doc-change: &steps-electron-ts-compile-for-doc-cha
|
||||
- *step-restore-brew-cache
|
||||
- *step-install-gnutar-on-mac
|
||||
- *step-get-more-space-on-mac
|
||||
- *step-setup-goma-for-build
|
||||
- *step-generate-deps-hash
|
||||
- *step-touch-sync-done
|
||||
- maybe-restore-portaled-src-cache
|
||||
@@ -1044,7 +1020,7 @@ steps-electron-ts-compile-for-doc-change: &steps-electron-ts-compile-for-doc-cha
|
||||
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-setup-env-for-build
|
||||
- *step-setup-goma-for-build
|
||||
- *step-wait-for-goma
|
||||
- *step-get-more-space-on-mac
|
||||
- *step-install-npm-deps-on-mac
|
||||
- *step-fix-sync-on-mac
|
||||
@@ -1060,6 +1036,7 @@ steps-native-tests: &steps-native-tests
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-setup-env-for-build
|
||||
- *step-setup-goma-for-build
|
||||
- *step-wait-for-goma
|
||||
- *step-gn-gen-default
|
||||
|
||||
- run:
|
||||
@@ -1245,7 +1222,6 @@ commands:
|
||||
fi
|
||||
}
|
||||
mv_if_exist src/out/Default/dist.zip
|
||||
mv_if_exist src/out/Default/shell_browser_ui_unittests
|
||||
mv_if_exist src/out/Default/gen/node_headers.tar.gz
|
||||
mv_if_exist src/out/Default/symbols.zip
|
||||
mv_if_exist src/out/Default/mksnapshot.zip
|
||||
@@ -1282,6 +1258,46 @@ commands:
|
||||
- *step-checkout-electron
|
||||
- *step-run-electron-only-hooks
|
||||
- *step-generate-deps-hash-cleanly
|
||||
|
||||
step-electron-dist-build:
|
||||
parameters:
|
||||
additional-targets:
|
||||
type: string
|
||||
default: ''
|
||||
steps:
|
||||
- run:
|
||||
name: Build dist.zip
|
||||
command: |
|
||||
cd src
|
||||
if [ "$SKIP_DIST_ZIP" != "1" ]; then
|
||||
ninja -C out/Default electron:electron_dist_zip << parameters.additional-targets >>
|
||||
if [ "$CHECK_DIST_MANIFEST" == "1" ]; then
|
||||
if [ "`uname`" == "Darwin" ]; then
|
||||
target_os=mac
|
||||
target_cpu=x64
|
||||
if [ x"$MAS_BUILD" == x"true" ]; then
|
||||
target_os=mac_mas
|
||||
fi
|
||||
if [ "$TARGET_ARCH" == "arm64" ]; then
|
||||
target_cpu=arm64
|
||||
fi
|
||||
elif [ "`uname`" == "Linux" ]; then
|
||||
target_os=linux
|
||||
if [ x"$TARGET_ARCH" == x ]; then
|
||||
target_cpu=x64
|
||||
elif [ "$TARGET_ARCH" == "ia32" ]; then
|
||||
target_cpu=x86
|
||||
else
|
||||
target_cpu="$TARGET_ARCH"
|
||||
fi
|
||||
else
|
||||
echo "Unknown system: `uname`"
|
||||
exit 1
|
||||
fi
|
||||
electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.$target_os.$target_cpu.manifest
|
||||
fi
|
||||
fi
|
||||
|
||||
electron-build:
|
||||
parameters:
|
||||
attach:
|
||||
@@ -1327,6 +1343,10 @@ commands:
|
||||
- *step-restore-brew-cache
|
||||
- *step-install-gnutar-on-mac
|
||||
- *step-save-brew-cache
|
||||
- when:
|
||||
condition: << parameters.build >>
|
||||
steps:
|
||||
- *step-setup-goma-for-build
|
||||
- when:
|
||||
condition: << parameters.checkout-and-assume-cache >>
|
||||
steps:
|
||||
@@ -1426,7 +1446,7 @@ commands:
|
||||
steps:
|
||||
- *step-depot-tools-add-to-path
|
||||
- *step-setup-env-for-build
|
||||
- *step-setup-goma-for-build
|
||||
- *step-wait-for-goma
|
||||
- *step-get-more-space-on-mac
|
||||
- *step-fix-sync-on-mac
|
||||
- *step-delete-git-directories
|
||||
@@ -1439,13 +1459,8 @@ commands:
|
||||
- *step-gn-gen-default
|
||||
- *step-electron-build
|
||||
- *step-maybe-electron-dist-strip
|
||||
- *step-electron-dist-build
|
||||
|
||||
# Native test targets
|
||||
- *step-native-unittests-build
|
||||
|
||||
# Node.js headers
|
||||
- *step-nodejs-headers-build
|
||||
- step-electron-dist-build:
|
||||
additional-targets: shell_browser_ui_unittests third_party/electron_node:headers electron:hunspell_dictionaries_zip
|
||||
|
||||
- *step-show-goma-stats
|
||||
|
||||
@@ -1463,13 +1478,14 @@ commands:
|
||||
- *step-ffmpeg-gn-gen
|
||||
- *step-ffmpeg-build
|
||||
|
||||
# hunspell
|
||||
- *step-hunspell-build
|
||||
|
||||
# Save all data needed for a further tests run.
|
||||
- when:
|
||||
condition: << parameters.persist >>
|
||||
steps:
|
||||
- *step-minimize-workspace-size-from-checkout
|
||||
- run: |
|
||||
rm -rf src/third_party/electron_node/deps/openssl
|
||||
rm -rf src/third_party/electron_node/deps/v8
|
||||
- *step-persist-data-for-tests
|
||||
|
||||
- when:
|
||||
@@ -1535,6 +1551,7 @@ commands:
|
||||
- *step-fix-sync-on-mac
|
||||
- *step-setup-env-for-build
|
||||
- *step-setup-goma-for-build
|
||||
- *step-wait-for-goma
|
||||
- *step-gn-gen-default
|
||||
|
||||
# Electron app
|
||||
@@ -1542,7 +1559,7 @@ commands:
|
||||
- *step-show-goma-stats
|
||||
- *step-maybe-generate-breakpad-symbols
|
||||
- *step-maybe-electron-dist-strip
|
||||
- *step-electron-dist-build
|
||||
- step-electron-dist-build
|
||||
- *step-maybe-zip-symbols
|
||||
|
||||
# mksnapshot
|
||||
@@ -1585,20 +1602,10 @@ jobs:
|
||||
<<: *steps-electron-ts-compile-for-doc-change
|
||||
|
||||
# Layer 1: Checkout.
|
||||
linux-checkout-for-workspace:
|
||||
executor: linux-docker
|
||||
environment:
|
||||
<<: *env-linux-2xlarge
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
||||
steps:
|
||||
- electron-build:
|
||||
persist: false
|
||||
build: false
|
||||
checkout: true
|
||||
persist-checkout: true
|
||||
|
||||
linux-make-src-cache:
|
||||
executor: linux-docker
|
||||
executor:
|
||||
name: linux-docker
|
||||
size: xlarge
|
||||
environment:
|
||||
<<: *env-linux-2xlarge
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
||||
@@ -1649,22 +1656,10 @@ jobs:
|
||||
persist-checkout: true
|
||||
restore-src-cache: false
|
||||
|
||||
mac-checkout-for-workspace:
|
||||
executor: linux-docker
|
||||
environment:
|
||||
<<: *env-linux-2xlarge
|
||||
<<: *env-testing-build
|
||||
<<: *env-macos-build
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
|
||||
steps:
|
||||
- electron-build:
|
||||
persist: false
|
||||
build: false
|
||||
checkout: true
|
||||
persist-checkout: true
|
||||
|
||||
mac-make-src-cache:
|
||||
executor: linux-docker
|
||||
executor:
|
||||
name: linux-docker
|
||||
size: xlarge
|
||||
environment:
|
||||
<<: *env-linux-2xlarge
|
||||
<<: *env-testing-build
|
||||
@@ -1689,7 +1684,8 @@ jobs:
|
||||
steps:
|
||||
- electron-build:
|
||||
persist: true
|
||||
checkout: true
|
||||
checkout: false
|
||||
checkout-and-assume-cache: true
|
||||
use-out-cache: false
|
||||
|
||||
linux-x64-testing-asan:
|
||||
@@ -1729,6 +1725,7 @@ jobs:
|
||||
environment:
|
||||
<<: *env-linux-medium
|
||||
<<: *env-testing-build
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
||||
<<: *steps-electron-gn-check
|
||||
|
||||
linux-x64-release:
|
||||
@@ -1825,7 +1822,8 @@ jobs:
|
||||
steps:
|
||||
- electron-build:
|
||||
persist: true
|
||||
checkout: true
|
||||
checkout: false
|
||||
checkout-and-assume-cache: true
|
||||
use-out-cache: false
|
||||
|
||||
linux-arm-release:
|
||||
@@ -1877,7 +1875,8 @@ jobs:
|
||||
steps:
|
||||
- electron-build:
|
||||
persist: true
|
||||
checkout: true
|
||||
checkout: false
|
||||
checkout-and-assume-cache: true
|
||||
use-out-cache: false
|
||||
|
||||
linux-arm64-testing-gn-check:
|
||||
@@ -1888,6 +1887,7 @@ jobs:
|
||||
<<: *env-linux-medium
|
||||
<<: *env-arm64
|
||||
<<: *env-testing-build
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
|
||||
<<: *steps-electron-gn-check
|
||||
|
||||
linux-arm64-release:
|
||||
@@ -1947,6 +1947,7 @@ jobs:
|
||||
environment:
|
||||
<<: *env-machine-mac
|
||||
<<: *env-testing-build
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
|
||||
<<: *steps-electron-gn-check
|
||||
|
||||
osx-publish-x64-skip-checkout:
|
||||
@@ -2029,6 +2030,7 @@ jobs:
|
||||
<<: *env-machine-mac
|
||||
<<: *env-mas
|
||||
<<: *env-testing-build
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
|
||||
<<: *steps-electron-gn-check
|
||||
|
||||
mas-publish-x64-skip-checkout:
|
||||
@@ -2355,14 +2357,19 @@ workflows:
|
||||
- equal: [false, << pipeline.parameters.run-linux-publish >>]
|
||||
- equal: [true, << pipeline.parameters.run-build-linux >>]
|
||||
jobs:
|
||||
- linux-checkout-for-workspace
|
||||
- linux-make-src-cache
|
||||
- linux-x64-testing
|
||||
- linux-x64-testing-asan
|
||||
- linux-x64-testing-no-run-as-node
|
||||
- linux-x64-testing:
|
||||
requires:
|
||||
- linux-make-src-cache
|
||||
- linux-x64-testing-asan:
|
||||
requires:
|
||||
- linux-make-src-cache
|
||||
- linux-x64-testing-no-run-as-node:
|
||||
requires:
|
||||
- linux-make-src-cache
|
||||
- linux-x64-testing-gn-check:
|
||||
requires:
|
||||
- linux-checkout-for-workspace
|
||||
- linux-make-src-cache
|
||||
- linux-x64-testing-tests:
|
||||
requires:
|
||||
- linux-x64-testing
|
||||
@@ -2375,7 +2382,9 @@ workflows:
|
||||
- linux-x64-testing-node:
|
||||
requires:
|
||||
- linux-x64-testing
|
||||
- linux-ia32-testing
|
||||
- linux-ia32-testing:
|
||||
requires:
|
||||
- linux-make-src-cache
|
||||
- linux-ia32-testing-tests:
|
||||
requires:
|
||||
- linux-ia32-testing
|
||||
@@ -2385,7 +2394,9 @@ workflows:
|
||||
- linux-ia32-testing-node:
|
||||
requires:
|
||||
- linux-ia32-testing
|
||||
- linux-arm-testing
|
||||
- linux-arm-testing:
|
||||
requires:
|
||||
- linux-make-src-cache
|
||||
- linux-arm-testing-tests:
|
||||
filters:
|
||||
branches:
|
||||
@@ -2393,7 +2404,9 @@ workflows:
|
||||
ignore: /pull\/[0-9]+/
|
||||
requires:
|
||||
- linux-arm-testing
|
||||
- linux-arm64-testing
|
||||
- linux-arm64-testing:
|
||||
requires:
|
||||
- linux-make-src-cache
|
||||
- linux-arm64-testing-tests:
|
||||
filters:
|
||||
branches:
|
||||
@@ -2403,7 +2416,7 @@ workflows:
|
||||
- linux-arm64-testing
|
||||
- linux-arm64-testing-gn-check:
|
||||
requires:
|
||||
- linux-checkout-for-workspace
|
||||
- linux-make-src-cache
|
||||
|
||||
build-mac:
|
||||
when:
|
||||
@@ -2412,14 +2425,13 @@ workflows:
|
||||
- equal: [false, << pipeline.parameters.run-linux-publish >>]
|
||||
- equal: [true, << pipeline.parameters.run-build-mac >>]
|
||||
jobs:
|
||||
- mac-checkout-for-workspace
|
||||
- mac-make-src-cache
|
||||
- osx-testing-x64:
|
||||
requires:
|
||||
- mac-make-src-cache
|
||||
- osx-testing-x64-gn-check:
|
||||
requires:
|
||||
- mac-checkout-for-workspace
|
||||
- mac-make-src-cache
|
||||
- osx-testing-x64-tests:
|
||||
requires:
|
||||
- osx-testing-x64
|
||||
@@ -2438,7 +2450,7 @@ workflows:
|
||||
- mac-make-src-cache
|
||||
- mas-testing-x64-gn-check:
|
||||
requires:
|
||||
- mac-checkout-for-workspace
|
||||
- mac-make-src-cache
|
||||
- mas-testing-x64-tests:
|
||||
requires:
|
||||
- mas-testing-x64
|
||||
|
||||
4
BUILD.gn
4
BUILD.gn
@@ -1231,6 +1231,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" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
15.5.5
|
||||
15.5.7
|
||||
@@ -16,6 +16,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
|
||||
|
||||
|
||||
@@ -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)`
|
||||
|
||||
|
||||
@@ -352,6 +352,8 @@ filenames = {
|
||||
"shell/browser/child_web_contents_tracker.h",
|
||||
"shell/browser/cookie_change_notifier.cc",
|
||||
"shell/browser/cookie_change_notifier.h",
|
||||
"shell/browser/electron_api_ipc_handler_impl.cc",
|
||||
"shell/browser/electron_api_ipc_handler_impl.h",
|
||||
"shell/browser/electron_autofill_driver.cc",
|
||||
"shell/browser/electron_autofill_driver.h",
|
||||
"shell/browser/electron_autofill_driver_factory.cc",
|
||||
@@ -360,8 +362,6 @@ filenames = {
|
||||
"shell/browser/electron_browser_client.h",
|
||||
"shell/browser/electron_browser_context.cc",
|
||||
"shell/browser/electron_browser_context.h",
|
||||
"shell/browser/electron_browser_handler_impl.cc",
|
||||
"shell/browser/electron_browser_handler_impl.h",
|
||||
"shell/browser/electron_browser_main_parts.cc",
|
||||
"shell/browser/electron_browser_main_parts.h",
|
||||
"shell/browser/electron_download_manager_delegate.cc",
|
||||
@@ -378,6 +378,8 @@ filenames = {
|
||||
"shell/browser/electron_quota_permission_context.h",
|
||||
"shell/browser/electron_speech_recognition_manager_delegate.cc",
|
||||
"shell/browser/electron_speech_recognition_manager_delegate.h",
|
||||
"shell/browser/electron_web_contents_utility_handler_impl.cc",
|
||||
"shell/browser/electron_web_contents_utility_handler_impl.h",
|
||||
"shell/browser/electron_web_ui_controller_factory.cc",
|
||||
"shell/browser/electron_web_ui_controller_factory.h",
|
||||
"shell/browser/event_emitter_mixin.cc",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "electron",
|
||||
"version": "15.5.5",
|
||||
"version": "15.5.7",
|
||||
"repository": "https://github.com/electron/electron",
|
||||
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
||||
"devDependencies": {
|
||||
|
||||
@@ -14,3 +14,6 @@ m98_protect_against_deleting_a_current_xfb_buffer.patch
|
||||
m96-lts_vulkan_fix_issue_with_redefining_a_layered_attachment.patch
|
||||
cherry-pick-d27d9d059b51.patch
|
||||
m100_fix_crash_when_pausing_xfb_then_deleting_a_buffer.patch
|
||||
cherry-pick-d49484c21e3c.patch
|
||||
cherry-pick-a602a068e022.patch
|
||||
fix_checkednumeric_using_the_wrong_type.patch
|
||||
|
||||
31
patches/angle/cherry-pick-a602a068e022.patch
Normal file
31
patches/angle/cherry-pick-a602a068e022.patch
Normal file
@@ -0,0 +1,31 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jamie Madill <jmadill@chromium.org>
|
||||
Date: Tue, 19 Apr 2022 17:01:20 -0400
|
||||
Subject: Fix validate state cache after XFB buffer deleted.
|
||||
|
||||
Bug: chromium:1317650
|
||||
Change-Id: Iec9f1167c3b2957091dd0f4ef3efcfcd7c4bf3c0
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3594250
|
||||
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
|
||||
Auto-Submit: Jamie Madill <jmadill@chromium.org>
|
||||
Commit-Queue: Jamie Madill <jmadill@chromium.org>
|
||||
(cherry picked from commit 4efc4ee6830a8a53a0daf9daa3c7aa835db4220f)
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3621779
|
||||
Reviewed-by: Amirali Abdolrashidi <abdolrashidi@google.com>
|
||||
|
||||
diff --git a/src/libANGLE/State.cpp b/src/libANGLE/State.cpp
|
||||
index 182709c348f7490e1ee990a05570c13d7e9d0dd7..dc2b1728e3a7ab494e616940565f08692a9ff028 100644
|
||||
--- a/src/libANGLE/State.cpp
|
||||
+++ b/src/libANGLE/State.cpp
|
||||
@@ -2115,10 +2115,7 @@ angle::Result State::detachBuffer(Context *context, const Buffer *buffer)
|
||||
if (curTransformFeedback)
|
||||
{
|
||||
ANGLE_TRY(curTransformFeedback->detachBuffer(context, bufferID));
|
||||
- if (isTransformFeedbackActiveUnpaused())
|
||||
- {
|
||||
- context->getStateCache().onActiveTransformFeedbackChange(context);
|
||||
- }
|
||||
+ context->getStateCache().onActiveTransformFeedbackChange(context);
|
||||
}
|
||||
|
||||
if (getVertexArray()->detachBuffer(context, bufferID))
|
||||
33
patches/angle/cherry-pick-d49484c21e3c.patch
Normal file
33
patches/angle/cherry-pick-d49484c21e3c.patch
Normal file
@@ -0,0 +1,33 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Jamie Madill <jmadill@chromium.org>
|
||||
Date: Mon, 11 Apr 2022 12:29:00 -0400
|
||||
Subject: Add error check on resuming XFB with deleted buffer.
|
||||
|
||||
Bug: chromium:1313905
|
||||
Change-Id: I22c6f6400b05ca32c922fba9a3b9d4b5841ca8b8
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3578378
|
||||
Auto-Submit: Jamie Madill <jmadill@chromium.org>
|
||||
Reviewed-by: Geoff Lang <geofflang@chromium.org>
|
||||
Commit-Queue: Jamie Madill <jmadill@chromium.org>
|
||||
(cherry picked from commit 5c85fd4e11a3835a0719223a7cedb978d309da21)
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3594103
|
||||
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
|
||||
|
||||
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
|
||||
index 1523cd5f0093b7b4b03bf0cd5432ee0a15f17dab..5f42d4b418fe6ae2f8c7473ef7a8954ef128ff99 100644
|
||||
--- a/src/libANGLE/validationES3.cpp
|
||||
+++ b/src/libANGLE/validationES3.cpp
|
||||
@@ -4286,6 +4286,13 @@ bool ValidateUniformBlockBinding(const Context *context,
|
||||
return false;
|
||||
}
|
||||
|
||||
+ if (!ValidateProgramExecutableXFBBuffersPresent(context,
|
||||
+ context->getState().getProgramExecutable()))
|
||||
+ {
|
||||
+ context->validationError(GL_INVALID_OPERATION, kTransformFeedbackBufferMissing);
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
return true;
|
||||
}
|
||||
|
||||
58
patches/angle/fix_checkednumeric_using_the_wrong_type.patch
Normal file
58
patches/angle/fix_checkednumeric_using_the_wrong_type.patch
Normal file
@@ -0,0 +1,58 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Geoff Lang <geofflang@google.com>
|
||||
Date: Fri, 1 Apr 2022 11:38:17 -0400
|
||||
Subject: Fix CheckedNumeric using the wrong type.
|
||||
|
||||
Validation for glBufferSubData checks that the buffer is large enough
|
||||
for size+offset but verifies they fit in a size_t which is a different
|
||||
type than the deduced type for size+offset on 32-bit systems.
|
||||
|
||||
Use decltype to ensure that we always verify there is no overflow on the
|
||||
correct type.
|
||||
|
||||
Bug: chromium:1298867
|
||||
Change-Id: I82f534b2d227d3273a763e626ebeae068dc918dc
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3563515
|
||||
Reviewed-by: Jamie Madill <jmadill@chromium.org>
|
||||
Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
|
||||
Commit-Queue: Geoff Lang <geofflang@chromium.org>
|
||||
(cherry picked from commit c458b5add432c3da98ef370680518d0af7e4d4e3)
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3630020
|
||||
|
||||
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
|
||||
index 9802a3385d5f042df8b643b9b452de29b41ba868..e0add8edaac527fac374afefbebce216d21182e9 100644
|
||||
--- a/src/libANGLE/validationES2.cpp
|
||||
+++ b/src/libANGLE/validationES2.cpp
|
||||
@@ -3779,7 +3779,7 @@ bool ValidateBufferSubData(const Context *context,
|
||||
}
|
||||
|
||||
// Check for possible overflow of size + offset
|
||||
- angle::CheckedNumeric<size_t> checkedSize(size);
|
||||
+ angle::CheckedNumeric<decltype(size + offset)> checkedSize(size);
|
||||
checkedSize += offset;
|
||||
if (!checkedSize.IsValid())
|
||||
{
|
||||
diff --git a/src/tests/gl_tests/BufferDataTest.cpp b/src/tests/gl_tests/BufferDataTest.cpp
|
||||
index b3e70c797ace1fbcaf0002fe7d63e4b4ac418e97..bad538962d262f81b3e6e78c820a28e114ea75fa 100644
|
||||
--- a/src/tests/gl_tests/BufferDataTest.cpp
|
||||
+++ b/src/tests/gl_tests/BufferDataTest.cpp
|
||||
@@ -746,6 +746,19 @@ void main()
|
||||
EXPECT_PIXEL_COLOR_EQ(3, 3, GLColor::green);
|
||||
}
|
||||
|
||||
+// Verify that buffer sub data uploads are properly validated within the buffer size range on 32-bit
|
||||
+// systems.
|
||||
+TEST_P(BufferDataTest, BufferSizeValidation32Bit)
|
||||
+{
|
||||
+ GLBuffer buffer;
|
||||
+ glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
||||
+ glBufferData(GL_ARRAY_BUFFER, 100, nullptr, GL_STATIC_DRAW);
|
||||
+
|
||||
+ GLubyte data = 0;
|
||||
+ glBufferSubData(GL_ARRAY_BUFFER, std::numeric_limits<uint32_t>::max(), 1, &data);
|
||||
+ EXPECT_GL_ERROR(GL_INVALID_VALUE);
|
||||
+}
|
||||
+
|
||||
// Tests a null crash bug caused by copying from null back-end buffer pointer
|
||||
// when calling bufferData again after drawing without calling bufferData in D3D11.
|
||||
TEST_P(BufferDataTestES3, DrawWithNotCallingBufferData)
|
||||
@@ -180,3 +180,5 @@ m96-lts_add_bounds_check_to_webgpudecoderimpl_dorequestdevice.patch
|
||||
cherry-pick-5ff02e4d7368.patch
|
||||
cherry-pick-12ba78f3fa7a.patch
|
||||
reland_fix_noopener_case_for_user_activation_consumption.patch
|
||||
cherry-pick-99c3f3bfd507.patch
|
||||
cherry-pick-ec0cce63f47d.patch
|
||||
|
||||
64
patches/chromium/cherry-pick-99c3f3bfd507.patch
Normal file
64
patches/chromium/cherry-pick-99c3f3bfd507.patch
Normal file
@@ -0,0 +1,64 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Eugene Zemtsov <eugene@chromium.org>
|
||||
Date: Fri, 8 Apr 2022 23:28:35 +0000
|
||||
Subject: Only destroy successfully created compression session in VT encoder
|
||||
|
||||
This is a defensive change, since we don't have a repro on hand.
|
||||
My guess is that VTCompressionSessionCreate() might fail to create a
|
||||
compression session, but still write a value to compressionSessionOut.
|
||||
It makes VTCompressionSessionInvalidate() access uninitialized memory.
|
||||
|
||||
That's why this CL makes sure that we only destroy a compression session
|
||||
if VTCompressionSessionCreate() reports success.
|
||||
|
||||
Bug: 1312563
|
||||
Change-Id: I468ce0e10bad251ca0b62b568607dbc5c32ba8bc
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3575680
|
||||
Reviewed-by: Dale Curtis <dalecurtis@chromium.org>
|
||||
Commit-Queue: Eugene Zemtsov <eugene@chromium.org>
|
||||
Cr-Commit-Position: refs/heads/main@{#990654}
|
||||
|
||||
diff --git a/media/gpu/mac/vt_video_encode_accelerator_mac.cc b/media/gpu/mac/vt_video_encode_accelerator_mac.cc
|
||||
index 8a49e706890a173a3e09ae16b8e88500aefb0499..39384b426a38f2210040cb3f2cbba85893496a7b 100644
|
||||
--- a/media/gpu/mac/vt_video_encode_accelerator_mac.cc
|
||||
+++ b/media/gpu/mac/vt_video_encode_accelerator_mac.cc
|
||||
@@ -120,13 +120,13 @@ VTVideoEncodeAccelerator::GetSupportedProfiles() {
|
||||
SupportedProfiles profiles;
|
||||
const bool rv = CreateCompressionSession(
|
||||
gfx::Size(kDefaultResolutionWidth, kDefaultResolutionHeight));
|
||||
- DestroyCompressionSession();
|
||||
if (!rv) {
|
||||
VLOG(1)
|
||||
<< "Hardware encode acceleration is not available on this platform.";
|
||||
return profiles;
|
||||
}
|
||||
|
||||
+ DestroyCompressionSession();
|
||||
SupportedProfile profile;
|
||||
profile.max_framerate_numerator = kMaxFrameRateNumerator;
|
||||
profile.max_framerate_denominator = kMaxFrameRateDenominator;
|
||||
@@ -505,10 +505,8 @@ bool VTVideoEncodeAccelerator::ResetCompressionSession() {
|
||||
DestroyCompressionSession();
|
||||
|
||||
bool session_rv = CreateCompressionSession(input_visible_size_);
|
||||
- if (!session_rv) {
|
||||
- DestroyCompressionSession();
|
||||
+ if (!session_rv)
|
||||
return false;
|
||||
- }
|
||||
|
||||
const bool configure_rv = ConfigureCompressionSession();
|
||||
if (configure_rv)
|
||||
@@ -544,6 +542,12 @@ bool VTVideoEncodeAccelerator::CreateCompressionSession(
|
||||
&VTVideoEncodeAccelerator::CompressionCallback,
|
||||
reinterpret_cast<void*>(this), compression_session_.InitializeInto());
|
||||
if (status != noErr) {
|
||||
+ // IMPORTANT: ScopedCFTypeRef::release() doesn't call CFRelease().
|
||||
+ // In case of an error VTCompressionSessionCreate() is not supposed to
|
||||
+ // write a non-null value into compression_session_, but just in case,
|
||||
+ // we'll clear it without calling CFRelease() because it can be unsafe
|
||||
+ // to call on a not fully created session.
|
||||
+ (void)compression_session_.release();
|
||||
DLOG(ERROR) << " VTCompressionSessionCreate failed: " << status;
|
||||
return false;
|
||||
}
|
||||
160
patches/chromium/cherry-pick-ec0cce63f47d.patch
Normal file
160
patches/chromium/cherry-pick-ec0cce63f47d.patch
Normal file
@@ -0,0 +1,160 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Corentin Pescheloche <cpescheloche@fb.com>
|
||||
Date: Tue, 10 May 2022 14:05:53 +0000
|
||||
Subject: Cleanup profiler group detached profilers
|
||||
|
||||
ProfilerGroup keeps track of detached profilers to be able to gracefully
|
||||
stop leaked profilers when the corresponding ExecutionContext is
|
||||
destroyed.
|
||||
|
||||
(cherry picked from commit 9f9d5fd2f3085414fc8776bf556fb5c4fa2dac2c)
|
||||
|
||||
Change-Id: I4fdbbc3a5208819397d742c9ecbff117f839691c
|
||||
Bug: chromium:1297283
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3594570
|
||||
Commit-Queue: Corentin Pescheloche <cpescheloche@fb.com>
|
||||
Cr-Original-Commit-Position: refs/heads/main@{#994316}
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3620956
|
||||
Reviewed-by: Oleh Lamzin <lamzin@google.com>
|
||||
Owners-Override: Oleh Lamzin <lamzin@google.com>
|
||||
Commit-Queue: Roger Felipe Zanoni da Silva <rzanoni@google.com>
|
||||
Auto-Submit: Roger Felipe Zanoni da Silva <rzanoni@google.com>
|
||||
Cr-Commit-Position: refs/branch-heads/4664@{#1629}
|
||||
Cr-Branched-From: 24dc4ee75e01a29d390d43c9c264372a169273a7-refs/heads/main@{#929512}
|
||||
|
||||
diff --git a/third_party/blink/renderer/core/timing/profiler_group.cc b/third_party/blink/renderer/core/timing/profiler_group.cc
|
||||
index 090068ee1dc22a0c823a4817e6c6e748fcec354b..466e4f76fce71787b78c2d24624e60184f1d1f36 100644
|
||||
--- a/third_party/blink/renderer/core/timing/profiler_group.cc
|
||||
+++ b/third_party/blink/renderer/core/timing/profiler_group.cc
|
||||
@@ -110,8 +110,7 @@ ProfilerGroup::ProfilerGroup(v8::Isolate* isolate)
|
||||
: isolate_(isolate),
|
||||
cpu_profiler_(nullptr),
|
||||
next_profiler_id_(0),
|
||||
- num_active_profilers_(0) {
|
||||
-}
|
||||
+ num_active_profilers_(0) {}
|
||||
|
||||
void DiscardedSamplesDelegate::Notify() {
|
||||
if (profiler_group_) {
|
||||
@@ -234,6 +233,8 @@ void ProfilerGroup::WillBeDestroyed() {
|
||||
DCHECK(!profilers_.Contains(profiler));
|
||||
}
|
||||
|
||||
+ StopDetachedProfilers();
|
||||
+
|
||||
if (cpu_profiler_)
|
||||
TeardownV8Profiler();
|
||||
}
|
||||
@@ -304,18 +305,49 @@ void ProfilerGroup::CancelProfiler(Profiler* profiler) {
|
||||
|
||||
void ProfilerGroup::CancelProfilerAsync(ScriptState* script_state,
|
||||
Profiler* profiler) {
|
||||
+ DCHECK(IsMainThread());
|
||||
DCHECK(cpu_profiler_);
|
||||
DCHECK(!profiler->stopped());
|
||||
profilers_.erase(profiler);
|
||||
|
||||
+ // register the profiler to be cleaned up in case its associated context
|
||||
+ // gets destroyed before the cleanup task is executed.
|
||||
+ detached_profiler_ids_.push_back(profiler->ProfilerId());
|
||||
+
|
||||
// Since it's possible for the profiler to get destructed along with its
|
||||
// associated context, dispatch a task to cleanup context-independent isolate
|
||||
// resources (rather than use the context's task runner).
|
||||
ThreadScheduler::Current()->V8TaskRunner()->PostTask(
|
||||
- FROM_HERE, WTF::Bind(&ProfilerGroup::CancelProfilerImpl,
|
||||
+ FROM_HERE, WTF::Bind(&ProfilerGroup::StopDetachedProfiler,
|
||||
WrapPersistent(this), profiler->ProfilerId()));
|
||||
}
|
||||
|
||||
+void ProfilerGroup::StopDetachedProfiler(String profiler_id) {
|
||||
+ DCHECK(IsMainThread());
|
||||
+
|
||||
+ // we use a vector instead of a map because the expected number of profiler
|
||||
+ // is expected to be very small
|
||||
+ auto* it = std::find(detached_profiler_ids_.begin(),
|
||||
+ detached_profiler_ids_.end(), profiler_id);
|
||||
+
|
||||
+ if (it == detached_profiler_ids_.end()) {
|
||||
+ // Profiler already stopped
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ CancelProfilerImpl(profiler_id);
|
||||
+ detached_profiler_ids_.erase(it);
|
||||
+}
|
||||
+
|
||||
+void ProfilerGroup::StopDetachedProfilers() {
|
||||
+ DCHECK(IsMainThread());
|
||||
+
|
||||
+ for (auto& detached_profiler_id : detached_profiler_ids_) {
|
||||
+ CancelProfilerImpl(detached_profiler_id);
|
||||
+ }
|
||||
+ detached_profiler_ids_.clear();
|
||||
+}
|
||||
+
|
||||
void ProfilerGroup::CancelProfilerImpl(String profiler_id) {
|
||||
if (!cpu_profiler_)
|
||||
return;
|
||||
diff --git a/third_party/blink/renderer/core/timing/profiler_group.h b/third_party/blink/renderer/core/timing/profiler_group.h
|
||||
index d673d0d6ec63a042a6b08149ba7c2b3fc505e221..8c27d41b160876e0347186958f0e9f08efd41e01 100644
|
||||
--- a/third_party/blink/renderer/core/timing/profiler_group.h
|
||||
+++ b/third_party/blink/renderer/core/timing/profiler_group.h
|
||||
@@ -81,6 +81,10 @@ class CORE_EXPORT ProfilerGroup
|
||||
// Internal implementation of cancel.
|
||||
void CancelProfilerImpl(String profiler_id);
|
||||
|
||||
+ // Clean context independent resources for leaked profilers
|
||||
+ void StopDetachedProfiler(String profiler_id);
|
||||
+ void StopDetachedProfilers();
|
||||
+
|
||||
// Generates an unused string identifier to use for a new profiling session.
|
||||
String NextProfilerId();
|
||||
|
||||
@@ -88,9 +92,11 @@ class CORE_EXPORT ProfilerGroup
|
||||
v8::CpuProfiler* cpu_profiler_;
|
||||
int next_profiler_id_;
|
||||
int num_active_profilers_;
|
||||
-
|
||||
HeapHashSet<WeakMember<Profiler>> profilers_;
|
||||
|
||||
+ // Store the ids of leaked collected profilers that needs to be stopped
|
||||
+ Vector<String> detached_profiler_ids_;
|
||||
+
|
||||
// A set of observers, one for each ExecutionContext that has profiling
|
||||
// enabled.
|
||||
HeapHashSet<Member<ProfilingContextObserver>> context_observers_;
|
||||
diff --git a/third_party/blink/renderer/core/timing/profiler_group_test.cc b/third_party/blink/renderer/core/timing/profiler_group_test.cc
|
||||
index fadab535bc3f8de7173e329e4d514e648e0f5817..1879523e9f18c41b448957d906c1684c024814da 100644
|
||||
--- a/third_party/blink/renderer/core/timing/profiler_group_test.cc
|
||||
+++ b/third_party/blink/renderer/core/timing/profiler_group_test.cc
|
||||
@@ -268,4 +268,29 @@ TEST(ProfilerGroupTest, LeakProfilerWithContext) {
|
||||
test::RunPendingTasks();
|
||||
}
|
||||
|
||||
+// Tests that a ProfilerGroup doesn't crash if the ProfilerGroup is destroyed
|
||||
+// before a Profiler::Dispose is ran.
|
||||
+TEST(ProfilerGroupTest, Bug1297283) {
|
||||
+ {
|
||||
+ V8TestingScope scope;
|
||||
+ ProfilerGroup* profiler_group = ProfilerGroup::From(scope.GetIsolate());
|
||||
+ profiler_group->OnProfilingContextAdded(scope.GetExecutionContext());
|
||||
+
|
||||
+ ProfilerInitOptions* init_options = ProfilerInitOptions::Create();
|
||||
+ init_options->setSampleInterval(0);
|
||||
+ init_options->setMaxBufferSize(0);
|
||||
+ Profiler* profiler = profiler_group->CreateProfiler(
|
||||
+ scope.GetScriptState(), *init_options, base::TimeTicks(),
|
||||
+ scope.GetExceptionState());
|
||||
+ EXPECT_FALSE(profiler->stopped());
|
||||
+
|
||||
+ // Force a collection of the underlying Profiler
|
||||
+ profiler = nullptr;
|
||||
+ ThreadState::Current()->CollectAllGarbageForTesting();
|
||||
+ // Exit Scope deallocating Context triggering ProfilerGroup::WillBeDestroyed
|
||||
+ // Ensure doesn't crash.
|
||||
+ }
|
||||
+ test::RunPendingTasks();
|
||||
+}
|
||||
+
|
||||
} // namespace blink
|
||||
@@ -17,5 +17,7 @@
|
||||
|
||||
"src/electron/patches/ReactiveObjC": "src/third_party/squirrel.mac/vendor/ReactiveObjC",
|
||||
|
||||
"src/electron/patches/angle": "src/third_party/angle"
|
||||
"src/electron/patches/angle": "src/third_party/angle",
|
||||
|
||||
"src/electron/patches/icu": "src/third_party/icu"
|
||||
}
|
||||
|
||||
1
patches/icu/.patches
Normal file
1
patches/icu/.patches
Normal file
@@ -0,0 +1 @@
|
||||
m100_cp_pr_2070_fix_int32_overflow.patch
|
||||
349
patches/icu/m100_cp_pr_2070_fix_int32_overflow.patch
Normal file
349
patches/icu/m100_cp_pr_2070_fix_int32_overflow.patch
Normal file
@@ -0,0 +1,349 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Frank Tang <ftang@chromium.org>
|
||||
Date: Fri, 29 Apr 2022 16:50:59 -0700
|
||||
Subject: CP PR 2070 fix int32 overflow
|
||||
|
||||
https://github.com/unicode-org/icu/pull/2070
|
||||
https://unicode-org.atlassian.net/browse/ICU-22005
|
||||
|
||||
Bug: chromium:1316946
|
||||
Change-Id: I6cd7d687a55b6cc157b1afa52365908be2992fa6
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/deps/icu/+/3614280
|
||||
Reviewed-by: Jungshik Shin <jshin@chromium.org>
|
||||
(cherry picked from commit 85814e1af52482199a13d284545623ffbc9eef83)
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/deps/icu/+/3632709
|
||||
|
||||
diff --git a/README.chromium b/README.chromium
|
||||
index 269fc7263ca642b24fd709312d6ecb70a9c8f48a..33c642b49be7fbebbe9b0f43edea565317e4c8ca 100644
|
||||
--- a/README.chromium
|
||||
+++ b/README.chromium
|
||||
@@ -282,3 +282,7 @@ D. Local Modifications
|
||||
- upstream PR:
|
||||
https://github.com/unicode-org/icu/pull/1762
|
||||
|
||||
+12. Patch i18n/formatted_string_builder to fix int32_t overflow bug
|
||||
+ patches/formatted_string_builder.patch
|
||||
+ - https://github.com/unicode-org/icu/pull/2070
|
||||
+ - https://unicode-org.atlassian.net/browse/ICU-22005
|
||||
diff --git a/patches/formatted_string_builder.patch b/patches/formatted_string_builder.patch
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..4fad6f18601f7b4097e2d46bfe6660bec2e2882d
|
||||
--- /dev/null
|
||||
+++ b/patches/formatted_string_builder.patch
|
||||
@@ -0,0 +1,191 @@
|
||||
+diff --git a/source/i18n/formatted_string_builder.cpp b/source/i18n/formatted_string_builder.cpp
|
||||
+index 73407864..628fbea8 100644
|
||||
+--- a/source/i18n/formatted_string_builder.cpp
|
||||
++++ b/source/i18n/formatted_string_builder.cpp
|
||||
+@@ -6,6 +6,7 @@
|
||||
+ #if !UCONFIG_NO_FORMATTING
|
||||
+
|
||||
+ #include "formatted_string_builder.h"
|
||||
++#include "putilimp.h"
|
||||
+ #include "unicode/ustring.h"
|
||||
+ #include "unicode/utf16.h"
|
||||
+ #include "unicode/unum.h" // for UNumberFormatFields literals
|
||||
+@@ -197,6 +198,9 @@ FormattedStringBuilder::splice(int32_t startThis, int32_t endThis, const Unicod
|
||||
+ int32_t thisLength = endThis - startThis;
|
||||
+ int32_t otherLength = endOther - startOther;
|
||||
+ int32_t count = otherLength - thisLength;
|
||||
++ if (U_FAILURE(status)) {
|
||||
++ return count;
|
||||
++ }
|
||||
+ int32_t position;
|
||||
+ if (count > 0) {
|
||||
+ // Overall, chars need to be added.
|
||||
+@@ -221,6 +225,9 @@ int32_t FormattedStringBuilder::append(const FormattedStringBuilder &other, UErr
|
||||
+
|
||||
+ int32_t
|
||||
+ FormattedStringBuilder::insert(int32_t index, const FormattedStringBuilder &other, UErrorCode &status) {
|
||||
++ if (U_FAILURE(status)) {
|
||||
++ return 0;
|
||||
++ }
|
||||
+ if (this == &other) {
|
||||
+ status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
+ return 0;
|
||||
+@@ -255,12 +262,18 @@ int32_t FormattedStringBuilder::prepareForInsert(int32_t index, int32_t count, U
|
||||
+ U_ASSERT(index >= 0);
|
||||
+ U_ASSERT(index <= fLength);
|
||||
+ U_ASSERT(count >= 0);
|
||||
++ U_ASSERT(fZero >= 0);
|
||||
++ U_ASSERT(fLength >= 0);
|
||||
++ U_ASSERT(getCapacity() - fZero >= fLength);
|
||||
++ if (U_FAILURE(status)) {
|
||||
++ return count;
|
||||
++ }
|
||||
+ if (index == 0 && fZero - count >= 0) {
|
||||
+ // Append to start
|
||||
+ fZero -= count;
|
||||
+ fLength += count;
|
||||
+ return fZero;
|
||||
+- } else if (index == fLength && fZero + fLength + count < getCapacity()) {
|
||||
++ } else if (index == fLength && count <= getCapacity() - fZero - fLength) {
|
||||
+ // Append to end
|
||||
+ fLength += count;
|
||||
+ return fZero + fLength - count;
|
||||
+@@ -275,18 +288,26 @@ int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t co
|
||||
+ int32_t oldZero = fZero;
|
||||
+ char16_t *oldChars = getCharPtr();
|
||||
+ Field *oldFields = getFieldPtr();
|
||||
+- if (fLength + count > oldCapacity) {
|
||||
+- if ((fLength + count) > INT32_MAX / 2) {
|
||||
+- // If we continue, then newCapacity will overflow int32_t in the next line.
|
||||
++ int32_t newLength;
|
||||
++ if (uprv_add32_overflow(fLength, count, &newLength)) {
|
||||
++ status = U_INPUT_TOO_LONG_ERROR;
|
||||
++ return -1;
|
||||
++ }
|
||||
++ int32_t newZero;
|
||||
++ if (newLength > oldCapacity) {
|
||||
++ if (newLength > INT32_MAX / 2) {
|
||||
++ // We do not support more than 1G char16_t in this code because
|
||||
++ // dealing with >2G *bytes* can cause subtle bugs.
|
||||
+ status = U_INPUT_TOO_LONG_ERROR;
|
||||
+ return -1;
|
||||
+ }
|
||||
+- int32_t newCapacity = (fLength + count) * 2;
|
||||
+- int32_t newZero = newCapacity / 2 - (fLength + count) / 2;
|
||||
++ // Keep newCapacity also to at most 1G char16_t.
|
||||
++ int32_t newCapacity = newLength * 2;
|
||||
++ newZero = (newCapacity - newLength) / 2;
|
||||
+
|
||||
+ // C++ note: malloc appears in two places: here and in the assignment operator.
|
||||
+- auto newChars = static_cast<char16_t *> (uprv_malloc(sizeof(char16_t) * newCapacity));
|
||||
+- auto newFields = static_cast<Field *>(uprv_malloc(sizeof(Field) * newCapacity));
|
||||
++ auto newChars = static_cast<char16_t *> (uprv_malloc(sizeof(char16_t) * static_cast<size_t>(newCapacity)));
|
||||
++ auto newFields = static_cast<Field *>(uprv_malloc(sizeof(Field) * static_cast<size_t>(newCapacity)));
|
||||
+ if (newChars == nullptr || newFields == nullptr) {
|
||||
+ uprv_free(newChars);
|
||||
+ uprv_free(newFields);
|
||||
+@@ -315,10 +336,8 @@ int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t co
|
||||
+ fChars.heap.capacity = newCapacity;
|
||||
+ fFields.heap.ptr = newFields;
|
||||
+ fFields.heap.capacity = newCapacity;
|
||||
+- fZero = newZero;
|
||||
+- fLength += count;
|
||||
+ } else {
|
||||
+- int32_t newZero = oldCapacity / 2 - (fLength + count) / 2;
|
||||
++ newZero = (oldCapacity - newLength) / 2;
|
||||
+
|
||||
+ // C++ note: memmove is required because src and dest may overlap.
|
||||
+ // First copy the entire string to the location of the prefix, and then move the suffix
|
||||
+@@ -331,18 +350,20 @@ int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t co
|
||||
+ uprv_memmove2(oldFields + newZero + index + count,
|
||||
+ oldFields + newZero + index,
|
||||
+ sizeof(Field) * (fLength - index));
|
||||
+-
|
||||
+- fZero = newZero;
|
||||
+- fLength += count;
|
||||
+ }
|
||||
+- U_ASSERT((fZero + index) >= 0);
|
||||
++ fZero = newZero;
|
||||
++ fLength = newLength;
|
||||
+ return fZero + index;
|
||||
+ }
|
||||
+
|
||||
+ int32_t FormattedStringBuilder::remove(int32_t index, int32_t count) {
|
||||
+- // TODO: Reset the heap here? (If the string after removal can fit on stack?)
|
||||
++ U_ASSERT(0 <= index);
|
||||
++ U_ASSERT(index <= fLength);
|
||||
++ U_ASSERT(count <= (fLength - index));
|
||||
++ U_ASSERT(index <= getCapacity() - fZero);
|
||||
++
|
||||
+ int32_t position = index + fZero;
|
||||
+- U_ASSERT(position >= 0);
|
||||
++ // TODO: Reset the heap here? (If the string after removal can fit on stack?)
|
||||
+ uprv_memmove2(getCharPtr() + position,
|
||||
+ getCharPtr() + position + count,
|
||||
+ sizeof(char16_t) * (fLength - index - count));
|
||||
+diff --git a/source/test/intltest/formatted_string_builder_test.cpp b/source/test/intltest/formatted_string_builder_test.cpp
|
||||
+index 45721a32..57294e24 100644
|
||||
+--- a/source/test/intltest/formatted_string_builder_test.cpp
|
||||
++++ b/source/test/intltest/formatted_string_builder_test.cpp
|
||||
+@@ -22,6 +22,7 @@ class FormattedStringBuilderTest : public IntlTest {
|
||||
+ void testFields();
|
||||
+ void testUnlimitedCapacity();
|
||||
+ void testCodePoints();
|
||||
++ void testInsertOverflow();
|
||||
+
|
||||
+ void runIndexedTest(int32_t index, UBool exec, const char *&name, char *par = 0) override;
|
||||
+
|
||||
+@@ -50,6 +51,7 @@ void FormattedStringBuilderTest::runIndexedTest(int32_t index, UBool exec, const
|
||||
+ TESTCASE_AUTO(testFields);
|
||||
+ TESTCASE_AUTO(testUnlimitedCapacity);
|
||||
+ TESTCASE_AUTO(testCodePoints);
|
||||
++ TESTCASE_AUTO(testInsertOverflow);
|
||||
+ TESTCASE_AUTO_END;
|
||||
+ }
|
||||
+
|
||||
+@@ -308,6 +310,45 @@ void FormattedStringBuilderTest::testCodePoints() {
|
||||
+ assertEquals("Code point count is 2", 2, nsb.codePointCount());
|
||||
+ }
|
||||
+
|
||||
++void FormattedStringBuilderTest::testInsertOverflow() {
|
||||
++ if (quick) return;
|
||||
++ // Setup the test fixture in sb, sb2, ustr.
|
||||
++ UErrorCode status = U_ZERO_ERROR;
|
||||
++ FormattedStringBuilder sb;
|
||||
++ int32_t data_length = INT32_MAX / 2;
|
||||
++ UnicodeString ustr(data_length, u'a', data_length);
|
||||
++ sb.append(ustr, kUndefinedField, status);
|
||||
++ assertSuccess("Setup the first FormattedStringBuilder", status);
|
||||
++
|
||||
++ FormattedStringBuilder sb2;
|
||||
++ sb2.append(ustr, kUndefinedField, status);
|
||||
++ sb2.insert(0, ustr, 0, data_length / 2, kUndefinedField, status);
|
||||
++ sb2.writeTerminator(status);
|
||||
++ assertSuccess("Setup the second FormattedStringBuilder", status);
|
||||
++
|
||||
++ ustr = sb2.toUnicodeString();
|
||||
++ // Complete setting up the test fixture in sb, sb2 and ustr.
|
||||
++
|
||||
++ // Test splice() of the second UnicodeString
|
||||
++ sb.splice(0, 1, ustr, 1, ustr.length(),
|
||||
++ kUndefinedField, status);
|
||||
++ assertEquals(
|
||||
++ "splice() long text should not crash but return U_INPUT_TOO_LONG_ERROR",
|
||||
++ U_INPUT_TOO_LONG_ERROR, status);
|
||||
++
|
||||
++ // Test sb.insert() of the first FormattedStringBuilder with the second one.
|
||||
++ sb.insert(0, sb2, status);
|
||||
++ assertEquals(
|
||||
++ "insert() long FormattedStringBuilder should not crash but return "
|
||||
++ "U_INPUT_TOO_LONG_ERROR", U_INPUT_TOO_LONG_ERROR, status);
|
||||
++
|
||||
++ // Test sb.insert() of the first FormattedStringBuilder with UnicodeString.
|
||||
++ sb.insert(0, ustr, 0, ustr.length(), kUndefinedField, status);
|
||||
++ assertEquals(
|
||||
++ "insert() long UnicodeString should not crash but return "
|
||||
++ "U_INPUT_TOO_LONG_ERROR", U_INPUT_TOO_LONG_ERROR, status);
|
||||
++}
|
||||
++
|
||||
+ void FormattedStringBuilderTest::assertEqualsImpl(const UnicodeString &a, const FormattedStringBuilder &b) {
|
||||
+ // TODO: Why won't this compile without the IntlTest:: qualifier?
|
||||
+ IntlTest::assertEquals("Lengths should be the same", a.length(), b.length());
|
||||
diff --git a/source/i18n/formatted_string_builder.cpp b/source/i18n/formatted_string_builder.cpp
|
||||
index b370f14f2ac4ff0873e5614376ae51fe0232b02d..628fbea871167619f60cc6eed0ee4b7776dab7fe 100644
|
||||
--- a/source/i18n/formatted_string_builder.cpp
|
||||
+++ b/source/i18n/formatted_string_builder.cpp
|
||||
@@ -6,6 +6,7 @@
|
||||
#if !UCONFIG_NO_FORMATTING
|
||||
|
||||
#include "formatted_string_builder.h"
|
||||
+#include "putilimp.h"
|
||||
#include "unicode/ustring.h"
|
||||
#include "unicode/utf16.h"
|
||||
#include "unicode/unum.h" // for UNumberFormatFields literals
|
||||
@@ -197,6 +198,9 @@ FormattedStringBuilder::splice(int32_t startThis, int32_t endThis, const Unicod
|
||||
int32_t thisLength = endThis - startThis;
|
||||
int32_t otherLength = endOther - startOther;
|
||||
int32_t count = otherLength - thisLength;
|
||||
+ if (U_FAILURE(status)) {
|
||||
+ return count;
|
||||
+ }
|
||||
int32_t position;
|
||||
if (count > 0) {
|
||||
// Overall, chars need to be added.
|
||||
@@ -221,6 +225,9 @@ int32_t FormattedStringBuilder::append(const FormattedStringBuilder &other, UErr
|
||||
|
||||
int32_t
|
||||
FormattedStringBuilder::insert(int32_t index, const FormattedStringBuilder &other, UErrorCode &status) {
|
||||
+ if (U_FAILURE(status)) {
|
||||
+ return 0;
|
||||
+ }
|
||||
if (this == &other) {
|
||||
status = U_ILLEGAL_ARGUMENT_ERROR;
|
||||
return 0;
|
||||
@@ -255,12 +262,18 @@ int32_t FormattedStringBuilder::prepareForInsert(int32_t index, int32_t count, U
|
||||
U_ASSERT(index >= 0);
|
||||
U_ASSERT(index <= fLength);
|
||||
U_ASSERT(count >= 0);
|
||||
+ U_ASSERT(fZero >= 0);
|
||||
+ U_ASSERT(fLength >= 0);
|
||||
+ U_ASSERT(getCapacity() - fZero >= fLength);
|
||||
+ if (U_FAILURE(status)) {
|
||||
+ return count;
|
||||
+ }
|
||||
if (index == 0 && fZero - count >= 0) {
|
||||
// Append to start
|
||||
fZero -= count;
|
||||
fLength += count;
|
||||
return fZero;
|
||||
- } else if (index == fLength && fZero + fLength + count < getCapacity()) {
|
||||
+ } else if (index == fLength && count <= getCapacity() - fZero - fLength) {
|
||||
// Append to end
|
||||
fLength += count;
|
||||
return fZero + fLength - count;
|
||||
@@ -275,18 +288,26 @@ int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t co
|
||||
int32_t oldZero = fZero;
|
||||
char16_t *oldChars = getCharPtr();
|
||||
Field *oldFields = getFieldPtr();
|
||||
- if (fLength + count > oldCapacity) {
|
||||
- if ((fLength + count) > INT32_MAX / 2) {
|
||||
- // If we continue, then newCapacity will overlow int32_t in the next line.
|
||||
+ int32_t newLength;
|
||||
+ if (uprv_add32_overflow(fLength, count, &newLength)) {
|
||||
+ status = U_INPUT_TOO_LONG_ERROR;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ int32_t newZero;
|
||||
+ if (newLength > oldCapacity) {
|
||||
+ if (newLength > INT32_MAX / 2) {
|
||||
+ // We do not support more than 1G char16_t in this code because
|
||||
+ // dealing with >2G *bytes* can cause subtle bugs.
|
||||
status = U_INPUT_TOO_LONG_ERROR;
|
||||
return -1;
|
||||
}
|
||||
- int32_t newCapacity = (fLength + count) * 2;
|
||||
- int32_t newZero = newCapacity / 2 - (fLength + count) / 2;
|
||||
+ // Keep newCapacity also to at most 1G char16_t.
|
||||
+ int32_t newCapacity = newLength * 2;
|
||||
+ newZero = (newCapacity - newLength) / 2;
|
||||
|
||||
// C++ note: malloc appears in two places: here and in the assignment operator.
|
||||
- auto newChars = static_cast<char16_t *> (uprv_malloc(sizeof(char16_t) * newCapacity));
|
||||
- auto newFields = static_cast<Field *>(uprv_malloc(sizeof(Field) * newCapacity));
|
||||
+ auto newChars = static_cast<char16_t *> (uprv_malloc(sizeof(char16_t) * static_cast<size_t>(newCapacity)));
|
||||
+ auto newFields = static_cast<Field *>(uprv_malloc(sizeof(Field) * static_cast<size_t>(newCapacity)));
|
||||
if (newChars == nullptr || newFields == nullptr) {
|
||||
uprv_free(newChars);
|
||||
uprv_free(newFields);
|
||||
@@ -315,10 +336,8 @@ int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t co
|
||||
fChars.heap.capacity = newCapacity;
|
||||
fFields.heap.ptr = newFields;
|
||||
fFields.heap.capacity = newCapacity;
|
||||
- fZero = newZero;
|
||||
- fLength += count;
|
||||
} else {
|
||||
- int32_t newZero = oldCapacity / 2 - (fLength + count) / 2;
|
||||
+ newZero = (oldCapacity - newLength) / 2;
|
||||
|
||||
// C++ note: memmove is required because src and dest may overlap.
|
||||
// First copy the entire string to the location of the prefix, and then move the suffix
|
||||
@@ -331,18 +350,20 @@ int32_t FormattedStringBuilder::prepareForInsertHelper(int32_t index, int32_t co
|
||||
uprv_memmove2(oldFields + newZero + index + count,
|
||||
oldFields + newZero + index,
|
||||
sizeof(Field) * (fLength - index));
|
||||
-
|
||||
- fZero = newZero;
|
||||
- fLength += count;
|
||||
}
|
||||
- U_ASSERT((fZero + index) >= 0);
|
||||
+ fZero = newZero;
|
||||
+ fLength = newLength;
|
||||
return fZero + index;
|
||||
}
|
||||
|
||||
int32_t FormattedStringBuilder::remove(int32_t index, int32_t count) {
|
||||
- // TODO: Reset the heap here? (If the string after removal can fit on stack?)
|
||||
+ U_ASSERT(0 <= index);
|
||||
+ U_ASSERT(index <= fLength);
|
||||
+ U_ASSERT(count <= (fLength - index));
|
||||
+ U_ASSERT(index <= getCapacity() - fZero);
|
||||
+
|
||||
int32_t position = index + fZero;
|
||||
- U_ASSERT(position >= 0);
|
||||
+ // TODO: Reset the heap here? (If the string after removal can fit on stack?)
|
||||
uprv_memmove2(getCharPtr() + position,
|
||||
getCharPtr() + position + count,
|
||||
sizeof(char16_t) * (fLength - index - count));
|
||||
@@ -42,6 +42,7 @@
|
||||
"parallel/test-https-agent-session-reuse",
|
||||
"parallel/test-https-options-boolean-check",
|
||||
"parallel/test-inspector-inspect-brk-node",
|
||||
"parallel/test-icu-minimum-version",
|
||||
"parallel/test-inspector-multisession-ws",
|
||||
"parallel/test-inspector-port-zero-cluster",
|
||||
"parallel/test-inspector-tracing-domain",
|
||||
|
||||
@@ -4,7 +4,11 @@ from __future__ import print_function
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import urllib2
|
||||
# Python 3 / 2 compat import
|
||||
try:
|
||||
from urllib.request import Request, urlopen
|
||||
except ImportError:
|
||||
from urllib2 import Request, urlopen
|
||||
|
||||
sys.path.append(
|
||||
os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../.."))
|
||||
@@ -28,12 +32,12 @@ def is_json(myjson):
|
||||
|
||||
def get_content(retry_count = 5):
|
||||
try:
|
||||
request = urllib2.Request(
|
||||
request = Request(
|
||||
BASE_URL + version,
|
||||
headers={"Authorization" : authToken}
|
||||
)
|
||||
|
||||
proposed_content = urllib2.urlopen(
|
||||
proposed_content = urlopen(
|
||||
request
|
||||
).read()
|
||||
|
||||
|
||||
@@ -31,12 +31,24 @@ void SetElectronCryptoReady(bool ready) {
|
||||
#endif
|
||||
|
||||
bool IsEncryptionAvailable() {
|
||||
#if defined(OS_LINUX)
|
||||
// Calling IsEncryptionAvailable() before the app is ready results in a crash
|
||||
// on Linux.
|
||||
// Refs: https://github.com/electron/electron/issues/32206.
|
||||
if (!Browser::Get()->is_ready())
|
||||
return false;
|
||||
#endif
|
||||
return OSCrypt::IsEncryptionAvailable();
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> EncryptString(v8::Isolate* isolate,
|
||||
const std::string& plaintext) {
|
||||
if (!OSCrypt::IsEncryptionAvailable()) {
|
||||
if (!IsEncryptionAvailable()) {
|
||||
if (!Browser::Get()->is_ready()) {
|
||||
gin_helper::ErrorThrower(isolate).ThrowError(
|
||||
"safeStorage cannot be used before app is ready");
|
||||
return v8::Local<v8::Value>();
|
||||
}
|
||||
gin_helper::ErrorThrower(isolate).ThrowError(
|
||||
"Error while decrypting the ciphertext provided to "
|
||||
"safeStorage.decryptString. "
|
||||
@@ -59,7 +71,12 @@ v8::Local<v8::Value> EncryptString(v8::Isolate* isolate,
|
||||
}
|
||||
|
||||
std::string DecryptString(v8::Isolate* isolate, v8::Local<v8::Value> buffer) {
|
||||
if (!OSCrypt::IsEncryptionAvailable()) {
|
||||
if (!IsEncryptionAvailable()) {
|
||||
if (!Browser::Get()->is_ready()) {
|
||||
gin_helper::ErrorThrower(isolate).ThrowError(
|
||||
"safeStorage cannot be used before app is ready");
|
||||
return "";
|
||||
}
|
||||
gin_helper::ErrorThrower(isolate).ThrowError(
|
||||
"Error while decrypting the ciphertext provided to "
|
||||
"safeStorage.decryptString. "
|
||||
|
||||
@@ -1661,7 +1661,7 @@ void WebContents::Message(bool internal,
|
||||
// webContents.emit('-ipc-message', new Event(), internal, channel,
|
||||
// arguments);
|
||||
EmitWithSender("-ipc-message", render_frame_host,
|
||||
electron::mojom::ElectronBrowser::InvokeCallback(), internal,
|
||||
electron::mojom::ElectronApiIPC::InvokeCallback(), internal,
|
||||
channel, std::move(arguments));
|
||||
}
|
||||
|
||||
@@ -1669,7 +1669,7 @@ void WebContents::Invoke(
|
||||
bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments,
|
||||
electron::mojom::ElectronBrowser::InvokeCallback callback,
|
||||
electron::mojom::ElectronApiIPC::InvokeCallback callback,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
TRACE_EVENT1("electron", "WebContents::Invoke", "channel", channel);
|
||||
// webContents.emit('-ipc-invoke', new Event(), internal, channel, arguments);
|
||||
@@ -1695,7 +1695,7 @@ void WebContents::ReceivePostMessage(
|
||||
v8::Local<v8::Value> message_value =
|
||||
electron::DeserializeV8Value(isolate, message);
|
||||
EmitWithSender("-ipc-ports", render_frame_host,
|
||||
electron::mojom::ElectronBrowser::InvokeCallback(), false,
|
||||
electron::mojom::ElectronApiIPC::InvokeCallback(), false,
|
||||
channel, message_value, std::move(wrapped_ports));
|
||||
}
|
||||
|
||||
@@ -1703,7 +1703,7 @@ void WebContents::MessageSync(
|
||||
bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments,
|
||||
electron::mojom::ElectronBrowser::MessageSyncCallback callback,
|
||||
electron::mojom::ElectronApiIPC::MessageSyncCallback callback,
|
||||
content::RenderFrameHost* render_frame_host) {
|
||||
TRACE_EVENT1("electron", "WebContents::MessageSync", "channel", channel);
|
||||
// webContents.emit('-ipc-message-sync', new Event(sender, message), internal,
|
||||
@@ -1741,7 +1741,7 @@ void WebContents::MessageHost(const std::string& channel,
|
||||
TRACE_EVENT1("electron", "WebContents::MessageHost", "channel", channel);
|
||||
// webContents.emit('ipc-message-host', new Event(), channel, args);
|
||||
EmitWithSender("ipc-message-host", render_frame_host,
|
||||
electron::mojom::ElectronBrowser::InvokeCallback(), channel,
|
||||
electron::mojom::ElectronApiIPC::InvokeCallback(), channel,
|
||||
std::move(arguments));
|
||||
}
|
||||
|
||||
@@ -3154,7 +3154,8 @@ void WebContents::SetTemporaryZoomLevel(double level) {
|
||||
}
|
||||
|
||||
void WebContents::DoGetZoomLevel(
|
||||
electron::mojom::ElectronBrowser::DoGetZoomLevelCallback callback) {
|
||||
electron::mojom::ElectronWebContentsUtility::DoGetZoomLevelCallback
|
||||
callback) {
|
||||
std::move(callback).Run(GetZoomLevel());
|
||||
}
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ class WebContents : public gin::Wrappable<WebContents>,
|
||||
template <typename... Args>
|
||||
bool EmitWithSender(base::StringPiece name,
|
||||
content::RenderFrameHost* sender,
|
||||
electron::mojom::ElectronBrowser::InvokeCallback callback,
|
||||
electron::mojom::ElectronApiIPC::InvokeCallback callback,
|
||||
Args&&... args) {
|
||||
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||
@@ -396,7 +396,7 @@ class WebContents : public gin::Wrappable<WebContents>,
|
||||
fullscreen_frame_ = rfh;
|
||||
}
|
||||
|
||||
// mojom::ElectronBrowser
|
||||
// mojom::ElectronApiIPC
|
||||
void Message(bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments,
|
||||
@@ -404,9 +404,8 @@ class WebContents : public gin::Wrappable<WebContents>,
|
||||
void Invoke(bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments,
|
||||
electron::mojom::ElectronBrowser::InvokeCallback callback,
|
||||
electron::mojom::ElectronApiIPC::InvokeCallback callback,
|
||||
content::RenderFrameHost* render_frame_host);
|
||||
void OnFirstNonEmptyLayout(content::RenderFrameHost* render_frame_host);
|
||||
void ReceivePostMessage(const std::string& channel,
|
||||
blink::TransferableMessage message,
|
||||
content::RenderFrameHost* render_frame_host);
|
||||
@@ -414,7 +413,7 @@ class WebContents : public gin::Wrappable<WebContents>,
|
||||
bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments,
|
||||
electron::mojom::ElectronBrowser::MessageSyncCallback callback,
|
||||
electron::mojom::ElectronApiIPC::MessageSyncCallback callback,
|
||||
content::RenderFrameHost* render_frame_host);
|
||||
void MessageTo(int32_t web_contents_id,
|
||||
const std::string& channel,
|
||||
@@ -422,10 +421,15 @@ class WebContents : public gin::Wrappable<WebContents>,
|
||||
void MessageHost(const std::string& channel,
|
||||
blink::CloneableMessage arguments,
|
||||
content::RenderFrameHost* render_frame_host);
|
||||
|
||||
// mojom::ElectronWebContentsUtility
|
||||
void OnFirstNonEmptyLayout(content::RenderFrameHost* render_frame_host);
|
||||
void UpdateDraggableRegions(std::vector<mojom::DraggableRegionPtr> regions);
|
||||
void SetTemporaryZoomLevel(double level);
|
||||
void DoGetZoomLevel(
|
||||
electron::mojom::ElectronBrowser::DoGetZoomLevelCallback callback);
|
||||
electron::mojom::ElectronWebContentsUtility::DoGetZoomLevelCallback
|
||||
callback);
|
||||
|
||||
void SetImageAnimationPolicy(const std::string& new_policy);
|
||||
|
||||
// Grants |origin| access to |device|.
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace gin_helper {
|
||||
|
||||
class Event : public gin::Wrappable<Event> {
|
||||
public:
|
||||
using InvokeCallback = electron::mojom::ElectronBrowser::InvokeCallback;
|
||||
using InvokeCallback = electron::mojom::ElectronApiIPC::InvokeCallback;
|
||||
|
||||
static gin::WrapperInfo kWrapperInfo;
|
||||
|
||||
|
||||
108
shell/browser/electron_api_ipc_handler_impl.cc
Normal file
108
shell/browser/electron_api_ipc_handler_impl.cc
Normal file
@@ -0,0 +1,108 @@
|
||||
// Copyright (c) 2022 Slack Technologies, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/electron_api_ipc_handler_impl.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
||||
|
||||
namespace electron {
|
||||
ElectronApiIPCHandlerImpl::ElectronApiIPCHandlerImpl(
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingAssociatedReceiver<mojom::ElectronApiIPC> receiver)
|
||||
: render_process_id_(frame_host->GetProcess()->GetID()),
|
||||
render_frame_id_(frame_host->GetRoutingID()) {
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(frame_host);
|
||||
DCHECK(web_contents);
|
||||
content::WebContentsObserver::Observe(web_contents);
|
||||
|
||||
receiver_.Bind(std::move(receiver));
|
||||
receiver_.set_disconnect_handler(base::BindOnce(
|
||||
&ElectronApiIPCHandlerImpl::OnConnectionError, GetWeakPtr()));
|
||||
}
|
||||
|
||||
ElectronApiIPCHandlerImpl::~ElectronApiIPCHandlerImpl() = default;
|
||||
|
||||
void ElectronApiIPCHandlerImpl::WebContentsDestroyed() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
void ElectronApiIPCHandlerImpl::OnConnectionError() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
void ElectronApiIPCHandlerImpl::Message(bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->Message(internal, channel, std::move(arguments),
|
||||
GetRenderFrameHost());
|
||||
}
|
||||
}
|
||||
void ElectronApiIPCHandlerImpl::Invoke(bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments,
|
||||
InvokeCallback callback) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->Invoke(internal, channel, std::move(arguments),
|
||||
std::move(callback), GetRenderFrameHost());
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronApiIPCHandlerImpl::ReceivePostMessage(
|
||||
const std::string& channel,
|
||||
blink::TransferableMessage message) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->ReceivePostMessage(channel, std::move(message),
|
||||
GetRenderFrameHost());
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronApiIPCHandlerImpl::MessageSync(bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments,
|
||||
MessageSyncCallback callback) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->MessageSync(internal, channel, std::move(arguments),
|
||||
std::move(callback), GetRenderFrameHost());
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronApiIPCHandlerImpl::MessageTo(int32_t web_contents_id,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->MessageTo(web_contents_id, channel, std::move(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronApiIPCHandlerImpl::MessageHost(const std::string& channel,
|
||||
blink::CloneableMessage arguments) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->MessageHost(channel, std::move(arguments),
|
||||
GetRenderFrameHost());
|
||||
}
|
||||
}
|
||||
|
||||
content::RenderFrameHost* ElectronApiIPCHandlerImpl::GetRenderFrameHost() {
|
||||
return content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
|
||||
}
|
||||
|
||||
// static
|
||||
void ElectronApiIPCHandlerImpl::Create(
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingAssociatedReceiver<mojom::ElectronApiIPC> receiver) {
|
||||
new ElectronApiIPCHandlerImpl(frame_host, std::move(receiver));
|
||||
}
|
||||
} // namespace electron
|
||||
@@ -1,9 +1,9 @@
|
||||
// Copyright (c) 2019 Slack Technologies, Inc.
|
||||
// Copyright (c) 2022 Slack Technologies, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_ELECTRON_BROWSER_HANDLER_IMPL_H_
|
||||
#define SHELL_BROWSER_ELECTRON_BROWSER_HANDLER_IMPL_H_
|
||||
#ifndef SHELL_BROWSER_ELECTRON_API_IPC_HANDLER_IMPL_H_
|
||||
#define SHELL_BROWSER_ELECTRON_API_IPC_HANDLER_IMPL_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -12,8 +12,7 @@
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "electron/shell/common/api/api.mojom.h"
|
||||
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
||||
#include "mojo/public/cpp/bindings/receiver.h"
|
||||
#include "mojo/public/cpp/bindings/associated_receiver.h"
|
||||
#include "shell/browser/api/electron_api_web_contents.h"
|
||||
|
||||
namespace content {
|
||||
@@ -21,17 +20,18 @@ class RenderFrameHost;
|
||||
}
|
||||
|
||||
namespace electron {
|
||||
class ElectronBrowserHandlerImpl : public mojom::ElectronBrowser,
|
||||
public content::WebContentsObserver {
|
||||
class ElectronApiIPCHandlerImpl : public mojom::ElectronApiIPC,
|
||||
public content::WebContentsObserver {
|
||||
public:
|
||||
explicit ElectronBrowserHandlerImpl(
|
||||
explicit ElectronApiIPCHandlerImpl(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
mojo::PendingReceiver<mojom::ElectronBrowser> receiver);
|
||||
mojo::PendingAssociatedReceiver<mojom::ElectronApiIPC> receiver);
|
||||
|
||||
static void Create(content::RenderFrameHost* frame_host,
|
||||
mojo::PendingReceiver<mojom::ElectronBrowser> receiver);
|
||||
static void Create(
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingAssociatedReceiver<mojom::ElectronApiIPC> receiver);
|
||||
|
||||
// mojom::ElectronBrowser:
|
||||
// mojom::ElectronApiIPC:
|
||||
void Message(bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments) override;
|
||||
@@ -39,7 +39,6 @@ class ElectronBrowserHandlerImpl : public mojom::ElectronBrowser,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments,
|
||||
InvokeCallback callback) override;
|
||||
void OnFirstNonEmptyLayout() override;
|
||||
void ReceivePostMessage(const std::string& channel,
|
||||
blink::TransferableMessage message) override;
|
||||
void MessageSync(bool internal,
|
||||
@@ -51,17 +50,13 @@ class ElectronBrowserHandlerImpl : public mojom::ElectronBrowser,
|
||||
blink::CloneableMessage arguments) override;
|
||||
void MessageHost(const std::string& channel,
|
||||
blink::CloneableMessage arguments) override;
|
||||
void UpdateDraggableRegions(
|
||||
std::vector<mojom::DraggableRegionPtr> regions) override;
|
||||
void SetTemporaryZoomLevel(double level) override;
|
||||
void DoGetZoomLevel(DoGetZoomLevelCallback callback) override;
|
||||
|
||||
base::WeakPtr<ElectronBrowserHandlerImpl> GetWeakPtr() {
|
||||
base::WeakPtr<ElectronApiIPCHandlerImpl> GetWeakPtr() {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
}
|
||||
|
||||
private:
|
||||
~ElectronBrowserHandlerImpl() override;
|
||||
~ElectronApiIPCHandlerImpl() override;
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void WebContentsDestroyed() override;
|
||||
@@ -73,11 +68,11 @@ class ElectronBrowserHandlerImpl : public mojom::ElectronBrowser,
|
||||
const int render_process_id_;
|
||||
const int render_frame_id_;
|
||||
|
||||
mojo::Receiver<mojom::ElectronBrowser> receiver_{this};
|
||||
mojo::AssociatedReceiver<mojom::ElectronApiIPC> receiver_{this};
|
||||
|
||||
base::WeakPtrFactory<ElectronBrowserHandlerImpl> weak_factory_{this};
|
||||
base::WeakPtrFactory<ElectronApiIPCHandlerImpl> weak_factory_{this};
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronBrowserHandlerImpl);
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronApiIPCHandlerImpl);
|
||||
};
|
||||
} // namespace electron
|
||||
#endif // SHELL_BROWSER_ELECTRON_BROWSER_HANDLER_IMPL_H_
|
||||
#endif // SHELL_BROWSER_ELECTRON_API_IPC_HANDLER_IMPL_H_
|
||||
@@ -71,13 +71,14 @@
|
||||
#include "shell/browser/api/electron_api_web_request.h"
|
||||
#include "shell/browser/badging/badge_manager.h"
|
||||
#include "shell/browser/child_web_contents_tracker.h"
|
||||
#include "shell/browser/electron_api_ipc_handler_impl.h"
|
||||
#include "shell/browser/electron_autofill_driver_factory.h"
|
||||
#include "shell/browser/electron_browser_context.h"
|
||||
#include "shell/browser/electron_browser_handler_impl.h"
|
||||
#include "shell/browser/electron_browser_main_parts.h"
|
||||
#include "shell/browser/electron_navigation_throttle.h"
|
||||
#include "shell/browser/electron_quota_permission_context.h"
|
||||
#include "shell/browser/electron_speech_recognition_manager_delegate.h"
|
||||
#include "shell/browser/electron_web_contents_utility_handler_impl.h"
|
||||
#include "shell/browser/font_defaults.h"
|
||||
#include "shell/browser/javascript_environment.h"
|
||||
#include "shell/browser/media/media_capture_devices_dispatcher.h"
|
||||
@@ -1444,6 +1445,31 @@ bool ElectronBrowserClient::PreSpawnChild(
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
bool BindElectronApiIPC(
|
||||
mojo::PendingAssociatedReceiver<electron::mojom::ElectronApiIPC> receiver,
|
||||
content::RenderFrameHost* frame_host) {
|
||||
auto* contents = content::WebContents::FromRenderFrameHost(frame_host);
|
||||
if (contents) {
|
||||
auto* prefs = WebContentsPreferences::From(contents);
|
||||
if (frame_host->GetFrameTreeNodeId() ==
|
||||
contents->GetMainFrame()->GetFrameTreeNodeId() ||
|
||||
(prefs && prefs->IsEnabled(options::kNodeIntegrationInSubFrames))) {
|
||||
ElectronApiIPCHandlerImpl::Create(frame_host, std::move(receiver));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void BindElectronWebContentsUtility(
|
||||
mojo::PendingAssociatedReceiver<electron::mojom::ElectronWebContentsUtility>
|
||||
receiver,
|
||||
content::RenderFrameHost* frame_host) {
|
||||
ElectronWebContentsUtilityHandlerImpl::Create(frame_host,
|
||||
std::move(receiver));
|
||||
}
|
||||
|
||||
bool ElectronBrowserClient::BindAssociatedReceiverFromFrame(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
const std::string& interface_name,
|
||||
@@ -1454,6 +1480,21 @@ bool ElectronBrowserClient::BindAssociatedReceiverFromFrame(
|
||||
render_frame_host);
|
||||
return true;
|
||||
}
|
||||
if (interface_name == electron::mojom::ElectronApiIPC::Name_) {
|
||||
return BindElectronApiIPC(
|
||||
mojo::PendingAssociatedReceiver<electron::mojom::ElectronApiIPC>(
|
||||
std::move(*handle)),
|
||||
render_frame_host);
|
||||
}
|
||||
|
||||
if (interface_name == electron::mojom::ElectronWebContentsUtility::Name_) {
|
||||
BindElectronWebContentsUtility(
|
||||
mojo::PendingAssociatedReceiver<
|
||||
electron::mojom::ElectronWebContentsUtility>(std::move(*handle)),
|
||||
render_frame_host);
|
||||
return true;
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
if (interface_name == printing::mojom::PrintManagerHost::Name_) {
|
||||
mojo::PendingAssociatedReceiver<printing::mojom::PrintManagerHost> receiver(
|
||||
@@ -1506,12 +1547,6 @@ void ElectronBrowserClient::BindHostReceiverForRenderer(
|
||||
#endif
|
||||
}
|
||||
|
||||
void BindElectronBrowser(
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingReceiver<electron::mojom::ElectronBrowser> receiver) {
|
||||
ElectronBrowserHandlerImpl::Create(frame_host, std::move(receiver));
|
||||
}
|
||||
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
void BindMimeHandlerService(
|
||||
content::RenderFrameHost* frame_host,
|
||||
@@ -1550,8 +1585,6 @@ void ElectronBrowserClient::RegisterBrowserInterfaceBindersForFrame(
|
||||
base::BindRepeating(&BindNetworkHintsHandler));
|
||||
map->Add<blink::mojom::BadgeService>(
|
||||
base::BindRepeating(&badging::BadgeManager::BindFrameReceiver));
|
||||
map->Add<electron::mojom::ElectronBrowser>(
|
||||
base::BindRepeating(&BindElectronBrowser));
|
||||
#if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
map->Add<extensions::mime_handler::MimeHandlerService>(
|
||||
base::BindRepeating(&BindMimeHandlerService));
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
// Copyright (c) 2019 Slack Technologies, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/electron_browser_handler_impl.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "content/public/browser/browser_context.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
||||
|
||||
namespace electron {
|
||||
ElectronBrowserHandlerImpl::ElectronBrowserHandlerImpl(
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingReceiver<mojom::ElectronBrowser> receiver)
|
||||
: render_process_id_(frame_host->GetProcess()->GetID()),
|
||||
render_frame_id_(frame_host->GetRoutingID()) {
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(frame_host);
|
||||
DCHECK(web_contents);
|
||||
content::WebContentsObserver::Observe(web_contents);
|
||||
|
||||
receiver_.Bind(std::move(receiver));
|
||||
receiver_.set_disconnect_handler(base::BindOnce(
|
||||
&ElectronBrowserHandlerImpl::OnConnectionError, GetWeakPtr()));
|
||||
}
|
||||
|
||||
ElectronBrowserHandlerImpl::~ElectronBrowserHandlerImpl() = default;
|
||||
|
||||
void ElectronBrowserHandlerImpl::WebContentsDestroyed() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
void ElectronBrowserHandlerImpl::OnConnectionError() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
void ElectronBrowserHandlerImpl::Message(bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->Message(internal, channel, std::move(arguments),
|
||||
GetRenderFrameHost());
|
||||
}
|
||||
}
|
||||
void ElectronBrowserHandlerImpl::Invoke(bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments,
|
||||
InvokeCallback callback) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->Invoke(internal, channel, std::move(arguments),
|
||||
std::move(callback), GetRenderFrameHost());
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronBrowserHandlerImpl::OnFirstNonEmptyLayout() {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->OnFirstNonEmptyLayout(GetRenderFrameHost());
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronBrowserHandlerImpl::ReceivePostMessage(
|
||||
const std::string& channel,
|
||||
blink::TransferableMessage message) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->ReceivePostMessage(channel, std::move(message),
|
||||
GetRenderFrameHost());
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronBrowserHandlerImpl::MessageSync(bool internal,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments,
|
||||
MessageSyncCallback callback) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->MessageSync(internal, channel, std::move(arguments),
|
||||
std::move(callback), GetRenderFrameHost());
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronBrowserHandlerImpl::MessageTo(int32_t web_contents_id,
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->MessageTo(web_contents_id, channel, std::move(arguments));
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronBrowserHandlerImpl::MessageHost(
|
||||
const std::string& channel,
|
||||
blink::CloneableMessage arguments) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->MessageHost(channel, std::move(arguments),
|
||||
GetRenderFrameHost());
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronBrowserHandlerImpl::UpdateDraggableRegions(
|
||||
std::vector<mojom::DraggableRegionPtr> regions) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->UpdateDraggableRegions(std::move(regions));
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronBrowserHandlerImpl::SetTemporaryZoomLevel(double level) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->SetTemporaryZoomLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronBrowserHandlerImpl::DoGetZoomLevel(
|
||||
DoGetZoomLevelCallback callback) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->DoGetZoomLevel(std::move(callback));
|
||||
}
|
||||
}
|
||||
|
||||
content::RenderFrameHost* ElectronBrowserHandlerImpl::GetRenderFrameHost() {
|
||||
return content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
|
||||
}
|
||||
|
||||
// static
|
||||
void ElectronBrowserHandlerImpl::Create(
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingReceiver<mojom::ElectronBrowser> receiver) {
|
||||
new ElectronBrowserHandlerImpl(frame_host, std::move(receiver));
|
||||
}
|
||||
} // namespace electron
|
||||
@@ -17,6 +17,9 @@
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "chrome/browser/icon_manager.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "chrome/common/chrome_switches.h"
|
||||
#include "components/os_crypt/key_storage_config_linux.h"
|
||||
#include "components/os_crypt/os_crypt.h"
|
||||
#include "content/browser/browser_main_loop.h" // nogncheck
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
@@ -483,6 +486,26 @@ void ElectronBrowserMainParts::PostCreateMainMessageLoop() {
|
||||
#endif
|
||||
#if defined(OS_LINUX)
|
||||
bluez::DBusBluezManagerWrapperLinux::Initialize();
|
||||
|
||||
// Set up crypt config. This needs to be done before anything starts the
|
||||
// network service, as the raw encryption key needs to be shared with the
|
||||
// network service for encrypted cookie storage.
|
||||
std::string app_name = electron::Browser::Get()->GetName();
|
||||
const base::CommandLine& command_line =
|
||||
*base::CommandLine::ForCurrentProcess();
|
||||
std::unique_ptr<os_crypt::Config> config =
|
||||
std::make_unique<os_crypt::Config>();
|
||||
// Forward to os_crypt the flag to use a specific password store.
|
||||
config->store = command_line.GetSwitchValueASCII(::switches::kPasswordStore);
|
||||
config->product_name = app_name;
|
||||
config->application_name = app_name;
|
||||
config->main_thread_runner = base::ThreadTaskRunnerHandle::Get();
|
||||
// c.f.
|
||||
// https://source.chromium.org/chromium/chromium/src/+/master:chrome/common/chrome_switches.cc;l=689;drc=9d82515060b9b75fa941986f5db7390299669ef1
|
||||
config->should_use_preference =
|
||||
command_line.HasSwitch(::switches::kEnableEncryptionSelection);
|
||||
base::PathService::Get(chrome::DIR_USER_DATA, &config->user_data_path);
|
||||
OSCrypt::SetConfig(std::move(config));
|
||||
#endif
|
||||
#if defined(OS_POSIX)
|
||||
// Exit in response to SIGINT, SIGTERM, etc.
|
||||
|
||||
@@ -333,22 +333,32 @@ bool ElectronPermissionManager::CheckDevicePermission(
|
||||
static_cast<content::PermissionType>(
|
||||
WebContentsPermissionHelper::PermissionType::SERIAL)) {
|
||||
#if defined(OS_WIN)
|
||||
if (device->FindStringKey(kDeviceInstanceIdKey) ==
|
||||
granted_device.FindStringKey(kDeviceInstanceIdKey))
|
||||
const auto* instance_id = device->FindStringKey(kDeviceInstanceIdKey);
|
||||
const auto* port_instance_id =
|
||||
granted_device.FindStringKey(kDeviceInstanceIdKey);
|
||||
if (instance_id && port_instance_id &&
|
||||
*instance_id == *port_instance_id)
|
||||
return true;
|
||||
#else
|
||||
const auto* serial_number =
|
||||
granted_device.FindStringKey(kSerialNumberKey);
|
||||
const auto* port_serial_number =
|
||||
device->FindStringKey(kSerialNumberKey);
|
||||
if (device->FindIntKey(kVendorIdKey) !=
|
||||
granted_device.FindIntKey(kVendorIdKey) ||
|
||||
device->FindIntKey(kProductIdKey) !=
|
||||
granted_device.FindIntKey(kProductIdKey) ||
|
||||
*device->FindStringKey(kSerialNumberKey) !=
|
||||
*granted_device.FindStringKey(kSerialNumberKey)) {
|
||||
(serial_number && port_serial_number &&
|
||||
*port_serial_number != *serial_number)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
#if defined(OS_MAC)
|
||||
if (*device->FindStringKey(kUsbDriverKey) !=
|
||||
*granted_device.FindStringKey(kUsbDriverKey)) {
|
||||
const auto* usb_driver_key = device->FindStringKey(kUsbDriverKey);
|
||||
const auto* port_usb_driver_key =
|
||||
granted_device.FindStringKey(kUsbDriverKey);
|
||||
if (usb_driver_key && port_usb_driver_key &&
|
||||
*usb_driver_key != *port_usb_driver_key) {
|
||||
continue;
|
||||
}
|
||||
#endif // defined(OS_MAC)
|
||||
|
||||
83
shell/browser/electron_web_contents_utility_handler_impl.cc
Normal file
83
shell/browser/electron_web_contents_utility_handler_impl.cc
Normal file
@@ -0,0 +1,83 @@
|
||||
// Copyright (c) 2022 Slack Technologies, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/electron_web_contents_utility_handler_impl.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "content/public/browser/render_process_host.h"
|
||||
#include "mojo/public/cpp/bindings/self_owned_receiver.h"
|
||||
|
||||
namespace electron {
|
||||
ElectronWebContentsUtilityHandlerImpl::ElectronWebContentsUtilityHandlerImpl(
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingAssociatedReceiver<mojom::ElectronWebContentsUtility> receiver)
|
||||
: render_process_id_(frame_host->GetProcess()->GetID()),
|
||||
render_frame_id_(frame_host->GetRoutingID()) {
|
||||
content::WebContents* web_contents =
|
||||
content::WebContents::FromRenderFrameHost(frame_host);
|
||||
DCHECK(web_contents);
|
||||
content::WebContentsObserver::Observe(web_contents);
|
||||
|
||||
receiver_.Bind(std::move(receiver));
|
||||
receiver_.set_disconnect_handler(base::BindOnce(
|
||||
&ElectronWebContentsUtilityHandlerImpl::OnConnectionError, GetWeakPtr()));
|
||||
}
|
||||
|
||||
ElectronWebContentsUtilityHandlerImpl::
|
||||
~ElectronWebContentsUtilityHandlerImpl() = default;
|
||||
|
||||
void ElectronWebContentsUtilityHandlerImpl::WebContentsDestroyed() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
void ElectronWebContentsUtilityHandlerImpl::OnConnectionError() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
void ElectronWebContentsUtilityHandlerImpl::OnFirstNonEmptyLayout() {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->OnFirstNonEmptyLayout(GetRenderFrameHost());
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronWebContentsUtilityHandlerImpl::UpdateDraggableRegions(
|
||||
std::vector<mojom::DraggableRegionPtr> regions) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->UpdateDraggableRegions(std::move(regions));
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronWebContentsUtilityHandlerImpl::SetTemporaryZoomLevel(
|
||||
double level) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->SetTemporaryZoomLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
void ElectronWebContentsUtilityHandlerImpl::DoGetZoomLevel(
|
||||
DoGetZoomLevelCallback callback) {
|
||||
api::WebContents* api_web_contents = api::WebContents::From(web_contents());
|
||||
if (api_web_contents) {
|
||||
api_web_contents->DoGetZoomLevel(std::move(callback));
|
||||
}
|
||||
}
|
||||
|
||||
content::RenderFrameHost*
|
||||
ElectronWebContentsUtilityHandlerImpl::GetRenderFrameHost() {
|
||||
return content::RenderFrameHost::FromID(render_process_id_, render_frame_id_);
|
||||
}
|
||||
|
||||
// static
|
||||
void ElectronWebContentsUtilityHandlerImpl::Create(
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingAssociatedReceiver<mojom::ElectronWebContentsUtility>
|
||||
receiver) {
|
||||
new ElectronWebContentsUtilityHandlerImpl(frame_host, std::move(receiver));
|
||||
}
|
||||
} // namespace electron
|
||||
68
shell/browser/electron_web_contents_utility_handler_impl.h
Normal file
68
shell/browser/electron_web_contents_utility_handler_impl.h
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright (c) 2022 Slack Technologies, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef SHELL_BROWSER_ELECTRON_WEB_CONTENTS_UTILITY_HANDLER_IMPL_H_
|
||||
#define SHELL_BROWSER_ELECTRON_WEB_CONTENTS_UTILITY_HANDLER_IMPL_H_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "electron/shell/common/api/api.mojom.h"
|
||||
#include "mojo/public/cpp/bindings/associated_receiver.h"
|
||||
#include "shell/browser/api/electron_api_web_contents.h"
|
||||
|
||||
namespace content {
|
||||
class RenderFrameHost;
|
||||
}
|
||||
|
||||
namespace electron {
|
||||
class ElectronWebContentsUtilityHandlerImpl
|
||||
: public mojom::ElectronWebContentsUtility,
|
||||
public content::WebContentsObserver {
|
||||
public:
|
||||
explicit ElectronWebContentsUtilityHandlerImpl(
|
||||
content::RenderFrameHost* render_frame_host,
|
||||
mojo::PendingAssociatedReceiver<mojom::ElectronWebContentsUtility>
|
||||
receiver);
|
||||
|
||||
static void Create(
|
||||
content::RenderFrameHost* frame_host,
|
||||
mojo::PendingAssociatedReceiver<mojom::ElectronWebContentsUtility>
|
||||
receiver);
|
||||
|
||||
// mojom::ElectronWebContentsUtility:
|
||||
void OnFirstNonEmptyLayout() override;
|
||||
void UpdateDraggableRegions(
|
||||
std::vector<mojom::DraggableRegionPtr> regions) override;
|
||||
void SetTemporaryZoomLevel(double level) override;
|
||||
void DoGetZoomLevel(DoGetZoomLevelCallback callback) override;
|
||||
|
||||
base::WeakPtr<ElectronWebContentsUtilityHandlerImpl> GetWeakPtr() {
|
||||
return weak_factory_.GetWeakPtr();
|
||||
}
|
||||
|
||||
private:
|
||||
~ElectronWebContentsUtilityHandlerImpl() override;
|
||||
|
||||
// content::WebContentsObserver:
|
||||
void WebContentsDestroyed() override;
|
||||
|
||||
void OnConnectionError();
|
||||
|
||||
content::RenderFrameHost* GetRenderFrameHost();
|
||||
|
||||
const int render_process_id_;
|
||||
const int render_frame_id_;
|
||||
|
||||
mojo::AssociatedReceiver<mojom::ElectronWebContentsUtility> receiver_{this};
|
||||
|
||||
base::WeakPtrFactory<ElectronWebContentsUtilityHandlerImpl> weak_factory_{
|
||||
this};
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ElectronWebContentsUtilityHandlerImpl);
|
||||
};
|
||||
} // namespace electron
|
||||
#endif // SHELL_BROWSER_ELECTRON_WEB_CONTENTS_UTILITY_HANDLER_IMPL_H_
|
||||
@@ -321,14 +321,15 @@ NativeWindowViews::NativeWindowViews(const gin_helper::Dictionary& options,
|
||||
// Set Window style so that we get a minimize and maximize animation when
|
||||
// frameless.
|
||||
DWORD frame_style = WS_CAPTION | WS_OVERLAPPED;
|
||||
if (resizable_ && thick_frame_)
|
||||
if (resizable_)
|
||||
frame_style |= WS_THICKFRAME;
|
||||
if (minimizable_)
|
||||
frame_style |= WS_MINIMIZEBOX;
|
||||
if (maximizable_)
|
||||
frame_style |= WS_MAXIMIZEBOX;
|
||||
if (!thick_frame_ || !has_frame())
|
||||
frame_style &= ~WS_CAPTION;
|
||||
// We should not show a frame for transparent window.
|
||||
if (!thick_frame_)
|
||||
frame_style &= ~(WS_THICKFRAME | WS_CAPTION);
|
||||
::SetWindowLong(GetAcceleratedWidget(), GWL_STYLE, frame_style);
|
||||
}
|
||||
|
||||
|
||||
@@ -293,46 +293,14 @@ void SystemNetworkContextManager::OnNetworkServiceCreated(
|
||||
KeychainPassword::GetServiceName() = app_name + " Safe Storage";
|
||||
KeychainPassword::GetAccountName() = app_name;
|
||||
#endif
|
||||
#if defined(OS_LINUX)
|
||||
// c.f.
|
||||
// https://source.chromium.org/chromium/chromium/src/+/master:chrome/browser/net/system_network_context_manager.cc;l=515;drc=9d82515060b9b75fa941986f5db7390299669ef1;bpv=1;bpt=1
|
||||
const base::CommandLine& command_line =
|
||||
*base::CommandLine::ForCurrentProcess();
|
||||
|
||||
auto config = std::make_unique<os_crypt::Config>();
|
||||
config->store = command_line.GetSwitchValueASCII(::switches::kPasswordStore);
|
||||
config->product_name = app_name;
|
||||
config->application_name = app_name;
|
||||
config->main_thread_runner = base::ThreadTaskRunnerHandle::Get();
|
||||
// c.f.
|
||||
// https://source.chromium.org/chromium/chromium/src/+/master:chrome/common/chrome_switches.cc;l=689;drc=9d82515060b9b75fa941986f5db7390299669ef1
|
||||
config->should_use_preference =
|
||||
command_line.HasSwitch(::switches::kEnableEncryptionSelection);
|
||||
base::PathService::Get(chrome::DIR_USER_DATA, &config->user_data_path);
|
||||
#endif
|
||||
|
||||
#if defined(OS_WIN) || defined(OS_MAC)
|
||||
// The OSCrypt keys are process bound, so if network service is out of
|
||||
// process, send it the required key.
|
||||
if (content::IsOutOfProcessNetworkService() &&
|
||||
electron::fuses::IsCookieEncryptionEnabled()) {
|
||||
#if defined(OS_LINUX)
|
||||
network::mojom::CryptConfigPtr network_crypt_config =
|
||||
network::mojom::CryptConfig::New();
|
||||
network_crypt_config->application_name = config->application_name;
|
||||
network_crypt_config->product_name = config->product_name;
|
||||
network_crypt_config->store = config->store;
|
||||
network_crypt_config->should_use_preference = config->should_use_preference;
|
||||
network_crypt_config->user_data_path = config->user_data_path;
|
||||
|
||||
network_service->SetCryptConfig(std::move(network_crypt_config));
|
||||
|
||||
#else
|
||||
network_service->SetEncryptionKey(OSCrypt::GetRawEncryptionKey());
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(OS_LINUX)
|
||||
OSCrypt::SetConfig(std::move(config));
|
||||
#endif
|
||||
|
||||
#if DCHECK_IS_ON()
|
||||
|
||||
@@ -50,8 +50,8 @@ END
|
||||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 15,5,5,0
|
||||
PRODUCTVERSION 15,5,5,0
|
||||
FILEVERSION 15,5,7,0
|
||||
PRODUCTVERSION 15,5,7,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
@@ -68,12 +68,12 @@ BEGIN
|
||||
BEGIN
|
||||
VALUE "CompanyName", "GitHub, Inc."
|
||||
VALUE "FileDescription", "Electron"
|
||||
VALUE "FileVersion", "15.5.5"
|
||||
VALUE "FileVersion", "15.5.7"
|
||||
VALUE "InternalName", "electron.exe"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
|
||||
VALUE "OriginalFilename", "electron.exe"
|
||||
VALUE "ProductName", "Electron"
|
||||
VALUE "ProductVersion", "15.5.5"
|
||||
VALUE "ProductVersion", "15.5.7"
|
||||
VALUE "SquirrelAwareVersion", "1"
|
||||
END
|
||||
END
|
||||
|
||||
@@ -31,7 +31,21 @@ struct DraggableRegion {
|
||||
gfx.mojom.Rect bounds;
|
||||
};
|
||||
|
||||
interface ElectronBrowser {
|
||||
interface ElectronWebContentsUtility {
|
||||
// Informs underlying WebContents that first non-empty layout was performed
|
||||
// by compositor.
|
||||
OnFirstNonEmptyLayout();
|
||||
|
||||
UpdateDraggableRegions(
|
||||
array<DraggableRegion> regions);
|
||||
|
||||
SetTemporaryZoomLevel(double zoom_level);
|
||||
|
||||
[Sync]
|
||||
DoGetZoomLevel() => (double result);
|
||||
};
|
||||
|
||||
interface ElectronApiIPC {
|
||||
// Emits an event on |channel| from the ipcMain JavaScript object in the main
|
||||
// process.
|
||||
Message(
|
||||
@@ -46,10 +60,6 @@ interface ElectronBrowser {
|
||||
string channel,
|
||||
blink.mojom.CloneableMessage arguments) => (blink.mojom.CloneableMessage result);
|
||||
|
||||
// Informs underlying WebContents that first non-empty layout was performed
|
||||
// by compositor.
|
||||
OnFirstNonEmptyLayout();
|
||||
|
||||
ReceivePostMessage(string channel, blink.mojom.TransferableMessage message);
|
||||
|
||||
// Emits an event on |channel| from the ipcMain JavaScript object in the main
|
||||
@@ -70,12 +80,4 @@ interface ElectronBrowser {
|
||||
MessageHost(
|
||||
string channel,
|
||||
blink.mojom.CloneableMessage arguments);
|
||||
|
||||
UpdateDraggableRegions(
|
||||
array<DraggableRegion> regions);
|
||||
|
||||
SetTemporaryZoomLevel(double zoom_level);
|
||||
|
||||
[Sync]
|
||||
DoGetZoomLevel() => (double result);
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ v8::Local<v8::Object> CreateNativeEvent(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> sender,
|
||||
content::RenderFrameHost* frame,
|
||||
electron::mojom::ElectronBrowser::MessageSyncCallback callback) {
|
||||
electron::mojom::ElectronApiIPC::MessageSyncCallback callback) {
|
||||
v8::Local<v8::Object> event;
|
||||
if (frame && callback) {
|
||||
gin::Handle<Event> native_event = Event::Create(isolate);
|
||||
|
||||
@@ -29,7 +29,7 @@ v8::Local<v8::Object> CreateNativeEvent(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Object> sender,
|
||||
content::RenderFrameHost* frame,
|
||||
electron::mojom::ElectronBrowser::MessageSyncCallback callback);
|
||||
electron::mojom::ElectronApiIPC::MessageSyncCallback callback);
|
||||
|
||||
} // namespace internal
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "shell/common/node_bindings.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/v8_value_serializer.h"
|
||||
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
||||
#include "third_party/blink/public/web/web_local_frame.h"
|
||||
#include "third_party/blink/public/web/web_message_port_converter.h"
|
||||
|
||||
@@ -59,17 +59,17 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||
v8::Global<v8::Context>(isolate, isolate->GetCurrentContext());
|
||||
weak_context_.SetWeak();
|
||||
|
||||
render_frame->GetBrowserInterfaceBroker()->GetInterface(
|
||||
electron_browser_remote_.BindNewPipeAndPassReceiver());
|
||||
render_frame->GetRemoteAssociatedInterfaces()->GetInterface(
|
||||
&electron_ipc_remote_);
|
||||
}
|
||||
|
||||
void OnDestruct() override { electron_browser_remote_.reset(); }
|
||||
void OnDestruct() override { electron_ipc_remote_.reset(); }
|
||||
|
||||
void WillReleaseScriptContext(v8::Local<v8::Context> context,
|
||||
int32_t world_id) override {
|
||||
if (weak_context_.IsEmpty() ||
|
||||
weak_context_.Get(context->GetIsolate()) == context)
|
||||
electron_browser_remote_.reset();
|
||||
electron_ipc_remote_.reset();
|
||||
}
|
||||
|
||||
// gin::Wrappable:
|
||||
@@ -92,7 +92,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||
bool internal,
|
||||
const std::string& channel,
|
||||
v8::Local<v8::Value> arguments) {
|
||||
if (!electron_browser_remote_) {
|
||||
if (!electron_ipc_remote_) {
|
||||
thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError);
|
||||
return;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||
if (!electron::SerializeV8Value(isolate, arguments, &message)) {
|
||||
return;
|
||||
}
|
||||
electron_browser_remote_->Message(internal, channel, std::move(message));
|
||||
electron_ipc_remote_->Message(internal, channel, std::move(message));
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> Invoke(v8::Isolate* isolate,
|
||||
@@ -108,7 +108,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||
bool internal,
|
||||
const std::string& channel,
|
||||
v8::Local<v8::Value> arguments) {
|
||||
if (!electron_browser_remote_) {
|
||||
if (!electron_ipc_remote_) {
|
||||
thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError);
|
||||
return v8::Local<v8::Promise>();
|
||||
}
|
||||
@@ -119,7 +119,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||
gin_helper::Promise<blink::CloneableMessage> p(isolate);
|
||||
auto handle = p.GetHandle();
|
||||
|
||||
electron_browser_remote_->Invoke(
|
||||
electron_ipc_remote_->Invoke(
|
||||
internal, channel, std::move(message),
|
||||
base::BindOnce(
|
||||
[](gin_helper::Promise<blink::CloneableMessage> p,
|
||||
@@ -134,7 +134,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||
const std::string& channel,
|
||||
v8::Local<v8::Value> message_value,
|
||||
absl::optional<v8::Local<v8::Value>> transfer) {
|
||||
if (!electron_browser_remote_) {
|
||||
if (!electron_ipc_remote_) {
|
||||
thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError);
|
||||
return;
|
||||
}
|
||||
@@ -166,8 +166,8 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||
}
|
||||
|
||||
transferable_message.ports = std::move(ports);
|
||||
electron_browser_remote_->ReceivePostMessage(
|
||||
channel, std::move(transferable_message));
|
||||
electron_ipc_remote_->ReceivePostMessage(channel,
|
||||
std::move(transferable_message));
|
||||
}
|
||||
|
||||
void SendTo(v8::Isolate* isolate,
|
||||
@@ -175,7 +175,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||
int32_t web_contents_id,
|
||||
const std::string& channel,
|
||||
v8::Local<v8::Value> arguments) {
|
||||
if (!electron_browser_remote_) {
|
||||
if (!electron_ipc_remote_) {
|
||||
thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError);
|
||||
return;
|
||||
}
|
||||
@@ -183,15 +183,15 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||
if (!electron::SerializeV8Value(isolate, arguments, &message)) {
|
||||
return;
|
||||
}
|
||||
electron_browser_remote_->MessageTo(web_contents_id, channel,
|
||||
std::move(message));
|
||||
electron_ipc_remote_->MessageTo(web_contents_id, channel,
|
||||
std::move(message));
|
||||
}
|
||||
|
||||
void SendToHost(v8::Isolate* isolate,
|
||||
gin_helper::ErrorThrower thrower,
|
||||
const std::string& channel,
|
||||
v8::Local<v8::Value> arguments) {
|
||||
if (!electron_browser_remote_) {
|
||||
if (!electron_ipc_remote_) {
|
||||
thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError);
|
||||
return;
|
||||
}
|
||||
@@ -199,7 +199,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||
if (!electron::SerializeV8Value(isolate, arguments, &message)) {
|
||||
return;
|
||||
}
|
||||
electron_browser_remote_->MessageHost(channel, std::move(message));
|
||||
electron_ipc_remote_->MessageHost(channel, std::move(message));
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> SendSync(v8::Isolate* isolate,
|
||||
@@ -207,7 +207,7 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||
bool internal,
|
||||
const std::string& channel,
|
||||
v8::Local<v8::Value> arguments) {
|
||||
if (!electron_browser_remote_) {
|
||||
if (!electron_ipc_remote_) {
|
||||
thrower.ThrowError(kIPCMethodCalledAfterContextReleasedError);
|
||||
return v8::Local<v8::Value>();
|
||||
}
|
||||
@@ -217,13 +217,13 @@ class IPCRenderer : public gin::Wrappable<IPCRenderer>,
|
||||
}
|
||||
|
||||
blink::CloneableMessage result;
|
||||
electron_browser_remote_->MessageSync(internal, channel, std::move(message),
|
||||
&result);
|
||||
electron_ipc_remote_->MessageSync(internal, channel, std::move(message),
|
||||
&result);
|
||||
return electron::DeserializeV8Value(isolate, result);
|
||||
}
|
||||
|
||||
v8::Global<v8::Context> weak_context_;
|
||||
mojo::Remote<electron::mojom::ElectronBrowser> electron_browser_remote_;
|
||||
mojo::AssociatedRemote<electron::mojom::ElectronApiIPC> electron_ipc_remote_;
|
||||
};
|
||||
|
||||
gin::WrapperInfo IPCRenderer::kWrapperInfo = {gin::kEmbedderNativeGin};
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include "shell/renderer/api/electron_api_context_bridge.h"
|
||||
#include "shell/renderer/api/electron_api_spell_check_client.h"
|
||||
#include "shell/renderer/renderer_client_base.h"
|
||||
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
||||
#include "third_party/blink/public/common/page/page_zoom.h"
|
||||
#include "third_party/blink/public/common/web_cache/web_cache_resource_type_stats.h"
|
||||
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
||||
@@ -445,10 +445,11 @@ class WebFrameRenderer : public gin::Wrappable<WebFrameRenderer>,
|
||||
if (!MaybeGetRenderFrame(isolate, "setZoomLevel", &render_frame))
|
||||
return;
|
||||
|
||||
mojo::Remote<mojom::ElectronBrowser> browser_remote;
|
||||
render_frame->GetBrowserInterfaceBroker()->GetInterface(
|
||||
browser_remote.BindNewPipeAndPassReceiver());
|
||||
browser_remote->SetTemporaryZoomLevel(level);
|
||||
mojo::AssociatedRemote<mojom::ElectronWebContentsUtility>
|
||||
web_contents_utility_remote;
|
||||
render_frame->GetRemoteAssociatedInterfaces()->GetInterface(
|
||||
&web_contents_utility_remote);
|
||||
web_contents_utility_remote->SetTemporaryZoomLevel(level);
|
||||
}
|
||||
|
||||
double GetZoomLevel(v8::Isolate* isolate) {
|
||||
@@ -457,10 +458,11 @@ class WebFrameRenderer : public gin::Wrappable<WebFrameRenderer>,
|
||||
if (!MaybeGetRenderFrame(isolate, "getZoomLevel", &render_frame))
|
||||
return result;
|
||||
|
||||
mojo::Remote<mojom::ElectronBrowser> browser_remote;
|
||||
render_frame->GetBrowserInterfaceBroker()->GetInterface(
|
||||
browser_remote.BindNewPipeAndPassReceiver());
|
||||
browser_remote->DoGetZoomLevel(&result);
|
||||
mojo::AssociatedRemote<mojom::ElectronWebContentsUtility>
|
||||
web_contents_utility_remote;
|
||||
render_frame->GetRemoteAssociatedInterfaces()->GetInterface(
|
||||
&web_contents_utility_remote);
|
||||
web_contents_utility_remote->DoGetZoomLevel(&result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "shell/common/options_switches.h"
|
||||
#include "shell/common/world_ids.h"
|
||||
#include "shell/renderer/renderer_client_base.h"
|
||||
#include "third_party/blink/public/common/browser_interface_broker_proxy.h"
|
||||
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
|
||||
#include "third_party/blink/public/common/web_preferences/web_preferences.h"
|
||||
#include "third_party/blink/public/platform/web_isolated_world_info.h"
|
||||
#include "third_party/blink/public/web/blink.h"
|
||||
@@ -149,10 +149,11 @@ void ElectronRenderFrameObserver::DraggableRegionsChanged() {
|
||||
regions.push_back(std::move(region));
|
||||
}
|
||||
|
||||
mojo::Remote<mojom::ElectronBrowser> browser_remote;
|
||||
render_frame_->GetBrowserInterfaceBroker()->GetInterface(
|
||||
browser_remote.BindNewPipeAndPassReceiver());
|
||||
browser_remote->UpdateDraggableRegions(std::move(regions));
|
||||
mojo::AssociatedRemote<mojom::ElectronWebContentsUtility>
|
||||
web_contents_utility_remote;
|
||||
render_frame_->GetRemoteAssociatedInterfaces()->GetInterface(
|
||||
&web_contents_utility_remote);
|
||||
web_contents_utility_remote->UpdateDraggableRegions(std::move(regions));
|
||||
}
|
||||
|
||||
void ElectronRenderFrameObserver::WillReleaseScriptContext(
|
||||
@@ -169,10 +170,11 @@ void ElectronRenderFrameObserver::OnDestruct() {
|
||||
void ElectronRenderFrameObserver::DidMeaningfulLayout(
|
||||
blink::WebMeaningfulLayout layout_type) {
|
||||
if (layout_type == blink::WebMeaningfulLayout::kVisuallyNonEmpty) {
|
||||
mojo::Remote<mojom::ElectronBrowser> browser_remote;
|
||||
render_frame_->GetBrowserInterfaceBroker()->GetInterface(
|
||||
browser_remote.BindNewPipeAndPassReceiver());
|
||||
browser_remote->OnFirstNonEmptyLayout();
|
||||
mojo::AssociatedRemote<mojom::ElectronWebContentsUtility>
|
||||
web_contents_utility_remote;
|
||||
render_frame_->GetRemoteAssociatedInterfaces()->GetInterface(
|
||||
&web_contents_utility_remote);
|
||||
web_contents_utility_remote->OnFirstNonEmptyLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,8 +12,27 @@ import * as fs from 'fs';
|
||||
*
|
||||
* Because all encryption methods are gated by isEncryptionAvailable, the methods will never return the correct values
|
||||
* when run on CI and linux.
|
||||
* Refs: https://github.com/electron/electron/issues/30424.
|
||||
*/
|
||||
|
||||
describe('safeStorage module', () => {
|
||||
it('safeStorage before and after app is ready', async () => {
|
||||
const appPath = path.join(__dirname, 'fixtures', 'crash-cases', 'safe-storage');
|
||||
const appProcess = cp.spawn(process.execPath, [appPath]);
|
||||
|
||||
let output = '';
|
||||
appProcess.stdout.on('data', data => { output += data; });
|
||||
appProcess.stderr.on('data', data => { output += data; });
|
||||
|
||||
const code = (await emittedOnce(appProcess, 'exit'))[0] ?? 1;
|
||||
|
||||
if (code !== 0 && output) {
|
||||
console.log(output);
|
||||
}
|
||||
expect(code).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
ifdescribe(process.platform !== 'linux')('safeStorage module', () => {
|
||||
after(async () => {
|
||||
const pathToEncryptedString = path.resolve(__dirname, 'fixtures', 'api', 'safe-storage', 'encrypted.txt');
|
||||
|
||||
@@ -1722,11 +1722,39 @@ describe('navigator.serial', () => {
|
||||
});
|
||||
|
||||
it('returns a port when select-serial-port event is defined', async () => {
|
||||
let havePorts = false;
|
||||
w.webContents.session.on('select-serial-port', (event, portList, webContents, callback) => {
|
||||
callback(portList[0].portId);
|
||||
if (portList.length > 0) {
|
||||
havePorts = true;
|
||||
callback(portList[0].portId);
|
||||
} else {
|
||||
callback('');
|
||||
}
|
||||
});
|
||||
const port = await getPorts();
|
||||
expect(port).to.equal('[object SerialPort]');
|
||||
if (havePorts) {
|
||||
expect(port).to.equal('[object SerialPort]');
|
||||
} else {
|
||||
expect(port).to.equal('NotFoundError: No port selected by the user.');
|
||||
}
|
||||
});
|
||||
|
||||
it('navigator.serial.getPorts() returns values', async () => {
|
||||
let havePorts = false;
|
||||
|
||||
w.webContents.session.on('select-serial-port', (event, portList, webContents, callback) => {
|
||||
if (portList.length > 0) {
|
||||
havePorts = true;
|
||||
callback(portList[0].portId);
|
||||
} else {
|
||||
callback('');
|
||||
}
|
||||
});
|
||||
await getPorts();
|
||||
if (havePorts) {
|
||||
const grantedPorts = await w.webContents.executeJavaScript('navigator.serial.getPorts()');
|
||||
expect(grantedPorts).to.not.be.empty();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
39
spec-main/fixtures/crash-cases/safe-storage/index.js
Normal file
39
spec-main/fixtures/crash-cases/safe-storage/index.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const { app, safeStorage } = require('electron');
|
||||
const { expect } = require('chai');
|
||||
|
||||
(async () => {
|
||||
if (!app.isReady()) {
|
||||
// isEncryptionAvailable() returns false before the app is ready on
|
||||
// Linux: https://github.com/electron/electron/issues/32206
|
||||
// and
|
||||
// Windows: https://github.com/electron/electron/issues/33640.
|
||||
expect(safeStorage.isEncryptionAvailable()).to.equal(process.platform === 'darwin');
|
||||
if (safeStorage.isEncryptionAvailable()) {
|
||||
const plaintext = 'plaintext';
|
||||
const ciphertext = safeStorage.encryptString(plaintext);
|
||||
expect(Buffer.isBuffer(ciphertext)).to.equal(true);
|
||||
expect(safeStorage.decryptString(ciphertext)).to.equal(plaintext);
|
||||
} else {
|
||||
expect(() => safeStorage.encryptString('plaintext')).to.throw(/safeStorage cannot be used before app is ready/);
|
||||
expect(() => safeStorage.decryptString(Buffer.from(''))).to.throw(/safeStorage cannot be used before app is ready/);
|
||||
}
|
||||
}
|
||||
await app.whenReady();
|
||||
// isEncryptionAvailable() will always return false on CI due to a mocked
|
||||
// dbus as mentioned above.
|
||||
expect(safeStorage.isEncryptionAvailable()).to.equal(process.platform !== 'linux');
|
||||
if (safeStorage.isEncryptionAvailable()) {
|
||||
const plaintext = 'plaintext';
|
||||
const ciphertext = safeStorage.encryptString(plaintext);
|
||||
expect(Buffer.isBuffer(ciphertext)).to.equal(true);
|
||||
expect(safeStorage.decryptString(ciphertext)).to.equal(plaintext);
|
||||
} else {
|
||||
expect(() => safeStorage.encryptString('plaintext')).to.throw(/Encryption is not available/);
|
||||
expect(() => safeStorage.decryptString(Buffer.from(''))).to.throw(/Decryption is not available/);
|
||||
}
|
||||
})()
|
||||
.then(app.quit)
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
app.exit(1);
|
||||
});
|
||||
Reference in New Issue
Block a user