mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
Compare commits
39 Commits
v23.0.0-ni
...
v22.0.0-al
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b637d0312c | ||
|
|
fa39ee4bb7 | ||
|
|
b0a5ada661 | ||
|
|
abf7a48605 | ||
|
|
0525247b38 | ||
|
|
6ee24c97ac | ||
|
|
72075edca5 | ||
|
|
f486172114 | ||
|
|
b938b30128 | ||
|
|
0b9212859b | ||
|
|
abd8c8367f | ||
|
|
9ab5b08466 | ||
|
|
8e7c81052d | ||
|
|
b403ccc73c | ||
|
|
583b24f0b2 | ||
|
|
b8a6fcd6c7 | ||
|
|
ec7e24da56 | ||
|
|
f232a31891 | ||
|
|
cc7822f950 | ||
|
|
71cbdb01b2 | ||
|
|
323803263f | ||
|
|
5b6b7e85ff | ||
|
|
0c8be31d1a | ||
|
|
b74a04cce5 | ||
|
|
a4afb0ab86 | ||
|
|
ba0ebeecdb | ||
|
|
1bcca22149 | ||
|
|
c87b479a05 | ||
|
|
07d4fc3288 | ||
|
|
bf8dec7b63 | ||
|
|
059f8cd353 | ||
|
|
8ca56d0ff8 | ||
|
|
1432649617 | ||
|
|
fb330fba9e | ||
|
|
09475f87f0 | ||
|
|
a9d1ccd6a0 | ||
|
|
1995972467 | ||
|
|
60ae79e418 | ||
|
|
71bc0395c5 |
@@ -455,7 +455,7 @@ step-delete-git-directories: &step-delete-git-directories
|
||||
command: |
|
||||
if [ "`uname`" == "Darwin" ]; then
|
||||
cd src
|
||||
( find . -type d -name ".git" -not -path "./third_party/angle/*" -not -path "./third_party/dawn/*" -not -path "./electron/*" ) | xargs rm -rf
|
||||
( find . -type d -name ".git" -not -path "./third_party/angle/*" -not -path "./third_party/dawn/*" ) | xargs rm -rf
|
||||
fi
|
||||
|
||||
# On macOS the yarn install command during gclient sync was run on a linux
|
||||
@@ -814,7 +814,7 @@ step-maybe-zip-symbols: &step-maybe-zip-symbols
|
||||
cd src
|
||||
export BUILD_PATH="$PWD/out/Default"
|
||||
ninja -C out/Default electron:licenses
|
||||
ninja -C out/Default electron:electron_version_file
|
||||
ninja -C out/Default electron:electron_version
|
||||
DELETE_DSYMS_AFTER_ZIP=1 electron/script/zip-symbols.py -b $BUILD_PATH
|
||||
|
||||
step-maybe-cross-arch-snapshot: &step-maybe-cross-arch-snapshot
|
||||
@@ -874,12 +874,12 @@ step-touch-sync-done: &step-touch-sync-done
|
||||
step-maybe-restore-src-cache: &step-maybe-restore-src-cache
|
||||
restore_cache:
|
||||
keys:
|
||||
- v15-src-cache-{{ checksum "src/electron/.depshash" }}
|
||||
- v14-src-cache-{{ checksum "src/electron/.depshash" }}
|
||||
name: Restoring src cache
|
||||
step-maybe-restore-src-cache-marker: &step-maybe-restore-src-cache-marker
|
||||
restore_cache:
|
||||
keys:
|
||||
- v15-src-cache-marker-{{ checksum "src/electron/.depshash" }}
|
||||
- v14-src-cache-marker-{{ checksum "src/electron/.depshash" }}
|
||||
name: Restoring src cache marker
|
||||
|
||||
# Restore exact or closest git cache based on the hash of DEPS and .circle-sync-done
|
||||
@@ -951,17 +951,17 @@ step-minimize-workspace-size-from-checkout: &step-minimize-workspace-size-from-c
|
||||
rm -rf src/ios/chrome
|
||||
rm -rf src/third_party/blink/web_tests
|
||||
rm -rf src/third_party/blink/perf_tests
|
||||
rm -rf src/third_party/WebKit/LayoutTests
|
||||
rm -rf third_party/electron_node/deps/openssl
|
||||
rm -rf third_party/electron_node/deps/v8
|
||||
rm -rf chrome/test/data/xr/webvr_info
|
||||
rm -rf src/third_party/angle/third_party/VK-GL-CTS/src
|
||||
|
||||
# Save the src cache based on the deps hash
|
||||
step-save-src-cache: &step-save-src-cache
|
||||
save_cache:
|
||||
paths:
|
||||
- /var/portal
|
||||
key: v15-src-cache-{{ checksum "/var/portal/src/electron/.depshash" }}
|
||||
key: v14-src-cache-{{ checksum "/var/portal/src/electron/.depshash" }}
|
||||
name: Persisting src cache
|
||||
step-make-src-cache-marker: &step-make-src-cache-marker
|
||||
run:
|
||||
@@ -971,7 +971,7 @@ step-save-src-cache-marker: &step-save-src-cache-marker
|
||||
save_cache:
|
||||
paths:
|
||||
- .src-cache-marker
|
||||
key: v15-src-cache-marker-{{ checksum "/var/portal/src/electron/.depshash" }}
|
||||
key: v14-src-cache-marker-{{ checksum "/var/portal/src/electron/.depshash" }}
|
||||
|
||||
step-maybe-early-exit-no-doc-change: &step-maybe-early-exit-no-doc-change
|
||||
run:
|
||||
|
||||
14
.github/stale.yml
vendored
Normal file
14
.github/stale.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
daysUntilStale: 90
|
||||
daysUntilClose: 30
|
||||
exemptLabels:
|
||||
- discussion
|
||||
- security 🔒
|
||||
- "enhancement :sparkles:"
|
||||
staleLabel: stale
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
|
||||
closeComment: >
|
||||
This issue has been closed as it was considered stale, this issue will not be
|
||||
monitored. If this is a bug and you can reproduce this issue on a [supported
|
||||
version of Electron](https://www.electronjs.org/docs/latest/tutorial/electron-timelines#timeline) please open a new issue and ensure a repro is provided.
|
||||
|
||||
25
.github/workflows/stale.yml
vendored
25
.github/workflows/stale.yml
vendored
@@ -1,25 +0,0 @@
|
||||
name: 'Close stale issues'
|
||||
on:
|
||||
schedule:
|
||||
# 1:30am every day
|
||||
- cron: '30 1 * * *'
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/stale@3de2653986ebd134983c79fe2be5d45cc3d9f4e1
|
||||
with:
|
||||
days-before-stale: 90
|
||||
days-before-close: 30
|
||||
stale-issue-label: stale
|
||||
operations-per-run: 1750
|
||||
stale-issue-message: >
|
||||
This issue has been automatically marked as stale. **If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open. If you have any new additional information—in particular, if this is still reproducible in the [latest version of Electron](https://www.electronjs.org/releases/stable) or in the [beta](https://www.electronjs.org/releases/beta)—please include it with your comment!
|
||||
close-issue-message: >
|
||||
This issue has been closed due to inactivity, and will not be monitored. If this is a bug and you can reproduce this issue on a [supported version of Electron](https://www.electronjs.org/docs/latest/tutorial/electron-timelines#timeline) please open a new issue and include instructions for reproducing the issue.
|
||||
exempt-issue-labels: "discussion,security \U0001F512,enhancement :sparkles:"
|
||||
only-pr-labels: not-a-real-label
|
||||
73
BUILD.gn
73
BUILD.gn
@@ -107,13 +107,6 @@ branding = read_file("shell/app/BRANDING.json", "json")
|
||||
electron_project_name = branding.project_name
|
||||
electron_product_name = branding.product_name
|
||||
electron_mac_bundle_id = branding.mac_bundle_id
|
||||
electron_version = exec_script("script/print-version.py",
|
||||
[],
|
||||
"trim string",
|
||||
[
|
||||
".git/packed-refs",
|
||||
".git/HEAD",
|
||||
])
|
||||
|
||||
if (is_mas_build) {
|
||||
assert(is_mac,
|
||||
@@ -209,15 +202,6 @@ webpack_build("electron_isolated_renderer_bundle") {
|
||||
out_file = "$target_gen_dir/js2c/isolated_bundle.js"
|
||||
}
|
||||
|
||||
webpack_build("electron_utility_bundle") {
|
||||
deps = [ ":build_electron_definitions" ]
|
||||
|
||||
inputs = auto_filenames.utility_bundle_deps
|
||||
|
||||
config_file = "//electron/build/webpack/webpack.config.utility.js"
|
||||
out_file = "$target_gen_dir/js2c/utility_init.js"
|
||||
}
|
||||
|
||||
action("electron_js2c") {
|
||||
deps = [
|
||||
":electron_asar_bundle",
|
||||
@@ -225,7 +209,6 @@ action("electron_js2c") {
|
||||
":electron_isolated_renderer_bundle",
|
||||
":electron_renderer_bundle",
|
||||
":electron_sandboxed_renderer_bundle",
|
||||
":electron_utility_bundle",
|
||||
":electron_worker_bundle",
|
||||
]
|
||||
|
||||
@@ -235,7 +218,6 @@ action("electron_js2c") {
|
||||
"$target_gen_dir/js2c/isolated_bundle.js",
|
||||
"$target_gen_dir/js2c/renderer_init.js",
|
||||
"$target_gen_dir/js2c/sandbox_bundle.js",
|
||||
"$target_gen_dir/js2c/utility_init.js",
|
||||
"$target_gen_dir/js2c/worker_init.js",
|
||||
]
|
||||
|
||||
@@ -320,9 +302,12 @@ npm_action("electron_version_args") {
|
||||
|
||||
outputs = [ "$target_gen_dir/electron_version.args" ]
|
||||
|
||||
args = rebase_path(outputs) + [ "$electron_version" ]
|
||||
args = rebase_path(outputs)
|
||||
|
||||
inputs = [ "script/generate-version-json.js" ]
|
||||
inputs = [
|
||||
"ELECTRON_VERSION",
|
||||
"script/generate-version-json.js",
|
||||
]
|
||||
}
|
||||
|
||||
templated_file("electron_version_header") {
|
||||
@@ -334,39 +319,6 @@ templated_file("electron_version_header") {
|
||||
args_files = get_target_outputs(":electron_version_args")
|
||||
}
|
||||
|
||||
templated_file("electron_win_rc") {
|
||||
deps = [ ":electron_version_args" ]
|
||||
|
||||
template = "build/templates/electron_rc.tmpl"
|
||||
output = "$target_gen_dir/win-resources/electron.rc"
|
||||
|
||||
args_files = get_target_outputs(":electron_version_args")
|
||||
}
|
||||
|
||||
copy("electron_win_resource_files") {
|
||||
sources = [
|
||||
"shell/browser/resources/win/electron.ico",
|
||||
"shell/browser/resources/win/resource.h",
|
||||
]
|
||||
outputs = [ "$target_gen_dir/win-resources/{{source_file_part}}" ]
|
||||
}
|
||||
|
||||
templated_file("electron_version_file") {
|
||||
deps = [ ":electron_version_args" ]
|
||||
|
||||
template = "build/templates/version_string.tmpl"
|
||||
output = "$root_build_dir/version"
|
||||
|
||||
args_files = get_target_outputs(":electron_version_args")
|
||||
}
|
||||
|
||||
group("electron_win32_resources") {
|
||||
public_deps = [
|
||||
":electron_win_rc",
|
||||
":electron_win_resource_files",
|
||||
]
|
||||
}
|
||||
|
||||
action("electron_fuses") {
|
||||
script = "build/fuses/build.py"
|
||||
|
||||
@@ -416,7 +368,6 @@ source_set("electron_lib") {
|
||||
"chromium_src:chrome",
|
||||
"chromium_src:chrome_spellchecker",
|
||||
"shell/common/api:mojo",
|
||||
"shell/services/node/public/mojom",
|
||||
"//base:base_static",
|
||||
"//base/allocator:buildflags",
|
||||
"//chrome:strings",
|
||||
@@ -662,6 +613,8 @@ source_set("electron_lib") {
|
||||
if (enable_plugins) {
|
||||
deps += [ "chromium_src:plugins" ]
|
||||
sources += [
|
||||
"shell/common/plugin_info.cc",
|
||||
"shell/common/plugin_info.h",
|
||||
"shell/renderer/pepper_helper.cc",
|
||||
"shell/renderer/pepper_helper.h",
|
||||
]
|
||||
@@ -800,6 +753,7 @@ if (is_mac) {
|
||||
electron_helper_name = "$electron_product_name Helper"
|
||||
electron_login_helper_name = "$electron_product_name Login Helper"
|
||||
electron_framework_version = "A"
|
||||
electron_version = read_file("ELECTRON_VERSION", "trim string")
|
||||
|
||||
mac_xib_bundle_data("electron_xibs") {
|
||||
sources = [ "shell/common/resources/mac/MainMenu.xib" ]
|
||||
@@ -1240,7 +1194,6 @@ if (is_mac) {
|
||||
":default_app_asar",
|
||||
":electron_app_manifest",
|
||||
":electron_lib",
|
||||
":electron_win32_resources",
|
||||
":packed_resources",
|
||||
"//components/crash/core/app",
|
||||
"//content:sandbox_helper_win",
|
||||
@@ -1274,7 +1227,8 @@ if (is_mac) {
|
||||
|
||||
if (is_win) {
|
||||
sources += [
|
||||
"$target_gen_dir/win-resources/electron.rc",
|
||||
# TODO: we should be generating our .rc files more like how chrome does
|
||||
"shell/browser/resources/win/electron.rc",
|
||||
"shell/browser/resources/win/resource.h",
|
||||
]
|
||||
|
||||
@@ -1456,10 +1410,15 @@ group("licenses") {
|
||||
]
|
||||
}
|
||||
|
||||
copy("electron_version") {
|
||||
sources = [ "ELECTRON_VERSION" ]
|
||||
outputs = [ "$root_build_dir/version" ]
|
||||
}
|
||||
|
||||
dist_zip("electron_dist_zip") {
|
||||
data_deps = [
|
||||
":electron_app",
|
||||
":electron_version_file",
|
||||
":electron_version",
|
||||
":licenses",
|
||||
]
|
||||
if (is_linux) {
|
||||
|
||||
2
DEPS
2
DEPS
@@ -2,7 +2,7 @@ gclient_gn_args_from = 'src'
|
||||
|
||||
vars = {
|
||||
'chromium_version':
|
||||
'108.0.5355.0',
|
||||
'108.0.5359.10',
|
||||
'node_version':
|
||||
'v16.17.1',
|
||||
'nan_version':
|
||||
|
||||
1
ELECTRON_VERSION
Normal file
1
ELECTRON_VERSION
Normal file
@@ -0,0 +1 @@
|
||||
22.0.0-alpha.8
|
||||
16
appveyor.yml
16
appveyor.yml
@@ -149,7 +149,7 @@ for:
|
||||
if ($env:SAVE_GCLIENT_SRC -eq 'true') {
|
||||
# archive current source for future use
|
||||
# only run on x64/woa to avoid contention saving
|
||||
$(7z a $zipfile src -xr!android_webview -xr!electron -xr'!*\.git' -xr!third_party\blink\web_tests -xr!third_party\blink\perf_tests -slp -t7z -mmt=30)
|
||||
$(7z a $zipfile src -xr!android_webview -xr!electron -xr'!*\.git' -xr!third_party\WebKit\LayoutTests! -xr!third_party\blink\web_tests -xr!third_party\blink\perf_tests -slp -t7z -mmt=30)
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-warning "Could not save source to shared drive; continuing anyway"
|
||||
}
|
||||
@@ -199,14 +199,14 @@ for:
|
||||
}
|
||||
- ps: >-
|
||||
if ($env:GN_CONFIG -eq 'release') {
|
||||
python3 electron\script\zip-symbols.py
|
||||
python electron\script\zip-symbols.py
|
||||
appveyor-retry appveyor PushArtifact out/Default/symbols.zip
|
||||
} else {
|
||||
# It's useful to have pdb files when debugging testing builds that are
|
||||
# built on CI.
|
||||
7z a pdb.zip out\Default\*.pdb
|
||||
}
|
||||
- python3 electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest
|
||||
- python electron/script/zip_manifests/check-zip-manifest.py out/Default/dist.zip electron/script/zip_manifests/dist_zip.win.%TARGET_ARCH%.manifest
|
||||
|
||||
deploy_script:
|
||||
- cd electron
|
||||
@@ -214,10 +214,10 @@ for:
|
||||
if (Test-Path Env:\ELECTRON_RELEASE) {
|
||||
if (Test-Path Env:\UPLOAD_TO_STORAGE) {
|
||||
Write-Output "Uploading Electron release distribution to azure"
|
||||
& python3 script\release\uploaders\upload.py --verbose --upload_to_storage
|
||||
& python script\release\uploaders\upload.py --verbose --upload_to_storage
|
||||
} else {
|
||||
Write-Output "Uploading Electron release distribution to github releases"
|
||||
& python3 script\release\uploaders\upload.py --verbose
|
||||
& python script\release\uploaders\upload.py --verbose
|
||||
}
|
||||
} elseif (Test-Path Env:\TEST_WOA) {
|
||||
node script/release/ci-release-build.js --job=electron-woa-testing --ci=GHA --appveyorJobId=$env:APPVEYOR_JOB_ID $env:APPVEYOR_REPO_BRANCH
|
||||
@@ -303,11 +303,11 @@ for:
|
||||
- echo Running main test suite & node script/yarn test -- --trace-uncaught --runners=main --enable-logging=file --log-file=%cd%\electron.log
|
||||
- echo Running native test suite & node script/yarn test -- --trace-uncaught --runners=native --enable-logging=file --log-file=%cd%\electron.log
|
||||
- cd ..
|
||||
- echo Verifying non proprietary ffmpeg & python3 electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg
|
||||
- echo Verifying non proprietary ffmpeg & python electron\script\verify-ffmpeg.py --build-dir out\Default --source-root %cd% --ffmpeg-path out\ffmpeg
|
||||
- echo "About to verify mksnapshot"
|
||||
- echo Verifying mksnapshot & python3 electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd%
|
||||
- echo Verifying mksnapshot & python electron\script\verify-mksnapshot.py --build-dir out\Default --source-root %cd%
|
||||
- echo "Done verifying mksnapshot"
|
||||
- echo Verifying chromedriver & python3 electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd%
|
||||
- echo Verifying chromedriver & python electron\script\verify-chromedriver.py --build-dir out\Default --source-root %cd%
|
||||
- echo "Done verifying chromedriver"
|
||||
|
||||
on_finish:
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
$full_version
|
||||
@@ -1,4 +0,0 @@
|
||||
module.exports = require('./webpack.config.base')({
|
||||
target: 'utility',
|
||||
alwaysHasNode: true
|
||||
});
|
||||
@@ -232,8 +232,6 @@ static_library("chrome") {
|
||||
"//chrome/browser/printing/printing_service.h",
|
||||
"//components/printing/browser/print_to_pdf/pdf_print_job.cc",
|
||||
"//components/printing/browser/print_to_pdf/pdf_print_job.h",
|
||||
"//components/printing/browser/print_to_pdf/pdf_print_result.cc",
|
||||
"//components/printing/browser/print_to_pdf/pdf_print_result.h",
|
||||
"//components/printing/browser/print_to_pdf/pdf_print_utils.cc",
|
||||
"//components/printing/browser/print_to_pdf/pdf_print_utils.h",
|
||||
]
|
||||
|
||||
@@ -1437,16 +1437,13 @@ Returns `boolean` - Whether the window's document has been edited.
|
||||
|
||||
#### `win.blurWebView()`
|
||||
|
||||
#### `win.capturePage([rect, opts])`
|
||||
#### `win.capturePage([rect])`
|
||||
|
||||
* `rect` [Rectangle](structures/rectangle.md) (optional) - The bounds to capture
|
||||
* `opts` Object (optional)
|
||||
* `stayHidden` boolean (optional) - Keep the page hidden instead of visible. Default is `false`.
|
||||
* `stayAwake` boolean (optional) - Keep the system awake instead of allowing it to sleep. Default is `false`.
|
||||
|
||||
Returns `Promise<NativeImage>` - Resolves with a [NativeImage](native-image.md)
|
||||
|
||||
Captures a snapshot of the page within `rect`. Omitting `rect` will capture the whole visible page. If the page is not visible, `rect` may be empty. The page is considered visible when its browser window is hidden and the capturer count is non-zero. If you would like the page to stay hidden, you should ensure that `stayHidden` is set to true.
|
||||
Captures a snapshot of the page within `rect`. Omitting `rect` will capture the whole visible page. If the page is not visible, `rect` may be empty.
|
||||
|
||||
#### `win.loadURL(url[, options])`
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ See [`Menu`](menu.md) for examples.
|
||||
* `menuItem` MenuItem
|
||||
* `browserWindow` [BrowserWindow](browser-window.md) | undefined - This will not be defined if no window is open.
|
||||
* `event` [KeyboardEvent](structures/keyboard-event.md)
|
||||
* `role` string (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, `showSubstitutions`, `toggleSmartQuotes`, `toggleSmartDashes`, `toggleTextReplacement`, `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the
|
||||
* `role` string (optional) - Can be `undo`, `redo`, `cut`, `copy`, `paste`, `pasteAndMatchStyle`, `delete`, `selectAll`, `reload`, `forceReload`, `toggleDevTools`, `resetZoom`, `zoomIn`, `zoomOut`, `toggleSpellChecker`, `togglefullscreen`, `window`, `minimize`, `close`, `help`, `about`, `services`, `hide`, `hideOthers`, `unhide`, `quit`, 'showSubstitutions', 'toggleSmartQuotes', 'toggleSmartDashes', 'toggleTextReplacement', `startSpeaking`, `stopSpeaking`, `zoom`, `front`, `appMenu`, `fileMenu`, `editMenu`, `viewMenu`, `shareMenu`, `recentDocuments`, `toggleTabBar`, `selectNextTab`, `selectPreviousTab`, `mergeAllWindows`, `clearRecentDocuments`, `moveTabToNewWindow` or `windowMenu` - Define the action of the menu item, when specified the
|
||||
`click` property will be ignored. See [roles](#roles).
|
||||
* `type` string (optional) - Can be `normal`, `separator`, `submenu`, `checkbox` or
|
||||
`radio`.
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
# parentPort
|
||||
|
||||
> Interface for communication with parent process.
|
||||
|
||||
Process: [Utility](../glossary.md#utility-process)
|
||||
|
||||
`parentPort` is an [EventEmitter][event-emitter].
|
||||
_This object is not exported from the `'electron'` module. It is only available as a property of the process object in the Electron API._
|
||||
|
||||
```js
|
||||
// Main process
|
||||
const child = utilityProcess.fork(path.join(__dirname, 'test.js'))
|
||||
child.postMessage({ message: 'hello' })
|
||||
child.on('message', (data) => {
|
||||
console.log(data) // hello world!
|
||||
})
|
||||
|
||||
// Child process
|
||||
process.parentPort.on('message', (e) => {
|
||||
process.parentPort.postMessage(`${e.data} world!`)
|
||||
})
|
||||
```
|
||||
|
||||
## Events
|
||||
|
||||
The `parentPort` object emits the following events:
|
||||
|
||||
### Event: 'message'
|
||||
|
||||
Returns:
|
||||
|
||||
* `messageEvent` Object
|
||||
* `data` any
|
||||
* `ports` MessagePortMain[]
|
||||
|
||||
Emitted when the process receives a message. Messages received on
|
||||
this port will be queued up until a handler is registered for this
|
||||
event.
|
||||
|
||||
## Methods
|
||||
|
||||
### `parentPort.postMessage(message)`
|
||||
|
||||
* `message` any
|
||||
|
||||
Sends a message from the process to its parent.
|
||||
@@ -113,7 +113,6 @@ A `string` representing the current process's type, can be:
|
||||
* `browser` - The main process
|
||||
* `renderer` - A renderer process
|
||||
* `worker` - In a web worker
|
||||
* `utility` - In a node process launched as a service
|
||||
|
||||
### `process.versions.chrome` _Readonly_
|
||||
|
||||
@@ -135,11 +134,6 @@ Each frame has its own JavaScript context. When contextIsolation is enabled, the
|
||||
world also has a separate JavaScript context.
|
||||
This property is only available in the renderer process.
|
||||
|
||||
### `process.parentPort`
|
||||
|
||||
A [`Electron.ParentPort`](parent-port.md) property if this is a [`UtilityProcess`](utility-process.md)
|
||||
(or `null` otherwise) allowing communication with the parent process.
|
||||
|
||||
## Methods
|
||||
|
||||
The `process` object has the following methods:
|
||||
|
||||
@@ -1,136 +0,0 @@
|
||||
# utilityProcess
|
||||
|
||||
`utilityProcess` creates a child process with
|
||||
Node.js and Message ports enabled. It provides the equivalent of [`child_process.fork`][] API from Node.js
|
||||
but instead uses [Services API][] from Chromium to launch the child process.
|
||||
|
||||
Process: [Main](../glossary.md#main-process)<br />
|
||||
|
||||
## Methods
|
||||
|
||||
### `utilityProcess.fork(modulePath[, args][, options])`
|
||||
|
||||
* `modulePath` string - Path to the script that should run as entrypoint in the child process.
|
||||
* `args` string[] (optional) - List of string arguments that will be available as `process.argv`
|
||||
in the child process.
|
||||
* `options` Object (optional)
|
||||
* `env` Object (optional) - Environment key-value pairs. Default is `process.env`.
|
||||
* `execArgv` string[] (optional) - List of string arguments passed to the executable.
|
||||
* `cwd` string (optional) - Current working directory of the child process.
|
||||
* `stdio` (string[] | string) (optional) - Allows configuring the mode for `stdout` and `stderr`
|
||||
of the child process. Default is `inherit`.
|
||||
String value can be one of `pipe`, `ignore`, `inherit`, for more details on these values you can refer to
|
||||
[stdio][] documentation from Node.js. Currently this option only supports configuring `stdout` and
|
||||
`stderr` to either `pipe`, `inherit` or `ignore`. Configuring `stdin` is not supported; `stdin` will
|
||||
always be ignored.
|
||||
For example, the supported values will be processed as following:
|
||||
* `pipe`: equivalent to ['ignore', 'pipe', 'pipe'] (the default)
|
||||
* `ignore`: equivalent to 'ignore', 'ignore', 'ignore']
|
||||
* `inherit`: equivalent to ['ignore', 'inherit', 'inherit']
|
||||
* `serviceName` string (optional) - Name of the process that will appear in `name` property of
|
||||
[`child-process-gone` event of `app`](app.md#event-child-process-gone).
|
||||
Default is `node.mojom.NodeService`.
|
||||
* `allowLoadingUnsignedLibraries` boolean (optional) _macOS_ - With this flag, the utility process will be
|
||||
launched via the `Electron Helper (Plugin).app` helper executable on macOS, which can be
|
||||
codesigned with `com.apple.security.cs.disable-library-validation` and
|
||||
`com.apple.security.cs.allow-unsigned-executable-memory` entitlements. This will allow the utility process
|
||||
to load unsigned libraries. Unless you specifically need this capability, it is best to leave this disabled.
|
||||
Default is `false`.
|
||||
|
||||
Returns [`UtilityProcess`](utility-process.md#class-utilityprocess)
|
||||
|
||||
## Class: UtilityProcess
|
||||
|
||||
> Instances of the `UtilityProcess` represent the Chromium spawned child process
|
||||
> with Node.js integration.
|
||||
|
||||
`UtilityProcess` is an [EventEmitter][event-emitter].
|
||||
|
||||
### Instance Methods
|
||||
|
||||
#### `child.postMessage(message, [transfer])`
|
||||
|
||||
* `message` any
|
||||
* `transfer` MessagePortMain[] (optional)
|
||||
|
||||
Send a message to the child process, optionally transferring ownership of
|
||||
zero or more [`MessagePortMain`][] objects.
|
||||
|
||||
For example:
|
||||
|
||||
```js
|
||||
// Main process
|
||||
const { port1, port2 } = new MessageChannelMain()
|
||||
const child = utilityProcess.fork(path.join(__dirname, 'test.js'))
|
||||
child.postMessage({ message: 'hello' }, [port1])
|
||||
|
||||
// Child process
|
||||
process.parentPort.once('message', (e) => {
|
||||
const [port] = e.ports
|
||||
// ...
|
||||
})
|
||||
```
|
||||
|
||||
#### `child.kill()`
|
||||
|
||||
Returns `boolean`
|
||||
|
||||
Terminates the process gracefully. On POSIX, it uses SIGTERM
|
||||
but will ensure the process is reaped on exit. This function returns
|
||||
true if the kill is successful, and false otherwise.
|
||||
|
||||
### Instance Properties
|
||||
|
||||
#### `child.pid`
|
||||
|
||||
A `Integer | undefined` representing the process identifier (PID) of the child process.
|
||||
If the child process fails to spawn due to errors, then the value is `undefined`. When
|
||||
the child process exits, then the value is `undefined` after the `exit` event is emitted.
|
||||
|
||||
#### `child.stdout`
|
||||
|
||||
A `NodeJS.ReadableStream | null` that represents the child process's stdout.
|
||||
If the child was spawned with options.stdio[1] set to anything other than 'pipe', then this will be `null`.
|
||||
When the child process exits, then the value is `null` after the `exit` event is emitted.
|
||||
|
||||
```js
|
||||
// Main process
|
||||
const { port1, port2 } = new MessageChannelMain()
|
||||
const child = utilityProcess.fork(path.join(__dirname, 'test.js'))
|
||||
child.stdout.on('data', (data) => {
|
||||
console.log(`Received chunk ${data}`)
|
||||
})
|
||||
```
|
||||
|
||||
#### `child.stderr`
|
||||
|
||||
A `NodeJS.ReadableStream | null` that represents the child process's stderr.
|
||||
If the child was spawned with options.stdio[2] set to anything other than 'pipe', then this will be `null`.
|
||||
When the child process exits, then the value is `null` after the `exit` event is emitted.
|
||||
|
||||
### Instance Events
|
||||
|
||||
#### Event: 'spawn'
|
||||
|
||||
Emitted once the child process has spawned successfully.
|
||||
|
||||
#### Event: 'exit'
|
||||
|
||||
Returns:
|
||||
|
||||
* `code` number - Contains the exit code for
|
||||
the process obtained from waitpid on posix, or GetExitCodeProcess on windows.
|
||||
|
||||
Emitted after the child process ends.
|
||||
|
||||
#### Event: 'message'
|
||||
|
||||
Returns:
|
||||
|
||||
* `message` any
|
||||
|
||||
Emitted when the child process sends a message using [`process.parentPort.postMessage()`](process.md#processparentport).
|
||||
|
||||
[`child_process.fork`]: https://nodejs.org/dist/latest-v16.x/docs/api/child_process.html#child_processforkmodulepath-args-options
|
||||
[Services API]: https://chromium.googlesource.com/chromium/src/+/master/docs/mojo_and_services.md
|
||||
[stdio]: https://nodejs.org/dist/latest/docs/api/child_process.html#optionsstdio
|
||||
@@ -1338,25 +1338,20 @@ const requestId = webContents.findInPage('api')
|
||||
console.log(requestId)
|
||||
```
|
||||
|
||||
#### `contents.capturePage([rect, opts])`
|
||||
#### `contents.capturePage([rect])`
|
||||
|
||||
* `rect` [Rectangle](structures/rectangle.md) (optional) - The area of the page to be captured.
|
||||
* `opts` Object (optional)
|
||||
* `stayHidden` boolean (optional) - Keep the page hidden instead of visible. Default is `false`.
|
||||
* `stayAwake` boolean (optional) - Keep the system awake instead of allowing it to sleep. Default is `false`.
|
||||
|
||||
Returns `Promise<NativeImage>` - Resolves with a [NativeImage](native-image.md)
|
||||
|
||||
Captures a snapshot of the page within `rect`. Omitting `rect` will capture the whole visible page.
|
||||
The page is considered visible when its browser window is hidden and the capturer count is non-zero.
|
||||
If you would like the page to stay hidden, you should ensure that `stayHidden` is set to true.
|
||||
|
||||
#### `contents.isBeingCaptured()`
|
||||
|
||||
Returns `boolean` - Whether this page is being captured. It returns true when the capturer count
|
||||
is large then 0.
|
||||
|
||||
#### `contents.incrementCapturerCount([size, stayHidden, stayAwake])` _Deprecated_
|
||||
#### `contents.incrementCapturerCount([size, stayHidden, stayAwake])`
|
||||
|
||||
* `size` [Size](structures/size.md) (optional) - The preferred size for the capturer.
|
||||
* `stayHidden` boolean (optional) - Keep the page hidden instead of visible.
|
||||
@@ -1367,9 +1362,7 @@ hidden and the capturer count is non-zero. If you would like the page to stay hi
|
||||
|
||||
This also affects the Page Visibility API.
|
||||
|
||||
**Deprecated:** This API's functionality is now handled automatically within `contents.capturePage()`. See [breaking changes](../breaking-changes.md).
|
||||
|
||||
#### `contents.decrementCapturerCount([stayHidden, stayAwake])` _Deprecated_
|
||||
#### `contents.decrementCapturerCount([stayHidden, stayAwake])`
|
||||
|
||||
* `stayHidden` boolean (optional) - Keep the page in hidden state instead of visible.
|
||||
* `stayAwake` boolean (optional) - Keep the system awake instead of allowing it to sleep.
|
||||
@@ -1378,9 +1371,6 @@ Decrease the capturer count by one. The page will be set to hidden or occluded s
|
||||
browser window is hidden or occluded and the capturer count reaches zero. If you want to
|
||||
decrease the hidden capturer count instead you should set `stayHidden` to true.
|
||||
|
||||
**Deprecated:** This API's functionality is now handled automatically within `contents.capturePage()`.
|
||||
See [breaking changes](../breaking-changes.md).
|
||||
|
||||
#### `contents.getPrinters()` _Deprecated_
|
||||
|
||||
Get the system printer list.
|
||||
|
||||
@@ -38,98 +38,14 @@ win.webContents.on('input-event', (_, event) => {
|
||||
})
|
||||
```
|
||||
|
||||
### Removed: `webContents.incrementCapturerCount(stayHidden, stayAwake)`
|
||||
|
||||
The `webContents.incrementCapturerCount(stayHidden, stayAwake)` function has been removed.
|
||||
It is now automatically handled by `webContents.capturePage` when a page capture completes.
|
||||
|
||||
```js
|
||||
const w = new BrowserWindow({ show: false })
|
||||
|
||||
// Removed in Electron 23
|
||||
w.webContents.incrementCapturerCount()
|
||||
w.capturePage().then(image => {
|
||||
console.log(image.toDataURL())
|
||||
w.webContents.decrementCapturerCount()
|
||||
})
|
||||
|
||||
// Replace with
|
||||
w.capturePage().then(image => {
|
||||
console.log(image.toDataURL())
|
||||
})
|
||||
```
|
||||
|
||||
### Removed: `webContents.decrementCapturerCount(stayHidden, stayAwake)`
|
||||
|
||||
The `webContents.decrementCapturerCount(stayHidden, stayAwake)` function has been removed.
|
||||
It is now automatically handled by `webContents.capturePage` when a page capture completes.
|
||||
|
||||
```js
|
||||
const w = new BrowserWindow({ show: false })
|
||||
|
||||
// Removed in Electron 23
|
||||
w.webContents.incrementCapturerCount()
|
||||
w.capturePage().then(image => {
|
||||
console.log(image.toDataURL())
|
||||
w.webContents.decrementCapturerCount()
|
||||
})
|
||||
|
||||
// Replace with
|
||||
w.capturePage().then(image => {
|
||||
console.log(image.toDataURL())
|
||||
})
|
||||
```
|
||||
|
||||
## Planned Breaking API Changes (22.0)
|
||||
|
||||
### Deprecated: `webContents.incrementCapturerCount(stayHidden, stayAwake)`
|
||||
|
||||
`webContents.incrementCapturerCount(stayHidden, stayAwake)` has been deprecated.
|
||||
It is now automatically handled by `webContents.capturePage` when a page capture completes.
|
||||
|
||||
```js
|
||||
const w = new BrowserWindow({ show: false })
|
||||
|
||||
// Removed in Electron 23
|
||||
w.webContents.incrementCapturerCount()
|
||||
w.capturePage().then(image => {
|
||||
console.log(image.toDataURL())
|
||||
w.webContents.decrementCapturerCount()
|
||||
})
|
||||
|
||||
// Replace with
|
||||
w.capturePage().then(image => {
|
||||
console.log(image.toDataURL())
|
||||
})
|
||||
```
|
||||
|
||||
### Deprecated: `webContents.decrementCapturerCount(stayHidden, stayAwake)`
|
||||
|
||||
`webContents.decrementCapturerCount(stayHidden, stayAwake)` has been deprecated.
|
||||
It is now automatically handled by `webContents.capturePage` when a page capture completes.
|
||||
|
||||
```js
|
||||
const w = new BrowserWindow({ show: false })
|
||||
|
||||
// Removed in Electron 23
|
||||
w.webContents.incrementCapturerCount()
|
||||
w.capturePage().then(image => {
|
||||
console.log(image.toDataURL())
|
||||
w.webContents.decrementCapturerCount()
|
||||
})
|
||||
|
||||
// Replace with
|
||||
w.capturePage().then(image => {
|
||||
console.log(image.toDataURL())
|
||||
})
|
||||
```
|
||||
|
||||
### Removed: WebContents `new-window` event
|
||||
|
||||
The `new-window` event of WebContents has been removed. It is replaced by [`webContents.setWindowOpenHandler()`](api/web-contents.md#contentssetwindowopenhandlerhandler).
|
||||
|
||||
```js
|
||||
// Removed in Electron 22
|
||||
// Removed in Electron 21
|
||||
webContents.on('new-window', (event) => {
|
||||
event.preventDefault()
|
||||
})
|
||||
|
||||
@@ -146,7 +146,7 @@ $ ninja -C out/Release electron
|
||||
```
|
||||
|
||||
This will build all of what was previously 'libchromiumcontent' (i.e. the
|
||||
`content/` directory of `chromium` and its dependencies, incl. Blink and V8),
|
||||
`content/` directory of `chromium` and its dependencies, incl. WebKit and V8),
|
||||
so it will take a while.
|
||||
|
||||
The built executable will be under `./out/Testing`:
|
||||
|
||||
@@ -116,6 +116,10 @@ $ git config --system core.longpaths true
|
||||
|
||||
This can happen during build, when Debugging Tools for Windows has been installed with Windows Driver Kit. Uninstall Windows Driver Kit and install Debugging Tools with steps described above.
|
||||
|
||||
### ImportError: No module named win32file
|
||||
|
||||
Make sure you have installed `pywin32` with `pip install pywin32`.
|
||||
|
||||
### Build Scripts Hang Until Keypress
|
||||
|
||||
This bug is a "feature" of Windows' command prompt. It happens when clicking inside the prompt window with
|
||||
|
||||
@@ -194,15 +194,6 @@ overly prescriptive about how it should be used. Userland enables users to
|
||||
create and share tools that provide additional functionality on top of what is
|
||||
available in "core".
|
||||
|
||||
### utility process
|
||||
|
||||
The utility process is a child of the main process that allows running any
|
||||
untrusted services that cannot be run in the main process. Chromium uses this
|
||||
process to perform network I/O, audio/video processing, device inputs etc.
|
||||
In Electron, you can create this process using [UtilityProcess][] API.
|
||||
|
||||
See also: [process](#process), [main process](#main-process)
|
||||
|
||||
### V8
|
||||
|
||||
V8 is Google's open source JavaScript engine. It is written in C++ and is
|
||||
@@ -240,5 +231,4 @@ embedded content.
|
||||
[renderer]: #renderer-process
|
||||
[userland]: #userland
|
||||
[using native node modules]: tutorial/using-native-node-modules.md
|
||||
[UtilityProcess]: api/utility-process.md
|
||||
[v8]: #v8
|
||||
|
||||
@@ -180,16 +180,19 @@ app.whenReady().then(async () => {
|
||||
|
||||
// We can't use ipcMain.handle() here, because the reply needs to transfer a
|
||||
// MessagePort.
|
||||
// Listen for message sent from the top-level frame
|
||||
mainWindow.webContents.mainFrame.on('request-worker-channel', (event) => {
|
||||
// Create a new channel ...
|
||||
const { port1, port2 } = new MessageChannelMain()
|
||||
// ... send one end to the worker ...
|
||||
worker.webContents.postMessage('new-client', null, [port1])
|
||||
// ... and the other end to the main window.
|
||||
event.senderFrame.postMessage('provide-worker-channel', null, [port2])
|
||||
// Now the main window and the worker can communicate with each other
|
||||
// without going through the main process!
|
||||
ipcMain.on('request-worker-channel', (event) => {
|
||||
// For security reasons, let's make sure only the frames we expect can
|
||||
// access the worker.
|
||||
if (event.senderFrame === mainWindow.webContents.mainFrame) {
|
||||
// Create a new channel ...
|
||||
const { port1, port2 } = new MessageChannelMain()
|
||||
// ... send one end to the worker ...
|
||||
worker.webContents.postMessage('new-client', null, [port1])
|
||||
// ... and the other end to the main window.
|
||||
event.senderFrame.postMessage('provide-worker-channel', null, [port2])
|
||||
// Now the main window and the worker can communicate with each other
|
||||
// without going through the main process!
|
||||
}
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
@@ -36,7 +36,6 @@ auto_filenames = {
|
||||
"docs/api/net-log.md",
|
||||
"docs/api/net.md",
|
||||
"docs/api/notification.md",
|
||||
"docs/api/parent-port.md",
|
||||
"docs/api/power-monitor.md",
|
||||
"docs/api/power-save-blocker.md",
|
||||
"docs/api/process.md",
|
||||
@@ -63,7 +62,6 @@ auto_filenames = {
|
||||
"docs/api/touch-bar-spacer.md",
|
||||
"docs/api/touch-bar.md",
|
||||
"docs/api/tray.md",
|
||||
"docs/api/utility-process.md",
|
||||
"docs/api/web-contents.md",
|
||||
"docs/api/web-frame-main.md",
|
||||
"docs/api/web-frame.md",
|
||||
@@ -222,7 +220,6 @@ auto_filenames = {
|
||||
"lib/browser/api/system-preferences.ts",
|
||||
"lib/browser/api/touch-bar.ts",
|
||||
"lib/browser/api/tray.ts",
|
||||
"lib/browser/api/utility-process.ts",
|
||||
"lib/browser/api/view.ts",
|
||||
"lib/browser/api/views/image-view.ts",
|
||||
"lib/browser/api/web-contents-view.ts",
|
||||
@@ -334,20 +331,4 @@ auto_filenames = {
|
||||
"typings/internal-ambient.d.ts",
|
||||
"typings/internal-electron.d.ts",
|
||||
]
|
||||
|
||||
utility_bundle_deps = [
|
||||
"lib/browser/message-port-main.ts",
|
||||
"lib/common/define-properties.ts",
|
||||
"lib/common/init.ts",
|
||||
"lib/common/reset-search-paths.ts",
|
||||
"lib/utility/api/exports/electron.ts",
|
||||
"lib/utility/api/module-list.ts",
|
||||
"lib/utility/init.ts",
|
||||
"lib/utility/parent-port.ts",
|
||||
"package.json",
|
||||
"tsconfig.electron.json",
|
||||
"tsconfig.json",
|
||||
"typings/internal-ambient.d.ts",
|
||||
"typings/internal-electron.d.ts",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ filenames = {
|
||||
"shell/app/electron_main_delegate_mac.h",
|
||||
"shell/app/electron_main_delegate_mac.mm",
|
||||
"shell/browser/api/electron_api_app_mac.mm",
|
||||
"shell/browser/api/electron_api_browser_window_mac.mm",
|
||||
"shell/browser/api/electron_api_menu_mac.h",
|
||||
"shell/browser/api/electron_api_menu_mac.mm",
|
||||
"shell/browser/api/electron_api_native_theme_mac.mm",
|
||||
@@ -210,6 +211,7 @@ filenames = {
|
||||
]
|
||||
|
||||
lib_sources_views = [
|
||||
"shell/browser/api/electron_api_browser_window_views.cc",
|
||||
"shell/browser/api/electron_api_menu_views.cc",
|
||||
"shell/browser/api/electron_api_menu_views.h",
|
||||
"shell/browser/native_browser_view_views.cc",
|
||||
@@ -311,8 +313,6 @@ filenames = {
|
||||
"shell/browser/api/electron_api_tray.h",
|
||||
"shell/browser/api/electron_api_url_loader.cc",
|
||||
"shell/browser/api/electron_api_url_loader.h",
|
||||
"shell/browser/api/electron_api_utility_process.cc",
|
||||
"shell/browser/api/electron_api_utility_process.h",
|
||||
"shell/browser/api/electron_api_view.cc",
|
||||
"shell/browser/api/electron_api_view.h",
|
||||
"shell/browser/api/electron_api_web_contents.cc",
|
||||
@@ -496,7 +496,6 @@ filenames = {
|
||||
"shell/browser/ui/inspectable_web_contents.cc",
|
||||
"shell/browser/ui/inspectable_web_contents.h",
|
||||
"shell/browser/ui/inspectable_web_contents_delegate.h",
|
||||
"shell/browser/ui/inspectable_web_contents_view.cc",
|
||||
"shell/browser/ui/inspectable_web_contents_view.h",
|
||||
"shell/browser/ui/inspectable_web_contents_view_delegate.cc",
|
||||
"shell/browser/ui/inspectable_web_contents_view_delegate.h",
|
||||
@@ -681,10 +680,6 @@ filenames = {
|
||||
"shell/renderer/renderer_client_base.h",
|
||||
"shell/renderer/web_worker_observer.cc",
|
||||
"shell/renderer/web_worker_observer.h",
|
||||
"shell/services/node/node_service.cc",
|
||||
"shell/services/node/node_service.h",
|
||||
"shell/services/node/parent_port.cc",
|
||||
"shell/services/node/parent_port.h",
|
||||
"shell/utility/electron_content_utility_client.cc",
|
||||
"shell/utility/electron_content_utility_client.h",
|
||||
]
|
||||
|
||||
@@ -31,7 +31,6 @@ export const browserModuleList: ElectronInternal.ModuleEntry[] = [
|
||||
{ name: 'systemPreferences', loader: () => require('./system-preferences') },
|
||||
{ name: 'TouchBar', loader: () => require('./touch-bar') },
|
||||
{ name: 'Tray', loader: () => require('./tray') },
|
||||
{ name: 'utilityProcess', loader: () => require('./utility-process') },
|
||||
{ name: 'View', loader: () => require('./view') },
|
||||
{ name: 'webContents', loader: () => require('./web-contents') },
|
||||
{ name: 'WebContentsView', loader: () => require('./web-contents-view') },
|
||||
|
||||
@@ -1,150 +0,0 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { Duplex, PassThrough } from 'stream';
|
||||
import { Socket } from 'net';
|
||||
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
|
||||
const { _fork } = process._linkedBinding('electron_browser_utility_process');
|
||||
|
||||
class ForkUtilityProcess extends EventEmitter {
|
||||
#handle: ElectronInternal.UtilityProcessWrapper | null;
|
||||
#stdout: Duplex | null = null;
|
||||
#stderr: Duplex | null = null;
|
||||
constructor (modulePath: string, args?: string[], options?: Electron.ForkOptions) {
|
||||
super();
|
||||
|
||||
if (!modulePath) {
|
||||
throw new Error('Missing UtilityProcess entry script.');
|
||||
}
|
||||
|
||||
if (args == null) {
|
||||
args = [];
|
||||
} else if (typeof args === 'object' && !Array.isArray(args)) {
|
||||
options = args;
|
||||
args = [];
|
||||
}
|
||||
|
||||
if (options == null) {
|
||||
options = {};
|
||||
} else {
|
||||
options = { ...options };
|
||||
}
|
||||
|
||||
if (!options) {
|
||||
throw new Error('Options cannot be undefined.');
|
||||
}
|
||||
|
||||
if (options.execArgv != null) {
|
||||
if (!Array.isArray(options.execArgv)) {
|
||||
throw new Error('execArgv must be an array of strings.');
|
||||
}
|
||||
}
|
||||
|
||||
if (options.serviceName != null) {
|
||||
if (typeof options.serviceName !== 'string') {
|
||||
throw new Error('serviceName must be a string.');
|
||||
}
|
||||
}
|
||||
|
||||
if (options.cwd != null) {
|
||||
if (typeof options.cwd !== 'string') {
|
||||
throw new Error('cwd path must be a string.');
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof options.stdio === 'string') {
|
||||
const stdio : Array<'pipe' | 'ignore' | 'inherit'> = [];
|
||||
switch (options.stdio) {
|
||||
case 'inherit':
|
||||
case 'ignore':
|
||||
stdio.push('ignore', options.stdio, options.stdio);
|
||||
break;
|
||||
case 'pipe':
|
||||
this.#stderr = new PassThrough();
|
||||
this.#stdout = new PassThrough();
|
||||
stdio.push('ignore', options.stdio, options.stdio);
|
||||
break;
|
||||
default:
|
||||
throw new Error('stdio must be of the following values: inherit, pipe, ignore');
|
||||
}
|
||||
options.stdio = stdio;
|
||||
} else if (Array.isArray(options.stdio)) {
|
||||
if (options.stdio.length >= 3) {
|
||||
if (options.stdio[0] !== 'ignore') {
|
||||
throw new Error('stdin value other than ignore is not supported.');
|
||||
}
|
||||
|
||||
if (options.stdio[1] === 'pipe') {
|
||||
this.#stdout = new PassThrough();
|
||||
} else if (options.stdio[1] !== 'ignore' && options.stdio[1] !== 'inherit') {
|
||||
throw new Error('stdout configuration must be of the following values: inherit, pipe, ignore');
|
||||
}
|
||||
|
||||
if (options.stdio[2] === 'pipe') {
|
||||
this.#stderr = new PassThrough();
|
||||
} else if (options.stdio[2] !== 'ignore' && options.stdio[2] !== 'inherit') {
|
||||
throw new Error('stderr configuration must be of the following values: inherit, pipe, ignore');
|
||||
}
|
||||
} else {
|
||||
throw new Error('configuration missing for stdin, stdout or stderr.');
|
||||
}
|
||||
}
|
||||
|
||||
this.#handle = _fork({ options, modulePath, args });
|
||||
this.#handle!.emit = (channel: string | symbol, ...args: any[]) => {
|
||||
if (channel === 'exit') {
|
||||
try {
|
||||
this.emit('exit', ...args);
|
||||
} finally {
|
||||
this.#handle = null;
|
||||
if (this.#stdout) {
|
||||
this.#stdout.removeAllListeners();
|
||||
this.#stdout = null;
|
||||
}
|
||||
if (this.#stderr) {
|
||||
this.#stderr.removeAllListeners();
|
||||
this.#stderr = null;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
} else if (channel === 'stdout' && this.#stdout) {
|
||||
new Socket({ fd: args[0], readable: true }).pipe(this.#stdout);
|
||||
return true;
|
||||
} else if (channel === 'stderr' && this.#stderr) {
|
||||
new Socket({ fd: args[0], readable: true }).pipe(this.#stderr);
|
||||
return true;
|
||||
} else {
|
||||
return this.emit(channel, ...args);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
get pid () {
|
||||
return this.#handle?.pid;
|
||||
}
|
||||
|
||||
get stdout () {
|
||||
return this.#stdout;
|
||||
}
|
||||
|
||||
get stderr () {
|
||||
return this.#stderr;
|
||||
}
|
||||
|
||||
postMessage (message: any, transfer?: MessagePortMain[]) {
|
||||
if (Array.isArray(transfer)) {
|
||||
transfer = transfer.map((o: any) => o instanceof MessagePortMain ? o._internalPort : o);
|
||||
return this.#handle?.postMessage(message, transfer);
|
||||
}
|
||||
return this.#handle?.postMessage(message);
|
||||
}
|
||||
|
||||
kill () : boolean {
|
||||
if (this.#handle === null) {
|
||||
return false;
|
||||
}
|
||||
return this.#handle.kill();
|
||||
}
|
||||
}
|
||||
|
||||
export function fork (modulePath: string, args?: string[], options?: Electron.ForkOptions) {
|
||||
return new ForkUtilityProcess(modulePath, args, options);
|
||||
}
|
||||
@@ -33,29 +33,20 @@ function wrap <T extends AnyFn> (func: T, wrapper: (fn: AnyFn) => T) {
|
||||
return wrapped;
|
||||
}
|
||||
|
||||
// process.nextTick and setImmediate make use of uv_check and uv_prepare to
|
||||
// run the callbacks, however since we only run uv loop on requests, the
|
||||
// callbacks wouldn't be called until something else activated the uv loop,
|
||||
// which would delay the callbacks for arbitrary long time. So we should
|
||||
// initiatively activate the uv loop once process.nextTick and setImmediate is
|
||||
// called.
|
||||
process.nextTick = wrapWithActivateUvLoop(process.nextTick);
|
||||
|
||||
global.setImmediate = timers.setImmediate = wrapWithActivateUvLoop(timers.setImmediate);
|
||||
global.clearImmediate = timers.clearImmediate;
|
||||
|
||||
// setTimeout needs to update the polling timeout of the event loop, when
|
||||
// called under Chromium's event loop the node's event loop won't get a chance
|
||||
// to update the timeout, so we have to force the node's event loop to
|
||||
// recalculate the timeout in the process.
|
||||
// recalculate the timeout in browser process.
|
||||
timers.setTimeout = wrapWithActivateUvLoop(timers.setTimeout);
|
||||
timers.setInterval = wrapWithActivateUvLoop(timers.setInterval);
|
||||
|
||||
// Update the global version of the timer apis to use the above wrapper
|
||||
// only in the process that runs node event loop alongside chromium
|
||||
// event loop. We skip renderer with nodeIntegration here because node globals
|
||||
// are deleted in these processes, see renderer/init.js for reference.
|
||||
if (process.type === 'browser' ||
|
||||
process.type === 'utility') {
|
||||
// Only override the global setTimeout/setInterval impls in the browser process
|
||||
if (process.type === 'browser') {
|
||||
global.setTimeout = timers.setTimeout;
|
||||
global.setInterval = timers.setInterval;
|
||||
}
|
||||
|
||||
@@ -52,16 +52,8 @@ if (process.type === 'renderer') {
|
||||
}
|
||||
|
||||
const originalResolveFilename = Module._resolveFilename;
|
||||
|
||||
// 'electron/main', 'electron/renderer' and 'electron/common' are module aliases
|
||||
// of the 'electron' module for TypeScript purposes, i.e., the types for
|
||||
// 'electron/main' consist of only main process modules, etc. It is intentional
|
||||
// that these can be `require()`-ed from both the main process as well as the
|
||||
// renderer process regardless of the names, they're superficial for TypeScript
|
||||
// only.
|
||||
const electronModuleNames = new Set(['electron', 'electron/main', 'electron/renderer', 'electron/common']);
|
||||
Module._resolveFilename = function (request: string, parent: NodeModule, isMain: boolean, options?: { paths: Array<string>}) {
|
||||
if (electronModuleNames.has(request)) {
|
||||
if (request === 'electron' || request.startsWith('electron/')) {
|
||||
return 'electron';
|
||||
} else {
|
||||
return originalResolveFilename(request, parent, isMain, options);
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"rules": {
|
||||
"no-restricted-imports": [
|
||||
"error",
|
||||
{
|
||||
"paths": [
|
||||
"electron",
|
||||
"electron/renderer"
|
||||
],
|
||||
"patterns": [
|
||||
"./*",
|
||||
"../*",
|
||||
"@electron/internal/isolated_renderer/*",
|
||||
"@electron/internal/renderer/*",
|
||||
"@electron/internal/sandboxed_worker/*",
|
||||
"@electron/internal/worker/*"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
import { defineProperties } from '@electron/internal/common/define-properties';
|
||||
import { utilityNodeModuleList } from '@electron/internal/utility/api/module-list';
|
||||
|
||||
module.exports = {};
|
||||
|
||||
defineProperties(module.exports, utilityNodeModuleList);
|
||||
@@ -1,2 +0,0 @@
|
||||
// Utility side modules, please sort alphabetically.
|
||||
export const utilityNodeModuleList: ElectronInternal.ModuleEntry[] = [];
|
||||
@@ -1,38 +0,0 @@
|
||||
import { ParentPort } from '@electron/internal/utility/parent-port';
|
||||
const Module = require('module');
|
||||
const v8Util = process._linkedBinding('electron_common_v8_util');
|
||||
|
||||
const entryScript: string = v8Util.getHiddenValue(process, '_serviceStartupScript');
|
||||
// We modified the original process.argv to let node.js load the init.js,
|
||||
// we need to restore it here.
|
||||
process.argv.splice(1, 1, entryScript);
|
||||
|
||||
// Clear search paths.
|
||||
require('../common/reset-search-paths');
|
||||
|
||||
// Import common settings.
|
||||
require('@electron/internal/common/init');
|
||||
|
||||
const parentPort: ParentPort = new ParentPort();
|
||||
Object.defineProperty(process, 'parentPort', {
|
||||
enumerable: true,
|
||||
writable: false,
|
||||
value: parentPort
|
||||
});
|
||||
|
||||
// Based on third_party/electron_node/lib/internal/worker/io.js
|
||||
parentPort.on('newListener', (name: string) => {
|
||||
if (name === 'message' && parentPort.listenerCount('message') === 0) {
|
||||
parentPort.start();
|
||||
}
|
||||
});
|
||||
|
||||
parentPort.on('removeListener', (name: string) => {
|
||||
if (name === 'message' && parentPort.listenerCount('message') === 0) {
|
||||
parentPort.pause();
|
||||
}
|
||||
});
|
||||
|
||||
// Finally load entry script.
|
||||
process._firstFileName = Module._resolveFilename(entryScript, null, false);
|
||||
Module._load(entryScript, Module, true);
|
||||
@@ -1,30 +0,0 @@
|
||||
import { EventEmitter } from 'events';
|
||||
import { MessagePortMain } from '@electron/internal/browser/message-port-main';
|
||||
const { createParentPort } = process._linkedBinding('electron_utility_parent_port');
|
||||
|
||||
export class ParentPort extends EventEmitter {
|
||||
#port: ParentPort
|
||||
constructor () {
|
||||
super();
|
||||
this.#port = createParentPort();
|
||||
this.#port.emit = (channel: string | symbol, event: { ports: any[] }) => {
|
||||
if (channel === 'message') {
|
||||
event = { ...event, ports: event.ports.map(p => new MessagePortMain(p)) };
|
||||
}
|
||||
this.emit(channel, event);
|
||||
return false;
|
||||
};
|
||||
}
|
||||
|
||||
start () : void {
|
||||
this.#port.start();
|
||||
}
|
||||
|
||||
pause () : void {
|
||||
this.#port.pause();
|
||||
}
|
||||
|
||||
postMessage (message: any) : void {
|
||||
this.#port.postMessage(message);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
{
|
||||
"name": "electron",
|
||||
"version": "0.0.0-development",
|
||||
"version": "22.0.0-alpha.8",
|
||||
"repository": "https://github.com/electron/electron",
|
||||
"description": "Build cross platform desktop apps with JavaScript, HTML, and CSS",
|
||||
"devDependencies": {
|
||||
"@azure/storage-blob": "^12.9.0",
|
||||
"@electron/asar": "^3.2.1",
|
||||
"@electron/docs-parser": "^0.12.4",
|
||||
"@electron/typescript-definitions": "^8.9.6",
|
||||
"@octokit/auth-app": "^2.10.0",
|
||||
@@ -32,6 +31,7 @@
|
||||
"@types/webpack-env": "^1.17.0",
|
||||
"@typescript-eslint/eslint-plugin": "^4.4.1",
|
||||
"@typescript-eslint/parser": "^4.4.1",
|
||||
"asar": "^3.1.0",
|
||||
"aws-sdk": "^2.814.0",
|
||||
"buffer": "^6.0.3",
|
||||
"check-for-leaks": "^1.2.1",
|
||||
|
||||
@@ -115,9 +115,6 @@ add_electron_deps_to_license_credits_file.patch
|
||||
fix_crash_loading_non-standard_schemes_in_iframes.patch
|
||||
fix_return_v8_value_from_localframe_requestexecutescript.patch
|
||||
create_browser_v8_snapshot_file_name_fuse.patch
|
||||
feat_configure_launch_options_for_service_process.patch
|
||||
feat_ensure_mas_builds_of_the_same_application_can_use_safestorage.patch
|
||||
fix_on-screen-keyboard_hides_on_input_blur_in_webview.patch
|
||||
preconnect_manager.patch
|
||||
fix_remove_caption-removing_style_call.patch
|
||||
build_allow_electron_to_use_exec_script.patch
|
||||
|
||||
@@ -67,10 +67,10 @@ index 149ca596036a4a4c123b6982014001953cf06800..dd069baf01929b75f42093ecf09ecf8e
|
||||
virtual void WillReleaseScriptContext(v8::Local<v8::Context>,
|
||||
int32_t world_id) {}
|
||||
diff --git a/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc b/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
|
||||
index c8af53d40eaa1dd3a0067948a8cda80d1599cee3..4de918ee52efa7ec27a21aa2f57616d31dfd07d1 100644
|
||||
index d0b5233ad45995bd6128a03fe9267618d723d683..e5e93be8f2433196a13aa104241b1ddd63985e81 100644
|
||||
--- a/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
|
||||
+++ b/third_party/blink/renderer/bindings/core/v8/local_window_proxy.cc
|
||||
@@ -209,6 +209,7 @@ void LocalWindowProxy::Initialize() {
|
||||
@@ -210,6 +210,7 @@ void LocalWindowProxy::Initialize() {
|
||||
}
|
||||
|
||||
InstallConditionalFeatures();
|
||||
|
||||
@@ -72,10 +72,10 @@ index f3b681ec44c57f69c57390f31bd951cef8de3f0c..2fbe866ddf50d7eb324b0e2e4d120f4c
|
||||
// Visibility -----------------------------------------------------------
|
||||
|
||||
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
index 50cae526561de69c7b6b3b5d2467946ee92fcb23..fe35e9c6b8c51e61f0f89c8feca03a36f756d432 100644
|
||||
index 33cd38a8e24a2db922987a957a115a5892382a59..b07f239296667e0d3809ccee255d608e7b0d0c9b 100644
|
||||
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
@@ -3808,13 +3808,21 @@ PageScheduler* WebViewImpl::Scheduler() const {
|
||||
@@ -3811,13 +3811,21 @@ PageScheduler* WebViewImpl::Scheduler() const {
|
||||
return GetPage()->GetPageScheduler();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,28 +3,28 @@ From: Jeremy Apthorp <nornagon@nornagon.net>
|
||||
Date: Mon, 26 Aug 2019 12:02:51 -0700
|
||||
Subject: allow new privileges in unsandboxed child processes
|
||||
|
||||
This allows unsandboxed child process to launch setuid processes on Linux.
|
||||
This allows unsandboxed renderers to launch setuid processes on Linux.
|
||||
|
||||
diff --git a/content/browser/child_process_launcher_helper_linux.cc b/content/browser/child_process_launcher_helper_linux.cc
|
||||
index dd5ccfc0bdc2e071999d1bf864dc065dd1311407..cfadd28fca9f80bf57578db78d5472c4f75414e1 100644
|
||||
index dd5ccfc0bdc2e071999d1bf864dc065dd1311407..7464e84f6e610749dce5c3a46afce262f29020cc 100644
|
||||
--- a/content/browser/child_process_launcher_helper_linux.cc
|
||||
+++ b/content/browser/child_process_launcher_helper_linux.cc
|
||||
@@ -56,6 +56,18 @@ bool ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread(
|
||||
@@ -54,6 +54,18 @@ bool ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread(
|
||||
if (GetProcessType() == switches::kRendererProcess) {
|
||||
const int sandbox_fd = SandboxHostLinux::GetInstance()->GetChildSocket();
|
||||
options->fds_to_remap.push_back(std::make_pair(sandbox_fd, GetSandboxFD()));
|
||||
+
|
||||
+ // (For Electron), if we're launching without zygote, that means we're
|
||||
+ // launching an unsandboxed process (since all sandboxed processes are
|
||||
+ // forked from the zygote). Relax the allow_new_privs option to permit
|
||||
+ // launching suid processes from unsandboxed renderers.
|
||||
+ ZygoteHandle zygote_handle =
|
||||
+ base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoZygote)
|
||||
+ ? nullptr
|
||||
+ : delegate_->GetZygote();
|
||||
+ if (!zygote_handle) {
|
||||
+ options->allow_new_privs = true;
|
||||
+ }
|
||||
}
|
||||
|
||||
+ // (For Electron), if we're launching without zygote, that means we're
|
||||
+ // launching an unsandboxed process (since all sandboxed processes are
|
||||
+ // forked from the zygote). Relax the allow_new_privs option to permit
|
||||
+ // launching suid processes from unsandboxed child processes.
|
||||
+ ZygoteHandle zygote_handle =
|
||||
+ base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kNoZygote)
|
||||
+ ? nullptr
|
||||
+ : delegate_->GetZygote();
|
||||
+ if (!zygote_handle) {
|
||||
+ options->allow_new_privs = true;
|
||||
+ }
|
||||
+
|
||||
for (const auto& remapped_fd : file_data_->additional_remapped_fds) {
|
||||
options->fds_to_remap.emplace_back(remapped_fd.second.get(),
|
||||
remapped_fd.first);
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samuel Attard <sattard@salesforce.com>
|
||||
Date: Fri, 21 Oct 2022 16:29:06 -0700
|
||||
Subject: build: allow electron to use exec_script
|
||||
|
||||
This is similar to the //build usecase so we're OK adding ourselves here
|
||||
|
||||
diff --git a/.gn b/.gn
|
||||
index 55f5ee19f13e49dfd0aa2300d980d813474c95ef..483e0f0598bfed76b4a4283be3cfa1fdb9eafe5a 100644
|
||||
--- a/.gn
|
||||
+++ b/.gn
|
||||
@@ -169,4 +169,6 @@ exec_script_whitelist =
|
||||
|
||||
"//tools/grit/grit_rule.gni",
|
||||
"//tools/gritsettings/BUILD.gn",
|
||||
+
|
||||
+ "//electron/BUILD.gn"
|
||||
]
|
||||
@@ -9,7 +9,7 @@ and can be removed when the crash in fork is resolved.
|
||||
Related issue: https://github.com/electron/electron/issues/32718
|
||||
|
||||
diff --git a/build_overrides/partition_alloc.gni b/build_overrides/partition_alloc.gni
|
||||
index 2e63825db7a41ecbb044547dbfe318767d743a4e..e245960ab5a714293cc08b556988a28e37f120ff 100644
|
||||
index 44ace8017bdf9ce2ddb996e30ee03dbdc6274fb9..e2ce9f6c57e55f6a9257bb2e58e99895ca52f8c6 100644
|
||||
--- a/build_overrides/partition_alloc.gni
|
||||
+++ b/build_overrides/partition_alloc.gni
|
||||
@@ -40,7 +40,7 @@ _disable_partition_alloc = is_component_build || (is_win && is_debug)
|
||||
|
||||
@@ -33,10 +33,10 @@ index b12b4e65be8ad29054f5fdd98600888726b1d068..d67683efeabed3209eac553ff050ec2e
|
||||
"//base",
|
||||
"//build:branding_buildflags",
|
||||
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
|
||||
index cb7cbdca15b12f5735d20777cb3b2fd8d3129061..7ce770bde9e70ac7f3aceb3dd7c14f4a19c76bfc 100644
|
||||
index 68415e75360cec6de27d95ba01b30935c491023e..b5885d348ed5a3ed18bb524cbbde51ed185a8658 100644
|
||||
--- a/chrome/browser/BUILD.gn
|
||||
+++ b/chrome/browser/BUILD.gn
|
||||
@@ -4679,7 +4679,7 @@ static_library("browser") {
|
||||
@@ -4683,7 +4683,7 @@ static_library("browser") {
|
||||
|
||||
# On Windows, the hashes are embedded in //chrome:chrome_initial rather
|
||||
# than here in :chrome_dll.
|
||||
@@ -46,10 +46,10 @@ index cb7cbdca15b12f5735d20777cb3b2fd8d3129061..7ce770bde9e70ac7f3aceb3dd7c14f4a
|
||||
sources += [ "certificate_viewer_stub.cc" ]
|
||||
}
|
||||
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
|
||||
index e368f894735d19ff166997b8f72379a8988541ac..141308ad441cd6864318533071dd033f1499ebf3 100644
|
||||
index 15b713cb25724fc2a0b743725837720492739ed2..f7649e3bc908cd9a04294d63c405f98b6363b05d 100644
|
||||
--- a/chrome/test/BUILD.gn
|
||||
+++ b/chrome/test/BUILD.gn
|
||||
@@ -6153,7 +6153,6 @@ test("unit_tests") {
|
||||
@@ -6156,7 +6156,6 @@ test("unit_tests") {
|
||||
|
||||
deps += [
|
||||
"//chrome:other_version",
|
||||
@@ -57,7 +57,7 @@ index e368f894735d19ff166997b8f72379a8988541ac..141308ad441cd6864318533071dd033f
|
||||
"//chrome//services/util_win:unit_tests",
|
||||
"//chrome/app:chrome_dll_resources",
|
||||
"//chrome/app:crash_reporter_client_win_unit_tests",
|
||||
@@ -6178,6 +6177,10 @@ test("unit_tests") {
|
||||
@@ -6181,6 +6180,10 @@ test("unit_tests") {
|
||||
"//ui/resources",
|
||||
]
|
||||
|
||||
@@ -68,7 +68,7 @@ index e368f894735d19ff166997b8f72379a8988541ac..141308ad441cd6864318533071dd033f
|
||||
ldflags = [
|
||||
"/DELAYLOAD:api-ms-win-core-winrt-error-l1-1-0.dll",
|
||||
"/DELAYLOAD:api-ms-win-core-winrt-l1-1-0.dll",
|
||||
@@ -7103,7 +7106,7 @@ test("unit_tests") {
|
||||
@@ -7107,7 +7110,7 @@ test("unit_tests") {
|
||||
}
|
||||
|
||||
deps += [
|
||||
@@ -77,7 +77,7 @@ index e368f894735d19ff166997b8f72379a8988541ac..141308ad441cd6864318533071dd033f
|
||||
"//chrome/browser/autofill_assistant/password_change/vector_icons:vector_icons",
|
||||
"//chrome/browser/enterprise/connectors/analysis:features",
|
||||
"//chrome/browser/media/router:test_support",
|
||||
@@ -7226,6 +7229,10 @@ test("unit_tests") {
|
||||
@@ -7230,6 +7233,10 @@ test("unit_tests") {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ potentially prevent a window from being created.
|
||||
TODO(loc): this patch is currently broken.
|
||||
|
||||
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
index f00a5c63bb8f6c61f1a89cb38cf1ea253a353e25..94690c49a771cb5ff873696bf0926972e7276d50 100644
|
||||
index e4e16ccdcd2070e56d9572b7d4bc22d685cb34bc..7484975281bf5c19b1640c56ea6ad5f8a1add54a 100644
|
||||
--- a/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
@@ -7443,6 +7443,7 @@ void RenderFrameHostImpl::CreateNewWindow(
|
||||
@@ -81,7 +81,7 @@ index f31156ba6ea6d6229198d129c5b56cfa1847c5fc..41f3dac6323bda9d1a10bcb8678fe3da
|
||||
bool opener_suppressed,
|
||||
bool* no_javascript_access) {
|
||||
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
|
||||
index 65d57c0efa1b268f0cbe4b49bd64a51d1da3cdc0..2dcea7a09b8521020e0821e18cbd45219caca639 100644
|
||||
index 9b6c2b8b249af92bc38c2c72f420e851c138d6f6..3f5f0449b7c70b7d48438d4c4c908c897cad3727 100644
|
||||
--- a/content/public/browser/content_browser_client.h
|
||||
+++ b/content/public/browser/content_browser_client.h
|
||||
@@ -163,6 +163,7 @@ class NetworkService;
|
||||
|
||||
@@ -7,7 +7,7 @@ By default, chromium sets up one v8 snapshot to be used in all v8 contexts. This
|
||||
to have a dedicated browser process v8 snapshot defined by the file `browser_v8_context_snapshot.bin`.
|
||||
|
||||
diff --git a/content/app/content_main_runner_impl.cc b/content/app/content_main_runner_impl.cc
|
||||
index f55888577c514abe5ed64e8b88ff9f6e442815fd..1cb549ad9229dc9cf478e1bb3959a984055d8fe1 100644
|
||||
index 89cbfffe47ba6dbf6ba771b49a327ea69a3aede9..3089d64a8d701fcce9a153b1fbb6553e030e0bcc 100644
|
||||
--- a/content/app/content_main_runner_impl.cc
|
||||
+++ b/content/app/content_main_runner_impl.cc
|
||||
@@ -38,6 +38,7 @@
|
||||
@@ -48,7 +48,7 @@ index f55888577c514abe5ed64e8b88ff9f6e442815fd..1cb549ad9229dc9cf478e1bb3959a984
|
||||
#endif // V8_USE_EXTERNAL_STARTUP_DATA
|
||||
}
|
||||
|
||||
@@ -955,7 +962,7 @@ int ContentMainRunnerImpl::Initialize(ContentMainParams params) {
|
||||
@@ -954,7 +961,7 @@ int ContentMainRunnerImpl::Initialize(ContentMainParams params) {
|
||||
return TerminateForFatalInitializationError();
|
||||
#endif // BUILDFLAG(IS_ANDROID) && (ICU_UTIL_DATA_IMPL == ICU_UTIL_DATA_FILE)
|
||||
|
||||
@@ -81,7 +81,7 @@ index a687861c04b323102a8d2bfe22b24a964793cd9b..4a7a469111eaec3e1e76ee852bd5afbb
|
||||
return new ContentClient();
|
||||
}
|
||||
diff --git a/content/public/app/content_main_delegate.h b/content/public/app/content_main_delegate.h
|
||||
index 94b0925b07528eb21004aeb180594c067932f1d3..095f697908595d14aa7fb524efe31df3a80e4144 100644
|
||||
index 8420d43b88bc7187d8e0701dd58a5de07366a5c6..5572fad8219ae2c72f7c636b8b86c0b64cf75411 100644
|
||||
--- a/content/public/app/content_main_delegate.h
|
||||
+++ b/content/public/app/content_main_delegate.h
|
||||
@@ -9,6 +9,7 @@
|
||||
@@ -92,7 +92,7 @@ index 94b0925b07528eb21004aeb180594c067932f1d3..095f697908595d14aa7fb524efe31df3
|
||||
#include "build/build_config.h"
|
||||
#include "content/common/content_export.h"
|
||||
#include "content/public/common/main_function_params.h"
|
||||
@@ -162,6 +163,8 @@ class CONTENT_EXPORT ContentMainDelegate {
|
||||
@@ -165,6 +166,8 @@ class CONTENT_EXPORT ContentMainDelegate {
|
||||
virtual bool ShouldHandleConsoleControlEvents();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ at some point be an API to "unfreeze" the flags, or we may be able to refactor
|
||||
node initialization to not update flags after V8 initialization.
|
||||
|
||||
diff --git a/content/renderer/render_process_impl.cc b/content/renderer/render_process_impl.cc
|
||||
index ff83822653e2e661eb0ce9e3a1a90c045b25fdb1..f7141cb915ab8028117264ecd8ebfdb53b1079f0 100644
|
||||
index f2bdea351833b9c49b2f6fb1a9badfc83c07dbb1..ed7b55da2ba31391d2840ef704159f59c26b92e3 100644
|
||||
--- a/content/renderer/render_process_impl.cc
|
||||
+++ b/content/renderer/render_process_impl.cc
|
||||
@@ -241,6 +241,9 @@ RenderProcessImpl::RenderProcessImpl()
|
||||
@@ -228,6 +228,9 @@ RenderProcessImpl::RenderProcessImpl()
|
||||
SetV8FlagIfNotFeature(features::kWebAssemblyDynamicTiering,
|
||||
"--no-wasm-dynamic-tiering");
|
||||
|
||||
@@ -27,4 +27,4 @@ index ff83822653e2e661eb0ce9e3a1a90c045b25fdb1..f7141cb915ab8028117264ecd8ebfdb5
|
||||
+
|
||||
#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && defined(ARCH_CPU_X86_64)
|
||||
if (base::FeatureList::IsEnabled(features::kWebAssemblyTrapHandler)) {
|
||||
if (command_line->HasSwitch(switches::kEnableCrashpad) ||
|
||||
base::CommandLine* const command_line =
|
||||
|
||||
@@ -51,10 +51,10 @@ index b1ac2fd235d3fc424d15b5c5991d7026a0f85090..6dc46954b070795de082d8542f8bae56
|
||||
// This may only be called on NetworkContexts created with the constructor
|
||||
// that calls MakeURLRequestContext().
|
||||
diff --git a/services/network/network_context.h b/services/network/network_context.h
|
||||
index 5b0a62302719f2aca565d933be4391ce59894f01..f16ba305b84c46ffbbef66d95c3f04bc8cc4f7e3 100644
|
||||
index ae43559f383538f9a8ef168a592a6de416f1ded2..402a9de330140e78f14dbfae204f4c637803fcef 100644
|
||||
--- a/services/network/network_context.h
|
||||
+++ b/services/network/network_context.h
|
||||
@@ -298,6 +298,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
|
||||
@@ -299,6 +299,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
|
||||
void CloseIdleConnections(CloseIdleConnectionsCallback callback) override;
|
||||
void SetNetworkConditions(const base::UnguessableToken& throttling_profile_id,
|
||||
mojom::NetworkConditionsPtr conditions) override;
|
||||
|
||||
@@ -12,7 +12,7 @@ Ideally we could add an embedder observer pattern here but that can be
|
||||
done in future work.
|
||||
|
||||
diff --git a/third_party/blink/renderer/core/exported/web_view_impl.cc b/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
index fe35e9c6b8c51e61f0f89c8feca03a36f756d432..775d81466dea650bb849cf6fb1a97662781a9b2d 100644
|
||||
index b07f239296667e0d3809ccee255d608e7b0d0c9b..4adb26b265738d5f16568252e070300dcf2951f5 100644
|
||||
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
|
||||
@@ -164,6 +164,7 @@
|
||||
|
||||
@@ -13,7 +13,7 @@ other protocols to register their streaming behavior. MultibufferDataSource::Ass
|
||||
then refers to the list so that it can correctly determine the data source's settings.
|
||||
|
||||
diff --git a/third_party/blink/renderer/platform/media/multi_buffer_data_source.cc b/third_party/blink/renderer/platform/media/multi_buffer_data_source.cc
|
||||
index 2201f930953ed125a0439bafb26e27b42de11003..7372476a7a794d5de8ee01858690f77af8875501 100644
|
||||
index 35e37b00ca87f1975c11ab98858b7849487304e5..82248fc99bbd0484f15de6ed7a7451cda741f807 100644
|
||||
--- a/third_party/blink/renderer/platform/media/multi_buffer_data_source.cc
|
||||
+++ b/third_party/blink/renderer/platform/media/multi_buffer_data_source.cc
|
||||
@@ -11,8 +11,10 @@
|
||||
@@ -65,7 +65,7 @@ index 2201f930953ed125a0439bafb26e27b42de11003..7372476a7a794d5de8ee01858690f77a
|
||||
|
||||
void MultiBufferDataSource::SetReader(MultiBufferReader* reader) {
|
||||
diff --git a/third_party/blink/renderer/platform/media/multi_buffer_data_source.h b/third_party/blink/renderer/platform/media/multi_buffer_data_source.h
|
||||
index fd7d59b9c50d0142a3d17a43b348f66f7f868674..e2361792eb6f9ba1e46018283634e2b9293916ec 100644
|
||||
index 28789ff812609dcad26955f4d22e9bfac8b9f948..6ea16442e0c4f29d1df81081a93a5f9fb6972d5c 100644
|
||||
--- a/third_party/blink/renderer/platform/media/multi_buffer_data_source.h
|
||||
+++ b/third_party/blink/renderer/platform/media/multi_buffer_data_source.h
|
||||
@@ -33,6 +33,8 @@ namespace blink {
|
||||
|
||||
@@ -1,671 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: deepak1556 <hop2deep@gmail.com>
|
||||
Date: Wed, 17 Aug 2022 22:04:47 +0900
|
||||
Subject: feat: configure launch options for service process
|
||||
|
||||
- POSIX:
|
||||
Allows configuring base::LaunchOptions::fds_to_remap when launching the child process.
|
||||
- Win:
|
||||
Allows configuring base::LaunchOptions::handles_to_inherit, base::LaunchOptions::stdout_handle
|
||||
and base::LaunchOptions::stderr_handle when launching the child process.
|
||||
- All:
|
||||
Allows configuring base::LauncOptions::current_directory, base::LaunchOptions::enviroment
|
||||
and base::LaunchOptions::clear_environment.
|
||||
|
||||
An example use of this option, UtilityProcess API allows reading the output From
|
||||
stdout and stderr of child process by creating a pipe, whose write end is remapped
|
||||
to STDOUT_FILENO/STD_OUTPUT_HANDLE and STDERR_FILENO/STD_ERROR_HANDLE allowing the
|
||||
parent process to read from the pipe.
|
||||
|
||||
diff --git a/content/browser/child_process_launcher.h b/content/browser/child_process_launcher.h
|
||||
index ba1f0d6e958cdb534b8af7717a0d6d8f2ee296bf..626f771ffbd88f1cf2e9475b745456f98575cda1 100644
|
||||
--- a/content/browser/child_process_launcher.h
|
||||
+++ b/content/browser/child_process_launcher.h
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/win/windows_types.h"
|
||||
+#include "base/win/scoped_handle.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
@@ -163,7 +164,10 @@ struct ChildProcessLauncherFileData {
|
||||
delete;
|
||||
~ChildProcessLauncherFileData();
|
||||
|
||||
-#if BUILDFLAG(IS_POSIX)
|
||||
+#if BUILDFLAG(IS_WIN)
|
||||
+ base::win::ScopedHandle stdout_handle;
|
||||
+ base::win::ScopedHandle stderr_handle;
|
||||
+#elif BUILDFLAG(IS_POSIX)
|
||||
// Files opened by the browser and passed as corresponding file descriptors
|
||||
// in the child process.
|
||||
// Currently only supported on Linux, ChromeOS and Android platforms.
|
||||
diff --git a/content/browser/child_process_launcher_helper_linux.cc b/content/browser/child_process_launcher_helper_linux.cc
|
||||
index cfadd28fca9f80bf57578db78d5472c4f75414e1..4925dc5cafbf312c3c9640d5873d62193e87f636 100644
|
||||
--- a/content/browser/child_process_launcher_helper_linux.cc
|
||||
+++ b/content/browser/child_process_launcher_helper_linux.cc
|
||||
@@ -73,7 +73,9 @@ bool ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread(
|
||||
remapped_fd.first);
|
||||
}
|
||||
|
||||
+ options->current_directory = delegate_->GetCurrentDirectory();
|
||||
options->environment = delegate_->GetEnvironment();
|
||||
+ options->clear_environment = !delegate_->ShouldInheritEnvironment();
|
||||
|
||||
return true;
|
||||
}
|
||||
diff --git a/content/browser/child_process_launcher_helper_mac.cc b/content/browser/child_process_launcher_helper_mac.cc
|
||||
index d74a40c0e5731281b132cc1c3dc2416f9dc2b083..dd8a9d35af617441c6643ed643b459a35b612969 100644
|
||||
--- a/content/browser/child_process_launcher_helper_mac.cc
|
||||
+++ b/content/browser/child_process_launcher_helper_mac.cc
|
||||
@@ -73,7 +73,8 @@ bool ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread(
|
||||
'mojo', base::MachRendezvousPort(endpoint.TakeMachReceiveRight())));
|
||||
|
||||
options->environment = delegate_->GetEnvironment();
|
||||
-
|
||||
+ options->clear_environment = !delegate_->ShouldInheritEnvironment();
|
||||
+ options->current_directory = delegate_->GetCurrentDirectory();
|
||||
options->disclaim_responsibility = delegate_->DisclaimResponsibility();
|
||||
options->enable_cpu_security_mitigations =
|
||||
delegate_->EnableCpuSecurityMitigations();
|
||||
diff --git a/content/browser/child_process_launcher_helper_win.cc b/content/browser/child_process_launcher_helper_win.cc
|
||||
index 799ad0a6e0b5c629d10f481d10dd4d6959d40b42..13c610ae1bb24fb6d274a082562dcd103df50513 100644
|
||||
--- a/content/browser/child_process_launcher_helper_win.cc
|
||||
+++ b/content/browser/child_process_launcher_helper_win.cc
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "sandbox/policy/win/sandbox_win.h"
|
||||
#include "sandbox/win/src/sandbox_types.h"
|
||||
|
||||
+#include <windows.h>
|
||||
+
|
||||
namespace content {
|
||||
namespace internal {
|
||||
|
||||
@@ -54,6 +56,30 @@ bool ChildProcessLauncherHelper::BeforeLaunchOnLauncherThread(
|
||||
mojo_channel_->PrepareToPassRemoteEndpoint(&options->handles_to_inherit,
|
||||
command_line());
|
||||
}
|
||||
+
|
||||
+ if (file_data_->stdout_handle.IsValid() || file_data_->stderr_handle.IsValid()) {
|
||||
+ // base::LaunchProcess requires that if any of the stdio handle is customized then
|
||||
+ // the other two handles should also be set.
|
||||
+ // https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch_win.cc;l=341-350
|
||||
+ options->stdin_handle = INVALID_HANDLE_VALUE;
|
||||
+ if (file_data_->stdout_handle.IsValid()) {
|
||||
+ options->stdout_handle = file_data_->stdout_handle.get();
|
||||
+ } else {
|
||||
+ options->stdout_handle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
+ }
|
||||
+
|
||||
+ if (file_data_->stderr_handle.IsValid()) {
|
||||
+ options->stderr_handle = file_data_->stderr_handle.get();
|
||||
+ } else {
|
||||
+ options->stderr_handle = GetStdHandle(STD_ERROR_HANDLE);
|
||||
+ }
|
||||
+ options->handles_to_inherit.push_back(options->stdout_handle);
|
||||
+ options->handles_to_inherit.push_back(options->stderr_handle);
|
||||
+ }
|
||||
+
|
||||
+ options->current_directory = delegate_->GetCurrentDirectory();
|
||||
+ options->environment = delegate_->GetEnvironment();
|
||||
+ options->clear_environment = !delegate_->ShouldInheritEnvironment();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -81,7 +107,7 @@ ChildProcessLauncherHelper::LaunchProcessOnLauncherThread(
|
||||
ChildProcessLauncherHelper::Process process;
|
||||
*launch_result =
|
||||
StartSandboxedProcess(delegate_.get(), *command_line(),
|
||||
- options.handles_to_inherit, &process.process);
|
||||
+ options, &process.process);
|
||||
return process;
|
||||
}
|
||||
|
||||
diff --git a/content/browser/service_process_host_impl.cc b/content/browser/service_process_host_impl.cc
|
||||
index e547f42bc0d06b485797ccc1605969259631831f..0f3041f4a5b636440d9579303721f2ae7e1855c6 100644
|
||||
--- a/content/browser/service_process_host_impl.cc
|
||||
+++ b/content/browser/service_process_host_impl.cc
|
||||
@@ -190,6 +190,15 @@ void LaunchServiceProcess(mojo::GenericPendingReceiver receiver,
|
||||
host->SetExtraCommandLineSwitches(std::move(options.extra_switches));
|
||||
if (options.child_flags)
|
||||
host->set_child_flags(*options.child_flags);
|
||||
+#if BUILDFLAG(IS_WIN)
|
||||
+ host->SetStdioHandles(std::move(options.stdout_handle), std::move(options.stderr_handle));
|
||||
+#elif BUILDFLAG(IS_POSIX)
|
||||
+ host->SetAdditionalFds(std::move(options.fds_to_remap));
|
||||
+#endif
|
||||
+ host->SetCurrentDirectory(options.current_directory);
|
||||
+ host->SetEnv(options.environment);
|
||||
+ if (options.clear_environment)
|
||||
+ host->ClearEnvironment();
|
||||
host->Start();
|
||||
host->GetChildProcess()->BindServiceInterface(std::move(receiver));
|
||||
}
|
||||
diff --git a/content/browser/utility_process_host.cc b/content/browser/utility_process_host.cc
|
||||
index 171b8440c25580d717f87c4f68bd8f4734b5fcf1..35826081dc3fc2f17fd7ceaf25c2c014ae623304 100644
|
||||
--- a/content/browser/utility_process_host.cc
|
||||
+++ b/content/browser/utility_process_host.cc
|
||||
@@ -108,11 +108,13 @@ const ChildProcessData& UtilityProcessHost::GetData() {
|
||||
return process_->GetData();
|
||||
}
|
||||
|
||||
-#if BUILDFLAG(IS_POSIX)
|
||||
void UtilityProcessHost::SetEnv(const base::EnvironmentMap& env) {
|
||||
env_ = env;
|
||||
}
|
||||
-#endif
|
||||
+
|
||||
+void UtilityProcessHost::ClearEnvironment() {
|
||||
+ inherit_environment_ = false;
|
||||
+}
|
||||
|
||||
bool UtilityProcessHost::Start() {
|
||||
return StartProcess();
|
||||
@@ -153,6 +155,24 @@ void UtilityProcessHost::SetExtraCommandLineSwitches(
|
||||
extra_switches_ = std::move(switches);
|
||||
}
|
||||
|
||||
+#if BUILDFLAG(IS_WIN)
|
||||
+void UtilityProcessHost::SetStdioHandles(
|
||||
+ base::win::ScopedHandle stdout_handle,
|
||||
+ base::win::ScopedHandle stderr_handle) {
|
||||
+ stdout_handle_ = std::move(stdout_handle);
|
||||
+ stderr_handle_ = std::move(stderr_handle);
|
||||
+}
|
||||
+#elif BUILDFLAG(IS_POSIX)
|
||||
+void UtilityProcessHost::SetAdditionalFds(base::FileHandleMappingVector mapping) {
|
||||
+ fds_to_remap_ = std::move(mapping);
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
+void UtilityProcessHost::SetCurrentDirectory(
|
||||
+ const base::FilePath& cwd) {
|
||||
+ current_directory_ = cwd;
|
||||
+}
|
||||
+
|
||||
mojom::ChildProcess* UtilityProcessHost::GetChildProcess() {
|
||||
return static_cast<ChildProcessHostImpl*>(process_->GetHost())
|
||||
->child_process();
|
||||
@@ -356,9 +376,22 @@ bool UtilityProcessHost::StartProcess() {
|
||||
}
|
||||
#endif // BUILDFLAG(IS_CHROMEOS_LACROS)
|
||||
|
||||
+#if BUILDFLAG(IS_WIN)
|
||||
+ file_data->stdout_handle = std::move(stdout_handle_);
|
||||
+ file_data->stderr_handle = std::move(stderr_handle_);
|
||||
+#elif BUILDFLAG(IS_POSIX)
|
||||
+ if (!fds_to_remap_.empty()) {
|
||||
+ for (const auto& remapped_fd : fds_to_remap_) {
|
||||
+ file_data->additional_remapped_fds.emplace(
|
||||
+ remapped_fd.second, remapped_fd.first);
|
||||
+ }
|
||||
+ }
|
||||
+#endif
|
||||
+
|
||||
std::unique_ptr<UtilitySandboxedProcessLauncherDelegate> delegate =
|
||||
std::make_unique<UtilitySandboxedProcessLauncherDelegate>(
|
||||
- sandbox_type_, env_, *cmd_line);
|
||||
+ sandbox_type_, env_, current_directory_, *cmd_line,
|
||||
+ inherit_environment_);
|
||||
|
||||
process_->LaunchWithFileData(std::move(delegate), std::move(cmd_line),
|
||||
std::move(file_data), true);
|
||||
diff --git a/content/browser/utility_process_host.h b/content/browser/utility_process_host.h
|
||||
index 13de4795df7731f27760901aff17c143008a72c1..3b8af456d86e7aaf3b57e6b039c7f444e1c9e5fe 100644
|
||||
--- a/content/browser/utility_process_host.h
|
||||
+++ b/content/browser/utility_process_host.h
|
||||
@@ -29,6 +29,10 @@
|
||||
#include "mojo/public/cpp/system/message_pipe.h"
|
||||
#endif
|
||||
|
||||
+#if BUILDFLAG(IS_WIN)
|
||||
+#include "base/win/scoped_handle.h"
|
||||
+#endif
|
||||
+
|
||||
namespace base {
|
||||
class Thread;
|
||||
} // namespace base
|
||||
@@ -87,9 +91,13 @@ class CONTENT_EXPORT UtilityProcessHost
|
||||
|
||||
// Returns information about the utility child process.
|
||||
const ChildProcessData& GetData();
|
||||
-#if BUILDFLAG(IS_POSIX)
|
||||
+
|
||||
+ // Set/Unset environment variables.
|
||||
void SetEnv(const base::EnvironmentMap& env);
|
||||
-#endif
|
||||
+
|
||||
+ // Clear the environment for the new process before processing
|
||||
+ // changes from SetEnv.
|
||||
+ void ClearEnvironment();
|
||||
|
||||
// Starts the utility process.
|
||||
bool Start();
|
||||
@@ -118,6 +126,16 @@ class CONTENT_EXPORT UtilityProcessHost
|
||||
// Provides extra switches to append to the process's command line.
|
||||
void SetExtraCommandLineSwitches(std::vector<std::string> switches);
|
||||
|
||||
+#if BUILDFLAG(IS_WIN)
|
||||
+ void SetStdioHandles(base::win::ScopedHandle stdout_handle,
|
||||
+ base::win::ScopedHandle stderr_handle);
|
||||
+#elif BUILDFLAG(IS_POSIX)
|
||||
+ void SetAdditionalFds(base::FileHandleMappingVector mapping);
|
||||
+#endif
|
||||
+
|
||||
+ // Sets the working directory of the process.
|
||||
+ void SetCurrentDirectory(const base::FilePath& cwd);
|
||||
+
|
||||
// Returns a control interface for the running child process.
|
||||
mojom::ChildProcess* GetChildProcess();
|
||||
|
||||
@@ -159,6 +177,22 @@ class CONTENT_EXPORT UtilityProcessHost
|
||||
// Extra command line switches to append.
|
||||
std::vector<std::string> extra_switches_;
|
||||
|
||||
+#if BUILDFLAG(IS_WIN)
|
||||
+ // Specifies the handles for redirection of stdout and stderr.
|
||||
+ base::win::ScopedHandle stdout_handle_;
|
||||
+ base::win::ScopedHandle stderr_handle_;
|
||||
+#elif BUILDFLAG(IS_POSIX)
|
||||
+ // Specifies file descriptors to propagate into the child process
|
||||
+ // based on the mapping.
|
||||
+ base::FileHandleMappingVector fds_to_remap_;
|
||||
+#endif
|
||||
+
|
||||
+ // If not empty, change to this directory before executing the new process.
|
||||
+ base::FilePath current_directory_;
|
||||
+
|
||||
+ // Inherit enviroment from parent process.
|
||||
+ bool inherit_environment_ = true;
|
||||
+
|
||||
// Indicates whether the process has been successfully launched yet, or if
|
||||
// launch failed.
|
||||
enum class LaunchState {
|
||||
diff --git a/content/browser/utility_sandbox_delegate.cc b/content/browser/utility_sandbox_delegate.cc
|
||||
index 070ee151ee96baa771cec6fe4de9f8762eff91bc..d7621b234e45f94a2ca8bc79f25345025b3bc48a 100644
|
||||
--- a/content/browser/utility_sandbox_delegate.cc
|
||||
+++ b/content/browser/utility_sandbox_delegate.cc
|
||||
@@ -29,13 +29,15 @@ UtilitySandboxedProcessLauncherDelegate::
|
||||
UtilitySandboxedProcessLauncherDelegate(
|
||||
sandbox::mojom::Sandbox sandbox_type,
|
||||
const base::EnvironmentMap& env,
|
||||
- const base::CommandLine& cmd_line)
|
||||
+ const base::FilePath& cwd,
|
||||
+ const base::CommandLine& cmd_line,
|
||||
+ bool inherit_environment)
|
||||
:
|
||||
-#if BUILDFLAG(IS_POSIX)
|
||||
env_(env),
|
||||
-#endif
|
||||
+ current_directory_(cwd),
|
||||
sandbox_type_(sandbox_type),
|
||||
- cmd_line_(cmd_line) {
|
||||
+ cmd_line_(cmd_line),
|
||||
+ inherit_environment_(inherit_environment) {
|
||||
#if DCHECK_IS_ON()
|
||||
bool supported_sandbox_type =
|
||||
sandbox_type_ == sandbox::mojom::Sandbox::kNoSandbox ||
|
||||
@@ -93,11 +95,17 @@ UtilitySandboxedProcessLauncherDelegate::GetSandboxType() {
|
||||
return sandbox_type_;
|
||||
}
|
||||
|
||||
-#if BUILDFLAG(IS_POSIX)
|
||||
base::EnvironmentMap UtilitySandboxedProcessLauncherDelegate::GetEnvironment() {
|
||||
return env_;
|
||||
}
|
||||
-#endif // BUILDFLAG(IS_POSIX)
|
||||
+
|
||||
+bool UtilitySandboxedProcessLauncherDelegate::ShouldInheritEnvironment() {
|
||||
+ return inherit_environment_;
|
||||
+}
|
||||
+
|
||||
+base::FilePath UtilitySandboxedProcessLauncherDelegate::GetCurrentDirectory() {
|
||||
+ return current_directory_;
|
||||
+}
|
||||
|
||||
#if BUILDFLAG(USE_ZYGOTE_HANDLE)
|
||||
ZygoteHandle UtilitySandboxedProcessLauncherDelegate::GetZygote() {
|
||||
diff --git a/content/browser/utility_sandbox_delegate.h b/content/browser/utility_sandbox_delegate.h
|
||||
index 41d93b41e7fff8ba4a7138d05035e4bc24b7a85b..20cb410fc71994e26cff6ac9801d42ebd11d9fee 100644
|
||||
--- a/content/browser/utility_sandbox_delegate.h
|
||||
+++ b/content/browser/utility_sandbox_delegate.h
|
||||
@@ -26,7 +26,9 @@ class UtilitySandboxedProcessLauncherDelegate
|
||||
public:
|
||||
UtilitySandboxedProcessLauncherDelegate(sandbox::mojom::Sandbox sandbox_type,
|
||||
const base::EnvironmentMap& env,
|
||||
- const base::CommandLine& cmd_line);
|
||||
+ const base::FilePath& cwd,
|
||||
+ const base::CommandLine& cmd_line,
|
||||
+ bool inherit_environment);
|
||||
~UtilitySandboxedProcessLauncherDelegate() override;
|
||||
|
||||
sandbox::mojom::Sandbox GetSandboxType() override;
|
||||
@@ -45,16 +47,16 @@ class UtilitySandboxedProcessLauncherDelegate
|
||||
ZygoteHandle GetZygote() override;
|
||||
#endif // BUILDFLAG(USE_ZYGOTE_HANDLE)
|
||||
|
||||
-#if BUILDFLAG(IS_POSIX)
|
||||
base::EnvironmentMap GetEnvironment() override;
|
||||
-#endif // BUILDFLAG(IS_POSIX)
|
||||
+ bool ShouldInheritEnvironment() override;
|
||||
+ base::FilePath GetCurrentDirectory() override;
|
||||
|
||||
private:
|
||||
-#if BUILDFLAG(IS_POSIX)
|
||||
base::EnvironmentMap env_;
|
||||
-#endif // BUILDFLAG(IS_POSIX)
|
||||
+ base::FilePath current_directory_;
|
||||
sandbox::mojom::Sandbox sandbox_type_;
|
||||
base::CommandLine cmd_line_;
|
||||
+ bool inherit_environment_;
|
||||
};
|
||||
} // namespace content
|
||||
|
||||
diff --git a/content/common/sandbox_init_win.cc b/content/common/sandbox_init_win.cc
|
||||
index 498f60227d13eb2e476413f88eaa58cc0babf461..b2d7a009477293bf73f3ae4a0c8452d1b1bf1dd8 100644
|
||||
--- a/content/common/sandbox_init_win.cc
|
||||
+++ b/content/common/sandbox_init_win.cc
|
||||
@@ -23,7 +23,7 @@ namespace content {
|
||||
sandbox::ResultCode StartSandboxedProcess(
|
||||
SandboxedProcessLauncherDelegate* delegate,
|
||||
const base::CommandLine& target_command_line,
|
||||
- const base::HandlesToInheritVector& handles_to_inherit,
|
||||
+ const base::LaunchOptions& options,
|
||||
base::Process* process) {
|
||||
std::string type_str =
|
||||
target_command_line.GetSwitchValueASCII(switches::kProcessType);
|
||||
@@ -45,7 +45,7 @@ sandbox::ResultCode StartSandboxedProcess(
|
||||
}
|
||||
|
||||
return sandbox::policy::SandboxWin::StartSandboxedProcess(
|
||||
- full_command_line, type_str, handles_to_inherit, delegate, process);
|
||||
+ full_command_line, type_str, options, delegate, process);
|
||||
}
|
||||
|
||||
} // namespace content
|
||||
diff --git a/content/public/browser/service_process_host.cc b/content/public/browser/service_process_host.cc
|
||||
index 6d25170e3badb65745c7dbea9c9664bdf8c91b0e..df79ba6137c8a9264ba32e4f9e1c1d7893e8f38a 100644
|
||||
--- a/content/public/browser/service_process_host.cc
|
||||
+++ b/content/public/browser/service_process_host.cc
|
||||
@@ -46,12 +46,45 @@ ServiceProcessHost::Options::WithExtraCommandLineSwitches(
|
||||
return *this;
|
||||
}
|
||||
|
||||
+#if BUILDFLAG(IS_WIN)
|
||||
+ServiceProcessHost::Options& ServiceProcessHost::Options::WithStdoutHandle(
|
||||
+ base::win::ScopedHandle handle) {
|
||||
+ stdout_handle = std::move(handle);
|
||||
+ return *this;
|
||||
+}
|
||||
+
|
||||
+ServiceProcessHost::Options& ServiceProcessHost::Options::WithStderrHandle(
|
||||
+ base::win::ScopedHandle handle) {
|
||||
+ stderr_handle = std::move(handle);
|
||||
+ return *this;
|
||||
+}
|
||||
+#elif BUILDFLAG(IS_POSIX)
|
||||
+ServiceProcessHost::Options& ServiceProcessHost::Options::WithAdditionalFds(
|
||||
+ base::FileHandleMappingVector mapping) {
|
||||
+ fds_to_remap = std::move(mapping);
|
||||
+ return *this;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
ServiceProcessHost::Options& ServiceProcessHost::Options::WithProcessCallback(
|
||||
base::OnceCallback<void(const base::Process&)> callback) {
|
||||
process_callback = std::move(callback);
|
||||
return *this;
|
||||
}
|
||||
|
||||
+ServiceProcessHost::Options& ServiceProcessHost::Options::WithCurrentDirectory(
|
||||
+ const base::FilePath& cwd) {
|
||||
+ current_directory = cwd;
|
||||
+ return *this;
|
||||
+}
|
||||
+
|
||||
+ServiceProcessHost::Options& ServiceProcessHost::Options::WithEnvironment(
|
||||
+ const base::EnvironmentMap& env, bool new_environment) {
|
||||
+ environment = env;
|
||||
+ clear_environment = new_environment;
|
||||
+ return *this;
|
||||
+}
|
||||
+
|
||||
ServiceProcessHost::Options ServiceProcessHost::Options::Pass() {
|
||||
return std::move(*this);
|
||||
}
|
||||
diff --git a/content/public/browser/service_process_host.h b/content/public/browser/service_process_host.h
|
||||
index a308d46612c1b30163cf9988117d2224a43ab5ad..5a41c3c907c0f0cf42759c52e7493cbf675f6fa6 100644
|
||||
--- a/content/public/browser/service_process_host.h
|
||||
+++ b/content/public/browser/service_process_host.h
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "base/callback.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/observer_list_types.h"
|
||||
+#include "base/process/launch.h"
|
||||
#include "base/process/process_handle.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "build/chromecast_buildflags.h"
|
||||
@@ -29,6 +30,10 @@
|
||||
#include "mojo/public/cpp/system/message_pipe.h"
|
||||
#endif
|
||||
|
||||
+#if BUILDFLAG(IS_WIN)
|
||||
+#include "base/win/scoped_handle.h"
|
||||
+#endif
|
||||
+
|
||||
namespace base {
|
||||
class Process;
|
||||
} // namespace base
|
||||
@@ -88,11 +93,30 @@ class CONTENT_EXPORT ServiceProcessHost {
|
||||
// Specifies extra command line switches to append before launch.
|
||||
Options& WithExtraCommandLineSwitches(std::vector<std::string> switches);
|
||||
|
||||
+#if BUILDFLAG(IS_WIN)
|
||||
+ // Specifies the handles for redirection of stdout and stderr.
|
||||
+ Options& WithStdoutHandle(base::win::ScopedHandle stdout_handle);
|
||||
+ Options& WithStderrHandle(base::win::ScopedHandle stderr_handle);
|
||||
+#elif BUILDFLAG(IS_POSIX)
|
||||
+ // Specifies file descriptors to propagate into the child process
|
||||
+ // based on the mapping.
|
||||
+ Options& WithAdditionalFds(base::FileHandleMappingVector mapping);
|
||||
+#endif
|
||||
+
|
||||
// Specifies a callback to be invoked with service process once it's
|
||||
// launched. Will be on UI thread.
|
||||
Options& WithProcessCallback(
|
||||
base::OnceCallback<void(const base::Process&)>);
|
||||
|
||||
+ // Specifies the working directory for the launched process.
|
||||
+ Options& WithCurrentDirectory(const base::FilePath& cwd);
|
||||
+
|
||||
+ // Specifies the environment that should be applied to the process.
|
||||
+ // |new_environment| controls whether the process should inherit
|
||||
+ // environment from the parent process.
|
||||
+ Options& WithEnvironment(const base::EnvironmentMap& environment,
|
||||
+ bool new_environment);
|
||||
+
|
||||
// Passes the contents of this Options object to a newly returned Options
|
||||
// value. This must be called when moving a built Options object into a call
|
||||
// to |Launch()|.
|
||||
@@ -101,7 +125,16 @@ class CONTENT_EXPORT ServiceProcessHost {
|
||||
std::u16string display_name;
|
||||
absl::optional<int> child_flags;
|
||||
std::vector<std::string> extra_switches;
|
||||
+#if BUILDFLAG(IS_WIN)
|
||||
+ base::win::ScopedHandle stdout_handle;
|
||||
+ base::win::ScopedHandle stderr_handle;
|
||||
+#elif BUILDFLAG(IS_POSIX)
|
||||
+ base::FileHandleMappingVector fds_to_remap;
|
||||
+#endif
|
||||
base::OnceCallback<void(const base::Process&)> process_callback;
|
||||
+ base::FilePath current_directory;
|
||||
+ base::EnvironmentMap environment;
|
||||
+ bool clear_environment = false;
|
||||
};
|
||||
|
||||
// An interface which can be implemented and registered/unregistered with
|
||||
diff --git a/content/public/common/sandbox_init_win.h b/content/public/common/sandbox_init_win.h
|
||||
index 9bb4b30ba0f5d37ec2b28f0848d94f34c24f9423..c19cceae4215d74ae74f6e6005125f326453f955 100644
|
||||
--- a/content/public/common/sandbox_init_win.h
|
||||
+++ b/content/public/common/sandbox_init_win.h
|
||||
@@ -29,7 +29,7 @@ class SandboxedProcessLauncherDelegate;
|
||||
CONTENT_EXPORT sandbox::ResultCode StartSandboxedProcess(
|
||||
SandboxedProcessLauncherDelegate* delegate,
|
||||
const base::CommandLine& target_command_line,
|
||||
- const base::HandlesToInheritVector& handles_to_inherit,
|
||||
+ const base::LaunchOptions& options,
|
||||
base::Process* process);
|
||||
|
||||
} // namespace content
|
||||
diff --git a/content/public/common/sandboxed_process_launcher_delegate.cc b/content/public/common/sandboxed_process_launcher_delegate.cc
|
||||
index ee7cdddba192f151346b74b68ef1eabe5f46e84a..4378d5ac7f455eb54f9f39364184649d7a63666f 100644
|
||||
--- a/content/public/common/sandboxed_process_launcher_delegate.cc
|
||||
+++ b/content/public/common/sandboxed_process_launcher_delegate.cc
|
||||
@@ -53,11 +53,17 @@ ZygoteHandle SandboxedProcessLauncherDelegate::GetZygote() {
|
||||
}
|
||||
#endif // BUILDFLAG(USE_ZYGOTE_HANDLE)
|
||||
|
||||
-#if BUILDFLAG(IS_POSIX)
|
||||
base::EnvironmentMap SandboxedProcessLauncherDelegate::GetEnvironment() {
|
||||
return base::EnvironmentMap();
|
||||
}
|
||||
-#endif // BUILDFLAG(IS_POSIX)
|
||||
+
|
||||
+bool SandboxedProcessLauncherDelegate::ShouldInheritEnvironment() {
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+base::FilePath SandboxedProcessLauncherDelegate::GetCurrentDirectory() {
|
||||
+ return base::FilePath();
|
||||
+}
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
|
||||
diff --git a/content/public/common/sandboxed_process_launcher_delegate.h b/content/public/common/sandboxed_process_launcher_delegate.h
|
||||
index 1e8f3994764a2b4e4efb87a08c522cc0e0103e18..83cc16ffbf484aa78b1c350d20a5a15ffd0dd0e8 100644
|
||||
--- a/content/public/common/sandboxed_process_launcher_delegate.h
|
||||
+++ b/content/public/common/sandboxed_process_launcher_delegate.h
|
||||
@@ -6,6 +6,7 @@
|
||||
#define CONTENT_PUBLIC_COMMON_SANDBOXED_PROCESS_LAUNCHER_DELEGATE_H_
|
||||
|
||||
#include "base/environment.h"
|
||||
+#include "base/files/file_path.h"
|
||||
#include "base/files/scoped_file.h"
|
||||
#include "base/process/process.h"
|
||||
#include "build/build_config.h"
|
||||
@@ -48,10 +49,14 @@ class CONTENT_EXPORT SandboxedProcessLauncherDelegate
|
||||
virtual ZygoteHandle GetZygote();
|
||||
#endif // BUILDFLAG(USE_ZYGOTE_HANDLE)
|
||||
|
||||
-#if BUILDFLAG(IS_POSIX)
|
||||
// Override this if the process needs a non-empty environment map.
|
||||
virtual base::EnvironmentMap GetEnvironment();
|
||||
-#endif // BUILDFLAG(IS_POSIX)
|
||||
+
|
||||
+ // Override this if the process should not inherit parent environment.
|
||||
+ virtual bool ShouldInheritEnvironment();
|
||||
+
|
||||
+ // Specifies the directory to change to before executing the process.
|
||||
+ virtual base::FilePath GetCurrentDirectory();
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
// Whether or not to disclaim TCC responsibility for the process, defaults to
|
||||
diff --git a/sandbox/policy/win/sandbox_win.cc b/sandbox/policy/win/sandbox_win.cc
|
||||
index 2191f51de17cfde5bb39f8231c8210dea6aa4fdd..6239f68771832d245d7270fd83e04f4fdce44032 100644
|
||||
--- a/sandbox/policy/win/sandbox_win.cc
|
||||
+++ b/sandbox/policy/win/sandbox_win.cc
|
||||
@@ -851,11 +851,9 @@ ResultCode GenerateConfigForSandboxedProcess(const base::CommandLine& cmd_line,
|
||||
// command line flag.
|
||||
ResultCode LaunchWithoutSandbox(
|
||||
const base::CommandLine& cmd_line,
|
||||
- const base::HandlesToInheritVector& handles_to_inherit,
|
||||
+ base::LaunchOptions options,
|
||||
SandboxDelegate* delegate,
|
||||
base::Process* process) {
|
||||
- base::LaunchOptions options;
|
||||
- options.handles_to_inherit = handles_to_inherit;
|
||||
// Network process runs in a job even when unsandboxed. This is to ensure it
|
||||
// does not outlive the browser, which could happen if there is a lot of I/O
|
||||
// on process shutdown, in which case TerminateProcess can fail. See
|
||||
@@ -1091,7 +1089,7 @@ bool SandboxWin::InitTargetServices(TargetServices* target_services) {
|
||||
ResultCode SandboxWin::GeneratePolicyForSandboxedProcess(
|
||||
const base::CommandLine& cmd_line,
|
||||
const std::string& process_type,
|
||||
- const base::HandlesToInheritVector& handles_to_inherit,
|
||||
+ const base::LaunchOptions& options,
|
||||
SandboxDelegate* delegate,
|
||||
TargetPolicy* policy) {
|
||||
const base::CommandLine& launcher_process_command_line =
|
||||
@@ -1105,7 +1103,7 @@ ResultCode SandboxWin::GeneratePolicyForSandboxedProcess(
|
||||
}
|
||||
|
||||
// Add any handles to be inherited to the policy.
|
||||
- for (HANDLE handle : handles_to_inherit)
|
||||
+ for (HANDLE handle : options.handles_to_inherit)
|
||||
policy->AddHandleToShare(handle);
|
||||
|
||||
if (!policy->GetConfig()->IsConfigured()) {
|
||||
@@ -1120,6 +1118,13 @@ ResultCode SandboxWin::GeneratePolicyForSandboxedProcess(
|
||||
// have no effect. These calls can fail with SBOX_ERROR_BAD_PARAMS.
|
||||
policy->SetStdoutHandle(GetStdHandle(STD_OUTPUT_HANDLE));
|
||||
policy->SetStderrHandle(GetStdHandle(STD_ERROR_HANDLE));
|
||||
+#else
|
||||
+ if (options.stdout_handle != nullptr && options.stdout_handle != INVALID_HANDLE_VALUE) {
|
||||
+ policy->SetStdoutHandle(options.stdout_handle);
|
||||
+ }
|
||||
+ if (options.stderr_handle != nullptr && options.stderr_handle != INVALID_HANDLE_VALUE) {
|
||||
+ policy->SetStderrHandle(options.stderr_handle);
|
||||
+ }
|
||||
#endif
|
||||
|
||||
if (!delegate->PreSpawnTarget(policy))
|
||||
@@ -1132,7 +1137,7 @@ ResultCode SandboxWin::GeneratePolicyForSandboxedProcess(
|
||||
ResultCode SandboxWin::StartSandboxedProcess(
|
||||
const base::CommandLine& cmd_line,
|
||||
const std::string& process_type,
|
||||
- const base::HandlesToInheritVector& handles_to_inherit,
|
||||
+ const base::LaunchOptions& options,
|
||||
SandboxDelegate* delegate,
|
||||
base::Process* process) {
|
||||
const base::ElapsedTimer timer;
|
||||
@@ -1140,7 +1145,7 @@ ResultCode SandboxWin::StartSandboxedProcess(
|
||||
// Avoid making a policy if we won't use it.
|
||||
if (IsUnsandboxedProcess(delegate->GetSandboxType(), cmd_line,
|
||||
*base::CommandLine::ForCurrentProcess())) {
|
||||
- return LaunchWithoutSandbox(cmd_line, handles_to_inherit, delegate,
|
||||
+ return LaunchWithoutSandbox(cmd_line, options, delegate,
|
||||
process);
|
||||
}
|
||||
|
||||
@@ -1151,7 +1156,7 @@ ResultCode SandboxWin::StartSandboxedProcess(
|
||||
auto policy = g_broker_services->CreatePolicy(tag);
|
||||
auto time_policy_created = timer.Elapsed();
|
||||
ResultCode result = GeneratePolicyForSandboxedProcess(
|
||||
- cmd_line, process_type, handles_to_inherit, delegate, policy.get());
|
||||
+ cmd_line, process_type, options, delegate, policy.get());
|
||||
if (SBOX_ALL_OK != result)
|
||||
return result;
|
||||
auto time_policy_generated = timer.Elapsed();
|
||||
diff --git a/sandbox/policy/win/sandbox_win.h b/sandbox/policy/win/sandbox_win.h
|
||||
index d1adadc10de3053f69fde39387d196054a96beda..0111a9c4becca009f17a3839d4d4bef3d9d880b8 100644
|
||||
--- a/sandbox/policy/win/sandbox_win.h
|
||||
+++ b/sandbox/policy/win/sandbox_win.h
|
||||
@@ -50,7 +50,7 @@ class SANDBOX_POLICY_EXPORT SandboxWin {
|
||||
static ResultCode StartSandboxedProcess(
|
||||
const base::CommandLine& cmd_line,
|
||||
const std::string& process_type,
|
||||
- const base::HandlesToInheritVector& handles_to_inherit,
|
||||
+ const base::LaunchOptions& options,
|
||||
SandboxDelegate* delegate,
|
||||
base::Process* process);
|
||||
|
||||
@@ -64,7 +64,7 @@ class SANDBOX_POLICY_EXPORT SandboxWin {
|
||||
static ResultCode GeneratePolicyForSandboxedProcess(
|
||||
const base::CommandLine& cmd_line,
|
||||
const std::string& process_type,
|
||||
- const base::HandlesToInheritVector& handles_to_inherit,
|
||||
+ const base::LaunchOptions& options,
|
||||
SandboxDelegate* delegate,
|
||||
TargetPolicy* policy);
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Samuel Attard <sattard@salesforce.com>
|
||||
Date: Thu, 29 Sep 2022 16:58:47 -0700
|
||||
Subject: feat: ensure mas builds of the same application can use safestorage
|
||||
|
||||
This change ensures that MAS builds of applications with an equivilant darwin build that share the same name do not fight over access to the same Safe Storage account.
|
||||
|
||||
Specifically this changes the account name for app "My App" from "My App" to "My App AppStore" if the app is using a MAS build of Electron.
|
||||
|
||||
We attempt to migrate the safe storage key from the old account, if that migration succeeds we delete the old key and move on.
|
||||
|
||||
Existing apps that aren't built for the app store should be unimpacted, there is one edge case where a user uses BOTH an AppStore and a darwin build of the same app only one will keep it's access to the safestorage key as during the migration we delete the old account. This is an acceptable edge case as no one should be actively using two versions of the same app.
|
||||
|
||||
diff --git a/components/os_crypt/keychain_password_mac.mm b/components/os_crypt/keychain_password_mac.mm
|
||||
index 214ae79b9a6de27b99ccfa9cf03327449fd79198..1b740e8dd19eeb34e68db30ba66ebadd1a132a39 100644
|
||||
--- a/components/os_crypt/keychain_password_mac.mm
|
||||
+++ b/components/os_crypt/keychain_password_mac.mm
|
||||
@@ -22,6 +22,12 @@
|
||||
using KeychainNameContainerType = const base::NoDestructor<std::string>;
|
||||
#endif
|
||||
|
||||
+#if defined(MAS_BUILD)
|
||||
+const char kAccountNameSuffix[] = " App Store Key";
|
||||
+#else
|
||||
+const char kAccountNameSuffix[] = " Key";
|
||||
+#endif
|
||||
+
|
||||
namespace {
|
||||
|
||||
// These two strings ARE indeed user facing. But they are used to access
|
||||
@@ -82,11 +88,18 @@
|
||||
std::string KeychainPassword::GetPassword() const {
|
||||
UInt32 password_length = 0;
|
||||
void* password_data = nullptr;
|
||||
+ KeychainPassword::KeychainNameType service_name = GetServiceName();
|
||||
+ KeychainPassword::KeychainNameType account_name = GetAccountName();
|
||||
+ const std::string account_name_suffix = kAccountNameSuffix;
|
||||
+ const std::string suffixed_account_name = account_name + account_name_suffix;
|
||||
+
|
||||
+ // We should check if the suffixed account exists first
|
||||
OSStatus error = keychain_.FindGenericPassword(
|
||||
- GetServiceName().size(), GetServiceName().c_str(),
|
||||
- GetAccountName().size(), GetAccountName().c_str(), &password_length,
|
||||
+ service_name.size(), service_name.c_str(),
|
||||
+ suffixed_account_name.size(), suffixed_account_name.c_str(), &password_length,
|
||||
&password_data, nullptr);
|
||||
|
||||
+ // If it exists we can return it immediately
|
||||
if (error == noErr) {
|
||||
std::string password =
|
||||
std::string(static_cast<char*>(password_data), password_length);
|
||||
@@ -94,9 +107,52 @@
|
||||
return password;
|
||||
}
|
||||
|
||||
+ // If the error was anything other than "it does not exist" we should error out here
|
||||
+ // This normally means the account exists but we were deniged access to it
|
||||
+ if (error != errSecItemNotFound) {
|
||||
+ OSSTATUS_LOG(ERROR, error) << "Keychain lookup for suffixed key failed";
|
||||
+ return std::string();
|
||||
+ }
|
||||
+
|
||||
+ // If the suffixed account didn't exist, we should check if the legacy non-suffixed account
|
||||
+ // exists. If it does we can use that key and migrate it to the new account
|
||||
+ base::ScopedCFTypeRef<SecKeychainItemRef> item_ref;
|
||||
+ error = keychain_.FindGenericPassword(
|
||||
+ service_name.size(), service_name.c_str(),
|
||||
+ account_name.size(), account_name.c_str(), &password_length,
|
||||
+ &password_data, item_ref.InitializeInto());
|
||||
+
|
||||
+ if (error == noErr) {
|
||||
+ std::string password =
|
||||
+ std::string(static_cast<char*>(password_data), password_length);
|
||||
+
|
||||
+ // If we found the legacy account name we should copy it over to
|
||||
+ // the new suffixed account
|
||||
+ error = keychain_.AddGenericPassword(
|
||||
+ service_name.size(), service_name.data(), suffixed_account_name.size(),
|
||||
+ suffixed_account_name.data(), password.size(), password_data, NULL);
|
||||
+
|
||||
+ if (error == noErr) {
|
||||
+ // If we successfully made the suffixed account we can delete the old
|
||||
+ // account to ensure new apps don't try to use it and run into IAM
|
||||
+ // issues
|
||||
+ error = keychain_.ItemDelete(item_ref.get());
|
||||
+ if (error != noErr) {
|
||||
+ OSSTATUS_DLOG(ERROR, error) << "Keychain delete for legacy key failed";
|
||||
+ }
|
||||
+ } else {
|
||||
+ OSSTATUS_DLOG(ERROR, error) << "Keychain add for suffixed key failed";
|
||||
+ }
|
||||
+
|
||||
+ keychain_.ItemFreeContent(password_data);
|
||||
+ return password;
|
||||
+ }
|
||||
+
|
||||
+ // If the legacy account name was not found, make a new account in the
|
||||
+ // with the suffixed name
|
||||
if (error == errSecItemNotFound) {
|
||||
std::string password = AddRandomPasswordToKeychain(
|
||||
- keychain_, GetServiceName(), GetAccountName());
|
||||
+ keychain_, service_name, suffixed_account_name);
|
||||
return password;
|
||||
}
|
||||
|
||||
@@ -103,10 +103,10 @@ index dd8e82d32cba09733b98f48ff08e750b4dec82d2..0680b97af6a933c060d759740da2a294
|
||||
string mime_type;
|
||||
|
||||
diff --git a/services/network/url_loader.cc b/services/network/url_loader.cc
|
||||
index 7e7032d83da30c95a01e5f240934a5aec81c8345..05095deaccf5ce111e3fc4ee4d304e17e55485a9 100644
|
||||
index 60a520d9f637a588d10e72239818fa5b862c9865..d3d1d572277605dddf2a2a2a78919bff92c00a22 100644
|
||||
--- a/services/network/url_loader.cc
|
||||
+++ b/services/network/url_loader.cc
|
||||
@@ -606,6 +606,7 @@ URLLoader::URLLoader(
|
||||
@@ -478,6 +478,7 @@ URLLoader::URLLoader(
|
||||
mojo::SimpleWatcher::ArmingPolicy::MANUAL,
|
||||
base::SequencedTaskRunnerHandle::Get()),
|
||||
per_factory_corb_state_(context.GetMutableCorbState()),
|
||||
@@ -114,7 +114,7 @@ index 7e7032d83da30c95a01e5f240934a5aec81c8345..05095deaccf5ce111e3fc4ee4d304e17
|
||||
devtools_request_id_(request.devtools_request_id),
|
||||
request_mode_(request.mode),
|
||||
request_credentials_mode_(request.credentials_mode),
|
||||
@@ -785,7 +786,7 @@ URLLoader::URLLoader(
|
||||
@@ -660,7 +661,7 @@ URLLoader::URLLoader(
|
||||
url_request_->SetRequestHeadersCallback(base::BindRepeating(
|
||||
&URLLoader::SetRawRequestHeadersAndNotify, base::Unretained(this)));
|
||||
|
||||
@@ -123,7 +123,7 @@ index 7e7032d83da30c95a01e5f240934a5aec81c8345..05095deaccf5ce111e3fc4ee4d304e17
|
||||
url_request_->SetResponseHeadersCallback(base::BindRepeating(
|
||||
&URLLoader::SetRawResponseHeaders, base::Unretained(this)));
|
||||
}
|
||||
@@ -1572,6 +1573,19 @@ void URLLoader::OnResponseStarted(net::URLRequest* url_request, int net_error) {
|
||||
@@ -1442,6 +1443,19 @@ void URLLoader::OnResponseStarted(net::URLRequest* url_request, int net_error) {
|
||||
}
|
||||
|
||||
response_ = BuildResponseHead();
|
||||
@@ -144,7 +144,7 @@ index 7e7032d83da30c95a01e5f240934a5aec81c8345..05095deaccf5ce111e3fc4ee4d304e17
|
||||
|
||||
// Parse and remove the Trust Tokens response headers, if any are expected,
|
||||
diff --git a/services/network/url_loader.h b/services/network/url_loader.h
|
||||
index 0cb0cc23cad280fd04dde13c8070d04ca2f886a0..e50b4f518da8fae47a76c26affcc7a5d2f07068f 100644
|
||||
index 9be9f703b189050332ca506dd3066609c3fa3992..1a15939f15fcc93de02cf0ff67faaefc5adbee53 100644
|
||||
--- a/services/network/url_loader.h
|
||||
+++ b/services/network/url_loader.h
|
||||
@@ -526,6 +526,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) URLLoader
|
||||
|
||||
@@ -13,10 +13,10 @@ This patch can be removed should we choose to support chrome.fileSystem
|
||||
or support it enough to fix the crash.
|
||||
|
||||
diff --git a/chrome/browser/resources/pdf/pdf_viewer.ts b/chrome/browser/resources/pdf/pdf_viewer.ts
|
||||
index faa76a4083ad33bf8262fa322b9bfdd885320e8f..5ef867b567fc8f1dd230ab46de7f8b3b05e47b38 100644
|
||||
index 05bb506868ffc2b72e57b348f10e868258297447..990336cc320135b27361494735a08a2284f95136 100644
|
||||
--- a/chrome/browser/resources/pdf/pdf_viewer.ts
|
||||
+++ b/chrome/browser/resources/pdf/pdf_viewer.ts
|
||||
@@ -860,26 +860,12 @@ export class PdfViewerElement extends PdfViewerBaseElement {
|
||||
@@ -865,26 +865,12 @@ export class PdfViewerElement extends PdfViewerBaseElement {
|
||||
dataArray = [result.dataToSave];
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ index faa76a4083ad33bf8262fa322b9bfdd885320e8f..5ef867b567fc8f1dd230ab46de7f8b3b
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -987,30 +973,12 @@ export class PdfViewerElement extends PdfViewerBaseElement {
|
||||
@@ -992,30 +978,12 @@ export class PdfViewerElement extends PdfViewerBaseElement {
|
||||
fileName = fileName + '.pdf';
|
||||
}
|
||||
|
||||
|
||||
@@ -50,10 +50,10 @@ upstream would also hit this DCHECK, so give it a try with content_shell or
|
||||
chrome and that would help reporting upstream crbug.
|
||||
|
||||
diff --git a/services/device/device_service.cc b/services/device/device_service.cc
|
||||
index e21ddc77480abc177b2c2afd76ccc0126b27ebb7..7db962d3bc076e9465b2e4e081122fd5bb2aa8d5 100644
|
||||
index eb9831586c92d5fbd90e075a8c32fa2e647edd82..c3bf4194fd97826aae8b9da5e0c91100081828c7 100644
|
||||
--- a/services/device/device_service.cc
|
||||
+++ b/services/device/device_service.cc
|
||||
@@ -159,7 +159,7 @@ DeviceService::~DeviceService() {
|
||||
@@ -158,7 +158,7 @@ DeviceService::~DeviceService() {
|
||||
// naturally sequenced after the last task on
|
||||
// |serial_port_manager_task_runner_| per ThreadPool shutdown semantics).
|
||||
// See crbug.com/1263149#c20 for details.
|
||||
|
||||
@@ -8,11 +8,11 @@ v8::Value instead of base::Value.
|
||||
Refs https://bugs.chromium.org/p/chromium/issues/detail?id=1323953
|
||||
|
||||
diff --git a/extensions/renderer/script_injection.cc b/extensions/renderer/script_injection.cc
|
||||
index 01d3ac55dbf4d366e660bbee1d964f21bc3182ac..9ead280cce1577f05ff3409f8b31bd0fb044eaea 100644
|
||||
index bbeec904936d05ef76a9e5de1dcd7159e5c0f364..4be3de364630e989f4ac956944362800d535ef73 100644
|
||||
--- a/extensions/renderer/script_injection.cc
|
||||
+++ b/extensions/renderer/script_injection.cc
|
||||
@@ -342,6 +342,7 @@ void ScriptInjection::InjectJs(std::set<std::string>* executing_scripts,
|
||||
blocking_option,
|
||||
@@ -331,6 +331,7 @@ void ScriptInjection::InjectJs(std::set<std::string>* executing_scripts,
|
||||
blink::mojom::LoadEventBlockingOption::kBlock,
|
||||
base::BindOnce(&ScriptInjection::OnJsInjectionCompleted,
|
||||
weak_ptr_factory_.GetWeakPtr()),
|
||||
+ base::NullCallback(),
|
||||
@@ -86,7 +86,7 @@ index 175b2a77d696a60fa8209809edc758912a11e83a..86cdb09f3d87cdc6970a288f50848c78
|
||||
|
||||
void LocalFrame::SetEvictCachedSessionStorageOnFreezeOrUnload() {
|
||||
diff --git a/third_party/blink/renderer/core/frame/local_frame.h b/third_party/blink/renderer/core/frame/local_frame.h
|
||||
index baac5c90c88991dc4b3ced175a8830f8d4cf1935..3b7f6a708fb41df297f9017daa6ec815ea1c418b 100644
|
||||
index 4296d020d3fa1b26b055dfd6140f8886b01e9493..cd42e9a71d1896b83ff6c556b3006cb1ca0af101 100644
|
||||
--- a/third_party/blink/renderer/core/frame/local_frame.h
|
||||
+++ b/third_party/blink/renderer/core/frame/local_frame.h
|
||||
@@ -762,6 +762,7 @@ class CORE_EXPORT LocalFrame final
|
||||
|
||||
@@ -20,7 +20,7 @@ index d1700997390777100002fb0a2f4a5fc0e961fb15..1a08dabef38c67b7ccfc5522e91b0322
|
||||
}
|
||||
|
||||
diff --git a/content/public/browser/content_browser_client.h b/content/public/browser/content_browser_client.h
|
||||
index 2dcea7a09b8521020e0821e18cbd45219caca639..0a128058163ec4adcdfb051d5c2e0f6c8394b81b 100644
|
||||
index 3f5f0449b7c70b7d48438d4c4c908c897cad3727..b00733238917b663909125e68a6fea84e060c9a8 100644
|
||||
--- a/content/public/browser/content_browser_client.h
|
||||
+++ b/content/public/browser/content_browser_client.h
|
||||
@@ -272,6 +272,11 @@ class CONTENT_EXPORT ContentBrowserClient {
|
||||
|
||||
@@ -11,7 +11,7 @@ If removing this patch causes no sync failures, it's safe to delete :+1:
|
||||
Ref https://chromium-review.googlesource.com/c/chromium/src/+/2953903
|
||||
|
||||
diff --git a/tools/clang/scripts/update.py b/tools/clang/scripts/update.py
|
||||
index a6adc31330f50a9495ef335b6c5d99e5d8f45e39..a85d5bb16ab0ce8a0193c54af282d49424a5b40b 100755
|
||||
index 24d1aff884305f2c5366a898e45632bdcd18f3ab..116765e717c22a550e21197dfd27145c08d36c41 100755
|
||||
--- a/tools/clang/scripts/update.py
|
||||
+++ b/tools/clang/scripts/update.py
|
||||
@@ -302,6 +302,8 @@ def GetDefaultHostOs():
|
||||
|
||||
@@ -9,7 +9,7 @@ but due to the nature of electron, we need to load the v8 snapshot
|
||||
in the browser process.
|
||||
|
||||
diff --git a/content/app/content_main_runner_impl.cc b/content/app/content_main_runner_impl.cc
|
||||
index e2f53860b9ea57e1a07f58a7490770a9b7517143..f55888577c514abe5ed64e8b88ff9f6e442815fd 100644
|
||||
index 6965f862853afa8ddebfbfc0ee766bcf7b0643a6..89cbfffe47ba6dbf6ba771b49a327ea69a3aede9 100644
|
||||
--- a/content/app/content_main_runner_impl.cc
|
||||
+++ b/content/app/content_main_runner_impl.cc
|
||||
@@ -261,11 +261,8 @@ void LoadV8SnapshotFile(const base::CommandLine& command_line) {
|
||||
|
||||
@@ -50,10 +50,10 @@ index 8d1b4e5bf4f95dc890a956b616860f955da5b929..9914fba92b472fbe52c1f14e695b2131
|
||||
|
||||
gfx::Size pixel_size_;
|
||||
diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.mm b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
|
||||
index 3bf9a1c4ca3fc41bc912852b291a1484da29e00a..eda48669fc091122004733d3585e2dc9cf81c35b 100644
|
||||
index 622ae164022f2e78f0591f81e6afdb6e7331cdd3..3c3e351c4d8da67a5b78bc359bb3b9ed0c898011 100644
|
||||
--- a/gpu/ipc/service/image_transport_surface_overlay_mac.mm
|
||||
+++ b/gpu/ipc/service/image_transport_surface_overlay_mac.mm
|
||||
@@ -61,6 +61,7 @@
|
||||
@@ -68,6 +68,7 @@
|
||||
ca_layer_tree_coordinator_ = std::make_unique<ui::CALayerTreeCoordinator>(
|
||||
use_remote_layer_api_, allow_av_sample_buffer_display_layer);
|
||||
|
||||
@@ -61,7 +61,7 @@ index 3bf9a1c4ca3fc41bc912852b291a1484da29e00a..eda48669fc091122004733d3585e2dc9
|
||||
// Create the CAContext to send this to the GPU process, and the layer for
|
||||
// the context.
|
||||
if (use_remote_layer_api_) {
|
||||
@@ -69,6 +70,7 @@
|
||||
@@ -76,6 +77,7 @@
|
||||
options:@{}] retain]);
|
||||
[ca_context_ setLayer:ca_layer_tree_coordinator_->GetCALayerForDisplay()];
|
||||
}
|
||||
@@ -69,7 +69,7 @@ index 3bf9a1c4ca3fc41bc912852b291a1484da29e00a..eda48669fc091122004733d3585e2dc9
|
||||
}
|
||||
|
||||
ImageTransportSurfaceOverlayMac::~ImageTransportSurfaceOverlayMac() {
|
||||
@@ -146,7 +148,9 @@
|
||||
@@ -153,7 +155,9 @@
|
||||
"GLImpl", static_cast<int>(gl::GetGLImplementation()),
|
||||
"width", pixel_size_.width());
|
||||
if (use_remote_layer_api_) {
|
||||
@@ -79,7 +79,7 @@ index 3bf9a1c4ca3fc41bc912852b291a1484da29e00a..eda48669fc091122004733d3585e2dc9
|
||||
} else {
|
||||
IOSurfaceRef io_surface =
|
||||
ca_layer_tree_coordinator_->GetIOSurfaceForDisplay();
|
||||
@@ -378,6 +382,7 @@
|
||||
@@ -385,6 +389,7 @@
|
||||
ca_layer_tree_coordinator_ = std::make_unique<ui::CALayerTreeCoordinator>(
|
||||
use_remote_layer_api_, allow_av_sample_buffer_display_layer);
|
||||
|
||||
@@ -87,7 +87,7 @@ index 3bf9a1c4ca3fc41bc912852b291a1484da29e00a..eda48669fc091122004733d3585e2dc9
|
||||
// Create the CAContext to send this to the GPU process, and the layer for
|
||||
// the context.
|
||||
if (use_remote_layer_api_) {
|
||||
@@ -386,6 +391,7 @@
|
||||
@@ -393,6 +398,7 @@
|
||||
options:@{}] retain]);
|
||||
[ca_context_ setLayer:ca_layer_tree_coordinator_->GetCALayerForDisplay()];
|
||||
}
|
||||
@@ -95,7 +95,7 @@ index 3bf9a1c4ca3fc41bc912852b291a1484da29e00a..eda48669fc091122004733d3585e2dc9
|
||||
}
|
||||
|
||||
ImageTransportSurfaceOverlayMacEGL::~ImageTransportSurfaceOverlayMacEGL() {
|
||||
@@ -464,7 +470,9 @@
|
||||
@@ -490,7 +496,9 @@
|
||||
"GLImpl", static_cast<int>(gl::GetGLImplementation()),
|
||||
"width", pixel_size_.width());
|
||||
if (use_remote_layer_api_) {
|
||||
|
||||
@@ -139,10 +139,10 @@ index a5974ea868cfca930794f522038844138a02b3ce..b1ac2fd235d3fc424d15b5c5991d7026
|
||||
|
||||
builder.SetCertVerifier(IgnoreErrorsCertVerifier::MaybeWrapCertVerifier(
|
||||
diff --git a/services/network/network_context.h b/services/network/network_context.h
|
||||
index 7a0d76107bf45fd4d1e638b9b66965c4ace4e893..5b0a62302719f2aca565d933be4391ce59894f01 100644
|
||||
index e6c3b62a0505b7dd83f77bde63264461446c770a..ae43559f383538f9a8ef168a592a6de416f1ded2 100644
|
||||
--- a/services/network/network_context.h
|
||||
+++ b/services/network/network_context.h
|
||||
@@ -102,6 +102,7 @@ class URLMatcher;
|
||||
@@ -103,6 +103,7 @@ class URLMatcher;
|
||||
|
||||
namespace network {
|
||||
class CertVerifierWithTrustAnchors;
|
||||
@@ -150,7 +150,7 @@ index 7a0d76107bf45fd4d1e638b9b66965c4ace4e893..5b0a62302719f2aca565d933be4391ce
|
||||
class CookieManager;
|
||||
class ExpectCTReporter;
|
||||
class HostResolver;
|
||||
@@ -238,6 +239,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
|
||||
@@ -239,6 +240,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
|
||||
void CreateURLLoaderFactory(
|
||||
mojo::PendingReceiver<mojom::URLLoaderFactory> receiver,
|
||||
mojom::URLLoaderFactoryParamsPtr params) override;
|
||||
@@ -159,7 +159,7 @@ index 7a0d76107bf45fd4d1e638b9b66965c4ace4e893..5b0a62302719f2aca565d933be4391ce
|
||||
void ResetURLLoaderFactories() override;
|
||||
void GetCookieManager(
|
||||
mojo::PendingReceiver<mojom::CookieManager> receiver) override;
|
||||
@@ -838,6 +841,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
|
||||
@@ -843,6 +846,8 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext
|
||||
std::vector<base::OnceClosure> dismount_closures_;
|
||||
#endif // BUILDFLAG(IS_DIRECTORY_TRANSFER_REQUIRED)
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ index dfbfbf4e5d92eb8c7c2ba38f31264ac41713a485..78cc81931321656c308e5611e30e0813
|
||||
const GURL& origin,
|
||||
const GURL& document_url,
|
||||
diff --git a/content/browser/notifications/blink_notification_service_impl.cc b/content/browser/notifications/blink_notification_service_impl.cc
|
||||
index a84465f5c59921a1febaf2015be71fb593eb92a5..0b8e0aea8ac663c22c327005cb95d3f19dd1200c 100644
|
||||
index f66c863b18da856b449eaf4fd8cf8202d34a2f10..55aecd359a7d375f64d2125e3c08d9ea50175cda 100644
|
||||
--- a/content/browser/notifications/blink_notification_service_impl.cc
|
||||
+++ b/content/browser/notifications/blink_notification_service_impl.cc
|
||||
@@ -83,11 +83,13 @@ BlinkNotificationServiceImpl::BlinkNotificationServiceImpl(
|
||||
@@ -49,7 +49,7 @@ index a84465f5c59921a1febaf2015be71fb593eb92a5..0b8e0aea8ac663c22c327005cb95d3f1
|
||||
service_worker_context_(std::move(service_worker_context)),
|
||||
render_process_host_id_(render_process_host->GetID()),
|
||||
@@ -152,7 +154,7 @@ void BlinkNotificationServiceImpl::DisplayNonPersistentNotification(
|
||||
notification_id, std::move(event_listener_remote));
|
||||
notification_id, std::move(event_listener_remote), weak_document_ptr_);
|
||||
|
||||
browser_context_->GetPlatformNotificationService()->DisplayNotification(
|
||||
- notification_id, origin_.GetURL(), document_url_,
|
||||
|
||||
@@ -796,7 +796,7 @@ index 51a5497b809cda82b223138f43507172a9f066ae..71227492fd87e577518f3bf55ded37b0
|
||||
#if BUILDFLAG(ENABLE_PRINT_PREVIEW)
|
||||
// Set options for print preset from source PDF document.
|
||||
diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn
|
||||
index a82ab440893d22424366c969d6765a10ee05ea86..a68bc27a93a38f5a1cb0c3dc225def6290dbf688 100644
|
||||
index 5a032fac280466c9e1498c4d629acbe0b0bb1ec6..3274b0331aaa077603e8ad10ca9fe4b3cebc3161 100644
|
||||
--- a/content/browser/BUILD.gn
|
||||
+++ b/content/browser/BUILD.gn
|
||||
@@ -2819,8 +2819,9 @@ source_set("browser") {
|
||||
@@ -812,7 +812,7 @@ index a82ab440893d22424366c969d6765a10ee05ea86..a68bc27a93a38f5a1cb0c3dc225def62
|
||||
if (is_chromeos) {
|
||||
sources += [
|
||||
diff --git a/content/browser/utility_sandbox_delegate_win.cc b/content/browser/utility_sandbox_delegate_win.cc
|
||||
index aa59ef2ea780af3e881be9a984eef5d309586dc4..c5bd3ed36ff3f4d1fe75ef2c6a1d40d655c0bbe0 100644
|
||||
index aa59ef2ea780af3e881be9a984eef5d309586dc4..fb5dcccf6d3f7cf9c18155319d87624432d92526 100644
|
||||
--- a/content/browser/utility_sandbox_delegate_win.cc
|
||||
+++ b/content/browser/utility_sandbox_delegate_win.cc
|
||||
@@ -99,6 +99,7 @@ bool NetworkPreSpawnTarget(sandbox::TargetConfig* config) {
|
||||
@@ -823,14 +823,14 @@ index aa59ef2ea780af3e881be9a984eef5d309586dc4..c5bd3ed36ff3f4d1fe75ef2c6a1d40d6
|
||||
// Sets the sandbox policy for the print backend service process.
|
||||
bool PrintBackendPreSpawnTarget(sandbox::TargetConfig* config) {
|
||||
DCHECK(!config->IsConfigured());
|
||||
@@ -192,6 +193,7 @@ bool XrCompositingPreSpawnTarget(sandbox::TargetConfig* config,
|
||||
|
||||
@@ -112,6 +113,7 @@ bool PrintBackendPreSpawnTarget(sandbox::TargetConfig* config) {
|
||||
config->SetDelayedIntegrityLevel(sandbox::INTEGRITY_LEVEL_LOW);
|
||||
return true;
|
||||
}
|
||||
+#endif
|
||||
} // namespace
|
||||
|
||||
std::string UtilitySandboxedProcessLauncherDelegate::GetSandboxTag() {
|
||||
std::string UtilityAppContainerId(base::CommandLine& cmd_line) {
|
||||
return base::WideToUTF8(cmd_line.GetProgram().value());
|
||||
diff --git a/printing/printing_context.cc b/printing/printing_context.cc
|
||||
index 3a9e75c229f028dcbfb2d7b9294bc42989cb4c1e..a890c5517c0708034bbc6b9b606c990a9ae8be7a 100644
|
||||
--- a/printing/printing_context.cc
|
||||
|
||||
@@ -10,7 +10,7 @@ kinds of utility windows. Similarly for `disableAutoHideCursor`.
|
||||
Additionally, disables usage of some private APIs in MAS builds.
|
||||
|
||||
diff --git a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
|
||||
index 1f5898124ca5ab45349dd4749c1b33a10723d46a..3c70ba4663b0176167a32e588dfd2840ba13362c 100644
|
||||
index 22b03d5bd27f09731a3c2d6dbb03c7dc612a2975..274a7e784af522b8f58c36095ca6c0cdadb97671 100644
|
||||
--- a/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
|
||||
+++ b/content/app_shim_remote_cocoa/render_widget_host_view_cocoa.mm
|
||||
@@ -158,6 +158,15 @@ void ExtractUnderlines(NSAttributedString* string,
|
||||
@@ -29,7 +29,7 @@ index 1f5898124ca5ab45349dd4749c1b33a10723d46a..3c70ba4663b0176167a32e588dfd2840
|
||||
// RenderWidgetHostViewCocoa ---------------------------------------------------
|
||||
|
||||
// Private methods:
|
||||
@@ -599,6 +608,9 @@ - (BOOL)acceptsMouseEventsWhenInactive {
|
||||
@@ -597,6 +606,9 @@ - (BOOL)acceptsMouseEventsWhenInactive {
|
||||
}
|
||||
|
||||
- (BOOL)acceptsFirstMouse:(NSEvent*)theEvent {
|
||||
@@ -39,7 +39,7 @@ index 1f5898124ca5ab45349dd4749c1b33a10723d46a..3c70ba4663b0176167a32e588dfd2840
|
||||
return [self acceptsMouseEventsWhenInactive];
|
||||
}
|
||||
|
||||
@@ -675,6 +687,10 @@ - (BOOL)shouldIgnoreMouseEvent:(NSEvent*)theEvent {
|
||||
@@ -673,6 +685,10 @@ - (BOOL)shouldIgnoreMouseEvent:(NSEvent*)theEvent {
|
||||
// its parent view.
|
||||
BOOL hitSelf = NO;
|
||||
while (view) {
|
||||
@@ -50,7 +50,7 @@ index 1f5898124ca5ab45349dd4749c1b33a10723d46a..3c70ba4663b0176167a32e588dfd2840
|
||||
if (view == self)
|
||||
hitSelf = YES;
|
||||
if ([view isKindOfClass:[self class]] && ![view isEqual:self] &&
|
||||
@@ -994,6 +1010,10 @@ - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv {
|
||||
@@ -992,6 +1008,10 @@ - (void)keyEvent:(NSEvent*)theEvent wasKeyEquivalent:(BOOL)equiv {
|
||||
eventType == NSEventTypeKeyDown &&
|
||||
!(modifierFlags & NSEventModifierFlagCommand);
|
||||
|
||||
@@ -61,7 +61,7 @@ index 1f5898124ca5ab45349dd4749c1b33a10723d46a..3c70ba4663b0176167a32e588dfd2840
|
||||
// We only handle key down events and just simply forward other events.
|
||||
if (eventType != NSEventTypeKeyDown) {
|
||||
_hostHelper->ForwardKeyboardEvent(event, latency_info);
|
||||
@@ -1818,9 +1838,11 @@ - (NSAccessibilityRole)accessibilityRole {
|
||||
@@ -1816,9 +1836,11 @@ - (NSAccessibilityRole)accessibilityRole {
|
||||
// Since this implementation doesn't have to wait any IPC calls, this doesn't
|
||||
// make any key-typing jank. --hbono 7/23/09
|
||||
//
|
||||
@@ -73,7 +73,7 @@ index 1f5898124ca5ab45349dd4749c1b33a10723d46a..3c70ba4663b0176167a32e588dfd2840
|
||||
|
||||
- (NSArray*)validAttributesForMarkedText {
|
||||
// This code is just copied from WebKit except renaming variables.
|
||||
@@ -1829,7 +1851,10 @@ - (NSArray*)validAttributesForMarkedText {
|
||||
@@ -1827,7 +1849,10 @@ - (NSArray*)validAttributesForMarkedText {
|
||||
initWithObjects:NSUnderlineStyleAttributeName,
|
||||
NSUnderlineColorAttributeName,
|
||||
NSMarkedClauseSegmentAttributeName,
|
||||
|
||||
@@ -14,7 +14,7 @@ Note that we also need to manually update embedder's
|
||||
`api::WebContents::IsFullscreenForTabOrPending` value.
|
||||
|
||||
diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
index 94690c49a771cb5ff873696bf0926972e7276d50..e6df759eff45383f809a98994bfae3b1d79807ef 100644
|
||||
index 7484975281bf5c19b1640c56ea6ad5f8a1add54a..674168c49840bf73512ec9fba7a91e4d8c49c7a0 100644
|
||||
--- a/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
+++ b/content/browser/renderer_host/render_frame_host_impl.cc
|
||||
@@ -6718,6 +6718,17 @@ void RenderFrameHostImpl::EnterFullscreen(
|
||||
|
||||
@@ -26,10 +26,10 @@ index 69e9da01fd70890a3df6c3c3959f87feb9ea316e..ce8cbdd6ce54bb2e0f1e6371679fc0d1
|
||||
// An empty URL is returned if the URL is not overriden.
|
||||
virtual GURL OverrideFlashEmbedWithHTML(const GURL& url);
|
||||
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc
|
||||
index 9a29b47834bd99129c73397e8873cedc8cf7f014..c3adc4563f0c5d8e50dc1f5acdd61f314b21493d 100644
|
||||
index 4cedfbfaa2f7b76a4add30f7d0859d6b59bb2c56..f934c18e385299682a66a3027f52460e1da20098 100644
|
||||
--- a/content/renderer/renderer_blink_platform_impl.cc
|
||||
+++ b/content/renderer/renderer_blink_platform_impl.cc
|
||||
@@ -867,6 +867,12 @@ void RendererBlinkPlatformImpl::WillStopWorkerThread() {
|
||||
@@ -876,6 +876,12 @@ void RendererBlinkPlatformImpl::WillStopWorkerThread() {
|
||||
WorkerThreadRegistry::Instance()->WillStopCurrentWorkerThread();
|
||||
}
|
||||
|
||||
@@ -43,10 +43,10 @@ index 9a29b47834bd99129c73397e8873cedc8cf7f014..c3adc4563f0c5d8e50dc1f5acdd61f31
|
||||
const v8::Local<v8::Context>& worker) {
|
||||
GetContentClient()->renderer()->DidInitializeWorkerContextOnWorkerThread(
|
||||
diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h
|
||||
index bb3be5a46b3dfd9f279c780d501a264cf4fc5be7..799cec3e793b1acf33864bea4d49b3544634781b 100644
|
||||
index 78ffa14e79f1294f5dc4731441d24905948dd2db..9561eed5d1e2234edbda8094b6c15af0c29d083b 100644
|
||||
--- a/content/renderer/renderer_blink_platform_impl.h
|
||||
+++ b/content/renderer/renderer_blink_platform_impl.h
|
||||
@@ -181,6 +181,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
|
||||
@@ -182,6 +182,7 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
|
||||
void DidStartWorkerThread() override;
|
||||
void WillStopWorkerThread() override;
|
||||
void WorkerContextCreated(const v8::Local<v8::Context>& worker) override;
|
||||
@@ -55,10 +55,10 @@ index bb3be5a46b3dfd9f279c780d501a264cf4fc5be7..799cec3e793b1acf33864bea4d49b354
|
||||
const blink::WebSecurityOrigin& script_origin) override;
|
||||
blink::ProtocolHandlerSecurityLevel GetProtocolHandlerSecurityLevel()
|
||||
diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h
|
||||
index 4bbd5c412ff46a865de52c07c0f91b2bd05ce476..9b4559f6dd51cec07a4fdc7da35ce645906f1a74 100644
|
||||
index bb82952036825aa6b19449956984cb3c90874af1..9550aee35d129c5cdd71de67150dfb70661414e6 100644
|
||||
--- a/third_party/blink/public/platform/platform.h
|
||||
+++ b/third_party/blink/public/platform/platform.h
|
||||
@@ -633,6 +633,7 @@ class BLINK_PLATFORM_EXPORT Platform {
|
||||
@@ -635,6 +635,7 @@ class BLINK_PLATFORM_EXPORT Platform {
|
||||
virtual void DidStartWorkerThread() {}
|
||||
virtual void WillStopWorkerThread() {}
|
||||
virtual void WorkerContextCreated(const v8::Local<v8::Context>& worker) {}
|
||||
@@ -67,12 +67,12 @@ index 4bbd5c412ff46a865de52c07c0f91b2bd05ce476..9b4559f6dd51cec07a4fdc7da35ce645
|
||||
const WebSecurityOrigin& script_origin) {
|
||||
return false;
|
||||
diff --git a/third_party/blink/renderer/core/workers/worker_thread.cc b/third_party/blink/renderer/core/workers/worker_thread.cc
|
||||
index 8bb4af88c478ba374682ee7fd56616336c1176b6..b5ab51bf0e8277794303046748ca43ed8cbcf9ba 100644
|
||||
index 8bf05b2789af3f7d2f6ecda9b7a6eb4abb84dbd6..b739ed97b190bce06b6c0f2bc12a1869fa590e39 100644
|
||||
--- a/third_party/blink/renderer/core/workers/worker_thread.cc
|
||||
+++ b/third_party/blink/renderer/core/workers/worker_thread.cc
|
||||
@@ -745,6 +745,12 @@ void WorkerThread::PrepareForShutdownOnWorkerThread() {
|
||||
nested_runner_->QuitNow();
|
||||
@@ -747,6 +747,12 @@ void WorkerThread::PrepareForShutdownOnWorkerThread() {
|
||||
}
|
||||
pause_handle_.reset();
|
||||
|
||||
+ {
|
||||
+ v8::HandleScope handle_scope(GetIsolate());
|
||||
|
||||
@@ -35,10 +35,10 @@ index ce8cbdd6ce54bb2e0f1e6371679fc0d1438ae69c..4de6b91b2f182be488249bf2a47b376a
|
||||
// from the worker thread.
|
||||
virtual void WillDestroyWorkerContextOnWorkerThread(
|
||||
diff --git a/content/renderer/renderer_blink_platform_impl.cc b/content/renderer/renderer_blink_platform_impl.cc
|
||||
index c3adc4563f0c5d8e50dc1f5acdd61f314b21493d..3460a40fb904ad0a976f53d5a53004692a75e380 100644
|
||||
index f934c18e385299682a66a3027f52460e1da20098..9bc3b562363f75ddbcb55ee1dd3e567a8f449b16 100644
|
||||
--- a/content/renderer/renderer_blink_platform_impl.cc
|
||||
+++ b/content/renderer/renderer_blink_platform_impl.cc
|
||||
@@ -879,6 +879,12 @@ void RendererBlinkPlatformImpl::WorkerContextCreated(
|
||||
@@ -888,6 +888,12 @@ void RendererBlinkPlatformImpl::WorkerContextCreated(
|
||||
worker);
|
||||
}
|
||||
|
||||
@@ -52,10 +52,10 @@ index c3adc4563f0c5d8e50dc1f5acdd61f314b21493d..3460a40fb904ad0a976f53d5a5300469
|
||||
const blink::WebSecurityOrigin& script_origin) {
|
||||
return GetContentClient()->renderer()->AllowScriptExtensionForServiceWorker(
|
||||
diff --git a/content/renderer/renderer_blink_platform_impl.h b/content/renderer/renderer_blink_platform_impl.h
|
||||
index 799cec3e793b1acf33864bea4d49b3544634781b..c4f354300035bede81187ba490178e717a448665 100644
|
||||
index 9561eed5d1e2234edbda8094b6c15af0c29d083b..b39e1d1783692ce787d6be8cc7ed59686b9cc78b 100644
|
||||
--- a/content/renderer/renderer_blink_platform_impl.h
|
||||
+++ b/content/renderer/renderer_blink_platform_impl.h
|
||||
@@ -181,6 +181,8 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
|
||||
@@ -182,6 +182,8 @@ class CONTENT_EXPORT RendererBlinkPlatformImpl : public BlinkPlatformImpl {
|
||||
void DidStartWorkerThread() override;
|
||||
void WillStopWorkerThread() override;
|
||||
void WorkerContextCreated(const v8::Local<v8::Context>& worker) override;
|
||||
@@ -65,10 +65,10 @@ index 799cec3e793b1acf33864bea4d49b3544634781b..c4f354300035bede81187ba490178e71
|
||||
bool AllowScriptExtensionForServiceWorker(
|
||||
const blink::WebSecurityOrigin& script_origin) override;
|
||||
diff --git a/third_party/blink/public/platform/platform.h b/third_party/blink/public/platform/platform.h
|
||||
index 9b4559f6dd51cec07a4fdc7da35ce645906f1a74..66f5268054cd00a8aa0f22cf5197a329b1ce38e5 100644
|
||||
index 9550aee35d129c5cdd71de67150dfb70661414e6..53f9b371d28a82ea20554bfd2ae04082047bf44b 100644
|
||||
--- a/third_party/blink/public/platform/platform.h
|
||||
+++ b/third_party/blink/public/platform/platform.h
|
||||
@@ -633,6 +633,8 @@ class BLINK_PLATFORM_EXPORT Platform {
|
||||
@@ -635,6 +635,8 @@ class BLINK_PLATFORM_EXPORT Platform {
|
||||
virtual void DidStartWorkerThread() {}
|
||||
virtual void WillStopWorkerThread() {}
|
||||
virtual void WorkerContextCreated(const v8::Local<v8::Context>& worker) {}
|
||||
|
||||
@@ -9,7 +9,7 @@ necessary for native modules to load.
|
||||
Also, some fixes relating to mksnapshot on ARM.
|
||||
|
||||
diff --git a/BUILD.gn b/BUILD.gn
|
||||
index bd6252bbce6c8232104b10a11395a83c272b3863..d6d3ab0cafe13334441594ab80cc62b46b79c50b 100644
|
||||
index 29eb0dc060063e0f68b16d5809e39ce2ebc8156e..f3a5b9f5d1e1dcb881497d793f982a8c38091bb4 100644
|
||||
--- a/BUILD.gn
|
||||
+++ b/BUILD.gn
|
||||
@@ -634,7 +634,7 @@ config("internal_config") {
|
||||
@@ -21,7 +21,7 @@ index bd6252bbce6c8232104b10a11395a83c272b3863..d6d3ab0cafe13334441594ab80cc62b4
|
||||
defines += [ "BUILDING_V8_SHARED" ]
|
||||
}
|
||||
|
||||
@@ -6072,7 +6072,7 @@ if (current_toolchain == v8_generator_toolchain) {
|
||||
@@ -6073,7 +6073,7 @@ if (current_toolchain == v8_generator_toolchain) {
|
||||
"src/interpreter/bytecodes.h",
|
||||
]
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ This patch can be safely removed if, when it is removed, `node.lib` does not
|
||||
contain any standard C++ library exports (e.g. `std::ostringstream`).
|
||||
|
||||
diff --git a/BUILD.gn b/BUILD.gn
|
||||
index cda24079b700d0cde451ef84cc2e19345040f32d..f4b89fe682b0454729a00b0e9c929b8e9af74d5d 100644
|
||||
index 12e322d66485ad174eb6cc7220296d0f8eb4655d..f481aaa18d18034b7f5ddd834820c2d065e39a83 100644
|
||||
--- a/BUILD.gn
|
||||
+++ b/BUILD.gn
|
||||
@@ -634,6 +634,10 @@ config("internal_config") {
|
||||
|
||||
@@ -6,10 +6,10 @@ Subject: expose_mksnapshot.patch
|
||||
Needed in order to target mksnapshot for mksnapshot zip.
|
||||
|
||||
diff --git a/BUILD.gn b/BUILD.gn
|
||||
index d6d3ab0cafe13334441594ab80cc62b46b79c50b..cda24079b700d0cde451ef84cc2e19345040f32d 100644
|
||||
index f3a5b9f5d1e1dcb881497d793f982a8c38091bb4..12e322d66485ad174eb6cc7220296d0f8eb4655d 100644
|
||||
--- a/BUILD.gn
|
||||
+++ b/BUILD.gn
|
||||
@@ -6084,7 +6084,6 @@ if (current_toolchain == v8_generator_toolchain) {
|
||||
@@ -6085,7 +6085,6 @@ if (current_toolchain == v8_generator_toolchain) {
|
||||
|
||||
if (current_toolchain == v8_snapshot_toolchain) {
|
||||
v8_executable("mksnapshot") {
|
||||
|
||||
@@ -18,7 +18,7 @@ index f58636fee555d782e18b7521c0c4f28ed60b3a52..6b0c63b34ff09f70cb9a4fe419f3b9bb
|
||||
StoreRoot(RootIndex::kCurrentMicrotask, microtask);
|
||||
TNode<IntPtrT> saved_entered_context_count = GetEnteredContextCount();
|
||||
diff --git a/src/codegen/code-stub-assembler.cc b/src/codegen/code-stub-assembler.cc
|
||||
index 68dd0da0750948d74bdcfeff4b25693e6d03855e..4b9bf906b90762749011ab7c21c43d9e862f1fda 100644
|
||||
index a069126f94daff6377dacc0e171e3ff27a0c176c..b5adde191992581f4aa052aec5a6587be9f9463c 100644
|
||||
--- a/src/codegen/code-stub-assembler.cc
|
||||
+++ b/src/codegen/code-stub-assembler.cc
|
||||
@@ -6257,12 +6257,6 @@ void CodeStubAssembler::SetPendingMessage(TNode<HeapObject> message) {
|
||||
|
||||
@@ -40,10 +40,6 @@ const main = async () => {
|
||||
{
|
||||
name: 'asar_bundle_deps',
|
||||
config: 'webpack.config.asar.js'
|
||||
},
|
||||
{
|
||||
name: 'utility_bundle_deps',
|
||||
config: 'webpack.config.utility.js'
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ const path = require('path');
|
||||
const semver = require('semver');
|
||||
|
||||
const outputPath = process.argv[2];
|
||||
const currentVersion = process.argv[3];
|
||||
|
||||
const currentVersion = fs.readFileSync(path.resolve(__dirname, '../ELECTRON_VERSION'), 'utf8').trim();
|
||||
|
||||
const parsed = semver.parse(currentVersion);
|
||||
|
||||
@@ -19,11 +20,9 @@ const {
|
||||
} = parsed;
|
||||
|
||||
fs.writeFileSync(outputPath, JSON.stringify({
|
||||
full_version: currentVersion,
|
||||
major,
|
||||
minor,
|
||||
patch,
|
||||
prerelease,
|
||||
prerelease_number: prerelease ? parsed.prerelease[parsed.prerelease.length - 1] : '0',
|
||||
has_prerelease: prerelease === '' ? 0 : 1
|
||||
}, null, 2));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const asar = require('@electron/asar');
|
||||
const asar = require('asar');
|
||||
const crypto = require('crypto');
|
||||
const fs = require('fs');
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const asar = require('@electron/asar');
|
||||
const asar = require('asar');
|
||||
const assert = require('assert');
|
||||
const fs = require('fs-extra');
|
||||
const os = require('os');
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
const { spawnSync } = require('child_process');
|
||||
const path = require('path');
|
||||
|
||||
module.exports.getElectronVersion = () => {
|
||||
// Find the nearest tag to the current HEAD
|
||||
// This is equivilant to our old logic of "use a value in package.json" for the following reasons
|
||||
//
|
||||
// 1. Whenever we updated the package.json we ALSO pushed a tag with the same version
|
||||
// 2. Whenever we _reverted_ a bump all we actually did was push a commit that deleted the tag and changed the version number back
|
||||
//
|
||||
// The only difference in the "git describe" technique is that technically a commit can "change" it's version
|
||||
// number if a tag is created / removed retroactively. i.e. the first time a commit is pushed it will be 1.2.3
|
||||
// and after the tag is made rebuilding the same commit will result in it being 1.2.4
|
||||
const output = spawnSync('git', ['describe', '--tags', '--abbrev=0'], {
|
||||
cwd: path.resolve(__dirname, '..', '..')
|
||||
});
|
||||
if (output.status !== 0) {
|
||||
console.error(output.stderr);
|
||||
throw new Error('Failed to get current electron version');
|
||||
}
|
||||
return output.stdout.toString().trim();
|
||||
};
|
||||
@@ -15,9 +15,7 @@ except ImportError:
|
||||
from urllib2 import urlopen
|
||||
import zipfile
|
||||
|
||||
# from lib.config import is_verbose_mode
|
||||
def is_verbose_mode():
|
||||
return False
|
||||
from lib.config import is_verbose_mode
|
||||
|
||||
ELECTRON_DIR = os.path.abspath(
|
||||
os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||
@@ -151,17 +149,11 @@ def get_electron_branding():
|
||||
with open(branding_file_path) as f:
|
||||
return json.load(f)
|
||||
|
||||
|
||||
cached_electron_version = None
|
||||
def get_electron_version():
|
||||
global cached_electron_version
|
||||
if cached_electron_version is None:
|
||||
cached_electron_version = str.strip(execute([
|
||||
'node',
|
||||
'-p',
|
||||
'require("./script/lib/get-version").getElectronVersion()'
|
||||
], cwd=ELECTRON_DIR).decode())
|
||||
return cached_electron_version
|
||||
SOURCE_ROOT = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
|
||||
version_file = os.path.join(SOURCE_ROOT, 'ELECTRON_VERSION')
|
||||
with open(version_file) as f:
|
||||
return 'v' + f.read().strip()
|
||||
|
||||
def store_artifact(prefix, key_prefix, files):
|
||||
# Azure Storage
|
||||
|
||||
@@ -181,7 +181,6 @@ const LINTERS = [{
|
||||
const patchesConfig = path.resolve(patchesDir, 'config.json');
|
||||
// If the config does not exist, that's a problem
|
||||
if (!fs.existsSync(patchesConfig)) {
|
||||
console.error(`Patches config file: "${patchesConfig}" does not exist`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
@@ -189,48 +188,34 @@ const LINTERS = [{
|
||||
for (const key of Object.keys(config)) {
|
||||
// The directory the config points to should exist
|
||||
const targetPatchesDir = path.resolve(__dirname, '../../..', key);
|
||||
if (!fs.existsSync(targetPatchesDir)) {
|
||||
console.error(`target patch directory: "${targetPatchesDir}" does not exist`);
|
||||
process.exit(1);
|
||||
}
|
||||
if (!fs.existsSync(targetPatchesDir)) throw new Error(`target patch directory: "${targetPatchesDir}" does not exist`);
|
||||
// We need a .patches file
|
||||
const dotPatchesPath = path.resolve(targetPatchesDir, '.patches');
|
||||
if (!fs.existsSync(dotPatchesPath)) {
|
||||
console.error(`.patches file: "${dotPatchesPath}" does not exist`);
|
||||
process.exit(1);
|
||||
}
|
||||
if (!fs.existsSync(dotPatchesPath)) throw new Error(`.patches file: "${dotPatchesPath}" does not exist`);
|
||||
|
||||
// Read the patch list
|
||||
const patchFileList = fs.readFileSync(dotPatchesPath, 'utf8').trim().split('\n');
|
||||
const patchFileSet = new Set(patchFileList);
|
||||
patchFileList.reduce((seen, file) => {
|
||||
if (seen.has(file)) {
|
||||
console.error(`'${file}' is listed in ${dotPatchesPath} more than once`);
|
||||
process.exit(1);
|
||||
throw new Error(`'${file}' is listed in ${dotPatchesPath} more than once`);
|
||||
}
|
||||
return seen.add(file);
|
||||
}, new Set());
|
||||
|
||||
if (patchFileList.length !== patchFileSet.size) {
|
||||
console.error('Each patch file should only be in the .patches file once');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (patchFileList.length !== patchFileSet.size) throw new Error('each patch file should only be in the .patches file once');
|
||||
for (const file of fs.readdirSync(targetPatchesDir)) {
|
||||
// Ignore the .patches file and READMEs
|
||||
if (file === '.patches' || file === 'README.md') continue;
|
||||
|
||||
if (!patchFileSet.has(file)) {
|
||||
console.error(`Expected the .patches file at "${dotPatchesPath}" to contain a patch file ("${file}") present in the directory but it did not`);
|
||||
process.exit(1);
|
||||
throw new Error(`Expected the .patches file at "${dotPatchesPath}" to contain a patch file ("${file}") present in the directory but it did not`);
|
||||
}
|
||||
patchFileSet.delete(file);
|
||||
}
|
||||
|
||||
// If anything is left in this set, it means it did not exist on disk
|
||||
if (patchFileSet.size > 0) {
|
||||
console.error(`Expected all the patch files listed in the .patches file at "${dotPatchesPath}" to exist but some did not:\n${JSON.stringify([...patchFileSet.values()], null, 2)}`);
|
||||
process.exit(1);
|
||||
throw new Error(`Expected all the patch files listed in the .patches file at "${dotPatchesPath}" to exist but some did not:\n${JSON.stringify([...patchFileSet.values()], null, 2)}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,8 +67,6 @@ async function main () {
|
||||
console.error(`Found ${missing.length} missing disabled specs: \n${missing.join('\n')}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const options = args.default ? defaultOptions : getCustomOptions();
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
from lib.util import get_electron_version
|
||||
|
||||
print(get_electron_version())
|
||||
@@ -6,7 +6,6 @@ const got = require('got');
|
||||
const semver = require('semver');
|
||||
|
||||
const { getCurrentBranch, ELECTRON_DIR } = require('../lib/utils');
|
||||
const { getElectronVersion } = require('../lib/get-version');
|
||||
const rootPackageJson = require('../../package.json');
|
||||
|
||||
const { Octokit } = require('@octokit/rest');
|
||||
@@ -35,6 +34,7 @@ const files = [
|
||||
|
||||
const jsonFields = [
|
||||
'name',
|
||||
'version',
|
||||
'repository',
|
||||
'description',
|
||||
'license',
|
||||
@@ -44,9 +44,6 @@ const jsonFields = [
|
||||
|
||||
let npmTag = '';
|
||||
|
||||
const currentElectronVersion = getElectronVersion();
|
||||
const isNightlyElectronVersion = currentElectronVersion.includes('nightly');
|
||||
|
||||
new Promise((resolve, reject) => {
|
||||
temp.mkdir('electron-npm', (err, dirPath) => {
|
||||
if (err) {
|
||||
@@ -71,7 +68,6 @@ new Promise((resolve, reject) => {
|
||||
jsonFields.forEach((fieldName) => {
|
||||
packageJson[fieldName] = rootPackageJson[fieldName];
|
||||
});
|
||||
packageJson.version = currentElectronVersion;
|
||||
fs.writeFileSync(
|
||||
path.join(tempDir, 'package.json'),
|
||||
JSON.stringify(packageJson, null, 2)
|
||||
@@ -79,27 +75,27 @@ new Promise((resolve, reject) => {
|
||||
|
||||
return octokit.repos.listReleases({
|
||||
owner: 'electron',
|
||||
repo: isNightlyElectronVersion ? 'nightlies' : 'electron'
|
||||
repo: rootPackageJson.version.indexOf('nightly') > 0 ? 'nightlies' : 'electron'
|
||||
});
|
||||
})
|
||||
.then((releases) => {
|
||||
// download electron.d.ts from release
|
||||
const release = releases.data.find(
|
||||
(release) => release.tag_name === `v${currentElectronVersion}`
|
||||
(release) => release.tag_name === `v${rootPackageJson.version}`
|
||||
);
|
||||
if (!release) {
|
||||
throw new Error(`cannot find release with tag v${currentElectronVersion}`);
|
||||
throw new Error(`cannot find release with tag v${rootPackageJson.version}`);
|
||||
}
|
||||
return release;
|
||||
})
|
||||
.then(async (release) => {
|
||||
const tsdAsset = release.assets.find((asset) => asset.name === 'electron.d.ts');
|
||||
if (!tsdAsset) {
|
||||
throw new Error(`cannot find electron.d.ts from v${currentElectronVersion} release assets`);
|
||||
throw new Error(`cannot find electron.d.ts from v${rootPackageJson.version} release assets`);
|
||||
}
|
||||
|
||||
const typingsContent = await getAssetContents(
|
||||
isNightlyElectronVersion ? 'nightlies' : 'electron',
|
||||
rootPackageJson.version.indexOf('nightly') > 0 ? 'nightlies' : 'electron',
|
||||
tsdAsset.id
|
||||
);
|
||||
|
||||
@@ -110,11 +106,11 @@ new Promise((resolve, reject) => {
|
||||
.then(async (release) => {
|
||||
const checksumsAsset = release.assets.find((asset) => asset.name === 'SHASUMS256.txt');
|
||||
if (!checksumsAsset) {
|
||||
throw new Error(`cannot find SHASUMS256.txt from v${currentElectronVersion} release assets`);
|
||||
throw new Error(`cannot find SHASUMS256.txt from v${rootPackageJson.version} release assets`);
|
||||
}
|
||||
|
||||
const checksumsContent = await getAssetContents(
|
||||
isNightlyElectronVersion ? 'nightlies' : 'electron',
|
||||
rootPackageJson.version.indexOf('nightly') > 0 ? 'nightlies' : 'electron',
|
||||
checksumsAsset.id
|
||||
);
|
||||
|
||||
@@ -131,7 +127,7 @@ new Promise((resolve, reject) => {
|
||||
.then(async (release) => {
|
||||
const currentBranch = await getCurrentBranch();
|
||||
|
||||
if (isNightlyElectronVersion) {
|
||||
if (release.tag_name.indexOf('nightly') > 0) {
|
||||
// TODO(main-migration): Simplify once main branch is renamed.
|
||||
if (currentBranch === 'master' || currentBranch === 'main') {
|
||||
// Nightlies get published to their own module, so they should be tagged as latest
|
||||
@@ -168,7 +164,7 @@ new Promise((resolve, reject) => {
|
||||
.then(() => childProcess.execSync('npm pack', { cwd: tempDir }))
|
||||
.then(() => {
|
||||
// test that the package can install electron prebuilt from github release
|
||||
const tarballPath = path.join(tempDir, `${rootPackageJson.name}-${currentElectronVersion}.tgz`);
|
||||
const tarballPath = path.join(tempDir, `${rootPackageJson.name}-${rootPackageJson.version}.tgz`);
|
||||
return new Promise((resolve, reject) => {
|
||||
const result = childProcess.spawnSync('npm', ['install', tarballPath, '--force', '--silent'], {
|
||||
env: { ...process.env, electron_config_cache: tempDir },
|
||||
@@ -194,7 +190,7 @@ new Promise((resolve, reject) => {
|
||||
});
|
||||
})
|
||||
.then((tarballPath) => {
|
||||
const existingVersionJSON = childProcess.execSync(`npm view electron@${currentElectronVersion} --json`).toString('utf-8');
|
||||
const existingVersionJSON = childProcess.execSync(`npm view electron@${rootPackageJson.version} --json`).toString('utf-8');
|
||||
// It's possible this is a re-run and we already have published the package, if not we just publish like normal
|
||||
if (!existingVersionJSON) {
|
||||
childProcess.execSync(`npm publish ${tarballPath} --tag ${npmTag} --otp=${process.env.ELECTRON_NPM_OTP}`);
|
||||
@@ -202,21 +198,22 @@ new Promise((resolve, reject) => {
|
||||
})
|
||||
.then(() => {
|
||||
const currentTags = JSON.parse(childProcess.execSync('npm show electron dist-tags --json').toString());
|
||||
const parsedLocalVersion = semver.parse(currentElectronVersion);
|
||||
const localVersion = rootPackageJson.version;
|
||||
const parsedLocalVersion = semver.parse(localVersion);
|
||||
if (rootPackageJson.name === 'electron') {
|
||||
// We should only customly add dist tags for non-nightly releases where the package name is still
|
||||
// "electron"
|
||||
if (parsedLocalVersion.prerelease.length === 0 &&
|
||||
semver.gt(currentElectronVersion, currentTags.latest)) {
|
||||
childProcess.execSync(`npm dist-tag add electron@${currentElectronVersion} latest --otp=${process.env.ELECTRON_NPM_OTP}`);
|
||||
semver.gt(localVersion, currentTags.latest)) {
|
||||
childProcess.execSync(`npm dist-tag add electron@${localVersion} latest --otp=${process.env.ELECTRON_NPM_OTP}`);
|
||||
}
|
||||
if (parsedLocalVersion.prerelease[0] === 'beta' &&
|
||||
semver.gt(currentElectronVersion, currentTags.beta)) {
|
||||
childProcess.execSync(`npm dist-tag add electron@${currentElectronVersion} beta --otp=${process.env.ELECTRON_NPM_OTP}`);
|
||||
semver.gt(localVersion, currentTags.beta)) {
|
||||
childProcess.execSync(`npm dist-tag add electron@${localVersion} beta --otp=${process.env.ELECTRON_NPM_OTP}`);
|
||||
}
|
||||
if (parsedLocalVersion.prerelease[0] === 'alpha' &&
|
||||
semver.gt(currentElectronVersion, currentTags.alpha)) {
|
||||
childProcess.execSync(`npm dist-tag add electron@${currentElectronVersion} alpha --otp=${process.env.ELECTRON_NPM_OTP}`);
|
||||
semver.gt(localVersion, currentTags.alpha)) {
|
||||
childProcess.execSync(`npm dist-tag add electron@${localVersion} alpha --otp=${process.env.ELECTRON_NPM_OTP}`);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -18,6 +18,26 @@ require('colors');
|
||||
const pass = '✓'.green;
|
||||
const fail = '✗'.red;
|
||||
|
||||
function getLastBumpCommit (tag) {
|
||||
const data = execSync(`git log -n1 --grep "Bump ${tag}" --format='format:{"hash": "%H", "message": "%s"}'`).toString();
|
||||
return JSON.parse(data);
|
||||
}
|
||||
|
||||
async function revertBumpCommit (tag) {
|
||||
const branch = await getCurrentBranch();
|
||||
const commitToRevert = getLastBumpCommit(tag).hash;
|
||||
await GitProcess.exec(['pull', '--rebase']);
|
||||
await GitProcess.exec(['revert', commitToRevert], ELECTRON_DIR);
|
||||
const pushDetails = await GitProcess.exec(['push', 'origin', `HEAD:${branch}`, '--follow-tags'], ELECTRON_DIR);
|
||||
if (pushDetails.exitCode === 0) {
|
||||
console.log(`${pass} successfully reverted release commit.`);
|
||||
} else {
|
||||
const error = GitProcess.parseError(pushDetails.stderr);
|
||||
console.error(`${fail} could not push release commit: `, error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteDraft (releaseId, targetRepo) {
|
||||
try {
|
||||
const result = await octokit.repos.getRelease({
|
||||
@@ -60,6 +80,9 @@ async function cleanReleaseArtifacts () {
|
||||
const releaseId = args.releaseID.length > 0 ? args.releaseID : null;
|
||||
const isNightly = args.tag.includes('nightly');
|
||||
|
||||
// try to revert commit regardless of tag and draft deletion status
|
||||
await revertBumpCommit(args.tag);
|
||||
|
||||
if (releaseId) {
|
||||
if (isNightly) {
|
||||
await deleteDraft(releaseId, 'nightlies');
|
||||
|
||||
@@ -12,6 +12,8 @@ const args = require('minimist')(process.argv.slice(2), {
|
||||
const fs = require('fs');
|
||||
const { execSync } = require('child_process');
|
||||
const got = require('got');
|
||||
const pkg = require('../../package.json');
|
||||
const pkgVersion = `v${pkg.version}`;
|
||||
const path = require('path');
|
||||
const temp = require('temp').track();
|
||||
const { URL } = require('url');
|
||||
@@ -23,11 +25,8 @@ const pass = '✓'.green;
|
||||
const fail = '✗'.red;
|
||||
|
||||
const { ELECTRON_DIR } = require('../lib/utils');
|
||||
const { getElectronVersion } = require('../lib/get-version');
|
||||
const getUrlHash = require('./get-url-hash');
|
||||
|
||||
const pkgVersion = `v${getElectronVersion()}`;
|
||||
|
||||
const octokit = new Octokit({
|
||||
auth: process.env.ELECTRON_GITHUB_TOKEN
|
||||
});
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const { GitProcess } = require('dugite');
|
||||
const { promises: fs } = require('fs');
|
||||
const semver = require('semver');
|
||||
const path = require('path');
|
||||
const minimist = require('minimist');
|
||||
|
||||
const { getElectronVersion } = require('../lib/get-version');
|
||||
const { ELECTRON_DIR } = require('../lib/utils');
|
||||
const versionUtils = require('./version-utils');
|
||||
const supported = path.resolve(ELECTRON_DIR, 'docs', 'tutorial', 'support.md');
|
||||
|
||||
const writeFile = fs.writeFile;
|
||||
const readFile = fs.readFile;
|
||||
|
||||
function parseCommandLine () {
|
||||
let help;
|
||||
@@ -30,7 +37,7 @@ function parseCommandLine () {
|
||||
// run the script
|
||||
async function main () {
|
||||
const opts = parseCommandLine();
|
||||
const currentVersion = getElectronVersion();
|
||||
const currentVersion = await versionUtils.getElectronVersion();
|
||||
const version = await nextVersion(opts.bump, currentVersion);
|
||||
|
||||
const parsed = semver.parse(version);
|
||||
@@ -47,6 +54,20 @@ async function main () {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (shouldUpdateSupported(opts.bump, currentVersion, version)) {
|
||||
await updateSupported(version, supported);
|
||||
}
|
||||
|
||||
// update all version-related files
|
||||
await Promise.all([
|
||||
updateVersion(version),
|
||||
updatePackageJSON(version),
|
||||
updateWinRC(components)
|
||||
]);
|
||||
|
||||
// commit all updated version-related files
|
||||
await commitVersionBump(version);
|
||||
|
||||
console.log(`Bumped to version: ${version}`);
|
||||
}
|
||||
|
||||
@@ -97,6 +118,10 @@ async function nextVersion (bumpType, version) {
|
||||
return version;
|
||||
}
|
||||
|
||||
function shouldUpdateSupported (bump, current, version) {
|
||||
return isMajorStable(bump, current) || isMajorNightly(version, current);
|
||||
}
|
||||
|
||||
function isMajorStable (bump, currentVersion) {
|
||||
if (versionUtils.isBeta(currentVersion) && (bump === 'stable')) return true;
|
||||
return false;
|
||||
@@ -109,6 +134,59 @@ function isMajorNightly (version, currentVersion) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// update VERSION file with latest release info
|
||||
async function updateVersion (version) {
|
||||
const versionPath = path.resolve(ELECTRON_DIR, 'ELECTRON_VERSION');
|
||||
await writeFile(versionPath, version, 'utf8');
|
||||
}
|
||||
|
||||
// update package metadata files with new version
|
||||
async function updatePackageJSON (version) {
|
||||
const filePath = path.resolve(ELECTRON_DIR, 'package.json');
|
||||
const file = require(filePath);
|
||||
file.version = version;
|
||||
await writeFile(filePath, JSON.stringify(file, null, 2));
|
||||
}
|
||||
|
||||
// push bump commit to release branch
|
||||
async function commitVersionBump (version) {
|
||||
const gitArgs = ['commit', '-a', '-m', `Bump v${version}`, '-n'];
|
||||
await GitProcess.exec(gitArgs, ELECTRON_DIR);
|
||||
}
|
||||
|
||||
// updates electron.rc file with new semver values
|
||||
async function updateWinRC (components) {
|
||||
const filePath = path.resolve(ELECTRON_DIR, 'shell', 'browser', 'resources', 'win', 'electron.rc');
|
||||
const data = await readFile(filePath, 'utf8');
|
||||
const arr = data.split('\n');
|
||||
arr.forEach((line, idx) => {
|
||||
if (line.includes('FILEVERSION')) {
|
||||
arr[idx] = ` FILEVERSION ${versionUtils.makeVersion(components, ',', versionUtils.preType.PARTIAL)}`;
|
||||
arr[idx + 1] = ` PRODUCTVERSION ${versionUtils.makeVersion(components, ',', versionUtils.preType.PARTIAL)}`;
|
||||
} else if (line.includes('FileVersion')) {
|
||||
arr[idx] = ` VALUE "FileVersion", "${versionUtils.makeVersion(components, '.')}"`;
|
||||
arr[idx + 5] = ` VALUE "ProductVersion", "${versionUtils.makeVersion(components, '.')}"`;
|
||||
}
|
||||
});
|
||||
await writeFile(filePath, arr.join('\n'));
|
||||
}
|
||||
|
||||
// updates support.md file with new semver values (stable only)
|
||||
async function updateSupported (version, filePath) {
|
||||
const v = parseInt(version);
|
||||
const newVersions = [`* ${v}.x.y`, `* ${v - 1}.x.y`, `* ${v - 2}.x.y`, `* ${v - 3}.x.y`];
|
||||
const contents = await readFile(filePath, 'utf8');
|
||||
const previousVersions = contents.split('\n').filter((elem) => {
|
||||
return (/[^\n]*\.x\.y[^\n]*/).test(elem);
|
||||
}, []);
|
||||
|
||||
const newContents = previousVersions.reduce((contents, current, i) => {
|
||||
return contents.replace(current, newVersions[i]);
|
||||
}, contents);
|
||||
|
||||
await writeFile(filePath, newContents, 'utf8');
|
||||
}
|
||||
|
||||
if (process.mainModule === module) {
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
@@ -116,4 +194,4 @@ if (process.mainModule === module) {
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = { nextVersion };
|
||||
module.exports = { nextVersion, shouldUpdateSupported, updateSupported };
|
||||
|
||||
@@ -68,6 +68,12 @@ async function nextBeta (v) {
|
||||
return tags.length === 0 ? `${next}-beta.1` : semver.inc(tags.pop(), 'prerelease');
|
||||
}
|
||||
|
||||
async function getElectronVersion () {
|
||||
const versionPath = path.resolve(ELECTRON_DIR, 'ELECTRON_VERSION');
|
||||
const version = await readFile(versionPath, 'utf8');
|
||||
return version.trim();
|
||||
}
|
||||
|
||||
async function nextNightly (v) {
|
||||
let next = semver.valid(semver.coerce(v));
|
||||
const pre = `nightly.${getCurrentDate()}`;
|
||||
@@ -108,6 +114,7 @@ module.exports = {
|
||||
nextAlpha,
|
||||
nextBeta,
|
||||
makeVersion,
|
||||
getElectronVersion,
|
||||
nextNightly,
|
||||
preType
|
||||
};
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
|
||||
#if BUILDFLAG(ENABLE_PLUGINS)
|
||||
#include "content/public/browser/plugin_service.h"
|
||||
#include "content/public/common/content_plugin_info.h"
|
||||
#include "ppapi/shared_impl/ppapi_permissions.h"
|
||||
#include "ppapi/shared_impl/ppapi_switches.h" // nogncheck crbug.com/1125897
|
||||
@@ -121,20 +120,6 @@ void ComputeBuiltInPlugins(std::vector<content::ContentPluginInfo>* plugins) {
|
||||
"Portable Document Format");
|
||||
pdf_info.mime_types.push_back(pdf_mime_type);
|
||||
plugins->push_back(pdf_info);
|
||||
|
||||
// NB. in Chrome, this plugin isn't registered until the PDF extension is
|
||||
// loaded. However, in Electron, we load the PDF extension unconditionally
|
||||
// when it is enabled in the build, so we're OK to load the plugin eagerly
|
||||
// here.
|
||||
content::WebPluginInfo info;
|
||||
info.type = content::WebPluginInfo::PLUGIN_TYPE_BROWSER_PLUGIN;
|
||||
info.name = base::ASCIIToUTF16(kPDFExtensionPluginName);
|
||||
// This isn't a real file path; it's just used as a unique identifier.
|
||||
info.path = base::FilePath::FromUTF8Unsafe(extension_misc::kPdfExtensionId);
|
||||
info.background_color = content::WebPluginInfo::kDefaultBackgroundColor;
|
||||
info.mime_types.emplace_back(kPDFMimeType, "pdf", "Portable Document Format");
|
||||
content::PluginService::GetInstance()->RefreshPlugins();
|
||||
content::PluginService::GetInstance()->RegisterInternalPlugin(info, true);
|
||||
#endif // BUILDFLAG(ENABLE_PDF_VIEWER)
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_PLUGINS)
|
||||
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "shell/app/command_line_args.h"
|
||||
#include "shell/browser/api/electron_api_menu.h"
|
||||
#include "shell/browser/api/electron_api_session.h"
|
||||
#include "shell/browser/api/electron_api_utility_process.h"
|
||||
#include "shell/browser/api/electron_api_web_contents.h"
|
||||
#include "shell/browser/api/gpuinfo_manager.h"
|
||||
#include "shell/browser/browser_process_impl.h"
|
||||
@@ -923,12 +922,6 @@ void App::BrowserChildProcessCrashedOrKilled(
|
||||
if (!data.name.empty()) {
|
||||
details.Set("name", data.name);
|
||||
}
|
||||
if (data.process_type == content::PROCESS_TYPE_UTILITY) {
|
||||
base::ProcessId pid = data.GetProcess().Pid();
|
||||
auto utility_process_wrapper = UtilityProcessWrapper::FromProcessId(pid);
|
||||
if (utility_process_wrapper)
|
||||
utility_process_wrapper->Shutdown(info.exit_code);
|
||||
}
|
||||
Emit("child-process-gone", details);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,16 +105,7 @@ void BrowserView::SetOwnerWindow(BaseWindow* window) {
|
||||
if (web_contents())
|
||||
web_contents()->SetOwnerWindow(window ? window->window() : nullptr);
|
||||
|
||||
if (owner_window_.get()) {
|
||||
owner_window_->window()->remove_inspectable_view(
|
||||
view_->GetInspectableWebContentsView());
|
||||
}
|
||||
|
||||
owner_window_ = window ? window->GetWeakPtr() : nullptr;
|
||||
|
||||
if (owner_window_.get() && view_->GetInspectableWebContentsView())
|
||||
owner_window_->window()->add_inspectable_view(
|
||||
view_->GetInspectableWebContentsView());
|
||||
}
|
||||
|
||||
BrowserView::~BrowserView() {
|
||||
@@ -132,10 +123,7 @@ void BrowserView::WebContentsDestroyed() {
|
||||
|
||||
void BrowserView::OnDraggableRegionsUpdated(
|
||||
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
||||
InspectableWebContentsView* iwc_view = view_->GetInspectableWebContentsView();
|
||||
if (!iwc_view)
|
||||
return;
|
||||
iwc_view->UpdateDraggableRegions(regions);
|
||||
view_->UpdateDraggableRegions(regions);
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -111,6 +111,11 @@ BrowserWindow::BrowserWindow(gin::Arguments* args,
|
||||
// Install the content view after BaseWindow's JS code is initialized.
|
||||
SetContentView(gin::CreateHandle<View>(isolate, web_contents_view.get()));
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
OverrideNSWindowContentView(
|
||||
web_contents->inspectable_web_contents()->GetView());
|
||||
#endif
|
||||
|
||||
// Init window after everything has been setup.
|
||||
window()->InitFromOptions(options);
|
||||
}
|
||||
@@ -159,10 +164,7 @@ void BrowserWindow::OnRendererResponsive(content::RenderProcessHost*) {
|
||||
|
||||
void BrowserWindow::OnDraggableRegionsUpdated(
|
||||
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
||||
if (window_->has_frame())
|
||||
return;
|
||||
|
||||
window_->UpdateDraggableRegions(regions);
|
||||
UpdateDraggableRegions(regions);
|
||||
}
|
||||
|
||||
void BrowserWindow::OnSetContentBounds(const gfx::Rect& rect) {
|
||||
@@ -215,8 +217,8 @@ void BrowserWindow::OnCloseButtonClicked(bool* prevent_default) {
|
||||
api_web_contents_->NotifyUserActivation();
|
||||
|
||||
// Trigger beforeunload events for associated BrowserViews.
|
||||
for (InspectableWebContentsView* view : window_->inspectable_views()) {
|
||||
auto* vwc = view->inspectable_web_contents()->GetWebContents();
|
||||
for (NativeBrowserView* view : window_->browser_views()) {
|
||||
auto* vwc = view->web_contents();
|
||||
auto* api_web_contents = api::WebContents::From(vwc);
|
||||
|
||||
// Required to make beforeunload handler work.
|
||||
@@ -266,6 +268,19 @@ void BrowserWindow::OnWindowIsKeyChanged(bool is_key) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrowserWindow::OnWindowResize() {
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
if (!draggable_regions_.empty()) {
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
} else {
|
||||
for (NativeBrowserView* view : window_->browser_views()) {
|
||||
view->UpdateDraggableRegions(view->GetDraggableRegions());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
BaseWindow::OnWindowResize();
|
||||
}
|
||||
|
||||
void BrowserWindow::OnWindowLeaveFullScreen() {
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
if (web_contents()->IsFullscreen())
|
||||
@@ -334,6 +349,42 @@ void BrowserWindow::SetBrowserView(
|
||||
BaseWindow::ResetBrowserViews();
|
||||
if (browser_view)
|
||||
BaseWindow::AddBrowserView(*browser_view);
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrowserWindow::AddBrowserView(gin::Handle<BrowserView> browser_view) {
|
||||
BaseWindow::AddBrowserView(browser_view);
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrowserWindow::RemoveBrowserView(gin::Handle<BrowserView> browser_view) {
|
||||
BaseWindow::RemoveBrowserView(browser_view);
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrowserWindow::SetTopBrowserView(gin::Handle<BrowserView> browser_view,
|
||||
gin_helper::Arguments* args) {
|
||||
BaseWindow::SetTopBrowserView(browser_view, args);
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrowserWindow::ResetBrowserViews() {
|
||||
BaseWindow::ResetBrowserViews();
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
#endif
|
||||
}
|
||||
|
||||
void BrowserWindow::OnDevToolsResized() {
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
}
|
||||
|
||||
void BrowserWindow::FocusOnWebView() {
|
||||
|
||||
@@ -57,6 +57,7 @@ class BrowserWindow : public BaseWindow,
|
||||
void OnActivateContents() override;
|
||||
void OnPageTitleUpdated(const std::u16string& title,
|
||||
bool explicit_set) override;
|
||||
void OnDevToolsResized() override;
|
||||
|
||||
// NativeWindowObserver:
|
||||
void RequestPreferredWidth(int* width) override;
|
||||
@@ -67,6 +68,7 @@ class BrowserWindow : public BaseWindow,
|
||||
// BaseWindow:
|
||||
void OnWindowBlur() override;
|
||||
void OnWindowFocus() override;
|
||||
void OnWindowResize() override;
|
||||
void OnWindowLeaveFullScreen() override;
|
||||
void CloseImmediately() override;
|
||||
void Focus() override;
|
||||
@@ -74,6 +76,11 @@ class BrowserWindow : public BaseWindow,
|
||||
void SetBackgroundColor(const std::string& color_name) override;
|
||||
void SetBrowserView(
|
||||
absl::optional<gin::Handle<BrowserView>> browser_view) override;
|
||||
void AddBrowserView(gin::Handle<BrowserView> browser_view) override;
|
||||
void RemoveBrowserView(gin::Handle<BrowserView> browser_view) override;
|
||||
void SetTopBrowserView(gin::Handle<BrowserView> browser_view,
|
||||
gin_helper::Arguments* args) override;
|
||||
void ResetBrowserViews() override;
|
||||
void OnWindowShow() override;
|
||||
void OnWindowHide() override;
|
||||
|
||||
@@ -88,6 +95,10 @@ class BrowserWindow : public BaseWindow,
|
||||
#endif
|
||||
|
||||
private:
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
void OverrideNSWindowContentView(InspectableWebContentsView* webView);
|
||||
#endif
|
||||
|
||||
// Helpers.
|
||||
|
||||
// Called when the window needs to update its draggable region.
|
||||
@@ -104,6 +115,8 @@ class BrowserWindow : public BaseWindow,
|
||||
// it should be cancelled when we can prove that the window is responsive.
|
||||
base::CancelableRepeatingClosure window_unresponsive_closure_;
|
||||
|
||||
std::vector<mojom::DraggableRegionPtr> draggable_regions_;
|
||||
|
||||
v8::Global<v8::Value> web_contents_;
|
||||
base::WeakPtr<api::WebContents> api_web_contents_;
|
||||
|
||||
|
||||
103
shell/browser/api/electron_api_browser_window_mac.mm
Normal file
103
shell/browser/api/electron_api_browser_window_mac.mm
Normal file
@@ -0,0 +1,103 @@
|
||||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/api/electron_api_browser_window.h"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "base/mac/scoped_nsobject.h"
|
||||
#include "shell/browser/native_browser_view.h"
|
||||
#include "shell/browser/native_window_mac.h"
|
||||
#include "shell/browser/ui/cocoa/electron_inspectable_web_contents_view.h"
|
||||
#include "shell/browser/ui/inspectable_web_contents_view.h"
|
||||
|
||||
namespace electron::api {
|
||||
|
||||
void BrowserWindow::OverrideNSWindowContentView(
|
||||
InspectableWebContentsView* view) {
|
||||
// Make NativeWindow use a NSView as content view.
|
||||
static_cast<NativeWindowMac*>(window())->OverrideNSWindowContentView();
|
||||
// Add webview to contentView.
|
||||
NSView* webView = view->GetNativeView().GetNativeNSView();
|
||||
NSView* contentView =
|
||||
[window()->GetNativeWindow().GetNativeNSWindow() contentView];
|
||||
[webView setFrame:[contentView bounds]];
|
||||
|
||||
// ensure that buttons view is floated to top of view hierarchy
|
||||
NSArray* subviews = [contentView subviews];
|
||||
NSView* last = subviews.lastObject;
|
||||
[contentView addSubview:webView positioned:NSWindowBelow relativeTo:last];
|
||||
|
||||
[contentView viewDidMoveToWindow];
|
||||
}
|
||||
|
||||
void BrowserWindow::UpdateDraggableRegions(
|
||||
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
||||
if (window_->has_frame() || !web_contents())
|
||||
return;
|
||||
|
||||
// All ControlRegionViews should be added as children of the WebContentsView,
|
||||
// because WebContentsView will be removed and re-added when entering and
|
||||
// leaving fullscreen mode.
|
||||
NSView* webView = web_contents()->GetNativeView().GetNativeNSView();
|
||||
NSInteger webViewWidth = NSWidth([webView bounds]);
|
||||
NSInteger webViewHeight = NSHeight([webView bounds]);
|
||||
|
||||
if ([webView respondsToSelector:@selector(setMouseDownCanMoveWindow:)]) {
|
||||
[webView setMouseDownCanMoveWindow:YES];
|
||||
}
|
||||
|
||||
// Remove all ControlRegionViews that are added last time.
|
||||
// Note that [webView subviews] returns the view's mutable internal array and
|
||||
// it should be copied to avoid mutating the original array while enumerating
|
||||
// it.
|
||||
base::scoped_nsobject<NSArray> subviews([[webView subviews] copy]);
|
||||
for (NSView* subview in subviews.get())
|
||||
if ([subview isKindOfClass:[ControlRegionView class]])
|
||||
[subview removeFromSuperview];
|
||||
|
||||
// Draggable regions are implemented by having the whole web view draggable
|
||||
// and overlaying regions that are not draggable.
|
||||
if (&draggable_regions_ != ®ions)
|
||||
draggable_regions_ = mojo::Clone(regions);
|
||||
|
||||
std::vector<gfx::Rect> drag_exclude_rects;
|
||||
if (regions.empty()) {
|
||||
drag_exclude_rects.emplace_back(0, 0, webViewWidth, webViewHeight);
|
||||
} else {
|
||||
drag_exclude_rects = CalculateNonDraggableRegions(
|
||||
DraggableRegionsToSkRegion(regions), webViewWidth, webViewHeight);
|
||||
}
|
||||
|
||||
// Draggable regions on BrowserViews are independent from those of
|
||||
// BrowserWindows, so if a BrowserView with different draggable regions than
|
||||
// the BrowserWindow it belongs to is superimposed on top of that window, the
|
||||
// draggable regions of the BrowserView take precedence over those of the
|
||||
// BrowserWindow.
|
||||
for (NativeBrowserView* view : window_->browser_views()) {
|
||||
view->UpdateDraggableRegions(view->GetDraggableRegions());
|
||||
}
|
||||
|
||||
// Create and add a ControlRegionView for each region that needs to be
|
||||
// excluded from the dragging.
|
||||
for (const auto& rect : drag_exclude_rects) {
|
||||
base::scoped_nsobject<NSView> controlRegion(
|
||||
[[ControlRegionView alloc] initWithFrame:NSZeroRect]);
|
||||
[controlRegion setFrame:NSMakeRect(rect.x(), webViewHeight - rect.bottom(),
|
||||
rect.width(), rect.height())];
|
||||
[webView addSubview:controlRegion];
|
||||
}
|
||||
|
||||
// AppKit will not update its cache of mouseDownCanMoveWindow unless something
|
||||
// changes. Previously we tried adding an NSView and removing it, but for some
|
||||
// reason it required reposting the mouse-down event, and didn't always work.
|
||||
// Calling the below seems to be an effective solution.
|
||||
[[webView window] setMovableByWindowBackground:NO];
|
||||
[[webView window] setMovableByWindowBackground:YES];
|
||||
}
|
||||
|
||||
} // namespace electron::api
|
||||
37
shell/browser/api/electron_api_browser_window_views.cc
Normal file
37
shell/browser/api/electron_api_browser_window_views.cc
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright (c) 2018 GitHub, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/api/electron_api_browser_window.h"
|
||||
|
||||
#include "content/browser/web_contents/web_contents_impl.h" // nogncheck
|
||||
#include "shell/browser/native_window_views.h"
|
||||
#include "ui/aura/window.h"
|
||||
|
||||
namespace electron::api {
|
||||
|
||||
void BrowserWindow::UpdateDraggableRegions(
|
||||
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
||||
if (window_->has_frame())
|
||||
return;
|
||||
|
||||
if (&draggable_regions_ != ®ions && web_contents()) {
|
||||
auto* view =
|
||||
static_cast<content::WebContentsImpl*>(web_contents())->GetView();
|
||||
if (view) {
|
||||
const gfx::NativeView nv = view->GetNativeView();
|
||||
auto const offset = nv->GetBoundsInRootWindow();
|
||||
auto snapped_regions = mojo::Clone(regions);
|
||||
for (auto& snapped_region : snapped_regions) {
|
||||
snapped_region->bounds.Offset(offset.x(), offset.y());
|
||||
}
|
||||
|
||||
draggable_regions_ = mojo::Clone(snapped_regions);
|
||||
}
|
||||
}
|
||||
|
||||
static_cast<NativeWindowViews*>(window_.get())
|
||||
->UpdateDraggableRegions(draggable_regions_);
|
||||
}
|
||||
|
||||
} // namespace electron::api
|
||||
@@ -1,420 +0,0 @@
|
||||
// Copyright (c) 2022 Microsoft, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/api/electron_api_utility_process.h"
|
||||
|
||||
#include <map>
|
||||
#include <utility>
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/process/kill.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/process/process.h"
|
||||
#include "content/public/browser/service_process_host.h"
|
||||
#include "content/public/common/child_process_host.h"
|
||||
#include "content/public/common/result_codes.h"
|
||||
#include "gin/handle.h"
|
||||
#include "gin/object_template_builder.h"
|
||||
#include "gin/wrappable.h"
|
||||
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
||||
#include "shell/browser/api/message_port.h"
|
||||
#include "shell/browser/javascript_environment.h"
|
||||
#include "shell/common/gin_converters/callback_converter.h"
|
||||
#include "shell/common/gin_converters/file_path_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "shell/common/gin_helper/object_template_builder.h"
|
||||
#include "shell/common/node_includes.h"
|
||||
#include "shell/common/v8_value_serializer.h"
|
||||
#include "third_party/blink/public/common/messaging/message_port_descriptor.h"
|
||||
#include "third_party/blink/public/common/messaging/transferable_message_mojom_traits.h"
|
||||
|
||||
#if BUILDFLAG(IS_POSIX)
|
||||
#include "base/posix/eintr_wrapper.h"
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
#include "base/win/windows_types.h"
|
||||
#endif
|
||||
|
||||
namespace electron {
|
||||
|
||||
base::IDMap<api::UtilityProcessWrapper*, base::ProcessId>&
|
||||
GetAllUtilityProcessWrappers() {
|
||||
static base::NoDestructor<
|
||||
base::IDMap<api::UtilityProcessWrapper*, base::ProcessId>>
|
||||
s_all_utility_process_wrappers;
|
||||
return *s_all_utility_process_wrappers;
|
||||
}
|
||||
|
||||
namespace api {
|
||||
|
||||
gin::WrapperInfo UtilityProcessWrapper::kWrapperInfo = {
|
||||
gin::kEmbedderNativeGin};
|
||||
|
||||
UtilityProcessWrapper::UtilityProcessWrapper(
|
||||
node::mojom::NodeServiceParamsPtr params,
|
||||
std::u16string display_name,
|
||||
std::map<IOHandle, IOType> stdio,
|
||||
base::EnvironmentMap env_map,
|
||||
base::FilePath current_working_directory,
|
||||
bool use_plugin_helper) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
base::win::ScopedHandle stdout_write(nullptr);
|
||||
base::win::ScopedHandle stderr_write(nullptr);
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
base::FileHandleMappingVector fds_to_remap;
|
||||
#endif
|
||||
for (const auto& [io_handle, io_type] : stdio) {
|
||||
if (io_type == IOType::IO_PIPE) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
HANDLE read = nullptr;
|
||||
HANDLE write = nullptr;
|
||||
// Ideally we would create with SECURITY_ATTRIBUTES.bInheritHandles
|
||||
// set to TRUE so that the write handle can be duplicated into the
|
||||
// child process for use,
|
||||
// See
|
||||
// https://learn.microsoft.com/en-us/windows/win32/procthread/inheritance#inheriting-handles
|
||||
// for inheritance behavior of child process. But we don't do it here
|
||||
// since base::Launch already takes of setting the
|
||||
// inherit attribute when configuring
|
||||
// `base::LaunchOptions::handles_to_inherit` Refs
|
||||
// https://source.chromium.org/chromium/chromium/src/+/main:base/process/launch_win.cc;l=303-332
|
||||
if (!::CreatePipe(&read, &write, nullptr, 0)) {
|
||||
PLOG(ERROR) << "pipe creation failed";
|
||||
return;
|
||||
}
|
||||
if (io_handle == IOHandle::STDOUT) {
|
||||
stdout_write.Set(write);
|
||||
stdout_read_handle_ = read;
|
||||
stdout_read_fd_ =
|
||||
_open_osfhandle(reinterpret_cast<intptr_t>(read), _O_RDONLY);
|
||||
} else if (io_handle == IOHandle::STDERR) {
|
||||
stderr_write.Set(write);
|
||||
stderr_read_handle_ = read;
|
||||
stderr_read_fd_ =
|
||||
_open_osfhandle(reinterpret_cast<intptr_t>(read), _O_RDONLY);
|
||||
}
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
int pipe_fd[2];
|
||||
if (HANDLE_EINTR(pipe(pipe_fd)) < 0) {
|
||||
PLOG(ERROR) << "pipe creation failed";
|
||||
return;
|
||||
}
|
||||
if (io_handle == IOHandle::STDOUT) {
|
||||
fds_to_remap.push_back(std::make_pair(pipe_fd[1], STDOUT_FILENO));
|
||||
stdout_read_fd_ = pipe_fd[0];
|
||||
} else if (io_handle == IOHandle::STDERR) {
|
||||
fds_to_remap.push_back(std::make_pair(pipe_fd[1], STDERR_FILENO));
|
||||
stderr_read_fd_ = pipe_fd[0];
|
||||
}
|
||||
#endif
|
||||
} else if (io_type == IOType::IO_IGNORE) {
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
HANDLE handle =
|
||||
CreateFileW(L"NUL", FILE_GENERIC_WRITE | FILE_READ_ATTRIBUTES,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
|
||||
OPEN_EXISTING, 0, nullptr);
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
PLOG(ERROR) << "Failed to create null handle";
|
||||
return;
|
||||
}
|
||||
if (io_handle == IOHandle::STDOUT) {
|
||||
stdout_write.Set(handle);
|
||||
} else if (io_handle == IOHandle::STDERR) {
|
||||
stderr_write.Set(handle);
|
||||
}
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
int devnull = open("/dev/null", O_WRONLY);
|
||||
if (devnull < 0) {
|
||||
PLOG(ERROR) << "failed to open /dev/null";
|
||||
return;
|
||||
}
|
||||
if (io_handle == IOHandle::STDOUT) {
|
||||
fds_to_remap.push_back(std::make_pair(devnull, STDOUT_FILENO));
|
||||
} else if (io_handle == IOHandle::STDERR) {
|
||||
fds_to_remap.push_back(std::make_pair(devnull, STDERR_FILENO));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
mojo::PendingReceiver<node::mojom::NodeService> receiver =
|
||||
node_service_remote_.BindNewPipeAndPassReceiver();
|
||||
|
||||
content::ServiceProcessHost::Launch(
|
||||
std::move(receiver),
|
||||
content::ServiceProcessHost::Options()
|
||||
.WithDisplayName(display_name.empty()
|
||||
? std::u16string(u"Node Utility Process")
|
||||
: display_name)
|
||||
.WithExtraCommandLineSwitches(params->exec_args)
|
||||
.WithCurrentDirectory(current_working_directory)
|
||||
// Inherit parent process environment when there is no custom
|
||||
// environment provided by the user.
|
||||
.WithEnvironment(env_map,
|
||||
env_map.empty() ? false : true /*clear_environment*/)
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
.WithStdoutHandle(std::move(stdout_write))
|
||||
.WithStderrHandle(std::move(stderr_write))
|
||||
#elif BUILDFLAG(IS_POSIX)
|
||||
.WithAdditionalFds(std::move(fds_to_remap))
|
||||
#endif
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
.WithChildFlags(use_plugin_helper
|
||||
? content::ChildProcessHost::CHILD_PLUGIN
|
||||
: content::ChildProcessHost::CHILD_NORMAL)
|
||||
#endif
|
||||
.WithProcessCallback(
|
||||
base::BindOnce(&UtilityProcessWrapper::OnServiceProcessLaunched,
|
||||
weak_factory_.GetWeakPtr()))
|
||||
.Pass());
|
||||
node_service_remote_.set_disconnect_with_reason_handler(
|
||||
base::BindOnce(&UtilityProcessWrapper::OnServiceProcessDisconnected,
|
||||
weak_factory_.GetWeakPtr()));
|
||||
|
||||
// We use a separate message pipe to support postMessage API
|
||||
// instead of the existing receiver interface so that we can
|
||||
// support queuing of messages without having to block other
|
||||
// interfaces.
|
||||
blink::MessagePortDescriptorPair pipe;
|
||||
host_port_ = pipe.TakePort0();
|
||||
params->port = pipe.TakePort1();
|
||||
connector_ = std::make_unique<mojo::Connector>(
|
||||
host_port_.TakeHandleToEntangleWithEmbedder(),
|
||||
mojo::Connector::SINGLE_THREADED_SEND,
|
||||
base::ThreadTaskRunnerHandle::Get());
|
||||
connector_->set_incoming_receiver(this);
|
||||
connector_->set_connection_error_handler(base::BindOnce(
|
||||
&UtilityProcessWrapper::CloseConnectorPort, weak_factory_.GetWeakPtr()));
|
||||
|
||||
node_service_remote_->Initialize(std::move(params));
|
||||
}
|
||||
|
||||
UtilityProcessWrapper::~UtilityProcessWrapper() = default;
|
||||
|
||||
void UtilityProcessWrapper::OnServiceProcessLaunched(
|
||||
const base::Process& process) {
|
||||
DCHECK(node_service_remote_.is_connected());
|
||||
pid_ = process.Pid();
|
||||
GetAllUtilityProcessWrappers().AddWithID(this, pid_);
|
||||
if (stdout_read_fd_ != -1) {
|
||||
EmitWithoutCustomEvent("stdout", stdout_read_fd_);
|
||||
}
|
||||
if (stderr_read_fd_ != -1) {
|
||||
EmitWithoutCustomEvent("stderr", stderr_read_fd_);
|
||||
}
|
||||
// Emit 'spawn' event
|
||||
EmitWithoutCustomEvent("spawn");
|
||||
}
|
||||
|
||||
void UtilityProcessWrapper::OnServiceProcessDisconnected(
|
||||
uint32_t error_code,
|
||||
const std::string& description) {
|
||||
if (pid_ != base::kNullProcessId)
|
||||
GetAllUtilityProcessWrappers().Remove(pid_);
|
||||
CloseConnectorPort();
|
||||
// Emit 'exit' event
|
||||
EmitWithoutCustomEvent("exit", error_code);
|
||||
Unpin();
|
||||
}
|
||||
|
||||
void UtilityProcessWrapper::CloseConnectorPort() {
|
||||
if (!connector_closed_ && connector_->is_valid()) {
|
||||
host_port_.GiveDisentangledHandle(connector_->PassMessagePipe());
|
||||
connector_ = nullptr;
|
||||
host_port_.Reset();
|
||||
connector_closed_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void UtilityProcessWrapper::Shutdown(int exit_code) {
|
||||
if (pid_ != base::kNullProcessId)
|
||||
GetAllUtilityProcessWrappers().Remove(pid_);
|
||||
node_service_remote_.reset();
|
||||
CloseConnectorPort();
|
||||
// Emit 'exit' event
|
||||
EmitWithoutCustomEvent("exit", exit_code);
|
||||
Unpin();
|
||||
}
|
||||
|
||||
void UtilityProcessWrapper::PostMessage(gin::Arguments* args) {
|
||||
if (!node_service_remote_.is_connected())
|
||||
return;
|
||||
|
||||
blink::TransferableMessage transferable_message;
|
||||
v8::Local<v8::Value> message_value;
|
||||
if (args->GetNext(&message_value)) {
|
||||
if (!electron::SerializeV8Value(args->isolate(), message_value,
|
||||
&transferable_message)) {
|
||||
// SerializeV8Value sets an exception.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> transferables;
|
||||
std::vector<gin::Handle<MessagePort>> wrapped_ports;
|
||||
if (args->GetNext(&transferables)) {
|
||||
if (!gin::ConvertFromV8(args->isolate(), transferables, &wrapped_ports)) {
|
||||
gin_helper::ErrorThrower(args->isolate())
|
||||
.ThrowTypeError("Invalid value for transfer");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool threw_exception = false;
|
||||
transferable_message.ports = MessagePort::DisentanglePorts(
|
||||
args->isolate(), wrapped_ports, &threw_exception);
|
||||
if (threw_exception)
|
||||
return;
|
||||
|
||||
mojo::Message mojo_message = blink::mojom::TransferableMessage::WrapAsMessage(
|
||||
std::move(transferable_message));
|
||||
connector_->Accept(&mojo_message);
|
||||
}
|
||||
|
||||
bool UtilityProcessWrapper::Kill() const {
|
||||
if (pid_ == base::kNullProcessId)
|
||||
return 0;
|
||||
base::Process process = base::Process::Open(pid_);
|
||||
bool result = process.Terminate(content::RESULT_CODE_NORMAL_EXIT, false);
|
||||
// Refs https://bugs.chromium.org/p/chromium/issues/detail?id=818244
|
||||
// Currently utility process is not sandboxed which
|
||||
// means Zygote is not used on linux, refs
|
||||
// content::UtilitySandboxedProcessLauncherDelegate::GetZygote.
|
||||
// If sandbox feature is enabled for the utility process, then the
|
||||
// process reap should be signaled through the zygote via
|
||||
// content::ZygoteCommunication::EnsureProcessTerminated.
|
||||
base::EnsureProcessTerminated(std::move(process));
|
||||
return result;
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> UtilityProcessWrapper::GetOSProcessId(
|
||||
v8::Isolate* isolate) const {
|
||||
if (pid_ == base::kNullProcessId)
|
||||
return v8::Undefined(isolate);
|
||||
return gin::ConvertToV8(isolate, pid_);
|
||||
}
|
||||
|
||||
bool UtilityProcessWrapper::Accept(mojo::Message* mojo_message) {
|
||||
blink::TransferableMessage message;
|
||||
if (!blink::mojom::TransferableMessage::DeserializeFromMessage(
|
||||
std::move(*mojo_message), &message)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
v8::Isolate* isolate = JavascriptEnvironment::GetIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Local<v8::Value> message_value =
|
||||
electron::DeserializeV8Value(isolate, message);
|
||||
EmitWithoutCustomEvent("message", message_value);
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
raw_ptr<UtilityProcessWrapper> UtilityProcessWrapper::FromProcessId(
|
||||
base::ProcessId pid) {
|
||||
auto* utility_process_wrapper = GetAllUtilityProcessWrappers().Lookup(pid);
|
||||
return !!utility_process_wrapper ? utility_process_wrapper : nullptr;
|
||||
}
|
||||
|
||||
// static
|
||||
gin::Handle<UtilityProcessWrapper> UtilityProcessWrapper::Create(
|
||||
gin::Arguments* args) {
|
||||
gin_helper::Dictionary dict;
|
||||
if (!args->GetNext(&dict)) {
|
||||
args->ThrowTypeError("Options must be an object.");
|
||||
return gin::Handle<UtilityProcessWrapper>();
|
||||
}
|
||||
|
||||
std::u16string display_name;
|
||||
bool use_plugin_helper = false;
|
||||
std::map<IOHandle, IOType> stdio;
|
||||
base::FilePath current_working_directory;
|
||||
base::EnvironmentMap env_map;
|
||||
node::mojom::NodeServiceParamsPtr params =
|
||||
node::mojom::NodeServiceParams::New();
|
||||
dict.Get("modulePath", ¶ms->script);
|
||||
if (dict.Has("args") && !dict.Get("args", ¶ms->args)) {
|
||||
args->ThrowTypeError("Invalid value for args");
|
||||
return gin::Handle<UtilityProcessWrapper>();
|
||||
}
|
||||
|
||||
gin_helper::Dictionary opts;
|
||||
if (dict.Get("options", &opts)) {
|
||||
if (opts.Has("env") && !opts.Get("env", &env_map)) {
|
||||
args->ThrowTypeError("Invalid value for env");
|
||||
return gin::Handle<UtilityProcessWrapper>();
|
||||
}
|
||||
|
||||
if (opts.Has("execArgv") && !opts.Get("execArgv", ¶ms->exec_args)) {
|
||||
args->ThrowTypeError("Invalid value for execArgv");
|
||||
return gin::Handle<UtilityProcessWrapper>();
|
||||
}
|
||||
|
||||
opts.Get("serviceName", &display_name);
|
||||
opts.Get("cwd", ¤t_working_directory);
|
||||
|
||||
std::vector<std::string> stdio_arr{"ignore", "inherit", "inherit"};
|
||||
opts.Get("stdio", &stdio_arr);
|
||||
for (size_t i = 0; i < 3; i++) {
|
||||
IOType type;
|
||||
if (stdio_arr[i] == "ignore")
|
||||
type = IOType::IO_IGNORE;
|
||||
else if (stdio_arr[i] == "inherit")
|
||||
type = IOType::IO_INHERIT;
|
||||
else if (stdio_arr[i] == "pipe")
|
||||
type = IOType::IO_PIPE;
|
||||
|
||||
stdio.emplace(static_cast<IOHandle>(i), type);
|
||||
}
|
||||
|
||||
#if BUILDFLAG(IS_MAC)
|
||||
opts.Get("allowLoadingUnsignedLibraries", &use_plugin_helper);
|
||||
#endif
|
||||
}
|
||||
auto handle = gin::CreateHandle(
|
||||
args->isolate(),
|
||||
new UtilityProcessWrapper(std::move(params), display_name,
|
||||
std::move(stdio), env_map,
|
||||
current_working_directory, use_plugin_helper));
|
||||
handle->Pin(args->isolate());
|
||||
return handle;
|
||||
}
|
||||
|
||||
// static
|
||||
gin::ObjectTemplateBuilder UtilityProcessWrapper::GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) {
|
||||
return gin_helper::EventEmitterMixin<
|
||||
UtilityProcessWrapper>::GetObjectTemplateBuilder(isolate)
|
||||
.SetMethod("postMessage", &UtilityProcessWrapper::PostMessage)
|
||||
.SetMethod("kill", &UtilityProcessWrapper::Kill)
|
||||
.SetProperty("pid", &UtilityProcessWrapper::GetOSProcessId);
|
||||
}
|
||||
|
||||
const char* UtilityProcessWrapper::GetTypeName() {
|
||||
return "UtilityProcessWrapper";
|
||||
}
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace electron
|
||||
|
||||
namespace {
|
||||
|
||||
void Initialize(v8::Local<v8::Object> exports,
|
||||
v8::Local<v8::Value> unused,
|
||||
v8::Local<v8::Context> context,
|
||||
void* priv) {
|
||||
v8::Isolate* isolate = context->GetIsolate();
|
||||
gin_helper::Dictionary dict(isolate, exports);
|
||||
dict.SetMethod("_fork", &electron::api::UtilityProcessWrapper::Create);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
NODE_LINKED_MODULE_CONTEXT_AWARE(electron_browser_utility_process, Initialize)
|
||||
@@ -1,100 +0,0 @@
|
||||
// Copyright (c) 2022 Microsoft, Inc.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_UTILITY_PROCESS_H_
|
||||
#define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_UTILITY_PROCESS_H_
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/id_map.h"
|
||||
#include "base/environment.h"
|
||||
#include "base/memory/weak_ptr.h"
|
||||
#include "base/process/process_handle.h"
|
||||
#include "gin/wrappable.h"
|
||||
#include "mojo/public/cpp/bindings/connector.h"
|
||||
#include "mojo/public/cpp/bindings/message.h"
|
||||
#include "mojo/public/cpp/bindings/remote.h"
|
||||
#include "shell/browser/event_emitter_mixin.h"
|
||||
#include "shell/common/gin_helper/pinnable.h"
|
||||
#include "shell/services/node/public/mojom/node_service.mojom.h"
|
||||
#include "v8/include/v8.h"
|
||||
|
||||
namespace gin {
|
||||
class Arguments;
|
||||
template <typename T>
|
||||
class Handle;
|
||||
} // namespace gin
|
||||
|
||||
namespace base {
|
||||
class Process;
|
||||
} // namespace base
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace api {
|
||||
|
||||
class UtilityProcessWrapper
|
||||
: public gin::Wrappable<UtilityProcessWrapper>,
|
||||
public gin_helper::Pinnable<UtilityProcessWrapper>,
|
||||
public gin_helper::EventEmitterMixin<UtilityProcessWrapper>,
|
||||
public mojo::MessageReceiver {
|
||||
public:
|
||||
enum class IOHandle : size_t { STDIN = 0, STDOUT = 1, STDERR = 2 };
|
||||
enum class IOType { IO_PIPE, IO_INHERIT, IO_IGNORE };
|
||||
|
||||
~UtilityProcessWrapper() override;
|
||||
static gin::Handle<UtilityProcessWrapper> Create(gin::Arguments* args);
|
||||
static raw_ptr<UtilityProcessWrapper> FromProcessId(base::ProcessId pid);
|
||||
|
||||
void Shutdown(int exit_code);
|
||||
|
||||
// gin::Wrappable
|
||||
static gin::WrapperInfo kWrapperInfo;
|
||||
gin::ObjectTemplateBuilder GetObjectTemplateBuilder(
|
||||
v8::Isolate* isolate) override;
|
||||
const char* GetTypeName() override;
|
||||
|
||||
private:
|
||||
UtilityProcessWrapper(node::mojom::NodeServiceParamsPtr params,
|
||||
std::u16string display_name,
|
||||
std::map<IOHandle, IOType> stdio,
|
||||
base::EnvironmentMap env_map,
|
||||
base::FilePath current_working_directory,
|
||||
bool use_plugin_helper);
|
||||
void OnServiceProcessDisconnected(uint32_t error_code,
|
||||
const std::string& description);
|
||||
void OnServiceProcessLaunched(const base::Process& process);
|
||||
void CloseConnectorPort();
|
||||
|
||||
void PostMessage(gin::Arguments* args);
|
||||
bool Kill() const;
|
||||
v8::Local<v8::Value> GetOSProcessId(v8::Isolate* isolate) const;
|
||||
|
||||
// mojo::MessageReceiver
|
||||
bool Accept(mojo::Message* mojo_message) override;
|
||||
|
||||
base::ProcessId pid_ = base::kNullProcessId;
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// Non-owning handles, these will be closed when the
|
||||
// corresponding FD are closed via _close.
|
||||
HANDLE stdout_read_handle_;
|
||||
HANDLE stderr_read_handle_;
|
||||
#endif
|
||||
int stdout_read_fd_ = -1;
|
||||
int stderr_read_fd_ = -1;
|
||||
bool connector_closed_ = false;
|
||||
std::unique_ptr<mojo::Connector> connector_;
|
||||
blink::MessagePortDescriptor host_port_;
|
||||
mojo::Remote<node::mojom::NodeService> node_service_remote_;
|
||||
base::WeakPtrFactory<UtilityProcessWrapper> weak_factory_{this};
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
} // namespace electron
|
||||
|
||||
#endif // ELECTRON_SHELL_BROWSER_API_ELECTRON_API_UTILITY_PROCESS_H_
|
||||
@@ -172,7 +172,6 @@
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
#include "chrome/browser/printing/print_view_manager_base.h"
|
||||
#include "components/printing/browser/print_manager_utils.h"
|
||||
#include "components/printing/browser/print_to_pdf/pdf_print_result.h"
|
||||
#include "components/printing/browser/print_to_pdf/pdf_print_utils.h"
|
||||
#include "printing/backend/print_backend.h" // nogncheck
|
||||
#include "printing/mojom/print.mojom.h" // nogncheck
|
||||
@@ -387,13 +386,11 @@ base::IDMap<WebContents*>& GetAllWebContents() {
|
||||
return *s_all_web_contents;
|
||||
}
|
||||
|
||||
// Called when CapturePage is done.
|
||||
void OnCapturePageDone(gin_helper::Promise<gfx::Image> promise,
|
||||
base::ScopedClosureRunner capture_handle,
|
||||
const SkBitmap& bitmap) {
|
||||
// Hack to enable transparency in captured image
|
||||
promise.Resolve(gfx::Image::CreateFrom1xBitmap(bitmap));
|
||||
|
||||
capture_handle.RunAndReset();
|
||||
}
|
||||
|
||||
absl::optional<base::TimeDelta> GetCursorBlinkInterval() {
|
||||
@@ -2903,12 +2900,12 @@ v8::Local<v8::Promise> WebContents::PrintToPDF(const base::Value& settings) {
|
||||
|
||||
void WebContents::OnPDFCreated(
|
||||
gin_helper::Promise<v8::Local<v8::Value>> promise,
|
||||
print_to_pdf::PdfPrintResult print_result,
|
||||
PrintViewManagerElectron::PrintResult print_result,
|
||||
scoped_refptr<base::RefCountedMemory> data) {
|
||||
if (print_result != print_to_pdf::PdfPrintResult::kPrintSuccess) {
|
||||
if (print_result != PrintViewManagerElectron::PrintResult::kPrintSuccess) {
|
||||
promise.RejectWithErrorMessage(
|
||||
"Failed to generate PDF: " +
|
||||
print_to_pdf::PdfPrintResultToString(print_result));
|
||||
PrintViewManagerElectron::PrintResultToString(print_result));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3177,22 +3174,13 @@ void WebContents::StartDrag(const gin_helper::Dictionary& item,
|
||||
}
|
||||
|
||||
v8::Local<v8::Promise> WebContents::CapturePage(gin::Arguments* args) {
|
||||
gfx::Rect rect;
|
||||
gin_helper::Promise<gfx::Image> promise(args->isolate());
|
||||
v8::Local<v8::Promise> handle = promise.GetHandle();
|
||||
|
||||
gfx::Rect rect;
|
||||
// get rect arguments if they exist
|
||||
args->GetNext(&rect);
|
||||
|
||||
bool stay_hidden = false;
|
||||
bool stay_awake = false;
|
||||
if (args && args->Length() == 2) {
|
||||
gin_helper::Dictionary options;
|
||||
if (args->GetNext(&options)) {
|
||||
options.Get("stayHidden", &stay_hidden);
|
||||
options.Get("stayAwake", &stay_awake);
|
||||
}
|
||||
}
|
||||
|
||||
auto* const view = web_contents()->GetRenderWidgetHostView();
|
||||
if (!view) {
|
||||
promise.Resolve(gfx::Image());
|
||||
@@ -3211,9 +3199,6 @@ v8::Local<v8::Promise> WebContents::CapturePage(gin::Arguments* args) {
|
||||
}
|
||||
#endif // BUILDFLAG(IS_MAC)
|
||||
|
||||
auto capture_handle = web_contents()->IncrementCapturerCount(
|
||||
rect.size(), stay_hidden, stay_awake);
|
||||
|
||||
// Capture full page if user doesn't specify a |rect|.
|
||||
const gfx::Size view_size =
|
||||
rect.IsEmpty() ? view->GetViewBounds().size() : rect.size();
|
||||
@@ -3230,18 +3215,11 @@ v8::Local<v8::Promise> WebContents::CapturePage(gin::Arguments* args) {
|
||||
bitmap_size = gfx::ScaleToCeiledSize(view_size, scale);
|
||||
|
||||
view->CopyFromSurface(gfx::Rect(rect.origin(), view_size), bitmap_size,
|
||||
base::BindOnce(&OnCapturePageDone, std::move(promise),
|
||||
std::move(capture_handle)));
|
||||
base::BindOnce(&OnCapturePageDone, std::move(promise)));
|
||||
return handle;
|
||||
}
|
||||
|
||||
// TODO(codebytere): remove in Electron v23.
|
||||
void WebContents::IncrementCapturerCount(gin::Arguments* args) {
|
||||
EmitWarning(node::Environment::GetCurrent(args->isolate()),
|
||||
"webContents.incrementCapturerCount() is deprecated and will be "
|
||||
"removed in v23",
|
||||
"electron");
|
||||
|
||||
gfx::Size size;
|
||||
bool stay_hidden = false;
|
||||
bool stay_awake = false;
|
||||
@@ -3258,13 +3236,7 @@ void WebContents::IncrementCapturerCount(gin::Arguments* args) {
|
||||
.Release();
|
||||
}
|
||||
|
||||
// TODO(codebytere): remove in Electron v23.
|
||||
void WebContents::DecrementCapturerCount(gin::Arguments* args) {
|
||||
EmitWarning(node::Environment::GetCurrent(args->isolate()),
|
||||
"webContents.decrementCapturerCount() is deprecated and will be "
|
||||
"removed in v23",
|
||||
"electron");
|
||||
|
||||
bool stay_hidden = false;
|
||||
bool stay_awake = false;
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@
|
||||
#include "ui/gfx/image/image.h"
|
||||
|
||||
#if BUILDFLAG(ENABLE_PRINTING)
|
||||
#include "components/printing/browser/print_to_pdf/pdf_print_result.h"
|
||||
#include "shell/browser/printing/print_view_manager_electron.h"
|
||||
#endif
|
||||
|
||||
@@ -228,7 +227,7 @@ class WebContents : public ExclusiveAccessContext,
|
||||
// Print current page as PDF.
|
||||
v8::Local<v8::Promise> PrintToPDF(const base::Value& settings);
|
||||
void OnPDFCreated(gin_helper::Promise<v8::Local<v8::Value>> promise,
|
||||
print_to_pdf::PdfPrintResult print_result,
|
||||
PrintViewManagerElectron::PrintResult print_result,
|
||||
scoped_refptr<base::RefCountedMemory> data);
|
||||
#endif
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/base_switches.h"
|
||||
#include "base/command_line.h"
|
||||
@@ -24,17 +25,13 @@
|
||||
#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_child_process_host_delegate.h"
|
||||
#include "content/public/browser/browser_child_process_host_iterator.h"
|
||||
#include "content/public/browser/browser_thread.h"
|
||||
#include "content/public/browser/child_process_data.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "content/public/browser/device_service.h"
|
||||
#include "content/public/browser/first_party_sets_handler.h"
|
||||
#include "content/public/browser/web_ui_controller_factory.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/common/content_switches.h"
|
||||
#include "content/public/common/process_type.h"
|
||||
#include "content/public/common/result_codes.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "electron/fuses.h"
|
||||
@@ -43,7 +40,6 @@
|
||||
#include "services/tracing/public/cpp/stack_sampling/tracing_sampler_profiler.h"
|
||||
#include "shell/app/electron_main_delegate.h"
|
||||
#include "shell/browser/api/electron_api_app.h"
|
||||
#include "shell/browser/api/electron_api_utility_process.h"
|
||||
#include "shell/browser/browser.h"
|
||||
#include "shell/browser/browser_process_impl.h"
|
||||
#include "shell/browser/electron_browser_client.h"
|
||||
@@ -117,6 +113,11 @@
|
||||
#include "chrome/browser/spellchecker/spellcheck_factory.h" // nogncheck
|
||||
#endif
|
||||
|
||||
#if BUILDFLAG(ENABLE_PLUGINS)
|
||||
#include "content/public/browser/plugin_service.h"
|
||||
#include "shell/common/plugin_info.h"
|
||||
#endif // BUILDFLAG(ENABLE_PLUGINS)
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace {
|
||||
@@ -278,15 +279,12 @@ void ElectronBrowserMainParts::PostEarlyInitialization() {
|
||||
// Add Electron extended APIs.
|
||||
electron_bindings_->BindTo(js_env_->isolate(), env->process_object());
|
||||
|
||||
// Create explicit microtasks runner.
|
||||
js_env_->CreateMicrotasksRunner();
|
||||
// Load everything.
|
||||
node_bindings_->LoadEnvironment(env);
|
||||
|
||||
// Wrap the uv loop with global env.
|
||||
node_bindings_->set_uv_env(env);
|
||||
|
||||
// Load everything.
|
||||
node_bindings_->LoadEnvironment(env);
|
||||
|
||||
// We already initialized the feature list in PreEarlyInitialization(), but
|
||||
// the user JS script would not have had a chance to alter the command-line
|
||||
// switches at that point. Lets reinitialize it here to pick up the
|
||||
@@ -390,6 +388,18 @@ void ElectronBrowserMainParts::PostCreateThreads() {
|
||||
content::GetIOThreadTaskRunner({})->PostTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&tracing::TracingSamplerProfiler::CreateOnChildThread));
|
||||
#if BUILDFLAG(ENABLE_PLUGINS)
|
||||
// PluginService can only be used on the UI thread
|
||||
// and ContentClient::AddPlugins gets called for both browser and render
|
||||
// process where the latter will not have UI thread which leads to DCHECK.
|
||||
// Separate the WebPluginInfo registration for these processes.
|
||||
std::vector<content::WebPluginInfo> plugins;
|
||||
auto* plugin_service = content::PluginService::GetInstance();
|
||||
plugin_service->RefreshPlugins();
|
||||
GetInternalPlugins(&plugins);
|
||||
for (const auto& plugin : plugins)
|
||||
plugin_service->RegisterInternalPlugin(plugin, true);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ElectronBrowserMainParts::PostDestroyThreads() {
|
||||
@@ -511,6 +521,7 @@ int ElectronBrowserMainParts::PreMainMessageLoopRun() {
|
||||
|
||||
void ElectronBrowserMainParts::WillRunMainMessageLoop(
|
||||
std::unique_ptr<base::RunLoop>& run_loop) {
|
||||
js_env_->OnMessageLoopCreated();
|
||||
exit_code_ = content::RESULT_CODE_NORMAL_EXIT;
|
||||
Browser::Get()->SetMainMessageLoopQuitClosure(
|
||||
run_loop->QuitWhenIdleClosure());
|
||||
@@ -572,39 +583,10 @@ void ElectronBrowserMainParts::PostMainMessageLoopRun() {
|
||||
}
|
||||
}
|
||||
|
||||
// Shutdown utility process created with Electron API before
|
||||
// stopping Node.js so that exit events can be emitted. We don't let
|
||||
// content layer perform this action since it destroys
|
||||
// child process only after this step (PostMainMessageLoopRun) via
|
||||
// BrowserProcessIOThread::ProcessHostCleanUp() which is too late for our
|
||||
// use case.
|
||||
// https://source.chromium.org/chromium/chromium/src/+/main:content/browser/browser_main_loop.cc;l=1086-1108
|
||||
//
|
||||
// The following logic is based on
|
||||
// https://source.chromium.org/chromium/chromium/src/+/main:content/browser/browser_process_io_thread.cc;l=127-159
|
||||
//
|
||||
// Although content::BrowserChildProcessHostIterator is only to be called from
|
||||
// IO thread, it is safe to call from PostMainMessageLoopRun because thread
|
||||
// restrictions have been lifted.
|
||||
// https://source.chromium.org/chromium/chromium/src/+/main:content/browser/browser_main_loop.cc;l=1062-1078
|
||||
for (content::BrowserChildProcessHostIterator it(
|
||||
content::PROCESS_TYPE_UTILITY);
|
||||
!it.Done(); ++it) {
|
||||
if (it.GetDelegate()->GetServiceName() == node::mojom::NodeService::Name_) {
|
||||
auto& process = it.GetData().GetProcess();
|
||||
if (!process.IsValid())
|
||||
continue;
|
||||
auto utility_process_wrapper =
|
||||
api::UtilityProcessWrapper::FromProcessId(process.Pid());
|
||||
if (utility_process_wrapper)
|
||||
utility_process_wrapper->Shutdown(0 /* exit_code */);
|
||||
}
|
||||
}
|
||||
|
||||
// Destroy node platform after all destructors_ are executed, as they may
|
||||
// invoke Node/V8 APIs inside them.
|
||||
node_env_->env()->set_trace_sync_io(false);
|
||||
js_env_->DestroyMicrotasksRunner();
|
||||
js_env_->OnMessageLoopDestroying();
|
||||
node::Stop(node_env_->env());
|
||||
node_env_.reset();
|
||||
|
||||
|
||||
@@ -38,17 +38,6 @@ class EventEmitterMixin {
|
||||
std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// this.emit(name, args...);
|
||||
template <typename... Args>
|
||||
void EmitWithoutCustomEvent(base::StringPiece name, Args&&... args) {
|
||||
v8::Isolate* isolate = electron::JavascriptEnvironment::GetIsolate();
|
||||
v8::HandleScope handle_scope(isolate);
|
||||
v8::Local<v8::Object> wrapper;
|
||||
if (!static_cast<T*>(this)->GetWrapper(isolate).ToLocal(&wrapper))
|
||||
return;
|
||||
gin_helper::EmitEvent(isolate, wrapper, name, std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
// this.emit(name, event, args...);
|
||||
template <typename... Args>
|
||||
bool EmitCustomEvent(base::StringPiece name,
|
||||
|
||||
@@ -287,13 +287,13 @@ v8::Isolate* JavascriptEnvironment::GetIsolate() {
|
||||
return g_isolate;
|
||||
}
|
||||
|
||||
void JavascriptEnvironment::CreateMicrotasksRunner() {
|
||||
void JavascriptEnvironment::OnMessageLoopCreated() {
|
||||
DCHECK(!microtasks_runner_);
|
||||
microtasks_runner_ = std::make_unique<MicrotasksRunner>(isolate());
|
||||
base::CurrentThread::Get()->AddTaskObserver(microtasks_runner_.get());
|
||||
}
|
||||
|
||||
void JavascriptEnvironment::DestroyMicrotasksRunner() {
|
||||
void JavascriptEnvironment::OnMessageLoopDestroying() {
|
||||
DCHECK(microtasks_runner_);
|
||||
{
|
||||
v8::HandleScope scope(isolate_);
|
||||
|
||||
@@ -29,8 +29,8 @@ class JavascriptEnvironment {
|
||||
JavascriptEnvironment(const JavascriptEnvironment&) = delete;
|
||||
JavascriptEnvironment& operator=(const JavascriptEnvironment&) = delete;
|
||||
|
||||
void CreateMicrotasksRunner();
|
||||
void DestroyMicrotasksRunner();
|
||||
void OnMessageLoopCreated();
|
||||
void OnMessageLoopDestroying();
|
||||
|
||||
node::MultiIsolatePlatform* platform() const { return platform_; }
|
||||
v8::Isolate* isolate() const { return isolate_; }
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "shell/common/api/api.mojom.h"
|
||||
#include "third_party/skia/include/core/SkColor.h"
|
||||
|
||||
namespace gfx {
|
||||
@@ -42,6 +43,10 @@ class NativeBrowserView : public content::WebContentsObserver {
|
||||
return inspectable_web_contents_;
|
||||
}
|
||||
|
||||
const std::vector<mojom::DraggableRegionPtr>& GetDraggableRegions() const {
|
||||
return draggable_regions_;
|
||||
}
|
||||
|
||||
InspectableWebContentsView* GetInspectableWebContentsView();
|
||||
|
||||
virtual void SetAutoResizeFlags(uint8_t flags) = 0;
|
||||
@@ -49,12 +54,20 @@ class NativeBrowserView : public content::WebContentsObserver {
|
||||
virtual gfx::Rect GetBounds() = 0;
|
||||
virtual void SetBackgroundColor(SkColor color) = 0;
|
||||
|
||||
virtual void UpdateDraggableRegions(
|
||||
const std::vector<gfx::Rect>& drag_exclude_rects) {}
|
||||
|
||||
// Called when the window needs to update its draggable region.
|
||||
virtual void UpdateDraggableRegions(
|
||||
const std::vector<mojom::DraggableRegionPtr>& regions) {}
|
||||
|
||||
protected:
|
||||
explicit NativeBrowserView(InspectableWebContents* inspectable_web_contents);
|
||||
// content::WebContentsObserver:
|
||||
void WebContentsDestroyed() override;
|
||||
|
||||
InspectableWebContents* inspectable_web_contents_;
|
||||
std::vector<mojom::DraggableRegionPtr> draggable_regions_;
|
||||
};
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -23,6 +23,12 @@ class NativeBrowserViewMac : public NativeBrowserView {
|
||||
void SetBounds(const gfx::Rect& bounds) override;
|
||||
gfx::Rect GetBounds() override;
|
||||
void SetBackgroundColor(SkColor color) override;
|
||||
|
||||
void UpdateDraggableRegions(
|
||||
const std::vector<mojom::DraggableRegionPtr>& regions) override;
|
||||
|
||||
void UpdateDraggableRegions(
|
||||
const std::vector<gfx::Rect>& drag_exclude_rects) override;
|
||||
};
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
|
||||
#include "shell/browser/native_browser_view_mac.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
#include <vector>
|
||||
|
||||
#include "shell/browser/ui/drag_util.h"
|
||||
#include "shell/browser/ui/inspectable_web_contents.h"
|
||||
#include "shell/browser/ui/inspectable_web_contents_view.h"
|
||||
#include "skia/ext/skia_utils_mac.h"
|
||||
@@ -13,6 +17,206 @@
|
||||
const NSAutoresizingMaskOptions kDefaultAutoResizingMask =
|
||||
NSViewMaxXMargin | NSViewMinYMargin;
|
||||
|
||||
@interface DragRegionView : NSView
|
||||
|
||||
@property(assign) NSPoint initialLocation;
|
||||
|
||||
@end
|
||||
|
||||
@interface NSWindow ()
|
||||
- (void)performWindowDragWithEvent:(NSEvent*)event;
|
||||
@end
|
||||
|
||||
@implementation DragRegionView
|
||||
|
||||
@synthesize initialLocation;
|
||||
|
||||
+ (void)load {
|
||||
if (getenv("ELECTRON_DEBUG_DRAG_REGIONS")) {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
SEL originalSelector = @selector(drawRect:);
|
||||
SEL swizzledSelector = @selector(drawDebugRect:);
|
||||
|
||||
Method originalMethod =
|
||||
class_getInstanceMethod([self class], originalSelector);
|
||||
Method swizzledMethod =
|
||||
class_getInstanceMethod([self class], swizzledSelector);
|
||||
BOOL didAddMethod =
|
||||
class_addMethod([self class], originalSelector,
|
||||
method_getImplementation(swizzledMethod),
|
||||
method_getTypeEncoding(swizzledMethod));
|
||||
|
||||
if (didAddMethod) {
|
||||
class_replaceMethod([self class], swizzledSelector,
|
||||
method_getImplementation(originalMethod),
|
||||
method_getTypeEncoding(originalMethod));
|
||||
} else {
|
||||
method_exchangeImplementations(originalMethod, swizzledMethod);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)mouseDownCanMoveWindow {
|
||||
return
|
||||
[self.window respondsToSelector:@selector(performWindowDragWithEvent:)];
|
||||
}
|
||||
|
||||
- (BOOL)acceptsFirstMouse:(NSEvent*)event {
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)shouldIgnoreMouseEvent {
|
||||
NSEventType type = [[NSApp currentEvent] type];
|
||||
return type != NSEventTypeLeftMouseDragged &&
|
||||
type != NSEventTypeLeftMouseDown;
|
||||
}
|
||||
|
||||
- (NSView*)hitTest:(NSPoint)point {
|
||||
// Pass-through events that hit one of the exclusion zones
|
||||
for (NSView* exclusion_zones in [self subviews]) {
|
||||
if ([exclusion_zones hitTest:point])
|
||||
return nil;
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)mouseDown:(NSEvent*)event {
|
||||
[super mouseDown:event];
|
||||
|
||||
if ([self.window respondsToSelector:@selector(performWindowDragWithEvent:)]) {
|
||||
// According to Google, using performWindowDragWithEvent:
|
||||
// does not generate a NSWindowWillMoveNotification. Hence post one.
|
||||
[[NSNotificationCenter defaultCenter]
|
||||
postNotificationName:NSWindowWillMoveNotification
|
||||
object:self];
|
||||
|
||||
[self.window performWindowDragWithEvent:event];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.window.styleMask & NSWindowStyleMaskFullScreen) {
|
||||
return;
|
||||
}
|
||||
|
||||
self.initialLocation = [event locationInWindow];
|
||||
}
|
||||
|
||||
- (void)mouseDragged:(NSEvent*)event {
|
||||
if ([self.window respondsToSelector:@selector(performWindowDragWithEvent:)]) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (self.window.styleMask & NSWindowStyleMaskFullScreen) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSPoint currentLocation = [NSEvent mouseLocation];
|
||||
NSPoint newOrigin;
|
||||
|
||||
NSRect screenFrame = [[NSScreen mainScreen] frame];
|
||||
NSSize screenSize = screenFrame.size;
|
||||
NSRect windowFrame = [self.window frame];
|
||||
NSSize windowSize = windowFrame.size;
|
||||
|
||||
newOrigin.x = currentLocation.x - self.initialLocation.x;
|
||||
newOrigin.y = currentLocation.y - self.initialLocation.y;
|
||||
|
||||
BOOL inMenuBar = (newOrigin.y + windowSize.height) >
|
||||
(screenFrame.origin.y + screenSize.height);
|
||||
BOOL screenAboveMainScreen = false;
|
||||
|
||||
if (inMenuBar) {
|
||||
for (NSScreen* screen in [NSScreen screens]) {
|
||||
NSRect currentScreenFrame = [screen frame];
|
||||
BOOL isHigher = currentScreenFrame.origin.y > screenFrame.origin.y;
|
||||
|
||||
// If there's another screen that is generally above the current screen,
|
||||
// we'll draw a new rectangle that is just above the current screen. If
|
||||
// the "higher" screen intersects with this rectangle, we'll allow drawing
|
||||
// above the menubar.
|
||||
if (isHigher) {
|
||||
NSRect aboveScreenRect =
|
||||
NSMakeRect(screenFrame.origin.x,
|
||||
screenFrame.origin.y + screenFrame.size.height - 10,
|
||||
screenFrame.size.width, 200);
|
||||
|
||||
BOOL screenAboveIntersects =
|
||||
NSIntersectsRect(currentScreenFrame, aboveScreenRect);
|
||||
|
||||
if (screenAboveIntersects) {
|
||||
screenAboveMainScreen = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Don't let window get dragged up under the menu bar
|
||||
if (inMenuBar && !screenAboveMainScreen) {
|
||||
newOrigin.y = screenFrame.origin.y +
|
||||
(screenFrame.size.height - windowFrame.size.height);
|
||||
}
|
||||
|
||||
// Move the window to the new location
|
||||
[self.window setFrameOrigin:newOrigin];
|
||||
}
|
||||
|
||||
// For debugging purposes only.
|
||||
- (void)drawDebugRect:(NSRect)aRect {
|
||||
[[[NSColor greenColor] colorWithAlphaComponent:0.5] set];
|
||||
NSRectFill([self bounds]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface ExcludeDragRegionView : NSView
|
||||
@end
|
||||
|
||||
@implementation ExcludeDragRegionView
|
||||
|
||||
+ (void)load {
|
||||
if (getenv("ELECTRON_DEBUG_DRAG_REGIONS")) {
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
SEL originalSelector = @selector(drawRect:);
|
||||
SEL swizzledSelector = @selector(drawDebugRect:);
|
||||
|
||||
Method originalMethod =
|
||||
class_getInstanceMethod([self class], originalSelector);
|
||||
Method swizzledMethod =
|
||||
class_getInstanceMethod([self class], swizzledSelector);
|
||||
BOOL didAddMethod =
|
||||
class_addMethod([self class], originalSelector,
|
||||
method_getImplementation(swizzledMethod),
|
||||
method_getTypeEncoding(swizzledMethod));
|
||||
|
||||
if (didAddMethod) {
|
||||
class_replaceMethod([self class], swizzledSelector,
|
||||
method_getImplementation(originalMethod),
|
||||
method_getTypeEncoding(originalMethod));
|
||||
} else {
|
||||
method_exchangeImplementations(originalMethod, swizzledMethod);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)mouseDownCanMoveWindow {
|
||||
return NO;
|
||||
}
|
||||
|
||||
// For debugging purposes only.
|
||||
- (void)drawDebugRect:(NSRect)aRect {
|
||||
[[[NSColor redColor] colorWithAlphaComponent:0.5] set];
|
||||
NSRectFill([self bounds]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
namespace electron {
|
||||
|
||||
NativeBrowserViewMac::NativeBrowserViewMac(
|
||||
@@ -75,7 +279,7 @@ void NativeBrowserViewMac::SetBounds(const gfx::Rect& bounds) {
|
||||
NSMakeRect(bounds.x(), new_height, bounds.width(), bounds.height());
|
||||
|
||||
// Ensure draggable regions are properly updated to reflect new bounds.
|
||||
iwc_view->UpdateDraggableRegions(iwc_view->GetDraggableRegions());
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
}
|
||||
|
||||
gfx::Rect NativeBrowserViewMac::GetBounds() {
|
||||
@@ -111,6 +315,75 @@ void NativeBrowserViewMac::SetBackgroundColor(SkColor color) {
|
||||
view.layer.backgroundColor = skia::CGColorCreateFromSkColor(color);
|
||||
}
|
||||
|
||||
void NativeBrowserViewMac::UpdateDraggableRegions(
|
||||
const std::vector<gfx::Rect>& drag_exclude_rects) {
|
||||
if (!inspectable_web_contents_)
|
||||
return;
|
||||
auto* web_contents = inspectable_web_contents_->GetWebContents();
|
||||
auto* iwc_view = GetInspectableWebContentsView();
|
||||
NSView* web_view = web_contents->GetNativeView().GetNativeNSView();
|
||||
NSView* inspectable_view = iwc_view->GetNativeView().GetNativeNSView();
|
||||
NSView* window_content_view = inspectable_view.superview;
|
||||
|
||||
// Remove all DragRegionViews that were added last time. Note that we need
|
||||
// to copy the `subviews` array to avoid mutation during iteration.
|
||||
base::scoped_nsobject<NSArray> subviews([[web_view subviews] copy]);
|
||||
for (NSView* subview in subviews.get()) {
|
||||
if ([subview isKindOfClass:[DragRegionView class]]) {
|
||||
[subview removeFromSuperview];
|
||||
}
|
||||
}
|
||||
|
||||
// Create one giant NSView that is draggable.
|
||||
base::scoped_nsobject<NSView> drag_region_view(
|
||||
[[DragRegionView alloc] initWithFrame:web_view.bounds]);
|
||||
[web_view addSubview:drag_region_view];
|
||||
|
||||
// Then, on top of that, add "exclusion zones".
|
||||
auto const offset = GetBounds().OffsetFromOrigin();
|
||||
const auto window_content_view_height = NSHeight(window_content_view.bounds);
|
||||
for (const auto& rect : drag_exclude_rects) {
|
||||
const auto x = rect.x() + offset.x();
|
||||
const auto y = window_content_view_height - (rect.bottom() + offset.y());
|
||||
const auto exclude_rect = NSMakeRect(x, y, rect.width(), rect.height());
|
||||
|
||||
const auto drag_region_view_exclude_rect =
|
||||
[window_content_view convertRect:exclude_rect toView:drag_region_view];
|
||||
|
||||
base::scoped_nsobject<NSView> exclude_drag_region_view(
|
||||
[[ExcludeDragRegionView alloc]
|
||||
initWithFrame:drag_region_view_exclude_rect]);
|
||||
[drag_region_view addSubview:exclude_drag_region_view];
|
||||
}
|
||||
}
|
||||
|
||||
void NativeBrowserViewMac::UpdateDraggableRegions(
|
||||
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
||||
if (!inspectable_web_contents_)
|
||||
return;
|
||||
auto* web_contents = inspectable_web_contents_->GetWebContents();
|
||||
NSView* web_view = web_contents->GetNativeView().GetNativeNSView();
|
||||
|
||||
NSInteger webViewWidth = NSWidth([web_view bounds]);
|
||||
NSInteger webViewHeight = NSHeight([web_view bounds]);
|
||||
|
||||
// Draggable regions are implemented by having the whole web view draggable
|
||||
// and overlaying regions that are not draggable.
|
||||
if (&draggable_regions_ != ®ions)
|
||||
draggable_regions_ = mojo::Clone(regions);
|
||||
|
||||
std::vector<gfx::Rect> drag_exclude_rects;
|
||||
if (draggable_regions_.empty()) {
|
||||
drag_exclude_rects.emplace_back(0, 0, webViewWidth, webViewHeight);
|
||||
} else {
|
||||
drag_exclude_rects = CalculateNonDraggableRegions(
|
||||
DraggableRegionsToSkRegion(draggable_regions_), webViewWidth,
|
||||
webViewHeight);
|
||||
}
|
||||
|
||||
UpdateDraggableRegions(drag_exclude_rects);
|
||||
}
|
||||
|
||||
// static
|
||||
NativeBrowserView* NativeBrowserView::Create(
|
||||
InspectableWebContents* inspectable_web_contents) {
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "shell/browser/ui/drag_util.h"
|
||||
#include "shell/browser/ui/views/inspectable_web_contents_view_views.h"
|
||||
#include "ui/gfx/geometry/rect.h"
|
||||
#include "ui/views/background.h"
|
||||
@@ -24,6 +25,25 @@ void NativeBrowserViewViews::SetAutoResizeFlags(uint8_t flags) {
|
||||
ResetAutoResizeProportions();
|
||||
}
|
||||
|
||||
void NativeBrowserViewViews::UpdateDraggableRegions(
|
||||
const std::vector<mojom::DraggableRegionPtr>& regions) {
|
||||
if (&draggable_regions_ != ®ions)
|
||||
draggable_regions_ = mojo::Clone(regions);
|
||||
|
||||
// We need to snap the regions to the bounds of the current BrowserView.
|
||||
// For example, if an attached BrowserView is draggable but its bounds are
|
||||
// { x: 200, y: 100, width: 300, height: 300 }
|
||||
// then we need to add 200 to the x-value and 100 to the
|
||||
// y-value of each of the passed regions or it will be incorrectly
|
||||
// assumed that the regions begin in the top left corner as they
|
||||
// would for the main client window.
|
||||
auto const offset = GetBounds().OffsetFromOrigin();
|
||||
for (auto& snapped_region : draggable_regions_) {
|
||||
snapped_region->bounds.Offset(offset);
|
||||
}
|
||||
draggable_region_ = DraggableRegionsToSkRegion(draggable_regions_);
|
||||
}
|
||||
|
||||
void NativeBrowserViewViews::SetAutoResizeProportions(
|
||||
const gfx::Size& window_size) {
|
||||
if ((auto_resize_flags_ & AutoResizeFlags::kAutoResizeHorizontal) &&
|
||||
@@ -112,6 +132,9 @@ void NativeBrowserViewViews::SetBounds(const gfx::Rect& bounds) {
|
||||
|
||||
view->InvalidateLayout();
|
||||
view->SchedulePaint();
|
||||
|
||||
// Ensure draggable regions are properly updated to reflect new bounds.
|
||||
UpdateDraggableRegions(draggable_regions_);
|
||||
}
|
||||
|
||||
gfx::Rect NativeBrowserViewViews::GetBounds() {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user