sha,author,date,commit_message,git_diff,type 6f2ab392abb3b18f79c1287727e0fafa8ec94a73,Michaela Laurencin,2023-04-12 18:10:47,"docs: update 22-x-y EOL dates (#37955) To account for https://www.electronjs.org/blog/electron-22-0#windows-7881-support-update Not sure if it is worth adding as a historical change though","diff --git a/docs/tutorial/electron-timelines.md b/docs/tutorial/electron-timelines.md index 94570caf43..44f1c60b24 100644 --- a/docs/tutorial/electron-timelines.md +++ b/docs/tutorial/electron-timelines.md @@ -12,7 +12,7 @@ check out our [Electron Versioning](./electron-versioning.md) doc. | 25.0.0 | 2023-Apr-10 | 2023-May-02 | 2023-May-30 | 2023-Dec-05 | M114 | TBD | ✅ | | 24.0.0 | 2022-Feb-09 | 2023-Mar-07 | 2023-Apr-04 | 2023-Oct-03 | M112 | v18.14 | ✅ | | 23.0.0 | 2022-Dec-01 | 2023-Jan-10 | 2023-Feb-07 | 2023-Aug-08 | M110 | v18.12 | ✅ | -| 22.0.0 | 2022-Sep-29 | 2022-Oct-25 | 2022-Nov-29 | 2023-May-30 | M108 | v16.17 | ✅ | +| 22.0.0 | 2022-Sep-29 | 2022-Oct-25 | 2022-Nov-29 | 2023-Oct-10 | M108 | v16.17 | ✅ | | 21.0.0 | 2022-Aug-04 | 2022-Aug-30 | 2022-Sep-27 | 2023-Apr-04 | M106 | v16.16 | 🚫 | | 20.0.0 | 2022-May-26 | 2022-Jun-21 | 2022-Aug-02 | 2023-Feb-07 | M104 | v16.15 | 🚫 | | 19.0.0 | 2022-Mar-31 | 2022-Apr-26 | 2022-May-24 | 2022-Nov-29 | M102 | v16.14 | 🚫 |",docs 868676aa5ccf68793333d40124e49f0d0b175246,Black-Hole,2023-02-21 18:44:35,"feat: add `httpOnly` `cookies.get` filter (#37255) feat: add httpOnly cookies filter","diff --git a/docs/api/cookies.md b/docs/api/cookies.md index 99b02ded75..0c733266c9 100644 --- a/docs/api/cookies.md +++ b/docs/api/cookies.md @@ -78,6 +78,7 @@ The following methods are available on instances of `Cookies`: * `path` string (optional) - Retrieves cookies whose path matches `path`. * `secure` boolean (optional) - Filters cookies by their Secure property. * `session` boolean (optional) - Filters out session or persistent cookies. + * `httpOnly` boolean (optional) - Filters cookies by httpOnly. Returns `Promise` - A promise which resolves an array of cookie objects. diff --git a/shell/browser/api/electron_api_cookies.cc b/shell/browser/api/electron_api_cookies.cc index 50208a28cc..8b2edc8fa5 100644 --- a/shell/browser/api/electron_api_cookies.cc +++ b/shell/browser/api/electron_api_cookies.cc @@ -133,6 +133,9 @@ bool MatchesCookie(const base::Value::Dict& filter, absl::optional session_filter = filter.FindBool(""session""); if (session_filter && *session_filter == cookie.IsPersistent()) return false; + absl::optional httpOnly_filter = filter.FindBool(""httpOnly""); + if (httpOnly_filter && *httpOnly_filter != cookie.IsHttpOnly()) + return false; return true; } diff --git a/spec/api-net-spec.ts b/spec/api-net-spec.ts index 836ad4f75a..d06aa93c76 100644 --- a/spec/api-net-spec.ts +++ b/spec/api-net-spec.ts @@ -874,6 +874,39 @@ describe('net module', () => { expect(cookies[0].name).to.equal('cookie2'); }); + it('should be able correctly filter out cookies that are httpOnly', async () => { + const sess = session.fromPartition(`cookie-tests-${Math.random()}`); + + await Promise.all([ + sess.cookies.set({ + url: 'https://electronjs.org', + domain: 'electronjs.org', + name: 'cookie1', + value: '1', + httpOnly: true + }), + sess.cookies.set({ + url: 'https://electronjs.org', + domain: 'electronjs.org', + name: 'cookie2', + value: '2', + httpOnly: false + }) + ]); + + const httpOnlyCookies = await sess.cookies.get({ + httpOnly: true + }); + expect(httpOnlyCookies).to.have.lengthOf(1); + expect(httpOnlyCookies[0].name).to.equal('cookie1'); + + const cookies = await sess.cookies.get({ + httpOnly: false + }); + expect(cookies).to.have.lengthOf(1); + expect(cookies[0].name).to.equal('cookie2'); + }); + describe('when {""credentials"":""omit""}', () => { it('should not send cookies'); it('should not store cookies');",feat cc39ddb72897e4cc97a38cde55e59b37b46feaa2,Cheng Zhao,2023-07-19 23:54:08,"test: add some environment variables for controlling tests (#39149) chore: add some environment variables for controlling tests","diff --git a/spec/index.js b/spec/index.js index 2f9b098c2c..47c7352da6 100644 --- a/spec/index.js +++ b/spec/index.js @@ -14,6 +14,11 @@ process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true'; const { app, protocol } = require('electron'); +// Some Linux machines have broken hardware acceleration support. +if (process.env.ELECTRON_TEST_DISABLE_HARDWARE_ACCELERATION) { + app.disableHardwareAcceleration(); +} + v8.setFlagsFromString('--expose_gc'); app.commandLine.appendSwitch('js-flags', '--expose_gc'); // Prevent the spec runner quitting when the first window closes @@ -69,6 +74,14 @@ app.whenReady().then(async () => { reporterEnabled: process.env.MOCHA_MULTI_REPORTERS }; } + // The MOCHA_GREP and MOCHA_INVERT are used in some vendor builds for sharding + // tests. + if (process.env.MOCHA_GREP) { + mochaOptions.grep = process.env.MOCHA_GREP; + } + if (process.env.MOCHA_INVERT) { + mochaOptions.invert = process.env.MOCHA_INVERT === 'true'; + } const mocha = new Mocha(mochaOptions); // Add a root hook on mocha to skip any tests that are disabled",test 25eb1bd4b26c2e697c7d3e162611aa22de875959,Shelley Vohr,2024-07-03 21:17:17,build: remove all publish & build on macOS (#42763),"diff --git a/.circleci/config.yml b/.circleci/config.yml index 8f9e8f0fb3..46f927cb42 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -22,28 +22,6 @@ parameters: type: boolean default: false - run-build-mac: - type: boolean - default: false - - run-linux-publish: - type: boolean - default: false - - linux-publish-arch-limit: - type: enum - default: all - enum: [""all"", ""arm"", ""arm64"", ""x64"", ""ia32""] - - run-macos-publish: - type: boolean - default: false - - macos-publish-arch-limit: - type: enum - default: all - enum: [""all"", ""osx-x64"", ""osx-arm64"", ""mas-x64"", ""mas-arm64""] - jobs: generate-config: docker: diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index 8c47ac6ce3..757faacae9 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -13,28 +13,6 @@ parameters: type: boolean default: false - run-build-mac: - type: boolean - default: false - - run-linux-publish: - type: boolean - default: false - - linux-publish-arch-limit: - type: enum - default: all - enum: [""all"", ""arm"", ""arm64"", ""x64""] - - run-macos-publish: - type: boolean - default: false - - macos-publish-arch-limit: - type: enum - default: all - enum: [""all"", ""osx-arm64"", ""mas-arm64""] - medium-linux-executor: type: enum default: electronjs/aks-linux-medium @@ -59,21 +37,6 @@ executors: - image: ghcr.io/electron/build:9a43c14f5c19be0359843299f79e736521373adc resource_class: << parameters.size >> - macos: - parameters: - size: - description: ""macOS executor size"" - type: enum - enum: [""macos.m1.large.gen1"", ""macos.m1.medium.gen1""] - version: - description: ""xcode version"" - type: enum - enum: [""15.0.0"", ""14.0.0""] - default: 15.0.0 - macos: - xcode: << parameters.version >> - resource_class: << parameters.size >> - # Electron Runners linux-arm: resource_class: electronjs/aks-linux-arm-test @@ -88,9 +51,6 @@ executors: # The config expects the following environment variables to be set: # - ""SLACK_WEBHOOK"" Slack hook URL to send notifications. # -# The publishing scripts expect access tokens to be defined as env vars, -# but those are not covered here. -# # CircleCI docs on variables: # https://circleci.com/docs/2.0/env-vars/ @@ -170,18 +130,6 @@ env-linux-2xlarge-release: &env-linux-2xlarge-release <<: *env-global NUMBER_OF_NINJA_PROCESSES: 16 -env-machine-mac: &env-machine-mac - <<: *env-global - NUMBER_OF_NINJA_PROCESSES: 6 - -env-mac-large: &env-mac-large - <<: *env-global - NUMBER_OF_NINJA_PROCESSES: 18 - -env-mac-large-release: &env-mac-large-release - <<: *env-global - NUMBER_OF_NINJA_PROCESSES: 8 - env-ninja-status: &env-ninja-status NINJA_STATUS: ""[%r processes, %f/%t @ %o/s : %es] "" @@ -189,10 +137,6 @@ env-32bit-release: &env-32bit-release # Set symbol level to 1 for 32 bit releases because of https://crbug.com/648948 GN_BUILDFLAG_ARGS: 'symbol_level = 1' -env-macos-build: &env-macos-build - # Disable pre-compiled headers to reduce out size, only useful for rebuilds - GN_BUILDFLAG_ARGS: 'enable_precompiled_headers = false' - # Individual (shared) steps. step-maybe-notify-slack-failure: &step-maybe-notify-slack-failure run: @@ -216,29 +160,6 @@ step-maybe-notify-slack-success: &step-maybe-notify-slack-success fi when: on_success -step-maybe-cleanup-arm64-mac: &step-maybe-cleanup-arm64-mac - run: - name: Cleanup after testing - command: | - if [ ""$TARGET_ARCH"" == ""arm64"" ] &&[ ""`uname`"" == ""Darwin"" ]; then - killall Electron || echo ""No Electron processes left running"" - killall Safari || echo ""No Safari processes left running"" - rm -rf ~/Library/Application\ Support/Electron* - rm -rf ~/Library/Application\ Support/electron* - security delete-generic-password -l ""Chromium Safe Storage"" || echo ""✓ Keychain does not contain password from tests"" - security delete-generic-password -l ""Electron Test Main Safe Storage"" || echo ""✓ Keychain does not contain password from tests"" - security delete-generic-password -a ""electron-test-safe-storage"" || echo ""✓ Keychain does not contain password from tests"" - security delete-generic-password -l ""electron-test-safe-storage Safe Storage"" || echo ""✓ Keychain does not contain password from tests"" - elif [ ""$TARGET_ARCH"" == ""arm"" ] || [ ""$TARGET_ARCH"" == ""arm64"" ]; then - XVFB=/usr/bin/Xvfb - /sbin/start-stop-daemon --stop --exec $XVFB || echo ""Xvfb not running"" - pkill electron || echo ""electron not running"" - rm -rf ~/.config/Electron* - rm -rf ~/.config/electron* - fi - - when: always - step-checkout-electron: &step-checkout-electron checkout: path: src/electron @@ -248,14 +169,10 @@ step-depot-tools-get: &step-depot-tools-get name: Get depot tools command: | git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git - if [ ""`uname`"" == ""Darwin"" ]; then - # remove ninjalog_uploader_wrapper.py from autoninja since we don't use it and it causes problems - sed -i '' '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja - else - sed -i '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja - # Remove swift-format dep from cipd on macOS until we send a patch upstream. - cd depot_tools - cat > gclient.diff \<< 'EOF' + sed -i '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja + # Remove swift-format dep from cipd on macOS until we send a patch upstream. + cd depot_tools + cat > gclient.diff \<< 'EOF' diff --git a/gclient.py b/gclient.py index c305c248..e6e0fbdc 100755 --- a/gclient.py @@ -371,126 +288,6 @@ step-save-brew-cache: &step-save-brew-cache key: v6-brew-cache-{{ arch }} name: Persisting brew cache -step-get-more-space-on-mac: &step-get-more-space-on-mac - run: - name: Free up space on MacOS - command: | - if [ ""`uname`"" == ""Darwin"" ]; then - sudo mkdir -p $TMPDIR/del-target - - tmpify() { - if [ -d ""$1"" ]; then - sudo mv ""$1"" $TMPDIR/del-target/$(echo $1|shasum -a 256|head -n1|cut -d "" "" -f1) - fi - } - - strip_universal_deep() { - opwd=$(pwd) - cd $1 - f=$(find . -perm +111 -type f) - for fp in $f - do - if [[ $(file ""$fp"") == *""universal binary""* ]]; then - if [ ""`arch`"" == ""arm64"" ]; then - if [[ $(file ""$fp"") == *""x86_64""* ]]; then - sudo lipo -remove x86_64 ""$fp"" -o ""$fp"" || true - fi - else - if [[ $(file ""$fp"") == *""arm64e)""* ]]; then - sudo lipo -remove arm64e ""$fp"" -o ""$fp"" || true - fi - if [[ $(file ""$fp"") == *""arm64)""* ]]; then - sudo lipo -remove arm64 ""$fp"" -o ""$fp"" || true - fi - fi - fi - done - - cd $opwd - } - - tmpify /Library/Developer/CoreSimulator - tmpify ~/Library/Developer/CoreSimulator - tmpify $(xcode-select -p)/Platforms/AppleTVOS.platform - tmpify $(xcode-select -p)/Platforms/iPhoneOS.platform - tmpify $(xcode-select -p)/Platforms/WatchOS.platform - tmpify $(xcode-select -p)/Platforms/WatchSimulator.platform - tmpify $(xcode-select -p)/Platforms/AppleTVSimulator.platform - tmpify $(xcode-select -p)/Platforms/iPhoneSimulator.platform - tmpify $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/metal/ios - tmpify $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift - tmpify $(xcode-select -p)/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift-5.0 - tmpify ~/.rubies - tmpify ~/Library/Caches/Homebrew - tmpify /usr/local/Homebrew - - # the contents of build/linux/strip_binary.gni aren't used, but - # https://chromium-review.googlesource.com/c/chromium/src/+/4278307 - # needs the file to exist. - mv ~/project/src/build/linux/strip_binary.gni ""${TMPDIR}""/ - tmpify ~/project/src/build/linux/ - mkdir -p ~/project/src/build/linux - mv ""${TMPDIR}/strip_binary.gni"" ~/project/src/build/linux/ - - sudo rm -rf $TMPDIR/del-target - - # sudo rm -rf ""/System/Library/Desktop Pictures"" - # sudo rm -rf /System/Library/Templates/Data - # sudo rm -rf /System/Library/Speech/Voices - # sudo rm -rf ""/System/Library/Screen Savers"" - # sudo rm -rf /System/Volumes/Data/Library/Developer/CommandLineTools/SDKs - # sudo rm -rf ""/System/Volumes/Data/Library/Application Support/Apple/Photos/Print Products"" - # sudo rm -rf /System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/ - # sudo rm -rf /System/Volumes/Data/Library/Java - # sudo rm -rf /System/Volumes/Data/Library/Ruby - # sudo rm -rf /System/Volumes/Data/Library/Printers - # sudo rm -rf /System/iOSSupport - # sudo rm -rf /System/Applications/*.app - # sudo rm -rf /System/Applications/Utilities/*.app - # sudo rm -rf /System/Library/LinguisticData - # sudo rm -rf /System/Volumes/Data/private/var/db/dyld/* - # sudo rm -rf /System/Library/Fonts/* - # sudo rm -rf /System/Library/PreferencePanes - # sudo rm -rf /System/Library/AssetsV2/* - sudo rm -rf /Applications/Safari.app - sudo rm -rf ~/project/src/third_party/catapult/tracing/test_data - sudo rm -rf ~/project/src/third_party/angle/third_party/VK-GL-CTS - - # lipo off some huge binaries arm64 versions to save space - strip_universal_deep $(xcode-select -p)/../SharedFrameworks - # strip_arm_deep /System/Volumes/Data/Library/Developer/CommandLineTools/usr - fi - background: true - -# On macOS delete all .git directories under src/ except for -# third_party/angle/ and third_party/dawn/ because of build time generation of files -# gen/angle/commit.h depends on third_party/angle/.git/HEAD -# https://chromium-review.googlesource.com/c/angle/angle/+/2074924 -# and dawn/common/Version_autogen.h depends on third_party/dawn/.git/HEAD -# https://dawn-review.googlesource.com/c/dawn/+/83901 -# TODO: maybe better to always leave out */.git/HEAD file for all targets ? -step-delete-git-directories: &step-delete-git-directories - run: - name: Delete all .git directories under src on MacOS to free space - 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 - fi - -# On macOS the yarn install command during gclient sync was run on a linux -# machine and therefore installed a slightly different set of dependencies -# Notably ""fsevents"" is a macOS only dependency, we rerun yarn install once -# we are on a macOS machine to get the correct state -step-install-npm-deps-on-mac: &step-install-npm-deps-on-mac - run: - name: Install node_modules on MacOS - command: | - if [ ""`uname`"" == ""Darwin"" ]; then - cd src/electron - node script/yarn install - fi - step-install-npm-deps: &step-install-npm-deps run: name: Install node_modules @@ -498,89 +295,6 @@ step-install-npm-deps: &step-install-npm-deps cd src/electron node script/yarn install --frozen-lockfile -# This step handles the differences between the linux ""gclient sync"" -# and the expected state on macOS -step-fix-sync: &step-fix-sync - run: - name: Fix Sync - command: | - SEDOPTION=""-i"" - if [ ""`uname`"" == ""Darwin"" ]; then - SEDOPTION=""-i ''"" - # Fix Clang Install (wrong binary) - rm -rf src/third_party/llvm-build - python3 src/tools/clang/scripts/update.py - - # Fix esbuild (wrong binary) - echo 'infra/3pp/tools/esbuild/${platform}' `gclient getdep --deps-file=src/third_party/devtools-frontend/src/DEPS -r 'third_party/esbuild:infra/3pp/tools/esbuild/${platform}'` > esbuild_ensure_file - # Remove extra output from calling gclient getdep which always calls update_depot_tools - sed -i '' ""s/Updating depot_tools... //g"" esbuild_ensure_file - cipd ensure --root src/third_party/devtools-frontend/src/third_party/esbuild -ensure-file esbuild_ensure_file - - # Fix rustc (wrong binary) - rm -rf src/third_party/rust-toolchain - python3 src/tools/rust/update_rust.py - - # Fix gn (wrong binary) - echo 'gn/gn/mac-${arch}' `gclient getdep --deps-file=src/DEPS -r 'src/buildtools/mac:gn/gn/mac-${arch}'` > gn_ensure_file - # Remove extra output from calling gclient getdep which always calls update_depot_tools - sed -i '' ""s/Updating depot_tools... //g"" gn_ensure_file - cipd ensure --root src/buildtools/mac -ensure-file gn_ensure_file - - # Fix reclient (wrong binary) - echo 'infra/rbe/client/${platform}' `gclient getdep --deps-file=src/DEPS -r 'src/buildtools/reclient:infra/rbe/client/${platform}'` > gn_ensure_file - # Remove extra output from calling gclient getdep which always calls update_depot_tools - sed -i '' ""s/Updating depot_tools... //g"" gn_ensure_file - cipd ensure --root src/buildtools/reclient -ensure-file gn_ensure_file - python3 src/buildtools/reclient_cfgs/configure_reclient_cfgs.py --rbe_instance ""projects/rbe-chrome-untrusted/instances/default_instance"" --reproxy_cfg_template reproxy.cfg.template --rewrapper_cfg_project """" --skip_remoteexec_cfg_fetch - - # Fix dsymutil (wrong binary) - if [ ""$TARGET_ARCH"" == ""arm64"" ]; then - export DSYM_SHA_FILE=src/tools/clang/dsymutil/bin/dsymutil.arm64.sha1 - else - export DSYM_SHA_FILE=src/tools/clang/dsymutil/bin/dsymutil.x64.sha1 - fi - python3 src/third_party/depot_tools/download_from_google_storage.py --no_resume --no_auth --bucket chromium-browser-clang -s $DSYM_SHA_FILE -o src/tools/clang/dsymutil/bin/dsymutil - fi - - # Make sure we are using the right ninja - echo 'infra/3pp/build_support/ninja-1_11_1/${platform}' `gclient getdep --deps-file=src/DEPS -r 'src/third_party/ninja:infra/3pp/build_support/ninja-1_11_1/${platform}'` > ninja_ensure_file - sed $SEDOPTION ""s/Updating depot_tools... //g"" ninja_ensure_file - cipd ensure --root src/third_party/ninja -ensure-file ninja_ensure_file - - # Explicitly add ninja to the path - echo 'export PATH=""$PATH:'""$PWD""'/src/third_party/ninja""' >> $BASH_ENV - - cd src/third_party/angle - rm .git/objects/info/alternates - git remote set-url origin https://chromium.googlesource.com/angle/angle.git - cp .git/config .git/config.backup - git remote remove origin - mv .git/config.backup .git/config - git fetch - -step-install-signing-cert-on-mac: &step-install-signing-cert-on-mac - run: - name: Import and trust self-signed codesigning cert on MacOS - command: | - if [ ""$TARGET_ARCH"" != ""arm64"" ] && [ ""`uname`"" == ""Darwin"" ]; then - sudo security authorizationdb write com.apple.trust-settings.admin allow - cd src/electron - ./script/codesign/generate-identity.sh - fi - -step-install-gnutar-on-mac: &step-install-gnutar-on-mac - run: - name: Install gnu-tar on macos - command: | - if [ ""`uname`"" == ""Darwin"" ]; then - if [ ! -d /usr/local/Cellar/gnu-tar/ ]; then - brew update - brew install gnu-tar - fi - ln -fs /usr/local/bin/gtar /usr/local/bin/tar - fi - step-gn-gen-default: &step-gn-gen-default run: name: Default GN gen @@ -643,24 +357,6 @@ step-nodejs-headers-build: &step-nodejs-headers-build cd src autoninja -C out/Default electron:node_headers -step-electron-publish: &step-electron-publish - run: - name: Publish Electron Dist - no_output_timeout: 30m - command: | - if [ ""`uname`"" == ""Darwin"" ]; then - rm -rf src/out/Default/obj - fi - - cd src/electron - if [ ""$UPLOAD_TO_STORAGE"" == ""1"" ]; then - echo 'Uploading Electron release distribution to Azure' - script/release/uploaders/upload.py --verbose --upload_to_storage - else - echo 'Uploading Electron release distribution to GitHub releases' - script/release/uploaders/upload.py --verbose - fi - step-electron-dist-unzip: &step-electron-dist-unzip run: name: Unzip dist.zip @@ -1315,16 +1011,7 @@ commands: if [ ""$SKIP_DIST_ZIP"" != ""1"" ]; then autoninja -C out/Default electron:electron_dist_zip << parameters.additional-targets >> -j $NUMBER_OF_NINJA_PROCESSES if [ ""$CHECK_DIST_MANIFEST"" == ""1"" ]; then - if [ ""`uname`"" == ""Darwin"" ]; then - target_os=mac - target_cpu=x64 - if [ x""$MAS_BUILD"" == x""true"" ]; then - target_os=mac_mas - fi - if [ ""$TARGET_ARCH"" == ""arm64"" ]; then - target_cpu=arm64 - fi - elif [ ""`uname`"" == ""Linux"" ]; then + if [ ""`uname`"" == ""Linux"" ]; then target_os=linux if [ x""$TARGET_ARCH"" == x ]; then target_cpu=x64 @@ -1409,7 +1096,6 @@ commands: at: . - run: rm -rf src/electron - *step-restore-brew-cache - - *step-install-gnutar-on-mac - *step-save-brew-cache - when: condition: << parameters.build >> @@ -1427,7 +1113,6 @@ commands: - *step-checkout-electron - *step-depot-tools-get - *step-depot-tools-add-to-path - - *step-get-more-space-on-mac - *step-generate-deps-hash - *step-touch-sync-done - when: @@ -1496,7 +1181,6 @@ commands: # is missing we will restore a useful git cache. - *step-mark-sync-done - *step-minimize-workspace-size-from-checkout - - *step-delete-git-directories - when: condition: << parameters.persist-checkout >> steps: @@ -1533,9 +1217,6 @@ commands: steps: - *step-depot-tools-add-to-path - *step-setup-env-for-build - - *step-get-more-space-on-mac - - *step-fix-sync - - *step-delete-git-directories - when: condition: << parameters.build >> @@ -1606,7 +1287,6 @@ commands: - *step-setup-linux-for-headless-testing - *step-restore-brew-cache - *step-fix-known-hosts-linux - - *step-install-signing-cert-on-mac - run: name: Run Electron tests @@ -1646,8 +1326,6 @@ commands: - *step-maybe-notify-slack-failure - - *step-maybe-cleanup-arm64-mac - nan-tests: parameters: artifact-key: @@ -1684,80 +1362,6 @@ commands: - store_test_results: path: src/junit - electron-publish: - parameters: - attach: - type: boolean - default: false - checkout: - type: boolean - default: true - build-type: - type: string - steps: - - when: - condition: << parameters.attach >> - steps: - - attach_workspace: - at: . - - when: - condition: << parameters.checkout >> - steps: - - *step-depot-tools-get - - *step-depot-tools-add-to-path - - *step-restore-brew-cache - - *step-get-more-space-on-mac - - when: - condition: << parameters.checkout >> - steps: - - *step-checkout-electron - - *step-touch-sync-done - - *step-maybe-restore-git-cache - - *step-set-git-cache-path - - *step-gclient-sync - - *step-delete-git-directories - - *step-minimize-workspace-size-from-checkout - - *step-fix-sync - - *step-setup-env-for-build - - *step-fix-known-hosts-linux - - *step-setup-rbe-for-build - - *step-gn-gen-default - - # Electron app - - ninja_build_electron: - build-type: << parameters.build-type >> - - *step-maybe-generate-breakpad-symbols - - *step-maybe-electron-dist-strip - - step-electron-dist-build - - *step-maybe-zip-symbols-and-clean - - # mksnapshot - - *step-mksnapshot-build - - # chromedriver - - *step-electron-chromedriver-build - - # Node.js headers - - *step-nodejs-headers-build - - # ffmpeg - - *step-ffmpeg-gn-gen - - *step-ffmpeg-build - - # hunspell - - *step-hunspell-build - - # libcxx - - *step-maybe-generate-libcxx - - # typescript defs - - *step-maybe-generate-typescript-defs - - # Publish - - *step-electron-publish - - move_and_store_all_artifacts: - artifact-key: 'publish' - # List of all jobs. jobs: # Layer 0: Docs. Standalone. @@ -1790,66 +1394,6 @@ jobs: build-type: 'nil' could-be-aks: true - mac-checkout: - executor: - name: linux-docker - size: xlarge - environment: - <<: *env-linux-2xlarge - <<: *env-testing-build - <<: *env-macos-build - GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac' - steps: - - electron-build: - persist: false - build: false - checkout: true - persist-checkout: true - restore-src-cache: false - artifact-key: 'nil' - build-type: 'nil' - could-be-aks: false - - mac-make-src-cache-x64: - executor: - name: linux-docker - size: xlarge - environment: - <<: *env-linux-2xlarge - <<: *env-testing-build - <<: *env-macos-build - GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac' - steps: - - electron-build: - persist: false - build: false - checkout: true - save-git-cache: true - checkout-to-create-src-cache: true - artifact-key: 'nil' - build-type: 'nil' - could-be-aks: false - - mac-make-src-cache-arm64: - executor: - name: linux-docker - size: xlarge - environment: - <<: *env-linux-2xlarge - <<: *env-testing-build - <<: *env-macos-build - GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac --custom-var=host_cpu=arm64' - steps: - - electron-build: - persist: false - build: false - checkout: true - save-git-cache: true - checkout-to-create-src-cache: true - artifact-key: 'nil' - build-type: 'nil' - could-be-aks: false - # Layer 2: Builds. linux-x64-testing: executor: @@ -1902,29 +1446,6 @@ jobs: - run-gn-check: could-be-aks: true - linux-x64-publish: - executor: - name: linux-docker - size: << pipeline.parameters.large-linux-executor >> - environment: - <<: *env-linux-2xlarge-release - <<: *env-release-build - UPLOAD_TO_STORAGE: << pipeline.parameters.upload-to-storage >> - <<: *env-ninja-status - steps: - - run: echo running - - when: - condition: - or: - - equal: [""all"", << pipeline.parameters.linux-publish-arch-limit >>] - - equal: [""x64"", << pipeline.parameters.linux-publish-arch-limit >>] - steps: - - electron-publish: - attach: false - checkout: true - build-type: 'Linux' - - linux-arm-testing: executor: name: linux-docker @@ -1946,31 +1467,6 @@ jobs: build-type: 'Linux ARM' could-be-aks: true - linux-arm-publish: - executor: - name: linux-docker - size: << pipeline.parameters.large-linux-executor >> - environment: - <<: *env-linux-2xlarge-release - <<: *env-arm - <<: *env-release-build - <<: *env-32bit-release - GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True' - UPLOAD_TO_STORAGE: << pipeline.parameters.upload-to-storage >> - <<: *env-ninja-status - steps: - - run: echo running - - when: - condition: - or: - - equal: [""all"", << pipeline.parameters.linux-publish-arch-limit >>] - - equal: [""arm"", << pipeline.parameters.linux-publish-arch-limit >>] - steps: - - electron-publish: - attach: false - checkout: true - build-type: 'Linux ARM' - linux-arm64-testing: executor: name: linux-docker @@ -2005,135 +1501,6 @@ jobs: - run-gn-check: could-be-aks: true - linux-arm64-publish: - executor: - name: linux-docker - size: << pipeline.parameters.large-linux-executor >> - environment: - <<: *env-linux-2xlarge-release - <<: *env-arm64 - <<: *env-release-build - GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm64=True' - UPLOAD_TO_STORAGE: << pipeline.parameters.upload-to-storage >> - <<: *env-ninja-status - steps: - - run: echo running - - when: - condition: - or: - - equal: [""all"", << pipeline.parameters.linux-publish-arch-limit >>] - - equal: [""arm64"", << pipeline.parameters.linux-publish-arch-limit >>] - steps: - - electron-publish: - attach: false - checkout: true - build-type: 'Linux ARM64' - - osx-publish-arm64: - executor: - name: macos - size: macos.m1.large.gen1 - environment: - <<: *env-mac-large-release - <<: *env-release-build - <<: *env-apple-silicon - UPLOAD_TO_STORAGE: << pipeline.parameters.upload-to-storage >> - <<: *env-ninja-status - steps: - - run: echo running - - when: - condition: - or: - - equal: [""all"", << pipeline.parameters.macos-publish-arch-limit >>] - - equal: [""osx-arm64"", << pipeline.parameters.macos-publish-arch-limit >>] - steps: - - electron-publish: - attach: true - checkout: false - build-type: 'Darwin ARM64' - - osx-testing-arm64: - executor: - name: macos - size: macos.m1.medium.gen1 - environment: - <<: *env-mac-large - <<: *env-testing-build - <<: *env-ninja-status - <<: *env-macos-build - <<: *env-apple-silicon - GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac --custom-var=host_cpu=arm64' - steps: - - electron-build: - persist: true - checkout: false - checkout-and-assume-cache: true - attach: true - artifact-key: 'darwin-arm64' - build-type: 'Darwin ARM64' - after-build-and-save: - - run: - name: Configuring MAS build - command: | - echo 'export GN_EXTRA_ARGS=""is_mas_build = true $GN_EXTRA_ARGS""' >> $BASH_ENV - echo 'export MAS_BUILD=""true""' >> $BASH_ENV - rm -rf ""src/out/Default/Electron Framework.framework"" - rm -rf src/out/Default/Electron*.app - - build_and_save_artifacts: - artifact-key: 'mas-arm64' - build-type: 'MAS ARM64' - after-persist: - - persist_to_workspace: - root: . - paths: - - generated_artifacts_mas-arm64 - could-be-aks: false - - mas-publish-x64: - executor: - name: macos - size: macos.x86.medium.gen2 - environment: - <<: *env-mac-large-release - <<: *env-mas - <<: *env-release-build - UPLOAD_TO_STORAGE: << pipeline.parameters.upload-to-storage >> - steps: - - run: echo running - - when: - condition: - or: - - equal: [""all"", << pipeline.parameters.macos-publish-arch-limit >>] - - equal: [""mas-x64"", << pipeline.parameters.macos-publish-arch-limit >>] - steps: - - electron-publish: - attach: true - checkout: false - build-type: 'MAS' - - mas-publish-arm64: - executor: - name: macos - size: macos.m1.large.gen1 - environment: - <<: *env-mac-large-release - <<: *env-mas-apple-silicon - <<: *env-release-build - UPLOAD_TO_STORAGE: << pipeline.parameters.upload-to-storage >> - <<: *env-ninja-status - steps: - - run: echo running - - when: - condition: - or: - - equal: [""all"", << pipeline.parameters.macos-publish-arch-limit >>] - - equal: [""mas-arm64"", << pipeline.parameters.macos-publish-arch-limit >>] - steps: - - electron-publish: - attach: true - checkout: false - build-type: 'MAS ARM64' - # Layer 3: Tests. linux-x64-testing-tests: executor: @@ -2211,72 +1578,18 @@ jobs: - electron-tests: artifact-key: linux-arm64 - darwin-testing-x64-tests: - executor: - name: macos - size: macos.x86.medium.gen2 - version: 14.0.0 - environment: - <<: *env-mac-large - <<: *env-stack-dumping - parallelism: 2 - steps: - - run: nvm install lts/iron && nvm alias default lts/iron - - electron-tests: - artifact-key: darwin-x64 - - darwin-testing-arm64-tests: - executor: - name: macos - size: macos.m1.medium.gen1 - environment: - <<: *env-mac-large - <<: *env-stack-dumping - <<: *env-apple-silicon - <<: *env-runner - steps: - - electron-tests: - artifact-key: darwin-arm64 - - mas-testing-arm64-tests: - executor: - name: macos - size: macos.m1.medium.gen1 - environment: - <<: *env-mac-large - <<: *env-stack-dumping - <<: *env-apple-silicon - <<: *env-runner - steps: - - electron-tests: - artifact-key: mas-arm64 - # List all workflows workflows: docs-only: when: and: - - equal: [false, << pipeline.parameters.run-macos-publish >>] - - equal: [false, << pipeline.parameters.run-linux-publish >>] - equal: [true, << pipeline.parameters.run-docs-only >>] jobs: - ts-compile-doc-change - publish-linux: - when: << pipeline.parameters.run-linux-publish >> - jobs: - - linux-x64-publish: - context: release-env - - linux-arm-publish: - context: release-env - - linux-arm64-publish: - context: release-env - build-linux: when: and: - - equal: [false, << pipeline.parameters.run-macos-publish >>] - - equal: [false, << pipeline.parameters.run-linux-publish >>] - equal: [true, << pipeline.parameters.run-build-linux >>] jobs: - linux-make-src-cache @@ -2325,31 +1638,6 @@ workflows: requires: - linux-make-src-cache - build-mac: - when: - and: - - equal: [false, << pipeline.parameters.run-macos-publish >>] - - equal: [false, << pipeline.parameters.run-linux-publish >>] - - equal: [true, << pipeline.parameters.run-build-mac >>] - jobs: - - mac-make-src-cache-arm64 - - osx-testing-arm64: - requires: - - mac-make-src-cache-arm64 - - darwin-testing-arm64-tests: - filters: - branches: - # Do not run this on forked pull requests - ignore: /pull\/[0-9]+/ - requires: - - osx-testing-arm64 - - mas-testing-arm64-tests: - filters: - branches: - # Do not run this on forked pull requests - ignore: /pull\/[0-9]+/ - requires: - - osx-testing-arm64 lint: jobs: - lint",build 67ba30402bcbf6942fa0846927f2d088cf0a749d,Jeremy Rose,2024-04-18 13:14:07,refactor: JSify BrowserWindow unresponsive handling (#37902),"diff --git a/lib/browser/api/browser-window.ts b/lib/browser/api/browser-window.ts index b6ec4e60b6..365258200f 100644 --- a/lib/browser/api/browser-window.ts +++ b/lib/browser/api/browser-window.ts @@ -36,6 +36,29 @@ BrowserWindow.prototype._init = function (this: BWT) { app.emit('browser-window-focus', event, this); }); + let unresponsiveEvent: NodeJS.Timeout | null = null; + const emitUnresponsiveEvent = () => { + unresponsiveEvent = null; + if (!this.isDestroyed() && this.isEnabled()) { this.emit('unresponsive'); } + }; + this.webContents.on('unresponsive', () => { + if (!unresponsiveEvent) { unresponsiveEvent = setTimeout(emitUnresponsiveEvent, 50); } + }); + this.webContents.on('responsive', () => { + if (unresponsiveEvent) { + clearTimeout(unresponsiveEvent); + unresponsiveEvent = null; + } + this.emit('responsive'); + }); + this.on('close', () => { + if (!unresponsiveEvent) { unresponsiveEvent = setTimeout(emitUnresponsiveEvent, 5000); } + }); + this.webContents.on('destroyed', () => { + if (unresponsiveEvent) clearTimeout(unresponsiveEvent); + unresponsiveEvent = null; + }); + // Subscribe to visibilityState changes and pass to renderer process. let isVisible = this.isVisible() && !this.isMinimized(); const visibilityChanged = () => { diff --git a/shell/browser/api/electron_api_browser_window.cc b/shell/browser/api/electron_api_browser_window.cc index acbbd88cb4..234dedb643 100644 --- a/shell/browser/api/electron_api_browser_window.cc +++ b/shell/browser/api/electron_api_browser_window.cc @@ -117,19 +117,6 @@ BrowserWindow::~BrowserWindow() { void BrowserWindow::BeforeUnloadDialogCancelled() { WindowList::WindowCloseCancelled(window()); - // Cancel unresponsive event when window close is cancelled. - window_unresponsive_closure_.Cancel(); -} - -void BrowserWindow::OnRendererUnresponsive(content::RenderProcessHost*) { - // Schedule the unresponsive shortly later, since we may receive the - // responsive event soon. This could happen after the whole application had - // blocked for a while. - // Also notice that when closing this event would be ignored because we have - // explicitly started a close timeout counter. This is on purpose because we - // don't want the unresponsive event to be sent too early when user is closing - // the window. - ScheduleUnresponsiveEvent(50); } void BrowserWindow::WebContentsDestroyed() { @@ -137,11 +124,6 @@ void BrowserWindow::WebContentsDestroyed() { CloseImmediately(); } -void BrowserWindow::OnRendererResponsive(content::RenderProcessHost*) { - window_unresponsive_closure_.Cancel(); - Emit(""responsive""); -} - void BrowserWindow::OnSetContentBounds(const gfx::Rect& rect) { // window.resizeTo(...) // window.moveTo(...) @@ -177,13 +159,6 @@ void BrowserWindow::OnCloseButtonClicked(bool* prevent_default) { // first, and when the web page is closed the window will also be closed. *prevent_default = true; - // Assume the window is not responding if it doesn't cancel the close and is - // not closed in 5s, in this way we can quickly show the unresponsive - // dialog when the window is busy executing some script without waiting for - // the unresponsive timeout. - if (window_unresponsive_closure_.IsCancelled()) - ScheduleUnresponsiveEvent(5000); - // Already closed by renderer. if (!web_contents() || !api_web_contents_) return; @@ -250,9 +225,6 @@ void BrowserWindow::CloseImmediately() { } BaseWindow::CloseImmediately(); - - // Do not sent ""unresponsive"" event after window is closed. - window_unresponsive_closure_.Cancel(); } void BrowserWindow::Focus() { @@ -362,24 +334,6 @@ void BrowserWindow::SetTitleBarOverlay(const gin_helper::Dictionary& options, } #endif -void BrowserWindow::ScheduleUnresponsiveEvent(int ms) { - if (!window_unresponsive_closure_.IsCancelled()) - return; - - window_unresponsive_closure_.Reset(base::BindRepeating( - &BrowserWindow::NotifyWindowUnresponsive, GetWeakPtr())); - base::SingleThreadTaskRunner::GetCurrentDefault()->PostDelayedTask( - FROM_HERE, window_unresponsive_closure_.callback(), - base::Milliseconds(ms)); -} - -void BrowserWindow::NotifyWindowUnresponsive() { - window_unresponsive_closure_.Cancel(); - if (!window_->IsClosed() && window_->IsEnabled()) { - Emit(""unresponsive""); - } -} - void BrowserWindow::OnWindowShow() { web_contents()->WasShown(); BaseWindow::OnWindowShow(); diff --git a/shell/browser/api/electron_api_browser_window.h b/shell/browser/api/electron_api_browser_window.h index df9f9754ce..c9de1334a4 100644 --- a/shell/browser/api/electron_api_browser_window.h +++ b/shell/browser/api/electron_api_browser_window.h @@ -43,9 +43,6 @@ class BrowserWindow : public BaseWindow, // content::WebContentsObserver: void BeforeUnloadDialogCancelled() override; - void OnRendererUnresponsive(content::RenderProcessHost*) override; - void OnRendererResponsive( - content::RenderProcessHost* render_process_host) override; void WebContentsDestroyed() override; // ExtendedWebContentsObserver: @@ -84,16 +81,6 @@ class BrowserWindow : public BaseWindow, private: // Helpers. - // Schedule a notification unresponsive event. - void ScheduleUnresponsiveEvent(int ms); - - // Dispatch unresponsive event to observers. - void NotifyWindowUnresponsive(); - - // Closure that would be called when window is unresponsive when closing, - // it should be cancelled when we can prove that the window is responsive. - base::CancelableRepeatingClosure window_unresponsive_closure_; - v8::Global web_contents_; v8::Global web_contents_view_; base::WeakPtr api_web_contents_;",refactor af54c5a4b6c9d022045d6f01a068fe62cb196565,Charles Kerr,2024-09-25 06:17:27,"test: add tests dbus notification images (#43938) Provide a NativeImage icon in the notification tests and then inspect the DBus message payload's `image_data` hint to see if it's correct. This adds test coverage for LibnotifyNotification::Show() and for GdkPixbufFromSkBitmap().","diff --git a/spec/api-notification-dbus-spec.ts b/spec/api-notification-dbus-spec.ts index 26e50e9bf3..3d359a307b 100644 --- a/spec/api-notification-dbus-spec.ts +++ b/spec/api-notification-dbus-spec.ts @@ -9,8 +9,12 @@ import { expect } from 'chai'; import * as dbus from 'dbus-native'; import { app } from 'electron/main'; +import { nativeImage } from 'electron/common'; import { ifdescribe } from './lib/spec-helpers'; import { promisify } from 'node:util'; +import * as path from 'node:path'; + +const fixturesPath = path.join(__dirname, 'fixtures'); const skip = process.platform !== 'linux' || process.arch === 'ia32' || @@ -92,6 +96,7 @@ ifdescribe(!skip)('Notification module (dbus)', () => { title: 'title', subtitle: 'subtitle', body: 'body', + icon: nativeImage.createFromPath(path.join(fixturesPath, 'assets', 'notification_icon.png')), replyPlaceholder: 'replyPlaceholder', sound: 'sound', closeButtonText: 'closeButtonText' @@ -117,6 +122,7 @@ ifdescribe(!skip)('Notification module (dbus)', () => { actions: [], hints: { append: 'true', + image_data: [3, 3, 12, true, 8, 4, Buffer.from([255, 0, 0, 255, 0, 0, 0, 255, 0, 0, 0, 0, 76, 255, 0, 255, 0, 0, 0, 255, 0, 0, 0, 0, 0, 38, 255, 255, 0, 0, 0, 255, 0, 0, 0, 0])], 'desktop-entry': appName, urgency: 1 } diff --git a/spec/fixtures/assets/notification_icon.png b/spec/fixtures/assets/notification_icon.png new file mode 100644 index 0000000000..cc2d155404 Binary files /dev/null and b/spec/fixtures/assets/notification_icon.png differ",test 42266546ebbaf5f5c8d29029097418c0956e641c,Keeley Hammond,2024-06-13 09:37:36,build: move hunspell generation to Linux (#42480),"diff --git a/.github/workflows/linux-pipeline.yml b/.github/workflows/linux-pipeline.yml index f7e423b6c3..7f8a2f9bfb 100644 --- a/.github/workflows/linux-pipeline.yml +++ b/.github/workflows/linux-pipeline.yml @@ -268,6 +268,11 @@ jobs: cd src gn gen out/ffmpeg --args=""import(\""//electron/build/args/ffmpeg.gn\"") use_remoteexec=true $GN_EXTRA_ARGS"" autoninja -C out/ffmpeg electron:electron_ffmpeg_zip -j $NUMBER_OF_NINJA_PROCESSES + - name: Generate Hunspell Dictionaries + if: ${{ inputs.is-release }} + run: | + cd src + autoninja -C out/Default electron:hunspell_dictionaries_zip -j $NUMBER_OF_NINJA_PROCESSES - name: Maybe Generate Libcxx if: ${{ inputs.is-release }} run: | diff --git a/.github/workflows/macos-pipeline.yml b/.github/workflows/macos-pipeline.yml index 9f0994f1ef..6ed1e5f438 100644 --- a/.github/workflows/macos-pipeline.yml +++ b/.github/workflows/macos-pipeline.yml @@ -393,11 +393,6 @@ jobs: cd src gn gen out/ffmpeg --args=""import(\""//electron/build/args/ffmpeg.gn\"") use_remoteexec=true $GN_EXTRA_ARGS"" autoninja -C out/ffmpeg electron:electron_ffmpeg_zip -j $NUMBER_OF_NINJA_PROCESSES - - name: Generate Hunspell Dictionaries - if: ${{ inputs.is-release }} - run: | - cd src - autoninja -C out/Default electron:hunspell_dictionaries_zip -j $NUMBER_OF_NINJA_PROCESSES - name: Generate TypeScript Definitions if: ${{ inputs.is-release }} run: |",build 07a68c2bf8b53ea1c639b5c12fa725e5ae81fab0,JakobDev,2024-04-19 15:58:32,"fix: don't check for Desktop Environment in unity_service.cc (#41211) Don't check for Desktop Environment in unity_service.cc","diff --git a/shell/browser/linux/unity_service.cc b/shell/browser/linux/unity_service.cc index 15f4944066..afff6ad83f 100644 --- a/shell/browser/linux/unity_service.cc +++ b/shell/browser/linux/unity_service.cc @@ -51,21 +51,10 @@ unity_launcher_entry_set_progress_visible_func entry_set_progress_visible = nullptr; void EnsureLibUnityLoaded() { - using base::nix::GetDesktopEnvironment; - if (attempted_load) return; attempted_load = true; - auto env = base::Environment::Create(); - base::nix::DesktopEnvironment desktop_env = GetDesktopEnvironment(env.get()); - - // The ""icon-tasks"" KDE task manager also honors Unity Launcher API. - if (desktop_env != base::nix::DESKTOP_ENVIRONMENT_UNITY && - desktop_env != base::nix::DESKTOP_ENVIRONMENT_KDE4 && - desktop_env != base::nix::DESKTOP_ENVIRONMENT_KDE5) - return; - // Ubuntu still hasn't given us a nice libunity.so symlink. void* unity_lib = dlopen(""libunity.so.4"", RTLD_LAZY); if (!unity_lib)",fix a0a44f07dda3562bcd7039e0270eae32be7549d6,Bruno Pitrus,2023-04-26 16:40:02,"chore: correct extra qualification causing build error with GCC (#37548) * chore: correct extra qualification causing build error with GCC * fixup for lint * chore: fix lint --------- Co-authored-by: John Kleinschmidt Co-authored-by: Shelley Vohr ","diff --git a/shell/browser/hid/electron_hid_delegate.h b/shell/browser/hid/electron_hid_delegate.h index a63328740b..7b3ee9cf8f 100644 --- a/shell/browser/hid/electron_hid_delegate.h +++ b/shell/browser/hid/electron_hid_delegate.h @@ -94,9 +94,8 @@ class ElectronHidDelegate : public content::HidDelegate, namespace base { template <> -struct base::ScopedObservationTraits< - electron::HidChooserContext, - electron::HidChooserContext::DeviceObserver> { +struct ScopedObservationTraits { static void AddObserver( electron::HidChooserContext* source, electron::HidChooserContext::DeviceObserver* observer) { diff --git a/shell/browser/serial/electron_serial_delegate.h b/shell/browser/serial/electron_serial_delegate.h index e66f6a51df..c0eb76f6a2 100644 --- a/shell/browser/serial/electron_serial_delegate.h +++ b/shell/browser/serial/electron_serial_delegate.h @@ -83,9 +83,8 @@ class ElectronSerialDelegate : public content::SerialDelegate, namespace base { template <> -struct base::ScopedObservationTraits< - electron::SerialChooserContext, - electron::SerialChooserContext::PortObserver> { +struct ScopedObservationTraits { static void AddObserver( electron::SerialChooserContext* source, electron::SerialChooserContext::PortObserver* observer) {",chore 7f8fabbe7b93f1d44421c12b42b8fc8a6cd69a96,Keeley Hammond,2024-05-14 15:57:00,chore: remove focus ring patch (#42183),"diff --git a/patches/chromium/.patches b/patches/chromium/.patches index ee057594d8..bf919fa1ae 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -128,4 +128,3 @@ refactor_expose_file_system_access_blocklist.patch partially_revert_is_newly_created_to_allow_for_browser_initiated.patch fix_use_app_launch_prefetch_namespace_for_subprocesstype.patch feat_add_support_for_missing_dialog_features_to_shell_dialogs.patch -fix_partially_revert_invalidate_focusring.patch diff --git a/patches/chromium/fix_partially_revert_invalidate_focusring.patch b/patches/chromium/fix_partially_revert_invalidate_focusring.patch deleted file mode 100644 index 3e61136b6c..0000000000 --- a/patches/chromium/fix_partially_revert_invalidate_focusring.patch +++ /dev/null @@ -1,58 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: VerteDinde -Date: Mon, 6 May 2024 11:03:08 -0700 -Subject: fix: partially revert views invalidate FocusRing when its host is - invalidated - -This reverts commit f425c438dfb11fb714655c999ba8c74b58393425. This -commit seems to be causing a sporadic crash on Ubuntu and other Linux -distros. This patch can be reverted when the issue is fixed upstream, or -when the crash is addressed. - -diff --git a/ui/views/view.cc b/ui/views/view.cc -index 4116b2a3fad02e1060bb7b137804753cf97dd7ca..46d3b426f54041efe4270bfda453358418fff160 100644 ---- a/ui/views/view.cc -+++ b/ui/views/view.cc -@@ -928,16 +928,6 @@ void View::Layout(PassKey) { - } - - void View::InvalidateLayout() { -- if (invalidating_) { -- return; -- } -- -- // There is no need to `InvalidateLayout()` when `Widget::IsClosed()`. -- if (Widget* widget = GetWidget(); widget && widget->IsClosed()) { -- return; -- } -- -- base::AutoReset invalidating(&invalidating_, true); - // We should never need to invalidate during a layout call; this tracks - // how many times that is happening. - ++invalidates_during_layout_; -@@ -945,11 +935,6 @@ void View::InvalidateLayout() { - // Always invalidate up. This is needed to handle the case of us already being - // valid, but not our parent. - needs_layout_ = true; -- -- for (ViewObserver& observer : observers_) { -- observer.OnViewLayoutInvalidated(this); -- } -- - if (HasLayoutManager()) { - GetLayoutManager()->InvalidateLayout(); - } -diff --git a/ui/views/view.h b/ui/views/view.h -index 8f377e417231698b9146d5b79dc14730e34260f7..9936899e10505f57d3b465d5613d90df8d18ded3 100644 ---- a/ui/views/view.h -+++ b/ui/views/view.h -@@ -2339,9 +2339,6 @@ class VIEWS_EXPORT View : public ui::LayerDelegate, - // it is happening. - int invalidates_during_layout_ = 0; - -- // Whether this view is in the middle of InvalidateLayout(). -- bool invalidating_ = false; -- - // The View's LayoutManager defines the sizing heuristics applied to child - // Views. The default is absolute positioning according to bounds_. - std::unique_ptr layout_manager_;",chore 3090e40c09e9bbe25907f916e60f649328714ccb,Charles Kerr,2024-11-05 10:48:23,"chore: remove executable flag from docs/api/app.md file permissions (#44548) chore: set docs/api/app.md file permissions to 644 md files should not be executable","diff --git a/docs/api/app.md b/docs/api/app.md old mode 100755 new mode 100644",chore 53458da01ef239a16fb9de80ccc04fc07a040ffa,Devin Binnie,2024-10-29 11:16:29,"docs: Fix `powerMonitor` docs for type generation of `speed-limit-change` (#44391) Fix `powerMonitor` docs for type generation of `speed-limit-change`","diff --git a/docs/api/power-monitor.md b/docs/api/power-monitor.md index 6f53114b12..0801f81a07 100644 --- a/docs/api/power-monitor.md +++ b/docs/api/power-monitor.md @@ -42,6 +42,8 @@ See https://developer.apple.com/library/archive/documentation/Performance/Concep ### Event: 'speed-limit-change' _macOS_ _Windows_ +Returns: + * `limit` number - The operating system's advertised speed limit for CPUs, in percent. Notification of a change in the operating system's advertised speed limit for",docs f5eba67f0d9b0d0838f90da7e0e91a57a550b064,Charles Kerr,2025-01-21 14:21:56,"refactor: simplify `ParseUserScript()` (#45269) refactor: simplify ParseUserScript() local variable user_script no longer needed after #43205","diff --git a/shell/browser/extensions/api/scripting/scripting_api.cc b/shell/browser/extensions/api/scripting/scripting_api.cc index 4745cc874b..448cb8aae2 100644 --- a/shell/browser/extensions/api/scripting/scripting_api.cc +++ b/shell/browser/extensions/api/scripting/scripting_api.cc @@ -490,14 +490,8 @@ std::unique_ptr ParseUserScript( ConvertRegisteredContentScriptToSerializedUserScript( std::move(content_script)); - std::unique_ptr user_script = - script_serialization::ParseSerializedUserScript( - serialized_script, extension, allowed_in_incognito, error); - if (!user_script) { - return nullptr; // Parsing failed. - } - - return user_script; + return script_serialization::ParseSerializedUserScript( + serialized_script, extension, allowed_in_incognito, error); } // Converts a UserScript object to a api::scripting::RegisteredContentScript",refactor 39d36e4462a0b84c469c72ddcfcf5c426a58482d,John Kleinschmidt,2023-10-31 17:05:16,"build: actually show github upload output if verbose is true. (#40393) * build: actually show github upload output if verbose is true. * chore: fixup lint","diff --git a/script/release/uploaders/upload.py b/script/release/uploaders/upload.py index 96e195f497..641f8ae6f2 100755 --- a/script/release/uploaders/upload.py +++ b/script/release/uploaders/upload.py @@ -363,8 +363,10 @@ def upload_io_to_github(release, filename, filepath, version): (filename)) script_path = os.path.join( ELECTRON_DIR, 'script', 'release', 'uploaders', 'upload-to-github.ts') - execute([TS_NODE, script_path, filepath, filename, str(release['id']), - version]) + upload_gh_output = execute([TS_NODE, script_path, filepath, filename, + str(release['id']), version]) + if is_verbose_mode(): + print(upload_gh_output) def upload_sha256_checksum(version, file_path, key_prefix=None):",build 1e219e457b7d04545d76abdc62f33e118a5f46ac,Samuel Attard,2024-06-13 01:43:33,build: generate deps hash quietly (#42476),"diff --git a/script/generate-deps-hash.js b/script/generate-deps-hash.js index c927fce645..11f0634ca3 100644 --- a/script/generate-deps-hash.js +++ b/script/generate-deps-hash.js @@ -36,12 +36,10 @@ addAllFiles(path.resolve(__dirname, '../patches')); // Create Hash const hasher = crypto.createHash('SHA256'); const addToHashAndLog = (s) => { - console.log('Hashing:', s); return hasher.update(s); }; addToHashAndLog(`HASH_VERSION:${HASH_VERSIONS[process.platform] || FALLBACK_HASH_VERSION}`); for (const file of filesToHash) { - console.log('Hashing Content:', file, crypto.createHash('SHA256').update(fs.readFileSync(file)).digest('hex')); hasher.update(fs.readFileSync(file)); } ",build 1ef5406c8cd88a4de8d8d70b32ca383ecfc907a6,David Sanders,2024-05-14 13:32:52,chore: enable no autolink markdownlint rule (#42127),"diff --git a/.markdownlint.json b/.markdownlint.json index 96357baa52..5e26ae888a 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -1,5 +1,9 @@ { ""extends"": ""@electron/lint-roller/configs/markdownlint.json"", + ""link-image-style"": { + ""autolink"": false, + ""shortcut"": false + }, ""no-angle-brackets"": true, ""no-curly-braces"": true, ""no-inline-html"": {",chore 089eb34e8dbe9f74867e13ee914188379543873e,Brandon Fowler,2023-11-01 20:27:23,docs: add `bypassCustomProtocolHandlers` to `ses.fetch` (#40358),"diff --git a/docs/api/session.md b/docs/api/session.md index 8eb65c582d..b058ea4768 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -785,7 +785,7 @@ Returns `Promise` - Resolves when all connections are closed. #### `ses.fetch(input[, init])` * `input` string | [GlobalRequest](https://nodejs.org/api/globals.html#request) -* `init` [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/fetch#options) (optional) +* `init` [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/fetch#options) & { bypassCustomProtocolHandlers?: boolean } (optional) Returns `Promise` - see [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response). ",docs 6e361537994dfeedae2f64b07243118ba0d838d7,Samuel Attard,2024-03-27 09:50:55,build: fix potential source of errors in issue workflow (#41715),"diff --git a/.github/workflows/issue-opened.yml b/.github/workflows/issue-opened.yml index 809fc8a46c..6e69b2615e 100644 --- a/.github/workflows/issue-opened.yml +++ b/.github/workflows/issue-opened.yml @@ -38,6 +38,8 @@ jobs: - run: npm install mdast-util-from-markdown@2.0.0 unist-util-select@5.1.0 - name: Add labels uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + env: + ISSUE_BODY: ${{ github.event.issue.body }} with: github-token: ${{ steps.generate-token.outputs.token }} script: | @@ -47,7 +49,7 @@ jobs: const [ owner, repo ] = '${{ github.repository }}'.split('/'); const issue_number = ${{ github.event.issue.number }}; - const tree = fromMarkdown(`${{ github.event.issue.body }}`); + const tree = fromMarkdown(process.env.ISSUE_BODY); const labels = []; ",build e9d5c3517cf3a6090826d7e8ca91c2d059a7caca,Jeremy Rose,2023-04-04 01:31:49,"fix: apply csp correctly when contextIsolation: false (#37756) * fix: apply csp correctly when contextIsolation: false * better comments","diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 28447a2775..ca65a4fd6d 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -184,9 +184,10 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( v8::Local context, v8::Local source, bool is_code_like) { - // If we're running with contextIsolation enabled in the renderer process, - // fall back to Blink's logic. if (node::Environment::GetCurrent(context) == nullptr) { + // No node environment means we're in the renderer process, either in a + // sandboxed renderer or in an unsandboxed renderer with context isolation + // enabled. if (gin_helper::Locker::IsBrowserProcess()) { NOTREACHED(); return {false, {}}; @@ -195,6 +196,22 @@ v8::ModifyCodeGenerationFromStringsResult ModifyCodeGenerationFromStrings( context, source, is_code_like); } + // If we get here then we have a node environment, so either a) we're in the + // main process, or b) we're in the renderer process in a context that has + // both node and blink, i.e. contextIsolation disabled. + + // If we're in the main process, delegate to node. + if (gin_helper::Locker::IsBrowserProcess()) { + return node::ModifyCodeGenerationFromStrings(context, source, is_code_like); + } + + // If we're in the renderer with contextIsolation disabled, ask blink first + // (for CSP), and iff that allows codegen, delegate to node. + v8::ModifyCodeGenerationFromStringsResult result = + blink::V8Initializer::CodeGenerationCheckCallbackInMainThread( + context, source, is_code_like); + if (!result.codegen_allowed) + return result; return node::ModifyCodeGenerationFromStrings(context, source, is_code_like); } diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index cc3fa6a3ac..3453afa0d3 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -352,28 +352,74 @@ describe('web security', () => { }); }); - describe('csp in sandbox: false', () => { - it('is correctly applied', async () => { - const w = new BrowserWindow({ - show: false, - webPreferences: { sandbox: false } + describe('csp', () => { + for (const sandbox of [true, false]) { + describe(`when sandbox: ${sandbox}`, () => { + for (const contextIsolation of [true, false]) { + describe(`when contextIsolation: ${contextIsolation}`, () => { + it('prevents eval from running in an inline script', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { sandbox, contextIsolation } + }); + w.loadURL(`data:text/html, + + + `); + const [,, message] = await once(w.webContents, 'console-message'); + expect(message).to.match(/Refused to evaluate a string/); + }); + + it('does not prevent eval from running in an inline script when there is no csp', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { sandbox, contextIsolation } + }); + w.loadURL(`data:text/html, + `); + const [,, message] = await once(w.webContents, 'console-message'); + expect(message).to.equal('true'); + }); + + it('prevents eval from running in executeJavaScript', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { sandbox, contextIsolation } + }); + w.loadURL('data:text/html,'); + await expect(w.webContents.executeJavaScript('eval(""true"")')).to.be.rejected(); + }); + + it('does not prevent eval from running in executeJavaScript when there is no csp', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { sandbox, contextIsolation } + }); + w.loadURL('data:text/html,'); + expect(await w.webContents.executeJavaScript('eval(""true"")')).to.be.true(); + }); + }); + } }); - w.loadURL(`data:text/html, - - - `); - const [,, message] = await once(w.webContents, 'console-message'); - expect(message).to.equal('success'); - }); + } }); it('does not crash when multiple WebContent are created with web security disabled', () => {",fix 9b6ba1ced11b705daedca170990ec762406243fd,Keeley Hammond,2025-02-25 09:28:09,fix: re-enable MacWebContentsOcclusion feature flag (#45775),"diff --git a/patches/chromium/revert_code_health_clean_up_stale_macwebcontentsocclusion.patch b/patches/chromium/revert_code_health_clean_up_stale_macwebcontentsocclusion.patch index 6a9a3c33e9..fcd0b03cb7 100644 --- a/patches/chromium/revert_code_health_clean_up_stale_macwebcontentsocclusion.patch +++ b/patches/chromium/revert_code_health_clean_up_stale_macwebcontentsocclusion.patch @@ -17,11 +17,59 @@ Refs: https://chromium-review.googlesource.com/c/chromium/src/+/6078344 This partially (leaves the removal of the feature flag) reverts ef865130abd5539e7bce12308659b19980368f12. +diff --git a/content/app_shim_remote_cocoa/web_contents_occlusion_checker_mac.h b/content/app_shim_remote_cocoa/web_contents_occlusion_checker_mac.h +index 428902f90950b2e9434c8a624a313268ebb80cd4..afcc3bc481be6a16119f7e2af647276cb0dafa1e 100644 +--- a/content/app_shim_remote_cocoa/web_contents_occlusion_checker_mac.h ++++ b/content/app_shim_remote_cocoa/web_contents_occlusion_checker_mac.h +@@ -12,6 +12,8 @@ + #import ""content/app_shim_remote_cocoa/web_contents_view_cocoa.h"" + #include ""content/common/web_contents_ns_view_bridge.mojom.h"" + ++extern CONTENT_EXPORT const base::FeatureParam ++ kEnhancedWindowOcclusionDetection; + extern CONTENT_EXPORT const base::FeatureParam + kDisplaySleepAndAppHideDetection; + +diff --git a/content/app_shim_remote_cocoa/web_contents_occlusion_checker_mac.mm b/content/app_shim_remote_cocoa/web_contents_occlusion_checker_mac.mm +index 32523e6a6f800de3917d18825f94c66ef4ea4388..634d68b9a2840d7c9e7c3b5e23d8b1b8ac02456b 100644 +--- a/content/app_shim_remote_cocoa/web_contents_occlusion_checker_mac.mm ++++ b/content/app_shim_remote_cocoa/web_contents_occlusion_checker_mac.mm +@@ -19,6 +19,12 @@ + #include ""content/public/browser/content_browser_client.h"" + #include ""content/public/common/content_client.h"" + ++using features::kMacWebContentsOcclusion; ++ ++// Experiment features. ++const base::FeatureParam kEnhancedWindowOcclusionDetection{ ++ &kMacWebContentsOcclusion, ""EnhancedWindowOcclusionDetection"", false}; ++ + namespace { + + NSString* const kWindowDidChangePositionInWindowList = +@@ -127,7 +133,8 @@ - (void)dealloc { + + - (BOOL)isManualOcclusionDetectionEnabled { + return [WebContentsOcclusionCheckerMac +- manualOcclusionDetectionSupportedForCurrentMacOSVersion]; ++ manualOcclusionDetectionSupportedForCurrentMacOSVersion] && ++ kEnhancedWindowOcclusionDetection.Get(); + } + + // Alternative implementation of orderWindow:relativeTo:. Replaces diff --git a/content/app_shim_remote_cocoa/web_contents_view_cocoa.mm b/content/app_shim_remote_cocoa/web_contents_view_cocoa.mm -index 2991489fae8a4eecad97b1ecb2271f096d9a9229..6c735286bf901fc7ff3872830d83fe119dd3bd33 100644 +index 2991489fae8a4eecad97b1ecb2271f096d9a9229..93b7aa620ad1da250ac06e3383ca689732de12cd 100644 --- a/content/app_shim_remote_cocoa/web_contents_view_cocoa.mm +++ b/content/app_shim_remote_cocoa/web_contents_view_cocoa.mm -@@ -126,13 +126,11 @@ @implementation WebContentsViewCocoa { +@@ -29,6 +29,7 @@ + #include ""ui/resources/grit/ui_resources.h"" + + using content::DropData; ++using features::kMacWebContentsOcclusion; + using remote_cocoa::mojom::DraggingInfo; + using remote_cocoa::mojom::SelectionDirection; + +@@ -126,12 +127,15 @@ @implementation WebContentsViewCocoa { gfx::Rect _windowControlsOverlayRect; @@ -29,15 +77,25 @@ index 2991489fae8a4eecad97b1ecb2271f096d9a9229..6c735286bf901fc7ff3872830d83fe11 BOOL _willSetWebContentsOccludedAfterDelay; } --+ (void)initialize { + + (void)initialize { - // Create the WebContentsOcclusionCheckerMac shared instance. - [WebContentsOcclusionCheckerMac sharedInstance]; --} -++ (void)initialize { } ++ if (base::FeatureList::IsEnabled(kMacWebContentsOcclusion)) { ++ // Create the WebContentsOcclusionCheckerMac shared instance. ++ [WebContentsOcclusionCheckerMac sharedInstance]; ++ } + } - (instancetype)initWithViewsHostableView:(ui::ViewsHostableView*)v { - self = [super initWithFrame:NSZeroRect tracking:YES]; -@@ -487,6 +485,20 @@ - (void)updateWebContentsVisibility { +@@ -442,6 +446,7 @@ - (void)updateWebContentsVisibility: + (remote_cocoa::mojom::Visibility)visibility { + using remote_cocoa::mojom::Visibility; + ++ DCHECK(base::FeatureList::IsEnabled(kMacWebContentsOcclusion)); + if (!_host) + return; + +@@ -487,6 +492,20 @@ - (void)updateWebContentsVisibility { [self updateWebContentsVisibility:visibility]; } @@ -58,10 +116,29 @@ index 2991489fae8a4eecad97b1ecb2271f096d9a9229..6c735286bf901fc7ff3872830d83fe11 - (void)resizeSubviewsWithOldSize:(NSSize)oldBoundsSize { // Subviews do not participate in auto layout unless the the size this view // changes. This allows RenderWidgetHostViewMac::SetBounds(..) to select a -@@ -509,11 +521,20 @@ - (void)viewWillMoveToWindow:(NSWindow*)newWindow { +@@ -509,11 +528,39 @@ - (void)viewWillMoveToWindow:(NSWindow*)newWindow { NSWindow* oldWindow = [self window]; ++ if (base::FeatureList::IsEnabled(kMacWebContentsOcclusion)) { ++ if (oldWindow) { ++ [notificationCenter ++ removeObserver:self ++ name:NSWindowDidChangeOcclusionStateNotification ++ object:oldWindow]; ++ } ++ ++ if (newWindow) { ++ [notificationCenter ++ addObserver:self ++ selector:@selector(windowChangedOcclusionState:) ++ name:NSWindowDidChangeOcclusionStateNotification ++ object:newWindow]; ++ } ++ ++ return; ++ } ++ + _inFullScreenTransition = NO; if (oldWindow) { - [notificationCenter @@ -83,7 +160,7 @@ index 2991489fae8a4eecad97b1ecb2271f096d9a9229..6c735286bf901fc7ff3872830d83fe11 } if (newWindow) { -@@ -521,27 +542,49 @@ - (void)viewWillMoveToWindow:(NSWindow*)newWindow { +@@ -521,26 +568,66 @@ - (void)viewWillMoveToWindow:(NSWindow*)newWindow { selector:@selector(windowChangedOcclusionState:) name:NSWindowDidChangeOcclusionStateNotification object:newWindow]; @@ -114,7 +191,10 @@ index 2991489fae8a4eecad97b1ecb2271f096d9a9229..6c735286bf901fc7ff3872830d83fe11 - NSString* occlusionCheckerKey = [WebContentsOcclusionCheckerMac className]; - if (userInfo[occlusionCheckerKey] != nil) - [self updateWebContentsVisibility]; -+ [self legacyUpdateWebContentsVisibility]; ++ if (!base::FeatureList::IsEnabled(kMacWebContentsOcclusion)) { ++ [self legacyUpdateWebContentsVisibility]; ++ return; ++ } +} + +- (void)fullscreenTransitionStarted:(NSNotification*)notification { @@ -126,18 +206,62 @@ index 2991489fae8a4eecad97b1ecb2271f096d9a9229..6c735286bf901fc7ff3872830d83fe11 } - (void)viewDidMoveToWindow { -- [self updateWebContentsVisibility]; -+ [self legacyUpdateWebContentsVisibility]; ++ if (!base::FeatureList::IsEnabled(kMacWebContentsOcclusion)) { ++ [self legacyUpdateWebContentsVisibility]; ++ return; ++ } ++ + [self updateWebContentsVisibility]; } - (void)viewDidHide { -- [self updateWebContentsVisibility]; -+ [self legacyUpdateWebContentsVisibility]; ++ if (!base::FeatureList::IsEnabled(kMacWebContentsOcclusion)) { ++ [self legacyUpdateWebContentsVisibility]; ++ return; ++ } ++ + [self updateWebContentsVisibility]; } - (void)viewDidUnhide { -- [self updateWebContentsVisibility]; -+ [self legacyUpdateWebContentsVisibility]; ++ if (!base::FeatureList::IsEnabled(kMacWebContentsOcclusion)) { ++ [self legacyUpdateWebContentsVisibility]; ++ return; ++ } ++ + [self updateWebContentsVisibility]; } - // ViewsHostable protocol implementation. +diff --git a/content/common/features.cc b/content/common/features.cc +index be5847985950e9136fc975fdbc021308f48f41b5..a5062c8fb5c5d9f1427819131b71ad6896e9d1df 100644 +--- a/content/common/features.cc ++++ b/content/common/features.cc +@@ -262,6 +262,14 @@ BASE_FEATURE(kIOSurfaceCapturer, + base::FEATURE_ENABLED_BY_DEFAULT); + #endif + ++// Feature that controls whether WebContentsOcclusionChecker should handle ++// occlusion notifications. ++#if BUILDFLAG(IS_MAC) ++BASE_FEATURE(kMacWebContentsOcclusion, ++ ""MacWebContentsOcclusion"", ++ base::FEATURE_ENABLED_BY_DEFAULT); ++#endif ++ + // If this feature is enabled, media-device enumerations use a cache that is + // invalidated upon notifications sent by base::SystemMonitor. If disabled, the + // cache is considered invalid on every enumeration request. +diff --git a/content/common/features.h b/content/common/features.h +index 06562dd07ac4f1cad1011d99aed6c09958044486..9748070bc26f8314faec99afdb20a5d91bc9dde2 100644 +--- a/content/common/features.h ++++ b/content/common/features.h +@@ -68,6 +68,9 @@ CONTENT_EXPORT BASE_DECLARE_FEATURE(kInterestGroupUpdateIfOlderThan); + #if BUILDFLAG(IS_MAC) + CONTENT_EXPORT BASE_DECLARE_FEATURE(kIOSurfaceCapturer); + #endif ++#if BUILDFLAG(IS_MAC) ++CONTENT_EXPORT BASE_DECLARE_FEATURE(kMacWebContentsOcclusion); ++#endif + CONTENT_EXPORT BASE_DECLARE_FEATURE(kMediaDevicesSystemMonitorCache); + CONTENT_EXPORT BASE_DECLARE_FEATURE(kMediaStreamTrackTransfer); + CONTENT_EXPORT BASE_DECLARE_FEATURE(kMojoDedicatedThread); diff --git a/shell/browser/feature_list.cc b/shell/browser/feature_list.cc index 0d8d268725..f063fbef92 100644 --- a/shell/browser/feature_list.cc +++ b/shell/browser/feature_list.cc @@ -11,6 +11,7 @@ #include ""base/feature_list.h"" #include ""base/metrics/field_trial.h"" #include ""components/spellcheck/common/spellcheck_features.h"" +#include ""content/common/features.h"" #include ""content/public/common/content_features.h"" #include ""electron/buildflags/buildflags.h"" #include ""media/base/media_switches.h"" @@ -48,6 +49,13 @@ void InitializeFeatureList() { std::string("","") + spellcheck::kWinDelaySpellcheckServiceInit.name; #endif +#if BUILDFLAG(IS_MAC) + disable_features += + // MacWebContentsOcclusion is causing some odd visibility + // issues with multiple web contents + std::string("","") + features::kMacWebContentsOcclusion.name; +#endif + #if BUILDFLAG(ENABLE_PDF_VIEWER) // Enable window.showSaveFilePicker api for saving pdf files. // Refs https://issues.chromium.org/issues/373852607",fix 83748bd1817df54c2d2ac1a46d29ca7dceaba9d9,Erick Zhao,2024-06-12 10:58:21,"docs: clean up MAS submission guide (#42368) * docs: clean up MAS submission guide * add info from osx-sign wiki","diff --git a/docs/tutorial/mac-app-store-submission-guide.md b/docs/tutorial/mac-app-store-submission-guide.md index 7f029065e5..53797485c4 100644 --- a/docs/tutorial/mac-app-store-submission-guide.md +++ b/docs/tutorial/mac-app-store-submission-guide.md @@ -20,7 +20,7 @@ You also have to register an Apple Developer account and join the Electron apps can be distributed through Mac App Store or outside it. Each way requires different ways of signing and testing. This guide focuses on -distribution via Mac App Store, but will also mention other methods. +distribution via Mac App Store. The following steps describe how to get the certificates from Apple, how to sign Electron apps, and how to test them. @@ -104,26 +104,15 @@ the App Sandbox. The standard darwin build of Electron will fail to launch when run under App Sandbox. When signing the app with `@electron/osx-sign`, it will automatically add the -necessary entitlements to your app's entitlements, but if you are using custom -entitlements, you must ensure App Sandbox capacity is added: +necessary entitlements to your app's entitlements. -```xml - - - - - com.apple.security.app-sandbox - - - -``` - -#### Extra steps without `electron-osx-sign` +
+Extra steps without `electron-osx-sign` If you are signing your app without using `@electron/osx-sign`, you must ensure the app bundle's entitlements have at least following keys: -```xml +```xml title='entitlements.plist' @@ -174,6 +163,7 @@ When using `@electron/osx-sign` the `ElectronTeamID` key will be added automatically by extracting the Team ID from the certificate's name. You may need to manually add this key if `@electron/osx-sign` could not find the correct Team ID. +
### Sign apps for development @@ -181,8 +171,14 @@ To sign an app that can run on your development machine, you must sign it with the ""Apple Development"" certificate and pass the provisioning profile to `@electron/osx-sign`. -```bash -electron-osx-sign YourApp.app --identity='Apple Development' --provisioning-profile=/path/to/yourapp.provisionprofile +```js @ts-nocheck +const { signAsync } = require('@electron/osx-sign') + +signAsync({ + app: '/path/to/your.app', + identity: 'Apple Development', + provisioningProfile: '/path/to/your.provisionprofile' +}) ``` If you are signing without `@electron/osx-sign`, you must place the provisioning @@ -198,30 +194,16 @@ To sign an app that will be submitted to Mac App Store, you must sign it with the ""Apple Distribution"" certificate. Note that apps signed with this certificate will not run anywhere, unless it is downloaded from Mac App Store. -```bash -electron-osx-sign YourApp.app --identity='Apple Distribution' -``` - -### Sign apps for distribution outside the Mac App Store +```js @ts-nocheck +const { signAsync } = require('@electron/osx-sign') -If you don't plan to submit the app to Mac App Store, you can sign it the -""Developer ID Application"" certificate. In this way there is no requirement on -App Sandbox, and you should use the normal darwin build of Electron if you don't -use App Sandbox. - -```bash -electron-osx-sign YourApp.app --identity='Developer ID Application' --no-gatekeeper-assess +signAsync({ + app: 'path/to/your.app', + identity: 'Apple Distribution' +}) ``` -By passing `--no-gatekeeper-assess`, `@electron/osx-sign` will skip the macOS -GateKeeper check as your app usually has not been notarized yet by this step. - - -This guide does not cover [App Notarization][app-notarization], but you might -want to do it otherwise Apple may prevent users from using your app outside Mac -App Store. - -## Submit Apps to the Mac App Store +## Submit apps to the Mac App Store After signing the app with the ""Apple Distribution"" certificate, you can continue to submit it to Mac App Store. @@ -263,10 +245,43 @@ more information. ### Additional entitlements +Every app running under the App Sandbox will run under a limited set of permissions, +which limits potential damage from malicious code. Depending on which Electron APIs your app uses, you may need to add additional entitlements to your app's entitlements file. Otherwise, the App Sandbox may prevent you from using them. +Entitlements are specified using a file with format like +property list (`.plist`) or XML. You must provide an entitlement file for the +application bundle itself and a child entitlement file which basically describes +an inheritance of properties, specified for all other enclosing executable files +like binaries, frameworks (`.framework`), and dynamically linked libraries (`.dylib`). + +A full list of entitlements is available in the [App Sandbox][app-sandboxing] +documentation, but below are a few entitlements you might need for your +MAS app. + +With `@electron/osx-sign`, you can set custom entitlements per file as such: + +```js @ts-nocheck +const { signAsync } = require('@electron/osx-sign') + +function getEntitlementsForFile (filePath) { + if (filePath.startsWith('my-path-1')) { + return './my-path-1.plist' + } else { + return './alternate.plist' + } +} + +signAsync({ + optionsForFile: (filePath) => ({ + // Ensure you return the right entitlements path here based on the file being signed. + entitlements: getEntitlementsForFile(filePath) + }) +}) +``` + #### Network access Enable outgoing network connections to allow your app to connect to a server: @@ -342,12 +357,11 @@ Electron uses following cryptographic algorithms: [developer-program]: https://developer.apple.com/support/compare-memberships/ [@electron/osx-sign]: https://github.com/electron/osx-sign -[app-sandboxing]: https://developer.apple.com/app-sandboxing/ -[app-notarization]: https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution -[submitting-your-app]: https://developer.apple.com/library/mac/documentation/IDEs/Conceptual/AppDistributionGuide/SubmittingYourApp/SubmittingYourApp.html -[create-record]: https://help.apple.com/app-store-connect/#/dev2cd126805 +[app-sandboxing]: https://developer.apple.com/documentation/security/app_sandbox +[submitting-your-app]: https://help.apple.com/xcode/mac/current/#/dev067853c94 +[create-record]: https://developer.apple.com/help/app-store-connect/create-an-app-record/add-a-new-app [apple-transporter]: https://help.apple.com/itc/transporteruserguide/en.lproj/static.html -[submit-for-review]: https://developer.apple.com/library/ios/documentation/LanguagesUtilities/Conceptual/iTunesConnect_Guide/Chapters/SubmittingTheApp.html +[submit-for-review]: https://developer.apple.com/help/app-store-connect/manage-submissions-to-app-review/submit-for-review [export-compliance]: https://help.apple.com/app-store-connect/#/devc3f64248f [user-selected]: https://developer.apple.com/library/mac/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingAppSandbox.html#//apple_ref/doc/uid/TP40011195-CH4-SW6 [network-access]: https://developer.apple.com/library/ios/documentation/Miscellaneous/Reference/EntitlementKeyReference/Chapters/EnablingAppSandbox.html#//apple_ref/doc/uid/TP40011195-CH4-SW9",docs 1f19a744176a2407d9b970e8946d30e9a6507078,Shelley Vohr,2023-08-01 08:07:30,"fix: potential crash calling `tray.popUpContextMenu()` (#39231) fix: potential crash calling tray.popUpContextMenu","diff --git a/shell/browser/api/electron_api_tray.cc b/shell/browser/api/electron_api_tray.cc index e1bcab8ffc..8b729fb00e 100644 --- a/shell/browser/api/electron_api_tray.cc +++ b/shell/browser/api/electron_api_tray.cc @@ -342,7 +342,9 @@ void Tray::PopUpContextMenu(gin::Arguments* args) { } } } - tray_icon_->PopUpContextMenu(pos, menu.IsEmpty() ? nullptr : menu->model()); + + tray_icon_->PopUpContextMenu( + pos, menu.IsEmpty() ? nullptr : menu->model()->GetWeakPtr()); } void Tray::CloseContextMenu() { diff --git a/shell/browser/ui/tray_icon.cc b/shell/browser/ui/tray_icon.cc index 07b801583f..7f22f3b6da 100644 --- a/shell/browser/ui/tray_icon.cc +++ b/shell/browser/ui/tray_icon.cc @@ -21,7 +21,7 @@ void TrayIcon::RemoveBalloon() {} void TrayIcon::Focus() {} void TrayIcon::PopUpContextMenu(const gfx::Point& pos, - raw_ptr menu_model) {} + base::WeakPtr menu_model) {} void TrayIcon::CloseContextMenu() {} diff --git a/shell/browser/ui/tray_icon.h b/shell/browser/ui/tray_icon.h index a8b4581a43..85a66163b6 100644 --- a/shell/browser/ui/tray_icon.h +++ b/shell/browser/ui/tray_icon.h @@ -89,7 +89,7 @@ class TrayIcon { // Popups the menu. virtual void PopUpContextMenu(const gfx::Point& pos, - raw_ptr menu_model); + base::WeakPtr menu_model); virtual void CloseContextMenu(); diff --git a/shell/browser/ui/tray_icon_cocoa.h b/shell/browser/ui/tray_icon_cocoa.h index 6f6241df68..d7a7904571 100644 --- a/shell/browser/ui/tray_icon_cocoa.h +++ b/shell/browser/ui/tray_icon_cocoa.h @@ -32,11 +32,11 @@ class TrayIconCocoa : public TrayIcon { std::string GetTitle() override; void SetIgnoreDoubleClickEvents(bool ignore) override; bool GetIgnoreDoubleClickEvents() override; - void PopUpOnUI(ElectronMenuModel* menu_model); + void PopUpOnUI(base::WeakPtr menu_model); void PopUpContextMenu(const gfx::Point& pos, - raw_ptr) override; + base::WeakPtr menu_model) override; void CloseContextMenu() override; - void SetContextMenu(raw_ptr) override; + void SetContextMenu(raw_ptr menu_model) override; gfx::Rect GetBounds() override; private: diff --git a/shell/browser/ui/tray_icon_cocoa.mm b/shell/browser/ui/tray_icon_cocoa.mm index e0d5f5c6a4..9d6d6d4bd0 100644 --- a/shell/browser/ui/tray_icon_cocoa.mm +++ b/shell/browser/ui/tray_icon_cocoa.mm @@ -83,6 +83,11 @@ [self removeTrackingArea:trackingArea_]; trackingArea_ = nil; } + + // Ensure any open menu is closed. + if ([statusItem_ menu]) + [[statusItem_ menu] cancelTracking]; + [[NSStatusBar systemStatusBar] removeStatusItem:statusItem_]; [self removeFromSuperview]; statusItem_ = nil; @@ -228,7 +233,6 @@ if (menuController_ && ![menuController_ isMenuOpen]) { // Ensure the UI can update while the menu is fading out. base::ScopedPumpMessagesInPrivateModes pump_private; - [[statusItem_ button] performClick:self]; } } @@ -354,16 +358,16 @@ bool TrayIconCocoa::GetIgnoreDoubleClickEvents() { return [status_item_view_ getIgnoreDoubleClickEvents]; } -void TrayIconCocoa::PopUpOnUI(ElectronMenuModel* menu_model) { - [status_item_view_ popUpContextMenu:menu_model]; +void TrayIconCocoa::PopUpOnUI(base::WeakPtr menu_model) { + [status_item_view_ popUpContextMenu:menu_model.get()]; } -void TrayIconCocoa::PopUpContextMenu(const gfx::Point& pos, - raw_ptr menu_model) { +void TrayIconCocoa::PopUpContextMenu( + const gfx::Point& pos, + base::WeakPtr menu_model) { content::GetUIThreadTaskRunner({})->PostTask( - FROM_HERE, - base::BindOnce(&TrayIconCocoa::PopUpOnUI, weak_factory_.GetWeakPtr(), - base::Unretained(menu_model))); + FROM_HERE, base::BindOnce(&TrayIconCocoa::PopUpOnUI, + weak_factory_.GetWeakPtr(), menu_model)); } void TrayIconCocoa::CloseContextMenu() { diff --git a/shell/browser/ui/win/notify_icon.cc b/shell/browser/ui/win/notify_icon.cc index 4a5171328d..195589f877 100644 --- a/shell/browser/ui/win/notify_icon.cc +++ b/shell/browser/ui/win/notify_icon.cc @@ -86,7 +86,7 @@ void NotifyIcon::HandleClickEvent(int modifiers, return; } else if (!double_button_click) { // single right click if (menu_model_) - PopUpContextMenu(gfx::Point(), menu_model_); + PopUpContextMenu(gfx::Point(), menu_model_->GetWeakPtr()); else NotifyRightClicked(bounds, modifiers); } @@ -191,7 +191,7 @@ void NotifyIcon::Focus() { } void NotifyIcon::PopUpContextMenu(const gfx::Point& pos, - raw_ptr menu_model) { + base::WeakPtr menu_model) { // Returns if context menu isn't set. if (menu_model == nullptr && menu_model_ == nullptr) return; @@ -209,9 +209,13 @@ void NotifyIcon::PopUpContextMenu(const gfx::Point& pos, if (pos.IsOrigin()) rect.set_origin(display::Screen::GetScreen()->GetCursorScreenPoint()); - menu_runner_ = std::make_unique( - menu_model != nullptr ? menu_model : menu_model_, - views::MenuRunner::HAS_MNEMONICS); + if (menu_model) { + menu_runner_ = std::make_unique( + menu_model.get(), views::MenuRunner::HAS_MNEMONICS); + } else { + menu_runner_ = std::make_unique( + menu_model_, views::MenuRunner::HAS_MNEMONICS); + } menu_runner_->RunMenuAt(nullptr, nullptr, rect, views::MenuAnchorPosition::kTopLeft, ui::MENU_SOURCE_MOUSE); diff --git a/shell/browser/ui/win/notify_icon.h b/shell/browser/ui/win/notify_icon.h index b0d0b78eb0..ee45864292 100644 --- a/shell/browser/ui/win/notify_icon.h +++ b/shell/browser/ui/win/notify_icon.h @@ -13,6 +13,7 @@ #include #include ""base/compiler_specific.h"" +#include ""base/memory/weak_ptr.h"" #include ""base/win/scoped_gdi_object.h"" #include ""shell/browser/ui/tray_icon.h"" #include ""shell/browser/ui/win/notify_icon_host.h"" @@ -65,7 +66,7 @@ class NotifyIcon : public TrayIcon { void RemoveBalloon() override; void Focus() override; void PopUpContextMenu(const gfx::Point& pos, - raw_ptr menu_model) override; + base::WeakPtr menu_model) override; void CloseContextMenu() override; void SetContextMenu(raw_ptr menu_model) override; gfx::Rect GetBounds() override;",fix 9f1bb531ba47e7011dce88e09f047c3d116d76d7,David Sanders,2025-02-03 13:13:36,"build: always use python3 in `script/lib/get-version.js` (#45400) build: always use python3 in script/lib/get-version.js","diff --git a/.github/workflows/pipeline-segment-electron-test.yml b/.github/workflows/pipeline-segment-electron-test.yml index e3a2336c51..42e6675f24 100644 --- a/.github/workflows/pipeline-segment-electron-test.yml +++ b/.github/workflows/pipeline-segment-electron-test.yml @@ -74,6 +74,7 @@ jobs: echo ""C:\Program Files\Git\cmd"" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo ""C:\Program Files\Git\bin"" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append echo ""C:\Python311"" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + cp ""C:\Python311\python.exe"" ""C:\Python311\python3.exe"" - name: Setup Node.js/npm if: ${{ inputs.target-platform == 'win' }} uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a diff --git a/script/lib/get-version.js b/script/lib/get-version.js index 33f1ca219f..7179b20907 100644 --- a/script/lib/get-version.js +++ b/script/lib/get-version.js @@ -19,10 +19,8 @@ module.exports.getElectronVersion = () => { // Error may happen when trying to get version before running gn, which is a // valid case and error will be ignored. } - // Most win32 machines have python.exe but no python3.exe. - const python = process.platform === 'win32' ? 'python.exe' : 'python3'; // Get the version from git tag if it is not defined in gn args. - const output = spawnSync(python, [path.join(ELECTRON_DIR, 'script', 'get-git-version.py')]); + const output = spawnSync('python3', [path.join(ELECTRON_DIR, 'script', 'get-git-version.py')]); if (output.status !== 0) { throw new Error(`Failed to get git tag, script quit with ${output.status}: ${output.stdout}`); }",build c3f02d7df2a0282adc1c453ad998c7fd864e709b,Shelley Vohr,2023-01-20 23:35:06,chore: cleanup autofill agent shutdown sequence (#36954),"diff --git a/shell/renderer/electron_autofill_agent.cc b/shell/renderer/electron_autofill_agent.cc index c648ee17fb..359cba7fe1 100644 --- a/shell/renderer/electron_autofill_agent.cc +++ b/shell/renderer/electron_autofill_agent.cc @@ -4,6 +4,7 @@ #include ""shell/renderer/electron_autofill_agent.h"" +#include #include #include @@ -20,9 +21,23 @@ namespace electron { namespace { -const size_t kMaxDataLength = 1024; +const size_t kMaxStringLength = 1024; const size_t kMaxListSize = 512; +// Copied from components/autofill/content/renderer/form_autofill_util.cc +void TrimStringVectorForIPC(std::vector* strings) { + // Limit the size of the vector. + if (strings->size() > kMaxListSize) + strings->resize(kMaxListSize); + + // Limit the size of the strings in the vector. + for (auto& string : *strings) { + if (string.length() > kMaxStringLength) + string.resize(kMaxStringLength); + } +} + +// Copied from components/autofill/content/renderer/form_autofill_util.cc. void GetDataListSuggestions(const blink::WebInputElement& element, std::vector* values, std::vector* labels) { @@ -33,19 +48,11 @@ void GetDataListSuggestions(const blink::WebInputElement& element, else labels->push_back(std::u16string()); } -} -void TrimStringVectorForIPC(std::vector* strings) { - // Limit the size of the vector. - if (strings->size() > kMaxListSize) - strings->resize(kMaxListSize); - - // Limit the size of the strings in the vector. - for (auto& str : *strings) { - if (str.length() > kMaxDataLength) - str.resize(kMaxDataLength); - } + TrimStringVectorForIPC(values); + TrimStringVectorForIPC(labels); } + } // namespace AutofillAgent::AutofillAgent(content::RenderFrame* frame, @@ -53,18 +60,26 @@ AutofillAgent::AutofillAgent(content::RenderFrame* frame, : content::RenderFrameObserver(frame) { render_frame()->GetWebFrame()->SetAutofillClient(this); registry->AddInterface(base::BindRepeating( - &AutofillAgent::BindReceiver, base::Unretained(this))); + &AutofillAgent::BindPendingReceiver, base::Unretained(this))); } AutofillAgent::~AutofillAgent() = default; -void AutofillAgent::BindReceiver( - mojo::PendingAssociatedReceiver receiver) { - receiver_.Bind(std::move(receiver)); +void AutofillAgent::BindPendingReceiver( + mojo::PendingAssociatedReceiver + pending_receiver) { + receiver_.Bind(std::move(pending_receiver)); } void AutofillAgent::OnDestruct() { - delete this; + Shutdown(); + base::SingleThreadTaskRunner::GetCurrentDefault()->DeleteSoon(FROM_HERE, + this); +} + +void AutofillAgent::Shutdown() { + receiver_.reset(); + weak_ptr_factory_.InvalidateWeakPtrs(); } void AutofillAgent::DidChangeScrollOffset() { @@ -94,9 +109,7 @@ void AutofillAgent::TextFieldDidChange( void AutofillAgent::TextFieldDidChangeImpl( const blink::WebFormControlElement& element) { - ShowSuggestionsOptions options; - options.requires_caret_at_end = true; - ShowSuggestions(element, options); + ShowSuggestions(element, {.requires_caret_at_end = true}); } void AutofillAgent::TextFieldDidReceiveKeyDown( @@ -104,18 +117,14 @@ void AutofillAgent::TextFieldDidReceiveKeyDown( const blink::WebKeyboardEvent& event) { if (event.windows_key_code == ui::VKEY_DOWN || event.windows_key_code == ui::VKEY_UP) { - ShowSuggestionsOptions options; - options.autofill_on_empty_values = true; - options.requires_caret_at_end = true; - ShowSuggestions(element, options); + ShowSuggestions(element, {.autofill_on_empty_values = true, + .requires_caret_at_end = true}); } } void AutofillAgent::OpenTextDataListChooser( const blink::WebInputElement& element) { - ShowSuggestionsOptions options; - options.autofill_on_empty_values = true; - ShowSuggestions(element, options); + ShowSuggestions(element, {.autofill_on_empty_values = true}); } void AutofillAgent::DataListOptionsChanged( @@ -123,31 +132,35 @@ void AutofillAgent::DataListOptionsChanged( if (!element.Focused()) return; - ShowSuggestionsOptions options; - options.requires_caret_at_end = true; - ShowSuggestions(element, options); + ShowSuggestions(element, {.requires_caret_at_end = true}); } -AutofillAgent::ShowSuggestionsOptions::ShowSuggestionsOptions() - : autofill_on_empty_values(false), requires_caret_at_end(false) {} - void AutofillAgent::ShowSuggestions(const blink::WebFormControlElement& element, const ShowSuggestionsOptions& options) { if (!element.IsEnabled() || element.IsReadOnly()) return; + if (!element.SuggestedValue().IsEmpty()) + return; + const blink::WebInputElement input_element = element.DynamicTo(); if (!input_element.IsNull()) { if (!input_element.IsTextField()) return; + if (!input_element.SuggestedValue().IsEmpty()) + return; } + // Don't attempt to autofill with values that are too large or if filling + // criteria are not met. Keyboard Accessory may still be shown when the + // |value| is empty, do not attempt to hide it. blink::WebString value = element.EditingValue(); - if (value.length() > kMaxDataLength || + if (value.length() > kMaxStringLength || (!options.autofill_on_empty_values && value.IsEmpty()) || (options.requires_caret_at_end && (element.SelectionStart() != element.SelectionEnd() || element.SelectionEnd() != static_cast(value.length())))) { + // Any popup currently showing is obsolete. HidePopup(); return; } @@ -156,8 +169,6 @@ void AutofillAgent::ShowSuggestions(const blink::WebFormControlElement& element, std::vector data_list_labels; if (!input_element.IsNull()) { GetDataListSuggestions(input_element, &data_list_values, &data_list_labels); - TrimStringVectorForIPC(&data_list_values); - TrimStringVectorForIPC(&data_list_labels); } ShowPopup(element, data_list_values, data_list_labels); @@ -165,11 +176,12 @@ void AutofillAgent::ShowSuggestions(const blink::WebFormControlElement& element, void AutofillAgent::DidReceiveLeftMouseDownOrGestureTapInNode( const blink::WebNode& node) { - focused_node_was_last_clicked_ = !node.IsNull() && node.Focused(); + DCHECK(!node.IsNull()); + focused_node_was_last_clicked_ = node.Focused(); } void AutofillAgent::DidCompleteFocusChangeInFrame() { - DoFocusChangeComplete(); + HandleFocusChangeComplete(); } bool AutofillAgent::IsUserGesture() const { @@ -197,18 +209,16 @@ void AutofillAgent::AcceptDataListSuggestion(const std::u16string& suggestion) { } } -void AutofillAgent::DoFocusChangeComplete() { +void AutofillAgent::HandleFocusChangeComplete() { auto element = render_frame()->GetWebFrame()->GetDocument().FocusedElement(); if (element.IsNull() || !element.IsFormControlElement()) return; if (focused_node_was_last_clicked_ && was_focused_before_now_) { - ShowSuggestionsOptions options; - options.autofill_on_empty_values = true; blink::WebInputElement input_element = element.DynamicTo(); if (!input_element.IsNull()) - ShowSuggestions(input_element, options); + ShowSuggestions(input_element, {.autofill_on_empty_values = true}); } was_focused_before_now_ = true; diff --git a/shell/renderer/electron_autofill_agent.h b/shell/renderer/electron_autofill_agent.h index 86bd9fa8f3..a82312c3fc 100644 --- a/shell/renderer/electron_autofill_agent.h +++ b/shell/renderer/electron_autofill_agent.h @@ -33,8 +33,9 @@ class AutofillAgent : public content::RenderFrameObserver, AutofillAgent(const AutofillAgent&) = delete; AutofillAgent& operator=(const AutofillAgent&) = delete; - void BindReceiver( - mojo::PendingAssociatedReceiver receiver); + void BindPendingReceiver( + mojo::PendingAssociatedReceiver + pending_receiver); // content::RenderFrameObserver: void OnDestruct() override; @@ -47,11 +48,18 @@ class AutofillAgent : public content::RenderFrameObserver, private: struct ShowSuggestionsOptions { - ShowSuggestionsOptions(); - bool autofill_on_empty_values; - bool requires_caret_at_end; + // Specifies that suggestions should be shown when |element| contains no + // text. + bool autofill_on_empty_values{false}; + // Specifies that suggestions should be shown when the caret is not + // after the last character in the element. + bool requires_caret_at_end{false}; }; + // Shuts the AutofillAgent down on RenderFrame deletion. Safe to call multiple + // times. + void Shutdown(); + // blink::WebAutofillClient: void TextFieldDidEndEditing(const blink::WebInputElement&) override; void TextFieldDidChange(const blink::WebFormControlElement&) override; @@ -72,7 +80,7 @@ class AutofillAgent : public content::RenderFrameObserver, void ShowSuggestions(const blink::WebFormControlElement& element, const ShowSuggestionsOptions& options); - void DoFocusChangeComplete(); + void HandleFocusChangeComplete(); const mojo::AssociatedRemote& GetAutofillDriver();",chore 8474bbe6895bd98f30e551aa8b3f34d75210a2c5,Calvin,2024-08-19 10:47:40,build: update NMV to 130 for Electron 33 (#43325),"diff --git a/build/args/all.gn b/build/args/all.gn index bb6f61da70..c286ef8312 100644 --- a/build/args/all.gn +++ b/build/args/all.gn @@ -2,7 +2,7 @@ is_electron_build = true root_extra_deps = [ ""//electron"" ] # Registry of NMVs --> https://github.com/nodejs/node/blob/main/doc/abi_version_registry.json -node_module_version = 128 +node_module_version = 130 v8_promise_internal_field_count = 1 v8_embedder_string = ""-electron.0""",build 10d967028af2e72382d16b7e2025d243b9e204ae,Will Anderson,2024-11-18 14:44:30,"docs: Make ipcRenderer and ipcMain listener API docs consistent (#44651) * docs: Make ipcRenderer and ipcMain listener API docs consistent * test: add some unit tests for ipcRenderer/ipcMain listener behavior * fix: Mark on/off methods as primary and addListener/removeListener as aliases * fix: clear all listeners before running ipcMain removeAllListeners tests","diff --git a/docs/api/ipc-main.md b/docs/api/ipc-main.md index 83dd3628a2..b5b84a2176 100644 --- a/docs/api/ipc-main.md +++ b/docs/api/ipc-main.md @@ -32,7 +32,7 @@ process, see [webContents.send][web-contents-send] for more information. ## Methods -The `ipcMain` module has the following method to listen for events: +The `ipcMain` module has the following methods to listen for events: ### `ipcMain.on(channel, listener)` @@ -44,6 +44,16 @@ The `ipcMain` module has the following method to listen for events: Listens to `channel`, when a new message arrives `listener` would be called with `listener(event, args...)`. +### `ipcMain.off(channel, listener)` + +* `channel` string +* `listener` Function + * `event` [IpcMainEvent][ipc-main-event] + * `...args` any[] + +Removes the specified `listener` from the listener array for the specified +`channel`. + ### `ipcMain.once(channel, listener)` * `channel` string @@ -54,20 +64,28 @@ Listens to `channel`, when a new message arrives `listener` would be called with Adds a one time `listener` function for the event. This `listener` is invoked only the next time a message is sent to `channel`, after which it is removed. +### `ipcMain.addListener(channel, listener)` + +* `channel` string +* `listener` Function + * `event` [IpcMainEvent][ipc-main-event] + * `...args` any[] + +Alias for [`ipcMain.on`](#ipcmainonchannel-listener). + ### `ipcMain.removeListener(channel, listener)` * `channel` string * `listener` Function * `...args` any[] -Removes the specified `listener` from the listener array for the specified -`channel`. +Alias for [`ipcMain.off`](#ipcmainoffchannel-listener). ### `ipcMain.removeAllListeners([channel])` * `channel` string (optional) -Removes listeners of the specified `channel`. +Removes all listeners from the specified `channel`. Removes all listeners from all channels if no channel is specified. ### `ipcMain.handle(channel, listener)` diff --git a/docs/api/ipc-renderer.md b/docs/api/ipc-renderer.md index c33e94fe77..12273e9e1f 100644 --- a/docs/api/ipc-renderer.md +++ b/docs/api/ipc-renderer.md @@ -48,7 +48,8 @@ Listens to `channel`, when a new message arrives `listener` would be called with * `event` [IpcRendererEvent][ipc-renderer-event] * `...args` any[] -Alias for [`ipcRenderer.removeListener`](#ipcrendererremovelistenerchannel-listener). +Removes the specified `listener` from the listener array for the specified +`channel`. ### `ipcRenderer.once(channel, listener)` @@ -76,14 +77,13 @@ Alias for [`ipcRenderer.on`](#ipcrendereronchannel-listener). * `event` [IpcRendererEvent][ipc-renderer-event] * `...args` any[] -Removes the specified `listener` from the listener array for the specified -`channel`. +Alias for [`ipcRenderer.off`](#ipcrendereroffchannel-listener). -### `ipcRenderer.removeAllListeners(channel)` +### `ipcRenderer.removeAllListeners([channel])` -* `channel` string +* `channel` string (optional) -Removes all listeners, or those of the specified `channel`. +Removes all listeners from the specified `channel`. Removes all listeners from all channels if no channel is specified. ### `ipcRenderer.send(channel, ...args)` diff --git a/spec/api-ipc-main-spec.ts b/spec/api-ipc-main-spec.ts index 869591f1d7..7a6340328a 100644 --- a/spec/api-ipc-main-spec.ts +++ b/spec/api-ipc-main-spec.ts @@ -92,4 +92,27 @@ describe('ipc main module', () => { expect(v).to.equal('hello'); }); }); + + describe('ipcMain.removeAllListeners', () => { + beforeEach(() => { ipcMain.removeAllListeners(); }); + beforeEach(() => { ipcMain.removeAllListeners(); }); + + it('removes only the given channel', () => { + ipcMain.on('channel1', () => {}); + ipcMain.on('channel2', () => {}); + + ipcMain.removeAllListeners('channel1'); + + expect(ipcMain.eventNames()).to.deep.equal(['channel2']); + }); + + it('removes all channels if no channel is specified', () => { + ipcMain.on('channel1', () => {}); + ipcMain.on('channel2', () => {}); + + ipcMain.removeAllListeners(); + + expect(ipcMain.eventNames()).to.deep.equal([]); + }); + }); }); diff --git a/spec/api-ipc-renderer-spec.ts b/spec/api-ipc-renderer-spec.ts index 2db75ef3a3..c05be34589 100644 --- a/spec/api-ipc-renderer-spec.ts +++ b/spec/api-ipc-renderer-spec.ts @@ -18,6 +18,7 @@ describe('ipcRenderer module', () => { } }); await w.loadURL('about:blank'); + w.webContents.on('console-message', (event, ...args) => console.error(...args)); }); after(async () => { await closeWindow(w); @@ -144,6 +145,40 @@ describe('ipcRenderer module', () => { }); }); + describe('ipcRenderer.removeAllListeners', () => { + it('removes only the given channel', async () => { + const result = await w.webContents.executeJavaScript(` + (() => { + const { ipcRenderer } = require('electron'); + + ipcRenderer.on('channel1', () => {}); + ipcRenderer.on('channel2', () => {}); + + ipcRenderer.removeAllListeners('channel1'); + + return ipcRenderer.eventNames(); + })() + `); + expect(result).to.deep.equal(['channel2']); + }); + + it('removes all channels if no channel is specified', async () => { + const result = await w.webContents.executeJavaScript(` + (() => { + const { ipcRenderer } = require('electron'); + + ipcRenderer.on('channel1', () => {}); + ipcRenderer.on('channel2', () => {}); + + ipcRenderer.removeAllListeners(); + + return ipcRenderer.eventNames(); + })() + `); + expect(result).to.deep.equal([]); + }); + }); + describe('after context is released', () => { it('throws an exception', async () => { const error = await w.webContents.executeJavaScript(`(${() => {",docs 37608933ae06e8d140317b191e2436dac3faf93a,Shelley Vohr,2024-06-20 17:01:50,fix: fetch-dependent interfaces in Web Workers (#42579),"diff --git a/lib/worker/init.ts b/lib/worker/init.ts index 0c92d61e88..d23a4f942b 100644 --- a/lib/worker/init.ts +++ b/lib/worker/init.ts @@ -17,6 +17,14 @@ const { makeRequireFunction } = __non_webpack_require__('internal/modules/helper global.module = new Module('electron/js2c/worker_init'); global.require = makeRequireFunction(global.module); +// See WebWorkerObserver::WorkerScriptReadyForEvaluation. +if ((globalThis as any).blinkfetch) { + const keys = ['fetch', 'Response', 'FormData', 'Request', 'Headers']; + for (const key of keys) { + (globalThis as any)[key] = (globalThis as any)[`blink${key}`]; + } +} + // Set the __filename to the path of html file if it is file: protocol. // NB. 'self' isn't defined in an AudioWorklet. if (typeof self !== 'undefined' && self.location.protocol === 'file:') { diff --git a/shell/renderer/web_worker_observer.cc b/shell/renderer/web_worker_observer.cc index 0faf53b1c5..eafa8ba00a 100644 --- a/shell/renderer/web_worker_observer.cc +++ b/shell/renderer/web_worker_observer.cc @@ -66,9 +66,25 @@ void WebWorkerObserver::WorkerScriptReadyForEvaluation( std::shared_ptr env = node_bindings_->CreateEnvironment(worker_context, nullptr); + // We need to use the Blink implementation of fetch in web workers + // Node.js deletes the global fetch function when their fetch implementation + // is disabled, so we need to save and re-add it after the Node.js environment + // is loaded. See corresponding change in node/init.ts. v8::Local global = worker_context->Global(); - v8::Local fetch_string = gin::StringToV8(env->isolate(), ""fetch""); - v8::MaybeLocal fetch = global->Get(worker_context, fetch_string); + + std::vector keys = {""fetch"", ""Response"", ""FormData"", ""Request"", + ""Headers""}; + for (const auto& key : keys) { + v8::MaybeLocal value = + global->Get(worker_context, gin::StringToV8(isolate, key.c_str())); + if (!value.IsEmpty()) { + std::string blink_key = ""blink"" + key; + global + ->Set(worker_context, gin::StringToV8(isolate, blink_key.c_str()), + value.ToLocalChecked()) + .Check(); + } + } // Add Electron extended APIs. electron_bindings_->BindTo(env->isolate(), env->process_object()); @@ -76,16 +92,6 @@ void WebWorkerObserver::WorkerScriptReadyForEvaluation( // Load everything. node_bindings_->LoadEnvironment(env.get()); - // We need to use the Blink implementation of fetch in WebWorker process - // Node.js deletes the global fetch function when their fetch implementation - // is disabled, so we need to save and re-add it after the Node.js environment - // is loaded. - if (!fetch.IsEmpty()) { - worker_context->Global() - ->Set(worker_context, fetch_string, fetch.ToLocalChecked()) - .Check(); - } - // Make uv loop being wrapped by window context. node_bindings_->set_uv_env(env.get()); diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts index 9431056bde..238480364c 100644 --- a/spec/chromium-spec.ts +++ b/spec/chromium-spec.ts @@ -1019,12 +1019,35 @@ describe('chromium features', () => { }); it('Worker has node integration with nodeIntegrationInWorker', async () => { - const w = new BrowserWindow({ show: false, webPreferences: { nodeIntegration: true, nodeIntegrationInWorker: true, contextIsolation: false } }); + const w = new BrowserWindow({ + show: false, + webPreferences: { + nodeIntegration: true, + nodeIntegrationInWorker: true, + contextIsolation: false + } + }); + w.loadURL(`file://${fixturesPath}/pages/worker.html`); const [, data] = await once(ipcMain, 'worker-result'); expect(data).to.equal('object function object function'); }); + it('Worker has access to fetch-dependent interfaces with nodeIntegrationInWorker', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { + nodeIntegration: true, + nodeIntegrationInWorker: true, + contextIsolation: false + } + }); + + w.loadURL(`file://${fixturesPath}/pages/worker-fetch.html`); + const [, data] = await once(ipcMain, 'worker-fetch-result'); + expect(data).to.equal('function function function function function'); + }); + describe('SharedWorker', () => { it('can work', async () => { const w = new BrowserWindow({ show: false }); diff --git a/spec/fixtures/pages/worker-fetch.html b/spec/fixtures/pages/worker-fetch.html new file mode 100644 index 0000000000..f573784293 --- /dev/null +++ b/spec/fixtures/pages/worker-fetch.html @@ -0,0 +1,12 @@ + + + + + diff --git a/spec/fixtures/workers/worker_node_fetch.js b/spec/fixtures/workers/worker_node_fetch.js new file mode 100644 index 0000000000..0f6ca70f04 --- /dev/null +++ b/spec/fixtures/workers/worker_node_fetch.js @@ -0,0 +1,7 @@ +self.postMessage([ + typeof fetch, + typeof Response, + typeof Request, + typeof Headers, + typeof FormData +].join(' ')); diff --git a/spec/node-spec.ts b/spec/node-spec.ts index f146d077a0..9c5059172c 100644 --- a/spec/node-spec.ts +++ b/spec/node-spec.ts @@ -159,6 +159,38 @@ describe('node feature', () => { }); }); + describe('fetch', () => { + itremote('works correctly when nodeIntegration is enabled in the renderer', async (fixtures: string) => { + const file = require('node:path').join(fixtures, 'hello.txt'); + expect(() => { + fetch('file://' + file); + }).to.not.throw(); + + expect(() => { + const formData = new FormData(); + formData.append('username', 'Groucho'); + }).not.to.throw(); + + expect(() => { + const request = new Request('https://example.com', { + method: 'POST', + body: JSON.stringify({ foo: 'bar' }) + }); + expect(request.method).to.equal('POST'); + }).not.to.throw(); + + expect(() => { + const response = new Response('Hello, world!'); + expect(response.status).to.equal(200); + }).not.to.throw(); + + expect(() => { + const headers = new Headers(); + headers.append('Content-Type', 'text/xml'); + }).not.to.throw(); + }, [fixtures]); + }); + it('does not hang when using the fs module in the renderer process', async () => { const appPath = path.join(mainFixturesPath, 'apps', 'libuv-hang', 'main.js'); const appProcess = childProcess.spawn(process.execPath, [appPath], {",fix b3e01220cb8511790d45ec3759faae1289ad197d,Charles Kerr,2024-01-15 04:01:35,"refactor: fix deprecated base::Base64Encode() API calls (#40962) * refactor: replace deprecated Base64Encode() usage in IWC::NetworkResourceLoader::OnDataReceived() * refactor: replace deprecated Base64Encode() usage EncodeToken(const base::UnguessableToken& token)","diff --git a/shell/browser/serial/serial_chooser_context.cc b/shell/browser/serial/serial_chooser_context.cc index 521fe7c53a..6b77330cb1 100644 --- a/shell/browser/serial/serial_chooser_context.cc +++ b/shell/browser/serial/serial_chooser_context.cc @@ -38,11 +38,8 @@ const char kUsbDriverKey[] = ""usb_driver""; std::string EncodeToken(const base::UnguessableToken& token) { const uint64_t data[2] = {token.GetHighForSerialization(), token.GetLowForSerialization()}; - std::string buffer; - base::Base64Encode( - base::StringPiece(reinterpret_cast(&data[0]), sizeof(data)), - &buffer); - return buffer; + return base::Base64Encode( + base::StringPiece(reinterpret_cast(&data[0]), sizeof(data))); } base::Value PortInfoToValue(const device::mojom::SerialPortInfo& port) { diff --git a/shell/browser/ui/inspectable_web_contents.cc b/shell/browser/ui/inspectable_web_contents.cc index 50ea5917b5..45c428ffd6 100644 --- a/shell/browser/ui/inspectable_web_contents.cc +++ b/shell/browser/ui/inspectable_web_contents.cc @@ -258,22 +258,11 @@ class InspectableWebContents::NetworkResourceLoader void OnDataReceived(base::StringPiece chunk, base::OnceClosure resume) override { - base::Value chunkValue; - bool encoded = !base::IsStringUTF8(chunk); - if (encoded) { - std::string encoded_string; - base::Base64Encode(chunk, &encoded_string); - chunkValue = base::Value(std::move(encoded_string)); - } else { - chunkValue = base::Value(chunk); - } - base::Value id(stream_id_); - base::Value encodedValue(encoded); - - bindings_->CallClientFunction(""DevToolsAPI"", ""streamWrite"", std::move(id), - std::move(chunkValue), - std::move(encodedValue)); + bindings_->CallClientFunction( + ""DevToolsAPI"", ""streamWrite"", base::Value{stream_id_}, + base::Value{encoded ? base::Base64Encode(chunk) : chunk}, + base::Value{encoded}); std::move(resume).Run(); } ",refactor 455f57322f705fdd67751328e8f1feaf6bd29409,Milan Burda,2023-07-25 18:08:46,"refactor: use `TypeError` instead of generic `Error` when appropriate (#39209) refactor: use TypeError instead of generic Error when appropriate","diff --git a/lib/browser/api/auto-updater/auto-updater-win.ts b/lib/browser/api/auto-updater/auto-updater-win.ts index 9758107019..27cdd512c8 100644 --- a/lib/browser/api/auto-updater/auto-updater-win.ts +++ b/lib/browser/api/auto-updater/auto-updater-win.ts @@ -24,12 +24,12 @@ class AutoUpdater extends EventEmitter { if (typeof options.url === 'string') { updateURL = options.url; } else { - throw new Error('Expected options object to contain a \'url\' string property in setFeedUrl call'); + throw new TypeError('Expected options object to contain a \'url\' string property in setFeedUrl call'); } } else if (typeof options === 'string') { updateURL = options; } else { - throw new Error('Expected an options object with a \'url\' property to be provided'); + throw new TypeError('Expected an options object with a \'url\' property to be provided'); } this.updateURL = updateURL; } diff --git a/lib/browser/api/touch-bar.ts b/lib/browser/api/touch-bar.ts index 9dfe4f208b..5ec18e2c7c 100644 --- a/lib/browser/api/touch-bar.ts +++ b/lib/browser/api/touch-bar.ts @@ -331,7 +331,7 @@ class TouchBar extends EventEmitter implements Electron.TouchBar { const idSet = new Set(); items.forEach((item) => { if (!(item instanceof TouchBarItem)) { - throw new Error('Each item must be an instance of TouchBarItem'); + throw new TypeError('Each item must be an instance of TouchBarItem'); } if (item.type === 'other_items_proxy') { diff --git a/lib/browser/api/utility-process.ts b/lib/browser/api/utility-process.ts index 8027a548eb..fcf21188cf 100644 --- a/lib/browser/api/utility-process.ts +++ b/lib/browser/api/utility-process.ts @@ -34,19 +34,19 @@ class ForkUtilityProcess extends EventEmitter { if (options.execArgv != null) { if (!Array.isArray(options.execArgv)) { - throw new Error('execArgv must be an array of strings.'); + throw new TypeError('execArgv must be an array of strings.'); } } if (options.serviceName != null) { if (typeof options.serviceName !== 'string') { - throw new Error('serviceName must be a string.'); + throw new TypeError('serviceName must be a string.'); } } if (options.cwd != null) { if (typeof options.cwd !== 'string') { - throw new Error('cwd path must be a string.'); + throw new TypeError('cwd path must be a string.'); } } diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index 12ffc577a7..bea6d7225d 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -411,7 +411,7 @@ WebContents.prototype.getPrintersAsync = async function () { WebContents.prototype.loadFile = function (filePath, options = {}) { if (typeof filePath !== 'string') { - throw new Error('Must pass filePath as a string'); + throw new TypeError('Must pass filePath as a string'); } const { query, search, hash } = options; diff --git a/lib/browser/api/web-frame-main.ts b/lib/browser/api/web-frame-main.ts index 95e4a2fa4d..9212c797cb 100644 --- a/lib/browser/api/web-frame-main.ts +++ b/lib/browser/api/web-frame-main.ts @@ -13,7 +13,7 @@ Object.defineProperty(WebFrameMain.prototype, 'ipc', { WebFrameMain.prototype.send = function (channel, ...args) { if (typeof channel !== 'string') { - throw new Error('Missing required channel argument'); + throw new TypeError('Missing required channel argument'); } try { @@ -25,7 +25,7 @@ WebFrameMain.prototype.send = function (channel, ...args) { WebFrameMain.prototype._sendInternal = function (channel, ...args) { if (typeof channel !== 'string') { - throw new Error('Missing required channel argument'); + throw new TypeError('Missing required channel argument'); } try { diff --git a/lib/browser/ipc-main-impl.ts b/lib/browser/ipc-main-impl.ts index ef8c9af6e3..bbd6a2531e 100644 --- a/lib/browser/ipc-main-impl.ts +++ b/lib/browser/ipc-main-impl.ts @@ -16,7 +16,7 @@ export class IpcMainImpl extends EventEmitter { throw new Error(`Attempted to register a second handler for '${method}'`); } if (typeof fn !== 'function') { - throw new Error(`Expected handler to be a function, but found type '${typeof fn}'`); + throw new TypeError(`Expected handler to be a function, but found type '${typeof fn}'`); } this._invokeHandlers.set(method, fn); }; diff --git a/lib/renderer/web-view/guest-view-internal.ts b/lib/renderer/web-view/guest-view-internal.ts index 893a6e2305..e6d25d5179 100644 --- a/lib/renderer/web-view/guest-view-internal.ts +++ b/lib/renderer/web-view/guest-view-internal.ts @@ -20,7 +20,7 @@ export function deregisterEvents (viewInstanceId: number) { export function createGuest (iframe: HTMLIFrameElement, elementInstanceId: number, params: Record): Promise { if (!(iframe instanceof HTMLIFrameElement)) { - throw new Error('Invalid embedder frame'); + throw new TypeError('Invalid embedder frame'); } const embedderFrameId = webFrame.getWebFrameId(iframe.contentWindow!); diff --git a/script/release/uploaders/upload-to-github.ts b/script/release/uploaders/upload-to-github.ts index 218e369fee..42dd9103c4 100644 --- a/script/release/uploaders/upload-to-github.ts +++ b/script/release/uploaders/upload-to-github.ts @@ -18,7 +18,7 @@ const releaseId = parseInt(process.argv[4], 10); const releaseVersion = process.argv[5]; if (isNaN(releaseId)) { - throw new Error('Provided release ID was not a valid integer'); + throw new TypeError('Provided release ID was not a valid integer'); } const getHeaders = (filePath: string, fileName: string) => { diff --git a/spec/lib/video-helpers.js b/spec/lib/video-helpers.js index 09c47556c9..edb89e040c 100644 --- a/spec/lib/video-helpers.js +++ b/spec/lib/video-helpers.js @@ -477,7 +477,7 @@ WhammyVideo.prototype.add = function (frame, duration) { // quickly store image data so we don't block cpu. encode in compile method. frame = frame.getContext('2d').getImageData(0, 0, frame.width, frame.height); } else if (typeof frame !== 'string') { - throw new Error('frame must be a a HTMLCanvasElement, a CanvasRenderingContext2D or a DataURI formatted string'); + throw new TypeError('frame must be a a HTMLCanvasElement, a CanvasRenderingContext2D or a DataURI formatted string'); } if (typeof frame === 'string' && !(/^data:image\/webp;base64,/ig).test(frame)) { throw new Error('Input must be formatted properly as a base64 encoded DataURI of type image/webp');",refactor 24df5f96d733a40234cdd7ca9c82a9b5c9d9beb8,Charles Kerr,2024-11-23 17:34:51,"fix: remove unused local variables (#44815) * chore: remove unused local non-trivial variable relaunch_executable became unused in June 2016 in 0d066de5 * chore: only declare program_name local variable if used We declared it everywhere but only used it on Windows * chore: remove unused local non-trivial variable path from UnregisterXWindow it became unused in 2020 by 72a08926","diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index 9aadb51b02..ce10c42e5a 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -1011,8 +1011,6 @@ bool App::RequestSingleInstanceLock(gin::Arguments* args) { if (HasSingleInstanceLock()) return true; - std::string program_name = electron::Browser::Get()->GetName(); - base::FilePath user_dir; base::PathService::Get(chrome::DIR_USER_DATA, &user_dir); // The user_dir may not have been created yet. @@ -1023,6 +1021,7 @@ bool App::RequestSingleInstanceLock(gin::Arguments* args) { blink::CloneableMessage additional_data_message; args->GetNext(&additional_data_message); #if BUILDFLAG(IS_WIN) + const std::string program_name = electron::Browser::Get()->GetName(); bool app_is_sandboxed = IsSandboxEnabled(base::CommandLine::ForCurrentProcess()); process_singleton_ = std::make_unique( diff --git a/shell/browser/relauncher.cc b/shell/browser/relauncher.cc index c15221181c..93deae119b 100644 --- a/shell/browser/relauncher.cc +++ b/shell/browser/relauncher.cc @@ -157,7 +157,6 @@ int RelauncherMain(const content::MainFunctionParams& main_parameters) { // Figure out what to execute, what arguments to pass it, and whether to // start it in the background. bool in_relauncher_args = false; - StringType relaunch_executable; StringVector relauncher_args; StringVector launch_argv; for (size_t argv_index = 2; argv_index < argv.size(); ++argv_index) { diff --git a/shell/browser/ui/views/global_menu_bar_registrar_x11.cc b/shell/browser/ui/views/global_menu_bar_registrar_x11.cc index 76e0940b81..5789ae7f40 100644 --- a/shell/browser/ui/views/global_menu_bar_registrar_x11.cc +++ b/shell/browser/ui/views/global_menu_bar_registrar_x11.cc @@ -80,7 +80,6 @@ void GlobalMenuBarRegistrarX11::RegisterXWindow(x11::Window window) { void GlobalMenuBarRegistrarX11::UnregisterXWindow(x11::Window window) { DCHECK(registrar_proxy_); - std::string path = electron::GlobalMenuBarX11::GetPathForWindow(window); ANNOTATE_SCOPED_MEMORY_LEAK; // http://crbug.com/314087 // TODO(erg): The mozilla implementation goes to a lot of callback trouble",fix eb3262cd87f1602cea651f89166b0da0f2ee6e14,Shelley Vohr,2022-09-22 01:44:27,"fix: allow docking DevTools with WCO (#35754) fix: allow for docking devtools with WCO","diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index f0c63d3af0..274cbd8e7b 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -2424,14 +2424,6 @@ void WebContents::OpenDevTools(gin::Arguments* args) { !owner_window()) { state = ""detach""; } - bool activate = true; - if (args && args->Length() == 1) { - gin_helper::Dictionary options; - if (args->GetNext(&options)) { - options.Get(""mode"", &state); - options.Get(""activate"", &activate); - } - } #if BUILDFLAG(IS_WIN) auto* win = static_cast(owner_window()); @@ -2441,6 +2433,15 @@ void WebContents::OpenDevTools(gin::Arguments* args) { state = ""detach""; #endif + bool activate = true; + if (args && args->Length() == 1) { + gin_helper::Dictionary options; + if (args->GetNext(&options)) { + options.Get(""mode"", &state); + options.Get(""activate"", &activate); + } + } + DCHECK(inspectable_web_contents_); inspectable_web_contents_->SetDockState(state); inspectable_web_contents_->ShowDevTools(activate);",fix 734395bea9d5f1e3fdce7e8917eb5245f0c1bf5f,Cedrik Ewers,2024-04-15 02:10:09,"docs: use ""id"" instead of ""label"" for positions (#41843) Co-authored-by: Cedrik Ewers ","diff --git a/docs/api/menu-item.md b/docs/api/menu-item.md index ad74bb57e6..3ad0c8e87c 100644 --- a/docs/api/menu-item.md +++ b/docs/api/menu-item.md @@ -38,18 +38,18 @@ See [`Menu`](menu.md) for examples. `Menu.buildFromTemplate`. * `id` string (optional) - Unique within a single menu. If defined then it can be used as a reference to this item by the position attribute. - * `before` string[] (optional) - Inserts this item before the item with the specified label. If + * `before` string[] (optional) - Inserts this item before the item with the specified id. If the referenced item doesn't exist the item will be inserted at the end of the menu. Also implies that the menu item in question should be placed in the same “group” as the item. - * `after` string[] (optional) - Inserts this item after the item with the specified label. If the + * `after` string[] (optional) - Inserts this item after the item with the specified id. If the referenced item doesn't exist the item will be inserted at the end of the menu. * `beforeGroupContaining` string[] (optional) - Provides a means for a single context menu to declare the placement of their containing group before the containing group of the item - with the specified label. + with the specified id. * `afterGroupContaining` string[] (optional) - Provides a means for a single context menu to declare the placement of their containing group after the containing group of the item - with the specified label. + with the specified id. **Note:** `acceleratorWorksWhenHidden` is specified as being macOS-only because accelerators always work when items are hidden on Windows and Linux. The option is exposed to users to give them the option to turn it off, as this is possible in native macOS development. diff --git a/docs/api/menu.md b/docs/api/menu.md index 860eb7e8d6..9be1eedb39 100644 --- a/docs/api/menu.md +++ b/docs/api/menu.md @@ -336,16 +336,16 @@ browser windows. You can make use of `before`, `after`, `beforeGroupContaining`, `afterGroupContaining` and `id` to control how the item will be placed when building a menu with `Menu.buildFromTemplate`. -* `before` - Inserts this item before the item with the specified label. If the +* `before` - Inserts this item before the item with the specified id. If the referenced item doesn't exist the item will be inserted at the end of the menu. Also implies that the menu item in question should be placed in the same “group” as the item. -* `after` - Inserts this item after the item with the specified label. If the +* `after` - Inserts this item after the item with the specified id. If the referenced item doesn't exist the item will be inserted at the end of the menu. Also implies that the menu item in question should be placed in the same “group” as the item. * `beforeGroupContaining` - Provides a means for a single context menu to declare - the placement of their containing group before the containing group of the item with the specified label. + the placement of their containing group before the containing group of the item with the specified id. * `afterGroupContaining` - Provides a means for a single context menu to declare - the placement of their containing group after the containing group of the item with the specified label. + the placement of their containing group after the containing group of the item with the specified id. By default, items will be inserted in the order they exist in the template unless one of the specified positioning keywords is used. ",docs b468b5e6e883a39ceaba6417ed8be1ece6ee281f,Shelley Vohr,2024-02-28 00:40:42,build: print error and retry on symstore fail (#41452),"diff --git a/script/release/uploaders/upload-symbols.py b/script/release/uploaders/upload-symbols.py index d48f132e6b..d4d7cc710b 100755 --- a/script/release/uploaders/upload-symbols.py +++ b/script/release/uploaders/upload-symbols.py @@ -80,8 +80,14 @@ def main(): def run_symstore(pdb, dest, product): - execute(['symstore', 'add', '/r', '/f', pdb, '/s', dest, '/t', product]) - + for attempt in range(2): + try: + execute(['symstore', 'add', '/r', '/f', pdb, '/s', dest, '/t', product]) + break + except Exception as e: + print(f""An error occurred while adding '{pdb}' to SymStore: {str(e)}"") + if attempt == 0: + print(""Retrying..."") def upload_symbols(files): store_artifact(SYMBOLS_DIR, 'symbols',",build 79d2fc9c234059baf474e7f33a722bd1cb142e39,John Kleinschmidt,2022-12-01 14:12:32,build: fixup mksnapshot args on linux (#36531),"diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index d28aa68327..e1de7f66ec 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -707,7 +707,7 @@ step-mksnapshot-build: &step-mksnapshot-build ninja -C out/Default electron:electron_mksnapshot -j $NUMBER_OF_NINJA_PROCESSES gn desc out/Default v8:run_mksnapshot_default args > out/Default/mksnapshot_args # Remove unused args from mksnapshot_args - SEDOPTION= + SEDOPTION=""-i"" if [ ""`uname`"" == ""Darwin"" ]; then SEDOPTION=""-i ''"" fi @@ -1229,7 +1229,7 @@ commands: ninja -C out/Default tools/v8_context_snapshot -j $NUMBER_OF_NINJA_PROCESSES gn desc out/Default v8:run_mksnapshot_default args > out/Default/mksnapshot_args # Remove unused args from mksnapshot_args - SEDOPTION= + SEDOPTION=""-i"" if [ ""`uname`"" == ""Darwin"" ]; then SEDOPTION=""-i ''"" fi",build 26d228ccfe009400a06d0271ca84a7b08b574c1b,Felix Rieseberg,2025-01-23 13:59:00,"docs: Add note about directly exposing Electron APIs in preload (#45241) * docs: Add note about directly exposing Electron APIs in preload * Implement feedback","diff --git a/docs/tutorial/security.md b/docs/tutorial/security.md index 66b4736da3..12f2815788 100644 --- a/docs/tutorial/security.md +++ b/docs/tutorial/security.md @@ -116,6 +116,7 @@ You should at least follow these steps to improve the security of your applicati 17. [Validate the `sender` of all IPC messages](#17-validate-the-sender-of-all-ipc-messages) 18. [Avoid usage of the `file://` protocol and prefer usage of custom protocols](#18-avoid-usage-of-the-file-protocol-and-prefer-usage-of-custom-protocols) 19. [Check which fuses you can change](#19-check-which-fuses-you-can-change) +20. [Do not expose Electron APIs to untrusted web content](#20-do-not-expose-electron-apis-to-untrusted-web-content) To automate the detection of misconfigurations and insecure patterns, it is possible to use @@ -229,7 +230,7 @@ API to remotely loaded content via the [contextBridge API](../api/context-bridge ### 3. Enable Context Isolation :::info -This recommendation is the default behavior in Electron since 12.0.0. +Context Isolation is the default behavior in Electron since 12.0.0. ::: Context isolation is an Electron feature that allows developers to run code @@ -804,6 +805,48 @@ flipping these fuses easy. Check out the README of that module for more details potential error cases, and refer to [How do I flip the fuses?](./fuses.md#how-do-i-flip-the-fuses) in our documentation. +### 20. Do not expose Electron APIs to untrusted web content + +You should not directly expose Electron's APIs, especially IPC, to untrusted web content in your +preload scripts. + +### Why? + +Exposing raw APIs like `ipcRenderer.on` is dangerous because it gives renderer processes direct +access to the entire IPC event system, allowing them to listen for any IPC events, not just the ones +intended for them. + +To avoid that exposure, we also cannot pass callbacks directly through: The first +argument to IPC event callbacks is an `IpcRendererEvent` object, which includes properties like `sender` +that provide access to the underlying `ipcRenderer` instance. Even if you only listen for specific +events, passing the callback directly means the renderer gets access to this event object. + +In short, we want the untrusted web content to only have access to necessary information and APIs. + +### How? + +```js title='preload'.js' +// Bad +contextBridge.exposeInMainWorld('electronAPI', { + on: ipcRenderer.on +}) + +// Also bad +contextBridge.exposeInMainWorld('electronAPI', { + onUpdateCounter: (callback) => ipcRenderer.on('update-counter', callback) +}) + +// Good +contextBridge.exposeInMainWorld('electronAPI', { + onUpdateCounter: (callback) => ipcRenderer.on('update-counter', (_event, value) => callback(value)) +}) +``` + +:::info +For more information on what `contextIsolation` is and how to use it to secure your app, +please see the [Context Isolation](context-isolation.md) document. +::: + [breaking-changes]: ../breaking-changes.md [browser-window]: ../api/browser-window.md [webview-tag]: ../api/webview-tag.md",docs f89bd745d5ac168665a09b0fc6f3a565b3fb40be,Shelley Vohr,2024-09-20 09:56:03,"fix: `createWindow` shouldn't load URL for `webContents` (#43775) * fix: createWindow shouldn't load URL for webContents * chore: add non about blank test","diff --git a/lib/browser/guest-window-manager.ts b/lib/browser/guest-window-manager.ts index 24ce9b761a..65526e1c5a 100644 --- a/lib/browser/guest-window-manager.ts +++ b/lib/browser/guest-window-manager.ts @@ -71,14 +71,6 @@ export function openGuestWindow ({ embedder, guest, referrer, disposition, postD throw new Error('Invalid webContents. Created window should be connected to webContents passed with options object.'); } - webContents.loadURL(url, { - httpReferrer: referrer, - ...(postData && { - postData, - extraHeaders: formatPostDataHeaders(postData as Electron.UploadRawData[]) - }) - }); - handleWindowLifecycleEvents({ embedder, frameName, guest, outlivesOpener }); } diff --git a/spec/guest-window-manager-spec.ts b/spec/guest-window-manager-spec.ts index 1cb4795a8b..bd5bab5bd9 100644 --- a/spec/guest-window-manager-spec.ts +++ b/spec/guest-window-manager-spec.ts @@ -231,6 +231,10 @@ describe('webContents.setWindowOpenHandler', () => { response.statusCode = 200; response.end('Child page'); break; + case '/test': + response.statusCode = 200; + response.end('Test page'); + break; default: throw new Error(`Unsupported endpoint: ${request.url}`); } @@ -303,6 +307,32 @@ describe('webContents.setWindowOpenHandler', () => { expect(childWindow.title).to.equal(browserWindowTitle); }); + it('should be able to access the child window document when createWindow is provided', async () => { + browserWindow.webContents.setWindowOpenHandler(() => { + return { + action: 'allow', + createWindow: (options) => { + const child = new BrowserWindow(options); + return child.webContents; + } + }; + }); + + const aboutBlankTitle = await browserWindow.webContents.executeJavaScript(` + const win1 = window.open('about:blank', '', 'show=no'); + win1.document.title = 'about-blank-title'; + win1.document.title; + `); + expect(aboutBlankTitle).to.equal('about-blank-title'); + + const serverPageTitle = await browserWindow.webContents.executeJavaScript(` + const win2 = window.open('${url}/child', '', 'show=no'); + win2.document.title = 'server-page-title'; + win2.document.title; + `); + expect(serverPageTitle).to.equal('server-page-title'); + }); + it('spawns browser window with overridden options', async () => { const childWindow = await new Promise(resolve => { browserWindow.webContents.setWindowOpenHandler(() => {",fix 3dbc0a365f3dd6b49b7317aa2ce153762e57c724,John Kleinschmidt,2023-05-11 16:07:39,chore: enable check raw ptr fields (#38167),"diff --git a/build/args/all.gn b/build/args/all.gn index 74769f6c97..6755a47d28 100644 --- a/build/args/all.gn +++ b/build/args/all.gn @@ -50,8 +50,5 @@ use_qt = false # TODO(codebytere): fix perfetto incompatibility with Node.js. use_perfetto_client_library = false -# Ref: https://chromium-review.googlesource.com/c/chromium/src/+/4402277 -enable_check_raw_ptr_fields = false - # Disables the builtins PGO for V8 v8_builtins_profiling_log_file = """" diff --git a/patches/chromium/expose_setuseragent_on_networkcontext.patch b/patches/chromium/expose_setuseragent_on_networkcontext.patch index 5e67bfb66d..71357fc44d 100644 --- a/patches/chromium/expose_setuseragent_on_networkcontext.patch +++ b/patches/chromium/expose_setuseragent_on_networkcontext.patch @@ -51,7 +51,7 @@ index 5b53653eb8448c3904fda67f054dd2ec4bbca338..a89b923bcece48d6eaece3d5ac5c5bfc // 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 ca1d417743e4ac3c1d3f9833c7d5cfc261d59087..35283c28c40d47f2ebd064a511e6da06b55fed0a 100644 +index 87e9c6b2549e0db4a3cd88f6528eeb84327ec183..34d2c1a33983489dc56e18a2a7bbd6717645c7a3 100644 --- a/services/network/network_context.h +++ b/services/network/network_context.h @@ -315,6 +315,7 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext diff --git a/patches/chromium/feat_allow_embedders_to_add_observers_on_created_hunspell.patch b/patches/chromium/feat_allow_embedders_to_add_observers_on_created_hunspell.patch index bcb5d6dce3..14d1f59f03 100644 --- a/patches/chromium/feat_allow_embedders_to_add_observers_on_created_hunspell.patch +++ b/patches/chromium/feat_allow_embedders_to_add_observers_on_created_hunspell.patch @@ -41,7 +41,7 @@ index 707a8346ea5bf49e20bac5669d777a8ab247dc51..69c82dd102e7e746db68c6ab4768a40a content::RenderProcessHost* host) { InitForRenderer(host); diff --git a/chrome/browser/spellchecker/spellcheck_service.h b/chrome/browser/spellchecker/spellcheck_service.h -index 00e613bb4ca4346eb0b0e65b9b818d817ac724d9..bd9745d29a61944a23b83b274aace2ea8cb37a0f 100644 +index 00e613bb4ca4346eb0b0e65b9b818d817ac724d9..1b40931b8654b80e9a5fd0f170217b4b008eaae9 100644 --- a/chrome/browser/spellchecker/spellcheck_service.h +++ b/chrome/browser/spellchecker/spellcheck_service.h @@ -135,6 +135,8 @@ class SpellcheckService : public KeyedService, @@ -57,7 +57,7 @@ index 00e613bb4ca4346eb0b0e65b9b818d817ac724d9..bd9745d29a61944a23b83b274aace2ea // A pointer to the BrowserContext which this service refers to. raw_ptr context_; -+ SpellcheckHunspellDictionary::Observer* hunspell_observer_ = nullptr; ++ raw_ptr hunspell_observer_ = nullptr; + std::unique_ptr metrics_; diff --git a/patches/chromium/feat_enable_offscreen_rendering_with_viz_compositor.patch b/patches/chromium/feat_enable_offscreen_rendering_with_viz_compositor.patch index 1765bce882..13956b50ec 100644 --- a/patches/chromium/feat_enable_offscreen_rendering_with_viz_compositor.patch +++ b/patches/chromium/feat_enable_offscreen_rendering_with_viz_compositor.patch @@ -583,7 +583,7 @@ index 2f462f0deb5fc8a637457243fb5d5849fc214d14..695869b83cefaa24af93a2e11b39de05 + Draw(gfx.mojom.Rect damage_rect) => (); }; diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h -index c9f14ed6547ba1f5cdaade063452036ac402885a..2d1718afbea84b3e4395ce511e2618848ef85859 100644 +index c9f14ed6547ba1f5cdaade063452036ac402885a..ddb28fd6f7549759df7e3b7d6b309cd982e199af 100644 --- a/ui/compositor/compositor.h +++ b/ui/compositor/compositor.h @@ -89,6 +89,7 @@ class DisplayPrivate; @@ -625,7 +625,7 @@ index c9f14ed6547ba1f5cdaade063452036ac402885a..2d1718afbea84b3e4395ce511e261884 std::unique_ptr pending_begin_frame_args_; -+ CompositorDelegate* delegate_ = nullptr; ++ raw_ptr delegate_ = nullptr; + // The root of the Layer tree drawn by this compositor. raw_ptr root_layer_ = nullptr; diff --git a/patches/chromium/fix_expose_decrementcapturercount_in_web_contents_impl.patch b/patches/chromium/fix_expose_decrementcapturercount_in_web_contents_impl.patch index 01914d2a1d..85446f4d99 100644 --- a/patches/chromium/fix_expose_decrementcapturercount_in_web_contents_impl.patch +++ b/patches/chromium/fix_expose_decrementcapturercount_in_web_contents_impl.patch @@ -21,7 +21,7 @@ index 69f9ffbf4826421491118a0b200d6c71e41f8950..c3b7f6fa146ac335b0d18a749a61600c // Calculates the PageVisibilityState for |visibility|, taking the capturing // state into account. diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h -index 86cb0de1e87a444bdd8d00bc2a981a8abbb94234..33d3af13ec5c243828412671a198070d09ad895d 100644 +index 44d75c043805f9bfb4b08741fc652aafc6c50740..41c15ba67ad66245fdac2ada8e9f0de755fe01be 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -702,6 +702,10 @@ class WebContents : public PageNavigator, diff --git a/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch b/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch index 9d9906c69d..51ccbf1b3b 100644 --- a/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch +++ b/patches/chromium/network_service_allow_remote_certificate_verification_logic.patch @@ -147,7 +147,7 @@ index 479b87b12cae8cc7727b198e0d15b97a569cfc28..5b53653eb8448c3904fda67f054dd2ec builder.SetCertVerifier(IgnoreErrorsCertVerifier::MaybeWrapCertVerifier( diff --git a/services/network/network_context.h b/services/network/network_context.h -index a314820247451f507b92bb8e41891cd2958ae45b..ca1d417743e4ac3c1d3f9833c7d5cfc261d59087 100644 +index a314820247451f507b92bb8e41891cd2958ae45b..87e9c6b2549e0db4a3cd88f6528eeb84327ec183 100644 --- a/services/network/network_context.h +++ b/services/network/network_context.h @@ -114,6 +114,7 @@ class URLMatcher; @@ -171,7 +171,7 @@ index a314820247451f507b92bb8e41891cd2958ae45b..ca1d417743e4ac3c1d3f9833c7d5cfc2 std::vector dismount_closures_; #endif // BUILDFLAG(IS_DIRECTORY_TRANSFER_REQUIRED) -+ RemoteCertVerifier* remote_cert_verifier_ = nullptr; ++ raw_ptr remote_cert_verifier_ = nullptr; + // Created on-demand. Null if unused. std::unique_ptr internal_host_resolver_; diff --git a/patches/chromium/web_contents.patch b/patches/chromium/web_contents.patch index 5372a52432..926b89b2b3 100644 --- a/patches/chromium/web_contents.patch +++ b/patches/chromium/web_contents.patch @@ -35,7 +35,7 @@ index 57a810427461b8240d5f8da88e6ae2815b06c69a..a114c8a72670037fe0f4b9d95c16a670 CHECK(view_.get()); diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h -index 8baf744895c941df36d770ad17fca925a1dfd45f..86cb0de1e87a444bdd8d00bc2a981a8abbb94234 100644 +index 8baf744895c941df36d770ad17fca925a1dfd45f..44d75c043805f9bfb4b08741fc652aafc6c50740 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -96,10 +96,13 @@ class BrowserContext; @@ -57,8 +57,8 @@ index 8baf744895c941df36d770ad17fca925a1dfd45f..86cb0de1e87a444bdd8d00bc2a981a8a network::mojom::WebSandboxFlags::kNone; + // Optionally specify the view and delegate view. -+ content::WebContentsView* view = nullptr; -+ content::RenderViewHostDelegateView* delegate_view = nullptr; ++ raw_ptr view = nullptr; ++ raw_ptr delegate_view = nullptr; + // Value used to set the last time the WebContents was made active, this is // the value that'll be returned by GetLastActiveTime(). If this is left diff --git a/shell/app/uv_task_runner.h b/shell/app/uv_task_runner.h index f88e5f137f..d792d2711a 100644 --- a/shell/app/uv_task_runner.h +++ b/shell/app/uv_task_runner.h @@ -8,6 +8,7 @@ #include #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/task/single_thread_task_runner.h"" #include ""uv.h"" // NOLINT(build/include_directory) @@ -41,7 +42,7 @@ class UvTaskRunner : public base::SingleThreadTaskRunner { static void OnTimeout(uv_timer_t* timer); static void OnClose(uv_handle_t* handle); - uv_loop_t* loop_; + raw_ptr loop_; std::map tasks_; }; diff --git a/shell/browser/api/electron_api_browser_view.cc b/shell/browser/api/electron_api_browser_view.cc index acfbcd4c62..a3c65f1ca8 100644 --- a/shell/browser/api/electron_api_browser_view.cc +++ b/shell/browser/api/electron_api_browser_view.cc @@ -76,9 +76,8 @@ gin::WrapperInfo BrowserView::kWrapperInfo = {gin::kEmbedderNativeGin}; BrowserView::BrowserView(gin::Arguments* args, const gin_helper::Dictionary& options) : id_(GetNextId()) { - v8::Isolate* isolate = args->isolate(); gin_helper::Dictionary web_preferences = - gin::Dictionary::CreateEmpty(isolate); + gin::Dictionary::CreateEmpty(args->isolate()); options.Get(options::kWebPreferences, &web_preferences); web_preferences.Set(""type"", ""browserView""); @@ -92,7 +91,7 @@ BrowserView::BrowserView(gin::Arguments* args, auto web_contents = WebContents::CreateFromWebPreferences(args->isolate(), web_preferences); - web_contents_.Reset(isolate, web_contents.ToV8()); + web_contents_.Reset(args->isolate(), web_contents.ToV8()); api_web_contents_ = web_contents.get(); api_web_contents_->AddObserver(this); Observe(web_contents->web_contents()); diff --git a/shell/browser/api/electron_api_browser_view.h b/shell/browser/api/electron_api_browser_view.h index f7bcc0584f..a7b535149c 100644 --- a/shell/browser/api/electron_api_browser_view.h +++ b/shell/browser/api/electron_api_browser_view.h @@ -9,6 +9,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""content/public/browser/web_contents_observer.h"" #include ""gin/handle.h"" #include ""gin/wrappable.h"" @@ -79,7 +80,7 @@ class BrowserView : public gin::Wrappable, v8::Local GetWebContents(v8::Isolate*); v8::Global web_contents_; - class WebContents* api_web_contents_ = nullptr; + class raw_ptr api_web_contents_ = nullptr; std::unique_ptr view_; base::WeakPtr owner_window_; diff --git a/shell/browser/api/electron_api_cookies.h b/shell/browser/api/electron_api_cookies.h index 3b98c033af..3dd16e84bc 100644 --- a/shell/browser/api/electron_api_cookies.h +++ b/shell/browser/api/electron_api_cookies.h @@ -8,6 +8,7 @@ #include #include ""base/callback_list.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/values.h"" #include ""gin/handle.h"" #include ""net/cookies/canonical_cookie.h"" @@ -61,7 +62,7 @@ class Cookies : public gin::Wrappable, base::CallbackListSubscription cookie_change_subscription_; // Weak reference; ElectronBrowserContext is guaranteed to outlive us. - ElectronBrowserContext* browser_context_; + raw_ptr browser_context_; }; } // namespace api diff --git a/shell/browser/api/electron_api_data_pipe_holder.cc b/shell/browser/api/electron_api_data_pipe_holder.cc index da46fb2730..533e1607f8 100644 --- a/shell/browser/api/electron_api_data_pipe_holder.cc +++ b/shell/browser/api/electron_api_data_pipe_holder.cc @@ -7,6 +7,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""base/no_destructor.h"" #include ""base/strings/string_number_conversions.h"" @@ -129,7 +130,7 @@ class DataPipeReader { std::vector buffer_; // The head of buffer. - char* head_ = nullptr; + raw_ptr head_ = nullptr; // Remaining data to read. uint64_t remaining_size_ = 0; diff --git a/shell/browser/api/electron_api_debugger.h b/shell/browser/api/electron_api_debugger.h index 0c359b3c46..7429961948 100644 --- a/shell/browser/api/electron_api_debugger.h +++ b/shell/browser/api/electron_api_debugger.h @@ -8,6 +8,7 @@ #include #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/values.h"" #include ""content/public/browser/devtools_agent_host_client.h"" #include ""content/public/browser/web_contents_observer.h"" @@ -65,7 +66,7 @@ class Debugger : public gin::Wrappable, v8::Local SendCommand(gin::Arguments* args); void ClearPendingRequests(); - content::WebContents* web_contents_; // Weak Reference. + raw_ptr web_contents_; // Weak Reference. scoped_refptr agent_host_; PendingRequestMap pending_requests_; diff --git a/shell/browser/api/electron_api_download_item.h b/shell/browser/api/electron_api_download_item.h index 85e314d9c6..7b240aa10a 100644 --- a/shell/browser/api/electron_api_download_item.h +++ b/shell/browser/api/electron_api_download_item.h @@ -8,6 +8,7 @@ #include #include ""base/files/file_path.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""components/download/public/common/download_item.h"" #include ""gin/handle.h"" @@ -78,9 +79,9 @@ class DownloadItem : public gin::Wrappable, base::FilePath save_path_; file_dialog::DialogSettings dialog_options_; - download::DownloadItem* download_item_; + raw_ptr download_item_; - v8::Isolate* isolate_; + raw_ptr isolate_; base::WeakPtrFactory weak_factory_{this}; }; diff --git a/shell/browser/api/electron_api_menu.h b/shell/browser/api/electron_api_menu.h index d8de583209..6827228611 100644 --- a/shell/browser/api/electron_api_menu.h +++ b/shell/browser/api/electron_api_menu.h @@ -9,6 +9,7 @@ #include #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" #include ""gin/arguments.h"" #include ""shell/browser/api/electron_api_base_window.h"" #include ""shell/browser/event_emitter_mixin.h"" @@ -82,7 +83,7 @@ class Menu : public gin::Wrappable, virtual std::u16string GetAcceleratorTextAtForTesting(int index) const; std::unique_ptr model_; - Menu* parent_ = nullptr; + raw_ptr parent_ = nullptr; // Observable: void OnMenuWillClose() override; diff --git a/shell/browser/api/electron_api_native_theme.h b/shell/browser/api/electron_api_native_theme.h index 3983360c98..6be9c008e0 100644 --- a/shell/browser/api/electron_api_native_theme.h +++ b/shell/browser/api/electron_api_native_theme.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NATIVE_THEME_H_ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_NATIVE_THEME_H_ +#include ""base/memory/raw_ptr.h"" #include ""gin/handle.h"" #include ""gin/wrappable.h"" #include ""shell/browser/event_emitter_mixin.h"" @@ -51,8 +52,8 @@ class NativeTheme : public gin::Wrappable, void OnNativeThemeUpdatedOnUI(); private: - ui::NativeTheme* ui_theme_; - ui::NativeTheme* web_theme_; + raw_ptr ui_theme_; + raw_ptr web_theme_; }; } // namespace electron::api diff --git a/shell/browser/api/electron_api_net_log.h b/shell/browser/api/electron_api_net_log.h index 362192129a..e715e0e241 100644 --- a/shell/browser/api/electron_api_net_log.h +++ b/shell/browser/api/electron_api_net_log.h @@ -7,6 +7,7 @@ #include ""base/files/file_path.h"" #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""base/values.h"" #include ""gin/handle.h"" @@ -62,7 +63,7 @@ class NetLog : public gin::Wrappable { void NetLogStarted(int32_t error); private: - ElectronBrowserContext* browser_context_; + raw_ptr browser_context_; mojo::Remote net_log_exporter_; diff --git a/shell/browser/api/electron_api_notification.h b/shell/browser/api/electron_api_notification.h index 854e862833..3a4a46d327 100644 --- a/shell/browser/api/electron_api_notification.h +++ b/shell/browser/api/electron_api_notification.h @@ -8,6 +8,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/strings/utf_string_conversions.h"" #include ""gin/wrappable.h"" #include ""shell/browser/event_emitter_mixin.h"" @@ -108,7 +109,7 @@ class Notification : public gin::Wrappable, std::u16string close_button_text_; std::u16string toast_xml_; - electron::NotificationPresenter* presenter_; + raw_ptr presenter_; base::WeakPtr notification_; }; diff --git a/shell/browser/api/electron_api_protocol.h b/shell/browser/api/electron_api_protocol.h index a23cc3eb29..ef69d93726 100644 --- a/shell/browser/api/electron_api_protocol.h +++ b/shell/browser/api/electron_api_protocol.h @@ -8,6 +8,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""content/public/browser/content_browser_client.h"" #include ""gin/handle.h"" #include ""gin/wrappable.h"" @@ -101,7 +102,7 @@ class Protocol : public gin::Wrappable, // Weak pointer; the lifetime of the ProtocolRegistry is guaranteed to be // longer than the lifetime of this JS interface. - ProtocolRegistry* protocol_registry_; + raw_ptr protocol_registry_; }; } // namespace api diff --git a/shell/browser/api/electron_api_screen.h b/shell/browser/api/electron_api_screen.h index ef203cd7b1..20bbff0497 100644 --- a/shell/browser/api/electron_api_screen.h +++ b/shell/browser/api/electron_api_screen.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""gin/wrappable.h"" #include ""shell/browser/event_emitter_mixin.h"" #include ""shell/common/gin_helper/error_thrower.h"" @@ -53,7 +54,7 @@ class Screen : public gin::Wrappable, uint32_t changed_metrics) override; private: - display::Screen* screen_; + raw_ptr screen_; }; } // namespace electron::api diff --git a/shell/browser/api/electron_api_service_worker_context.h b/shell/browser/api/electron_api_service_worker_context.h index 048bcda716..9a6a6cd671 100644 --- a/shell/browser/api/electron_api_service_worker_context.h +++ b/shell/browser/api/electron_api_service_worker_context.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_SERVICE_WORKER_CONTEXT_H_ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_SERVICE_WORKER_CONTEXT_H_ +#include ""base/memory/raw_ptr.h"" #include ""content/public/browser/service_worker_context.h"" #include ""content/public/browser/service_worker_context_observer.h"" #include ""gin/handle.h"" @@ -53,7 +54,7 @@ class ServiceWorkerContext ~ServiceWorkerContext() override; private: - content::ServiceWorkerContext* service_worker_context_; + raw_ptr service_worker_context_; base::WeakPtrFactory weak_ptr_factory_{this}; }; diff --git a/shell/browser/api/electron_api_session.cc b/shell/browser/api/electron_api_session.cc index 22ff6ab78c..d278f03966 100644 --- a/shell/browser/api/electron_api_session.cc +++ b/shell/browser/api/electron_api_session.cc @@ -16,6 +16,7 @@ #include ""base/files/file_path.h"" #include ""base/files/file_util.h"" #include ""base/guid.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/strings/string_number_conversions.h"" #include ""base/strings/string_util.h"" #include ""base/strings/stringprintf.h"" @@ -327,7 +328,7 @@ class DictionaryObserver final : public SpellcheckCustomDictionary::Observer { struct UserDataLink : base::SupportsUserData::Data { explicit UserDataLink(Session* ses) : session(ses) {} - Session* session; + raw_ptr session; }; const void* kElectronApiSessionKey = &kElectronApiSessionKey; diff --git a/shell/browser/api/electron_api_session.h b/shell/browser/api/electron_api_session.h index 248673a07a..e50ae7ed52 100644 --- a/shell/browser/api/electron_api_session.h +++ b/shell/browser/api/electron_api_session.h @@ -8,6 +8,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/values.h"" #include ""content/public/browser/download_manager.h"" #include ""electron/buildflags/buildflags.h"" @@ -203,12 +204,12 @@ class Session : public gin::Wrappable, v8::Global service_worker_context_; v8::Global web_request_; - v8::Isolate* isolate_; + raw_ptr isolate_; // The client id to enable the network throttler. base::UnguessableToken network_emulation_token_; - ElectronBrowserContext* browser_context_; + raw_ptr browser_context_; }; } // namespace api diff --git a/shell/browser/api/electron_api_url_loader.cc b/shell/browser/api/electron_api_url_loader.cc index 6060cdadc4..38320da0ba 100644 --- a/shell/browser/api/electron_api_url_loader.cc +++ b/shell/browser/api/electron_api_url_loader.cc @@ -10,6 +10,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/no_destructor.h"" #include ""gin/handle.h"" #include ""gin/object_template_builder.h"" @@ -312,7 +313,7 @@ class JSChunkedDataPipeGetter : public gin::Wrappable, bool is_writing_ = false; uint64_t bytes_written_ = 0; - v8::Isolate* isolate_; + raw_ptr isolate_; v8::Global body_func_; }; diff --git a/shell/browser/api/electron_api_url_loader.h b/shell/browser/api/electron_api_url_loader.h index 590b9eab65..a0e89597f2 100644 --- a/shell/browser/api/electron_api_url_loader.h +++ b/shell/browser/api/electron_api_url_loader.h @@ -9,6 +9,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""gin/wrappable.h"" #include ""mojo/public/cpp/bindings/receiver_set.h"" @@ -122,7 +123,7 @@ class SimpleURLLoaderWrapper void Pin(); void PinBodyGetter(v8::Local); - ElectronBrowserContext* browser_context_; + raw_ptr browser_context_; int request_options_; std::unique_ptr request_; scoped_refptr url_loader_factory_; diff --git a/shell/browser/api/electron_api_view.h b/shell/browser/api/electron_api_view.h index 4c9b6df348..2a905cb263 100644 --- a/shell/browser/api/electron_api_view.h +++ b/shell/browser/api/electron_api_view.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""electron/buildflags/buildflags.h"" #include ""gin/handle.h"" #include ""shell/common/gin_helper/wrappable.h"" @@ -44,7 +45,7 @@ class View : public gin_helper::Wrappable { std::vector> child_views_; bool delete_view_ = true; - views::View* view_ = nullptr; + raw_ptr view_ = nullptr; }; } // namespace electron::api diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index e524bceda0..fc19d05c83 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -11,6 +11,8 @@ #include #include +#include ""base/memory/raw_ptr.h"" +#include ""base/memory/raw_ptr_exclusion.h"" #include ""base/memory/weak_ptr.h"" #include ""base/observer_list.h"" #include ""base/observer_list_types.h"" @@ -766,13 +768,13 @@ class WebContents : public ExclusiveAccessContext, #endif // The host webcontents that may contain this webcontents. - WebContents* embedder_ = nullptr; + RAW_PTR_EXCLUSION WebContents* embedder_ = nullptr; // Whether the guest view has been attached. bool attached_ = false; // The zoom controller for this webContents. - WebContentsZoomController* zoom_controller_ = nullptr; + raw_ptr zoom_controller_ = nullptr; // The type of current WebContents. Type type_ = Type::kBrowserWindow; @@ -810,7 +812,7 @@ class WebContents : public ExclusiveAccessContext, std::unique_ptr eye_dropper_; - ElectronBrowserContext* browser_context_; + raw_ptr browser_context_; // The stored InspectableWebContents object. // Notice that inspectable_web_contents_ must be placed after @@ -835,7 +837,7 @@ class WebContents : public ExclusiveAccessContext, #endif // Stores the frame thats currently in fullscreen, nullptr if there is none. - content::RenderFrameHost* fullscreen_frame_ = nullptr; + raw_ptr fullscreen_frame_ = nullptr; std::unique_ptr draggable_region_; diff --git a/shell/browser/api/electron_api_web_contents_view.cc b/shell/browser/api/electron_api_web_contents_view.cc index be795529df..55c89c8e0f 100644 --- a/shell/browser/api/electron_api_web_contents_view.cc +++ b/shell/browser/api/electron_api_web_contents_view.cc @@ -49,7 +49,7 @@ WebContentsView::~WebContentsView() { } gin::Handle WebContentsView::GetWebContents(v8::Isolate* isolate) { - return gin::CreateHandle(isolate, api_web_contents_); + return gin::CreateHandle(isolate, api_web_contents_.get()); } int WebContentsView::NonClientHitTest(const gfx::Point& point) { diff --git a/shell/browser/api/electron_api_web_contents_view.h b/shell/browser/api/electron_api_web_contents_view.h index aa2cd00912..46c10fc83d 100644 --- a/shell/browser/api/electron_api_web_contents_view.h +++ b/shell/browser/api/electron_api_web_contents_view.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_VIEW_H_ #define ELECTRON_SHELL_BROWSER_API_ELECTRON_API_WEB_CONTENTS_VIEW_H_ +#include ""base/memory/raw_ptr.h"" #include ""content/public/browser/web_contents_observer.h"" #include ""shell/browser/api/electron_api_view.h"" #include ""shell/browser/draggable_region_provider.h"" @@ -53,7 +54,7 @@ class WebContentsView : public View, // Keep a reference to v8 wrapper. v8::Global web_contents_; - api::WebContents* api_web_contents_; + raw_ptr api_web_contents_; }; } // namespace electron::api diff --git a/shell/browser/api/electron_api_web_frame_main.h b/shell/browser/api/electron_api_web_frame_main.h index 4facae73d9..56fb2eb3ac 100644 --- a/shell/browser/api/electron_api_web_frame_main.h +++ b/shell/browser/api/electron_api_web_frame_main.h @@ -8,6 +8,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""base/process/process.h"" #include ""gin/handle.h"" @@ -122,7 +123,7 @@ class WebFrameMain : public gin::Wrappable, int frame_tree_node_id_; - content::RenderFrameHost* render_frame_ = nullptr; + raw_ptr render_frame_ = nullptr; // Whether the RenderFrameHost has been removed and that it should no longer // be accessed. diff --git a/shell/browser/api/electron_api_web_request.cc b/shell/browser/api/electron_api_web_request.cc index 0e3b4ae622..e88d7c38df 100644 --- a/shell/browser/api/electron_api_web_request.cc +++ b/shell/browser/api/electron_api_web_request.cc @@ -8,6 +8,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/stl_util.h"" #include ""base/task/sequenced_task_runner.h"" #include ""base/values.h"" @@ -91,7 +92,7 @@ const char kUserDataKey[] = ""WebRequest""; // BrowserContext <=> WebRequest relationship. struct UserData : public base::SupportsUserData::Data { explicit UserData(WebRequest* data) : data(data) {} - WebRequest* data; + raw_ptr data; }; extensions::WebRequestResourceType ParseResourceType(const std::string& value) { @@ -612,7 +613,7 @@ gin::Handle WebRequest::From( static_cast(browser_context->GetUserData(kUserDataKey)); if (!user_data) return gin::Handle(); - return gin::CreateHandle(isolate, user_data->data); + return gin::CreateHandle(isolate, user_data->data.get()); } } // namespace electron::api diff --git a/shell/browser/api/electron_api_web_request.h b/shell/browser/api/electron_api_web_request.h index 0c243beace..a4bf0a9e10 100644 --- a/shell/browser/api/electron_api_web_request.h +++ b/shell/browser/api/electron_api_web_request.h @@ -8,6 +8,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/values.h"" #include ""extensions/common/url_pattern.h"" #include ""gin/arguments.h"" @@ -167,7 +168,7 @@ class WebRequest : public gin::Wrappable, public WebRequestAPI { std::map callbacks_; // Weak-ref, it manages us. - content::BrowserContext* browser_context_; + raw_ptr browser_context_; }; } // namespace electron::api diff --git a/shell/browser/api/frame_subscriber.h b/shell/browser/api/frame_subscriber.h index 4c680ea8b6..57cf81e96d 100644 --- a/shell/browser/api/frame_subscriber.h +++ b/shell/browser/api/frame_subscriber.h @@ -9,6 +9,7 @@ #include #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""components/viz/host/client_frame_sink_video_capturer.h"" #include ""content/public/browser/web_contents.h"" @@ -69,7 +70,7 @@ class FrameSubscriber : public content::WebContentsObserver, FrameCaptureCallback callback_; bool only_dirty_; - content::RenderWidgetHost* host_; + raw_ptr host_; std::unique_ptr video_capturer_; base::WeakPtrFactory weak_ptr_factory_{this}; diff --git a/shell/browser/api/gpuinfo_manager.h b/shell/browser/api/gpuinfo_manager.h index 8b134e50bf..3486d96903 100644 --- a/shell/browser/api/gpuinfo_manager.h +++ b/shell/browser/api/gpuinfo_manager.h @@ -8,6 +8,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""content/browser/gpu/gpu_data_manager_impl.h"" // nogncheck #include ""content/public/browser/gpu_data_manager.h"" #include ""content/public/browser/gpu_data_manager_observer.h"" @@ -42,7 +43,7 @@ class GPUInfoManager : public content::GpuDataManagerObserver { // This set maintains all the promises that should be fulfilled // once we have the complete information data std::vector> complete_info_promise_set_; - content::GpuDataManagerImpl* gpu_data_manager_; + raw_ptr gpu_data_manager_; }; } // namespace electron diff --git a/shell/browser/api/save_page_handler.h b/shell/browser/api/save_page_handler.h index d7468ed1a6..33328e6c7d 100644 --- a/shell/browser/api/save_page_handler.h +++ b/shell/browser/api/save_page_handler.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_API_SAVE_PAGE_HANDLER_H_ #define ELECTRON_SHELL_BROWSER_API_SAVE_PAGE_HANDLER_H_ +#include ""base/memory/raw_ptr.h"" #include ""components/download/public/common/download_item.h"" #include ""content/public/browser/download_manager.h"" #include ""content/public/browser/save_page_type.h"" @@ -42,7 +43,7 @@ class SavePageHandler : public content::DownloadManager::Observer, // download::DownloadItem::Observer: void OnDownloadUpdated(download::DownloadItem* item) override; - content::WebContents* web_contents_; // weak + raw_ptr web_contents_; // weak gin_helper::Promise promise_; }; diff --git a/shell/browser/certificate_manager_model.h b/shell/browser/certificate_manager_model.h index 463d9f666d..91f7f3c4dc 100644 --- a/shell/browser/certificate_manager_model.h +++ b/shell/browser/certificate_manager_model.h @@ -9,6 +9,7 @@ #include #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/memory/ref_counted.h"" #include ""net/cert/nss_cert_database.h"" @@ -107,7 +108,7 @@ class CertificateManagerModel { static void GetCertDBOnIOThread(content::ResourceContext* context, CreationCallback callback); - net::NSSCertDatabase* cert_db_; + raw_ptr cert_db_; // Whether the certificate database has a public slot associated with the // profile. If not set, importing certificates is not allowed with this model. bool is_user_db_available_; diff --git a/shell/browser/cookie_change_notifier.h b/shell/browser/cookie_change_notifier.h index be33c2b294..0f00938349 100644 --- a/shell/browser/cookie_change_notifier.h +++ b/shell/browser/cookie_change_notifier.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_COOKIE_CHANGE_NOTIFIER_H_ #include ""base/callback_list.h"" +#include ""base/memory/raw_ptr.h"" #include ""mojo/public/cpp/bindings/receiver.h"" #include ""net/cookies/cookie_change_dispatcher.h"" #include ""services/network/public/mojom/cookie_manager.mojom.h"" @@ -36,7 +37,7 @@ class CookieChangeNotifier : public network::mojom::CookieChangeListener { // network::mojom::CookieChangeListener implementation. void OnCookieChange(const net::CookieChangeInfo& change) override; - ElectronBrowserContext* browser_context_; + raw_ptr browser_context_; base::RepeatingCallbackList cookie_change_sub_list_; diff --git a/shell/browser/electron_autofill_driver.h b/shell/browser/electron_autofill_driver.h index 53219ce72f..65567a070c 100644 --- a/shell/browser/electron_autofill_driver.h +++ b/shell/browser/electron_autofill_driver.h @@ -12,6 +12,7 @@ #include ""shell/browser/ui/autofill_popup.h"" #endif +#include ""base/memory/raw_ptr.h"" #include ""mojo/public/cpp/bindings/associated_receiver.h"" #include ""mojo/public/cpp/bindings/pending_associated_receiver.h"" #include ""shell/common/api/api.mojom.h"" @@ -35,7 +36,7 @@ class AutofillDriver : public mojom::ElectronAutofillDriver { void HideAutofillPopup() override; private: - content::RenderFrameHost* const render_frame_host_; + raw_ptr const render_frame_host_; #if defined(TOOLKIT_VIEWS) std::unique_ptr autofill_popup_; diff --git a/shell/browser/electron_browser_client.h b/shell/browser/electron_browser_client.h index bfdba08c4b..77a68b602e 100644 --- a/shell/browser/electron_browser_client.h +++ b/shell/browser/electron_browser_client.h @@ -12,6 +12,7 @@ #include #include ""base/files/file_path.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/synchronization/lock.h"" #include ""content/public/browser/content_browser_client.h"" #include ""content/public/browser/render_process_host_observer.h"" @@ -314,7 +315,7 @@ class ElectronBrowserClient : public content::ContentBrowserClient, std::unique_ptr notification_service_; std::unique_ptr notification_presenter_; - Delegate* delegate_ = nullptr; + raw_ptr delegate_ = nullptr; std::string user_agent_override_ = """"; diff --git a/shell/browser/electron_browser_context.h b/shell/browser/electron_browser_context.h index 2774f0a9df..7ab732c7a0 100644 --- a/shell/browser/electron_browser_context.h +++ b/shell/browser/electron_browser_context.h @@ -9,7 +9,7 @@ #include #include #include - +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""chrome/browser/predictors/preconnect_manager.h"" #include ""content/public/browser/browser_context.h"" @@ -259,7 +259,7 @@ class ElectronBrowserContext : public content::BrowserContext { #if BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS) // Owned by the KeyedService system. - extensions::ElectronExtensionSystem* extension_system_; + raw_ptr extension_system_; #endif // Shared URLLoaderFactory. diff --git a/shell/browser/electron_download_manager_delegate.h b/shell/browser/electron_download_manager_delegate.h index e3100e54e5..334328cd08 100644 --- a/shell/browser/electron_download_manager_delegate.h +++ b/shell/browser/electron_download_manager_delegate.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_ELECTRON_DOWNLOAD_MANAGER_DELEGATE_H_ #define ELECTRON_SHELL_BROWSER_ELECTRON_DOWNLOAD_MANAGER_DELEGATE_H_ +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""content/public/browser/download_manager_delegate.h"" #include ""shell/browser/ui/file_dialog.h"" @@ -58,7 +59,7 @@ class ElectronDownloadManagerDelegate base::FilePath last_saved_directory_; - content::DownloadManager* download_manager_; + raw_ptr download_manager_; base::WeakPtrFactory weak_ptr_factory_{this}; }; diff --git a/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h b/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h index 8d167c60f1..286acf3923 100644 --- a/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h +++ b/shell/browser/extensions/api/runtime/electron_runtime_api_delegate.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""extensions/browser/api/runtime/runtime_api_delegate.h"" namespace content { @@ -36,7 +37,7 @@ class ElectronRuntimeAPIDelegate : public RuntimeAPIDelegate { bool RestartDevice(std::string* error_message) override; private: - content::BrowserContext* browser_context_; + raw_ptr browser_context_; }; } // namespace extensions diff --git a/shell/browser/extensions/api/tabs/tabs_api.h b/shell/browser/extensions/api/tabs/tabs_api.h index 4cbbcfc519..fd6c94f2c9 100644 --- a/shell/browser/extensions/api/tabs/tabs_api.h +++ b/shell/browser/extensions/api/tabs/tabs_api.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""extensions/browser/api/execute_code_function.h"" #include ""extensions/browser/extension_function.h"" #include ""extensions/common/extension_resource.h"" @@ -107,7 +108,7 @@ class TabsUpdateFunction : public ExtensionFunction { bool UpdateURL(const std::string& url, int tab_id, std::string* error); ResponseValue GetResult(); - content::WebContents* web_contents_; + raw_ptr web_contents_; private: ResponseAction Run() override; diff --git a/shell/browser/extensions/electron_extension_loader.h b/shell/browser/extensions/electron_extension_loader.h index dd0209ae55..16d3a13663 100644 --- a/shell/browser/extensions/electron_extension_loader.h +++ b/shell/browser/extensions/electron_extension_loader.h @@ -9,6 +9,7 @@ #include #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/memory/ref_counted.h"" #include ""base/memory/weak_ptr.h"" #include ""extensions/browser/extension_registrar.h"" @@ -80,7 +81,7 @@ class ElectronExtensionLoader : public ExtensionRegistrar::Delegate { bool CanDisableExtension(const Extension* extension) override; bool ShouldBlockExtension(const Extension* extension) override; - content::BrowserContext* browser_context_; // Not owned. + raw_ptr browser_context_; // Not owned. // Registers and unregisters extensions. ExtensionRegistrar extension_registrar_; diff --git a/shell/browser/extensions/electron_extension_message_filter.h b/shell/browser/extensions/electron_extension_message_filter.h index cb0d69a6f3..103c85d2e5 100644 --- a/shell/browser/extensions/electron_extension_message_filter.h +++ b/shell/browser/extensions/electron_extension_message_filter.h @@ -8,6 +8,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/task/sequenced_task_runner_helpers.h"" #include ""content/public/browser/browser_message_filter.h"" #include ""content/public/browser/browser_thread.h"" @@ -63,7 +64,7 @@ class ElectronExtensionMessageFilter : public content::BrowserMessageFilter { // be accessed on the UI thread! Furthermore since this class is refcounted it // may outlive |browser_context_|, so make sure to NULL check if in doubt; // async calls and the like. - content::BrowserContext* browser_context_; + raw_ptr browser_context_; }; } // namespace electron diff --git a/shell/browser/extensions/electron_extension_system.h b/shell/browser/extensions/electron_extension_system.h index f48d7ba9d4..d91ce93615 100644 --- a/shell/browser/extensions/electron_extension_system.h +++ b/shell/browser/extensions/electron_extension_system.h @@ -9,6 +9,7 @@ #include #include ""base/compiler_specific.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/memory/ref_counted.h"" #include ""base/memory/weak_ptr.h"" #include ""base/one_shot_event.h"" @@ -92,7 +93,7 @@ class ElectronExtensionSystem : public ExtensionSystem { scoped_refptr extension); void LoadComponentExtensions(); - content::BrowserContext* browser_context_; // Not owned. + raw_ptr browser_context_; // Not owned. std::unique_ptr service_worker_manager_; std::unique_ptr quota_service_; diff --git a/shell/browser/file_select_helper.h b/shell/browser/file_select_helper.h index 39a0d8dc91..60bdb2815c 100644 --- a/shell/browser/file_select_helper.h +++ b/shell/browser/file_select_helper.h @@ -11,6 +11,7 @@ #include #include ""base/compiler_specific.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/scoped_observation.h"" #include ""build/build_config.h"" #include ""content/public/browser/browser_thread.h"" @@ -188,8 +189,8 @@ class FileSelectHelper : public base::RefCountedThreadSafe< // The RenderFrameHost and WebContents for the page showing a file dialog // (may only be one such dialog). - content::RenderFrameHost* render_frame_host_; - content::WebContents* web_contents_; + raw_ptr render_frame_host_; + raw_ptr web_contents_; // |listener_| receives the result of the FileSelectHelper. scoped_refptr listener_; diff --git a/shell/browser/hid/hid_chooser_context.h b/shell/browser/hid/hid_chooser_context.h index 6c174427f4..a5c55d8403 100644 --- a/shell/browser/hid/hid_chooser_context.h +++ b/shell/browser/hid/hid_chooser_context.h @@ -13,6 +13,7 @@ #include #include ""base/containers/queue.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""base/observer_list.h"" #include ""base/unguessable_token.h"" @@ -117,7 +118,7 @@ class HidChooserContext : public KeyedService, const url::Origin& origin, const device::mojom::HidDeviceInfo& device); - ElectronBrowserContext* browser_context_; + raw_ptr browser_context_; bool is_initialized_ = false; base::queue diff --git a/shell/browser/javascript_environment.h b/shell/browser/javascript_environment.h index 49cc2175f9..459269f90e 100644 --- a/shell/browser/javascript_environment.h +++ b/shell/browser/javascript_environment.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""gin/public/isolate_holder.h"" #include ""uv.h"" // NOLINT(build/include_directory) #include ""v8/include/v8-locker.h"" @@ -42,7 +43,7 @@ class JavascriptEnvironment { v8::Isolate* Initialize(uv_loop_t* event_loop, bool setup_wasm_streaming); std::unique_ptr platform_; - v8::Isolate* isolate_; + raw_ptr isolate_; gin::IsolateHolder isolate_holder_; v8::Locker locker_; @@ -62,7 +63,7 @@ class NodeEnvironment { node::Environment* env() { return env_; } private: - node::Environment* env_; + raw_ptr env_; }; } // namespace electron diff --git a/shell/browser/lib/bluetooth_chooser.h b/shell/browser/lib/bluetooth_chooser.h index aed252c556..19f7eac838 100644 --- a/shell/browser/lib/bluetooth_chooser.h +++ b/shell/browser/lib/bluetooth_chooser.h @@ -9,6 +9,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""content/public/browser/bluetooth_chooser.h"" #include ""shell/browser/api/electron_api_web_contents.h"" @@ -42,7 +43,7 @@ class BluetoothChooser : public content::BluetoothChooser { private: std::map device_map_; - api::WebContents* api_web_contents_; + raw_ptr api_web_contents_; EventHandler event_handler_; bool refreshing_ = false; bool rescan_ = false; diff --git a/shell/browser/lib/power_observer_linux.h b/shell/browser/lib/power_observer_linux.h index c1d1453c4e..1c9c743efd 100644 --- a/shell/browser/lib/power_observer_linux.h +++ b/shell/browser/lib/power_observer_linux.h @@ -8,6 +8,7 @@ #include #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""base/power_monitor/power_observer.h"" #include ""dbus/bus.h"" @@ -42,7 +43,7 @@ class PowerObserverLinux { bool success); base::RepeatingCallback should_shutdown_; - base::PowerSuspendObserver* suspend_observer_ = nullptr; + raw_ptr suspend_observer_ = nullptr; scoped_refptr logind_; std::string lock_owner_name_; diff --git a/shell/browser/mac/in_app_purchase_observer.h b/shell/browser/mac/in_app_purchase_observer.h index 1f9d54013b..a5e610091f 100644 --- a/shell/browser/mac/in_app_purchase_observer.h +++ b/shell/browser/mac/in_app_purchase_observer.h @@ -9,6 +9,7 @@ #include #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr_exclusion.h"" #include ""base/memory/weak_ptr.h"" #include ""third_party/abseil-cpp/absl/types/optional.h"" @@ -74,7 +75,7 @@ class TransactionObserver { const std::vector& transactions) = 0; private: - InAppTransactionObserver* observer_; + RAW_PTR_EXCLUSION InAppTransactionObserver* observer_; base::WeakPtrFactory weak_ptr_factory_{this}; }; diff --git a/shell/browser/microtasks_runner.h b/shell/browser/microtasks_runner.h index b37b7b677d..0ad1e046d7 100644 --- a/shell/browser/microtasks_runner.h +++ b/shell/browser/microtasks_runner.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_MICROTASKS_RUNNER_H_ #define ELECTRON_SHELL_BROWSER_MICROTASKS_RUNNER_H_ +#include ""base/memory/raw_ptr.h"" #include ""base/task/task_observer.h"" namespace v8 { @@ -29,7 +30,7 @@ class MicrotasksRunner : public base::TaskObserver { void DidProcessTask(const base::PendingTask& pending_task) override; private: - v8::Isolate* isolate_; + raw_ptr isolate_; }; } // namespace electron diff --git a/shell/browser/native_browser_view.h b/shell/browser/native_browser_view.h index 620e414ec2..b76b4fd449 100644 --- a/shell/browser/native_browser_view.h +++ b/shell/browser/native_browser_view.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""content/public/browser/web_contents.h"" #include ""content/public/browser/web_contents_observer.h"" #include ""third_party/skia/include/core/SkColor.h"" @@ -54,7 +55,7 @@ class NativeBrowserView : public content::WebContentsObserver { // content::WebContentsObserver: void WebContentsDestroyed() override; - InspectableWebContents* inspectable_web_contents_; + raw_ptr inspectable_web_contents_; }; } // namespace electron diff --git a/shell/browser/native_window.h b/shell/browser/native_window.h index 23d37dd29d..ff69360d15 100644 --- a/shell/browser/native_window.h +++ b/shell/browser/native_window.h @@ -11,6 +11,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""base/observer_list.h"" #include ""base/supports_user_data.h"" @@ -425,7 +426,7 @@ class NativeWindow : public base::SupportsUserData, static int32_t next_id_; // The content view, weak ref. - views::View* content_view_ = nullptr; + raw_ptr content_view_ = nullptr; // Whether window has standard frame. bool has_frame_ = true; @@ -458,7 +459,7 @@ class NativeWindow : public base::SupportsUserData, gfx::Size aspect_ratio_extraSize_; // The parent window, it is guaranteed to be valid during this window's life. - NativeWindow* parent_ = nullptr; + raw_ptr parent_ = nullptr; // Is this a modal window. bool is_modal_ = false; diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index 19b3b76b22..3511d7ba15 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -13,6 +13,7 @@ #include #include ""base/cxx17_backports.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/stl_util.h"" #include ""base/strings/utf_string_conversions.h"" #include ""content/public/browser/browser_thread.h"" @@ -163,7 +164,7 @@ class NativeWindowClientView : public views::ClientView { } private: - NativeWindowViews* window_; + raw_ptr window_; }; } // namespace diff --git a/shell/browser/native_window_views.h b/shell/browser/native_window_views.h index 27019aaf7f..2961072ed4 100644 --- a/shell/browser/native_window_views.h +++ b/shell/browser/native_window_views.h @@ -12,6 +12,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""ui/views/widget/widget_observer.h"" #if defined(USE_OZONE) @@ -252,7 +253,7 @@ class NativeWindowViews : public NativeWindow, std::unique_ptr root_view_; // The view should be focused by default. - views::View* focused_view_ = nullptr; + raw_ptr focused_view_ = nullptr; // The ""resizable"" flag on Linux is implemented by setting size constraints, // we need to make sure size constraints are restored when window becomes diff --git a/shell/browser/net/network_context_service.h b/shell/browser/net/network_context_service.h index e68c21db25..a790a18284 100644 --- a/shell/browser/net/network_context_service.h +++ b/shell/browser/net/network_context_service.h @@ -6,6 +6,7 @@ #define ELECTRON_SHELL_BROWSER_NET_NETWORK_CONTEXT_SERVICE_H_ #include ""base/files/file_path.h"" +#include ""base/memory/raw_ptr.h"" #include ""chrome/browser/net/proxy_config_monitor.h"" #include ""components/keyed_service/core/keyed_service.h"" #include ""mojo/public/cpp/bindings/remote.h"" @@ -36,7 +37,7 @@ class NetworkContextService : public KeyedService { bool in_memory, const base::FilePath& path); - ElectronBrowserContext* browser_context_; + raw_ptr browser_context_; ProxyConfigMonitor proxy_config_monitor_; }; diff --git a/shell/browser/net/node_stream_loader.h b/shell/browser/net/node_stream_loader.h index c3afe02088..5629f64b55 100644 --- a/shell/browser/net/node_stream_loader.h +++ b/shell/browser/net/node_stream_loader.h @@ -10,6 +10,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""mojo/public/cpp/bindings/pending_remote.h"" #include ""mojo/public/cpp/bindings/receiver.h"" #include ""mojo/public/cpp/bindings/remote.h"" @@ -68,7 +69,7 @@ class NodeStreamLoader : public network::mojom::URLLoader { mojo::Receiver url_loader_; mojo::Remote client_; - v8::Isolate* isolate_; + raw_ptr isolate_; v8::Global emitter_; v8::Global buffer_; diff --git a/shell/browser/net/proxying_url_loader_factory.h b/shell/browser/net/proxying_url_loader_factory.h index 6d737293f3..e0231d9e36 100644 --- a/shell/browser/net/proxying_url_loader_factory.h +++ b/shell/browser/net/proxying_url_loader_factory.h @@ -12,6 +12,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""content/public/browser/content_browser_client.h"" #include ""content/public/browser/render_frame_host.h"" @@ -131,7 +132,7 @@ class ProxyingURLLoaderFactory void OnRequestError(const network::URLLoaderCompletionStatus& status); void HandleBeforeRequestRedirect(); - ProxyingURLLoaderFactory* const factory_; + raw_ptr const factory_; network::ResourceRequest request_; const absl::optional original_initiator_; const uint64_t request_id_ = 0; @@ -247,7 +248,7 @@ class ProxyingURLLoaderFactory bool ShouldIgnoreConnectionsLimit(const network::ResourceRequest& request); // Passed from api::WebRequest. - WebRequestAPI* web_request_api_; + raw_ptr web_request_api_; // This is passed from api::Protocol. // @@ -260,7 +261,7 @@ class ProxyingURLLoaderFactory const int render_process_id_; const int frame_routing_id_; - uint64_t* request_id_generator_; // managed by ElectronBrowserClient + raw_ptr request_id_generator_; // managed by ElectronBrowserClient std::unique_ptr navigation_ui_data_; absl::optional navigation_id_; mojo::ReceiverSet proxy_receivers_; diff --git a/shell/browser/net/proxying_websocket.h b/shell/browser/net/proxying_websocket.h index 009b9a1e9d..96dc08bb58 100644 --- a/shell/browser/net/proxying_websocket.h +++ b/shell/browser/net/proxying_websocket.h @@ -9,6 +9,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""content/public/browser/content_browser_client.h"" #include ""extensions/browser/api/web_request/web_request_info.h"" #include ""mojo/public/cpp/bindings/pending_receiver.h"" @@ -137,7 +138,7 @@ class ProxyingWebSocket : public network::mojom::WebSocketHandshakeClient, void OnMojoConnectionError(); // Passed from api::WebRequest. - WebRequestAPI* web_request_api_; + raw_ptr web_request_api_; // Saved to feed the api::WebRequest. network::ResourceRequest request_; diff --git a/shell/browser/net/resolve_host_function.h b/shell/browser/net/resolve_host_function.h index 97203bd844..963be64a2a 100644 --- a/shell/browser/net/resolve_host_function.h +++ b/shell/browser/net/resolve_host_function.h @@ -9,6 +9,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/memory/ref_counted.h"" #include ""mojo/public/cpp/bindings/receiver.h"" #include ""net/base/address_list.h"" @@ -58,7 +59,7 @@ class ResolveHostFunction mojo::Receiver receiver_{this}; // Weak Ref - ElectronBrowserContext* browser_context_; + raw_ptr browser_context_; std::string host_; network::mojom::ResolveHostParametersPtr params_; ResolveHostCallback callback_; diff --git a/shell/browser/net/resolve_proxy_helper.h b/shell/browser/net/resolve_proxy_helper.h index 7225e2542e..632e160041 100644 --- a/shell/browser/net/resolve_proxy_helper.h +++ b/shell/browser/net/resolve_proxy_helper.h @@ -8,6 +8,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/memory/ref_counted.h"" #include ""mojo/public/cpp/bindings/receiver.h"" #include ""services/network/public/mojom/proxy_lookup_client.mojom.h"" @@ -70,7 +71,7 @@ class ResolveProxyHelper mojo::Receiver receiver_{this}; // Weak Ref - ElectronBrowserContext* browser_context_; + raw_ptr browser_context_; }; } // namespace electron diff --git a/shell/browser/net/system_network_context_manager.cc b/shell/browser/net/system_network_context_manager.cc index 1cccb9a863..c9c77f6068 100644 --- a/shell/browser/net/system_network_context_manager.cc +++ b/shell/browser/net/system_network_context_manager.cc @@ -10,6 +10,7 @@ #include #include ""base/command_line.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/path_service.h"" #include ""base/strings/string_split.h"" #include ""chrome/browser/browser_process.h"" @@ -141,7 +142,7 @@ class SystemNetworkContextManager::URLLoaderFactoryForSystem ~URLLoaderFactoryForSystem() override = default; SEQUENCE_CHECKER(sequence_checker_); - SystemNetworkContextManager* manager_; + raw_ptr manager_; }; network::mojom::NetworkContext* SystemNetworkContextManager::GetContext() { diff --git a/shell/browser/network_hints_handler_impl.h b/shell/browser/network_hints_handler_impl.h index 3270cf2774..3abf619259 100644 --- a/shell/browser/network_hints_handler_impl.h +++ b/shell/browser/network_hints_handler_impl.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_NETWORK_HINTS_HANDLER_IMPL_H_ #define ELECTRON_SHELL_BROWSER_NETWORK_HINTS_HANDLER_IMPL_H_ +#include ""base/memory/raw_ptr.h"" #include ""components/network_hints/browser/simple_network_hints_handler_impl.h"" namespace content { @@ -29,7 +30,7 @@ class NetworkHintsHandlerImpl private: explicit NetworkHintsHandlerImpl(content::RenderFrameHost*); - content::BrowserContext* browser_context_ = nullptr; + raw_ptr browser_context_ = nullptr; }; #endif // ELECTRON_SHELL_BROWSER_NETWORK_HINTS_HANDLER_IMPL_H_ diff --git a/shell/browser/notifications/linux/libnotify_notification.h b/shell/browser/notifications/linux/libnotify_notification.h index 0158df4503..4e20ab4e12 100644 --- a/shell/browser/notifications/linux/libnotify_notification.h +++ b/shell/browser/notifications/linux/libnotify_notification.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_NOTIFICATION_H_ #define ELECTRON_SHELL_BROWSER_NOTIFICATIONS_LINUX_LIBNOTIFY_NOTIFICATION_H_ +#include ""base/memory/raw_ptr_exclusion.h"" #include ""library_loaders/libnotify_loader.h"" #include ""shell/browser/notifications/notification.h"" #include ""ui/base/glib/glib_signal.h"" @@ -34,7 +35,7 @@ class LibnotifyNotification : public Notification { NotifyNotification*, char*); - NotifyNotification* notification_ = nullptr; + RAW_PTR_EXCLUSION NotifyNotification* notification_ = nullptr; }; } // namespace electron diff --git a/shell/browser/notifications/notification.h b/shell/browser/notifications/notification.h index 6d7456c5dc..e3c65090ce 100644 --- a/shell/browser/notifications/notification.h +++ b/shell/browser/notifications/notification.h @@ -8,6 +8,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""third_party/skia/include/core/SkBitmap.h"" #include ""url/gurl.h"" @@ -81,8 +82,8 @@ class Notification { NotificationPresenter* presenter); private: - NotificationDelegate* delegate_; - NotificationPresenter* presenter_; + raw_ptr delegate_; + raw_ptr presenter_; std::string notification_id_; base::WeakPtrFactory weak_factory_{this}; diff --git a/shell/browser/notifications/platform_notification_service.h b/shell/browser/notifications/platform_notification_service.h index fefbbb70ce..55b00b9993 100644 --- a/shell/browser/notifications/platform_notification_service.h +++ b/shell/browser/notifications/platform_notification_service.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""content/public/browser/platform_notification_service.h"" namespace electron { @@ -50,7 +51,7 @@ class PlatformNotificationService base::Time ReadNextTriggerTimestamp() override; private: - ElectronBrowserClient* browser_client_; + raw_ptr browser_client_; }; } // namespace electron diff --git a/shell/browser/osr/osr_render_widget_host_view.cc b/shell/browser/osr/osr_render_widget_host_view.cc index a942d7ef0d..e7fe5132e6 100644 --- a/shell/browser/osr/osr_render_widget_host_view.cc +++ b/shell/browser/osr/osr_render_widget_host_view.cc @@ -12,6 +12,7 @@ #include ""base/functional/callback_helpers.h"" #include ""base/location.h"" #include ""base/memory/ptr_util.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/task/single_thread_task_runner.h"" #include ""base/time/time.h"" #include ""components/viz/common/features.h"" @@ -167,7 +168,7 @@ class ElectronDelegatedFrameHostClient void InvalidateLocalSurfaceIdOnEviction() override {} private: - OffScreenRenderWidgetHostView* const view_; + const raw_ptr view_; }; OffScreenRenderWidgetHostView::OffScreenRenderWidgetHostView( @@ -635,7 +636,7 @@ OffScreenRenderWidgetHostView::CreateHostDisplayClient( base::BindRepeating(&OffScreenRenderWidgetHostView::OnPaint, weak_ptr_factory_.GetWeakPtr())); host_display_client_->SetActive(IsPainting()); - return base::WrapUnique(host_display_client_); + return base::WrapUnique(host_display_client_.get()); } bool OffScreenRenderWidgetHostView::InstallTransparency() { diff --git a/shell/browser/osr/osr_render_widget_host_view.h b/shell/browser/osr/osr_render_widget_host_view.h index d4c15a3c0c..4a146ab16b 100644 --- a/shell/browser/osr/osr_render_widget_host_view.h +++ b/shell/browser/osr/osr_render_widget_host_view.h @@ -16,6 +16,7 @@ #include #endif +#include ""base/memory/raw_ptr.h"" #include ""base/process/kill.h"" #include ""base/threading/thread.h"" #include ""base/time/time.h"" @@ -243,11 +244,11 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, void UpdateBackgroundColorFromRenderer(SkColor color); // Weak ptrs. - content::RenderWidgetHostImpl* render_widget_host_; + raw_ptr render_widget_host_; - OffScreenRenderWidgetHostView* parent_host_view_ = nullptr; - OffScreenRenderWidgetHostView* popup_host_view_ = nullptr; - OffScreenRenderWidgetHostView* child_host_view_ = nullptr; + raw_ptr parent_host_view_ = nullptr; + raw_ptr popup_host_view_ = nullptr; + raw_ptr child_host_view_ = nullptr; std::set guest_host_views_; std::set proxy_views_; @@ -285,7 +286,7 @@ class OffScreenRenderWidgetHostView : public content::RenderWidgetHostViewBase, std::unique_ptr cursor_manager_; - OffScreenHostDisplayClient* host_display_client_; + raw_ptr host_display_client_; std::unique_ptr video_consumer_; std::unique_ptr diff --git a/shell/browser/osr/osr_video_consumer.h b/shell/browser/osr/osr_video_consumer.h index bcefbf4eb5..e96e7399aa 100644 --- a/shell/browser/osr/osr_video_consumer.h +++ b/shell/browser/osr/osr_video_consumer.h @@ -9,6 +9,7 @@ #include #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""components/viz/host/client_frame_sink_video_capturer.h"" #include ""media/capture/mojom/video_capture_buffer.mojom-forward.h"" @@ -52,7 +53,7 @@ class OffScreenVideoConsumer : public viz::mojom::FrameSinkVideoConsumer { OnPaintCallback callback_; - OffScreenRenderWidgetHostView* view_; + raw_ptr view_; std::unique_ptr video_capturer_; base::WeakPtrFactory weak_ptr_factory_{this}; diff --git a/shell/browser/osr/osr_view_proxy.h b/shell/browser/osr/osr_view_proxy.h index 6704cfd4fc..78c6460cf2 100644 --- a/shell/browser/osr/osr_view_proxy.h +++ b/shell/browser/osr/osr_view_proxy.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""third_party/skia/include/core/SkBitmap.h"" #include ""ui/events/event.h"" #include ""ui/gfx/geometry/rect.h"" @@ -41,12 +42,12 @@ class OffscreenViewProxy { void ResetView() { view_ = nullptr; } private: - views::View* view_; + raw_ptr view_; gfx::Rect view_bounds_; std::unique_ptr view_bitmap_; - OffscreenViewProxyObserver* observer_ = nullptr; + raw_ptr observer_ = nullptr; }; } // namespace electron diff --git a/shell/browser/osr/osr_web_contents_view.h b/shell/browser/osr/osr_web_contents_view.h index 9f3d55a93d..84fb3c84c4 100644 --- a/shell/browser/osr/osr_web_contents_view.h +++ b/shell/browser/osr/osr_web_contents_view.h @@ -8,6 +8,7 @@ #include ""shell/browser/native_window.h"" #include ""shell/browser/native_window_observer.h"" +#include ""base/memory/raw_ptr.h"" #include ""content/browser/renderer_host/render_view_host_delegate_view.h"" // nogncheck #include ""content/browser/web_contents/web_contents_view.h"" // nogncheck #include ""content/public/browser/web_contents.h"" @@ -92,7 +93,7 @@ class OffScreenWebContentsView : public content::WebContentsView, OffScreenRenderWidgetHostView* GetView() const; - NativeWindow* native_window_ = nullptr; + raw_ptr native_window_ = nullptr; const bool transparent_; bool painting_ = true; @@ -100,7 +101,7 @@ class OffScreenWebContentsView : public content::WebContentsView, OnPaintCallback callback_; // Weak refs. - content::WebContents* web_contents_ = nullptr; + raw_ptr web_contents_ = nullptr; #if BUILDFLAG(IS_MAC) OffScreenView* offScreenView_; diff --git a/shell/browser/serial/serial_chooser_context.h b/shell/browser/serial/serial_chooser_context.h index f64597b667..0e0f203a5d 100644 --- a/shell/browser/serial/serial_chooser_context.h +++ b/shell/browser/serial/serial_chooser_context.h @@ -10,6 +10,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""base/observer_list.h"" #include ""base/unguessable_token.h"" @@ -107,7 +108,7 @@ class SerialChooserContext : public KeyedService, mojo::Receiver client_receiver_{this}; base::ObserverList port_observer_list_; - ElectronBrowserContext* browser_context_; + raw_ptr browser_context_; base::WeakPtrFactory weak_factory_{this}; }; diff --git a/shell/browser/ui/accelerator_util.h b/shell/browser/ui/accelerator_util.h index 35c44869aa..3e88451a2b 100644 --- a/shell/browser/ui/accelerator_util.h +++ b/shell/browser/ui/accelerator_util.h @@ -8,6 +8,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""shell/browser/ui/electron_menu_model.h"" #include ""ui/base/accelerators/accelerator.h"" @@ -15,7 +16,7 @@ namespace accelerator_util { typedef struct { size_t position; - electron::ElectronMenuModel* model; + raw_ptr model; } MenuItem; typedef std::map AcceleratorTable; diff --git a/shell/browser/ui/autofill_popup.h b/shell/browser/ui/autofill_popup.h index a7e43f9d8f..59fa7d0425 100644 --- a/shell/browser/ui/autofill_popup.h +++ b/shell/browser/ui/autofill_popup.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""content/public/browser/render_frame_host.h"" #include ""shell/browser/ui/views/autofill_popup_view.h"" #include ""ui/color/color_id.h"" @@ -79,13 +80,13 @@ class AutofillPopup : public views::ViewObserver { // For sending the accepted suggestion to the render frame that // asked to open the popup - content::RenderFrameHost* frame_host_ = nullptr; + raw_ptr frame_host_ = nullptr; // The popup view. The lifetime is managed by the owning Widget - AutofillPopupView* view_ = nullptr; + raw_ptr view_ = nullptr; // The parent view that the popup view shows on. Weak ref. - views::View* parent_ = nullptr; + raw_ptr parent_ = nullptr; }; } // namespace electron diff --git a/shell/browser/ui/electron_desktop_window_tree_host_linux.h b/shell/browser/ui/electron_desktop_window_tree_host_linux.h index a6d993a705..d026bf4f7c 100644 --- a/shell/browser/ui/electron_desktop_window_tree_host_linux.h +++ b/shell/browser/ui/electron_desktop_window_tree_host_linux.h @@ -9,6 +9,7 @@ #ifndef ELECTRON_SHELL_BROWSER_UI_ELECTRON_DESKTOP_WINDOW_TREE_HOST_LINUX_H_ #define ELECTRON_SHELL_BROWSER_UI_ELECTRON_DESKTOP_WINDOW_TREE_HOST_LINUX_H_ +#include ""base/memory/raw_ptr.h"" #include ""base/scoped_observation.h"" #include ""shell/browser/native_window_views.h"" #include ""shell/browser/ui/views/client_frame_view_linux.h"" @@ -59,7 +60,7 @@ class ElectronDesktopWindowTreeHostLinux void UpdateClientDecorationHints(ClientFrameViewLinux* view); void UpdateWindowState(ui::PlatformWindowState new_state); - NativeWindowViews* native_window_view_; // weak ref + raw_ptr native_window_view_; // weak ref base::ScopedObservation theme_observation_{this}; diff --git a/shell/browser/ui/electron_menu_model.h b/shell/browser/ui/electron_menu_model.h index 63999ad161..2f13f1ad4b 100644 --- a/shell/browser/ui/electron_menu_model.h +++ b/shell/browser/ui/electron_menu_model.h @@ -10,6 +10,7 @@ #include #include ""base/files/file_path.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""base/observer_list.h"" #include ""base/observer_list_types.h"" @@ -112,7 +113,7 @@ class ElectronMenuModel : public ui::SimpleMenuModel { ElectronMenuModel* GetSubmenuModelAt(size_t index); private: - Delegate* delegate_; // weak ref. + raw_ptr delegate_; // weak ref. #if BUILDFLAG(IS_MAC) absl::optional sharing_item_; diff --git a/shell/browser/ui/file_dialog.h b/shell/browser/ui/file_dialog.h index 3bed2f581b..c410bbf4fb 100644 --- a/shell/browser/ui/file_dialog.h +++ b/shell/browser/ui/file_dialog.h @@ -10,6 +10,7 @@ #include #include ""base/files/file_path.h"" +#include ""base/memory/raw_ptr_exclusion.h"" #include ""shell/common/gin_helper/dictionary.h"" #include ""shell/common/gin_helper/promise.h"" @@ -44,7 +45,7 @@ enum SaveFileDialogProperty { }; struct DialogSettings { - electron::NativeWindow* parent_window = nullptr; + RAW_PTR_EXCLUSION electron::NativeWindow* parent_window = nullptr; std::string title; std::string message; std::string button_label; diff --git a/shell/browser/ui/file_dialog_gtk.cc b/shell/browser/ui/file_dialog_gtk.cc index 0d949e17f9..b6d9f9bb14 100644 --- a/shell/browser/ui/file_dialog_gtk.cc +++ b/shell/browser/ui/file_dialog_gtk.cc @@ -7,6 +7,8 @@ #include ""base/files/file_util.h"" #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" +#include ""base/memory/raw_ptr_exclusion.h"" #include ""base/strings/string_util.h"" #include ""electron/electron_gtk_stubs.h"" #include ""shell/browser/javascript_environment.h"" @@ -219,10 +221,10 @@ class FileChooserDialog { private: void AddFilters(const Filters& filters); - electron::NativeWindowViews* parent_; + raw_ptr parent_; - GtkFileChooser* dialog_; - GtkWidget* preview_; + RAW_PTR_EXCLUSION GtkFileChooser* dialog_; + RAW_PTR_EXCLUSION GtkWidget* preview_; Filters filters_; std::unique_ptr> save_promise_; diff --git a/shell/browser/ui/inspectable_web_contents.cc b/shell/browser/ui/inspectable_web_contents.cc index 5549a6ff0e..aad6b0bf98 100644 --- a/shell/browser/ui/inspectable_web_contents.cc +++ b/shell/browser/ui/inspectable_web_contents.cc @@ -13,6 +13,7 @@ #include ""base/json/json_reader.h"" #include ""base/json/json_writer.h"" #include ""base/json/string_escape.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/metrics/histogram.h"" #include ""base/stl_util.h"" #include ""base/strings/pattern.h"" @@ -314,7 +315,7 @@ class InspectableWebContents::NetworkResourceLoader void OnRetry(base::OnceClosure start_retry) override {} const int stream_id_; - InspectableWebContents* const bindings_; + raw_ptr const bindings_; const network::ResourceRequest resource_request_; const net::NetworkTrafficAnnotationTag traffic_annotation_; std::unique_ptr loader_; diff --git a/shell/browser/ui/inspectable_web_contents.h b/shell/browser/ui/inspectable_web_contents.h index b283c48ff6..ec52e229bd 100644 --- a/shell/browser/ui/inspectable_web_contents.h +++ b/shell/browser/ui/inspectable_web_contents.h @@ -15,6 +15,7 @@ #include ""base/containers/span.h"" #include ""base/containers/unique_ptr_adapters.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""chrome/browser/devtools/devtools_contents_resizing_strategy.h"" #include ""chrome/browser/devtools/devtools_embedder_message_dispatcher.h"" @@ -211,9 +212,10 @@ class InspectableWebContents std::string dock_state_; bool activate_ = true; - InspectableWebContentsDelegate* delegate_ = nullptr; // weak references. + raw_ptr delegate_ = + nullptr; // weak references. - PrefService* pref_service_; // weak reference. + raw_ptr pref_service_; // weak reference. std::unique_ptr web_contents_; @@ -221,7 +223,7 @@ class InspectableWebContents // one assigned by SetDevToolsWebContents. std::unique_ptr managed_devtools_web_contents_; // The external devtools assigned by SetDevToolsWebContents. - content::WebContents* external_devtools_web_contents_ = nullptr; + raw_ptr external_devtools_web_contents_ = nullptr; bool is_guest_; std::unique_ptr view_; diff --git a/shell/browser/ui/inspectable_web_contents_view.h b/shell/browser/ui/inspectable_web_contents_view.h index 7e6d6845c0..b279abfbcd 100644 --- a/shell/browser/ui/inspectable_web_contents_view.h +++ b/shell/browser/ui/inspectable_web_contents_view.h @@ -9,6 +9,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""shell/common/api/api.mojom.h"" #include ""ui/gfx/native_widget_types.h"" @@ -64,10 +65,11 @@ class InspectableWebContentsView { protected: // Owns us. - InspectableWebContents* inspectable_web_contents_; + raw_ptr inspectable_web_contents_; private: - InspectableWebContentsViewDelegate* delegate_ = nullptr; // weak references. + raw_ptr delegate_ = + nullptr; // weak references. }; } // namespace electron diff --git a/shell/browser/ui/message_box.h b/shell/browser/ui/message_box.h index 23727b28f3..66932b515d 100644 --- a/shell/browser/ui/message_box.h +++ b/shell/browser/ui/message_box.h @@ -9,6 +9,7 @@ #include #include ""base/functional/callback_forward.h"" +#include ""base/memory/raw_ptr_exclusion.h"" #include ""third_party/abseil-cpp/absl/types/optional.h"" #include ""ui/gfx/image/image_skia.h"" @@ -25,7 +26,7 @@ enum class MessageBoxType { }; struct MessageBoxSettings { - electron::NativeWindow* parent_window = nullptr; + RAW_PTR_EXCLUSION electron::NativeWindow* parent_window = nullptr; MessageBoxType type = electron::MessageBoxType::kNone; std::vector buttons; absl::optional id; diff --git a/shell/browser/ui/message_box_gtk.cc b/shell/browser/ui/message_box_gtk.cc index 5498ef5503..4b8e44029f 100644 --- a/shell/browser/ui/message_box_gtk.cc +++ b/shell/browser/ui/message_box_gtk.cc @@ -8,6 +8,8 @@ #include ""base/containers/contains.h"" #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" +#include ""base/memory/raw_ptr_exclusion.h"" #include ""base/no_destructor.h"" #include ""base/strings/string_util.h"" #include ""base/strings/utf_string_conversions.h"" @@ -194,8 +196,8 @@ class GtkMessageBox : public NativeWindowObserver { bool checkbox_checked_ = false; - NativeWindow* parent_; - GtkWidget* dialog_; + raw_ptr parent_; + RAW_PTR_EXCLUSION GtkWidget* dialog_; MessageBoxCallback callback_; }; diff --git a/shell/browser/ui/views/autofill_popup_view.h b/shell/browser/ui/views/autofill_popup_view.h index 1f1a1bedd0..43366c2b6f 100644 --- a/shell/browser/ui/views/autofill_popup_view.h +++ b/shell/browser/ui/views/autofill_popup_view.h @@ -9,6 +9,7 @@ #include ""shell/browser/ui/autofill_popup.h"" +#include ""base/memory/raw_ptr.h"" #include ""content/public/browser/native_web_keyboard_event.h"" #include ""content/public/browser/render_widget_host.h"" #include ""electron/buildflags/buildflags.h"" @@ -130,10 +131,10 @@ class AutofillPopupView : public views::WidgetDelegateView, void RemoveObserver(); // Controller for this popup. Weak reference. - AutofillPopup* popup_; + raw_ptr popup_; // The widget of the window that triggered this popup. Weak reference. - views::Widget* parent_widget_; + raw_ptr parent_widget_; // The time when the popup was shown. base::Time show_time_; diff --git a/shell/browser/ui/views/client_frame_view_linux.h b/shell/browser/ui/views/client_frame_view_linux.h index 5666c18473..79b3aadf0d 100644 --- a/shell/browser/ui/views/client_frame_view_linux.h +++ b/shell/browser/ui/views/client_frame_view_linux.h @@ -9,6 +9,8 @@ #include #include +#include ""base/memory/raw_ptr.h"" +#include ""base/memory/raw_ptr_exclusion.h"" #include ""base/scoped_observation.h"" #include ""shell/browser/ui/views/frameless_view.h"" #include ""ui/base/ui_base_types.h"" @@ -85,7 +87,7 @@ class ClientFrameViewLinux : public FramelessView, void (views::Widget::*callback)(); int accessibility_id; int hit_test_id; - views::ImageButton* button{nullptr}; + RAW_PTR_EXCLUSION views::ImageButton* button{nullptr}; }; struct ThemeValues { @@ -119,10 +121,10 @@ class ClientFrameViewLinux : public FramelessView, gfx::Size SizeWithDecorations(gfx::Size size) const; - ui::NativeTheme* theme_; + raw_ptr theme_; ThemeValues theme_values_; - views::Label* title_; + RAW_PTR_EXCLUSION views::Label* title_; std::unique_ptr nav_button_provider_; std::array nav_buttons_; @@ -132,7 +134,7 @@ class ClientFrameViewLinux : public FramelessView, bool host_supports_client_frame_shadow_ = false; - ui::WindowFrameProvider* frame_provider_; + raw_ptr frame_provider_; base::ScopedObservation native_theme_observer_{this}; diff --git a/shell/browser/ui/views/frameless_view.h b/shell/browser/ui/views/frameless_view.h index f88f543757..049f8008b2 100644 --- a/shell/browser/ui/views/frameless_view.h +++ b/shell/browser/ui/views/frameless_view.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_FRAMELESS_VIEW_H_ #define ELECTRON_SHELL_BROWSER_UI_VIEWS_FRAMELESS_VIEW_H_ +#include ""base/memory/raw_ptr.h"" #include ""ui/views/window/non_client_view.h"" namespace views { @@ -57,8 +58,8 @@ class FramelessView : public views::NonClientFrameView { const char* GetClassName() const override; // Not owned. - NativeWindowViews* window_ = nullptr; - views::Widget* frame_ = nullptr; + raw_ptr window_ = nullptr; + raw_ptr frame_ = nullptr; friend class NativeWindowsViews; }; diff --git a/shell/browser/ui/views/global_menu_bar_registrar_x11.h b/shell/browser/ui/views/global_menu_bar_registrar_x11.h index 1519f4c035..930d8c4473 100644 --- a/shell/browser/ui/views/global_menu_bar_registrar_x11.h +++ b/shell/browser/ui/views/global_menu_bar_registrar_x11.h @@ -9,6 +9,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""base/memory/ref_counted.h"" #include ""base/memory/singleton.h"" #include ""ui/base/glib/glib_signal.h"" @@ -53,7 +54,7 @@ class GlobalMenuBarRegistrarX11 { GObject*, GParamSpec*); - GDBusProxy* registrar_proxy_ = nullptr; + raw_ptr registrar_proxy_ = nullptr; // x11::Window which want to be registered, but haven't yet been because // we're waiting for the proxy to become available. diff --git a/shell/browser/ui/views/global_menu_bar_x11.h b/shell/browser/ui/views/global_menu_bar_x11.h index 2c5adcf31c..dbffbf7e64 100644 --- a/shell/browser/ui/views/global_menu_bar_x11.h +++ b/shell/browser/ui/views/global_menu_bar_x11.h @@ -8,6 +8,7 @@ #include #include ""base/compiler_specific.h"" +#include ""base/memory/raw_ptr.h"" #include ""shell/browser/ui/electron_menu_model.h"" #include ""ui/base/glib/glib_signal.h"" #include ""ui/gfx/native_widget_types.h"" @@ -72,10 +73,10 @@ class GlobalMenuBarX11 { unsigned int); CHROMEG_CALLBACK_0(GlobalMenuBarX11, void, OnSubMenuShow, DbusmenuMenuitem*); - NativeWindowViews* window_; + raw_ptr window_; x11::Window xwindow_; - DbusmenuServer* server_ = nullptr; + raw_ptr server_ = nullptr; }; } // namespace electron diff --git a/shell/browser/ui/views/inspectable_web_contents_view_views.cc b/shell/browser/ui/views/inspectable_web_contents_view_views.cc index 7c76417fa3..c3fd829795 100644 --- a/shell/browser/ui/views/inspectable_web_contents_view_views.cc +++ b/shell/browser/ui/views/inspectable_web_contents_view_views.cc @@ -9,6 +9,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/strings/utf_string_conversions.h"" #include ""shell/browser/ui/drag_util.h"" #include ""shell/browser/ui/inspectable_web_contents.h"" @@ -66,9 +67,9 @@ class DevToolsWindowDelegate : public views::ClientView, } private: - InspectableWebContentsViewViews* shell_; - views::View* view_; - views::Widget* widget_; + raw_ptr shell_; + raw_ptr view_; + raw_ptr widget_; ui::ImageModel icon_; }; @@ -95,8 +96,8 @@ InspectableWebContentsViewViews::InspectableWebContentsViewViews( } devtools_web_view_->SetVisible(false); - AddChildView(devtools_web_view_); - AddChildView(contents_web_view_); + AddChildView(devtools_web_view_.get()); + AddChildView(contents_web_view_.get()); } InspectableWebContentsViewViews::~InspectableWebContentsViewViews() { diff --git a/shell/browser/ui/views/inspectable_web_contents_view_views.h b/shell/browser/ui/views/inspectable_web_contents_view_views.h index 25f7f075c3..8ba51257ba 100644 --- a/shell/browser/ui/views/inspectable_web_contents_view_views.h +++ b/shell/browser/ui/views/inspectable_web_contents_view_views.h @@ -9,6 +9,7 @@ #include #include ""base/compiler_specific.h"" +#include ""base/memory/raw_ptr.h"" #include ""chrome/browser/devtools/devtools_contents_resizing_strategy.h"" #include ""shell/browser/ui/inspectable_web_contents_view.h"" #include ""third_party/skia/include/core/SkRegion.h"" @@ -48,13 +49,13 @@ class InspectableWebContentsViewViews : public InspectableWebContentsView, private: std::unique_ptr devtools_window_; - views::WebView* devtools_window_web_view_ = nullptr; - views::View* contents_web_view_ = nullptr; - views::WebView* devtools_web_view_ = nullptr; + raw_ptr devtools_window_web_view_ = nullptr; + raw_ptr contents_web_view_ = nullptr; + raw_ptr devtools_web_view_ = nullptr; DevToolsContentsResizingStrategy strategy_; bool devtools_visible_ = false; - views::WidgetDelegate* devtools_window_delegate_ = nullptr; + raw_ptr devtools_window_delegate_ = nullptr; std::u16string title_; }; diff --git a/shell/browser/ui/views/menu_bar.h b/shell/browser/ui/views/menu_bar.h index b4beb95a72..21e4956f6e 100644 --- a/shell/browser/ui/views/menu_bar.h +++ b/shell/browser/ui/views/menu_bar.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_MENU_BAR_H_ #define ELECTRON_SHELL_BROWSER_UI_VIEWS_MENU_BAR_H_ +#include ""base/memory/raw_ptr.h"" #include ""shell/browser/native_window_observer.h"" #include ""shell/browser/ui/electron_menu_model.h"" #include ""shell/browser/ui/views/menu_delegate.h"" @@ -87,9 +88,9 @@ class MenuBar : public views::AccessiblePaneView, SkColor disabled_color_; #endif - NativeWindow* window_; - RootView* root_view_; - ElectronMenuModel* menu_model_ = nullptr; + raw_ptr window_; + raw_ptr root_view_; + raw_ptr menu_model_ = nullptr; bool accelerator_installed_ = false; }; diff --git a/shell/browser/ui/views/menu_delegate.h b/shell/browser/ui/views/menu_delegate.h index 92153f9773..8af32cbcb7 100644 --- a/shell/browser/ui/views/menu_delegate.h +++ b/shell/browser/ui/views/menu_delegate.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""base/observer_list.h"" #include ""shell/browser/ui/electron_menu_model.h"" #include ""ui/views/controls/menu/menu_delegate.h"" @@ -66,13 +67,13 @@ class MenuDelegate : public views::MenuDelegate { views::MenuButton** button) override; private: - MenuBar* menu_bar_; + raw_ptr menu_bar_; int id_ = -1; std::unique_ptr adapter_; std::unique_ptr menu_runner_; // The menu button to switch to. - views::MenuButton* button_to_open_ = nullptr; + raw_ptr button_to_open_ = nullptr; bool hold_first_switch_ = false; base::ObserverList::Unchecked observers_; diff --git a/shell/browser/ui/views/menu_model_adapter.h b/shell/browser/ui/views/menu_model_adapter.h index 95fc8dbb6e..669a8da540 100644 --- a/shell/browser/ui/views/menu_model_adapter.h +++ b/shell/browser/ui/views/menu_model_adapter.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_MENU_MODEL_ADAPTER_H_ #define ELECTRON_SHELL_BROWSER_UI_VIEWS_MENU_MODEL_ADAPTER_H_ +#include ""base/memory/raw_ptr.h"" #include ""shell/browser/ui/electron_menu_model.h"" #include ""ui/views/controls/menu/menu_model_adapter.h"" @@ -23,7 +24,7 @@ class MenuModelAdapter : public views::MenuModelAdapter { bool GetAccelerator(int id, ui::Accelerator* accelerator) const override; private: - ElectronMenuModel* menu_model_; + raw_ptr menu_model_; }; } // namespace electron diff --git a/shell/browser/ui/views/native_frame_view.h b/shell/browser/ui/views/native_frame_view.h index 8098e43dfb..a10a439106 100644 --- a/shell/browser/ui/views/native_frame_view.h +++ b/shell/browser/ui/views/native_frame_view.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_UI_VIEWS_NATIVE_FRAME_VIEW_H_ #define ELECTRON_SHELL_BROWSER_UI_VIEWS_NATIVE_FRAME_VIEW_H_ +#include ""base/memory/raw_ptr.h"" #include ""ui/views/window/native_frame_view.h"" namespace electron { @@ -29,7 +30,7 @@ class NativeFrameView : public views::NativeFrameView { const char* GetClassName() const override; private: - NativeWindow* window_; // weak ref. + raw_ptr window_; // weak ref. }; } // namespace electron diff --git a/shell/browser/ui/views/root_view.h b/shell/browser/ui/views/root_view.h index d893a42320..7ecfc3c27c 100644 --- a/shell/browser/ui/views/root_view.h +++ b/shell/browser/ui/views/root_view.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""shell/browser/ui/accelerator_util.h"" #include ""ui/gfx/geometry/insets.h"" #include ""ui/views/view.h"" @@ -53,7 +54,7 @@ class RootView : public views::View { private: // Parent window, weak ref. - NativeWindow* window_; + raw_ptr window_; // Menu bar. std::unique_ptr menu_bar_; diff --git a/shell/browser/usb/usb_chooser_context.h b/shell/browser/usb/usb_chooser_context.h index 76c55b0dd1..12f52ed094 100644 --- a/shell/browser/usb/usb_chooser_context.h +++ b/shell/browser/usb/usb_chooser_context.h @@ -13,6 +13,7 @@ #include #include ""base/containers/queue.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/observer_list.h"" #include ""base/values.h"" #include ""build/build_config.h"" @@ -112,7 +113,7 @@ class UsbChooserContext : public KeyedService, client_receiver_{this}; base::ObserverList device_observer_list_; - ElectronBrowserContext* browser_context_; + raw_ptr browser_context_; base::WeakPtrFactory weak_factory_{this}; }; diff --git a/shell/browser/web_contents_permission_helper.h b/shell/browser/web_contents_permission_helper.h index 972675c19f..bde6b2952c 100644 --- a/shell/browser/web_contents_permission_helper.h +++ b/shell/browser/web_contents_permission_helper.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_ #define ELECTRON_SHELL_BROWSER_WEB_CONTENTS_PERMISSION_HELPER_H_ +#include ""base/memory/raw_ptr.h"" #include ""base/values.h"" #include ""content/public/browser/media_stream_request.h"" #include ""content/public/browser/web_contents_user_data.h"" @@ -71,7 +72,7 @@ class WebContentsPermissionHelper // TODO(clavin): refactor to use the WebContents provided by the // WebContentsUserData base class instead of storing a duplicate ref - content::WebContents* web_contents_; + raw_ptr web_contents_; WEB_CONTENTS_USER_DATA_KEY_DECL(); }; diff --git a/shell/browser/web_contents_preferences.h b/shell/browser/web_contents_preferences.h index eac4f7e51e..9d6bcfcfb9 100644 --- a/shell/browser/web_contents_preferences.h +++ b/shell/browser/web_contents_preferences.h @@ -9,6 +9,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/values.h"" #include ""content/public/browser/web_contents_user_data.h"" #include ""electron/buildflags/buildflags.h"" @@ -92,7 +93,7 @@ class WebContentsPreferences // TODO(clavin): refactor to use the WebContents provided by the // WebContentsUserData base class instead of storing a duplicate ref - content::WebContents* web_contents_; + raw_ptr web_contents_; bool plugins_; bool experimental_features_; diff --git a/shell/browser/web_contents_zoom_controller.h b/shell/browser/web_contents_zoom_controller.h index 2df6f22984..c8e9124648 100644 --- a/shell/browser/web_contents_zoom_controller.h +++ b/shell/browser/web_contents_zoom_controller.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_BROWSER_WEB_CONTENTS_ZOOM_CONTROLLER_H_ #define ELECTRON_SHELL_BROWSER_WEB_CONTENTS_ZOOM_CONTROLLER_H_ +#include ""base/memory/raw_ptr.h"" #include ""base/observer_list.h"" #include ""base/observer_list_types.h"" #include ""content/public/browser/host_zoom_map.h"" @@ -111,11 +112,11 @@ class WebContentsZoomController int old_process_id_ = -1; int old_view_id_ = -1; - WebContentsZoomController* embedder_zoom_controller_ = nullptr; + raw_ptr embedder_zoom_controller_ = nullptr; base::ObserverList observers_; - content::HostZoomMap* host_zoom_map_; + raw_ptr host_zoom_map_; WEB_CONTENTS_USER_DATA_KEY_DECL(); }; diff --git a/shell/browser/web_view_guest_delegate.h b/shell/browser/web_view_guest_delegate.h index 3b8671c4e2..38b456b0aa 100644 --- a/shell/browser/web_view_guest_delegate.h +++ b/shell/browser/web_view_guest_delegate.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""content/public/browser/browser_plugin_guest_delegate.h"" #include ""shell/browser/web_contents_zoom_controller.h"" @@ -48,13 +49,13 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate, void ResetZoomController(); // The WebContents that attaches this guest view. - content::WebContents* embedder_web_contents_ = nullptr; + raw_ptr embedder_web_contents_ = nullptr; // The zoom controller of the embedder that is used // to subscribe for zoom changes. - WebContentsZoomController* embedder_zoom_controller_ = nullptr; + raw_ptr embedder_zoom_controller_ = nullptr; - api::WebContents* api_web_contents_ = nullptr; + raw_ptr api_web_contents_ = nullptr; }; } // namespace electron diff --git a/shell/browser/web_view_manager.cc b/shell/browser/web_view_manager.cc index f24a5d1b83..ab870820b1 100644 --- a/shell/browser/web_view_manager.cc +++ b/shell/browser/web_view_manager.cc @@ -29,7 +29,7 @@ bool WebViewManager::ForEachGuest(content::WebContents* embedder_web_contents, if (item.second.embedder != embedder_web_contents) continue; - auto* guest_web_contents = item.second.web_contents; + content::WebContents* guest_web_contents = item.second.web_contents; if (guest_web_contents && callback.Run(guest_web_contents)) return true; } diff --git a/shell/browser/web_view_manager.h b/shell/browser/web_view_manager.h index 19d25211ff..c327e2cda7 100644 --- a/shell/browser/web_view_manager.h +++ b/shell/browser/web_view_manager.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""content/public/browser/browser_plugin_guest_manager.h"" namespace electron { @@ -33,8 +34,8 @@ class WebViewManager : public content::BrowserPluginGuestManager { private: struct WebContentsWithEmbedder { - content::WebContents* web_contents; - content::WebContents* embedder; + raw_ptr web_contents; + raw_ptr embedder; }; // guest_instance_id => (web_contents, embedder) std::map web_contents_embedder_map_; diff --git a/shell/browser/zoom_level_delegate.h b/shell/browser/zoom_level_delegate.h index 1c4302fadf..50922c3e40 100644 --- a/shell/browser/zoom_level_delegate.h +++ b/shell/browser/zoom_level_delegate.h @@ -7,6 +7,7 @@ #include +#include ""base/memory/raw_ptr.h"" #include ""base/values.h"" #include ""components/prefs/pref_service.h"" #include ""content/public/browser/host_zoom_map.h"" @@ -52,8 +53,8 @@ class ZoomLevelDelegate : public content::ZoomLevelDelegate { // zoom levels (if any) managed by this class (for its associated partition). void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); - PrefService* pref_service_; - content::HostZoomMap* host_zoom_map_ = nullptr; + raw_ptr pref_service_; + raw_ptr host_zoom_map_ = nullptr; base::CallbackListSubscription zoom_subscription_; std::string partition_key_; }; diff --git a/shell/common/api/electron_api_native_image.h b/shell/common/api/electron_api_native_image.h index 3330765ff5..af646e4d85 100644 --- a/shell/common/api/electron_api_native_image.h +++ b/shell/common/api/electron_api_native_image.h @@ -9,6 +9,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/values.h"" #include ""gin/handle.h"" #include ""gin/wrappable.h"" @@ -134,7 +135,7 @@ class NativeImage : public gin::Wrappable { gfx::Image image_; - v8::Isolate* isolate_; + raw_ptr isolate_; int32_t memory_usage_ = 0; }; diff --git a/shell/common/gin_converters/net_converter.cc b/shell/common/gin_converters/net_converter.cc index 4df91635ea..acef56271e 100644 --- a/shell/common/gin_converters/net_converter.cc +++ b/shell/common/gin_converters/net_converter.cc @@ -10,6 +10,7 @@ #include #include ""base/containers/span.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/strings/string_number_conversions.h"" #include ""base/strings/string_util.h"" #include ""base/values.h"" @@ -475,10 +476,10 @@ class ChunkedDataPipeReadableStream OnSizeReceived(net::ERR_FAILED, 0); } - v8::Isolate* isolate_; + raw_ptr isolate_; int status_ = net::OK; scoped_refptr resource_request_body_; - network::DataElementChunkedDataPipe* data_element_; + raw_ptr data_element_; mojo::Remote chunked_data_pipe_getter_; mojo::ScopedDataPipeConsumerHandle data_pipe_; mojo::SimpleWatcher handle_watcher_; diff --git a/shell/common/gin_helper/accessor.h b/shell/common/gin_helper/accessor.h index 5bd0bc9cb4..b8a004eca4 100644 --- a/shell/common/gin_helper/accessor.h +++ b/shell/common/gin_helper/accessor.h @@ -5,6 +5,8 @@ #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_ACCESSOR_H_ #define ELECTRON_SHELL_COMMON_GIN_HELPER_ACCESSOR_H_ +#include ""base/memory/raw_ptr_exclusion.h"" + namespace gin_helper { // Wrapper for a generic value to be used as an accessor in a @@ -19,7 +21,7 @@ struct AccessorValue { }; template struct AccessorValue { - T* Value; + RAW_PTR_EXCLUSION T* Value; }; } // namespace gin_helper diff --git a/shell/common/gin_helper/error_thrower.h b/shell/common/gin_helper/error_thrower.h index 6089363c42..879705b70a 100644 --- a/shell/common/gin_helper/error_thrower.h +++ b/shell/common/gin_helper/error_thrower.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_ERROR_THROWER_H_ #define ELECTRON_SHELL_COMMON_GIN_HELPER_ERROR_THROWER_H_ +#include ""base/memory/raw_ptr.h"" #include ""base/strings/string_piece.h"" #include ""v8/include/v8.h"" @@ -29,7 +30,7 @@ class ErrorThrower { v8::Local (*)(v8::Local err_msg); void Throw(ErrorGenerator gen, base::StringPiece err_msg) const; - v8::Isolate* isolate_; + raw_ptr isolate_; }; } // namespace gin_helper diff --git a/shell/common/gin_helper/function_template.h b/shell/common/gin_helper/function_template.h index 792e0980da..11b38f8fac 100644 --- a/shell/common/gin_helper/function_template.h +++ b/shell/common/gin_helper/function_template.h @@ -9,6 +9,7 @@ #include ""base/functional/bind.h"" #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" #include ""gin/arguments.h"" #include ""shell/common/gin_helper/arguments.h"" #include ""shell/common/gin_helper/destroyable.h"" @@ -241,7 +242,7 @@ class Invoker, ArgTypes...> return arg1 && And(args...); } - gin::Arguments* args_; + raw_ptr args_; }; // DispatchToCallback converts all the JavaScript arguments to C++ types and diff --git a/shell/common/gin_helper/object_template_builder.h b/shell/common/gin_helper/object_template_builder.h index 5ec9761bee..05526043df 100644 --- a/shell/common/gin_helper/object_template_builder.h +++ b/shell/common/gin_helper/object_template_builder.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_OBJECT_TEMPLATE_BUILDER_H_ #define ELECTRON_SHELL_COMMON_GIN_HELPER_OBJECT_TEMPLATE_BUILDER_H_ +#include ""base/memory/raw_ptr.h"" #include ""shell/common/gin_helper/function_template.h"" namespace gin_helper { @@ -66,7 +67,7 @@ class ObjectTemplateBuilder { v8::Local getter, v8::Local setter); - v8::Isolate* isolate_; + raw_ptr isolate_; // ObjectTemplateBuilder should only be used on the stack. v8::Local template_; diff --git a/shell/common/gin_helper/persistent_dictionary.h b/shell/common/gin_helper/persistent_dictionary.h index 8bc19d822c..a10d8802b2 100644 --- a/shell/common/gin_helper/persistent_dictionary.h +++ b/shell/common/gin_helper/persistent_dictionary.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_PERSISTENT_DICTIONARY_H_ #define ELECTRON_SHELL_COMMON_GIN_HELPER_PERSISTENT_DICTIONARY_H_ +#include ""base/memory/raw_ptr.h"" #include ""shell/common/gin_helper/dictionary.h"" namespace gin_helper { @@ -38,7 +39,7 @@ class PersistentDictionary { } private: - v8::Isolate* isolate_ = nullptr; + raw_ptr isolate_ = nullptr; v8::Global handle_; }; diff --git a/shell/common/gin_helper/promise.h b/shell/common/gin_helper/promise.h index efdc170930..6acf9b49ea 100644 --- a/shell/common/gin_helper/promise.h +++ b/shell/common/gin_helper/promise.h @@ -10,6 +10,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""base/strings/string_piece.h"" #include ""content/public/browser/browser_task_traits.h"" #include ""content/public/browser/browser_thread.h"" @@ -77,7 +78,7 @@ class PromiseBase { v8::Local GetInner() const; private: - v8::Isolate* isolate_; + raw_ptr isolate_; v8::Global context_; v8::Global resolver_; }; diff --git a/shell/common/gin_helper/wrappable_base.h b/shell/common/gin_helper/wrappable_base.h index 87ba126d17..996cb40472 100644 --- a/shell/common/gin_helper/wrappable_base.h +++ b/shell/common/gin_helper/wrappable_base.h @@ -5,6 +5,7 @@ #ifndef ELECTRON_SHELL_COMMON_GIN_HELPER_WRAPPABLE_BASE_H_ #define ELECTRON_SHELL_COMMON_GIN_HELPER_WRAPPABLE_BASE_H_ +#include ""base/memory/raw_ptr.h"" #include ""v8/include/v8.h"" namespace gin { @@ -62,7 +63,7 @@ class WrappableBase { static void SecondWeakCallback( const v8::WeakCallbackInfo& data); - v8::Isolate* isolate_ = nullptr; + raw_ptr isolate_ = nullptr; }; } // namespace gin_helper diff --git a/shell/common/heap_snapshot.cc b/shell/common/heap_snapshot.cc index 2f416e6413..0a13849329 100644 --- a/shell/common/heap_snapshot.cc +++ b/shell/common/heap_snapshot.cc @@ -5,6 +5,7 @@ #include ""shell/common/heap_snapshot.h"" #include ""base/files/file.h"" +#include ""base/memory/raw_ptr.h"" #include ""v8/include/v8-profiler.h"" #include ""v8/include/v8.h"" @@ -28,7 +29,7 @@ class HeapSnapshotOutputStream : public v8::OutputStream { } private: - base::File* file_ = nullptr; + raw_ptr file_ = nullptr; bool is_complete_ = false; }; diff --git a/shell/common/key_weak_map.h b/shell/common/key_weak_map.h index 038349b8e9..487ada3f5a 100644 --- a/shell/common/key_weak_map.h +++ b/shell/common/key_weak_map.h @@ -9,6 +9,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""v8/include/v8.h"" namespace electron { @@ -20,7 +21,7 @@ class KeyWeakMap { // Records the key and self, used by SetWeak. struct KeyObject { K key; - KeyWeakMap* self; + raw_ptr self; }; KeyWeakMap() {} diff --git a/shell/common/node_bindings.h b/shell/common/node_bindings.h index 5476434f96..f8df9cb908 100644 --- a/shell/common/node_bindings.h +++ b/shell/common/node_bindings.h @@ -10,6 +10,8 @@ #include #include ""base/files/file_path.h"" +#include ""base/memory/raw_ptr.h"" +#include ""base/memory/raw_ptr_exclusion.h"" #include ""base/memory/weak_ptr.h"" #include ""uv.h"" // NOLINT(build/include_directory) #include ""v8/include/v8.h"" @@ -71,7 +73,7 @@ class UvHandle { delete reinterpret_cast(handle); } - T* t_ = {}; + RAW_PTR_EXCLUSION T* t_ = {}; }; class NodeBindings { @@ -146,7 +148,7 @@ class NodeBindings { scoped_refptr task_runner_; // Current thread's libuv loop. - uv_loop_t* uv_loop_; + raw_ptr uv_loop_; private: // Thread to poll uv events. @@ -171,10 +173,10 @@ class NodeBindings { uv_sem_t embed_sem_; // Environment that to wrap the uv loop. - node::Environment* uv_env_ = nullptr; + raw_ptr uv_env_ = nullptr; // Isolate data used in creating the environment - node::IsolateData* isolate_data_ = nullptr; + raw_ptr isolate_data_ = nullptr; base::WeakPtrFactory weak_factory_{this}; }; diff --git a/shell/common/platform_util_linux.cc b/shell/common/platform_util_linux.cc index e534b184d6..bbfa3e63ce 100644 --- a/shell/common/platform_util_linux.cc +++ b/shell/common/platform_util_linux.cc @@ -15,6 +15,7 @@ #include ""base/environment.h"" #include ""base/files/file_util.h"" #include ""base/logging.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/nix/xdg_util.h"" #include ""base/no_destructor.h"" #include ""base/posix/eintr_wrapper.h"" @@ -241,8 +242,8 @@ class ShowItemHelper { } scoped_refptr bus_; - dbus::ObjectProxy* dbus_proxy_ = nullptr; - dbus::ObjectProxy* object_proxy_ = nullptr; + raw_ptr dbus_proxy_ = nullptr; + raw_ptr object_proxy_ = nullptr; absl::optional prefer_filemanager_interface_; }; diff --git a/shell/common/v8_value_serializer.cc b/shell/common/v8_value_serializer.cc index 645797bcbb..5420adb4db 100644 --- a/shell/common/v8_value_serializer.cc +++ b/shell/common/v8_value_serializer.cc @@ -7,6 +7,7 @@ #include #include +#include ""base/memory/raw_ptr.h"" #include ""gin/converter.h"" #include ""shell/common/api/electron_api_native_image.h"" #include ""shell/common/gin_helper/microtasks_scope.h"" @@ -110,7 +111,7 @@ class V8Serializer : public v8::ValueSerializer::Delegate { serializer_.WriteUint32(blink_version); } - v8::Isolate* isolate_; + raw_ptr isolate_; std::vector data_; v8::ValueSerializer serializer_; }; @@ -217,7 +218,7 @@ class V8Deserializer : public v8::ValueDeserializer::Delegate { return new api::NativeImage(isolate, image); } - v8::Isolate* isolate_; + raw_ptr isolate_; v8::ValueDeserializer deserializer_; }; diff --git a/shell/renderer/api/electron_api_spell_check_client.h b/shell/renderer/api/electron_api_spell_check_client.h index 7522157be5..404400b76d 100644 --- a/shell/renderer/api/electron_api_spell_check_client.h +++ b/shell/renderer/api/electron_api_spell_check_client.h @@ -11,6 +11,7 @@ #include #include ""base/functional/callback.h"" +#include ""base/memory/raw_ptr.h"" #include ""base/memory/weak_ptr.h"" #include ""components/spellcheck/renderer/spellcheck_worditerator.h"" #include ""third_party/blink/public/platform/web_spell_check_panel_host_client.h"" @@ -101,7 +102,7 @@ class SpellCheckClient : public blink::WebSpellCheckPanelHostClient, // requests so we do not have to use vectors.) std::unique_ptr pending_request_param_; - v8::Isolate* isolate_; + raw_ptr isolate_; v8::Global context_; v8::Global provider_; v8::Global spell_check_;",chore 95cd84f14032c7640ef69e221d007562f115cfef,Keeley Hammond,2023-05-10 20:52:59,build: fix octokit resolution with patch-package (#38250),"diff --git a/package.json b/package.json index 8ce7c9ce55..e746bbe7b2 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ ""lint-staged"": ""^10.2.11"", ""minimist"": ""^1.2.6"", ""null-loader"": ""^4.0.0"", + ""patch-package"": ""^7.0.0"", ""pre-flight"": ""^1.1.0"", ""process"": ""^0.11.10"", ""remark-cli"": ""^10.0.0"", @@ -101,9 +102,9 @@ ""gn-format"": ""python3 script/run-gn-format.py"", ""precommit"": ""lint-staged"", ""preinstall"": ""node -e 'process.exit(0)'"", - ""prepack"": ""check-for-leaks"", - ""prepare"": ""husky install"", ""pretest"": ""npm run create-typescript-definitions"", + ""prepack"": ""check-for-leaks"", + ""prepare"": ""husky install && patch-package --patch-dir patches_npm"", ""repl"": ""node ./script/start.js --interactive"", ""start"": ""node ./script/start.js"", ""test"": ""node ./script/spec-runner.js"", @@ -150,6 +151,7 @@ ] }, ""resolutions"": { - ""nan"": ""nodejs/nan#16fa32231e2ccd89d2804b3f765319128b20c4ac"" + ""nan"": ""nodejs/nan#16fa32231e2ccd89d2804b3f765319128b20c4ac"", + ""@octokit/request"": ""6.2.3"" } } diff --git a/patches_npm/@octokit+request+6.2.3.patch b/patches_npm/@octokit+request+6.2.3.patch new file mode 100644 index 0000000000..1ba1f84b9b --- /dev/null +++ b/patches_npm/@octokit+request+6.2.3.patch @@ -0,0 +1,26 @@ +diff --git a/node_modules/@octokit/request/dist-node/index.js b/node_modules/@octokit/request/dist-node/index.js +index 11ac3f4..c4d9331 100644 +--- a/node_modules/@octokit/request/dist-node/index.js ++++ b/node_modules/@octokit/request/dist-node/index.js +@@ -29,7 +29,8 @@ function fetchWrapper(requestOptions) { + method: requestOptions.method, + body: requestOptions.body, + headers: requestOptions.headers, +- redirect: requestOptions.redirect ++ redirect: requestOptions.redirect, ++ ...(requestOptions.body && { duplex: ""half"" }), + }, + // `requestOptions.request.agent` type is incompatible + // see https://github.com/octokit/types.ts/pull/264 +diff --git a/node_modules/@octokit/request/dist-src/fetch-wrapper.js b/node_modules/@octokit/request/dist-src/fetch-wrapper.js +index 223307a..15114d5 100644 +--- a/node_modules/@octokit/request/dist-src/fetch-wrapper.js ++++ b/node_modules/@octokit/request/dist-src/fetch-wrapper.js +@@ -21,6 +21,7 @@ export default function fetchWrapper(requestOptions) { + body: requestOptions.body, + headers: requestOptions.headers, + redirect: requestOptions.redirect, ++ ...(requestOptions.body && { duplex: ""half"" }), + }, + // `requestOptions.request.agent` type is incompatible + // see https://github.com/octokit/types.ts/pull/264 diff --git a/yarn.lock b/yarn.lock index da5c5905ff..837cab7059 100644 --- a/yarn.lock +++ b/yarn.lock @@ -413,15 +413,6 @@ before-after-hook ""^2.2.0"" universal-user-agent ""^6.0.0"" -""@octokit/endpoint@^6.0.1"": - version ""6.0.5"" - resolved ""https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-6.0.5.tgz#43a6adee813c5ffd2f719e20cfd14a1fee7c193a"" - integrity sha512-70K5u6zd45ItOny6aHQAsea8HHQjlQq85yqOMe+Aj8dkhN2qSJ9T+Q3YjUjEYfPRBcuUWNgMn62DQnP/4LAIiQ== - dependencies: - ""@octokit/types"" ""^5.0.0"" - is-plain-object ""^4.0.0"" - universal-user-agent ""^6.0.0"" - ""@octokit/endpoint@^7.0.0"": version ""7.0.3"" resolved ""https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-7.0.3.tgz#0b96035673a9e3bedf8bab8f7335de424a2147ed"" @@ -549,26 +540,14 @@ deprecation ""^2.0.0"" once ""^1.4.0"" -""@octokit/request@^5.4.14"", ""@octokit/request@^5.6.0"", ""@octokit/request@^5.6.3"": - version ""5.6.3"" - resolved ""https://registry.yarnpkg.com/@octokit/request/-/request-5.6.3.tgz#19a022515a5bba965ac06c9d1334514eb50c48b0"" - integrity sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A== - dependencies: - ""@octokit/endpoint"" ""^6.0.1"" - ""@octokit/request-error"" ""^2.1.0"" - ""@octokit/types"" ""^6.16.1"" - is-plain-object ""^5.0.0"" - node-fetch ""^2.6.7"" - universal-user-agent ""^6.0.0"" - -""@octokit/request@^6.0.0"": - version ""6.2.2"" - resolved ""https://registry.yarnpkg.com/@octokit/request/-/request-6.2.2.tgz#a2ba5ac22bddd5dcb3f539b618faa05115c5a255"" - integrity sha512-6VDqgj0HMc2FUX2awIs+sM6OwLgwHvAi4KCK3mT2H2IKRt6oH9d0fej5LluF5mck1lRR/rFWN0YIDSYXYSylbw== +""@octokit/request@6.2.3"", ""@octokit/request@^5.4.14"", ""@octokit/request@^5.6.0"", ""@octokit/request@^5.6.3"", ""@octokit/request@^6.0.0"": + version ""6.2.3"" + resolved ""https://registry.yarnpkg.com/@octokit/request/-/request-6.2.3.tgz#76d5d6d44da5c8d406620a4c285d280ae310bdb4"" + integrity sha512-TNAodj5yNzrrZ/VxP+H5HiYaZep0H3GU0O7PaF+fhDrt8FPrnkei9Aal/txsN/1P7V3CPiThG0tIvpPDYUsyAA== dependencies: ""@octokit/endpoint"" ""^7.0.0"" ""@octokit/request-error"" ""^3.0.0"" - ""@octokit/types"" ""^8.0.0"" + ""@octokit/types"" ""^9.0.0"" is-plain-object ""^5.0.0"" node-fetch ""^2.6.7"" universal-user-agent ""^6.0.0"" @@ -593,14 +572,7 @@ ""@octokit/plugin-request-log"" ""^1.0.4"" ""@octokit/plugin-rest-endpoint-methods"" ""^7.0.0"" -""@octokit/types@^5.0.0"": - version ""5.2.0"" - resolved ""https://registry.yarnpkg.com/@octokit/types/-/types-5.2.0.tgz#d075dc23bf293f540739250b6879e2c1be2fc20c"" - integrity sha512-XjOk9y4m8xTLIKPe1NFxNWBdzA2/z3PFFA/bwf4EoH6oS8hM0Y46mEa4Cb+KCyj/tFDznJFahzQ0Aj3o1FYq4A== - dependencies: - ""@types/node"" "">= 8"" - -""@octokit/types@^6.0.3"", ""@octokit/types@^6.10.0"", ""@octokit/types@^6.12.2"", ""@octokit/types@^6.16.1"", ""@octokit/types@^6.39.0"", ""@octokit/types@^6.40.0"": +""@octokit/types@^6.0.3"", ""@octokit/types@^6.10.0"", ""@octokit/types@^6.12.2"", ""@octokit/types@^6.39.0"", ""@octokit/types@^6.40.0"": version ""6.41.0"" resolved ""https://registry.yarnpkg.com/@octokit/types/-/types-6.41.0.tgz#e58ef78d78596d2fb7df9c6259802464b5f84a04"" integrity sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg== @@ -940,11 +912,6 @@ resolved ""https://registry.yarnpkg.com/@types/node/-/node-12.6.1.tgz#d5544f6de0aae03eefbb63d5120f6c8be0691946"" integrity sha512-rp7La3m845mSESCgsJePNL/JQyhkOJA6G4vcwvVgkDAwHhGdq5GCumxmPjEk1MZf+8p5ZQAUE7tqgQRQTXN7uQ== -""@types/node@>= 8"": - version ""14.0.27"" - resolved ""https://registry.yarnpkg.com/@types/node/-/node-14.0.27.tgz#a151873af5a5e851b51b3b065c9e63390a9e0eb1"" - integrity sha512-kVrqXhbclHNHGu9ztnAwSncIgJv/FaxmzXJvGXNdcCpV1b8u1/Mi6z6m0vwy0LzKeXFTPLH0NzwmoJ3fNCIq0g== - ""@types/node@^11.13.7"": version ""11.13.22"" resolved ""https://registry.yarnpkg.com/@types/node/-/node-11.13.22.tgz#91ee88ebfa25072433497f6f3150f84fa8c3a91b"" @@ -1323,6 +1290,11 @@ resolved ""https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d"" integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== +""@yarnpkg/lockfile@^1.1.0"": + version ""1.1.0"" + resolved ""https://registry.yarnpkg.com/@yarnpkg/lockfile/-/lockfile-1.1.0.tgz#e77a97fbd345b76d83245edcd17d393b1b41fb31"" + integrity sha512-GpSwvyXOcOOlV70vbnzjj4fW5xW/FdUF6nQEt1ENy7m4ZCczi1+/buVUPAqmGfqznsORNFzUMjctTIp8a9tuCQ== + accepts@~1.3.8: version ""1.3.8"" resolved ""https://registry.yarnpkg.com/accepts/-/accepts-1.3.8.tgz#0bf0be125b67014adcb0b0921e62db7bffe16b2e"" @@ -1732,6 +1704,14 @@ chalk@^4.0.0, chalk@^4.1.0: ansi-styles ""^4.1.0"" supports-color ""^7.1.0"" +chalk@^4.1.2: + version ""4.1.2"" + resolved ""https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"" + integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA== + dependencies: + ansi-styles ""^4.1.0"" + supports-color ""^7.1.0"" + character-entities-legacy@^2.0.0: version ""2.0.0"" resolved ""https://registry.yarnpkg.com/character-entities-legacy/-/character-entities-legacy-2.0.0.tgz#57f4d00974c696e8f74e9f493e7fcb75b44d7ee7"" @@ -1799,6 +1779,11 @@ chromium-pickle-js@^0.2.0: resolved ""https://registry.yarnpkg.com/chromium-pickle-js/-/chromium-pickle-js-0.2.0.tgz#04a106672c18b085ab774d983dfa3ea138f22205"" integrity sha1-BKEGZywYsIWrd02YPfo+oTjyIgU= +ci-info@^3.7.0: + version ""3.8.0"" + resolved ""https://registry.yarnpkg.com/ci-info/-/ci-info-3.8.0.tgz#81408265a5380c929f0bc665d62256628ce9ef91"" + integrity sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw== + clean-stack@^2.0.0: version ""2.2.0"" resolved ""https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"" @@ -2958,6 +2943,13 @@ find-up@^4.0.0: locate-path ""^5.0.0"" path-exists ""^4.0.0"" +find-yarn-workspace-root@^2.0.0: + version ""2.0.0"" + resolved ""https://registry.yarnpkg.com/find-yarn-workspace-root/-/find-yarn-workspace-root-2.0.0.tgz#f47fb8d239c900eb78179aa81b66673eac88f7bd"" + integrity sha512-1IMnbjt4KzsQfnhnzNd8wUEgXZ44IzZaZmnLYx7D5FZlaHt2gW20Cri8Q+E/t5tIj4+epTBub+2Zxu/vNILzqQ== + dependencies: + micromatch ""^4.0.2"" + flat-cache@^2.0.1: version ""2.0.1"" resolved ""https://registry.yarnpkg.com/flat-cache/-/flat-cache-2.0.1.tgz#5d296d6f04bda44a4630a301413bdbc2ec085ec0"" @@ -3041,6 +3033,16 @@ fs-extra@^8.1.0: jsonfile ""^4.0.0"" universalify ""^0.1.0"" +fs-extra@^9.0.0: + version ""9.1.0"" + resolved ""https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d"" + integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ== + dependencies: + at-least-node ""^1.0.0"" + graceful-fs ""^4.2.0"" + jsonfile ""^6.0.1"" + universalify ""^2.0.0"" + fs-extra@^9.0.1: version ""9.0.1"" resolved ""https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.0.1.tgz#910da0062437ba4c39fedd863f1675ccfefcb9fc"" @@ -3222,6 +3224,11 @@ got@^11.8.5: p-cancelable ""^2.0.0"" responselike ""^2.0.0"" +graceful-fs@^4.1.11: + version ""4.2.11"" + resolved ""https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"" + integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ== + graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9, graceful-fs@^4.2.0, graceful-fs@^4.2.4, graceful-fs@^4.2.9: version ""4.2.10"" resolved ""https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c"" @@ -3497,6 +3504,11 @@ is-decimal@^2.0.0: resolved ""https://registry.yarnpkg.com/is-decimal/-/is-decimal-2.0.0.tgz#db1140337809fd043a056ae40a9bd1cdc563034c"" integrity sha512-QfrfjQV0LjoWQ1K1XSoEZkTAzSa14RKVMa5zg3SdAfzEmQzRM4+tbSFWb78creCeA9rNBzaZal92opi1TwPWZw== +is-docker@^2.0.0: + version ""2.2.1"" + resolved ""https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa"" + integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== + is-empty@^1.0.0: version ""1.2.0"" resolved ""https://registry.yarnpkg.com/is-empty/-/is-empty-1.2.0.tgz#de9bb5b278738a05a0b09a57e1fb4d4a341a9f6b"" @@ -3568,11 +3580,6 @@ is-plain-object@^2.0.4: dependencies: isobject ""^3.0.1"" -is-plain-object@^4.0.0: - version ""4.1.1"" - resolved ""https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-4.1.1.tgz#1a14d6452cbd50790edc7fdaa0aed5a40a35ebb5"" - integrity sha512-5Aw8LLVsDlZsETVMhoMXzqsXwQqr/0vlnBYzIXJbYo2F4yYlhLHs+Ez7Bod7IIQKWkJbJfxrWD7pA1Dw1TKrwA== - is-plain-object@^5.0.0: version ""5.0.0"" resolved ""https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-5.0.0.tgz#4427f50ab3429e9025ea7d52e9043a9ef4159344"" @@ -3614,6 +3621,13 @@ is-symbol@^1.0.2: dependencies: has-symbols ""^1.0.0"" +is-wsl@^2.1.1: + version ""2.2.0"" + resolved ""https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271"" + integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== + dependencies: + is-docker ""^2.0.0"" + isarray@^1.0.0, isarray@~1.0.0: version ""1.0.0"" resolved ""https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"" @@ -3769,6 +3783,13 @@ kind-of@^6.0.2: resolved ""https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"" integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== +klaw-sync@^6.0.0: + version ""6.0.0"" + resolved ""https://registry.yarnpkg.com/klaw-sync/-/klaw-sync-6.0.0.tgz#1fd2cfd56ebb6250181114f0a581167099c2b28c"" + integrity sha512-nIeuVSzdCCs6TDPTqI8w1Yre34sSq7AkZ4B3sfOBbI2CgVSB4Du4aLQijFU2+lhAFCwt9+42Hel6lQNIv6AntQ== + dependencies: + graceful-fs ""^4.1.11"" + klaw@^3.0.0: version ""3.0.0"" resolved ""https://registry.yarnpkg.com/klaw/-/klaw-3.0.0.tgz#b11bec9cf2492f06756d6e809ab73a2910259146"" @@ -4682,6 +4703,14 @@ onetime@^5.1.0: dependencies: mimic-fn ""^2.1.0"" +open@^7.4.2: + version ""7.4.2"" + resolved ""https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321"" + integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q== + dependencies: + is-docker ""^2.0.0"" + is-wsl ""^2.1.1"" + optionator@^0.8.3: version ""0.8.3"" resolved ""https://registry.yarnpkg.com/optionator/-/optionator-0.8.3.tgz#84fa1d036fe9d3c7e21d99884b601167ec8fb495"" @@ -4863,6 +4892,26 @@ parseurl@~1.3.3: resolved ""https://registry.yarnpkg.com/parseurl/-/parseurl-1.3.3.tgz#9da19e7bee8d12dff0513ed5b76957793bc2e8d4"" integrity sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ== +patch-package@^7.0.0: + version ""7.0.0"" + resolved ""https://registry.yarnpkg.com/patch-package/-/patch-package-7.0.0.tgz#5c646b6b4b4bf37e5184a6950777b21dea6bb66e"" + integrity sha512-eYunHbnnB2ghjTNc5iL1Uo7TsGMuXk0vibX3RFcE/CdVdXzmdbMsG/4K4IgoSuIkLTI5oHrMQk4+NkFqSed0BQ== + dependencies: + ""@yarnpkg/lockfile"" ""^1.1.0"" + chalk ""^4.1.2"" + ci-info ""^3.7.0"" + cross-spawn ""^7.0.3"" + find-yarn-workspace-root ""^2.0.0"" + fs-extra ""^9.0.0"" + klaw-sync ""^6.0.0"" + minimist ""^1.2.6"" + open ""^7.4.2"" + rimraf ""^2.6.3"" + semver ""^5.6.0"" + slash ""^2.0.0"" + tmp ""^0.0.33"" + yaml ""^2.2.2"" + path-exists@^3.0.0: version ""3.0.0"" resolved ""https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"" @@ -5835,6 +5884,13 @@ rimraf@2.6.3: dependencies: glob ""^7.1.3"" +rimraf@^2.6.3: + version ""2.7.1"" + resolved ""https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec"" + integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== + dependencies: + glob ""^7.1.3"" + rimraf@~2.2.6: version ""2.2.8"" resolved ""https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582"" @@ -6088,6 +6144,11 @@ simple-git@^3.5.0: ""@kwsites/promise-deferred"" ""^1.1.1"" debug ""^4.3.4"" +slash@^2.0.0: + version ""2.0.0"" + resolved ""https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"" + integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A== + slash@^3.0.0: version ""3.0.0"" resolved ""https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"" @@ -7200,6 +7261,11 @@ yaml@^1.7.2: resolved ""https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"" integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg== +yaml@^2.2.2: + version ""2.2.2"" + resolved ""https://registry.yarnpkg.com/yaml/-/yaml-2.2.2.tgz#ec551ef37326e6d42872dad1970300f8eb83a073"" + integrity sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA== + yauzl@^2.10.0: version ""2.10.0"" resolved ""https://registry.yarnpkg.com/yauzl/-/yauzl-2.10.0.tgz#c7eb17c93e112cb1086fa6d8e51fb0667b79a5f9""",build 6be1151ffc4a83cc241b78e0c3a04211dfb79943,Sam Maddock,2025-02-17 17:25:19,"fix: win.closeFilePreview recreates panel when called twice (#45319) * fix: close quick look during tests on macOS * use longer delay :shrug: * fix: sharedPreviewPanel being recreated on close * test: ensure preview panel gets closed","diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index 6889eb6f18..521a692f0a 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -1596,8 +1596,11 @@ void NativeWindowMac::PreviewFile(const std::string& path, } void NativeWindowMac::CloseFilePreview() { - if ([QLPreviewPanel sharedPreviewPanelExists]) { + // Need to be careful about checking [QLPreviewPanel sharedPreviewPanel] as + // simply accessing it will cause it to reinitialize and reappear. + if ([QLPreviewPanel sharedPreviewPanelExists] && preview_item_) { [[QLPreviewPanel sharedPreviewPanel] close]; + preview_item_ = nil; } } diff --git a/spec/api-browser-window-spec.ts b/spec/api-browser-window-spec.ts index 94f627ee23..5258abd4b7 100755 --- a/spec/api-browser-window-spec.ts +++ b/spec/api-browser-window-spec.ts @@ -6256,6 +6256,7 @@ describe('BrowserWindow module', () => { w.previewFile(__filename); await setTimeout(500); expect(showCalled).to.equal(false, 'should not have called show twice'); + w.closeFilePreview(); }); }); ",fix 32b44aa5c8a7e3dd26951aa4201d6faacb5d2851,Shelley Vohr,2024-03-26 14:32:06,"fix: crash on extension unload when script validation finishes (#41686) https://chromium-review.googlesource.com/c/chromium/src/+/5225796","diff --git a/shell/browser/extensions/api/scripting/scripting_api.cc b/shell/browser/extensions/api/scripting/scripting_api.cc index 069d70d980..cea869d8b4 100644 --- a/shell/browser/extensions/api/scripting/scripting_api.cc +++ b/shell/browser/extensions/api/scripting/scripting_api.cc @@ -22,6 +22,7 @@ #include ""extensions/browser/api/scripting/scripting_utils.h"" #include ""extensions/browser/extension_api_frame_id_map.h"" #include ""extensions/browser/extension_file_task_runner.h"" +#include ""extensions/browser/extension_registry.h"" #include ""extensions/browser/extension_system.h"" #include ""extensions/browser/extension_user_script_loader.h"" #include ""extensions/browser/extension_util.h"" @@ -1061,6 +1062,17 @@ void ScriptingRegisterContentScriptsFunction::OnContentScriptFilesValidated( return; } + // We cannot proceed if the extension is uninstalled or unloaded in the middle + // of validating its script files. + ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context()); + if (!extension() || + !registry->enabled_extensions().Contains(extension_id())) { + // Note: a Respond() is not needed if the system is shutting down or if the + // extension is no longer enabled. + Release(); // Matches the `AddRef()` in `Run()`. + return; + } + auto error = std::move(result.second); auto scripts = std::move(result.first); ExtensionUserScriptLoader* loader = @@ -1306,6 +1318,17 @@ void ScriptingUpdateContentScriptsFunction::OnContentScriptFilesValidated( return; } + // We cannot proceed if the extension is uninstalled or unloaded in the middle + // of validating its script files. + ExtensionRegistry* registry = ExtensionRegistry::Get(browser_context()); + if (!extension() || + !registry->enabled_extensions().Contains(extension_id())) { + // Note: a Respond() is not needed if the system is shutting down or if the + // extension is no longer enabled. + Release(); // Matches the `AddRef()` in `Run()`. + return; + } + auto error = std::move(result.second); auto scripts = std::move(result.first); ExtensionUserScriptLoader* loader =",fix 26131b23b81a661fb65d37437b9a1f63b4408fae,Robo,2024-02-23 02:08:25,"feat: add support for configuring system network context proxies (#41335) * feat: add support for configuring system network context proxies * chore: add specs * chore: fix lint * fix: address review feedback","diff --git a/docs/api/app.md b/docs/api/app.md index d9b921e6e8..cbd9e42e26 100755 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -1468,6 +1468,24 @@ details. **Note:** Enable `Secure Keyboard Entry` only when it is needed and disable it when it is no longer needed. +### `app.setProxy(config)` + +* `config` [ProxyConfig](structures/proxy-config.md) + +Returns `Promise` - Resolves when the proxy setting process is complete. + +Sets the proxy settings for networks requests made without an associated [Session](session.md). +Currently this will affect requests made with [Net](net.md) in the [utility process](../glossary.md#utility-process) +and internal requests made by the runtime (ex: geolocation queries). + +This method can only be called after app is ready. + +#### `app.resolveProxy(url)` + +* `url` URL + +Returns `Promise` - Resolves with the proxy information for `url` that will be used when attempting to make requests using [Net](net.md) in the [utility process](../glossary.md#utility-process). + ## Properties ### `app.accessibilitySupportEnabled` _macOS_ _Windows_ diff --git a/docs/api/session.md b/docs/api/session.md index 6e2f0de113..020d5a4f81 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -589,105 +589,15 @@ Writes any unwritten DOMStorage data to disk. #### `ses.setProxy(config)` -* `config` Object - * `mode` string (optional) - The proxy mode. Should be one of `direct`, - `auto_detect`, `pac_script`, `fixed_servers` or `system`. If it's - unspecified, it will be automatically determined based on other specified - options. - * `direct` - In direct mode all connections are created directly, without any proxy involved. - * `auto_detect` - In auto_detect mode the proxy configuration is determined by a PAC script that can - be downloaded at http://wpad/wpad.dat. - * `pac_script` - In pac_script mode the proxy configuration is determined by a PAC script that is - retrieved from the URL specified in the `pacScript`. This is the default mode - if `pacScript` is specified. - * `fixed_servers` - In fixed_servers mode the proxy configuration is specified in `proxyRules`. - This is the default mode if `proxyRules` is specified. - * `system` - In system mode the proxy configuration is taken from the operating system. - Note that the system mode is different from setting no proxy configuration. - In the latter case, Electron falls back to the system settings - only if no command-line options influence the proxy configuration. - * `pacScript` string (optional) - The URL associated with the PAC file. - * `proxyRules` string (optional) - Rules indicating which proxies to use. - * `proxyBypassRules` string (optional) - Rules indicating which URLs should - bypass the proxy settings. +* `config` [ProxyConfig](structures/proxy-config.md) Returns `Promise` - Resolves when the proxy setting process is complete. Sets the proxy settings. -When `mode` is unspecified, `pacScript` and `proxyRules` are provided together, the `proxyRules` -option is ignored and `pacScript` configuration is applied. - You may need `ses.closeAllConnections` to close currently in flight connections to prevent pooled sockets using previous proxy from being reused by future requests. -The `proxyRules` has to follow the rules below: - -```sh -proxyRules = schemeProxies["";""] -schemeProxies = [""=""] -urlScheme = ""http"" | ""https"" | ""ftp"" | ""socks"" -proxyURIList = ["",""] -proxyURL = [""://""]["":""] -``` - -For example: - -* `http=foopy:80;ftp=foopy2` - Use HTTP proxy `foopy:80` for `http://` URLs, and - HTTP proxy `foopy2:80` for `ftp://` URLs. -* `foopy:80` - Use HTTP proxy `foopy:80` for all URLs. -* `foopy:80,bar,direct://` - Use HTTP proxy `foopy:80` for all URLs, failing - over to `bar` if `foopy:80` is unavailable, and after that using no proxy. -* `socks4://foopy` - Use SOCKS v4 proxy `foopy:1080` for all URLs. -* `http=foopy,socks5://bar.com` - Use HTTP proxy `foopy` for http URLs, and fail - over to the SOCKS5 proxy `bar.com` if `foopy` is unavailable. -* `http=foopy,direct://` - Use HTTP proxy `foopy` for http URLs, and use no - proxy if `foopy` is unavailable. -* `http=foopy;socks=foopy2` - Use HTTP proxy `foopy` for http URLs, and use - `socks4://foopy2` for all other URLs. - -The `proxyBypassRules` is a comma separated list of rules described below: - -* `[ URL_SCHEME ""://"" ] HOSTNAME_PATTERN [ "":"" ]` - - Match all hostnames that match the pattern HOSTNAME_PATTERN. - - Examples: - ""foobar.com"", ""\*foobar.com"", ""\*.foobar.com"", ""\*foobar.com:99"", - ""https://x.\*.y.com:99"" - -* `""."" HOSTNAME_SUFFIX_PATTERN [ "":"" PORT ]` - - Match a particular domain suffix. - - Examples: - "".google.com"", "".com"", ""http://.google.com"" - -* `[ SCHEME ""://"" ] IP_LITERAL [ "":"" PORT ]` - - Match URLs which are IP address literals. - - Examples: - ""127.0.1"", ""\[0:0::1]"", ""\[::1]"", ""http://\[::1]:99"" - -* `IP_LITERAL ""/"" PREFIX_LENGTH_IN_BITS` - - Match any URL that is to an IP literal that falls between the - given range. IP range is specified using CIDR notation. - - Examples: - ""192.168.1.1/16"", ""fefe:13::abc/33"". - -* `` - - Match local addresses. The meaning of `` is whether the - host matches one of: ""127.0.0.1"", ""::1"", ""localhost"". - #### `ses.resolveHost(host, [options])` * `host` string - Hostname to resolve. diff --git a/docs/api/structures/proxy-config.md b/docs/api/structures/proxy-config.md new file mode 100644 index 0000000000..eb68d37e65 --- /dev/null +++ b/docs/api/structures/proxy-config.md @@ -0,0 +1,86 @@ +# ProxyConfig Object + +* `mode` string (optional) - The proxy mode. Should be one of `direct`, +`auto_detect`, `pac_script`, `fixed_servers` or `system`. +Defaults to `pac_script` proxy mode if `pacScript` option is specified +otherwise defaults to `fixed_servers`. + * `direct` - In direct mode all connections are created directly, without any proxy involved. + * `auto_detect` - In auto_detect mode the proxy configuration is determined by a PAC script that can + be downloaded at http://wpad/wpad.dat. + * `pac_script` - In pac_script mode the proxy configuration is determined by a PAC script that is + retrieved from the URL specified in the `pacScript`. This is the default mode if `pacScript` is specified. + * `fixed_servers` - In fixed_servers mode the proxy configuration is specified in `proxyRules`. + This is the default mode if `proxyRules` is specified. + * `system` - In system mode the proxy configuration is taken from the operating system. + Note that the system mode is different from setting no proxy configuration. + In the latter case, Electron falls back to the system settings only if no + command-line options influence the proxy configuration. +* `pacScript` string (optional) - The URL associated with the PAC file. +* `proxyRules` string (optional) - Rules indicating which proxies to use. +* `proxyBypassRules` string (optional) - Rules indicating which URLs should +bypass the proxy settings. + +When `mode` is unspecified, `pacScript` and `proxyRules` are provided together, the `proxyRules` +option is ignored and `pacScript` configuration is applied. + +The `proxyRules` has to follow the rules below: + +```sh +proxyRules = schemeProxies["";""] +schemeProxies = [""=""] +urlScheme = ""http"" | ""https"" | ""ftp"" | ""socks"" +proxyURIList = ["",""] +proxyURL = [""://""]["":""] +``` + +For example: + +* `http=foopy:80;ftp=foopy2` - Use HTTP proxy `foopy:80` for `http://` URLs, and + HTTP proxy `foopy2:80` for `ftp://` URLs. +* `foopy:80` - Use HTTP proxy `foopy:80` for all URLs. +* `foopy:80,bar,direct://` - Use HTTP proxy `foopy:80` for all URLs, failing + over to `bar` if `foopy:80` is unavailable, and after that using no proxy. +* `socks4://foopy` - Use SOCKS v4 proxy `foopy:1080` for all URLs. +* `http=foopy,socks5://bar.com` - Use HTTP proxy `foopy` for http URLs, and fail + over to the SOCKS5 proxy `bar.com` if `foopy` is unavailable. +* `http=foopy,direct://` - Use HTTP proxy `foopy` for http URLs, and use no + proxy if `foopy` is unavailable. +* `http=foopy;socks=foopy2` - Use HTTP proxy `foopy` for http URLs, and use + `socks4://foopy2` for all other URLs. + +The `proxyBypassRules` is a comma separated list of rules described below: + +* `[ URL_SCHEME ""://"" ] HOSTNAME_PATTERN [ "":"" ]` + + Match all hostnames that match the pattern HOSTNAME_PATTERN. + + Examples: + ""foobar.com"", ""\*foobar.com"", ""\*.foobar.com"", ""\*foobar.com:99"", + ""https://x.\*.y.com:99"" + +* `""."" HOSTNAME_SUFFIX_PATTERN [ "":"" PORT ]` + + Match a particular domain suffix. + + Examples: + "".google.com"", "".com"", ""http://.google.com"" + +* `[ SCHEME ""://"" ] IP_LITERAL [ "":"" PORT ]` + + Match URLs which are IP address literals. + + Examples: + ""127.0.1"", ""\[0:0::1]"", ""\[::1]"", ""http://\[::1]:99"" + +* `IP_LITERAL ""/"" PREFIX_LENGTH_IN_BITS` + + Match any URL that is to an IP literal that falls between the + given range. IP range is specified using CIDR notation. + + Examples: + ""192.168.1.1/16"", ""fefe:13::abc/33"". + +* `` + + Match local addresses. The meaning of `` is whether the + host matches one of: ""127.0.0.1"", ""::1"", ""localhost"". diff --git a/filenames.auto.gni b/filenames.auto.gni index 43bff50aca..6c02bcd4de 100644 --- a/filenames.auto.gni +++ b/filenames.auto.gni @@ -118,6 +118,7 @@ auto_filenames = { ""docs/api/structures/protocol-request.md"", ""docs/api/structures/protocol-response-upload-data.md"", ""docs/api/structures/protocol-response.md"", + ""docs/api/structures/proxy-config.md"", ""docs/api/structures/rectangle.md"", ""docs/api/structures/referrer.md"", ""docs/api/structures/render-process-gone-details.md"", diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index 734c4959e6..4b971e156e 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -26,6 +26,9 @@ #include ""chrome/browser/icon_manager.h"" #include ""chrome/common/chrome_features.h"" #include ""chrome/common/chrome_paths.h"" +#include ""components/proxy_config/proxy_config_dictionary.h"" +#include ""components/proxy_config/proxy_config_pref_names.h"" +#include ""components/proxy_config/proxy_prefs.h"" #include ""content/browser/gpu/compositor_util.h"" // nogncheck #include ""content/browser/gpu/gpu_data_manager_impl.h"" // nogncheck #include ""content/public/browser/browser_accessibility_state.h"" @@ -1472,6 +1475,98 @@ void App::EnableSandbox(gin_helper::ErrorThrower thrower) { command_line->AppendSwitch(switches::kEnableSandbox); } +v8::Local App::SetProxy(gin::Arguments* args) { + v8::Isolate* isolate = args->isolate(); + gin_helper::Promise promise(isolate); + v8::Local handle = promise.GetHandle(); + + gin_helper::Dictionary options; + args->GetNext(&options); + + if (!Browser::Get()->is_ready()) { + promise.RejectWithErrorMessage( + ""app.setProxy() can only be called after app is ready.""); + return handle; + } + + if (!g_browser_process->local_state()) { + promise.RejectWithErrorMessage( + ""app.setProxy() failed due to internal error.""); + return handle; + } + + std::string mode, proxy_rules, bypass_list, pac_url; + + options.Get(""pacScript"", &pac_url); + options.Get(""proxyRules"", &proxy_rules); + options.Get(""proxyBypassRules"", &bypass_list); + + ProxyPrefs::ProxyMode proxy_mode = ProxyPrefs::MODE_FIXED_SERVERS; + if (!options.Get(""mode"", &mode)) { + // pacScript takes precedence over proxyRules. + if (!pac_url.empty()) { + proxy_mode = ProxyPrefs::MODE_PAC_SCRIPT; + } + } else if (!ProxyPrefs::StringToProxyMode(mode, &proxy_mode)) { + promise.RejectWithErrorMessage( + ""Invalid mode, must be one of direct, auto_detect, pac_script, "" + ""fixed_servers or system""); + return handle; + } + + base::Value::Dict proxy_config; + switch (proxy_mode) { + case ProxyPrefs::MODE_DIRECT: + proxy_config = ProxyConfigDictionary::CreateDirect(); + break; + case ProxyPrefs::MODE_SYSTEM: + proxy_config = ProxyConfigDictionary::CreateSystem(); + break; + case ProxyPrefs::MODE_AUTO_DETECT: + proxy_config = ProxyConfigDictionary::CreateAutoDetect(); + break; + case ProxyPrefs::MODE_PAC_SCRIPT: + proxy_config = ProxyConfigDictionary::CreatePacScript(pac_url, true); + break; + case ProxyPrefs::MODE_FIXED_SERVERS: + proxy_config = + ProxyConfigDictionary::CreateFixedServers(proxy_rules, bypass_list); + break; + default: + NOTIMPLEMENTED(); + } + + static_cast(g_browser_process) + ->in_memory_pref_store() + ->SetValue(proxy_config::prefs::kProxy, + base::Value{std::move(proxy_config)}, + WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS); + + g_browser_process->system_network_context_manager() + ->GetContext() + ->ForceReloadProxyConfig(base::BindOnce( + gin_helper::Promise::ResolvePromise, std::move(promise))); + + return handle; +} + +v8::Local App::ResolveProxy(gin::Arguments* args) { + v8::Isolate* isolate = args->isolate(); + gin_helper::Promise promise(isolate); + v8::Local handle = promise.GetHandle(); + + GURL url; + args->GetNext(&url); + + static_cast(g_browser_process) + ->GetResolveProxyHelper() + ->ResolveProxy( + url, base::BindOnce(gin_helper::Promise::ResolvePromise, + std::move(promise))); + + return handle; +} + void App::SetUserAgentFallback(const std::string& user_agent) { ElectronBrowserClient::Get()->SetUserAgent(user_agent); } @@ -1776,7 +1871,9 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) { .SetProperty(""userAgentFallback"", &App::GetUserAgentFallback, &App::SetUserAgentFallback) .SetMethod(""configureHostResolver"", &ConfigureHostResolver) - .SetMethod(""enableSandbox"", &App::EnableSandbox); + .SetMethod(""enableSandbox"", &App::EnableSandbox) + .SetMethod(""setProxy"", &App::SetProxy) + .SetMethod(""resolveProxy"", &App::ResolveProxy); } const char* App::GetTypeName() { diff --git a/shell/browser/api/electron_api_app.h b/shell/browser/api/electron_api_app.h index c2f5eae50b..846b1a11e6 100644 --- a/shell/browser/api/electron_api_app.h +++ b/shell/browser/api/electron_api_app.h @@ -222,6 +222,8 @@ class App : public ElectronBrowserClient::Delegate, void EnableSandbox(gin_helper::ErrorThrower thrower); void SetUserAgentFallback(const std::string& user_agent); std::string GetUserAgentFallback(); + v8::Local SetProxy(gin::Arguments* args); + v8::Local ResolveProxy(gin::Arguments* args); #if BUILDFLAG(IS_MAC) void SetActivationPolicy(gin_helper::ErrorThrower thrower, diff --git a/shell/browser/browser_process_impl.cc b/shell/browser/browser_process_impl.cc index f33455d992..b80dd44cc8 100644 --- a/shell/browser/browser_process_impl.cc +++ b/shell/browser/browser_process_impl.cc @@ -37,6 +37,7 @@ #include ""net/proxy_resolution/proxy_config_with_annotation.h"" #include ""services/device/public/cpp/geolocation/geolocation_manager.h"" #include ""services/network/public/cpp/network_switches.h"" +#include ""shell/browser/net/resolve_proxy_helper.h"" #include ""shell/common/electron_paths.h"" #include ""shell/common/thread_restrictions.h"" @@ -100,9 +101,9 @@ void BrowserProcessImpl::PostEarlyInitialization() { OSCrypt::RegisterLocalPrefs(pref_registry.get()); #endif - auto pref_store = base::MakeRefCounted(); - ApplyProxyModeFromCommandLine(pref_store.get()); - prefs_factory.set_command_line_prefs(std::move(pref_store)); + in_memory_pref_store_ = base::MakeRefCounted(); + ApplyProxyModeFromCommandLine(in_memory_pref_store()); + prefs_factory.set_command_line_prefs(in_memory_pref_store()); // Only use a persistent prefs store when cookie encryption is enabled as that // is the only key that needs it @@ -316,6 +317,14 @@ const std::string& BrowserProcessImpl::GetSystemLocale() const { return system_locale_; } +electron::ResolveProxyHelper* BrowserProcessImpl::GetResolveProxyHelper() { + if (!resolve_proxy_helper_) { + resolve_proxy_helper_ = base::MakeRefCounted( + system_network_context_manager()->GetContext()); + } + return resolve_proxy_helper_.get(); +} + #if BUILDFLAG(IS_LINUX) void BrowserProcessImpl::SetLinuxStorageBackend( os_crypt::SelectedLinuxBackend selected_backend) { diff --git a/shell/browser/browser_process_impl.h b/shell/browser/browser_process_impl.h index fd34bb8f96..e6cbb963dc 100644 --- a/shell/browser/browser_process_impl.h +++ b/shell/browser/browser_process_impl.h @@ -31,6 +31,10 @@ namespace printing { class PrintJobManager; } +namespace electron { +class ResolveProxyHelper; +} + // Empty definition for std::unique_ptr, rather than a forward declaration class BackgroundModeManager {}; @@ -53,9 +57,9 @@ class BrowserProcessImpl : public BrowserProcess { void PreMainMessageLoopRun(); void PostDestroyThreads() {} void PostMainMessageLoopRun(); - void SetSystemLocale(const std::string& locale); const std::string& GetSystemLocale() const; + electron::ResolveProxyHelper* GetResolveProxyHelper(); #if BUILDFLAG(IS_LINUX) void SetLinuxStorageBackend(os_crypt::SelectedLinuxBackend selected_backend); @@ -123,6 +127,10 @@ class BrowserProcessImpl : public BrowserProcess { printing::PrintJobManager* print_job_manager() override; StartupData* startup_data() override; + ValueMapPrefStore* in_memory_pref_store() const { + return in_memory_pref_store_.get(); + } + private: void CreateNetworkQualityObserver(); void CreateOSCryptAsync(); @@ -139,6 +147,8 @@ class BrowserProcessImpl : public BrowserProcess { #endif embedder_support::OriginTrialsSettingsStorage origin_trials_settings_storage_; + scoped_refptr in_memory_pref_store_; + scoped_refptr resolve_proxy_helper_; std::unique_ptr network_quality_tracker_; std::unique_ptr< network::NetworkQualityTracker::RTTAndThroughputEstimatesObserver> diff --git a/shell/browser/electron_browser_context.cc b/shell/browser/electron_browser_context.cc index 5b1b0fe454..4045070de1 100644 --- a/shell/browser/electron_browser_context.cc +++ b/shell/browser/electron_browser_context.cc @@ -535,7 +535,8 @@ ElectronBrowserContext::GetReduceAcceptLanguageControllerDelegate() { ResolveProxyHelper* ElectronBrowserContext::GetResolveProxyHelper() { if (!resolve_proxy_helper_) { - resolve_proxy_helper_ = base::MakeRefCounted(this); + resolve_proxy_helper_ = base::MakeRefCounted( + GetDefaultStoragePartition()->GetNetworkContext()); } return resolve_proxy_helper_.get(); } diff --git a/shell/browser/net/resolve_proxy_helper.cc b/shell/browser/net/resolve_proxy_helper.cc index 106e863169..3f54212b54 100644 --- a/shell/browser/net/resolve_proxy_helper.cc +++ b/shell/browser/net/resolve_proxy_helper.cc @@ -8,19 +8,17 @@ #include ""base/functional/bind.h"" #include ""content/public/browser/browser_thread.h"" -#include ""content/public/browser/storage_partition.h"" #include ""mojo/public/cpp/bindings/pending_remote.h"" #include ""net/base/network_anonymization_key.h"" #include ""net/proxy_resolution/proxy_info.h"" -#include ""services/network/public/mojom/network_context.mojom.h"" -#include ""shell/browser/electron_browser_context.h"" using content::BrowserThread; namespace electron { -ResolveProxyHelper::ResolveProxyHelper(ElectronBrowserContext* browser_context) - : browser_context_(browser_context) {} +ResolveProxyHelper::ResolveProxyHelper( + network::mojom::NetworkContext* network_context) + : network_context_(network_context) {} ResolveProxyHelper::~ResolveProxyHelper() { DCHECK_CURRENTLY_ON(BrowserThread::UI); @@ -54,11 +52,9 @@ void ResolveProxyHelper::StartPendingRequest() { receiver_.set_disconnect_handler( base::BindOnce(&ResolveProxyHelper::OnProxyLookupComplete, base::Unretained(this), net::ERR_ABORTED, std::nullopt)); - browser_context_->GetDefaultStoragePartition() - ->GetNetworkContext() - ->LookUpProxyForURL(pending_requests_.front().url, - net::NetworkAnonymizationKey(), - std::move(proxy_lookup_client)); + network_context_->LookUpProxyForURL(pending_requests_.front().url, + net::NetworkAnonymizationKey(), + std::move(proxy_lookup_client)); } void ResolveProxyHelper::OnProxyLookupComplete( diff --git a/shell/browser/net/resolve_proxy_helper.h b/shell/browser/net/resolve_proxy_helper.h index 20c998be26..d12b64acc7 100644 --- a/shell/browser/net/resolve_proxy_helper.h +++ b/shell/browser/net/resolve_proxy_helper.h @@ -12,20 +12,19 @@ #include ""base/memory/raw_ptr.h"" #include ""base/memory/ref_counted.h"" #include ""mojo/public/cpp/bindings/receiver.h"" +#include ""services/network/public/mojom/network_context.mojom.h"" #include ""services/network/public/mojom/proxy_lookup_client.mojom.h"" #include ""url/gurl.h"" namespace electron { -class ElectronBrowserContext; - class ResolveProxyHelper : public base::RefCountedThreadSafe, network::mojom::ProxyLookupClient { public: using ResolveProxyCallback = base::OnceCallback; - explicit ResolveProxyHelper(ElectronBrowserContext* browser_context); + explicit ResolveProxyHelper(network::mojom::NetworkContext* network_context); void ResolveProxy(const GURL& url, ResolveProxyCallback callback); @@ -71,7 +70,7 @@ class ResolveProxyHelper mojo::Receiver receiver_{this}; // Weak Ref - raw_ptr browser_context_; + raw_ptr network_context_ = nullptr; }; } // namespace electron diff --git a/spec/api-app-spec.ts b/spec/api-app-spec.ts index bfe6d6a444..5194dced3c 100644 --- a/spec/api-app-spec.ts +++ b/spec/api-app-spec.ts @@ -6,9 +6,10 @@ import * as net from 'node:net'; import * as fs from 'fs-extra'; import * as path from 'node:path'; import { promisify } from 'node:util'; -import { app, BrowserWindow, Menu, session, net as electronNet, WebContents } from 'electron/main'; +import { app, BrowserWindow, Menu, session, net as electronNet, WebContents, utilityProcess } from 'electron/main'; import { closeWindow, closeAllWindows } from './lib/window-helpers'; import { ifdescribe, ifit, listen, waitUntil } from './lib/spec-helpers'; +import { collectStreamBody, getResponse } from './lib/net-helpers'; import { once } from 'node:events'; import split = require('split') import * as semver from 'semver'; @@ -1895,6 +1896,154 @@ describe('app module', () => { app.showAboutPanel(); }); }); + + describe('app.setProxy(options)', () => { + let server: http.Server; + + afterEach(async () => { + if (server) { + server.close(); + } + await app.setProxy({ mode: 'direct' as const }); + }); + + it('allows configuring proxy settings', async () => { + const config = { proxyRules: 'http=myproxy:80' }; + await app.setProxy(config); + const proxy = await app.resolveProxy('http://example.com/'); + expect(proxy).to.equal('PROXY myproxy:80'); + }); + + it('allows removing the implicit bypass rules for localhost', async () => { + const config = { + proxyRules: 'http=myproxy:80', + proxyBypassRules: '<-loopback>' + }; + + await app.setProxy(config); + const proxy = await app.resolveProxy('http://localhost'); + expect(proxy).to.equal('PROXY myproxy:80'); + }); + + it('allows configuring proxy settings with pacScript', async () => { + server = http.createServer((req, res) => { + const pac = ` + function FindProxyForURL(url, host) { + return ""PROXY myproxy:8132""; + } + `; + res.writeHead(200, { + 'Content-Type': 'application/x-ns-proxy-autoconfig' + }); + res.end(pac); + }); + const { url } = await listen(server); + { + const config = { pacScript: url }; + await app.setProxy(config); + const proxy = await app.resolveProxy('https://google.com'); + expect(proxy).to.equal('PROXY myproxy:8132'); + } + { + const config = { mode: 'pac_script' as any, pacScript: url }; + await app.setProxy(config); + const proxy = await app.resolveProxy('https://google.com'); + expect(proxy).to.equal('PROXY myproxy:8132'); + } + }); + + it('allows bypassing proxy settings', async () => { + const config = { + proxyRules: 'http=myproxy:80', + proxyBypassRules: '' + }; + await app.setProxy(config); + const proxy = await app.resolveProxy('http://example/'); + expect(proxy).to.equal('DIRECT'); + }); + + it('allows configuring proxy settings with mode `direct`', async () => { + const config = { mode: 'direct' as const, proxyRules: 'http=myproxy:80' }; + await app.setProxy(config); + const proxy = await app.resolveProxy('http://example.com/'); + expect(proxy).to.equal('DIRECT'); + }); + + it('allows configuring proxy settings with mode `auto_detect`', async () => { + const config = { mode: 'auto_detect' as const }; + await app.setProxy(config); + }); + + it('allows configuring proxy settings with mode `pac_script`', async () => { + const config = { mode: 'pac_script' as const }; + await app.setProxy(config); + const proxy = await app.resolveProxy('http://example.com/'); + expect(proxy).to.equal('DIRECT'); + }); + + it('allows configuring proxy settings with mode `fixed_servers`', async () => { + const config = { mode: 'fixed_servers' as const, proxyRules: 'http=myproxy:80' }; + await app.setProxy(config); + const proxy = await app.resolveProxy('http://example.com/'); + expect(proxy).to.equal('PROXY myproxy:80'); + }); + + it('allows configuring proxy settings with mode `system`', async () => { + const config = { mode: 'system' as const }; + await app.setProxy(config); + }); + + it('disallows configuring proxy settings with mode `invalid`', async () => { + const config = { mode: 'invalid' as any }; + await expect(app.setProxy(config)).to.eventually.be.rejectedWith(/Invalid mode/); + }); + + it('impacts proxy for requests made from utility process', async () => { + const utilityFixturePath = path.resolve(__dirname, 'fixtures', 'api', 'utility-process', 'api-net-spec.js'); + const fn = async () => { + const urlRequest = electronNet.request('http://example.com/'); + const response = await getResponse(urlRequest); + expect(response.statusCode).to.equal(200); + const message = await collectStreamBody(response); + expect(message).to.equal('ok from proxy\n'); + }; + server = http.createServer((req, res) => { + res.writeHead(200); + res.end('ok from proxy\n'); + }); + const { port, hostname } = await listen(server); + const config = { mode: 'fixed_servers' as const, proxyRules: `http=${hostname}:${port}` }; + await app.setProxy(config); + const proxy = await app.resolveProxy('http://example.com/'); + expect(proxy).to.equal(`PROXY ${hostname}:${port}`); + const child = utilityProcess.fork(utilityFixturePath, [], { + execArgv: ['--expose-gc'] + }); + child.postMessage({ fn: `(${fn})()` }); + const [data] = await once(child, 'message'); + expect(data.ok).to.be.true(data.message); + // Cleanup. + const [code] = await once(child, 'exit'); + expect(code).to.equal(0); + }); + + it('does not impact proxy for requests made from main process', async () => { + server = http.createServer((req, res) => { + res.writeHead(200); + res.end('ok from server\n'); + }); + const { url } = await listen(server); + const config = { mode: 'fixed_servers' as const, proxyRules: 'http=myproxy:80' }; + await app.setProxy(config); + const proxy = await app.resolveProxy('http://example.com/'); + expect(proxy).to.equal('PROXY myproxy:80'); + const urlRequest = electronNet.request(url); + const response = await getResponse(urlRequest); + expect(response.statusCode).to.equal(200); + const message = await collectStreamBody(response); + expect(message).to.equal('ok from server\n'); + }); + }); }); describe('default behavior', () => { diff --git a/spec/lib/spec-helpers.ts b/spec/lib/spec-helpers.ts index e814c5a453..9bad7f322a 100644 --- a/spec/lib/spec-helpers.ts +++ b/spec/lib/spec-helpers.ts @@ -200,5 +200,5 @@ export async function listen (server: http.Server | https.Server | http2.Http2Se await new Promise(resolve => server.listen(0, hostname, () => resolve())); const { port } = server.address() as net.AddressInfo; const protocol = (server instanceof http.Server) ? 'http' : 'https'; - return { port, url: url.format({ protocol, hostname, port }) }; + return { port, hostname, url: url.format({ protocol, hostname, port }) }; }",feat 48e14bc54e26b540d3667b940b51434a76e0205b,David Sanders,2023-08-25 11:09:12,ci: fix deprecation review automation for PRs (#39649),"diff --git a/.github/workflows/pull-request-labeled.yml b/.github/workflows/pull-request-labeled.yml index d15c75fbc1..9695d83b0f 100644 --- a/.github/workflows/pull-request-labeled.yml +++ b/.github/workflows/pull-request-labeled.yml @@ -23,7 +23,7 @@ jobs: echo ""TOKEN=$TOKEN"" >> ""$GITHUB_OUTPUT"" - name: Set status if: ${{ steps.generate-token.outputs.TOKEN }} - uses: github/update-project-action@2d475e08804f11f4022df7e21f5816531e97cb64 # v2 + uses: dsanders11/update-project-action@7ade91760df70df76770a238abee7a4869e01cf8 with: github_token: ${{ steps.generate-token.outputs.TOKEN }} organization: electron",ci 9563b5f98bf6ac5a00a0f9da6fcb5f34e89e1207,David Sanders,2023-04-06 11:03:14,test: support 'latest'/'latest@X' Electron version strings (#37840),"diff --git a/script/spec-runner.js b/script/spec-runner.js index a6f7083b7f..8edc5d44d2 100755 --- a/script/spec-runner.js +++ b/script/spec-runner.js @@ -64,10 +64,24 @@ if (args.runners !== undefined) { async function main () { if (args.electronVersion) { const versions = await ElectronVersions.create(); - if (!versions.isVersion(args.electronVersion)) { + if (args.electronVersion === 'latest') { + args.electronVersion = versions.latest.version; + } else if (args.electronVersion.startsWith('latest@')) { + const majorVersion = parseInt(args.electronVersion.slice('latest@'.length)); + const ver = versions.inMajor(majorVersion).slice(-1)[0]; + if (ver) { + args.electronVersion = ver.version; + } else { + console.log(`${fail} '${majorVersion}' is not a recognized Electron major version`); + process.exit(1); + } + } else if (!versions.isVersion(args.electronVersion)) { console.log(`${fail} '${args.electronVersion}' is not a recognized Electron version`); process.exit(1); } + + const versionString = `v${args.electronVersion}`; + console.log(`Running against Electron ${versionString.green}`); } const [lastSpecHash, lastSpecInstallHash] = loadLastSpecHash();",test e480cb7103df6702d0364cf76d1f20724efc49dc,Shelley Vohr,2023-03-14 14:17:28,"docs: clarify `open-url` not preventable (#37564) docs: clarify open-url not preventable","diff --git a/docs/api/app.md b/docs/api/app.md index e29973ad52..9bae9c860d 100755 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -127,8 +127,6 @@ Emitted when the user wants to open a URL with the application. Your application `Info.plist` file must define the URL scheme within the `CFBundleURLTypes` key, and set `NSPrincipalClass` to `AtomApplication`. -You should call `event.preventDefault()` if you want to handle this event. - As with the `open-file` event, be sure to register a listener for the `open-url` event early in your application startup to detect if the the application being is being opened to handle a URL. If you register the listener in response to a",docs 527efc01a4d989e973ed96042c890b820bb7b649,Charles Kerr,2024-10-11 14:29:00,fix: -Wunsafe-buffer-usage warnings when read()ing and write()ing integers (#44185),"diff --git a/shell/browser/electron_browser_main_parts_posix.cc b/shell/browser/electron_browser_main_parts_posix.cc index a13cd8afb9..ce0433f843 100644 --- a/shell/browser/electron_browser_main_parts_posix.cc +++ b/shell/browser/electron_browser_main_parts_posix.cc @@ -25,6 +25,18 @@ namespace electron { namespace { +// write |ref|'s raw bytes to |fd|. +template +void WriteValToFd(int fd, const T& ref) { + base::span bytes = base::byte_span_from_ref(ref); + while (!bytes.empty()) { + const ssize_t rv = HANDLE_EINTR(write(fd, bytes.data(), bytes.size())); + RAW_CHECK(rv >= 0); + const size_t n_bytes_written = rv >= 0 ? static_cast(rv) : 0U; + bytes = bytes.subspan(n_bytes_written); + } +} + // See comment in |PreEarlyInitialization()|, where sigaction is called. void SIGCHLDHandler(int signal) {} @@ -49,15 +61,7 @@ void GracefulShutdownHandler(int signal) { RAW_CHECK(g_pipe_pid == getpid()); RAW_CHECK(g_shutdown_pipe_write_fd != -1); RAW_CHECK(g_shutdown_pipe_read_fd != -1); - size_t bytes_written = 0; - do { - int rv = HANDLE_EINTR( - write(g_shutdown_pipe_write_fd, - reinterpret_cast(&signal) + bytes_written, - sizeof(signal) - bytes_written)); - RAW_CHECK(rv >= 0); - bytes_written += rv; - } while (bytes_written < sizeof(signal)); + WriteValToFd(g_shutdown_pipe_write_fd, signal); } // See comment in |PostCreateMainMessageLoop()|, where sigaction is called. @@ -130,26 +134,33 @@ NOINLINE void ExitPosted() { sleep(UINT_MAX); } -void ShutdownDetector::ThreadMain() { - base::PlatformThread::SetName(""CrShutdownDetector""); - - int signal; - size_t bytes_read = 0; - do { - const ssize_t ret = HANDLE_EINTR( - read(shutdown_fd_, reinterpret_cast(&signal) + bytes_read, - sizeof(signal) - bytes_read)); - if (ret < 0) { +// read |sizeof(T)| raw bytes from |fd| and return the result +template +[[nodiscard]] std::optional ReadValFromFd(int fd) { + auto val = T{}; + base::span bytes = base::byte_span_from_ref(val); + while (!bytes.empty()) { + const ssize_t rv = HANDLE_EINTR(read(fd, bytes.data(), bytes.size())); + if (rv < 0) { NOTREACHED_IN_MIGRATION() << ""Unexpected error: "" << strerror(errno); ShutdownFDReadError(); - break; - } else if (ret == 0) { + return {}; + } + if (rv == 0) { NOTREACHED_IN_MIGRATION() << ""Unexpected closure of shutdown pipe.""; ShutdownFDClosedError(); - break; + return {}; } - bytes_read += ret; - } while (bytes_read < sizeof(signal)); + const size_t n_bytes_read = static_cast(rv); + bytes = bytes.subspan(n_bytes_read); + } + return val; +} + +void ShutdownDetector::ThreadMain() { + base::PlatformThread::SetName(""CrShutdownDetector""); + + const int signal = ReadValFromFd(shutdown_fd_).value_or(0); VLOG(1) << ""Handling shutdown for signal "" << signal << "".""; if (!task_runner_->PostTask(FROM_HERE,",fix 7a03509b7184be000ba6f5e942c15c22a97a5dd9,David Sanders,2023-05-08 01:39:28,ci: automate release label tasks (#38181),"diff --git a/.github/workflows/branch-created.yml b/.github/workflows/branch-created.yml new file mode 100644 index 0000000000..77689f4ec3 --- /dev/null +++ b/.github/workflows/branch-created.yml @@ -0,0 +1,55 @@ +name: Branch Created + +on: + create: + +permissions: {} + +jobs: + release-branch-created: + name: Release Branch Created + if: ${{ github.event.ref_type == 'branch' && endsWith(github.event.ref, '-x-y') }} + permissions: + contents: read + pull-requests: write + repository-projects: write # Required for labels + runs-on: ubuntu-latest + steps: + - name: New Release Branch Tasks + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_REPO: electron/electron + NUM_SUPPORTED_VERSIONS: 3 + run: | + if [[ ${{ github.event.ref }} =~ ^([0-9]+)-x-y$ ]]; then + MAJOR=${BASH_REMATCH[1]} + PREVIOUS_MAJOR=$((MAJOR - 1)) + UNSUPPORTED_MAJOR=$((MAJOR - NUM_SUPPORTED_VERSIONS - 1)) + + # Create new labels + gh label create $MAJOR-x-y --color 8d9ee8 || true + gh label create target/$MAJOR-x-y --color ad244f || true + gh label create merged/$MAJOR-x-y --color 61a3c6 || true + gh label create in-flight/$MAJOR-x-y --color db69a6 || true + gh label create needs-manual-bp/$MAJOR-x-y --color 8b5dba || true + + # Change color of old labels + gh label edit $UNSUPPORTED_MAJOR-x-y --color ededed || true + gh label edit target/$UNSUPPORTED_MAJOR-x-y --color ededed || true + gh label edit merged/$UNSUPPORTED_MAJOR-x-y --color ededed || true + gh label edit in-flight/$UNSUPPORTED_MAJOR-x-y --color ededed || true + gh label edit needs-manual-bp/$UNSUPPORTED_MAJOR-x-y --color ededed || true + + # Add the new target label to any PRs which: + # * target the previous major + # * are in-flight for the previous major + # * need manual backport for the previous major + for PREVIOUS_MAJOR_LABEL in target/$PREVIOUS_MAJOR-x-y in-flight/$PREVIOUS_MAJOR-x-y needs-manual-bp/$PREVIOUS_MAJOR-x-y; do + PULL_REQUESTS=$(gh pr list --label $PREVIOUS_MAJOR_LABEL --jq .[].number --json number --limit 500) + if [[ $PULL_REQUESTS ]]; then + echo $PULL_REQUESTS | xargs -n 1 gh pr edit --add-label target/$MAJOR-x-y || true + fi + done + else + echo ""Not a release branch: ${{ github.event.ref }}"" + fi",ci 4aa1855e396fa8d57cc3d3d9367a2b21c0a69fba,Charles Kerr,2024-11-27 07:55:54,refactor: use base::Extend in AddAdditionalSchemes() (#44839),"diff --git a/shell/app/electron_content_client.cc b/shell/app/electron_content_client.cc index 136b15e848..4db1ba9f1c 100644 --- a/shell/app/electron_content_client.cc +++ b/shell/app/electron_content_client.cc @@ -10,6 +10,7 @@ #include #include ""base/command_line.h"" +#include ""base/containers/extend.h"" #include ""base/files/file_util.h"" #include ""base/strings/string_split.h"" #include ""content/public/common/content_constants.h"" @@ -98,21 +99,6 @@ bool IsWidevineAvailable( } #endif // BUILDFLAG(ENABLE_WIDEVINE) -void AppendDelimitedSwitchToVector(const std::string_view cmd_switch, - std::vector* append_me) { - auto* command_line = base::CommandLine::ForCurrentProcess(); - auto switch_value = command_line->GetSwitchValueASCII(cmd_switch); - if (!switch_value.empty()) { - constexpr std::string_view delimiter{"","", 1}; - auto tokens = - base::SplitString(switch_value, delimiter, base::TRIM_WHITESPACE, - base::SPLIT_WANT_NONEMPTY); - append_me->reserve(append_me->size() + tokens.size()); - std::move(std::begin(tokens), std::end(tokens), - std::back_inserter(*append_me)); - } -} - } // namespace ElectronContentClient::ElectronContentClient() = default; @@ -149,16 +135,19 @@ void ElectronContentClient::AddAdditionalSchemes(Schemes* schemes) { // // We use this for registration to network utility process if (IsUtilityProcess()) { - AppendDelimitedSwitchToVector(switches::kServiceWorkerSchemes, - &schemes->service_worker_schemes); - AppendDelimitedSwitchToVector(switches::kStandardSchemes, - &schemes->standard_schemes); - AppendDelimitedSwitchToVector(switches::kSecureSchemes, - &schemes->secure_schemes); - AppendDelimitedSwitchToVector(switches::kBypassCSPSchemes, - &schemes->csp_bypassing_schemes); - AppendDelimitedSwitchToVector(switches::kCORSSchemes, - &schemes->cors_enabled_schemes); + const auto& cmd = *base::CommandLine::ForCurrentProcess(); + auto append_cli_schemes = [&cmd](auto& appendme, const auto key) { + base::Extend(appendme, base::SplitString(cmd.GetSwitchValueASCII(key), + "","", base::TRIM_WHITESPACE, + base::SPLIT_WANT_NONEMPTY)); + }; + + using namespace switches; + append_cli_schemes(schemes->cors_enabled_schemes, kCORSSchemes); + append_cli_schemes(schemes->csp_bypassing_schemes, kBypassCSPSchemes); + append_cli_schemes(schemes->secure_schemes, kSecureSchemes); + append_cli_schemes(schemes->service_worker_schemes, kServiceWorkerSchemes); + append_cli_schemes(schemes->standard_schemes, kStandardSchemes); } if (electron::fuses::IsGrantFileProtocolExtraPrivilegesEnabled()) {",refactor ebb866e63d90fc44168f2b9c97ea2378d4c17831,Shelley Vohr,2022-10-10 07:48:44,fix: override `content::ContentMainDelegate::CreateContentClient()` (#35932),"diff --git a/shell/app/electron_main_delegate.cc b/shell/app/electron_main_delegate.cc index 46a3bcc1d6..b70ace445c 100644 --- a/shell/app/electron_main_delegate.cc +++ b/shell/app/electron_main_delegate.cc @@ -317,9 +317,6 @@ absl::optional ElectronMainDelegate::BasicStartupComplete() { ::switches::kDisableGpuMemoryBufferCompositorResources); #endif - content_client_ = std::make_unique(); - SetContentClient(content_client_.get()); - return absl::nullopt; } @@ -440,6 +437,11 @@ base::StringPiece ElectronMainDelegate::GetBrowserV8SnapshotFilename() { return ContentMainDelegate::GetBrowserV8SnapshotFilename(); } +content::ContentClient* ElectronMainDelegate::CreateContentClient() { + content_client_ = std::make_unique(); + return content_client_.get(); +} + content::ContentBrowserClient* ElectronMainDelegate::CreateContentBrowserClient() { browser_client_ = std::make_unique(); diff --git a/shell/app/electron_main_delegate.h b/shell/app/electron_main_delegate.h index 4b51f5ba2a..15cff1cc76 100644 --- a/shell/app/electron_main_delegate.h +++ b/shell/app/electron_main_delegate.h @@ -38,6 +38,7 @@ class ElectronMainDelegate : public content::ContentMainDelegate { void PreSandboxStartup() override; void SandboxInitialized(const std::string& process_type) override; absl::optional PreBrowserMain() override; + content::ContentClient* CreateContentClient() override; content::ContentBrowserClient* CreateContentBrowserClient() override; content::ContentGpuClient* CreateContentGpuClient() override; content::ContentRendererClient* CreateContentRendererClient() override;",fix 324db14969c74461b849ba02c66af387c0d70d49,Samuel Attard,2022-09-23 12:32:10,"fix: set macOS crypto keychain name earlier (#34683) * fix: set macOS crypto keychain name earlier * spec: ensure arm64 mac tests are cleaned up","diff --git a/.circleci/config/base.yml b/.circleci/config/base.yml index 04b3daec34..91efc6bb13 100644 --- a/.circleci/config/base.yml +++ b/.circleci/config/base.yml @@ -216,6 +216,7 @@ step-maybe-cleanup-arm64-mac: &step-maybe-cleanup-arm64-mac rm -rf ~/Library/Application\ Support/electron* security delete-generic-password -l ""Chromium Safe Storage"" || echo ""✓ Keychain does not contain password from tests"" security delete-generic-password -l ""Electron Test Main Safe Storage"" || echo ""✓ Keychain does not contain password from tests"" + security delete-generic-password -a ""electron-test-safe-storage"" || echo ""✓ Keychain does not contain password from tests"" elif [ ""$TARGET_ARCH"" == ""arm"" ] || [ ""$TARGET_ARCH"" == ""arm64"" ]; then XVFB=/usr/bin/Xvfb /sbin/start-stop-daemon --stop --exec $XVFB || echo ""Xvfb not running"" diff --git a/shell/browser/electron_browser_main_parts.cc b/shell/browser/electron_browser_main_parts.cc index 20c2d611d8..601879ab28 100644 --- a/shell/browser/electron_browser_main_parts.cc +++ b/shell/browser/electron_browser_main_parts.cc @@ -91,6 +91,7 @@ #endif #if BUILDFLAG(IS_MAC) +#include ""components/os_crypt/keychain_password_mac.h"" #include ""services/device/public/cpp/geolocation/geolocation_manager.h"" #include ""shell/browser/ui/cocoa/views_delegate_mac.h"" #else @@ -490,6 +491,9 @@ void ElectronBrowserMainParts::WillRunMainMessageLoop( } void ElectronBrowserMainParts::PostCreateMainMessageLoop() { +#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) + std::string app_name = electron::Browser::Get()->GetName(); +#endif #if BUILDFLAG(IS_LINUX) auto shutdown_cb = base::BindOnce(base::RunLoop::QuitCurrentWhenIdleClosureDeprecated()); @@ -500,7 +504,6 @@ void ElectronBrowserMainParts::PostCreateMainMessageLoop() { // Set up crypt config. This needs to be done before anything starts the // network service, as the raw encryption key needs to be shared with the // network service for encrypted cookie storage. - std::string app_name = electron::Browser::Get()->GetName(); const base::CommandLine& command_line = *base::CommandLine::ForCurrentProcess(); std::unique_ptr config = @@ -517,6 +520,10 @@ void ElectronBrowserMainParts::PostCreateMainMessageLoop() { base::PathService::Get(DIR_SESSION_DATA, &config->user_data_path); OSCrypt::SetConfig(std::move(config)); #endif +#if BUILDFLAG(IS_MAC) + KeychainPassword::GetServiceName() = app_name + "" Safe Storage""; + KeychainPassword::GetAccountName() = app_name; +#endif #if BUILDFLAG(IS_POSIX) // Exit in response to SIGINT, SIGTERM, etc. InstallShutdownSignalHandlers( diff --git a/shell/browser/net/system_network_context_manager.cc b/shell/browser/net/system_network_context_manager.cc index d1f474d59e..2b8f431425 100644 --- a/shell/browser/net/system_network_context_manager.cc +++ b/shell/browser/net/system_network_context_manager.cc @@ -42,10 +42,6 @@ #include ""shell/common/options_switches.h"" #include ""url/gurl.h"" -#if BUILDFLAG(IS_MAC) -#include ""components/os_crypt/keychain_password_mac.h"" -#endif - #if BUILDFLAG(IS_LINUX) #include ""components/os_crypt/key_storage_config_linux.h"" #endif @@ -288,12 +284,6 @@ void SystemNetworkContextManager::OnNetworkServiceCreated( base::FeatureList::IsEnabled(features::kAsyncDns), default_secure_dns_mode, doh_config, additional_dns_query_types_enabled); - std::string app_name = electron::Browser::Get()->GetName(); -#if BUILDFLAG(IS_MAC) - KeychainPassword::GetServiceName() = app_name + "" Safe Storage""; - KeychainPassword::GetAccountName() = app_name; -#endif - // The OSCrypt keys are process bound, so if network service is out of // process, send it the required key. if (content::IsOutOfProcessNetworkService() && diff --git a/spec/api-safe-storage-spec.ts b/spec/api-safe-storage-spec.ts index 098095e2fd..e7f4dcf185 100644 --- a/spec/api-safe-storage-spec.ts +++ b/spec/api-safe-storage-spec.ts @@ -4,7 +4,7 @@ import { safeStorage } from 'electron/main'; import { expect } from 'chai'; import { emittedOnce } from './events-helpers'; import { ifdescribe } from './spec-helpers'; -import * as fs from 'fs'; +import * as fs from 'fs-extra'; /* isEncryptionAvailable returns false in Linux when running CI due to a mocked dbus. This stops * Chrome from reaching the system's keyring or libsecret. When running the tests with config.store @@ -36,8 +36,8 @@ describe('safeStorage module', () => { ifdescribe(process.platform !== 'linux')('safeStorage module', () => { after(async () => { const pathToEncryptedString = path.resolve(__dirname, 'fixtures', 'api', 'safe-storage', 'encrypted.txt'); - if (fs.existsSync(pathToEncryptedString)) { - await fs.unlinkSync(pathToEncryptedString); + if (await fs.pathExists(pathToEncryptedString)) { + await fs.remove(pathToEncryptedString); } }); ",fix 3e6a038af77cc01e16bf139dc68dd8eb45483c7b,Shelley Vohr,2024-01-25 01:12:54,"fix: draggable regions not working (#41030) * fix: draggable regions not working * fix: only support app regions for main frame --------- Co-authored-by: deepak1556 ","diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 1ddb9f6d15..681baab2ee 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -128,3 +128,4 @@ fix_restore_original_resize_performance_on_macos.patch feat_allow_code_cache_in_custom_schemes.patch enable_partition_alloc_ref_count_size.patch build_run_reclient_cfg_generator_after_chrome.patch +fix_drag_regions_not_working_after_navigation_in_wco_app.patch diff --git a/patches/chromium/fix_drag_regions_not_working_after_navigation_in_wco_app.patch b/patches/chromium/fix_drag_regions_not_working_after_navigation_in_wco_app.patch new file mode 100644 index 0000000000..118c2082f3 --- /dev/null +++ b/patches/chromium/fix_drag_regions_not_working_after_navigation_in_wco_app.patch @@ -0,0 +1,205 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Amanda Baker +Date: Wed, 17 Jan 2024 21:07:24 +0000 +Subject: fix: drag regions not working after navigation in WCO app + +crrev.com/c/4814003 caused a regression where draggable regions (set +using the app-region CSS property) did not work after a Window +Controls Overlay or Borderless app navigated to another url. + +This change fixes this issue by setting SupportsAppRegion to true on +each navigation within the app window. + +Bug: 1516830, 1447586 +Change-Id: I98019070f13ccd93a0f6db57a187eed00b460e81 +Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5179536 +Commit-Queue: Amanda Baker +Reviewed-by: Phillis Tang +Reviewed-by: Dmitry Gozman +Cr-Commit-Position: refs/heads/main@{#1248354} + +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 0550bf54088ba18311ea13cea1555d22e2976a20..9c1359730ae381037102d2fe9950f1a19a679e54 100644 +--- a/third_party/blink/renderer/core/exported/web_view_impl.cc ++++ b/third_party/blink/renderer/core/exported/web_view_impl.cc +@@ -4016,7 +4016,24 @@ bool WebViewImpl::IsFencedFrameRoot() const { + } + + void WebViewImpl::SetSupportsAppRegion(bool supports_app_region) { +- MainFrameImpl()->GetFrame()->SetSupportsAppRegion(supports_app_region); ++ supports_app_region_ = supports_app_region; ++ if (!MainFrameImpl() || !MainFrameImpl()->GetFrame()) { ++ return; ++ } ++ ++ LocalFrame* local_frame = MainFrameImpl()->GetFrame(); ++ ++ if (supports_app_region_) { ++ local_frame->View()->UpdateDocumentAnnotatedRegions(); ++ } else { ++ local_frame->GetDocument()->SetAnnotatedRegions( ++ Vector()); ++ local_frame->Client()->AnnotatedRegionsChanged(); ++ } ++} ++ ++bool WebViewImpl::SupportsAppRegion() { ++ return supports_app_region_; + } + + void WebViewImpl::MojoDisconnected() { +diff --git a/third_party/blink/renderer/core/exported/web_view_impl.h b/third_party/blink/renderer/core/exported/web_view_impl.h +index c227b904fef4acc76a4af50263ab9d4fa35472e2..8dfb3b5b9026df92e28271258870c9eb588a6526 100644 +--- a/third_party/blink/renderer/core/exported/web_view_impl.h ++++ b/third_party/blink/renderer/core/exported/web_view_impl.h +@@ -636,6 +636,9 @@ class CORE_EXPORT WebViewImpl final : public WebView, + + scheduler::WebAgentGroupScheduler& GetWebAgentGroupScheduler(); + ++ // Returns true if the page supports app-region: drag/no-drag. ++ bool SupportsAppRegion(); ++ + private: + FRIEND_TEST_ALL_PREFIXES(WebFrameTest, DivScrollIntoEditableTest); + FRIEND_TEST_ALL_PREFIXES(WebFrameTest, +@@ -998,6 +1001,10 @@ class CORE_EXPORT WebViewImpl final : public WebView, + absl::optional close_called_stack_trace_; + absl::optional close_window_called_stack_trace_; + ++ // Indicates whether the page supports draggable regions via the app-region ++ // CSS property. ++ bool supports_app_region_ = false; ++ + // All the registered observers. + base::ObserverList observers_; + +diff --git a/third_party/blink/renderer/core/frame/local_frame.cc b/third_party/blink/renderer/core/frame/local_frame.cc +index 8cd79df2968ca7e98761b5aa604fb0228cbeaa8d..3a948217adf7ddb5a846c06cd4c0c5a8d64ab87b 100644 +--- a/third_party/blink/renderer/core/frame/local_frame.cc ++++ b/third_party/blink/renderer/core/frame/local_frame.cc +@@ -3829,19 +3829,4 @@ const mojom::RendererContentSettingsPtr& LocalFrame::GetContentSettings() { + return loader_.GetDocumentLoader()->GetContentSettings(); + } + +-bool LocalFrame::SupportsAppRegion() { +- return supports_app_region_; +-} +- +-void LocalFrame::SetSupportsAppRegion(bool supports_app_region) { +- supports_app_region_ = supports_app_region; +- if (supports_app_region) { +- view_->UpdateDocumentAnnotatedRegions(); +- } else { +- CHECK(GetDocument()); +- GetDocument()->SetAnnotatedRegions(Vector()); +- Client()->AnnotatedRegionsChanged(); +- } +-} +- + } // namespace blink +diff --git a/third_party/blink/renderer/core/frame/local_frame.h b/third_party/blink/renderer/core/frame/local_frame.h +index eb5ec8620c583e8850ea40deca9d19b08a144323..4acd8d0df124e1c2d5a546294e7fae261baf3440 100644 +--- a/third_party/blink/renderer/core/frame/local_frame.h ++++ b/third_party/blink/renderer/core/frame/local_frame.h +@@ -926,10 +926,6 @@ class CORE_EXPORT LocalFrame final + // Can only be called while the frame is not detached. + const mojom::RendererContentSettingsPtr& GetContentSettings(); + +- // Returns true if the frame supports app-region: drag/no-drag. +- bool SupportsAppRegion(); +- void SetSupportsAppRegion(bool supports_app_region); +- + private: + friend class FrameNavigationDisabler; + // LocalFrameMojoHandler is a part of LocalFrame. +@@ -1191,8 +1187,6 @@ class CORE_EXPORT LocalFrame final + + Member + v8_local_compile_hints_producer_; +- +- bool supports_app_region_ = false; + }; + + inline FrameLoader& LocalFrame::Loader() const { +diff --git a/third_party/blink/renderer/core/frame/local_frame_view.cc b/third_party/blink/renderer/core/frame/local_frame_view.cc +index 8cb1426970f17a84f1012ab7520373648f40ea35..b5c034a451c860c2fd4ca6488a98b6c863691c2f 100644 +--- a/third_party/blink/renderer/core/frame/local_frame_view.cc ++++ b/third_party/blink/renderer/core/frame/local_frame_view.cc +@@ -1730,7 +1730,8 @@ void LocalFrameView::NotifyPageThatContentAreaWillPaint() const { + + void LocalFrameView::UpdateDocumentAnnotatedRegions() const { + Document* document = frame_->GetDocument(); +- if (!document->HasAnnotatedRegions() || !frame_->SupportsAppRegion()) { ++ if (!document->HasAnnotatedRegions() || ++ !frame_->GetPage()->GetChromeClient().SupportsAppRegion()) { + return; + } + +diff --git a/third_party/blink/renderer/core/loader/empty_clients.h b/third_party/blink/renderer/core/loader/empty_clients.h +index 47dab797a32b8832e9380c89cad92546233d9351..82bf787bc884a60ad49aeabecf8b62d2f72cd619 100644 +--- a/third_party/blink/renderer/core/loader/empty_clients.h ++++ b/third_party/blink/renderer/core/loader/empty_clients.h +@@ -106,6 +106,7 @@ class CORE_EXPORT EmptyChromeClient : public ChromeClient { + void DidFocusPage() override {} + bool CanTakeFocus(mojom::blink::FocusType) override { return false; } + void TakeFocus(mojom::blink::FocusType) override {} ++ bool SupportsAppRegion() override { return false; } + void Show(LocalFrame& frame, + LocalFrame& opener_frame, + NavigationPolicy navigation_policy, +diff --git a/third_party/blink/renderer/core/page/chrome_client.h b/third_party/blink/renderer/core/page/chrome_client.h +index 73cddb74781652fddae126f497bf8f76a2cd179c..07cc5202bd2fc38f5463a1ec651dc6dd3cc4b419 100644 +--- a/third_party/blink/renderer/core/page/chrome_client.h ++++ b/third_party/blink/renderer/core/page/chrome_client.h +@@ -177,6 +177,10 @@ class CORE_EXPORT ChromeClient : public GarbageCollected { + + virtual void SetKeyboardFocusURL(Element*) {} + ++ // Returns true if the page should support drag regions via the app-region ++ // CSS property. ++ virtual bool SupportsAppRegion() = 0; ++ + // Allow document lifecycle updates to be run in order to produce composited + // outputs. Updates are blocked from occurring during loading navigation in + // order to prevent contention and allow Blink to proceed more quickly. This +diff --git a/third_party/blink/renderer/core/page/chrome_client_impl.cc b/third_party/blink/renderer/core/page/chrome_client_impl.cc +index 55d3e4248f722c56951b9c0120f3ac4480f1b5fe..b047b993fa780b19e08fb9a5bd328f7e83cc5661 100644 +--- a/third_party/blink/renderer/core/page/chrome_client_impl.cc ++++ b/third_party/blink/renderer/core/page/chrome_client_impl.cc +@@ -291,6 +291,10 @@ void ChromeClientImpl::SetKeyboardFocusURL(Element* new_focus_element) { + web_view_->SetKeyboardFocusURL(focus_url); + } + ++bool ChromeClientImpl::SupportsAppRegion() { ++ return web_view_->SupportsAppRegion(); ++} ++ + void ChromeClientImpl::StartDragging(LocalFrame* frame, + const WebDragData& drag_data, + DragOperationsMask mask, +diff --git a/third_party/blink/renderer/core/page/chrome_client_impl.h b/third_party/blink/renderer/core/page/chrome_client_impl.h +index bc8f7fe91eaff2ee9a0676e91ddff806bcaee5ff..ad179bc9ea6290e7bbeba427f54f0ea6ab396338 100644 +--- a/third_party/blink/renderer/core/page/chrome_client_impl.h ++++ b/third_party/blink/renderer/core/page/chrome_client_impl.h +@@ -77,6 +77,7 @@ class CORE_EXPORT ChromeClientImpl final : public ChromeClient { + bool CanTakeFocus(mojom::blink::FocusType) override; + void TakeFocus(mojom::blink::FocusType) override; + void SetKeyboardFocusURL(Element* new_focus_element) override; ++ bool SupportsAppRegion() override; + void BeginLifecycleUpdates(LocalFrame& main_frame) override; + void RegisterForCommitObservation(CommitObserver*) override; + void UnregisterFromCommitObservation(CommitObserver*) override; +diff --git a/third_party/blink/renderer/core/testing/internals.cc b/third_party/blink/renderer/core/testing/internals.cc +index 23cf906dbba8136c604a1e3a59d27882710368c6..9ff8b22cf794cd58bff985e054df37636e34aabd 100644 +--- a/third_party/blink/renderer/core/testing/internals.cc ++++ b/third_party/blink/renderer/core/testing/internals.cc +@@ -3008,7 +3008,8 @@ DOMRectList* Internals::nonDraggableRegions(Document* document, + } + + void Internals::SetSupportsAppRegion(bool supports_app_region) { +- GetFrame()->SetSupportsAppRegion(supports_app_region); ++ document_->GetPage()->GetChromeClient().GetWebView()->SetSupportsAppRegion( ++ supports_app_region); + } + + DOMRectList* Internals::AnnotatedRegions(Document* document, diff --git a/shell/renderer/electron_render_frame_observer.cc b/shell/renderer/electron_render_frame_observer.cc index 5ca94d49b3..eff8ab3e4f 100644 --- a/shell/renderer/electron_render_frame_observer.cc +++ b/shell/renderer/electron_render_frame_observer.cc @@ -30,6 +30,7 @@ #include ""third_party/blink/public/web/web_element.h"" #include ""third_party/blink/public/web/web_local_frame.h"" #include ""third_party/blink/public/web/web_script_source.h"" +#include ""third_party/blink/public/web/web_view.h"" #include ""third_party/blink/renderer/core/frame/web_local_frame_impl.h"" // nogncheck #include ""ui/base/resource/resource_bundle.h"" @@ -55,6 +56,11 @@ ElectronRenderFrameObserver::ElectronRenderFrameObserver( renderer_client_(renderer_client) { // Initialise resource for directory listing. net::NetModule::SetResourceProvider(NetResourceProvider); + + // App regions are only supported in the main frame. + auto* main_frame = frame->GetMainRenderFrame(); + if (main_frame && main_frame == frame) + render_frame_->GetWebView()->SetSupportsAppRegion(true); } void ElectronRenderFrameObserver::DidClearWindowObject() {",fix 5400c04e43a85cd3d1a4a3eeb235ec3256d3ddc5,Niklas Wenzel,2024-10-11 16:25:25,docs: clarify interplay between utility process events (#44015),"diff --git a/docs/api/utility-process.md b/docs/api/utility-process.md index af6c74967e..bb78e57649 100644 --- a/docs/api/utility-process.md +++ b/docs/api/utility-process.md @@ -127,6 +127,9 @@ Returns: Emitted when the child process needs to terminate due to non continuable error from V8. +No matter if you listen to the `error` event, the `exit` event will be emitted after the +child process terminates. + #### Event: 'exit' Returns:",docs 1d4b00692deae10ae98d2eb20dd7f8a20fc1e89a,David Sanders,2024-06-27 04:46:11,build: bump version in .nvmrc to 20 (#42668),"diff --git a/.nvmrc b/.nvmrc index b6a7d89c68..209e3ef4b6 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -16 +20",build 7d3f22dd32365d5432583d936fa4c7f3d480ef45,Milan Burda,2022-09-16 07:33:01,"fix: uv_os_gethostname failing on Windows 7 (libuv patch regression) (#35702) Co-authored-by: Milan Burda ","diff --git a/patches/node/fix_crash_caused_by_gethostnamew_on_windows_7.patch b/patches/node/fix_crash_caused_by_gethostnamew_on_windows_7.patch index 5ebadbf25b..8d1899062c 100644 --- a/patches/node/fix_crash_caused_by_gethostnamew_on_windows_7.patch +++ b/patches/node/fix_crash_caused_by_gethostnamew_on_windows_7.patch @@ -6,7 +6,7 @@ Subject: fix: crash caused by GetHostNameW on Windows 7 Backported from https://github.com/libuv/libuv/pull/3285. diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c -index 33e874ac442f88b58d2b68c8ec9764f6f664552e..2d4cc0aaa02e61bf359e80eca27527efb49fd85e 100644 +index 33e874ac442f88b58d2b68c8ec9764f6f664552e..37ece5e2867ab836492a8b7faa0aa5e1b8e562f0 100644 --- a/deps/uv/src/win/util.c +++ b/deps/uv/src/win/util.c @@ -37,6 +37,7 @@ @@ -166,3 +166,17 @@ index 33e874ac442f88b58d2b68c8ec9764f6f664552e..2d4cc0aaa02e61bf359e80eca27527ef int uv_os_gethostname(char* buffer, size_t* size) { WCHAR buf[UV_MAXHOSTNAMESIZE]; size_t len; +@@ -1674,10 +1803,10 @@ int uv_os_gethostname(char* buffer, size_t* size) { + + uv__once_init(); /* Initialize winsock */ + +- if (pGetHostNameW == NULL) +- return UV_ENOSYS; ++ uv_sGetHostNameW gethostnamew = ++ pGetHostNameW == NULL ? uv__gethostnamew_nt60 : pGetHostNameW; + +- if (pGetHostNameW(buf, UV_MAXHOSTNAMESIZE) != 0) ++ if (gethostnamew(buf, UV_MAXHOSTNAMESIZE) != 0) + return uv_translate_sys_error(WSAGetLastError()); + + convert_result = uv__convert_utf16_to_utf8(buf, -1, &utf8_str); diff --git a/patches/node/fix_suppress_clang_-wdeprecated-declarations_in_libuv.patch b/patches/node/fix_suppress_clang_-wdeprecated-declarations_in_libuv.patch index bb7df671a3..a6ae065079 100644 --- a/patches/node/fix_suppress_clang_-wdeprecated-declarations_in_libuv.patch +++ b/patches/node/fix_suppress_clang_-wdeprecated-declarations_in_libuv.patch @@ -6,7 +6,7 @@ Subject: fix: suppress clang -Wdeprecated-declarations in libuv Should be upstreamed. diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c -index 2d4cc0aaa02e61bf359e80eca27527efb49fd85e..aaa16052e2a9c7d1dca82763c41c0890371f1471 100644 +index 37ece5e2867ab836492a8b7faa0aa5e1b8e562f0..d50296728f7e0810064647125a469f3ed714f8ea 100644 --- a/deps/uv/src/win/util.c +++ b/deps/uv/src/win/util.c @@ -1950,10 +1950,17 @@ int uv_os_uname(uv_utsname_t* buffer) {",fix 18717ee62d4f54a880e00ccd80f2a33423bb74eb,spencer17x,2023-09-19 04:51:46,"docs: add a more detailed explanation to cookies.flushStore() (#37572) * docs: cookies.flushStore() * docs: modify cookies.flushStore() * Update docs/api/cookies.md Co-authored-by: Shelley Vohr --------- Co-authored-by: Shelley Vohr ","diff --git a/docs/api/cookies.md b/docs/api/cookies.md index 41e448b713..5665c8587c 100644 --- a/docs/api/cookies.md +++ b/docs/api/cookies.md @@ -119,4 +119,8 @@ Removes the cookies matching `url` and `name` Returns `Promise` - A promise which resolves when the cookie store has been flushed -Writes any unwritten cookies data to disk. +Writes any unwritten cookies data to disk + +Cookies written by any method will not be written to disk immediately, but will be written every 30 seconds or 512 operations + +Calling this method can cause the cookie to be written to disk immediately.",docs 852f9ff329ff7c1a00aeaa468bc25e956ae0b81a,Charles Kerr,2024-09-26 12:10:30,"perf: build g_dgettext domain name at compile time (#43960) perf: build GettextPackage name at compile time","diff --git a/shell/browser/ui/gtk_util.cc b/shell/browser/ui/gtk_util.cc index 651ab50596..faa6b29854 100644 --- a/shell/browser/ui/gtk_util.cc +++ b/shell/browser/ui/gtk_util.cc @@ -8,16 +8,12 @@ #include #include -#include -#include - -#include ""base/no_destructor.h"" -#include ""base/strings/string_number_conversions.h"" +#include ""base/macros/remove_parens.h"" +#include ""base/strings/stringize_macros.h"" #include ""electron/electron_gtk_stubs.h"" #include ""third_party/skia/include/core/SkBitmap.h"" #include ""third_party/skia/include/core/SkColor.h"" #include ""third_party/skia/include/core/SkUnPreMultiply.h"" -#include ""ui/gtk/gtk_compat.h"" // nogncheck // The following utilities are pulled from // https://source.chromium.org/chromium/chromium/src/+/main:ui/gtk/select_file_dialog_linux_gtk.cc;l=44-75;drc=a03ba4ca94f75531207c3ea832d6a605cde77394 @@ -25,14 +21,12 @@ namespace gtk_util { namespace { -const char* GettextPackage() { - static base::NoDestructor gettext_package( - ""gtk"" + base::NumberToString(gtk::GtkVersion().components()[0]) + ""0""); - return gettext_package->c_str(); -} - const char* GtkGettext(const char* str) { - return g_dgettext(GettextPackage(), str); + // ex: ""gtk30"". GTK_MAJOR_VERSION is #defined as an int in parenthesis, + // like (3), so use base macros to remove parenthesis and stringize it + static const char kGettextDomain[] = + ""gtk"" STRINGIZE(BASE_REMOVE_PARENS(GTK_MAJOR_VERSION)) ""0""; + return g_dgettext(kGettextDomain, str); } } // namespace",perf 32583ac756a8e201c3a4b0db86c0564e84f08b67,Jeremy Rose,2022-11-23 00:52:36,"docs: add missing event-emitter link to utility-process docs (#36428) add missing event-emitter link","diff --git a/docs/api/utility-process.md b/docs/api/utility-process.md index 147f970810..9495b527e7 100644 --- a/docs/api/utility-process.md +++ b/docs/api/utility-process.md @@ -134,3 +134,4 @@ Emitted when the child process sends a message using [`process.parentPort.postMe [`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 +[event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter",docs 587b66acc1609e78e2d8e86e5f40f2942650e79f,Kenneth Gerald Hamilton,2024-03-21 14:25:35,"docs: nodejs trademark policy link broken (#41558) * Fix broken Trademark Policy link * add durable link Per codebyter: https://github.com/electron/electron/pull/41558#discussion_r1522938560","diff --git a/README.md b/README.md index d45d3cfe50..74dfaa6fea 100644 --- a/README.md +++ b/README.md @@ -112,4 +112,4 @@ and more can be found on the [Community page](https://www.electronjs.org/communi [MIT](https://github.com/electron/electron/blob/main/LICENSE) -When using Electron logos, make sure to follow [OpenJS Foundation Trademark Policy](https://openjsf.org/wp-content/uploads/sites/84/2021/01/OpenJS-Foundation-Trademark-Policy-2021-01-12.docx.pdf). +When using Electron logos, make sure to follow [OpenJS Foundation Trademark Policy](https://trademark-policy.openjsf.org/).",docs cdafe09ffbfdcbbc789bd141f6c9cad7e7fa3e92,electron-appveyor-updater[bot],2024-04-17 10:51:13,"build: update appveyor image to latest version (#41871) Co-authored-by: electron-appveyor-updater[bot] <161660339+electron-appveyor-updater[bot]@users.noreply.github.com>","diff --git a/appveyor-woa.yml b/appveyor-woa.yml index a2053901df..cc12885c01 100644 --- a/appveyor-woa.yml +++ b/appveyor-woa.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-124.0.6359.0 +image: e-125.0.6412.0 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default diff --git a/appveyor.yml b/appveyor.yml index a60833b6e9..18460e651e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -29,7 +29,7 @@ version: 1.0.{build} build_cloud: electronhq-16-core -image: e-124.0.6359.0 +image: e-125.0.6412.0 environment: GIT_CACHE_PATH: C:\Users\appveyor\libcc_cache ELECTRON_OUT_DIR: Default",build ca0920872d2f8f180fecfbb321ecdb77a7f0e677,Michaela Laurencin,2024-02-17 12:20:53,chore: update breaking-changes.md to reflect WebContentsView revert (#41361),"diff --git a/docs/breaking-changes.md b/docs/breaking-changes.md index 5800ffa181..ace564a6a9 100644 --- a/docs/breaking-changes.md +++ b/docs/breaking-changes.md @@ -26,6 +26,18 @@ more information. This switch was never formally documented but it's removal is being noted here regardless. Chromium itself now has better support for color spaces so this flag should not be needed. +### Behavior Changed: `BrowserView.setAutoResize` behavior on macOS + +In Electron 30, BrowserView is now a wrapper around the new [WebContentsView](api/web-contents-view.md) API. + +Previously, the `setAutoResize` function of the `BrowserView` API was backed by [autoresizing](https://developer.apple.com/documentation/appkit/nsview/1483281-autoresizingmask?language=objc) on macOS, and by a custom algorithm on Windows and Linux. +For simple use cases such as making a BrowserView fill the entire window, the behavior of these two approaches was identical. +However, in more advanced cases, BrowserViews would be autoresized differently on macOS than they would be on other platforms, as the custom resizing algorithm for Windows and Linux did not perfectly match the behavior of macOS's autoresizing API. +The autoresizing behavior is now standardized across all platforms. + +If your app uses `BrowserView.setAutoResize` to do anything more complex than making a BrowserView fill the entire window, it's likely you already had custom logic in place to handle this difference in behavior on macOS. +If so, that logic will no longer be needed in Electron 30 as autoresizing behavior is consistent. + ## Planned Breaking API Changes (29.0) ### Behavior Changed: `ipcRenderer` can no longer be sent over the `contextBridge` @@ -82,18 +94,6 @@ app.on('gpu-process-crashed', (event, killed) => { /* ... */ }) app.on('child-process-gone', (event, details) => { /* ... */ }) ``` -### Behavior Changed: `BrowserView.setAutoResize` behavior on macOS - -In Electron 29, BrowserView is now a wrapper around the new [WebContentsView](api/web-contents-view.md) API. - -Previously, the `setAutoResize` function of the `BrowserView` API was backed by [autoresizing](https://developer.apple.com/documentation/appkit/nsview/1483281-autoresizingmask?language=objc) on macOS, and by a custom algorithm on Windows and Linux. -For simple use cases such as making a BrowserView fill the entire window, the behavior of these two approaches was identical. -However, in more advanced cases, BrowserViews would be autoresized differently on macOS than they would be on other platforms, as the custom resizing algorithm for Windows and Linux did not perfectly match the behavior of macOS's autoresizing API. -The autoresizing behavior is now standardized across all platforms. - -If your app uses `BrowserView.setAutoResize` to do anything more complex than making a BrowserView fill the entire window, it's likely you already had custom logic in place to handle this difference in behavior on macOS. -If so, that logic will no longer be needed in Electron 29 as autoresizing behavior is consistent. - ## Planned Breaking API Changes (28.0) ### Behavior Changed: `WebContents.backgroundThrottling` set to false affects all `WebContents` in the host `BrowserWindow`",chore 2e778a98b90a2b769a0de76d68f906dd1defeecb,Samuel Attard,2024-05-20 14:12:05,fix: ensure showInactive actually shows (#42226),"diff --git a/shell/browser/native_window_mac.mm b/shell/browser/native_window_mac.mm index abb02e9b75..04ea63270a 100644 --- a/shell/browser/native_window_mac.mm +++ b/shell/browser/native_window_mac.mm @@ -473,7 +473,7 @@ void NativeWindowMac::ShowInactive() { if (parent()) InternalSetParentWindow(parent(), true); - [window_ orderFrontRegardless]; + [window_ orderFrontKeepWindowKeyState]; } void NativeWindowMac::Hide() {",fix a9ef68f12676fd76998ac9e15c0b10a3b6cd4daf,Samuel Attard,2022-11-14 12:46:52,"refactor: change defined(MAS_BUILD) to IS_MAS_BUILD() (#36332) * refactor: change defined(MAS_BUILD) to IS_MAS_BUILD() This is missing-definition safe and thus allows us to move the definition of this macro away from ""all compilation targets"" to ""just the compilation targets that depend on this macro"". In turn this makes the rebuild time changing from mas <-> darwin only 80 seconds on my machine, instead of the 12-15 minutes it used to take. This will also allow us in the future to build both MAS and darwin on the same CI machine. Costing us ~2 minutes on one machine but saving us anywhere from 30 minutes to an hour of CI time on other parts of the matrix. * build: always define IS_MAS_BUILD even on non-mac builds * build: use extra_configs","diff --git a/BUILD.gn b/BUILD.gn index 070b4c3a93..5c77826b23 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -512,6 +512,8 @@ source_set(""electron_lib"") { ] } + configs += [ ""//electron/build/config:mas_build"" ] + sources = filenames.lib_sources if (is_win) { sources += filenames.lib_sources_win @@ -573,7 +575,6 @@ source_set(""electron_lib"") { if (is_mas_build) { sources += [ ""shell/browser/api/electron_api_app_mas.mm"" ] sources -= [ ""shell/browser/auto_updater_mac.mm"" ] - defines += [ ""MAS_BUILD"" ] sources -= [ ""shell/app/electron_crash_reporter_client.cc"", ""shell/app/electron_crash_reporter_client.h"", @@ -977,6 +978,7 @@ if (is_mac) { deps += [ ""//sandbox/mac:seatbelt"" ] } defines = [ ""HELPER_EXECUTABLE"" ] + extra_configs = [ ""//electron/build/config:mas_build"" ] sources = [ ""shell/app/electron_main_mac.cc"", ""shell/app/uv_stdio_fix.cc"", @@ -1147,6 +1149,7 @@ if (is_mac) { ""-rpath"", ""@executable_path/../Frameworks"", ] + extra_configs = [ ""//electron/build/config:mas_build"" ] } if (enable_dsyms) { diff --git a/build/config/BUILD.gn b/build/config/BUILD.gn index 31ff2dc8bb..ca48bd859b 100644 --- a/build/config/BUILD.gn +++ b/build/config/BUILD.gn @@ -1,6 +1,8 @@ # For MAS build, we force defining ""MAS_BUILD"". config(""mas_build"") { if (is_mas_build) { - defines = [ ""MAS_BUILD"" ] + defines = [ ""IS_MAS_BUILD()=1"" ] + } else { + defines = [ ""IS_MAS_BUILD()=0"" ] } } diff --git a/patches/chromium/.patches b/patches/chromium/.patches index b703442392..b68d3b695e 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -123,3 +123,4 @@ fix_remove_caption-removing_style_call.patch build_allow_electron_to_use_exec_script.patch revert_use_accessibility_pkey_when_setting_page_access.patch roll_clang_llvmorg-16-init-8189-g97196a2d-2.patch +build_only_use_the_mas_build_config_in_the_required_components.patch diff --git a/patches/chromium/build_only_use_the_mas_build_config_in_the_required_components.patch b/patches/chromium/build_only_use_the_mas_build_config_in_the_required_components.patch new file mode 100644 index 0000000000..bab5298926 --- /dev/null +++ b/patches/chromium/build_only_use_the_mas_build_config_in_the_required_components.patch @@ -0,0 +1,282 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samuel Attard +Date: Mon, 14 Nov 2022 01:05:20 -0800 +Subject: build: only use the mas build config in the required components + +Before landing this patch should be split into the relevant MAS patches, or at least the patch this one partially reverts + +diff --git a/base/BUILD.gn b/base/BUILD.gn +index 98c3dbe91452543c4cbe58f51268633346f3851f..6e06f98e8db59bda3d34307467dc3158fdd097f7 100644 +--- a/base/BUILD.gn ++++ b/base/BUILD.gn +@@ -1480,6 +1480,7 @@ mixed_component(""base"") { + ""//build/config/compiler:prevent_unsafe_narrowing"", + ""//build/config/compiler:wexit_time_destructors"", + ""//build/config/compiler:wglobal_constructors"", ++ ""//electron/build/config:mas_build"", + ] + + deps = [ +diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn +index 091b1ae4b16771a5ec05cdeab6a1f281b2d9ccc5..21841237347178d7720fd0b79f7799d471a3e31f 100644 +--- a/build/config/BUILDCONFIG.gn ++++ b/build/config/BUILDCONFIG.gn +@@ -355,7 +355,6 @@ default_compiler_configs = [ + ""//build/config/compiler/pgo:default_pgo_flags"", + ""//build/config/coverage:default_coverage"", + ""//build/config/sanitizers:default_sanitizer_flags"", +- ""//electron/build/config:mas_build"", + ] + + if (is_win) { +diff --git a/components/os_crypt/BUILD.gn b/components/os_crypt/BUILD.gn +index 8448ff2d912ed8664ba1117397a2407c08e9a578..5f6bb1a87615c474e06209fc8034ff36ee6a5b75 100644 +--- a/components/os_crypt/BUILD.gn ++++ b/components/os_crypt/BUILD.gn +@@ -65,6 +65,8 @@ component(""os_crypt"") { + ""keychain_password_mac.mm"", + ""os_crypt_mac.mm"", + ] ++ ++ configs += [""//electron/build/config:mas_build""] + } + + if (is_win) { +diff --git a/components/remote_cocoa/app_shim/BUILD.gn b/components/remote_cocoa/app_shim/BUILD.gn +index 629172faea91a3384e6115f732a1d0ba272b3835..5970d1cb2ed7d29f653cc1b094cdfa8248e0b48c 100644 +--- a/components/remote_cocoa/app_shim/BUILD.gn ++++ b/components/remote_cocoa/app_shim/BUILD.gn +@@ -16,6 +16,7 @@ component(""app_shim"") { + assert(is_mac) + + configs += [ "":app_shim_warnings"" ] ++ configs += [""//electron/build/config:mas_build""] + sources = [ + ""alert.h"", + ""alert.mm"", +diff --git a/components/viz/service/BUILD.gn b/components/viz/service/BUILD.gn +index c2c65f685e760248adf3efcc98e6c7a8f1f7e5fb..34a15cbb10861058c5ba46c9ac111c9de69800f9 100644 +--- a/components/viz/service/BUILD.gn ++++ b/components/viz/service/BUILD.gn +@@ -305,6 +305,8 @@ viz_component(""service"") { + + deps += [ ""//ui/accelerated_widget_mac"" ] + frameworks = [ ""IOSurface.framework"" ] ++ ++ configs = [""//electron/build/config:mas_build""] + } + + if (is_android || use_ozone) { +diff --git a/content/browser/BUILD.gn b/content/browser/BUILD.gn +index b33864b2d57fb26637bd96edbd8fb917881f5f4c..749949d1b3618a16fce3a47dd2776af3555f64d2 100644 +--- a/content/browser/BUILD.gn ++++ b/content/browser/BUILD.gn +@@ -52,6 +52,7 @@ source_set(""browser"") { + ""//tools/v8_context_snapshot:use_v8_context_snapshot"", + ""//v8:external_startup_data"", + ] ++ configs += [""//electron/build/config:mas_build""] + defines = [] + libs = [] + frameworks = [] +diff --git a/content/common/BUILD.gn b/content/common/BUILD.gn +index bcc0a45f9b9eabb8aa98def58a68a8fcac93eadb..6105cb434bf0de629a9876480ad8bf31ba554d09 100644 +--- a/content/common/BUILD.gn ++++ b/content/common/BUILD.gn +@@ -177,6 +177,7 @@ source_set(""common"") { + ""//content:content_implementation"", + ""//build/config:precompiled_headers"", + ] ++ configs += [""//electron/build/config:mas_build""] + + public_deps = [ + "":mojo_bindings"", +diff --git a/content/renderer/BUILD.gn b/content/renderer/BUILD.gn +index ac506972529bec0f2c02dd1d1f7e25cb6709959a..1815ee6dd219c9f90ea052464e73427ae9a68fb7 100644 +--- a/content/renderer/BUILD.gn ++++ b/content/renderer/BUILD.gn +@@ -214,6 +214,7 @@ target(link_target_type, ""renderer"") { + } + + configs += [ ""//content:content_implementation"" ] ++ configs += [""//electron/build/config:mas_build""] + defines = [] + + public_deps = [ +diff --git a/device/bluetooth/BUILD.gn b/device/bluetooth/BUILD.gn +index bd08baf779fba569079cfa27726adfca92a27f8e..640975ae8c67892ea99813553cec63addad69339 100644 +--- a/device/bluetooth/BUILD.gn ++++ b/device/bluetooth/BUILD.gn +@@ -251,6 +251,7 @@ component(""bluetooth"") { + ""IOKit.framework"", + ""Foundation.framework"", + ] ++ configs += [""//electron/build/config:mas_build""] + } + + if (is_win) { +diff --git a/gpu/ipc/service/BUILD.gn b/gpu/ipc/service/BUILD.gn +index c342a9c95b1787c49b88ba62457c6f27151cbb87..6181018d4940569e1feb323587fcbc96bd597ae9 100644 +--- a/gpu/ipc/service/BUILD.gn ++++ b/gpu/ipc/service/BUILD.gn +@@ -118,6 +118,7 @@ component(""service"") { + ""OpenGL.framework"", + ""QuartzCore.framework"", + ] ++ configs += [""//electron/build/config:mas_build""] + } + if (is_android) { + sources += [ +diff --git a/media/audio/BUILD.gn b/media/audio/BUILD.gn +index 1e6b91961c3e32aa223383b444d075ada9688b0b..f7b6e6f20b0972d0c1e51d34f9a82f98494f0182 100644 +--- a/media/audio/BUILD.gn ++++ b/media/audio/BUILD.gn +@@ -192,6 +192,7 @@ source_set(""audio"") { + ""CoreAudio.framework"", + ""CoreFoundation.framework"", + ] ++ configs += [""//electron/build/config:mas_build""] + } + + if (is_win) { +diff --git a/net/dns/BUILD.gn b/net/dns/BUILD.gn +index 9f4efcb2244b9e044c540586e1246c08161a8d6f..0d346b3cf0f2de8d35b2b07a1c789ea292e54ced 100644 +--- a/net/dns/BUILD.gn ++++ b/net/dns/BUILD.gn +@@ -165,6 +165,8 @@ source_set(""dns"") { + "":host_resolver_manager"", + "":mdns_client"", + ] ++ ++ configs += [""//electron/build/config:mas_build""] + } + + # The standard API of net/dns. +diff --git a/sandbox/mac/BUILD.gn b/sandbox/mac/BUILD.gn +index 06b7f0310f1bca118cc2c89a9c21d3ebd661ec1e..b5b7432e1d998db003dd33622c750e817c79d7bc 100644 +--- a/sandbox/mac/BUILD.gn ++++ b/sandbox/mac/BUILD.gn +@@ -33,6 +33,7 @@ component(""seatbelt"") { + ] + public_deps = [ ""//third_party/protobuf:protobuf_lite"" ] + defines = [ ""SEATBELT_IMPLEMENTATION"" ] ++ configs += [""//electron/build/config:mas_build""] + } + + component(""seatbelt_extension"") { +@@ -46,6 +47,7 @@ component(""seatbelt_extension"") { + libs = [ ""sandbox"" ] + public_deps = [ ""//base"" ] + defines = [ ""SEATBELT_IMPLEMENTATION"" ] ++ configs += [""//electron/build/config:mas_build""] + } + + component(""system_services"") { +@@ -60,6 +62,7 @@ component(""system_services"") { + deps = [ "":seatbelt_export"" ] + public_deps = [ ""//base"" ] + defines = [ ""SEATBELT_IMPLEMENTATION"" ] ++ configs += [""//electron/build/config:mas_build""] + } + + source_set(""sandbox_unittests"") { +diff --git a/third_party/blink/renderer/core/BUILD.gn b/third_party/blink/renderer/core/BUILD.gn +index a42b76b65e9b04f5226c5e4e706fae45464a96b0..c5a8d12a0c6c456d8f8d92d1e9ca06180cde641c 100644 +--- a/third_party/blink/renderer/core/BUILD.gn ++++ b/third_party/blink/renderer/core/BUILD.gn +@@ -282,6 +282,7 @@ component(""core"") { + ""//tools/v8_context_snapshot:use_v8_context_snapshot"", + ""//v8:external_startup_data"", + ] ++ configs += [""//electron/build/config:mas_build""] + + public_deps = [ + "":core_generated"", +diff --git a/ui/accelerated_widget_mac/BUILD.gn b/ui/accelerated_widget_mac/BUILD.gn +index 79b5a50e197897ab36253761fddffda25e5e98a4..0bcb5d1ff7b0e97922406a6f758421d9c4b24c75 100644 +--- a/ui/accelerated_widget_mac/BUILD.gn ++++ b/ui/accelerated_widget_mac/BUILD.gn +@@ -50,6 +50,8 @@ component(""accelerated_widget_mac"") { + ""OpenGL.framework"", + ""QuartzCore.framework"", + ] ++ ++ configs += [""//electron/build/config:mas_build""] + } + + test(""accelerated_widget_mac_unittests"") { +diff --git a/ui/accessibility/platform/BUILD.gn b/ui/accessibility/platform/BUILD.gn +index 8eb556b9fb92ee523417e8dd6298ee0bdedfbb9e..e46fce5152c09138e7765c0743bfbeef011a51cf 100644 +--- a/ui/accessibility/platform/BUILD.gn ++++ b/ui/accessibility/platform/BUILD.gn +@@ -235,6 +235,7 @@ source_set(""platform"") { + ""AppKit.framework"", + ""Foundation.framework"", + ] ++ configs += [""//electron/build/config:mas_build""] + } + + if (use_atk) { +diff --git a/ui/base/BUILD.gn b/ui/base/BUILD.gn +index c1cc143209fbd60a34ad1d8f92c55c94f780e977..7bc5670489381d38e57de75f8ed4885790266b78 100644 +--- a/ui/base/BUILD.gn ++++ b/ui/base/BUILD.gn +@@ -347,6 +347,7 @@ component(""base"") { + ""l10n/l10n_util_mac.mm"", + ""resource/resource_bundle_mac.mm"", + ] ++ configs += [""//electron/build/config:mas_build""] + } + + if (is_chromeos_lacros) { +diff --git a/ui/display/BUILD.gn b/ui/display/BUILD.gn +index b379aa35ddfba8a43881a3b936f382dfdb92c9b5..fa965b8f1e7e05b4153f6e5d9ae0ac787dc808d3 100644 +--- a/ui/display/BUILD.gn ++++ b/ui/display/BUILD.gn +@@ -56,6 +56,10 @@ component(""display"") { + ""mac/display_link_mac.h"", + ""mac/screen_mac.mm"", + ] ++ ++ configs += [ ++ ""//electron/build/config:mas_build"" ++ ] + } + + if (is_win) { +diff --git a/ui/gfx/BUILD.gn b/ui/gfx/BUILD.gn +index 77ec78c9fdf6b8acdf15d74dbc2f970cda242d7d..119f688169e5050a17078f6b52043461bc2c1ba2 100644 +--- a/ui/gfx/BUILD.gn ++++ b/ui/gfx/BUILD.gn +@@ -187,6 +187,7 @@ component(""gfx"") { + ""scoped_ns_graphics_context_save_gstate_mac.h"", + ""scoped_ns_graphics_context_save_gstate_mac.mm"", + ] ++ configs += [""//electron/build/config:mas_build""] + } + if (is_win) { + sources += [ +diff --git a/ui/views/BUILD.gn b/ui/views/BUILD.gn +index 4aee50aff6d97b9bfac75c943eacce8a552d20a5..44e92a351193ccbbd387d06c13460886dd8b443c 100644 +--- a/ui/views/BUILD.gn ++++ b/ui/views/BUILD.gn +@@ -657,6 +657,7 @@ component(""views"") { + ""IOSurface.framework"", + ""QuartzCore.framework"", + ] ++ configs += [""//electron/build/config:mas_build""] + } + + if (is_win) { +diff --git a/ui/views/controls/webview/BUILD.gn b/ui/views/controls/webview/BUILD.gn +index f37a5a881ac6ac432a4672c5738b7f49b75b5523..1764117f539c2423ebe8bb4c3fe70afcdd0883e8 100644 +--- a/ui/views/controls/webview/BUILD.gn ++++ b/ui/views/controls/webview/BUILD.gn +@@ -19,6 +19,7 @@ component(""webview"") { + + if (is_mac) { + sources += [ ""unhandled_keyboard_event_handler_mac.mm"" ] ++ configs += [""//electron/build/config:mas_build""] + } + + if (is_win) { diff --git a/patches/chromium/disable_compositor_recycling.patch b/patches/chromium/disable_compositor_recycling.patch index 3dc9d45774..57ba8487a7 100644 --- a/patches/chromium/disable_compositor_recycling.patch +++ b/patches/chromium/disable_compositor_recycling.patch @@ -6,7 +6,7 @@ Subject: fix: disabling compositor recycling Compositor recycling is useful for Chrome because there can be many tabs and spinning up a compositor for each one would be costly. In practice, Chrome uses the parent compositor code path of browser_compositor_view_mac.mm; the NSView of each tab is detached when it's hidden and attached when it's shown. For Electron, there is no parent compositor, so we're forced into the ""own compositor"" code path, which seems to be non-optimal and pretty ruthless in terms of the release of resources. Electron has no real concept of multiple tabs per window, so it should be okay to disable this ruthless recycling altogether in Electron. diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm -index a420b3cf9b1c325967318db322d61c4ebc4cf7c6..c5bc07973bba93aff7837cea92895e2ef7dff897 100644 +index cc2836fb66d9cf84fa298f1d75480f2c796b274f..4de5eddfeded8881717832c78725eb57769dcb5b 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -525,7 +525,11 @@ diff --git a/patches/chromium/feat_ensure_mas_builds_of_the_same_application_can_use_safestorage.patch b/patches/chromium/feat_ensure_mas_builds_of_the_same_application_can_use_safestorage.patch index 1c34b4acbe..fcc8158486 100644 --- a/patches/chromium/feat_ensure_mas_builds_of_the_same_application_can_use_safestorage.patch +++ b/patches/chromium/feat_ensure_mas_builds_of_the_same_application_can_use_safestorage.patch @@ -12,14 +12,14 @@ We attempt to migrate the safe storage key from the old account, if that migrati 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 +index 214ae79b9a6de27b99ccfa9cf03327449fd79198..fc8e8485706a8725f88e8a37c8d26ca29ec492e8 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; #endif -+#if defined(MAS_BUILD) ++#if IS_MAS_BUILD() +const char kAccountNameSuffix[] = "" App Store Key""; +#else +const char kAccountNameSuffix[] = "" Key""; diff --git a/patches/chromium/mas-cgdisplayusesforcetogray.patch b/patches/chromium/mas-cgdisplayusesforcetogray.patch index 7e632508fc..8635d4fe56 100644 --- a/patches/chromium/mas-cgdisplayusesforcetogray.patch +++ b/patches/chromium/mas-cgdisplayusesforcetogray.patch @@ -6,14 +6,14 @@ Subject: mas: avoid usage of CGDisplayUsesForceToGray Removes usage of the CGDisplayUsesForceToGray private API. diff --git a/ui/display/mac/screen_mac.mm b/ui/display/mac/screen_mac.mm -index a0c06e539088c6521793ecf9ba8d54311c4a6ff7..562fbe579639b7dd64e897d0f88fd23e492ac058 100644 +index a0c06e539088c6521793ecf9ba8d54311c4a6ff7..90c21bfc045df5c43dfa1d5305df28acb7d1123f 100644 --- a/ui/display/mac/screen_mac.mm +++ b/ui/display/mac/screen_mac.mm @@ -269,7 +269,17 @@ DisplayMac BuildDisplayForScreen(NSScreen* screen) { display.set_color_depth(Display::kDefaultBitsPerPixel); display.set_depth_per_component(Display::kDefaultBitsPerComponent); } -+#ifdef MAS_BUILD ++#if IS_MAS_BUILD() + // This is equivalent to the CGDisplayUsesForceToGray() API as at 2018-08-06, + // but avoids usage of the private API. + CFStringRef app = CFSTR(""com.apple.CoreGraphics""); diff --git a/patches/chromium/mas_avoid_usage_of_private_macos_apis.patch b/patches/chromium/mas_avoid_usage_of_private_macos_apis.patch index a627f985fd..141b7dfd97 100644 --- a/patches/chromium/mas_avoid_usage_of_private_macos_apis.patch +++ b/patches/chromium/mas_avoid_usage_of_private_macos_apis.patch @@ -14,14 +14,14 @@ Disable usage of the following private APIs in MAS builds: * AudioDeviceDuck diff --git a/base/enterprise_util_mac.mm b/base/enterprise_util_mac.mm -index 91a65a1e700cf1accb8e4541e0ceca4e0a734b16..a41df69515e421b629aa6dc82e296c3a3bb04f8e 100644 +index 91a65a1e700cf1accb8e4541e0ceca4e0a734b16..323b9b48214aa013ad8f7da2f63cca2ee3295d68 100644 --- a/base/enterprise_util_mac.mm +++ b/base/enterprise_util_mac.mm @@ -189,6 +189,13 @@ MacDeviceManagementStateNew IsDeviceRegisteredWithManagementNew() { DeviceUserDomainJoinState AreDeviceAndUserJoinedToDomain() { static DeviceUserDomainJoinState state = [] { DeviceUserDomainJoinState state{false, false}; -+#if defined(MAS_BUILD) ++#if IS_MAS_BUILD() + return state; + }(); + @@ -76,14 +76,14 @@ index e38a02b3f0eed139653eaa82b6a09167b8658d81..071e699b23b99abd96a8a1ef2acbdca5 if ([ns_val isKindOfClass:[NSFont class]]) { return (CTFontRef)(cf_val); diff --git a/base/process/launch_mac.cc b/base/process/launch_mac.cc -index f860be6fbb6caf166f4808772a490ebba9cd7f08..20cead8c65f109fd74669bf647486132055e9860 100644 +index f860be6fbb6caf166f4808772a490ebba9cd7f08..d1b588346e106b032045b1a33ccc469c479b8f03 100644 --- a/base/process/launch_mac.cc +++ b/base/process/launch_mac.cc @@ -19,14 +19,19 @@ #include ""base/threading/scoped_blocking_call.h"" #include ""base/threading/thread_restrictions.h"" #include ""base/trace_event/base_tracing.h"" -+#if defined(MAS_BUILD) ++#if IS_MAS_BUILD() +#include +#endif @@ -92,7 +92,7 @@ index f860be6fbb6caf166f4808772a490ebba9cd7f08..20cead8c65f109fd74669bf647486132 // descriptor. libpthread only exposes a syscall wrapper starting in // macOS 10.12, but the system call dates back to macOS 10.5. On older OSes, // the syscall is issued directly. -+#if !defined(MAS_BUILD) ++#if !IS_MAS_BUILD() int pthread_chdir_np(const char* dir) API_AVAILABLE(macosx(10.12)); int pthread_fchdir_np(int fd) API_AVAILABLE(macosx(10.12)); +#endif @@ -103,7 +103,7 @@ index f860be6fbb6caf166f4808772a490ebba9cd7f08..20cead8c65f109fd74669bf647486132 }; int ChangeCurrentThreadDirectory(const char* path) { -+#if defined(MAS_BUILD) ++#if IS_MAS_BUILD() + #pragma clang diagnostic push + #pragma clang diagnostic ignored ""-Wdeprecated-declarations"" + return syscall(SYS___pthread_chdir, path); @@ -116,7 +116,7 @@ index f860be6fbb6caf166f4808772a490ebba9cd7f08..20cead8c65f109fd74669bf647486132 // The recommended way to unset a per-thread cwd is to set a new value to an // invalid file descriptor, per libpthread-218.1.3/private/private.h. int ResetCurrentThreadDirectory() { -+#if defined(MAS_BUILD) ++#if IS_MAS_BUILD() + #pragma clang diagnostic push + #pragma clang diagnostic ignored ""-Wdeprecated-declarations"" + return syscall(SYS___pthread_fchdir, -1); @@ -142,14 +142,14 @@ index f860be6fbb6caf166f4808772a490ebba9cd7f08..20cead8c65f109fd74669bf647486132 std::vector argv_cstr; argv_cstr.reserve(argv.size() + 1); diff --git a/media/audio/mac/audio_low_latency_input_mac.cc b/media/audio/mac/audio_low_latency_input_mac.cc -index 751b723388f78a314e2af9c0ec0205f3bd4b6d77..248fe5fc47bb94bf18a96700a5aaca0c516c39b8 100644 +index 751b723388f78a314e2af9c0ec0205f3bd4b6d77..ee89452b8af1a372b208403ad5a1d4dadd7f0165 100644 --- a/media/audio/mac/audio_low_latency_input_mac.cc +++ b/media/audio/mac/audio_low_latency_input_mac.cc @@ -34,19 +34,23 @@ namespace { extern ""C"" { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // See: // https://trac.webkit.org/browser/webkit/trunk/Source/WebCore/PAL/pal/spi/cf/CoreAudioSPI.h?rev=228264 OSStatus AudioDeviceDuck(AudioDeviceID inDevice, @@ -160,7 +160,7 @@ index 751b723388f78a314e2af9c0ec0205f3bd4b6d77..248fe5fc47bb94bf18a96700a5aaca0c } void UndoDucking(AudioDeviceID output_device_id) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() if (AudioDeviceDuck != nullptr) { // Ramp the volume back up over half a second. AudioDeviceDuck(output_device_id, 1.0, nullptr, 0.5); @@ -170,14 +170,14 @@ index 751b723388f78a314e2af9c0ec0205f3bd4b6d77..248fe5fc47bb94bf18a96700a5aaca0c } // namespace diff --git a/sandbox/mac/sandbox_logging.cc b/sandbox/mac/sandbox_logging.cc -index f52f1d1da4d431505b1a55df4764f37a70e0b29d..ebc15064d0d0e97dfab7fc82b99254556b050eb2 100644 +index f52f1d1da4d431505b1a55df4764f37a70e0b29d..2406f5d4342dafc0d2c398f03ac23907a55c929f 100644 --- a/sandbox/mac/sandbox_logging.cc +++ b/sandbox/mac/sandbox_logging.cc @@ -32,9 +32,11 @@ } #endif -+#if !defined(MAS_BUILD) ++#if !IS_MAS_BUILD() extern ""C"" { void abort_report_np(const char*, ...); } @@ -189,7 +189,7 @@ index f52f1d1da4d431505b1a55df4764f37a70e0b29d..ebc15064d0d0e97dfab7fc82b9925455 os_log_with_type(log.get(), os_log_type, ""%{public}s"", message); -+#if !defined(MAS_BUILD) ++#if !IS_MAS_BUILD() if (level == Level::FATAL) { abort_report_np(message); } @@ -198,14 +198,14 @@ index f52f1d1da4d431505b1a55df4764f37a70e0b29d..ebc15064d0d0e97dfab7fc82b9925455 // |error| is strerror(errno) when a P* logging function is called. Pass diff --git a/sandbox/mac/system_services.cc b/sandbox/mac/system_services.cc -index 92b84121da46b692b89f70a46e36f5d1991383b8..8e5f05bb012b622e27f41b7c6327f70959dd9731 100644 +index 92b84121da46b692b89f70a46e36f5d1991383b8..8de2556bb59c70f229d35da05fd0718ba81696b5 100644 --- a/sandbox/mac/system_services.cc +++ b/sandbox/mac/system_services.cc @@ -9,6 +9,7 @@ #include ""base/mac/mac_logging.h"" -+#if !defined(MAS_BUILD) ++#if !IS_MAS_BUILD() extern ""C"" { OSStatus SetApplicationIsDaemon(Boolean isDaemon); void _LSSetApplicationLaunchServicesServerConnectionStatus( @@ -218,7 +218,7 @@ index 92b84121da46b692b89f70a46e36f5d1991383b8..8e5f05bb012b622e27f41b7c6327f709 namespace sandbox { void DisableLaunchServices() { -+ #if !defined(MAS_BUILD) ++ #if !IS_MAS_BUILD() // Allow the process to continue without a LaunchServices ASN. The // INIT_Process function in HIServices will abort if it cannot connect to // launchservicesd to get an ASN. By setting this flag, HIServices skips @@ -230,7 +230,7 @@ index 92b84121da46b692b89f70a46e36f5d1991383b8..8e5f05bb012b622e27f41b7c6327f709 } void DisableCoreServicesCheckFix() { -+#if !defined(MAS_BUILD) ++#if !IS_MAS_BUILD() if (__builtin_available(macOS 10.15, *)) { _CSCheckFixDisable(); } diff --git a/patches/chromium/mas_blink_no_private_api.patch b/patches/chromium/mas_blink_no_private_api.patch index 9b285d9b9e..e276a4f292 100644 --- a/patches/chromium/mas_blink_no_private_api.patch +++ b/patches/chromium/mas_blink_no_private_api.patch @@ -7,14 +7,14 @@ Guard usages in chromium code of private Mac APIs by MAS_BUILD, so they can be excluded for people who want to submit their apps to the Mac App store. diff --git a/third_party/blink/renderer/core/editing/kill_ring_mac.mm b/third_party/blink/renderer/core/editing/kill_ring_mac.mm -index 94afefcee81b87c05bf9b1199d90d3d4b5ea84a6..2ec7f04c71824b47de1ddbf1f0e8625d33e833a8 100644 +index 94afefcee81b87c05bf9b1199d90d3d4b5ea84a6..78e4e0fe20e0fdfeab18b28fe208d5aa38eb0bd1 100644 --- a/third_party/blink/renderer/core/editing/kill_ring_mac.mm +++ b/third_party/blink/renderer/core/editing/kill_ring_mac.mm @@ -27,6 +27,7 @@ namespace blink { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() extern ""C"" { // Kill ring calls. Would be better to use NSKillRing.h, but that's not @@ -28,7 +28,7 @@ index 94afefcee81b87c05bf9b1199d90d3d4b5ea84a6..2ec7f04c71824b47de1ddbf1f0e8625d static bool initialized_kill_ring = false; if (!initialized_kill_ring) { initialized_kill_ring = true; -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() _NSInitializeKillRing(); +#endif } @@ -36,21 +36,21 @@ index 94afefcee81b87c05bf9b1199d90d3d4b5ea84a6..2ec7f04c71824b47de1ddbf1f0e8625d void KillRing::Append(const String& string) { InitializeKillRingIfNeeded(); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() _NSAppendToKillRing(string); +#endif } void KillRing::Prepend(const String& string) { InitializeKillRingIfNeeded(); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() _NSPrependToKillRing(string); +#endif } String KillRing::Yank() { InitializeKillRingIfNeeded(); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() return _NSYankFromKillRing(); +#else + return """"; @@ -59,14 +59,14 @@ index 94afefcee81b87c05bf9b1199d90d3d4b5ea84a6..2ec7f04c71824b47de1ddbf1f0e8625d void KillRing::StartNewSequence() { InitializeKillRingIfNeeded(); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() _NSNewKillRingSequence(); +#endif } void KillRing::SetToYankedState() { InitializeKillRingIfNeeded(); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() _NSSetKillRingToYankedState(); +#endif } diff --git a/patches/chromium/mas_disable_custom_window_frame.patch b/patches/chromium/mas_disable_custom_window_frame.patch index 50dd6b45e2..5db40e5348 100644 --- a/patches/chromium/mas_disable_custom_window_frame.patch +++ b/patches/chromium/mas_disable_custom_window_frame.patch @@ -7,14 +7,14 @@ Disable private window frame APIs (NSNextStepFrame and NSThemeFrame) for MAS build. diff --git a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm -index 6e116d634c658ff26f6990fae5fcac975285e865..5beceecf8e0d712b69eefeba939c6fa524b7e363 100644 +index 6e116d634c658ff26f6990fae5fcac975285e865..8c034acee912b26c187d0da7e1d9e68fa6abb5b6 100644 --- a/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm +++ b/components/remote_cocoa/app_shim/browser_native_widget_window_mac.mm @@ -9,6 +9,7 @@ #include ""components/remote_cocoa/app_shim/native_widget_ns_window_bridge.h"" #include ""components/remote_cocoa/common/native_widget_ns_window_host.mojom.h"" -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() @interface NSWindow (PrivateBrowserNativeWidgetAPI) + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle; @end @@ -28,7 +28,7 @@ index 6e116d634c658ff26f6990fae5fcac975285e865..5beceecf8e0d712b69eefeba939c6fa5 // NSWindow (PrivateAPI) overrides. -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle { // - NSThemeFrame and its subclasses will be nil if it's missing at runtime. if ([BrowserWindowFrame class]) @@ -42,14 +42,14 @@ index 6e116d634c658ff26f6990fae5fcac975285e865..5beceecf8e0d712b69eefeba939c6fa5 // Keyboard -> Shortcuts -> Keyboard. Usually Ctrl+F5. The argument (|unknown|) // tends to just be nil. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm -index 3a815ebf505bd95fa7f6b61ba433d98fbfe20225..8584b6b09323a9e100841dcde9a963b48e84b518 100644 +index 3a815ebf505bd95fa7f6b61ba433d98fbfe20225..dbbebbdc1735bc14224dfcde0b7fe3a6fd9f9e40 100644 --- a/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm +++ b/components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.mm @@ -4,6 +4,8 @@ #import ""components/remote_cocoa/app_shim/native_widget_mac_frameless_nswindow.h"" -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() + @interface NSWindow (PrivateAPI) + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle; @@ -62,7 +62,7 @@ index 3a815ebf505bd95fa7f6b61ba433d98fbfe20225..8584b6b09323a9e100841dcde9a963b4 + @implementation NativeWidgetMacFramelessNSWindow -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() + + (Class)frameViewClassForStyleMask:(NSUInteger)windowStyle { if ([NativeWidgetMacFramelessNSWindowFrame class]) { @@ -75,14 +75,14 @@ index 3a815ebf505bd95fa7f6b61ba433d98fbfe20225..8584b6b09323a9e100841dcde9a963b4 + @end diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h -index e7bf48ba670dbe8fa2a8688cf89e74a7d15cc6a3..5596703bbae1977c9c2bcd421373c578ca9780cb 100644 +index e7bf48ba670dbe8fa2a8688cf89e74a7d15cc6a3..f385de06d8b33aafa0eac1858d9fd23347f64594 100644 --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.h @@ -17,6 +17,7 @@ class NativeWidgetNSWindowBridge; @protocol WindowTouchBarDelegate; -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // Weak lets Chrome launch even if a future macOS doesn't have the below classes WEAK_IMPORT_ATTRIBUTE @interface NSNextStepFrame : NSView @@ -95,14 +95,14 @@ index e7bf48ba670dbe8fa2a8688cf89e74a7d15cc6a3..5596703bbae1977c9c2bcd421373c578 // The NSWindow used by BridgedNativeWidget. Provides hooks into AppKit that // can only be accomplished by overriding methods. diff --git a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm -index 0cf281aff32bd37b3539056ea202aa74ef432000..f65046706dc0e05f7d654ea96901fdeee268a445 100644 +index 0cf281aff32bd37b3539056ea202aa74ef432000..9b070697f5243ae25f50aa9f681cec57128da5cf 100644 --- a/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm +++ b/components/remote_cocoa/app_shim/native_widget_mac_nswindow.mm @@ -97,7 +97,9 @@ void OrderChildWindow(NSWindow* child_window, } // namespace @interface NSWindow (Private) -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle; +#endif - (BOOL)hasKeyAppearance; @@ -112,7 +112,7 @@ index 0cf281aff32bd37b3539056ea202aa74ef432000..f65046706dc0e05f7d654ea96901fdee } @end -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() + @implementation NativeWidgetMacNSWindowTitledFrame - (void)mouseDown:(NSEvent*)event { @@ -130,7 +130,7 @@ index 0cf281aff32bd37b3539056ea202aa74ef432000..f65046706dc0e05f7d654ea96901fdee // NSWindow overrides. -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() + + (Class)frameViewClassForStyleMask:(NSWindowStyleMask)windowStyle { if (windowStyle & NSWindowStyleMaskTitled) { diff --git a/patches/chromium/mas_disable_remote_accessibility.patch b/patches/chromium/mas_disable_remote_accessibility.patch index 6f358c0548..c79e022d2b 100644 --- a/patches/chromium/mas_disable_remote_accessibility.patch +++ b/patches/chromium/mas_disable_remote_accessibility.patch @@ -11,14 +11,14 @@ needs to think it's coming from the PWA process). I think it can just be chopped out -- if there are any side-effects, we should be able to work around them. diff --git a/components/remote_cocoa/app_shim/application_bridge.mm b/components/remote_cocoa/app_shim/application_bridge.mm -index 89b9323c08cfed0d3ea3a0ec1beaa0bdfabe343e..d000b7f43f393d297a3715ea4279537bcf3fa813 100644 +index 89b9323c08cfed0d3ea3a0ec1beaa0bdfabe343e..69ae95eb8537bab751d27749d6cf392a8419f317 100644 --- a/components/remote_cocoa/app_shim/application_bridge.mm +++ b/components/remote_cocoa/app_shim/application_bridge.mm @@ -51,6 +51,7 @@ // NativeWidgetNSWindowHostHelper: id GetNativeViewAccessible() override { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() if (!remote_accessibility_element_) { base::ProcessId browser_pid = base::kNullProcessId; std::vector element_token; @@ -36,7 +36,7 @@ index 89b9323c08cfed0d3ea3a0ec1beaa0bdfabe343e..d000b7f43f393d297a3715ea4279537b mojo::AssociatedRemote text_input_host_remote_; std::unique_ptr bridge_; -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() base::scoped_nsobject remote_accessibility_element_; +#endif @@ -44,14 +44,14 @@ index 89b9323c08cfed0d3ea3a0ec1beaa0bdfabe343e..d000b7f43f393d297a3715ea4279537b } // namespace diff --git a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm -index 1b91b71bae8201d7cae5850a8c810bd179a36ab1..7f4bc1ded505067ba83001b389ab5813bad17dc4 100644 +index 1b91b71bae8201d7cae5850a8c810bd179a36ab1..f010b3565f81ecb692269d778822b31f9cbfe585 100644 --- a/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm +++ b/components/remote_cocoa/app_shim/native_widget_ns_window_bridge.mm @@ -566,10 +566,12 @@ NSUInteger CountBridgedWindows(NSArray* child_windows) { // this should be treated as an error and caught early. CHECK(bridged_view_); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // Send the accessibility tokens for the NSView now that it exists. host_->SetRemoteAccessibilityTokens( ui::RemoteAccessibility::GetTokenForLocalElement(window_), @@ -61,14 +61,14 @@ index 1b91b71bae8201d7cae5850a8c810bd179a36ab1..7f4bc1ded505067ba83001b389ab5813 // Beware: This view was briefly removed (in favor of a bare CALayer) in // crrev/c/1236675. The ordering of unassociated layers relative to NSView diff --git a/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm b/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm -index abd19b8613e52a6f4c9404f509ab7ed5a61046a6..35945493a02996e88b0c53caf107c4352450aff7 100644 +index abd19b8613e52a6f4c9404f509ab7ed5a61046a6..8c69b989882084946bb821e1d64d75657f17ab26 100644 --- a/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm +++ b/content/app_shim_remote_cocoa/ns_view_bridge_factory_impl.mm @@ -77,6 +77,7 @@ explicit RenderWidgetHostNSViewBridgeOwner( // RenderWidgetHostNSViewHostHelper implementation. id GetAccessibilityElement() override { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() if (!remote_accessibility_element_) { base::ProcessId browser_pid = base::kNullProcessId; std::vector element_token; @@ -86,7 +86,7 @@ index abd19b8613e52a6f4c9404f509ab7ed5a61046a6..35945493a02996e88b0c53caf107c435 return nil; } void SetAccessibilityWindow(NSWindow* window) override { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() host_->SetRemoteAccessibilityWindowToken( ui::RemoteAccessibility::GetTokenForLocalElement(window)); +#endif @@ -97,7 +97,7 @@ index abd19b8613e52a6f4c9404f509ab7ed5a61046a6..35945493a02996e88b0c53caf107c435 mojo::AssociatedRemote host_; std::unique_ptr bridge_; -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() base::scoped_nsobject remote_accessibility_element_; +#endif @@ -105,14 +105,14 @@ index abd19b8613e52a6f4c9404f509ab7ed5a61046a6..35945493a02996e88b0c53caf107c435 } diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.mm b/content/browser/accessibility/browser_accessibility_manager_mac.mm -index 67473b500bc8305bc21ec0324001ea5a64612aee..964acff055c3e192813b7793894b3fde8940facb 100644 +index 67473b500bc8305bc21ec0324001ea5a64612aee..859e45bd6f4f130947e0718e32fea4abe8fe3a8c 100644 --- a/content/browser/accessibility/browser_accessibility_manager_mac.mm +++ b/content/browser/accessibility/browser_accessibility_manager_mac.mm @@ -22,7 +22,9 @@ #include ""ui/accelerated_widget_mac/accelerated_widget_mac.h"" #include ""ui/accessibility/ax_role_properties.h"" #include ""ui/accessibility/platform/ax_private_webkit_constants_mac.h"" -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() #include ""ui/base/cocoa/remote_accessibility_api.h"" +#endif @@ -122,7 +122,7 @@ index 67473b500bc8305bc21ec0324001ea5a64612aee..964acff055c3e192813b7793894b3fde if ([NSApp isActive]) return window == [NSApp accessibilityFocusedWindow]; -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // TODO(accessibility): We need a solution to the problem described below. // If the window is NSAccessibilityRemoteUIElement, there are some challenges: // 1. NSApp is the browser which spawned the PWA, and what it considers the @@ -135,14 +135,14 @@ index 67473b500bc8305bc21ec0324001ea5a64612aee..964acff055c3e192813b7793894b3fde return false; } diff --git a/content/browser/renderer_host/render_widget_host_view_mac.h b/content/browser/renderer_host/render_widget_host_view_mac.h -index c1f2725cf74fe8845843461518a849f2cbf2c024..897f46a7333eb80c8fe54535f6159dc1350d2d64 100644 +index c1f2725cf74fe8845843461518a849f2cbf2c024..c9f489a8603a63dc2641fbd435c4ab1de9fafbd3 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.h +++ b/content/browser/renderer_host/render_widget_host_view_mac.h @@ -52,7 +52,9 @@ class ScopedPasswordInputEnabler; @protocol RenderWidgetHostViewMacDelegate; -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() @class NSAccessibilityRemoteUIElement; +#endif @class RenderWidgetHostViewCocoa; @@ -152,7 +152,7 @@ index c1f2725cf74fe8845843461518a849f2cbf2c024..897f46a7333eb80c8fe54535f6159dc1 // EnsureSurfaceSynchronizedForWebTest(). uint32_t latest_capture_sequence_number_ = 0u; -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // Remote accessibility objects corresponding to the NSWindow that this is // displayed to the user in. base::scoped_nsobject @@ -162,14 +162,14 @@ index c1f2725cf74fe8845843461518a849f2cbf2c024..897f46a7333eb80c8fe54535f6159dc1 // Used to force the NSApplication's focused accessibility element to be the // content::BrowserAccessibilityCocoa accessibility tree when the NSView for diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm -index f2cd4583734aab9a6760f357eb6fb9ce73d96753..a420b3cf9b1c325967318db322d61c4ebc4cf7c6 100644 +index f2cd4583734aab9a6760f357eb6fb9ce73d96753..cc2836fb66d9cf84fa298f1d75480f2c796b274f 100644 --- a/content/browser/renderer_host/render_widget_host_view_mac.mm +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm @@ -260,8 +260,10 @@ void RenderWidgetHostViewMac::MigrateNSViewBridge( remote_cocoa::mojom::Application* remote_cocoa_application, uint64_t parent_ns_view_id) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // Destroy the previous remote accessibility element. remote_window_accessible_.reset(); +#endif @@ -180,7 +180,7 @@ index f2cd4583734aab9a6760f357eb6fb9ce73d96753..a420b3cf9b1c325967318db322d61c4e gfx::NativeViewAccessible RenderWidgetHostViewMac::AccessibilityGetNativeViewAccessibleForWindow() { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() if (remote_window_accessible_) return remote_window_accessible_.get(); +#endif @@ -191,7 +191,7 @@ index f2cd4583734aab9a6760f357eb6fb9ce73d96753..a420b3cf9b1c325967318db322d61c4e } void RenderWidgetHostViewMac::SetAccessibilityWindow(NSWindow* window) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // When running in-process, just use the NSView's NSWindow as its own // accessibility element. remote_window_accessible_.reset(); @@ -203,7 +203,7 @@ index f2cd4583734aab9a6760f357eb6fb9ce73d96753..a420b3cf9b1c325967318db322d61c4e void RenderWidgetHostViewMac::GetRenderWidgetAccessibilityToken( GetRenderWidgetAccessibilityTokenCallback callback) { base::ProcessId pid = getpid(); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() id element_id = GetNativeViewAccessible(); std::vector token = ui::RemoteAccessibility::GetTokenForLocalElement(element_id); @@ -215,7 +215,7 @@ index f2cd4583734aab9a6760f357eb6fb9ce73d96753..a420b3cf9b1c325967318db322d61c4e void RenderWidgetHostViewMac::SetRemoteAccessibilityWindowToken( const std::vector& window_token) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() if (window_token.empty()) { remote_window_accessible_.reset(); } else { @@ -245,14 +245,14 @@ index 52f8e4e48b4c54dc39231dc4702dc4ce9089c520..c1cc143209fbd60a34ad1d8f92c55c94 sources += [ ""device_form_factor_ios.mm"", diff --git a/ui/base/cocoa/remote_accessibility_api.h b/ui/base/cocoa/remote_accessibility_api.h -index 4d47115d3f72da17b2ada8866770ac24717c29da..a74c655a6143a3ce9b10c6c23a508b1d306bb980 100644 +index 4d47115d3f72da17b2ada8866770ac24717c29da..506d7847d904478793d992dbe548a61177644d09 100644 --- a/ui/base/cocoa/remote_accessibility_api.h +++ b/ui/base/cocoa/remote_accessibility_api.h @@ -11,6 +11,8 @@ #include ""base/component_export.h"" #include ""base/mac/scoped_nsobject.h"" -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() + @interface NSAccessibilityRemoteUIElement : NSObject + (void)setRemoteUIApp:(BOOL)flag; @@ -265,14 +265,14 @@ index 4d47115d3f72da17b2ada8866770ac24717c29da..a74c655a6143a3ce9b10c6c23a508b1d + #endif // UI_BASE_COCOA_REMOTE_ACCESSIBILITY_API_H_ diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.h b/ui/views/cocoa/native_widget_mac_ns_window_host.h -index f6d8e8847203d705aea9f581bab84c361a6164c9..d8b17d16aaeba9e9aa95bd0e646a143b325ecc64 100644 +index f6d8e8847203d705aea9f581bab84c361a6164c9..4130f1bced39af36f9761613a1d1cbcddf922dd2 100644 --- a/ui/views/cocoa/native_widget_mac_ns_window_host.h +++ b/ui/views/cocoa/native_widget_mac_ns_window_host.h @@ -32,7 +32,9 @@ #include ""ui/views/window/dialog_observer.h"" @class NativeWidgetMacNSWindow; -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() @class NSAccessibilityRemoteUIElement; +#endif @class NSView; @@ -282,7 +282,7 @@ index f6d8e8847203d705aea9f581bab84c361a6164c9..d8b17d16aaeba9e9aa95bd0e646a143b mojo::AssociatedRemote remote_ns_window_remote_; -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // Remote accessibility objects corresponding to the NSWindow and its root // NSView. base::scoped_nsobject @@ -293,14 +293,14 @@ index f6d8e8847203d705aea9f581bab84c361a6164c9..d8b17d16aaeba9e9aa95bd0e646a143b // Used to force the NSApplication's focused accessibility element to be the // views::Views accessibility tree when the NSView for this is focused. diff --git a/ui/views/cocoa/native_widget_mac_ns_window_host.mm b/ui/views/cocoa/native_widget_mac_ns_window_host.mm -index 020c952ea07bd67b3acefe33c73e7c1aed598fea..1b67c91b499aa583bd2f7516658f7377cec62566 100644 +index 020c952ea07bd67b3acefe33c73e7c1aed598fea..3bf8849e269b62d9a5a2389b2e45433b3acf8448 100644 --- a/ui/views/cocoa/native_widget_mac_ns_window_host.mm +++ b/ui/views/cocoa/native_widget_mac_ns_window_host.mm @@ -336,14 +336,22 @@ void HandleAccelerator(const ui::Accelerator& accelerator, NativeWidgetMacNSWindowHost::GetNativeViewAccessibleForNSView() const { if (in_process_ns_window_bridge_) return in_process_ns_window_bridge_->ns_view(); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() return remote_view_accessible_.get(); +#else + return nullptr; @@ -311,7 +311,7 @@ index 020c952ea07bd67b3acefe33c73e7c1aed598fea..1b67c91b499aa583bd2f7516658f7377 NativeWidgetMacNSWindowHost::GetNativeViewAccessibleForNSWindow() const { if (in_process_ns_window_bridge_) return in_process_ns_window_bridge_->ns_window(); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() return remote_window_accessible_.get(); +#else + return nullptr; @@ -323,7 +323,7 @@ index 020c952ea07bd67b3acefe33c73e7c1aed598fea..1b67c91b499aa583bd2f7516658f7377 void NativeWidgetMacNSWindowHost::SetRemoteAccessibilityTokens( const std::vector& window_token, const std::vector& view_token) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() remote_window_accessible_ = ui::RemoteAccessibility::GetRemoteElementFromToken(window_token); remote_view_accessible_ = @@ -337,7 +337,7 @@ index 020c952ea07bd67b3acefe33c73e7c1aed598fea..1b67c91b499aa583bd2f7516658f7377 bool NativeWidgetMacNSWindowHost::GetRootViewAccessibilityToken( base::ProcessId* pid, std::vector* token) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() *pid = getpid(); id element_id = GetNativeViewAccessible(); *token = ui::RemoteAccessibility::GetTokenForLocalElement(element_id); diff --git a/patches/chromium/mas_disable_remote_layer.patch b/patches/chromium/mas_disable_remote_layer.patch index b6514613c4..e2392eddcb 100644 --- a/patches/chromium/mas_disable_remote_layer.patch +++ b/patches/chromium/mas_disable_remote_layer.patch @@ -16,14 +16,14 @@ cases where performance improves when disabling remote CoreAnimation (remote CoreAnimation is really only about battery usage). diff --git a/gpu/ipc/service/image_transport_surface_overlay_mac.h b/gpu/ipc/service/image_transport_surface_overlay_mac.h -index 54df9cd23be7441f9b61e9f94b191b3a6a7ab6fd..1ba6c4804cd98c6aa118fcd4ee74b1368648bde6 100644 +index 54df9cd23be7441f9b61e9f94b191b3a6a7ab6fd..861f6579d9fb93ab7c3741fd39eaaf8bda76ed9d 100644 --- a/gpu/ipc/service/image_transport_surface_overlay_mac.h +++ b/gpu/ipc/service/image_transport_surface_overlay_mac.h @@ -21,7 +21,9 @@ #include ""ui/gl/gl_surface_egl.h"" #endif -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() @class CAContext; +#endif @class CALayer; @@ -33,7 +33,7 @@ index 54df9cd23be7441f9b61e9f94b191b3a6a7ab6fd..1ba6c4804cd98c6aa118fcd4ee74b136 base::WeakPtr delegate_; bool use_remote_layer_api_; -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() base::scoped_nsobject ca_context_; +#endif std::unique_ptr ca_layer_tree_coordinator_; @@ -43,21 +43,21 @@ index 54df9cd23be7441f9b61e9f94b191b3a6a7ab6fd..1ba6c4804cd98c6aa118fcd4ee74b136 base::WeakPtr delegate_; bool use_remote_layer_api_; -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() base::scoped_nsobject ca_context_; +#endif std::unique_ptr ca_layer_tree_coordinator_; 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 6944ef9d099231c04e1b13e8a434ca436637ddd2..f0e64b88d0dcaff5937424c14a41552a554c2be0 100644 +index 6944ef9d099231c04e1b13e8a434ca436637ddd2..57ec91986dad4f7f18263fdc81ec877406fbee69 100644 --- a/gpu/ipc/service/image_transport_surface_overlay_mac.mm +++ b/gpu/ipc/service/image_transport_surface_overlay_mac.mm @@ -68,6 +68,7 @@ ca_layer_tree_coordinator_ = std::make_unique( use_remote_layer_api_, allow_av_sample_buffer_display_layer); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // Create the CAContext to send this to the GPU process, and the layer for // the context. if (use_remote_layer_api_) { @@ -73,7 +73,7 @@ index 6944ef9d099231c04e1b13e8a434ca436637ddd2..f0e64b88d0dcaff5937424c14a41552a ""GLImpl"", static_cast(gl::GetGLImplementation()), ""width"", pixel_size_.width()); if (use_remote_layer_api_) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() params.ca_context_id = [ca_context_ contextId]; +#endif } else { @@ -83,7 +83,7 @@ index 6944ef9d099231c04e1b13e8a434ca436637ddd2..f0e64b88d0dcaff5937424c14a41552a ca_layer_tree_coordinator_ = std::make_unique( use_remote_layer_api_, allow_av_sample_buffer_display_layer); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // Create the CAContext to send this to the GPU process, and the layer for // the context. if (use_remote_layer_api_) { @@ -99,21 +99,21 @@ index 6944ef9d099231c04e1b13e8a434ca436637ddd2..f0e64b88d0dcaff5937424c14a41552a ""GLImpl"", static_cast(gl::GetGLImplementation()), ""width"", pixel_size_.width()); if (use_remote_layer_api_) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() params.ca_context_id = [ca_context_ contextId]; +#endif } else { IOSurfaceRef io_surface = ca_layer_tree_coordinator_->GetIOSurfaceForDisplay(); diff --git a/ui/accelerated_widget_mac/display_ca_layer_tree.mm b/ui/accelerated_widget_mac/display_ca_layer_tree.mm -index 2c4821b34f71d30ce814bd1f3cf9a7a76bbaac66..cd7e0eac449bc81d5c9f6f0bed40b0d339712427 100644 +index 2c4821b34f71d30ce814bd1f3cf9a7a76bbaac66..c7dc371c780a405f502a84c77e92251ae08f66e0 100644 --- a/ui/accelerated_widget_mac/display_ca_layer_tree.mm +++ b/ui/accelerated_widget_mac/display_ca_layer_tree.mm @@ -99,6 +99,7 @@ - (void)setContentsChanged; } void DisplayCALayerTree::GotCALayerFrame(uint32_t ca_context_id) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // Early-out if the remote layer has not changed. if ([remote_layer_ contextId] == ca_context_id) return; @@ -128,14 +128,14 @@ index 2c4821b34f71d30ce814bd1f3cf9a7a76bbaac66..cd7e0eac449bc81d5c9f6f0bed40b0d3 void DisplayCALayerTree::GotIOSurfaceFrame( diff --git a/ui/base/cocoa/remote_layer_api.h b/ui/base/cocoa/remote_layer_api.h -index 9b691e2f16c68235dd180a28b6eb2eefc91f8e4c..0ce8048c6a72fe1483d71b2fd5786c28d86ac2bf 100644 +index 9b691e2f16c68235dd180a28b6eb2eefc91f8e4c..9d4a7fb36e671980024b895eaafab2d970ac2818 100644 --- a/ui/base/cocoa/remote_layer_api.h +++ b/ui/base/cocoa/remote_layer_api.h @@ -13,6 +13,7 @@ #include ""base/component_export.h"" -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // The CGSConnectionID is used to create the CAContext in the process that is // going to share the CALayers that it is rendering to another process to // display. @@ -149,14 +149,14 @@ index 9b691e2f16c68235dd180a28b6eb2eefc91f8e4c..0ce8048c6a72fe1483d71b2fd5786c28 // This function will check if all of the interfaces listed above are supported diff --git a/ui/base/cocoa/remote_layer_api.mm b/ui/base/cocoa/remote_layer_api.mm -index e23eb7719a9798afe984c6af6a422167b93d89b5..2fcc48067c2992a2fae950a678269014b7295817 100644 +index e23eb7719a9798afe984c6af6a422167b93d89b5..d448bc09ee54fc77f1ed4d088d1369b96f83a1db 100644 --- a/ui/base/cocoa/remote_layer_api.mm +++ b/ui/base/cocoa/remote_layer_api.mm @@ -10,6 +10,7 @@ namespace ui { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() namespace { // Control use of cross-process CALayers to display content directly from the // GPU process on Mac. @@ -167,7 +167,7 @@ index e23eb7719a9798afe984c6af6a422167b93d89b5..2fcc48067c2992a2fae950a678269014 +#endif bool RemoteLayerAPISupported() { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() if (!base::FeatureList::IsEnabled(kRemoteCoreAnimationAPI)) return false; diff --git a/patches/chromium/mas_no_private_api.patch b/patches/chromium/mas_no_private_api.patch index 4ece6c9b60..752403ee63 100644 --- a/patches/chromium/mas_no_private_api.patch +++ b/patches/chromium/mas_no_private_api.patch @@ -7,14 +7,14 @@ Guard usages in blink of private Mac APIs by MAS_BUILD, so they can be excluded for people who want to submit their apps to the Mac App store. diff --git a/base/process/process_info_mac.cc b/base/process/process_info_mac.cc -index 6840358c3187522c63dff66b5a85567aaadc5c12..ef94524eab52719c84e176fde2afd88f85223888 100644 +index 6840358c3187522c63dff66b5a85567aaadc5c12..72c57fbc5fbb267f96ff9e21915fb801ed5bf24e 100644 --- a/base/process/process_info_mac.cc +++ b/base/process/process_info_mac.cc @@ -9,18 +9,22 @@ #include #include -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() extern ""C"" { pid_t responsibility_get_pid_responsible_for_pid(pid_t) API_AVAILABLE(macosx(10.12)); @@ -24,7 +24,7 @@ index 6840358c3187522c63dff66b5a85567aaadc5c12..ef94524eab52719c84e176fde2afd88f namespace base { bool IsProcessSelfResponsible() { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() if (__builtin_available(macOS 10.14, *)) { const pid_t pid = getpid(); return responsibility_get_pid_responsible_for_pid(pid) == pid; @@ -34,14 +34,14 @@ index 6840358c3187522c63dff66b5a85567aaadc5c12..ef94524eab52719c84e176fde2afd88f } diff --git a/content/common/pseudonymization_salt.cc b/content/common/pseudonymization_salt.cc -index c7e4ef224e76b4df4fa08bb7fa8dd78605ea8de1..16cb4084ecc5818813022412a00a3b1acc67cc05 100644 +index c7e4ef224e76b4df4fa08bb7fa8dd78605ea8de1..8a15ee3e062e108824c6b2fadc2ffa807ff03ade 100644 --- a/content/common/pseudonymization_salt.cc +++ b/content/common/pseudonymization_salt.cc @@ -41,11 +41,13 @@ uint32_t GetPseudonymizationSalt() { uint32_t salt = g_salt.load(); if (salt == 0) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() #if DCHECK_IS_ON() // Only the Browser process needs to initialize the `salt` on demand. // Other processes (identified via the IsProcessSandboxed heuristic) should @@ -52,14 +52,14 @@ index c7e4ef224e76b4df4fa08bb7fa8dd78605ea8de1..16cb4084ecc5818813022412a00a3b1a salt = InitializeSalt(); } diff --git a/content/renderer/renderer_main_platform_delegate_mac.mm b/content/renderer/renderer_main_platform_delegate_mac.mm -index add9345fdd076698fc7ec654d7ef1701699639a4..13e615dbbe0fca71acea1f494944262933843f40 100644 +index add9345fdd076698fc7ec654d7ef1701699639a4..ea5287cbe878014e4f0f6124a459bef225b0ca59 100644 --- a/content/renderer/renderer_main_platform_delegate_mac.mm +++ b/content/renderer/renderer_main_platform_delegate_mac.mm @@ -10,9 +10,11 @@ #include ""sandbox/mac/seatbelt.h"" #include ""sandbox/mac/system_services.h"" -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() extern ""C"" { CGError CGSSetDenyWindowServerConnections(bool); } @@ -71,7 +71,7 @@ index add9345fdd076698fc7ec654d7ef1701699639a4..13e615dbbe0fca71acea1f4949442629 // verifies there are no existing open connections), and then indicates that // Chrome should continue execution without access to launchservicesd. void DisableSystemServices() { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // Tell the WindowServer that we don't want to make any future connections. // This will return Success as long as there are no open connections, which // is what we want. @@ -84,7 +84,7 @@ index add9345fdd076698fc7ec654d7ef1701699639a4..13e615dbbe0fca71acea1f4949442629 } // namespace diff --git a/content/renderer/theme_helper_mac.mm b/content/renderer/theme_helper_mac.mm -index f50448237c40710e25644c2f7d44e8d0bc0789c8..fd351c916993a8950b595c103f3f5a4086d5480b 100644 +index f50448237c40710e25644c2f7d44e8d0bc0789c8..752b575cf341546bdcc46e6dfff28fe4c66325b3 100644 --- a/content/renderer/theme_helper_mac.mm +++ b/content/renderer/theme_helper_mac.mm @@ -7,11 +7,11 @@ @@ -92,7 +92,7 @@ index f50448237c40710e25644c2f7d44e8d0bc0789c8..fd351c916993a8950b595c103f3f5a40 #include ""base/strings/sys_string_conversions.h"" - -+#if !defined(MAS_BUILD) ++#if !IS_MAS_BUILD() extern ""C"" { bool CGFontRenderingGetFontSmoothingDisabled(void) API_AVAILABLE(macos(10.14)); } @@ -105,7 +105,7 @@ index f50448237c40710e25644c2f7d44e8d0bc0789c8..fd351c916993a8950b595c103f3f5a40 bool IsSubpixelAntialiasingAvailable() { if (__builtin_available(macOS 10.14, *)) { // See https://trac.webkit.org/changeset/239306/webkit for more info. -+#if !defined(MAS_BUILD) ++#if !IS_MAS_BUILD() return !CGFontRenderingGetFontSmoothingDisabled(); +#else + NSUserDefaults* defaults = [NSUserDefaults standardUserDefaults]; @@ -122,14 +122,14 @@ index f50448237c40710e25644c2f7d44e8d0bc0789c8..fd351c916993a8950b595c103f3f5a40 } diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm -index 644990412b4d67789faffc65c4f1114fa96c8f42..085ceafcda3f66b27cec2aedde86ac7ca23fcf8f 100644 +index 644990412b4d67789faffc65c4f1114fa96c8f42..7ecbfbff3ac73157a3eac371c673ea80b55c619b 100644 --- a/device/bluetooth/bluetooth_adapter_mac.mm +++ b/device/bluetooth/bluetooth_adapter_mac.mm @@ -43,6 +43,7 @@ #include ""device/bluetooth/bluetooth_socket_mac.h"" #include ""device/bluetooth/public/cpp/bluetooth_address.h"" -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() extern ""C"" { // Undocumented IOBluetooth Preference API [1]. Used by `blueutil` [2] and // `Karabiner` [3] to programmatically control the Bluetooth state. Calling the @@ -145,7 +145,7 @@ index 644990412b4d67789faffc65c4f1114fa96c8f42..085ceafcda3f66b27cec2aedde86ac7c : controller_state_function_( base::BindRepeating(&BluetoothAdapterMac::GetHostControllerState, base::Unretained(this))), -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() power_state_function_( base::BindRepeating(IOBluetoothPreferenceSetControllerPowerState)), +#endif @@ -156,7 +156,7 @@ index 644990412b4d67789faffc65c4f1114fa96c8f42..085ceafcda3f66b27cec2aedde86ac7c } bool BluetoothAdapterMac::SetPoweredImpl(bool powered) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() power_state_function_.Run(base::strict_cast(powered)); return true; +#else @@ -196,7 +196,7 @@ index f2e38845218fe585085ca4ad9dc364ce2fdf3546..516bd4ae829d67e9d53b783671a2f603 } diff --git a/net/dns/dns_config_service_posix.cc b/net/dns/dns_config_service_posix.cc -index a8a223d1d9ea6de51a27f148c008ee8be38af29a..7413277bd91e7a08042fc957f89112fcb53d440c 100644 +index a8a223d1d9ea6de51a27f148c008ee8be38af29a..328200858bd7aa4077bf6824bfc1367bda748920 100644 --- a/net/dns/dns_config_service_posix.cc +++ b/net/dns/dns_config_service_posix.cc @@ -130,8 +130,8 @@ class DnsConfigServicePosix::Watcher : public DnsConfigService::Watcher { @@ -205,7 +205,7 @@ index a8a223d1d9ea6de51a27f148c008ee8be38af29a..7413277bd91e7a08042fc957f89112fc CheckOnCorrectSequence(); - bool success = true; -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() if (!config_watcher_.Watch(base::BindRepeating(&Watcher::OnConfigChanged, base::Unretained(this)))) { LOG(ERROR) << ""DNS config watch failed to start.""; @@ -218,14 +218,14 @@ index a8a223d1d9ea6de51a27f148c008ee8be38af29a..7413277bd91e7a08042fc957f89112fc } diff --git a/sandbox/mac/sandbox_compiler.cc b/sandbox/mac/sandbox_compiler.cc -index 5db411212b62b583ae26e9ecd0a87ad5fc5504e8..d5feedb02900a2a323b8a3961b1de21734ad1b65 100644 +index 5db411212b62b583ae26e9ecd0a87ad5fc5504e8..2778852a1573ca5d573018171caeadf1e89f3b9e 100644 --- a/sandbox/mac/sandbox_compiler.cc +++ b/sandbox/mac/sandbox_compiler.cc @@ -28,6 +28,7 @@ bool SandboxCompiler::InsertStringParam(const std::string& key, } bool SandboxCompiler::CompileAndApplyProfile(std::string* error) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() char* error_internal = nullptr; std::vector params; @@ -238,14 +238,14 @@ index 5db411212b62b583ae26e9ecd0a87ad5fc5504e8..d5feedb02900a2a323b8a3961b1de217 } diff --git a/sandbox/mac/seatbelt.cc b/sandbox/mac/seatbelt.cc -index 1e75790d60789746073828cc22d3863b35ab6f95..68e68bb1bd0b5c897bf385911ab36f5562563974 100644 +index 1e75790d60789746073828cc22d3863b35ab6f95..08fa6b16d09e2ceb73094639fa81570202123178 100644 --- a/sandbox/mac/seatbelt.cc +++ b/sandbox/mac/seatbelt.cc @@ -64,7 +64,11 @@ void Seatbelt::FreeError(char* errorbuf) { // static bool Seatbelt::IsSandboxed() { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() return ::sandbox_check(getpid(), NULL, 0); +#else + return true; @@ -254,14 +254,14 @@ index 1e75790d60789746073828cc22d3863b35ab6f95..68e68bb1bd0b5c897bf385911ab36f55 } // namespace sandbox diff --git a/sandbox/mac/seatbelt_extension.cc b/sandbox/mac/seatbelt_extension.cc -index 18479382a277cb2b25626ec8d31442bfd1377ee6..b048bb27eee1001c2bc34092220150d312ca61c6 100644 +index 18479382a277cb2b25626ec8d31442bfd1377ee6..7d80d7fa8337523c3a70f317f883f0cc26c6f40b 100644 --- a/sandbox/mac/seatbelt_extension.cc +++ b/sandbox/mac/seatbelt_extension.cc @@ -11,6 +11,7 @@ #include ""base/notreached.h"" #include ""sandbox/mac/seatbelt_extension_token.h"" -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // libsandbox private API. extern ""C"" { extern const char* APP_SANDBOX_READ; @@ -277,7 +277,7 @@ index 18479382a277cb2b25626ec8d31442bfd1377ee6..b048bb27eee1001c2bc34092220150d3 bool SeatbeltExtension::Consume() { DCHECK(!token_.empty()); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() handle_ = sandbox_extension_consume(token_.c_str()); +#else + handle_ = -1; @@ -289,7 +289,7 @@ index 18479382a277cb2b25626ec8d31442bfd1377ee6..b048bb27eee1001c2bc34092220150d3 } bool SeatbeltExtension::Revoke() { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() int rv = sandbox_extension_release(handle_); +#else + int rv = -1; @@ -301,7 +301,7 @@ index 18479382a277cb2b25626ec8d31442bfd1377ee6..b048bb27eee1001c2bc34092220150d3 char* SeatbeltExtension::IssueToken(SeatbeltExtension::Type type, const std::string& resource) { switch (type) { -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() case FILE_READ: return sandbox_extension_issue_file(APP_SANDBOX_READ, resource.c_str(), 0); @@ -313,14 +313,14 @@ index 18479382a277cb2b25626ec8d31442bfd1377ee6..b048bb27eee1001c2bc34092220150d3 NOTREACHED(); return nullptr; diff --git a/ui/accessibility/platform/inspect/ax_transform_mac.mm b/ui/accessibility/platform/inspect/ax_transform_mac.mm -index fe043e6dc2203a9054ae367b70a3854b8560c9c7..8d8ba5065d3c50263650eb2452a0f81449d40a25 100644 +index fe043e6dc2203a9054ae367b70a3854b8560c9c7..6cc51d9df176512f6f296e0eb82bc31b5a9515fa 100644 --- a/ui/accessibility/platform/inspect/ax_transform_mac.mm +++ b/ui/accessibility/platform/inspect/ax_transform_mac.mm @@ -88,6 +88,7 @@ } } -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() // AXTextMarker if (IsAXTextMarker(value)) { return AXTextMarkerToBaseValue(value, indexer); diff --git a/patches/chromium/mas_use_public_apis_to_determine_if_a_font_is_a_system_font.patch b/patches/chromium/mas_use_public_apis_to_determine_if_a_font_is_a_system_font.patch index 5ca4d856fa..b7a1074430 100644 --- a/patches/chromium/mas_use_public_apis_to_determine_if_a_font_is_a_system_font.patch +++ b/patches/chromium/mas_use_public_apis_to_determine_if_a_font_is_a_system_font.patch @@ -9,14 +9,14 @@ system font by checking if it's kCTFontPriorityAttribute is set to system priority. diff --git a/ui/gfx/platform_font_mac.mm b/ui/gfx/platform_font_mac.mm -index b9858f5c8d9abcdea0ef40d8b0bc9c2606e977f5..72ffad13176771955f24b81bf73cf1d40faed56d 100644 +index b9858f5c8d9abcdea0ef40d8b0bc9c2606e977f5..e4a7f4ac33e113270ebdd17633b9c345619447d2 100644 --- a/ui/gfx/platform_font_mac.mm +++ b/ui/gfx/platform_font_mac.mm @@ -25,9 +25,11 @@ using Weight = Font::Weight; -+#if !defined(MAS_BUILD) ++#if !IS_MAS_BUILD() extern ""C"" { bool CTFontDescriptorIsSystemUIFont(CTFontDescriptorRef); } @@ -28,7 +28,7 @@ index b9858f5c8d9abcdea0ef40d8b0bc9c2606e977f5..72ffad13176771955f24b81bf73cf1d4 // TODO(avi, etienneb): Figure out this font stuff. base::ScopedCFTypeRef descriptor( CTFontCopyFontDescriptor(font)); -+#if defined(MAS_BUILD) ++#if IS_MAS_BUILD() + CFNumberRef priority = (CFNumberRef)CTFontDescriptorCopyAttribute(descriptor.get(), (CFStringRef)kCTFontPriorityAttribute); + SInt64 v; + if (CFNumberGetValue(priority, kCFNumberSInt64Type, &v) && v == kCTFontPrioritySystem) { diff --git a/patches/chromium/render_widget_host_view_mac.patch b/patches/chromium/render_widget_host_view_mac.patch index e9c8e40de4..c1a16a5551 100644 --- a/patches/chromium/render_widget_host_view_mac.patch +++ b/patches/chromium/render_widget_host_view_mac.patch @@ -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 22b03d5bd27f09731a3c2d6dbb03c7dc612a2975..274a7e784af522b8f58c36095ca6c0cdadb97671 100644 +index 22b03d5bd27f09731a3c2d6dbb03c7dc612a2975..75e6a47f6b96695f3ef3c3a599bd70cb92935623 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, @@ -65,7 +65,7 @@ index 22b03d5bd27f09731a3c2d6dbb03c7dc612a2975..274a7e784af522b8f58c36095ca6c0cd // Since this implementation doesn't have to wait any IPC calls, this doesn't // make any key-typing jank. --hbono 7/23/09 // -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() extern ""C"" { extern NSString* NSTextInputReplacementRangeAttributeName; } @@ -78,7 +78,7 @@ index 22b03d5bd27f09731a3c2d6dbb03c7dc612a2975..274a7e784af522b8f58c36095ca6c0cd NSUnderlineColorAttributeName, NSMarkedClauseSegmentAttributeName, - NSTextInputReplacementRangeAttributeName, nil]); -+#ifndef MAS_BUILD ++#if !IS_MAS_BUILD() + NSTextInputReplacementRangeAttributeName, +#endif + nil]); diff --git a/shell/app/electron_main_delegate.cc b/shell/app/electron_main_delegate.cc index 8aed325bd8..5bd5f8e56c 100644 --- a/shell/app/electron_main_delegate.cc +++ b/shell/app/electron_main_delegate.cc @@ -62,7 +62,7 @@ #include ""v8/include/v8.h"" #endif -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() #include ""components/crash/core/app/crash_switches.h"" // nogncheck #include ""components/crash/core/app/crashpad.h"" // nogncheck #include ""components/crash/core/common/crash_key.h"" @@ -301,7 +301,7 @@ absl::optional ElectronMainDelegate::BasicStartupComplete() { << "" is not supported. See https://crbug.com/638180.""; #endif -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() // In MAS build we are using --disable-remote-core-animation. // // According to ccameron: @@ -345,7 +345,7 @@ void ElectronMainDelegate::PreSandboxStartup() { process_type == ::switches::kZygoteProcess); #endif -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() crash_reporter::InitializeCrashKeys(); #endif @@ -357,7 +357,7 @@ void ElectronMainDelegate::PreSandboxStartup() { LoadResourceBundle(locale); } -#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_MAC) && !defined(MAS_BUILD)) +#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_MAC) && !IS_MAS_BUILD()) // In the main process, we wait for JS to call crashReporter.start() before // initializing crashpad. If we're in the renderer, we want to initialize it // immediately at boot. @@ -380,7 +380,7 @@ void ElectronMainDelegate::PreSandboxStartup() { } #endif -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() crash_keys::SetCrashKeysFromCommandLine(*command_line); crash_keys::SetPlatformCrashKey(); #endif diff --git a/shell/app/electron_main_mac.cc b/shell/app/electron_main_mac.cc index c817df186e..b32cb64968 100644 --- a/shell/app/electron_main_mac.cc +++ b/shell/app/electron_main_mac.cc @@ -11,7 +11,7 @@ #include ""shell/app/electron_library_main.h"" #include ""shell/app/uv_stdio_fix.h"" -#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD) +#if defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD() #include #include @@ -38,7 +38,7 @@ int main(int argc, char* argv[]) { } #endif -#if defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD) +#if defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD() uint32_t exec_path_size = 0; int rv = _NSGetExecutablePath(NULL, &exec_path_size); if (rv != -1) { @@ -65,7 +65,7 @@ int main(int argc, char* argv[]) { abort(); } } -#endif // defined(HELPER_EXECUTABLE) && !defined(MAS_BUILD) +#endif // defined(HELPER_EXECUTABLE) && !IS_MAS_BUILD return ElectronMain(argc, argv); } diff --git a/shell/app/node_main.cc b/shell/app/node_main.cc index 1c75cd0163..f1ef042242 100644 --- a/shell/app/node_main.cc +++ b/shell/app/node_main.cc @@ -34,7 +34,7 @@ #include ""chrome/child/v8_crashpad_support_win.h"" #endif -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() #include ""components/crash/core/app/crashpad.h"" // nogncheck #include ""shell/app/electron_crash_reporter_client.h"" #include ""shell/common/crash_keys.h"" @@ -86,7 +86,7 @@ int SetNodeCliFlags() { node::kDisallowedInEnvironment); } -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() void SetCrashKeyStub(const std::string& key, const std::string& value) {} void ClearCrashKeyStub(const std::string& key) {} #endif @@ -97,7 +97,7 @@ namespace electron { v8::Local GetParameters(v8::Isolate* isolate) { std::map keys; -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() electron::crash_keys::GetCrashKeys(&keys); #endif return gin::ConvertToV8(isolate, keys); @@ -113,7 +113,7 @@ int NodeMain(int argc, char* argv[]) { // TODO(deepak1556): Enable crashpad support on linux for // ELECTRON_RUN_AS_NODE processes. // Refs https://github.com/electron/electron/issues/36030 -#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_MAC) && !defined(MAS_BUILD)) +#if BUILDFLAG(IS_WIN) || (BUILDFLAG(IS_MAC) && !IS_MAS_BUILD()) ElectronCrashReporterClient::Create(); crash_reporter::InitializeCrashpad(false, ""node""); crash_keys::SetCrashKeysFromCommandLine( @@ -189,7 +189,7 @@ int NodeMain(int argc, char* argv[]) { // Setup process.crashReporter in child node processes gin_helper::Dictionary reporter = gin::Dictionary::CreateEmpty(isolate); reporter.SetMethod(""getParameters"", &GetParameters); -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() reporter.SetMethod(""addExtraParameter"", &SetCrashKeyStub); reporter.SetMethod(""removeExtraParameter"", &ClearCrashKeyStub); #else diff --git a/shell/browser/api/electron_api_app.cc b/shell/browser/api/electron_api_app.cc index e278785c88..a55f1ab535 100644 --- a/shell/browser/api/electron_api_app.cc +++ b/shell/browser/api/electron_api_app.cc @@ -1826,7 +1826,7 @@ gin::ObjectTemplateBuilder App::GetObjectTemplateBuilder(v8::Isolate* isolate) { .SetMethod(""getAppMetrics"", &App::GetAppMetrics) .SetMethod(""getGPUFeatureStatus"", &App::GetGPUFeatureStatus) .SetMethod(""getGPUInfo"", &App::GetGPUInfo) -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() .SetMethod(""startAccessingSecurityScopedResource"", &App::StartAccessingSecurityScopedResource) #endif diff --git a/shell/browser/api/electron_api_app.h b/shell/browser/api/electron_api_app.h index 40f76b1914..afc29e6a08 100644 --- a/shell/browser/api/electron_api_app.h +++ b/shell/browser/api/electron_api_app.h @@ -235,7 +235,7 @@ class App : public ElectronBrowserClient::Delegate, bool IsRunningUnderARM64Translation() const; #endif -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() base::RepeatingCallback StartAccessingSecurityScopedResource( gin::Arguments* args); #endif diff --git a/shell/browser/api/electron_api_crash_reporter.cc b/shell/browser/api/electron_api_crash_reporter.cc index d5ab294c71..ae02d518d9 100644 --- a/shell/browser/api/electron_api_crash_reporter.cc +++ b/shell/browser/api/electron_api_crash_reporter.cc @@ -30,7 +30,7 @@ #include ""shell/common/gin_helper/dictionary.h"" #include ""shell/common/node_includes.h"" -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() #include ""components/crash/core/app/crashpad.h"" // nogncheck #include ""components/crash/core/browser/crash_upload_list_crashpad.h"" // nogncheck #include ""components/crash/core/common/crash_key.h"" @@ -65,7 +65,7 @@ bool g_crash_reporter_initialized = false; namespace electron::api::crash_reporter { -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() namespace { void NoOp() {} @@ -132,7 +132,7 @@ void Start(const std::string& submit_url, const std::map& extra, bool is_node_process) { TRACE_EVENT0(""electron"", ""crash_reporter::Start""); -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() if (g_crash_reporter_initialized) return; g_crash_reporter_initialized = true; @@ -182,7 +182,7 @@ void Start(const std::string& submit_url, namespace { -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() void GetUploadedReports( v8::Isolate* isolate, base::OnceCallback)> callback) { @@ -237,13 +237,13 @@ v8::Local GetUploadedReports(v8::Isolate* isolate) { #endif void SetUploadToServer(bool upload) { -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() ElectronCrashReporterClient::Get()->SetCollectStatsConsent(upload); #endif } bool GetUploadToServer() { -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() return false; #else return ElectronCrashReporterClient::Get()->GetCollectStatsConsent(); @@ -252,7 +252,7 @@ bool GetUploadToServer() { v8::Local GetParameters(v8::Isolate* isolate) { std::map keys; -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() electron::crash_keys::GetCrashKeys(&keys); #endif return gin::ConvertToV8(isolate, keys); @@ -264,7 +264,7 @@ void Initialize(v8::Local exports, void* priv) { gin_helper::Dictionary dict(context->GetIsolate(), exports); dict.SetMethod(""start"", &electron::api::crash_reporter::Start); -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() dict.SetMethod(""addExtraParameter"", &electron::api::crash_reporter::NoOp); dict.SetMethod(""removeExtraParameter"", &electron::api::crash_reporter::NoOp); #else diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 27a3c3ba8f..776f905d21 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -197,7 +197,7 @@ #include ""content/public/browser/plugin_service.h"" #endif -#ifndef MAS_BUILD +#if !IS_MAS_BUILD() #include ""chrome/browser/hang_monitor/hang_crash_dump.h"" // nogncheck #endif @@ -2395,7 +2395,7 @@ void WebContents::ForcefullyCrashRenderer() { rph->ForceCrash(); #else // Try to generate a crash report for the hung process. -#ifndef MAS_BUILD +#if !IS_MAS_BUILD() CrashDumpHungChildProcess(rph->GetProcess().Handle()); #endif rph->Shutdown(content::RESULT_CODE_HUNG); diff --git a/shell/browser/api/process_metric.cc b/shell/browser/api/process_metric.cc index b1a2a65052..a7d628e691 100644 --- a/shell/browser/api/process_metric.cc +++ b/shell/browser/api/process_metric.cc @@ -160,7 +160,7 @@ ProcessMemoryInfo ProcessMetric::GetMemoryInfo() const { } bool ProcessMetric::IsSandboxed() const { -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() return true; #else return sandbox_check(process.Pid(), nullptr, 0) != 0; diff --git a/shell/browser/auto_updater.cc b/shell/browser/auto_updater.cc index b9a8932c3e..1e95964c47 100644 --- a/shell/browser/auto_updater.cc +++ b/shell/browser/auto_updater.cc @@ -16,7 +16,7 @@ void AutoUpdater::SetDelegate(Delegate* delegate) { delegate_ = delegate; } -#if !BUILDFLAG(IS_MAC) || defined(MAS_BUILD) +#if !BUILDFLAG(IS_MAC) || IS_MAS_BUILD() std::string AutoUpdater::GetFeedURL() { return """"; } diff --git a/shell/browser/browser_mac.mm b/shell/browser/browser_mac.mm index ab7942e369..32e73f3828 100644 --- a/shell/browser/browser_mac.mm +++ b/shell/browser/browser_mac.mm @@ -309,7 +309,7 @@ bool Browser::UpdateUserActivityState(const std::string& type, Browser::LoginItemSettings Browser::GetLoginItemSettings( const LoginItemSettings& options) { LoginItemSettings settings; -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() settings.open_at_login = platform_util::GetLoginItemEnabled(); #else settings.open_at_login = @@ -322,7 +322,7 @@ Browser::LoginItemSettings Browser::GetLoginItemSettings( } void Browser::SetLoginItemSettings(LoginItemSettings settings) { -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() if (!platform_util::SetLoginItemEnabled(settings.open_at_login)) { LOG(ERROR) << ""Unable to set login item enabled on sandboxed app.""; } diff --git a/shell/browser/notifications/mac/notification_center_delegate.mm b/shell/browser/notifications/mac/notification_center_delegate.mm index 3d8c0073ea..d9603bcd94 100644 --- a/shell/browser/notifications/mac/notification_center_delegate.mm +++ b/shell/browser/notifications/mac/notification_center_delegate.mm @@ -65,7 +65,7 @@ return YES; } -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() // This undocumented method notifies us if a user closes ""Alert"" notifications // https://chromium.googlesource.com/chromium/src/+/lkgr/chrome/browser/notifications/notification_platform_bridge_mac.mm - (void)userNotificationCenter:(NSUserNotificationCenter*)center @@ -76,7 +76,7 @@ } #endif -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() // This undocumented method notifies us if a user closes ""Banner"" notifications // https://github.com/mozilla/gecko-dev/blob/master/widget/cocoa/OSXNotificationCenter.mm - (void)userNotificationCenter:(NSUserNotificationCenter*)center diff --git a/shell/browser/ui/file_dialog_mac.mm b/shell/browser/ui/file_dialog_mac.mm index fa7cfa424e..7eea9a533b 100644 --- a/shell/browser/ui/file_dialog_mac.mm +++ b/shell/browser/ui/file_dialog_mac.mm @@ -340,13 +340,13 @@ void OpenDialogCompletion(int chosen, if (chosen == NSModalResponseCancel) { dict.Set(""canceled"", true); dict.Set(""filePaths"", std::vector()); -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() dict.Set(""bookmarks"", std::vector()); #endif } else { std::vector paths; dict.Set(""canceled"", false); -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() std::vector bookmarks; if (security_scoped_bookmarks) ReadDialogPathsWithBookmarks(dialog, &paths, &bookmarks); @@ -418,14 +418,14 @@ void SaveDialogCompletion(int chosen, if (chosen == NSModalResponseCancel) { dict.Set(""canceled"", true); dict.Set(""filePath"", base::FilePath()); -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() dict.Set(""bookmark"", base::StringPiece()); #endif } else { std::string path = base::SysNSStringToUTF8([[dialog URL] path]); dict.Set(""filePath"", base::FilePath(path)); dict.Set(""canceled"", false); -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() std::string bookmark; if (security_scoped_bookmarks) { bookmark = GetBookmarkDataFromNSURL([dialog URL]); diff --git a/shell/common/api/electron_bindings.cc b/shell/common/api/electron_bindings.cc index 5cd1930a8b..306178a6ac 100644 --- a/shell/common/api/electron_bindings.cc +++ b/shell/common/api/electron_bindings.cc @@ -61,7 +61,7 @@ void ElectronBindings::BindProcess(v8::Isolate* isolate, base::BindRepeating(&ElectronBindings::GetCPUUsage, base::Unretained(metrics))); -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() process->SetReadOnly(""mas"", true); #endif diff --git a/shell/common/node_bindings.cc b/shell/common/node_bindings.cc index 5e4ab461c2..546e4658c1 100644 --- a/shell/common/node_bindings.cc +++ b/shell/common/node_bindings.cc @@ -39,7 +39,7 @@ #include ""third_party/blink/renderer/bindings/core/v8/v8_initializer.h"" // nogncheck #include ""third_party/electron_node/src/debug_utils.h"" -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() #include ""shell/common/crash_keys.h"" #endif @@ -147,7 +147,7 @@ bool g_is_initialized = false; void V8FatalErrorCallback(const char* location, const char* message) { LOG(ERROR) << ""Fatal error in V8: "" << location << "" "" << message; -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() electron::crash_keys::SetCrashKey(""electron.v8-fatal.message"", message); electron::crash_keys::SetCrashKey(""electron.v8-fatal.location"", location); #endif diff --git a/shell/renderer/api/electron_api_crash_reporter_renderer.cc b/shell/renderer/api/electron_api_crash_reporter_renderer.cc index b011a80631..05df96a68c 100644 --- a/shell/renderer/api/electron_api_crash_reporter_renderer.cc +++ b/shell/renderer/api/electron_api_crash_reporter_renderer.cc @@ -6,7 +6,7 @@ #include ""shell/common/gin_helper/dictionary.h"" #include ""shell/common/node_includes.h"" -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() #include ""shell/common/crash_keys.h"" #endif @@ -14,13 +14,13 @@ namespace { v8::Local GetParameters(v8::Isolate* isolate) { std::map keys; -#if !defined(MAS_BUILD) +#if !IS_MAS_BUILD() electron::crash_keys::GetCrashKeys(&keys); #endif return gin::ConvertToV8(isolate, keys); } -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() void SetCrashKeyStub(const std::string& key, const std::string& value) {} void ClearCrashKeyStub(const std::string& key) {} #endif @@ -30,7 +30,7 @@ void Initialize(v8::Local exports, v8::Local context, void* priv) { gin_helper::Dictionary dict(context->GetIsolate(), exports); -#if defined(MAS_BUILD) +#if IS_MAS_BUILD() dict.SetMethod(""addExtraParameter"", &SetCrashKeyStub); dict.SetMethod(""removeExtraParameter"", &ClearCrashKeyStub); #else",refactor 0d3aee26b9e653e27ae6fe9d28586fd0a87fe2a7,John Kleinschmidt,2023-03-07 15:36:31,"docs: fixup WebUSB fiddle (#37455) docs: fixup webusb fiddle","diff --git a/docs/fiddles/features/web-usb/main.js b/docs/fiddles/features/web-usb/main.js index 580c6686bc..14983093c6 100644 --- a/docs/fiddles/features/web-usb/main.js +++ b/docs/fiddles/features/web-usb/main.js @@ -1,5 +1,4 @@ const {app, BrowserWindow} = require('electron') -const e = require('express') const path = require('path') function createWindow () { @@ -44,7 +43,6 @@ function createWindow () { } }) - mainWindow.webContents.session.setDevicePermissionHandler((details) => { if (details.deviceType === 'usb' && details.origin === 'file://') { if (!grantedDeviceThroughPermHandler) { diff --git a/docs/fiddles/features/web-usb/renderer.js b/docs/fiddles/features/web-usb/renderer.js index 3983a6fbf7..8544353f0f 100644 --- a/docs/fiddles/features/web-usb/renderer.js +++ b/docs/fiddles/features/web-usb/renderer.js @@ -1,5 +1,5 @@ function getDeviceDetails(device) { - return grantedDevice.productName || `Unknown device ${grantedDevice.deviceId}` + return device.productName || `Unknown device ${device.deviceId}` } async function testIt() {",docs 2002472b10d056b1b3fb64c19df5aa4f24795a8d,Charles Kerr,2024-11-06 08:49:25,"chore: remove unused gin::Converter::ToV8(isolate, const char*) (#44568) No longer needed after #44498","diff --git a/shell/common/gin_converters/std_converter.h b/shell/common/gin_converters/std_converter.h index 96ffb82818..6b30049353 100644 --- a/shell/common/gin_converters/std_converter.h +++ b/shell/common/gin_converters/std_converter.h @@ -54,14 +54,6 @@ struct Converter { } }; -template <> -struct Converter { - static v8::Local ToV8(v8::Isolate* isolate, const char* val) { - return v8::String::NewFromUtf8(isolate, val, v8::NewStringType::kNormal) - .ToLocalChecked(); - } -}; - template struct Converter { static v8::Local ToV8(v8::Isolate* isolate, const char (&val)[N]) {",chore a7fa6e89b535f4418a03dd20e25f2d6f6cd7e914,Charles Kerr,2024-12-02 10:39:10,"chore: remove unused arg from BaseWindow::GetBackgroundColor() (#44906) chore: remove unused gin_helper::Arguments* arg from BaseWindow::GetBackgroundColor() looks like this was added in db79734b but never used","diff --git a/shell/browser/api/electron_api_base_window.cc b/shell/browser/api/electron_api_base_window.cc index e034f4c30b..ae991a627f 100644 --- a/shell/browser/api/electron_api_base_window.cc +++ b/shell/browser/api/electron_api_base_window.cc @@ -669,7 +669,7 @@ void BaseWindow::SetBackgroundColor(const std::string& color_name) { window_->SetBackgroundColor(color); } -std::string BaseWindow::GetBackgroundColor(gin_helper::Arguments* args) const { +std::string BaseWindow::GetBackgroundColor() const { return ToRGBHex(window_->GetBackgroundColor()); } diff --git a/shell/browser/api/electron_api_base_window.h b/shell/browser/api/electron_api_base_window.h index 0291439da2..081a9fdd2c 100644 --- a/shell/browser/api/electron_api_base_window.h +++ b/shell/browser/api/electron_api_base_window.h @@ -164,7 +164,7 @@ class BaseWindow : public gin_helper::TrackableObject, bool IsKiosk() const; bool IsTabletMode() const; virtual void SetBackgroundColor(const std::string& color_name); - std::string GetBackgroundColor(gin_helper::Arguments* args) const; + std::string GetBackgroundColor() const; void InvalidateShadow(); void SetHasShadow(bool has_shadow); bool HasShadow() const;",chore 69eb076bca6de06df258421b654d78b35c9c6a23,Charles Kerr,2025-02-24 10:09:01,"refactor: do not use `AdaptCallbackForRepeating()` in `electron_api_url_loader.cc` (#45771) refactor: do not use AdaptCallbackForRepeating in electron_api_url_loader.cc","diff --git a/shell/common/api/electron_api_url_loader.cc b/shell/common/api/electron_api_url_loader.cc index 612843565f..607e6bee73 100644 --- a/shell/common/api/electron_api_url_loader.cc +++ b/shell/common/api/electron_api_url_loader.cc @@ -438,7 +438,7 @@ void SimpleURLLoaderWrapper::OnAuthRequired( net::AuthCredentials(username_str, password_str)); }, std::move(auth_responder)); - Emit(""login"", auth_info, base::AdaptCallbackForRepeating(std::move(cb))); + Emit(""login"", auth_info, std::move(cb)); } void SimpleURLLoaderWrapper::OnSSLCertificateError( @@ -716,8 +716,7 @@ void SimpleURLLoaderWrapper::OnDataReceived(std::string_view string_view, v8::HandleScope handle_scope(isolate); auto array_buffer = v8::ArrayBuffer::New(isolate, string_view.size()); memcpy(array_buffer->Data(), string_view.data(), string_view.size()); - Emit(""data"", array_buffer, - base::AdaptCallbackForRepeating(std::move(resume))); + Emit(""data"", array_buffer, std::move(resume)); } void SimpleURLLoaderWrapper::OnComplete(bool success) { diff --git a/shell/common/gin_helper/event_emitter_caller.h b/shell/common/gin_helper/event_emitter_caller.h index 3859f02359..0ac374f840 100644 --- a/shell/common/gin_helper/event_emitter_caller.h +++ b/shell/common/gin_helper/event_emitter_caller.h @@ -11,6 +11,7 @@ #include ""base/containers/span.h"" #include ""gin/converter.h"" #include ""gin/wrappable.h"" +#include ""shell/common/gin_converters/std_converter.h"" // for ConvertToV8(iso, &&) namespace gin_helper { ",refactor f68184a9f927ef94107e83227116114fdf32114b,Robo,2024-09-27 10:17:06,"feat: add error event for utility process (#43774) * feat: add error event for utility process * chore: use public report api * chore: fix lint * doc: mark error event as experimental --------- Co-authored-by: Shelley Vohr ","diff --git a/docs/api/utility-process.md b/docs/api/utility-process.md index 100c3ead6d..af6c74967e 100644 --- a/docs/api/utility-process.md +++ b/docs/api/utility-process.md @@ -116,6 +116,17 @@ When the child process exits, then the value is `null` after the `exit` event is Emitted once the child process has spawned successfully. +#### Event: 'error' _Experimental_ + +Returns: + +* `type` string - Type of error. One of the following values: + * `FatalError` +* `location` string - Source location from where the error originated. +* `report` string - [`Node.js diagnostic report`][]. + +Emitted when the child process needs to terminate due to non continuable error from V8. + #### Event: 'exit' Returns: @@ -138,3 +149,4 @@ Emitted when the child process sends a message using [`process.parentPort.postMe [stdio]: https://nodejs.org/dist/latest/docs/api/child_process.html#optionsstdio [event-emitter]: https://nodejs.org/api/events.html#events_class_eventemitter [`MessagePortMain`]: message-port-main.md +[`Node.js diagnostic report`]: https://nodejs.org/docs/latest/api/report.html#diagnostic-report diff --git a/shell/browser/api/electron_api_utility_process.cc b/shell/browser/api/electron_api_utility_process.cc index 333e4b66c5..ab813d7aba 100644 --- a/shell/browser/api/electron_api_utility_process.cc +++ b/shell/browser/api/electron_api_utility_process.cc @@ -223,7 +223,8 @@ UtilityProcessWrapper::UtilityProcessWrapper( params->use_network_observer_from_url_loader_factory = create_network_observer; - node_service_remote_->Initialize(std::move(params)); + node_service_remote_->Initialize(std::move(params), + receiver_.BindNewPipeAndPassRemote()); } UtilityProcessWrapper::~UtilityProcessWrapper() { @@ -258,8 +259,9 @@ void UtilityProcessWrapper::HandleTermination(uint64_t exit_code) { void UtilityProcessWrapper::OnServiceProcessDisconnected( uint32_t exit_code, const std::string& description) { - if (description == ""process_exit_termination"") + if (description == ""process_exit_termination"") { HandleTermination(exit_code); + } } void UtilityProcessWrapper::OnServiceProcessTerminatedNormally( @@ -372,6 +374,11 @@ bool UtilityProcessWrapper::Accept(mojo::Message* mojo_message) { return true; } +void UtilityProcessWrapper::OnV8FatalError(const std::string& location, + const std::string& report) { + EmitWithoutEvent(""error"", ""FatalError"", location, report); +} + // static raw_ptr UtilityProcessWrapper::FromProcessId( base::ProcessId pid) { diff --git a/shell/browser/api/electron_api_utility_process.h b/shell/browser/api/electron_api_utility_process.h index 2e37157c85..c0a992ba7f 100644 --- a/shell/browser/api/electron_api_utility_process.h +++ b/shell/browser/api/electron_api_utility_process.h @@ -44,6 +44,7 @@ class UtilityProcessWrapper final public gin_helper::Pinnable, public gin_helper::EventEmitterMixin, public mojo::MessageReceiver, + public node::mojom::NodeServiceClient, public content::ServiceProcessHost::Observer { public: enum class IOHandle : size_t { STDIN = 0, STDOUT = 1, STDERR = 2 }; @@ -81,6 +82,10 @@ class UtilityProcessWrapper final // mojo::MessageReceiver bool Accept(mojo::Message* mojo_message) override; + // node::mojom::NodeServiceClient + void OnV8FatalError(const std::string& location, + const std::string& report) override; + // content::ServiceProcessHost::Observer void OnServiceProcessTerminatedNormally( const content::ServiceProcessInfo& info) override; @@ -102,6 +107,7 @@ class UtilityProcessWrapper final bool connector_closed_ = false; std::unique_ptr connector_; blink::MessagePortDescriptor host_port_; + mojo::Receiver receiver_{this}; mojo::Remote node_service_remote_; std::optional url_loader_network_observer_; diff --git a/shell/common/node_includes.h b/shell/common/node_includes.h index 26d3bb24d6..512a8d636a 100644 --- a/shell/common/node_includes.h +++ b/shell/common/node_includes.h @@ -27,6 +27,7 @@ #include ""node_options-inl.h"" #include ""node_options.h"" #include ""node_platform.h"" +#include ""node_report.h"" #include ""tracing/agent.h"" #include ""electron/pop_node_defines.h"" diff --git a/shell/services/node/node_service.cc b/shell/services/node/node_service.cc index 6d273119d0..edcdb127bf 100644 --- a/shell/services/node/node_service.cc +++ b/shell/services/node/node_service.cc @@ -4,11 +4,13 @@ #include ""shell/services/node/node_service.h"" +#include #include #include ""base/command_line.h"" #include ""base/no_destructor.h"" #include ""base/strings/utf_string_conversions.h"" +#include ""electron/mas.h"" #include ""services/network/public/cpp/wrapper_shared_url_loader_factory.h"" #include ""services/network/public/mojom/host_resolver.mojom.h"" #include ""services/network/public/mojom/network_context.mojom.h"" @@ -20,8 +22,32 @@ #include ""shell/common/node_includes.h"" #include ""shell/services/node/parent_port.h"" +#if !IS_MAS_BUILD() +#include ""shell/common/crash_keys.h"" +#endif + namespace electron { +mojo::Remote g_client_remote; + +void V8FatalErrorCallback(const char* location, const char* message) { + if (g_client_remote.is_bound() && g_client_remote.is_connected()) { + auto* isolate = v8::Isolate::TryGetCurrent(); + std::ostringstream outstream; + node::GetNodeReport(isolate, message, location, + v8::Local() /* error */, outstream); + g_client_remote->OnV8FatalError(location, outstream.str()); + } + +#if !IS_MAS_BUILD() + electron::crash_keys::SetCrashKey(""electron.v8-fatal.message"", message); + electron::crash_keys::SetCrashKey(""electron.v8-fatal.location"", location); +#endif + + volatile int* zero = nullptr; + *zero = 0; +} + URLLoaderBundle::URLLoaderBundle() = default; URLLoaderBundle::~URLLoaderBundle() = default; @@ -73,12 +99,20 @@ NodeService::~NodeService() { js_env_->DestroyMicrotasksRunner(); node::Stop(node_env_.get(), node::StopFlags::kDoNotTerminateIsolate); } + if (g_client_remote.is_bound()) { + g_client_remote.reset(); + } } -void NodeService::Initialize(node::mojom::NodeServiceParamsPtr params) { +void NodeService::Initialize( + node::mojom::NodeServiceParamsPtr params, + mojo::PendingRemote client_pending_remote) { if (NodeBindings::IsInitialized()) return; + g_client_remote.Bind(std::move(client_pending_remote)); + g_client_remote.reset_on_disconnect(); + ParentPort::GetInstance()->Initialize(std::move(params->port)); URLLoaderBundle::GetInstance()->SetURLLoaderFactory( @@ -105,6 +139,9 @@ void NodeService::Initialize(node::mojom::NodeServiceParamsPtr params) { js_env_->isolate()->GetCurrentContext(), js_env_->platform(), params->args, params->exec_args); + // Override the default handler set by NodeBindings. + node_env_->isolate()->SetFatalErrorHandler(V8FatalErrorCallback); + node::SetProcessExitHandler( node_env_.get(), [this](node::Environment* env, int exit_code) { // Destroy node platform. diff --git a/shell/services/node/node_service.h b/shell/services/node/node_service.h index b025ad233a..d6e3edd092 100644 --- a/shell/services/node/node_service.h +++ b/shell/services/node/node_service.h @@ -61,7 +61,9 @@ class NodeService : public node::mojom::NodeService { NodeService& operator=(const NodeService&) = delete; // mojom::NodeService implementation: - void Initialize(node::mojom::NodeServiceParamsPtr params) override; + void Initialize(node::mojom::NodeServiceParamsPtr params, + mojo::PendingRemote + client_pending_remote) override; private: // This needs to be initialized first so that it can be destroyed last diff --git a/shell/services/node/public/mojom/node_service.mojom b/shell/services/node/public/mojom/node_service.mojom index be9a0cb0ab..c2fce2660d 100644 --- a/shell/services/node/public/mojom/node_service.mojom +++ b/shell/services/node/public/mojom/node_service.mojom @@ -20,7 +20,12 @@ struct NodeServiceParams { bool use_network_observer_from_url_loader_factory = false; }; +interface NodeServiceClient { + OnV8FatalError(string location, string report); +}; + [ServiceSandbox=sandbox.mojom.Sandbox.kNoSandbox] interface NodeService { - Initialize(NodeServiceParams params); + Initialize(NodeServiceParams params, + pending_remote client_remote); }; diff --git a/spec/.gitignore b/spec/.gitignore index 1e64585917..a8e40c44c6 100644 --- a/spec/.gitignore +++ b/spec/.gitignore @@ -1,2 +1,3 @@ node_modules artifacts +**/native-addon/*/build diff --git a/spec/api-utility-process-spec.ts b/spec/api-utility-process-spec.ts index 76d0e2d6e3..d283b41f4c 100644 --- a/spec/api-utility-process-spec.ts +++ b/spec/api-utility-process-spec.ts @@ -113,6 +113,21 @@ describe('utilityProcess module', () => { const [code] = await once(child, 'exit'); expect(code).to.equal(exitCode); }); + + // 32-bit system will not have V8 Sandbox enabled. + // WoA testing does not have VS toolchain configured to build native addons. + ifit(process.arch !== 'ia32' && process.arch !== 'arm' && !isWindowsOnArm)('emits \'error\' when fatal error is triggered from V8', async () => { + const child = utilityProcess.fork(path.join(fixturesPath, 'external-ab-test.js')); + const [type, location, report] = await once(child, 'error'); + const [code] = await once(child, 'exit'); + expect(type).to.equal('FatalError'); + expect(location).to.equal('v8_ArrayBuffer_NewBackingStore'); + const reportJSON = JSON.parse(report); + expect(reportJSON.header.trigger).to.equal('v8_ArrayBuffer_NewBackingStore'); + const addonPath = path.join(require.resolve('@electron-ci/external-ab'), '..', '..', 'build', 'Release', 'external_ab.node'); + expect(reportJSON.sharedObjects).to.include(path.toNamespacedPath(addonPath)); + expect(code).to.not.equal(0); + }); }); describe('app \'child-process-gone\' event', () => { diff --git a/spec/fixtures/api/utility-process/external-ab-test.js b/spec/fixtures/api/utility-process/external-ab-test.js new file mode 100644 index 0000000000..16afd2d614 --- /dev/null +++ b/spec/fixtures/api/utility-process/external-ab-test.js @@ -0,0 +1,3 @@ +'use strict'; + +require('@electron-ci/external-ab'); diff --git a/spec/fixtures/native-addon/external-ab/binding.cc b/spec/fixtures/native-addon/external-ab/binding.cc new file mode 100644 index 0000000000..277e13f97e --- /dev/null +++ b/spec/fixtures/native-addon/external-ab/binding.cc @@ -0,0 +1,50 @@ +#include +#undef NAPI_VERSION +#include +#include + +namespace { + +napi_value CreateBuffer(napi_env env, napi_callback_info info) { + v8::Isolate* isolate = v8::Isolate::TryGetCurrent(); + if (isolate == nullptr) { + return NULL; + } + + const size_t length = 4; + + uint8_t* data = new uint8_t[length]; + for (size_t i = 0; i < 4; i++) { + data[i] = static_cast(length); + } + + auto finalizer = [](char* data, void* hint) { + delete[] static_cast(reinterpret_cast(data)); + }; + + // NOTE: Buffer API is invoked directly rather than + // napi version to trigger the FATAL error from V8. + v8::MaybeLocal maybe = node::Buffer::New( + isolate, static_cast(reinterpret_cast(data)), length, + finalizer, nullptr); + + return reinterpret_cast(*maybe.ToLocalChecked()); +} + +napi_value Init(napi_env env, napi_value exports) { + napi_status status; + napi_property_descriptor descriptors[] = {{""createBuffer"", NULL, CreateBuffer, + NULL, NULL, NULL, napi_default, + NULL}}; + + status = napi_define_properties( + env, exports, sizeof(descriptors) / sizeof(*descriptors), descriptors); + if (status != napi_ok) + return NULL; + + return exports; +} + +} // namespace + +NAPI_MODULE(NODE_GYP_MODULE_NAME, Init) diff --git a/spec/fixtures/native-addon/external-ab/binding.gyp b/spec/fixtures/native-addon/external-ab/binding.gyp new file mode 100644 index 0000000000..d8c4884bb9 --- /dev/null +++ b/spec/fixtures/native-addon/external-ab/binding.gyp @@ -0,0 +1,10 @@ +{ + ""targets"": [ + { + ""target_name"": ""external_ab"", + ""sources"": [ + ""binding.cc"" + ] + } + ] +} diff --git a/spec/fixtures/native-addon/external-ab/lib/test-array-buffer.js b/spec/fixtures/native-addon/external-ab/lib/test-array-buffer.js new file mode 100644 index 0000000000..97b49e7693 --- /dev/null +++ b/spec/fixtures/native-addon/external-ab/lib/test-array-buffer.js @@ -0,0 +1,4 @@ +'use strict'; + +const binding = require('../build/Release/external_ab.node'); +binding.createBuffer(); diff --git a/spec/fixtures/native-addon/external-ab/package.json b/spec/fixtures/native-addon/external-ab/package.json new file mode 100644 index 0000000000..1ab30a4dc3 --- /dev/null +++ b/spec/fixtures/native-addon/external-ab/package.json @@ -0,0 +1,5 @@ +{ + ""main"": ""./lib/test-array-buffer.js"", + ""name"": ""@electron-ci/external-ab"", + ""version"": ""0.0.1"" +} diff --git a/spec/package.json b/spec/package.json index bceb77b3b7..3ea7820d56 100644 --- a/spec/package.json +++ b/spec/package.json @@ -23,6 +23,7 @@ ""@electron-ci/is-valid-window"": ""file:./is-valid-window"", ""@electron-ci/uv-dlopen"": ""file:./fixtures/native-addon/uv-dlopen/"", ""@electron-ci/osr-gpu"": ""file:./fixtures/native-addon/osr-gpu/"", + ""@electron-ci/external-ab"": ""file:./fixtures/native-addon/external-ab/"", ""@electron/fuses"": ""^1.8.0"", ""@electron/packager"": ""^18.3.2"", ""@marshallofsound/mocha-appveyor-reporter"": ""^0.4.3"", diff --git a/spec/yarn.lock b/spec/yarn.lock index 5c16d1fa36..fab25f3387 100644 --- a/spec/yarn.lock +++ b/spec/yarn.lock @@ -5,6 +5,9 @@ ""@electron-ci/echo@file:./fixtures/native-addon/echo"": version ""0.0.1"" +""@electron-ci/external-ab@file:./fixtures/native-addon/external-ab"": + version ""0.0.1"" + ""@electron-ci/is-valid-window@file:./is-valid-window"": version ""0.0.5"" dependencies:",feat 9aefe5db3335858c5ac7033212057a85869f167c,Keeley Hammond,2023-06-13 13:23:11,build: move chrome_lib_arc to chromium_src/BUILD.gn (#38764),"diff --git a/BUILD.gn b/BUILD.gn index b95a4d47f3..344f772ee4 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -542,7 +542,6 @@ source_set(""electron_lib"") { if (is_mac) { deps += [ - "":chrome_lib_arc"", "":electron_lib_arc"", ""//components/remote_cocoa/app_shim"", ""//components/remote_cocoa/browser"", @@ -746,32 +745,6 @@ source_set(""electron_lib"") { } if (is_mac) { - source_set(""chrome_lib_arc"") { - include_dirs = [ ""."" ] - sources = [ - ""//chrome/browser/extensions/global_shortcut_listener_mac.h"", - ""//chrome/browser/extensions/global_shortcut_listener_mac.mm"", - ""//chrome/browser/icon_loader_mac.mm"", - ""//chrome/browser/media/webrtc/system_media_capture_permissions_mac.h"", - ""//chrome/browser/media/webrtc/system_media_capture_permissions_mac.mm"", - ""//chrome/browser/media/webrtc/system_media_capture_permissions_stats_mac.h"", - ""//chrome/browser/media/webrtc/system_media_capture_permissions_stats_mac.mm"", - ""//chrome/browser/media/webrtc/window_icon_util_mac.mm"", - ""//chrome/browser/platform_util_mac.mm"", - ""//chrome/browser/process_singleton_mac.mm"", - ] - - deps = [ - ""//base"", - ""//skia"", - ""//third_party/electron_node:node_lib"", - ""//third_party/webrtc_overrides:webrtc_component"", - ""//v8"", - ] - - configs += [ ""//build/config/compiler:enable_arc"" ] - } - source_set(""electron_lib_arc"") { include_dirs = [ ""."" ] sources = [ diff --git a/chromium_src/BUILD.gn b/chromium_src/BUILD.gn index 29f342266b..6f4747f7c6 100644 --- a/chromium_src/BUILD.gn +++ b/chromium_src/BUILD.gn @@ -218,6 +218,10 @@ static_library(""chrome"") { public_deps += [ ""//chrome/services/util_win:lib"" ] } + if (is_mac) { + public_deps += [ "":chrome_lib_arc"" ] + } + if (enable_widevine) { sources += [ ""//chrome/renderer/media/chrome_key_systems.cc"", @@ -331,6 +335,34 @@ static_library(""chrome"") { } } +if (is_mac) { + source_set(""chrome_lib_arc"") { + include_dirs = [ ""."" ] + sources = [ + ""//chrome/browser/extensions/global_shortcut_listener_mac.h"", + ""//chrome/browser/extensions/global_shortcut_listener_mac.mm"", + ""//chrome/browser/icon_loader_mac.mm"", + ""//chrome/browser/media/webrtc/system_media_capture_permissions_mac.h"", + ""//chrome/browser/media/webrtc/system_media_capture_permissions_mac.mm"", + ""//chrome/browser/media/webrtc/system_media_capture_permissions_stats_mac.h"", + ""//chrome/browser/media/webrtc/system_media_capture_permissions_stats_mac.mm"", + ""//chrome/browser/media/webrtc/window_icon_util_mac.mm"", + ""//chrome/browser/platform_util_mac.mm"", + ""//chrome/browser/process_singleton_mac.mm"", + ] + + deps = [ + ""//base"", + ""//skia"", + ""//third_party/electron_node:node_lib"", + ""//third_party/webrtc_overrides:webrtc_component"", + ""//v8"", + ] + + configs += [ ""//build/config/compiler:enable_arc"" ] + } +} + source_set(""plugins"") { sources = [] deps = []",build 50860712943da0feabcb668b264c35b7837286c0,Brandon Fowler,2024-01-04 23:00:27,"feat: add `transparent` webpreference to webview (#40301) * feat: add transparent option to WebContents * feat: add transparent attribute to webview * test: add tests for webview transparent attribute * docs: add transparent attribute to webview docs * fix: run tests on macOS only * refactor: remove unneeded html tag * fix: only apply transparent option to guests * refactor: correct comment * refactor: use opaque instead Retains current webview behaviour by default. * fix: correct variable name to guest_opaque_ * refactor: use transparent webpreference * docs: remove unused web preference * fix: uncomment condition for transparency test * docs: converted to list format and linked to MDN * fix: make webviews transparent by default again * fix: rebase error --------- Co-authored-by: Cheng Zhao ","diff --git a/docs/api/webview-tag.md b/docs/api/webview-tag.md index d34026e97f..eecd2e86f9 100644 --- a/docs/api/webview-tag.md +++ b/docs/api/webview-tag.md @@ -221,7 +221,9 @@ windows. Popups are disabled by default. ``` A `string` which is a comma separated list of strings which specifies the web preferences to be set on the webview. -The full list of supported preference strings can be found in [BrowserWindow](browser-window.md#new-browserwindowoptions). +The full list of supported preference strings can be found in [BrowserWindow](browser-window.md#new-browserwindowoptions). In addition, webview supports the following preferences: + +* `transparent` boolean (optional) - Whether to enable background transparency for the guest page. Default is `true`. **Note:** The guest page's text and background colors are derived from the [color scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme) of its root element. When transparency is enabled, the text color will still change accordingly but the background will remain transparent. The string follows the same format as the features string in `window.open`. A name by itself is given a `true` boolean value. diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 29cfc8537b..c24d328883 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -822,6 +822,9 @@ WebContents::WebContents(v8::Isolate* isolate, // Get type options.Get(""type"", &type_); + // Get transparent for guest view + options.Get(""transparent"", &guest_transparent_); + bool b = false; if (options.Get(options::kOffscreen, &b) && b) type_ = Type::kOffScreen; @@ -3778,7 +3781,7 @@ void WebContents::SetImageAnimationPolicy(const std::string& new_policy) { } void WebContents::SetBackgroundColor(absl::optional maybe_color) { - SkColor color = maybe_color.value_or(type_ == Type::kWebView || + SkColor color = maybe_color.value_or((IsGuest() && guest_transparent_) || type_ == Type::kBrowserView ? SK_ColorTRANSPARENT : SK_ColorWHITE); diff --git a/shell/browser/api/electron_api_web_contents.h b/shell/browser/api/electron_api_web_contents.h index 49c1a1f81a..00c3ad8648 100644 --- a/shell/browser/api/electron_api_web_contents.h +++ b/shell/browser/api/electron_api_web_contents.h @@ -801,6 +801,9 @@ class WebContents : public ExclusiveAccessContext, // The type of current WebContents. Type type_ = Type::kBrowserWindow; + // Weather the guest view should be transparent + bool guest_transparent_ = true; + int32_t id_; // Request id used for findInPage request. diff --git a/spec/fixtures/pages/flex-webview.html b/spec/fixtures/pages/flex-webview.html new file mode 100644 index 0000000000..7d5369946c --- /dev/null +++ b/spec/fixtures/pages/flex-webview.html @@ -0,0 +1,15 @@ + diff --git a/spec/webview-spec.ts b/spec/webview-spec.ts index 57770e797c..3e4dca739f 100644 --- a/spec/webview-spec.ts +++ b/spec/webview-spec.ts @@ -1,6 +1,6 @@ import * as path from 'node:path'; import * as url from 'node:url'; -import { BrowserWindow, session, ipcMain, app, WebContents } from 'electron/main'; +import { BrowserWindow, session, ipcMain, app, WebContents, screen } from 'electron/main'; import { closeAllWindows } from './lib/window-helpers'; import { emittedUntil } from './lib/events-helpers'; import { ifit, ifdescribe, defer, itremote, useRemoteContext, listen } from './lib/spec-helpers'; @@ -9,6 +9,7 @@ import * as http from 'node:http'; import * as auth from 'basic-auth'; import { once } from 'node:events'; import { setTimeout } from 'node:timers/promises'; +import { areColorsSimilar, captureScreen, HexColors, getPixelColor } from './lib/screen-helpers'; declare let WebView: any; const features = process._linkedBinding('electron_common_features'); @@ -773,6 +774,85 @@ describe(' tag', function () { }); }); + describe('webpreferences attribute', () => { + const WINDOW_BACKGROUND_COLOR = '#55ccbb'; + + let w: BrowserWindow; + before(async () => { + w = new BrowserWindow({ + webPreferences: { + webviewTag: true, + nodeIntegration: true, + contextIsolation: false + } + }); + await w.loadURL(`file://${fixtures}/pages/flex-webview.html`); + w.setBackgroundColor(WINDOW_BACKGROUND_COLOR); + }); + afterEach(async () => { + await w.webContents.executeJavaScript(`{ + for (const el of document.querySelectorAll('webview')) el.remove(); + }`); + }); + after(() => w.close()); + + // Linux and arm64 platforms (WOA and macOS) do not return any capture sources + ifit(process.platform === 'darwin' && process.arch === 'x64')('is transparent by default', async () => { + await loadWebView(w.webContents, { + src: 'data:text/html,foo' + }); + + await setTimeout(1000); + + const display = screen.getPrimaryDisplay(); + const screenCapture = await captureScreen(); + const centerColor = getPixelColor(screenCapture, { + x: display.size.width / 2, + y: display.size.height / 2 + }); + + expect(areColorsSimilar(centerColor, WINDOW_BACKGROUND_COLOR)).to.be.true(); + }); + + // Linux and arm64 platforms (WOA and macOS) do not return any capture sources + ifit(process.platform === 'darwin' && process.arch === 'x64')('remains transparent when set', async () => { + await loadWebView(w.webContents, { + src: 'data:text/html,foo', + webpreferences: 'transparent=yes' + }); + + await setTimeout(1000); + + const display = screen.getPrimaryDisplay(); + const screenCapture = await captureScreen(); + const centerColor = getPixelColor(screenCapture, { + x: display.size.width / 2, + y: display.size.height / 2 + }); + + expect(areColorsSimilar(centerColor, WINDOW_BACKGROUND_COLOR)).to.be.true(); + }); + + // Linux and arm64 platforms (WOA and macOS) do not return any capture sources + ifit(process.platform === 'darwin' && process.arch === 'x64')('can disable transparency', async () => { + await loadWebView(w.webContents, { + src: 'data:text/html,foo', + webpreferences: 'transparent=no' + }); + + await setTimeout(1000); + + const display = screen.getPrimaryDisplay(); + const screenCapture = await captureScreen(); + const centerColor = getPixelColor(screenCapture, { + x: display.size.width / 2, + y: display.size.height / 2 + }); + + expect(areColorsSimilar(centerColor, HexColors.WHITE)).to.be.true(); + }); + }); + describe('permission request handlers', () => { let w: BrowserWindow; beforeEach(async () => {",feat 1574cbf137e46f14ead2b9c980c4e30a4590c7df,Samuel Attard,2023-11-21 23:58:57,fix: restore performance of macOS window resizing (#40577),"diff --git a/patches/chromium/.patches b/patches/chromium/.patches index 97830b3b97..2482566d4f 100644 --- a/patches/chromium/.patches +++ b/patches/chromium/.patches @@ -128,3 +128,4 @@ revert_remove_the_allowaggressivethrottlingwithwebsocket_feature.patch fix_activate_background_material_on_windows.patch feat_allow_passing_of_objecttemplate_to_objecttemplatebuilder.patch chore_remove_check_is_test_on_script_injection_tracker.patch +fix_restore_original_resize_performance_on_macos.patch diff --git a/patches/chromium/fix_restore_original_resize_performance_on_macos.patch b/patches/chromium/fix_restore_original_resize_performance_on_macos.patch new file mode 100644 index 0000000000..7961fa26bc --- /dev/null +++ b/patches/chromium/fix_restore_original_resize_performance_on_macos.patch @@ -0,0 +1,25 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Samuel Attard +Date: Tue, 21 Nov 2023 15:03:21 -0800 +Subject: fix: restore original resize performance on macOS + +Reverts https://chromium-review.googlesource.com/c/chromium/src/+/3118293 which +fixed a android only regression but in the process regressed electron window +resize perf wildly on macOS. + +diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc +index 749ee4641462aec1142f75de9f0459d7e7cf322f..4dcee366b8bd43add1f7e1dbedaf73403dd944cd 100644 +--- a/content/browser/renderer_host/render_widget_host_impl.cc ++++ b/content/browser/renderer_host/render_widget_host_impl.cc +@@ -2205,9 +2205,8 @@ RenderWidgetHostImpl::GetWidgetInputHandler() { + void RenderWidgetHostImpl::NotifyScreenInfoChanged() { + // The resize message (which may not happen immediately) will carry with it + // the screen info as well as the new size (if the screen has changed scale +- // factor). Force sending the new visual properties even if there is one in +- // flight to ensure proper IPC ordering for features like the Fullscreen API. +- SynchronizeVisualPropertiesIgnoringPendingAck(); ++ // factor). ++ SynchronizeVisualProperties(); + + // The device scale factor will be same for all the views contained by the + // primary main frame, so just set it once.",fix fda8ea9277983836a7f96a979ca07dbcf5eec14c,Jeremy Rose,2023-03-27 10:00:55,feat: add protocol.handle (#36674),"diff --git a/docs/api/client-request.md b/docs/api/client-request.md index f1cb4ef2c2..fc14e20bb5 100644 --- a/docs/api/client-request.md +++ b/docs/api/client-request.md @@ -243,6 +243,8 @@ it is not allowed to add or remove a custom header. * `encoding` string (optional) * `callback` Function (optional) +Returns `this`. + Sends the last chunk of the request data. Subsequent write or end operations will not be allowed. The `finish` event is emitted just after the end operation. diff --git a/docs/api/net.md b/docs/api/net.md index a1199150b7..590c74f7e3 100644 --- a/docs/api/net.md +++ b/docs/api/net.md @@ -65,8 +65,8 @@ requests according to the specified protocol scheme in the `options` object. ### `net.fetch(input[, init])` -* `input` string | [Request](https://nodejs.org/api/globals.html#request) -* `init` [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/fetch#options) (optional) +* `input` string | [GlobalRequest](https://nodejs.org/api/globals.html#request) +* `init` [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/fetch#options) & { bypassCustomProtocolHandlers?: boolean } (optional) Returns `Promise` - see [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response). @@ -101,9 +101,23 @@ Limitations: * The `.type` and `.url` values of the returned `Response` object are incorrect. -Requests made with `net.fetch` can be made to [custom protocols](protocol.md) -as well as `file:`, and will trigger [webRequest](web-request.md) handlers if -present. +By default, requests made with `net.fetch` can be made to [custom +protocols](protocol.md) as well as `file:`, and will trigger +[webRequest](web-request.md) handlers if present. When the non-standard +`bypassCustomProtocolHandlers` option is set in RequestInit, custom protocol +handlers will not be called for this request. This allows forwarding an +intercepted request to the built-in handler. [webRequest](web-request.md) +handlers will still be triggered when bypassing custom protocols. + +```js +protocol.handle('https', (req) => { + if (req.url === 'https://my-app.com') { + return new Response('my app') + } else { + return net.fetch(req, { bypassCustomProtocolHandlers: true }) + } +}) +``` ### `net.isOnline()` diff --git a/docs/api/protocol.md b/docs/api/protocol.md index 8b0d2fbc89..4ca6b5ebb0 100644 --- a/docs/api/protocol.md +++ b/docs/api/protocol.md @@ -8,15 +8,11 @@ An example of implementing a protocol that has the same effect as the `file://` protocol: ```javascript -const { app, protocol } = require('electron') -const path = require('path') -const url = require('url') +const { app, protocol, net } = require('electron') app.whenReady().then(() => { - protocol.registerFileProtocol('atom', (request, callback) => { - const filePath = url.fileURLToPath('file://' + request.url.slice('atom://'.length)) - callback(filePath) - }) + protocol.handle('atom', (request) => + net.fetch('file://' + request.url.slice('atom://'.length))) }) ``` @@ -38,14 +34,15 @@ to register it to that session explicitly. ```javascript const { session, app, protocol } = require('electron') const path = require('path') +const url = require('url') app.whenReady().then(() => { const partition = 'persist:example' const ses = session.fromPartition(partition) - ses.protocol.registerFileProtocol('atom', (request, callback) => { - const url = request.url.substr(7) - callback({ path: path.normalize(`${__dirname}/${url}`) }) + ses.protocol.handle('atom', (request) => { + const path = request.url.slice('atom://'.length) + return net.fetch(url.pathToFileURL(path.join(__dirname, path))) }) mainWindow = new BrowserWindow({ webPreferences: { partition } }) @@ -109,7 +106,74 @@ The `