mirror of
https://github.com/electron/electron.git
synced 2026-02-19 03:14:51 -05:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6457689dce | ||
|
|
7d21b74f7d | ||
|
|
c7ccd12256 | ||
|
|
62929f17cb | ||
|
|
73d8068244 | ||
|
|
125d231ea7 | ||
|
|
497fcd3684 | ||
|
|
81c5e1b4cd | ||
|
|
e3b7531eae | ||
|
|
d36df82a9e | ||
|
|
f839d175a0 |
4
.gitattributes
vendored
4
.gitattributes
vendored
@@ -1,10 +1,14 @@
|
||||
# `git apply` and friends don't understand CRLF, even on windows. Force those
|
||||
# files to be checked out with LF endings even if core.autocrlf is true.
|
||||
*.patch text eol=lf
|
||||
DEPS text eol=lf
|
||||
yarn.lock text eol=lf
|
||||
script/zip_manifests/*.manifest text eol=lf
|
||||
patches/**/.patches merge=union
|
||||
|
||||
# Patch file line ending exceptions (patches that affect CRLF files)
|
||||
reland_lzma_sdk_update_to_24_09.patch -text
|
||||
|
||||
# Source code and markdown files should always use LF as line ending.
|
||||
*.c text eol=lf
|
||||
*.cc text eol=lf
|
||||
|
||||
52
.github/actions/checkout/action.yml
vendored
52
.github/actions/checkout/action.yml
vendored
@@ -9,6 +9,8 @@ inputs:
|
||||
description: 'Whether to persist the cache to the shared drive'
|
||||
required: false
|
||||
default: 'true'
|
||||
target-platform:
|
||||
description: 'Target platform, should be linux, win, macos'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
@@ -18,40 +20,34 @@ runs:
|
||||
echo "GIT_CACHE_PATH=$(pwd)/git-cache" >> $GITHUB_ENV
|
||||
- name: Install Dependencies
|
||||
uses: ./src/electron/.github/actions/install-dependencies
|
||||
- name: Install Build Tools
|
||||
uses: ./src/electron/.github/actions/install-build-tools
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Get Depot Tools
|
||||
shell: bash
|
||||
run: |
|
||||
if [[ ! -d depot_tools ]]; then
|
||||
git clone --depth=1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
|
||||
# Ensure depot_tools does not update.
|
||||
test -d depot_tools && cd depot_tools
|
||||
touch .disable_auto_update
|
||||
fi
|
||||
- name: Add Depot Tools to PATH
|
||||
shell: bash
|
||||
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
|
||||
- name: Install Build Tools
|
||||
uses: ./src/electron/.github/actions/install-build-tools
|
||||
- name: Generate DEPS Hash
|
||||
shell: bash
|
||||
run: |
|
||||
node src/electron/script/generate-deps-hash.js
|
||||
echo "DEPSHASH=v1-src-cache-$(cat src/electron/.depshash)" >> $GITHUB_ENV
|
||||
DEPSHASH="v1-src-cache-$(cat src/electron/.depshash)"
|
||||
echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
|
||||
echo "CACHE_FILE=$DEPSHASH.tar" >> $GITHUB_ENV
|
||||
if [ "${{ inputs.target-platform }}" = "win" ]; then
|
||||
echo "CACHE_DRIVE=/mnt/win-cache" >> $GITHUB_ENV
|
||||
else
|
||||
echo "CACHE_DRIVE=/mnt/cross-instance-cache" >> $GITHUB_ENV
|
||||
fi
|
||||
- name: Generate SAS Key
|
||||
if: ${{ inputs.generate-sas-token == 'true' }}
|
||||
shell: bash
|
||||
run: |
|
||||
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$DEPSHASH.tar" > sas-token
|
||||
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$CACHE_FILE?platform=${{ inputs.target-platform }}" > sas-token
|
||||
- name: Save SAS Key
|
||||
if: ${{ inputs.generate-sas-token == 'true' }}
|
||||
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
|
||||
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf
|
||||
with:
|
||||
path: |
|
||||
sas-token
|
||||
key: sas-key-${{ github.run_number }}-${{ github.run_attempt }}
|
||||
path: sas-token
|
||||
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-${{ github.run_attempt }}
|
||||
enableCrossOsArchive: true
|
||||
- name: Check If Cache Exists
|
||||
id: check-cache
|
||||
shell: bash
|
||||
@@ -60,7 +56,7 @@ runs:
|
||||
echo "Not using cache this time..."
|
||||
echo "cache_exists=false" >> $GITHUB_OUTPUT
|
||||
else
|
||||
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
|
||||
cache_path=$CACHE_DRIVE/$CACHE_FILE
|
||||
echo "Using cache key: $DEPSHASH"
|
||||
echo "Checking for cache in: $cache_path"
|
||||
if [ ! -f "$cache_path" ] || [ `du $cache_path | cut -f1` = "0" ]; then
|
||||
@@ -76,8 +72,8 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
# if there is less than 35 GB free space then creating the cache might fail so exit early
|
||||
freespace=`df -m /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'`
|
||||
freespace_human=`df -h /mnt/cross-instance-cache | grep -w /mnt/cross-instance-cache | awk '{print $4}'`
|
||||
freespace=`df -m $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
|
||||
freespace_human=`df -h $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
|
||||
if [ $freespace -le 35000 ]; then
|
||||
echo "The cross mount cache has $freespace_human free space which is not enough - exiting"
|
||||
exit 1
|
||||
@@ -165,14 +161,14 @@ runs:
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Uncompressed src size: $(du -sh src | cut -f1 -d' ')"
|
||||
tar -cf $DEPSHASH.tar src
|
||||
echo "Compressed src to $(du -sh $DEPSHASH.tar | cut -f1 -d' ')"
|
||||
cp ./$DEPSHASH.tar /mnt/cross-instance-cache/
|
||||
tar -cf $CACHE_FILE src
|
||||
echo "Compressed src to $(du -sh $CACHE_FILE | cut -f1 -d' ')"
|
||||
cp ./$CACHE_FILE $CACHE_DRIVE/
|
||||
- name: Persist Src Cache
|
||||
if: ${{ steps.check-cache.outputs.cache_exists == 'false' && inputs.use-cache == 'true' }}
|
||||
shell: bash
|
||||
run: |
|
||||
final_cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
|
||||
final_cache_path=$CACHE_DRIVE/$CACHE_FILE
|
||||
echo "Using cache key: $DEPSHASH"
|
||||
echo "Checking path: $final_cache_path"
|
||||
if [ ! -f "$final_cache_path" ]; then
|
||||
|
||||
40
.github/actions/cipd-install/action.yml
vendored
Normal file
40
.github/actions/cipd-install/action.yml
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
name: 'CIPD install'
|
||||
description: 'Installs the specified CIPD package'
|
||||
inputs:
|
||||
cipd-root-prefix-path:
|
||||
description: 'Path to prepend to installation directory'
|
||||
default: ''
|
||||
dependency:
|
||||
description: 'Name of dependency to install'
|
||||
deps-file:
|
||||
description: 'Location of DEPS file that defines the dependency'
|
||||
installation-dir:
|
||||
description: 'Location to install dependency'
|
||||
target-platform:
|
||||
description: 'Target platform, should be linux, win, macos'
|
||||
package:
|
||||
description: 'Package to install'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Delete wrong ${{ inputs.dependency }}
|
||||
shell: bash
|
||||
run : |
|
||||
rm -rf ${{ inputs.cipd-root-prefix-path }}${{ inputs.installation-dir }}
|
||||
- name: Create ensure file for ${{ inputs.dependency }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo '${{ inputs.package }}' `e d gclient getdep --deps-file=${{ inputs.deps-file }} -r '${{ inputs.installation-dir }}:${{ inputs.package }}'` > ${{ inputs.dependency }}_ensure_file
|
||||
cat ${{ inputs.dependency }}_ensure_file
|
||||
- name: CIPD installation of ${{ inputs.dependency }} (macOS)
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "ensuring ${{ inputs.dependency }} on macOS"
|
||||
e d cipd ensure --root ${{ inputs.cipd-root-prefix-path }}${{ inputs.installation-dir }} -ensure-file ${{ inputs.dependency }}_ensure_file
|
||||
- name: CIPD installation of ${{ inputs.dependency }} (Windows)
|
||||
if: ${{ inputs.target-platform == 'win' }}
|
||||
shell: powershell
|
||||
run: |
|
||||
echo "ensuring ${{ inputs.dependency }} on Windows"
|
||||
e d cipd ensure --root ${{ inputs.cipd-root-prefix-path }}${{ inputs.installation-dir }} -ensure-file ${{ inputs.dependency }}_ensure_file
|
||||
61
.github/actions/fix-sync-macos/action.yml
vendored
61
.github/actions/fix-sync-macos/action.yml
vendored
@@ -1,61 +0,0 @@
|
||||
name: 'Fix Sync macOS'
|
||||
description: 'Checks out Electron and stores it in the AKS Cache'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Fix Sync
|
||||
shell: bash
|
||||
# This step is required to correct for differences between "gclient sync"
|
||||
# on Linux and the expected state on macOS. This requires:
|
||||
# 1. Fixing Clang Install (wrong binary)
|
||||
# 2. Fixing esbuild (wrong binary)
|
||||
# 3. Fixing rustc (wrong binary)
|
||||
# 4. Fixing gn (wrong binary)
|
||||
# 5. Fix reclient (wrong binary)
|
||||
# 6. Fixing dsymutil (wrong binary)
|
||||
# 7. Ensuring we are using the correct ninja and adding it to PATH
|
||||
# 8. Fixing angle (wrong remote)
|
||||
run : |
|
||||
SEDOPTION="-i ''"
|
||||
rm -rf src/third_party/llvm-build
|
||||
python3 src/tools/clang/scripts/update.py
|
||||
|
||||
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
|
||||
|
||||
rm -rf src/third_party/rust-toolchain
|
||||
python3 src/tools/rust/update_rust.py
|
||||
|
||||
# Prevent calling gclient getdep which always calls update_depot_tools
|
||||
echo 'gn/gn/mac-${arch}' `gclient getdep --deps-file=src/DEPS -r 'src/buildtools/mac:gn/gn/mac-${arch}'` > gn_ensure_file
|
||||
sed -i '' "s/Updating depot_tools... //g" gn_ensure_file
|
||||
cipd ensure --root src/buildtools/mac -ensure-file gn_ensure_file
|
||||
|
||||
# Prevent calling gclient getdep which always calls update_depot_tools
|
||||
echo 'infra/rbe/client/${platform}' `gclient getdep --deps-file=src/DEPS -r 'src/buildtools/reclient:infra/rbe/client/${platform}'` > gn_ensure_file
|
||||
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
|
||||
|
||||
if [ "${{ env.TARGET_ARCH }}" == "arm64" ]; then
|
||||
DSYM_SHA_FILE=src/tools/clang/dsymutil/bin/dsymutil.arm64.sha1
|
||||
else
|
||||
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
|
||||
|
||||
echo 'infra/3pp/tools/ninja/${platform}' `gclient getdep --deps-file=src/DEPS -r 'src/third_party/ninja:infra/3pp/tools/ninja/${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
|
||||
|
||||
echo "$(pwd)/src/third_party/ninja" >> $GITHUB_PATH
|
||||
|
||||
cd src/third_party/angle
|
||||
rm -f .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
|
||||
121
.github/actions/fix-sync/action.yml
vendored
Normal file
121
.github/actions/fix-sync/action.yml
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
name: 'Fix Sync'
|
||||
description: 'Ensures proper binaries are in place'
|
||||
# This action is required to correct for differences between "gclient sync"
|
||||
# on Linux and the expected state on macOS/windows. This requires:
|
||||
# 1. Fixing Clang Install (wrong binary)
|
||||
# 2. Fixing esbuild (wrong binary)
|
||||
# 3. Fixing rustc (wrong binary)
|
||||
# 4. Fixing gn (wrong binary)
|
||||
# 5. Fix reclient (wrong binary)
|
||||
# 6. Fixing dsymutil (wrong binary)
|
||||
# 7. Ensuring we are using the correct ninja and adding it to PATH
|
||||
# 8. Fixing angle (wrong remote)
|
||||
# 9. Install windows toolchain on Windows
|
||||
# 10. Fix node binary on Windows
|
||||
# 11. Fix rc binary on Windows
|
||||
inputs:
|
||||
target-platform:
|
||||
description: 'Target platform, should be linux, win, macos'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Fix clang
|
||||
shell: bash
|
||||
run : |
|
||||
rm -rf src/third_party/llvm-build
|
||||
python3 src/tools/clang/scripts/update.py
|
||||
- name: Fix esbuild
|
||||
uses: ./src/electron/.github/actions/cipd-install
|
||||
with:
|
||||
cipd-root-prefix-path: src/third_party/devtools-frontend/src/
|
||||
dependency: esbuild
|
||||
deps-file: src/third_party/devtools-frontend/src/DEPS
|
||||
installation-dir: third_party/esbuild
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
package: infra/3pp/tools/esbuild/${platform}
|
||||
- name: Fix rustc
|
||||
shell: bash
|
||||
run : |
|
||||
rm -rf src/third_party/rust-toolchain
|
||||
python3 src/tools/rust/update_rust.py
|
||||
- name: Fix gn (macOS)
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
uses: ./src/electron/.github/actions/cipd-install
|
||||
with:
|
||||
dependency: gn
|
||||
deps-file: src/DEPS
|
||||
installation-dir: src/buildtools/mac
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
package: gn/gn/mac-${arch}
|
||||
- name: Fix gn (Windows)
|
||||
if: ${{ inputs.target-platform == 'win' }}
|
||||
uses: ./src/electron/.github/actions/cipd-install
|
||||
with:
|
||||
dependency: gn
|
||||
deps-file: src/DEPS
|
||||
installation-dir: src/buildtools/win
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
package: gn/gn/windows-amd64
|
||||
- name: Fix reclient
|
||||
uses: ./src/electron/.github/actions/cipd-install
|
||||
with:
|
||||
dependency: reclient
|
||||
deps-file: src/DEPS
|
||||
installation-dir: src/buildtools/reclient
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
package: infra/rbe/client/${platform}
|
||||
- name: Configure reclient configs
|
||||
shell: bash
|
||||
run : |
|
||||
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
|
||||
- name: Fix dsymutil (macOS)
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
shell: bash
|
||||
run : |
|
||||
# Fix dsymutil
|
||||
if [ "${{ inputs.target-platform }}" = "macos" ]; then
|
||||
if [ "${{ env.TARGET_ARCH }}" == "arm64" ]; then
|
||||
DSYM_SHA_FILE=src/tools/clang/dsymutil/bin/dsymutil.arm64.sha1
|
||||
else
|
||||
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
|
||||
- name: Fix ninja
|
||||
uses: ./src/electron/.github/actions/cipd-install
|
||||
with:
|
||||
dependency: ninja
|
||||
deps-file: src/DEPS
|
||||
installation-dir: src/third_party/ninja
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
package: infra/3pp/tools/ninja/${platform}
|
||||
- name: Set ninja in path
|
||||
shell: bash
|
||||
run : |
|
||||
echo "$(pwd)/src/third_party/ninja" >> $GITHUB_PATH
|
||||
- name: Fixup angle git
|
||||
shell: bash
|
||||
run : |
|
||||
cd src/third_party/angle
|
||||
rm -f .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
|
||||
- name: Get Windows toolchain
|
||||
if: ${{ inputs.target-platform == 'win' }}
|
||||
shell: powershell
|
||||
run: e d vpython3 src\build\vs_toolchain.py update --force
|
||||
- name: Download nodejs
|
||||
if: ${{ inputs.target-platform == 'win' }}
|
||||
shell: powershell
|
||||
run: |
|
||||
$nodedeps = e d gclient getdep --deps-file=src/DEPS -r src/third_party/node/win | ConvertFrom-JSON
|
||||
$sha1 = $nodedeps.object_name.split('/')[1]
|
||||
python3 src\third_party\depot_tools\download_from_google_storage.py --no_resume --no_auth --bucket chromium-nodejs -o src\third_party\node\win\node.exe $sha1
|
||||
- name: Install rc
|
||||
if: ${{ inputs.target-platform == 'win' }}
|
||||
shell: bash
|
||||
run: |
|
||||
python3 src/third_party/depot_tools/download_from_google_storage.py --no_resume --no_auth --bucket chromium-browser-clang/rc -s src/build/toolchain/win/rc/win/rc.exe.sha1
|
||||
@@ -14,7 +14,9 @@ runs:
|
||||
export BUILD_TOOLS_SHA=8246e57791b0af4ae5975eb96f09855f9269b1cd
|
||||
npm i -g @electron/build-tools
|
||||
e auto-update disable
|
||||
e d auto-update disable
|
||||
if [ "$(expr substr $(uname -s) 1 10)" == "MSYS_NT-10" ]; then
|
||||
e d cipd.bat --version
|
||||
cp "C:\Python311\python.exe" "C:\Python311\python3.exe"
|
||||
fi
|
||||
echo "$HOME/.electron_build_tools/third_party/depot_tools" >> $GITHUB_PATH
|
||||
|
||||
10
.github/actions/restore-cache-aks/action.yml
vendored
10
.github/actions/restore-cache-aks/action.yml
vendored
@@ -1,12 +1,20 @@
|
||||
name: 'Restore Cache AKS'
|
||||
description: 'Restores Electron src cache via AKS'
|
||||
inputs:
|
||||
target-platform:
|
||||
description: 'Target platform, should be linux, win, macos'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Restore and Ensure Src Cache
|
||||
shell: bash
|
||||
run: |
|
||||
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
|
||||
if [ "${{ inputs.target-platform }}" = "win" ]; then
|
||||
cache_path=/mnt/win-cache/$DEPSHASH.tar
|
||||
else
|
||||
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
|
||||
fi
|
||||
|
||||
echo "Using cache key: $DEPSHASH"
|
||||
echo "Checking for cache in: $cache_path"
|
||||
if [ ! -f "$cache_path" ]; then
|
||||
|
||||
75
.github/actions/restore-cache-azcopy/action.yml
vendored
75
.github/actions/restore-cache-azcopy/action.yml
vendored
@@ -1,22 +1,25 @@
|
||||
name: 'Restore Cache AZCopy'
|
||||
description: 'Restores Electron src cache via AZCopy'
|
||||
inputs:
|
||||
target-platform:
|
||||
description: 'Target platform, should be linux, win, macos'
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Obtain SAS Key
|
||||
continue-on-error: true
|
||||
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
|
||||
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf
|
||||
with:
|
||||
path: |
|
||||
sas-token
|
||||
key: sas-key-${{ github.run_number }}-1
|
||||
path: sas-token
|
||||
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-1
|
||||
enableCrossOsArchive: true
|
||||
- name: Obtain SAS Key
|
||||
continue-on-error: true
|
||||
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
|
||||
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf
|
||||
with:
|
||||
path: |
|
||||
sas-token
|
||||
key: sas-key-${{ github.run_number }}-${{ github.run_attempt }}
|
||||
path: sas-token
|
||||
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-${{ github.run_attempt }}
|
||||
enableCrossOsArchive: true
|
||||
- name: Download Src Cache from AKS
|
||||
# The cache will always exist here as a result of the checkout job
|
||||
# Either it was uploaded to Azure in the checkout job for this commit
|
||||
@@ -26,21 +29,30 @@ runs:
|
||||
timeout_minutes: 30
|
||||
max_attempts: 3
|
||||
retry_on: error
|
||||
shell: bash
|
||||
command: |
|
||||
sas_token=$(cat sas-token)
|
||||
if [ -z $sas-token ]; then
|
||||
echo "SAS Token not found; exiting src cache download early..."
|
||||
exit 1
|
||||
else
|
||||
if [ "${{ inputs.target-platform }}" = "win" ]; then
|
||||
azcopy copy --log-level=ERROR \
|
||||
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_WIN_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
|
||||
else
|
||||
azcopy copy --log-level=ERROR \
|
||||
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
|
||||
fi
|
||||
fi
|
||||
azcopy copy --log-level=ERROR \
|
||||
"https://${{ env.AZURE_AKS_CACHE_STORAGE_ACCOUNT }}.file.core.windows.net/${{ env.AZURE_AKS_CACHE_SHARE_NAME }}/${{ env.CACHE_PATH }}?$sas_token" $DEPSHASH.tar
|
||||
env:
|
||||
AZURE_AKS_CACHE_STORAGE_ACCOUNT: f723719aa87a34622b5f7f3
|
||||
AZURE_AKS_CACHE_SHARE_NAME: pvc-f6a4089f-b082-4bee-a3f9-c3e1c0c02d8f
|
||||
AZURE_AKS_WIN_CACHE_SHARE_NAME: pvc-71dec4f2-0d44-4fd1-a2c3-add049d70bdf
|
||||
- name: Clean SAS Key
|
||||
shell: bash
|
||||
run: rm -f sas-token
|
||||
- name: Unzip and Ensure Src Cache
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
shell: bash
|
||||
run: |
|
||||
echo "Downloaded cache is $(du -sh $DEPSHASH.tar | cut -f1)"
|
||||
@@ -68,4 +80,45 @@ runs:
|
||||
fi
|
||||
|
||||
echo "Wiping Electron Directory"
|
||||
rm -rf src/electron
|
||||
rm -rf src/electron
|
||||
|
||||
- name: Unzip and Ensure Src Cache (Windows)
|
||||
if: ${{ inputs.target-platform == 'win' }}
|
||||
shell: powershell
|
||||
run: |
|
||||
$src_cache = "$env:DEPSHASH.tar"
|
||||
$cache_size = $(Get-Item $src_cache).length
|
||||
Write-Host "Downloaded cache is $cache_size"
|
||||
if ($cache_size -eq 0) {
|
||||
Write-Host "Cache is empty - exiting"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$TEMP_DIR=New-Item -ItemType Directory -Path temp-cache
|
||||
$TEMP_DIR_PATH = $TEMP_DIR.FullName
|
||||
C:\ProgramData\Chocolatey\bin\7z.exe -y x $src_cache -o"$TEMP_DIR_PATH"
|
||||
|
||||
- name: Move Src Cache (Windows)
|
||||
if: ${{ inputs.target-platform == 'win' }}
|
||||
uses: nick-fields/retry@7152eba30c6575329ac0576536151aca5a72780e # v3.0.0
|
||||
with:
|
||||
timeout_minutes: 30
|
||||
max_attempts: 3
|
||||
retry_on: error
|
||||
shell: powershell
|
||||
command: |
|
||||
if (Test-Path "temp-cache\src") {
|
||||
Write-Host "Relocating Cache"
|
||||
Remove-Item -Recurse -Force src
|
||||
Move-Item temp-cache\src src
|
||||
|
||||
Write-Host "Deleting zip file"
|
||||
Remove-Item -Force $src_cache
|
||||
}
|
||||
if (-Not (Test-Path "src\third_party\blink")) {
|
||||
Write-Host "Cache was not correctly restored - exiting"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Wiping Electron Directory"
|
||||
Remove-Item -Recurse -Force src\electron
|
||||
|
||||
15
.github/workflows/build.yml
vendored
15
.github/workflows/build.yml
vendored
@@ -115,6 +115,7 @@ jobs:
|
||||
uses: ./src/electron/.github/actions/checkout
|
||||
with:
|
||||
generate-sas-token: 'true'
|
||||
target-platform: macos
|
||||
|
||||
checkout-linux:
|
||||
needs: setup
|
||||
@@ -150,7 +151,8 @@ jobs:
|
||||
image: ghcr.io/electron/build:${{ needs.setup.outputs.build-image-sha }}
|
||||
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
|
||||
volumes:
|
||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||
- /mnt/win-cache:/mnt/win-cache
|
||||
- /var/run/sas:/var/run/sas
|
||||
env:
|
||||
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
|
||||
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
|
||||
@@ -168,6 +170,9 @@ jobs:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Checkout & Sync & Save
|
||||
uses: ./src/electron/.github/actions/checkout
|
||||
with:
|
||||
generate-sas-token: 'true'
|
||||
target-platform: win
|
||||
|
||||
# GN Check Jobs
|
||||
macos-gn-check:
|
||||
@@ -198,7 +203,7 @@ jobs:
|
||||
target-platform: win
|
||||
target-archs: x64 x86 arm64
|
||||
check-runs-on: electron-arc-linux-amd64-8core
|
||||
check-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-windows.outputs.build-image-sha }}","options":"--user root --device /dev/fuse --cap-add SYS_ADMIN","volumes":["/mnt/cross-instance-cache:/mnt/cross-instance-cache"]}'
|
||||
check-container: '{"image":"ghcr.io/electron/build:${{ needs.checkout-windows.outputs.build-image-sha }}","options":"--user root --device /dev/fuse --cap-add SYS_ADMIN","volumes":["/mnt/win-cache:/mnt/win-cache"]}'
|
||||
gn-build-type: testing
|
||||
secrets: inherit
|
||||
|
||||
@@ -326,7 +331,7 @@ jobs:
|
||||
issues: read
|
||||
pull-requests: read
|
||||
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
|
||||
needs: setup
|
||||
needs: checkout-windows
|
||||
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
||||
with:
|
||||
build-runs-on: electron-arc-windows-amd64-16core
|
||||
@@ -345,7 +350,7 @@ jobs:
|
||||
issues: read
|
||||
pull-requests: read
|
||||
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
|
||||
needs: setup
|
||||
needs: checkout-windows
|
||||
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
||||
with:
|
||||
build-runs-on: electron-arc-windows-amd64-16core
|
||||
@@ -364,7 +369,7 @@ jobs:
|
||||
issues: read
|
||||
pull-requests: read
|
||||
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
|
||||
needs: setup
|
||||
needs: checkout-windows
|
||||
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
|
||||
with:
|
||||
build-runs-on: electron-arc-windows-amd64-16core
|
||||
|
||||
4
.github/workflows/clean-src-cache.yml
vendored
4
.github/workflows/clean-src-cache.yml
vendored
@@ -16,6 +16,7 @@ jobs:
|
||||
options: --user root
|
||||
volumes:
|
||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||
- /mnt/win-cache:/mnt/win-cache
|
||||
steps:
|
||||
- name: Cleanup Source Cache
|
||||
shell: bash
|
||||
@@ -23,3 +24,6 @@ jobs:
|
||||
df -h /mnt/cross-instance-cache
|
||||
find /mnt/cross-instance-cache -type f -mtime +15 -delete
|
||||
df -h /mnt/cross-instance-cache
|
||||
df -h /mnt/win-cache
|
||||
find /mnt/win-cache -type f -mtime +15 -delete
|
||||
df -h /mnt/win-cache
|
||||
|
||||
1
.github/workflows/macos-publish.yml
vendored
1
.github/workflows/macos-publish.yml
vendored
@@ -39,6 +39,7 @@ jobs:
|
||||
uses: ./src/electron/.github/actions/checkout
|
||||
with:
|
||||
generate-sas-token: 'true'
|
||||
target-platform: macos
|
||||
|
||||
publish-x64-darwin:
|
||||
uses: ./.github/workflows/pipeline-segment-electron-build.yml
|
||||
|
||||
@@ -129,24 +129,8 @@ jobs:
|
||||
echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Get Depot Tools
|
||||
timeout-minutes: 5
|
||||
run: |
|
||||
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
|
||||
SEDOPTION="-i"
|
||||
if [ "`uname`" = "Darwin" ]; then
|
||||
SEDOPTION="-i ''"
|
||||
fi
|
||||
|
||||
# remove ninjalog_uploader_wrapper.py from autoninja since we don't use it and it causes problems
|
||||
sed $SEDOPTION '/ninjalog_uploader_wrapper.py/d' ./depot_tools/autoninja
|
||||
|
||||
# Ensure depot_tools does not update.
|
||||
test -d depot_tools && cd depot_tools
|
||||
touch .disable_auto_update
|
||||
- name: Add Depot Tools to PATH
|
||||
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
|
||||
- name: Install Build Tools
|
||||
uses: ./src/electron/.github/actions/install-build-tools
|
||||
- name: Generate DEPS Hash
|
||||
run: |
|
||||
node src/electron/script/generate-deps-hash.js
|
||||
@@ -154,24 +138,26 @@ jobs:
|
||||
echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
|
||||
echo "CACHE_PATH=$DEPSHASH.tar" >> $GITHUB_ENV
|
||||
- name: Restore src cache via AZCopy
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
if: ${{ inputs.target-platform != 'linux' }}
|
||||
uses: ./src/electron/.github/actions/restore-cache-azcopy
|
||||
with:
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
- name: Restore src cache via AKS
|
||||
if: ${{ inputs.target-platform == 'linux' }}
|
||||
uses: ./src/electron/.github/actions/restore-cache-aks
|
||||
- name: Checkout src via gclient sync
|
||||
if: ${{ inputs.target-platform == 'win' }}
|
||||
uses: ./src/electron/.github/actions/checkout
|
||||
with:
|
||||
use-cache: 'false'
|
||||
- name: Checkout Electron
|
||||
uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
|
||||
with:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Install Build Tools
|
||||
uses: ./src/electron/.github/actions/install-build-tools
|
||||
- name: Fix Sync
|
||||
if: ${{ inputs.target-platform != 'linux' }}
|
||||
uses: ./src/electron/.github/actions/fix-sync
|
||||
with:
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
env:
|
||||
ELECTRON_DEPOT_TOOLS_DISABLE_LOG: true
|
||||
- name: Init Build Tools
|
||||
run: |
|
||||
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }}
|
||||
@@ -184,9 +170,6 @@ jobs:
|
||||
echo "DEPSHASH=$(cat src/electron/.depshash)" >> $GITHUB_ENV
|
||||
- name: Add CHROMIUM_BUILDTOOLS_PATH to env
|
||||
run: echo "CHROMIUM_BUILDTOOLS_PATH=$(pwd)/src/buildtools" >> $GITHUB_ENV
|
||||
- name: Fix Sync (macOS)
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
uses: ./src/electron/.github/actions/fix-sync-macos
|
||||
- name: Setup Number of Ninja Processes
|
||||
run: |
|
||||
echo "NUMBER_OF_NINJA_PROCESSES=${{ inputs.target-platform != 'macos' && '300' || '200' }}" >> $GITHUB_ENV
|
||||
|
||||
@@ -65,7 +65,9 @@ jobs:
|
||||
sudo rm -rf $TMPDIR/del-target
|
||||
- name: Check disk space after freeing up space
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
run: df -h
|
||||
run: df -h
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Install Build Tools
|
||||
uses: ./src/electron/.github/actions/install-build-tools
|
||||
- name: Enable windows toolchain
|
||||
@@ -81,9 +83,13 @@ jobs:
|
||||
- name: Restore src cache via AZCopy
|
||||
if: ${{ inputs.target-platform == 'macos' }}
|
||||
uses: ./src/electron/.github/actions/restore-cache-azcopy
|
||||
with:
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
- name: Restore src cache via AKS
|
||||
if: ${{ inputs.target-platform == 'linux' || inputs.target-platform == 'win' }}
|
||||
uses: ./src/electron/.github/actions/restore-cache-aks
|
||||
with:
|
||||
target-platform: ${{ inputs.target-platform }}
|
||||
- name: Run Electron Only Hooks
|
||||
run: |
|
||||
echo "solutions=[{'name':'src/electron','url':None,'deps_file':'DEPS','custom_vars':{'process_deps':False},'managed':False}]" > tmpgclient
|
||||
|
||||
@@ -51,6 +51,8 @@ jobs:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Install Build Tools
|
||||
uses: ./src/electron/.github/actions/install-build-tools
|
||||
- name: Init Build Tools
|
||||
@@ -58,17 +60,6 @@ jobs:
|
||||
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }} --import ${{ inputs.gn-build-type }} --target-cpu ${{ inputs.target-arch }}
|
||||
- name: Install Dependencies
|
||||
uses: ./src/electron/.github/actions/install-dependencies
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Get Depot Tools
|
||||
timeout-minutes: 5
|
||||
run: |
|
||||
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
# Ensure depot_tools does not update.
|
||||
test -d depot_tools && cd depot_tools
|
||||
touch .disable_auto_update
|
||||
- name: Add Depot Tools to PATH
|
||||
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
|
||||
- name: Download Generated Artifacts
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
|
||||
with:
|
||||
@@ -114,6 +105,8 @@ jobs:
|
||||
path: src/electron
|
||||
fetch-depth: 0
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Install Build Tools
|
||||
uses: ./src/electron/.github/actions/install-build-tools
|
||||
- name: Init Build Tools
|
||||
@@ -121,17 +114,6 @@ jobs:
|
||||
e init -f --root=$(pwd) --out=Default ${{ inputs.gn-build-type }}
|
||||
- name: Install Dependencies
|
||||
uses: ./src/electron/.github/actions/install-dependencies
|
||||
- name: Set Chromium Git Cookie
|
||||
uses: ./src/electron/.github/actions/set-chromium-cookie
|
||||
- name: Get Depot Tools
|
||||
timeout-minutes: 5
|
||||
run: |
|
||||
git clone --filter=tree:0 https://chromium.googlesource.com/chromium/tools/depot_tools.git
|
||||
# Ensure depot_tools does not update.
|
||||
test -d depot_tools && cd depot_tools
|
||||
touch .disable_auto_update
|
||||
- name: Add Depot Tools to PATH
|
||||
run: echo "$(pwd)/depot_tools" >> $GITHUB_PATH
|
||||
- name: Download Generated Artifacts
|
||||
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
|
||||
with:
|
||||
|
||||
6
.github/workflows/windows-publish.yml
vendored
6
.github/workflows/windows-publish.yml
vendored
@@ -25,7 +25,8 @@ jobs:
|
||||
image: ghcr.io/electron/build:${{ inputs.build-image-sha }}
|
||||
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
|
||||
volumes:
|
||||
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
|
||||
- /mnt/win-cache:/mnt/win-cache
|
||||
- /var/run/sas:/var/run/sas
|
||||
env:
|
||||
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_win=True'
|
||||
TARGET_OS: 'win'
|
||||
@@ -40,6 +41,9 @@ jobs:
|
||||
fetch-depth: 0
|
||||
- name: Checkout & Sync & Save
|
||||
uses: ./src/electron/.github/actions/checkout
|
||||
with:
|
||||
generate-sas-token: 'true'
|
||||
target-platform: win
|
||||
|
||||
publish-x64-win:
|
||||
uses: ./.github/workflows/pipeline-segment-electron-build.yml
|
||||
|
||||
@@ -150,3 +150,4 @@ add_a_flag_to_enable_strict_js_compliance_in_audioworklet.patch
|
||||
remove_denormalenabler_from_scriptprocessornode.patch
|
||||
allow_denormal_flushing_to_outlive_scoped_object.patch
|
||||
fix_take_snapped_status_into_account_when_showing_a_window.patch
|
||||
cherry-pick-b8f80176b163.patch
|
||||
|
||||
174
patches/chromium/cherry-pick-b8f80176b163.patch
Normal file
174
patches/chromium/cherry-pick-b8f80176b163.patch
Normal file
@@ -0,0 +1,174 @@
|
||||
From b8f80176b1636154c6bfc85a607b05cc3aec50cb Mon Sep 17 00:00:00 2001
|
||||
From: Alex Gough <ajgo@chromium.org>
|
||||
Date: Mon, 24 Mar 2025 09:04:37 -0700
|
||||
Subject: [PATCH] Avoid receiving or sending sentinel handle values
|
||||
|
||||
These values can be misinterpreted by OS functions, so
|
||||
avoid sending or receiving them over IPCZ.
|
||||
|
||||
(cherry picked from commit 36dbbf38697dd1e23ef8944bb9e57f6e0b3d41ec)
|
||||
|
||||
Bug: 405143032
|
||||
Change-Id: Ib578fb4727e78e2697c60c42005daa97e08695e9
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6380193
|
||||
Reviewed-by: Will Harris <wfh@chromium.org>
|
||||
Commit-Queue: Alex Gough <ajgo@chromium.org>
|
||||
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
|
||||
Cr-Original-Commit-Position: refs/heads/main@{#1436135}
|
||||
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6383569
|
||||
Owners-Override: Srinivas Sista <srinivassista@chromium.org>
|
||||
Commit-Queue: Srinivas Sista <srinivassista@chromium.org>
|
||||
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
|
||||
Cr-Commit-Position: refs/branch-heads/6998@{#2315}
|
||||
Cr-Branched-From: de9c6fafd8ae5c6ea0438764076ca7d04a0b165d-refs/heads/main@{#1415337}
|
||||
---
|
||||
|
||||
diff --git a/base/win/win_util.h b/base/win/win_util.h
|
||||
index c10538d..0bc93a25 100644
|
||||
--- a/base/win/win_util.h
|
||||
+++ b/base/win/win_util.h
|
||||
@@ -49,6 +49,25 @@
|
||||
|
||||
namespace win {
|
||||
|
||||
+inline bool IsPseudoHandle(HANDLE h) {
|
||||
+ // Note that there appears to be no official documentation covering the
|
||||
+ // existence of specific pseudo handle values. In practice it's clear that
|
||||
+ // e.g. -1 is the current process, -2 is the current thread, etc. The largest
|
||||
+ // negative value known to be an issue with DuplicateHandle in fuzzers is
|
||||
+ // -12.
|
||||
+ //
|
||||
+ // Note that there is virtually no risk of a real handle value falling within
|
||||
+ // this range and being misclassified as a pseudo handle.
|
||||
+ //
|
||||
+ // Cast through uintptr_t and then unsigned int to make the truncation to
|
||||
+ // 32 bits explicit. Handles are size of-pointer but are always 32-bit values.
|
||||
+ // https://msdn.microsoft.com/en-us/library/aa384203(VS.85).aspx says:
|
||||
+ // 64-bit versions of Windows use 32-bit handles for interoperability.
|
||||
+ constexpr int kMinimumKnownPseudoHandleValue = -12;
|
||||
+ const auto value = static_cast<int32_t>(reinterpret_cast<uintptr_t>(h));
|
||||
+ return value < 0 && value >= kMinimumKnownPseudoHandleValue;
|
||||
+}
|
||||
+
|
||||
inline uint32_t HandleToUint32(HANDLE h) {
|
||||
// Cast through uintptr_t and then unsigned int to make the truncation to
|
||||
// 32 bits explicit. Handles are size of-pointer but are always 32-bit values.
|
||||
diff --git a/base/win/win_util_unittest.cc b/base/win/win_util_unittest.cc
|
||||
index 70eedf10..f8bbc0b 100644
|
||||
--- a/base/win/win_util_unittest.cc
|
||||
+++ b/base/win/win_util_unittest.cc
|
||||
@@ -91,6 +91,12 @@
|
||||
EXPECT_EQ(INVALID_HANDLE_VALUE, Uint32ToHandle(invalid_handle));
|
||||
}
|
||||
|
||||
+TEST(BaseWinUtilTest, PseudoHandles) {
|
||||
+ EXPECT_TRUE(IsPseudoHandle(::GetCurrentProcess()));
|
||||
+ EXPECT_TRUE(IsPseudoHandle(::GetCurrentThread()));
|
||||
+ EXPECT_FALSE(IsPseudoHandle(nullptr));
|
||||
+}
|
||||
+
|
||||
TEST(BaseWinUtilTest, WStringFromGUID) {
|
||||
const GUID kGuid = {0x7698f759,
|
||||
0xf5b0,
|
||||
diff --git a/mojo/core/ipcz_driver/transport.cc b/mojo/core/ipcz_driver/transport.cc
|
||||
index 96918f8..d1e3286 100644
|
||||
--- a/mojo/core/ipcz_driver/transport.cc
|
||||
+++ b/mojo/core/ipcz_driver/transport.cc
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "third_party/ipcz/include/ipcz/ipcz.h"
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
+#include "base/win/win_util.h"
|
||||
#include "mojo/public/cpp/platform/platform_handle_security_util_win.h"
|
||||
#endif
|
||||
|
||||
@@ -135,10 +136,12 @@
|
||||
HandleOwner handle_owner,
|
||||
HandleData& out_handle_data,
|
||||
bool is_remote_process_untrusted) {
|
||||
+ CHECK(handle.is_valid());
|
||||
// Duplicating INVALID_HANDLE_VALUE passes a process handle. If you intend to
|
||||
// do this, you must open a valid process handle, not pass the result of
|
||||
- // GetCurrentProcess(). e.g. https://crbug.com/243339.
|
||||
- CHECK(handle.is_valid());
|
||||
+ // GetCurrentProcess() or GetCurrentThread(). e.g. https://crbug.com/243339.
|
||||
+ CHECK(!handle.is_pseudo_handle());
|
||||
+
|
||||
if (handle_owner == HandleOwner::kSender) {
|
||||
// Nothing to do when sending handles that belong to us. The recipient must
|
||||
// be sufficiently privileged and equipped to duplicate such handles to
|
||||
@@ -178,6 +181,10 @@
|
||||
HandleOwner handle_owner,
|
||||
Transport& from_transport) {
|
||||
const HANDLE handle = DataToHandle(data);
|
||||
+ // Do not decode sentinel values used by Windows (INVALID_HANDLE_VALUE &
|
||||
+ // GetCurrentThread()).
|
||||
+ CHECK(!base::win::IsPseudoHandle(handle));
|
||||
+
|
||||
if (handle_owner == HandleOwner::kRecipient) {
|
||||
if (from_transport.destination_type() != Transport::kBroker &&
|
||||
!from_transport.is_peer_trusted() && !remote_process.is_current()) {
|
||||
diff --git a/mojo/core/platform_handle_in_transit.cc b/mojo/core/platform_handle_in_transit.cc
|
||||
index 44330d2..670dca4 100644
|
||||
--- a/mojo/core/platform_handle_in_transit.cc
|
||||
+++ b/mojo/core/platform_handle_in_transit.cc
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "base/win/nt_status.h"
|
||||
#include "base/win/scoped_handle.h"
|
||||
+#include "base/win/win_util.h"
|
||||
#include "mojo/public/cpp/platform/platform_handle_security_util_win.h"
|
||||
#endif
|
||||
|
||||
@@ -37,8 +38,8 @@
|
||||
|
||||
// Duplicating INVALID_HANDLE_VALUE passes a process handle. If you intend to
|
||||
// do this, you must open a valid process handle, not pass the result of
|
||||
- // GetCurrentProcess(). e.g. https://crbug.com/243339.
|
||||
- CHECK(handle != INVALID_HANDLE_VALUE);
|
||||
+ // GetCurrentProcess() or GetCurrentThread(). e.g. https://crbug.com/243339.
|
||||
+ CHECK(!base::win::IsPseudoHandle(handle));
|
||||
|
||||
HANDLE out_handle;
|
||||
BOOL result =
|
||||
@@ -164,17 +165,7 @@
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
// static
|
||||
bool PlatformHandleInTransit::IsPseudoHandle(HANDLE handle) {
|
||||
- // Note that there appears to be no official documentation covering the
|
||||
- // existence of specific pseudo handle values. In practice it's clear that
|
||||
- // e.g. -1 is the current process, -2 is the current thread, etc. The largest
|
||||
- // negative value known to be an issue with DuplicateHandle in the fuzzer is
|
||||
- // -12.
|
||||
- //
|
||||
- // Note that there is virtually no risk of a real handle value falling within
|
||||
- // this range and being misclassified as a pseudo handle.
|
||||
- constexpr int kMinimumKnownPseudoHandleValue = -12;
|
||||
- const auto value = static_cast<int32_t>(reinterpret_cast<uintptr_t>(handle));
|
||||
- return value < 0 && value >= kMinimumKnownPseudoHandleValue;
|
||||
+ return base::win::IsPseudoHandle(handle);
|
||||
}
|
||||
|
||||
// static
|
||||
diff --git a/mojo/public/cpp/platform/platform_handle.h b/mojo/public/cpp/platform/platform_handle.h
|
||||
index 7154aeb..3390540d 100644
|
||||
--- a/mojo/public/cpp/platform/platform_handle.h
|
||||
+++ b/mojo/public/cpp/platform/platform_handle.h
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#if BUILDFLAG(IS_WIN)
|
||||
#include "base/win/scoped_handle.h"
|
||||
+#include "base/win/win_util.h"
|
||||
#elif BUILDFLAG(IS_FUCHSIA)
|
||||
#include <lib/zx/handle.h>
|
||||
#elif BUILDFLAG(IS_APPLE)
|
||||
@@ -117,6 +118,9 @@
|
||||
bool is_valid() const { return is_valid_handle(); }
|
||||
bool is_valid_handle() const { return handle_.IsValid(); }
|
||||
bool is_handle() const { return type_ == Type::kHandle; }
|
||||
+ bool is_pseudo_handle() const {
|
||||
+ return base::win::IsPseudoHandle(handle_.get());
|
||||
+ }
|
||||
const base::win::ScopedHandle& GetHandle() const { return handle_; }
|
||||
base::win::ScopedHandle TakeHandle() {
|
||||
DCHECK_EQ(type_, Type::kHandle);
|
||||
@@ -33,10 +33,6 @@ namespace base {
|
||||
class FilePath;
|
||||
}
|
||||
|
||||
namespace gfx {
|
||||
class Image;
|
||||
}
|
||||
|
||||
namespace gin {
|
||||
template <typename T>
|
||||
class Handle;
|
||||
@@ -64,9 +60,6 @@ class App final : public ElectronBrowserClient::Delegate,
|
||||
private content::GpuDataManagerObserver,
|
||||
private content::BrowserChildProcessObserver {
|
||||
public:
|
||||
using FileIconCallback =
|
||||
base::RepeatingCallback<void(v8::Local<v8::Value>, const gfx::Image&)>;
|
||||
|
||||
static gin::Handle<App> Create(v8::Isolate* isolate);
|
||||
static App* Get();
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
#include "content/public/common/color_parser.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
@@ -1014,7 +1013,7 @@ void BaseWindow::UnhookWindowMessage(UINT message) {
|
||||
}
|
||||
|
||||
bool BaseWindow::IsWindowMessageHooked(UINT message) {
|
||||
return base::Contains(messages_callback_map_, message);
|
||||
return messages_callback_map_.contains(message);
|
||||
}
|
||||
|
||||
void BaseWindow::UnhookAllWindowMessages() {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/containers/map_util.h"
|
||||
#include "extensions/common/command.h"
|
||||
#include "gin/dictionary.h"
|
||||
#include "gin/handle.h"
|
||||
@@ -53,12 +53,13 @@ GlobalShortcut::~GlobalShortcut() {
|
||||
}
|
||||
|
||||
void GlobalShortcut::OnKeyPressed(const ui::Accelerator& accelerator) {
|
||||
if (!base::Contains(accelerator_callback_map_, accelerator)) {
|
||||
if (auto* cb = base::FindOrNull(accelerator_callback_map_, accelerator)) {
|
||||
cb->Run();
|
||||
} else {
|
||||
// This should never occur, because if it does, GlobalShortcutListener
|
||||
// notifies us with wrong accelerator.
|
||||
NOTREACHED();
|
||||
}
|
||||
accelerator_callback_map_[accelerator].Run();
|
||||
}
|
||||
|
||||
bool GlobalShortcut::RegisterAll(
|
||||
@@ -136,7 +137,7 @@ void GlobalShortcut::UnregisterSome(
|
||||
}
|
||||
|
||||
bool GlobalShortcut::IsRegistered(const ui::Accelerator& accelerator) {
|
||||
return base::Contains(accelerator_callback_map_, accelerator);
|
||||
return accelerator_callback_map_.contains(accelerator);
|
||||
}
|
||||
|
||||
void GlobalShortcut::UnregisterAll() {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/functional/callback_helpers.h"
|
||||
#include "content/public/browser/device_service.h"
|
||||
#include "gin/dictionary.h"
|
||||
@@ -110,7 +109,7 @@ bool PowerSaveBlocker::Stop(int id) {
|
||||
}
|
||||
|
||||
bool PowerSaveBlocker::IsStarted(int id) const {
|
||||
return base::Contains(wake_lock_types_, id);
|
||||
return wake_lock_types_.contains(id);
|
||||
}
|
||||
|
||||
// static
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/containers/contains.h"
|
||||
#include "content/common/url_schemes.h"
|
||||
#include "content/public/browser/child_process_security_policy.h"
|
||||
#include "gin/handle.h"
|
||||
|
||||
@@ -1467,7 +1467,7 @@ v8::Local<v8::Promise> Session::ClearCodeCaches(
|
||||
if (options.Get("urls", &url_list) && !url_list.empty()) {
|
||||
url_matcher = base::BindRepeating(
|
||||
[](const std::set<GURL>& url_list, const GURL& url) {
|
||||
return base::Contains(url_list, url);
|
||||
return url_list.contains(url);
|
||||
},
|
||||
url_list);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/base64.h"
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/containers/fixed_flat_map.h"
|
||||
#include "base/containers/id_map.h"
|
||||
#include "base/files/file_util.h"
|
||||
@@ -642,8 +641,7 @@ std::map<std::string, std::string> GetAddedFileSystemPaths(
|
||||
|
||||
bool IsDevToolsFileSystemAdded(content::WebContents* web_contents,
|
||||
const std::string& file_system_path) {
|
||||
return base::Contains(GetAddedFileSystemPaths(web_contents),
|
||||
file_system_path);
|
||||
return GetAddedFileSystemPaths(web_contents).contains(file_system_path);
|
||||
}
|
||||
|
||||
content::RenderFrameHost* GetRenderFrameHost(
|
||||
@@ -4146,7 +4144,7 @@ void WebContents::DevToolsIndexPath(
|
||||
OnDevToolsIndexingDone(request_id, file_system_path);
|
||||
return;
|
||||
}
|
||||
if (devtools_indexing_jobs_.count(request_id) != 0)
|
||||
if (devtools_indexing_jobs_.contains(request_id))
|
||||
return;
|
||||
std::vector<std::string> excluded_folders;
|
||||
std::optional<base::Value> parsed_excluded_folders =
|
||||
|
||||
@@ -156,7 +156,7 @@ WebFrameMain::WebFrameMain(content::RenderFrameHost* rfh)
|
||||
if (!render_frame_detached_)
|
||||
GetFrameTreeNodeIdMap().emplace(frame_tree_node_id_, this);
|
||||
|
||||
DCHECK(GetFrameTokenMap().find(frame_token_) == GetFrameTokenMap().end());
|
||||
DCHECK(!GetFrameTokenMap().contains(frame_token_));
|
||||
GetFrameTokenMap().emplace(frame_token_, this);
|
||||
|
||||
// WebFrameMain should only be created for active or unloading frames.
|
||||
@@ -194,7 +194,7 @@ void WebFrameMain::UpdateRenderFrameHost(content::RenderFrameHost* rfh) {
|
||||
// Ensure that RFH being swapped in doesn't already exist as its own
|
||||
// WebFrameMain instance.
|
||||
frame_token_ = rfh->GetGlobalFrameToken();
|
||||
DCHECK(GetFrameTokenMap().find(frame_token_) == GetFrameTokenMap().end());
|
||||
DCHECK(!GetFrameTokenMap().contains(frame_token_));
|
||||
GetFrameTokenMap().emplace(frame_token_, this);
|
||||
|
||||
render_frame_disposed_ = false;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/containers/fixed_flat_map.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
@@ -240,7 +239,7 @@ bool WebRequest::RequestFilter::MatchesURL(const GURL& url) const {
|
||||
|
||||
bool WebRequest::RequestFilter::MatchesType(
|
||||
extensions::WebRequestResourceType type) const {
|
||||
return types_.empty() || base::Contains(types_, type);
|
||||
return types_.empty() || types_.contains(type);
|
||||
}
|
||||
|
||||
bool WebRequest::RequestFilter::MatchesRequest(
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <unordered_set>
|
||||
#include <utility>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/containers/to_vector.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/task/single_thread_task_runner.h"
|
||||
@@ -234,7 +233,7 @@ std::vector<blink::MessagePortChannel> MessagePort::DisentanglePorts(
|
||||
// or cloned ports, throw an error (per section 8.3.3 of the HTML5 spec).
|
||||
for (unsigned i = 0; i < ports.size(); ++i) {
|
||||
auto* port = ports[i].get();
|
||||
if (!port || port->IsNeutered() || base::Contains(visited, port)) {
|
||||
if (!port || port->IsNeutered() || visited.contains(port)) {
|
||||
std::string type;
|
||||
if (!port)
|
||||
type = "null";
|
||||
|
||||
@@ -84,7 +84,7 @@ AutofillDriver* AutofillDriverFactory::DriverForFrame(
|
||||
driver.get());
|
||||
} else {
|
||||
driver_map_.erase(insertion_result.first);
|
||||
DCHECK_EQ(driver_map_.count(render_frame_host), 0u);
|
||||
DCHECK(!driver_map_.contains(render_frame_host));
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -377,7 +377,7 @@ content::SiteInstance* ElectronBrowserClient::GetSiteInstanceFromAffinity(
|
||||
}
|
||||
|
||||
bool ElectronBrowserClient::IsRendererSubFrame(int process_id) const {
|
||||
return base::Contains(renderer_is_subframe_, process_id);
|
||||
return renderer_is_subframe_.contains(process_id);
|
||||
}
|
||||
|
||||
void ElectronBrowserClient::RenderProcessWillLaunch(
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "base/check.h"
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/json/json_writer.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
@@ -1084,13 +1083,13 @@ ScriptingGetRegisteredContentScriptsFunction::Run() {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!id_filter.empty() && !base::Contains(id_filter, script->id())) {
|
||||
if (!id_filter.empty() && !id_filter.contains(script->id())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
auto registered_script = CreateRegisteredContentScriptInfo(*script);
|
||||
registered_script.persist_across_sessions =
|
||||
base::Contains(persistent_script_ids, script->id());
|
||||
persistent_script_ids.contains(script->id());
|
||||
|
||||
// Remove the internally used prefix from the `script`'s ID before
|
||||
// returning.
|
||||
@@ -1260,7 +1259,7 @@ std::unique_ptr<UserScript> ScriptingUpdateContentScriptsFunction::ApplyUpdate(
|
||||
// original script is persisted and the flag is not specified.
|
||||
if (new_script.persist_across_sessions.value_or(false) ||
|
||||
(!new_script.persist_across_sessions &&
|
||||
base::Contains(*script_ids_to_persist, new_script.id))) {
|
||||
script_ids_to_persist->contains(new_script.id))) {
|
||||
script_ids_to_persist->insert(new_script.id);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/strings/pattern.h"
|
||||
#include "base/types/expected_macros.h"
|
||||
#include "chrome/common/url_constants.h"
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/path_service.h"
|
||||
#include "base/values.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
@@ -89,7 +88,7 @@ void ElectronComponentExtensionResourceManager::AddComponentResourceEntries(
|
||||
resource_path = resource_path.NormalizePathSeparators();
|
||||
|
||||
if (!gen_folder_path.IsParent(resource_path)) {
|
||||
DCHECK(!base::Contains(path_to_resource_id_, resource_path));
|
||||
DCHECK(!path_to_resource_id_.contains(resource_path));
|
||||
path_to_resource_id_[resource_path] = entry.id;
|
||||
} else {
|
||||
// If the resource is a generated file, strip the generated folder's path,
|
||||
@@ -98,7 +97,7 @@ void ElectronComponentExtensionResourceManager::AddComponentResourceEntries(
|
||||
base::FilePath effective_path =
|
||||
base::FilePath().AppendASCII(resource_path.AsUTF8Unsafe().substr(
|
||||
gen_folder_path.value().length()));
|
||||
DCHECK(!base::Contains(path_to_resource_id_, effective_path));
|
||||
DCHECK(!path_to_resource_id_.contains(effective_path));
|
||||
path_to_resource_id_[effective_path] = entry.id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/scoped_observation.h"
|
||||
#include "chrome/common/chrome_features.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
@@ -118,7 +117,7 @@ std::unique_ptr<content::HidChooser> ElectronHidDelegate::RunChooser(
|
||||
|
||||
// Start observing HidChooserContext for permission and device events.
|
||||
GetContextObserver(browser_context);
|
||||
DCHECK(base::Contains(observations_, browser_context));
|
||||
DCHECK(observations_.contains(browser_context));
|
||||
|
||||
HidChooserController* controller = ControllerForFrame(render_frame_host);
|
||||
if (controller) {
|
||||
@@ -188,7 +187,7 @@ void ElectronHidDelegate::RemoveObserver(
|
||||
content::HidDelegate::Observer* observer) {
|
||||
if (!browser_context)
|
||||
return;
|
||||
DCHECK(base::Contains(observations_, browser_context));
|
||||
DCHECK(observations_.contains(browser_context));
|
||||
GetContextObserver(browser_context)->RemoveObserver(observer);
|
||||
}
|
||||
|
||||
@@ -222,7 +221,7 @@ bool ElectronHidDelegate::IsServiceWorkerAllowedForOrigin(
|
||||
ElectronHidDelegate::ContextObservation*
|
||||
ElectronHidDelegate::GetContextObserver(
|
||||
content::BrowserContext* browser_context) {
|
||||
if (!base::Contains(observations_, browser_context)) {
|
||||
if (!observations_.contains(browser_context)) {
|
||||
observations_.emplace(browser_context, std::make_unique<ContextObservation>(
|
||||
this, browser_context));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <utility>
|
||||
|
||||
#include "base/command_line.h"
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/containers/map_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@@ -97,7 +96,7 @@ base::Value HidChooserContext::DeviceInfoToValue(
|
||||
void HidChooserContext::GrantDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device) {
|
||||
DCHECK(base::Contains(devices_, device.guid));
|
||||
DCHECK(devices_.contains(device.guid));
|
||||
if (CanStorePersistentEntry(device)) {
|
||||
auto* permission_manager = static_cast<ElectronPermissionManager*>(
|
||||
browser_context_->GetPermissionControllerDelegate());
|
||||
@@ -114,7 +113,7 @@ void HidChooserContext::GrantDevicePermission(
|
||||
void HidChooserContext::RevokeDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const device::mojom::HidDeviceInfo& device) {
|
||||
DCHECK(base::Contains(devices_, device.guid));
|
||||
DCHECK(devices_.contains(device.guid));
|
||||
if (CanStorePersistentEntry(device)) {
|
||||
RevokePersistentDevicePermission(origin, device);
|
||||
} else {
|
||||
@@ -170,8 +169,7 @@ bool HidChooserContext::HasDevicePermission(
|
||||
return false;
|
||||
|
||||
auto it = ephemeral_devices_.find(origin);
|
||||
if (it != ephemeral_devices_.end() &&
|
||||
base::Contains(it->second, device.guid)) {
|
||||
if (it != ephemeral_devices_.end() && it->second.contains(device.guid)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -192,7 +190,7 @@ bool HidChooserContext::IsFidoAllowedForOrigin(const url::Origin& origin) {
|
||||
});
|
||||
|
||||
if (origin.scheme() == extensions::kExtensionScheme &&
|
||||
base::Contains(kPrivilegedExtensionIds, origin.host())) {
|
||||
kPrivilegedExtensionIds.contains(origin.host())) {
|
||||
return true;
|
||||
}
|
||||
#endif // BUILDFLAG(ENABLE_ELECTRON_EXTENSIONS)
|
||||
@@ -248,7 +246,7 @@ void HidChooserContext::DeviceAdded(device::mojom::HidDeviceInfoPtr device) {
|
||||
DCHECK(device);
|
||||
|
||||
// Update the device list.
|
||||
if (!base::Contains(devices_, device->guid))
|
||||
if (!devices_.contains(device->guid))
|
||||
devices_.insert({device->guid, device->Clone()});
|
||||
|
||||
// Notify all observers.
|
||||
@@ -258,7 +256,7 @@ void HidChooserContext::DeviceAdded(device::mojom::HidDeviceInfoPtr device) {
|
||||
|
||||
void HidChooserContext::DeviceRemoved(device::mojom::HidDeviceInfoPtr device) {
|
||||
DCHECK(device);
|
||||
DCHECK(base::Contains(devices_, device->guid));
|
||||
DCHECK(devices_.contains(device->guid));
|
||||
|
||||
// Update the device list.
|
||||
devices_.erase(device->guid);
|
||||
@@ -279,7 +277,7 @@ void HidChooserContext::DeviceRemoved(device::mojom::HidDeviceInfoPtr device) {
|
||||
|
||||
void HidChooserContext::DeviceChanged(device::mojom::HidDeviceInfoPtr device) {
|
||||
DCHECK(device);
|
||||
DCHECK(base::Contains(devices_, device->guid));
|
||||
DCHECK(devices_.contains(device->guid));
|
||||
|
||||
// Update the device list.
|
||||
devices_[device->guid] = device->Clone();
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "content/public/common/webplugininfo.h"
|
||||
#include "electron/buildflags/buildflags.h"
|
||||
#include "url/gurl.h"
|
||||
@@ -53,8 +52,7 @@ PluginUtils::GetMimeTypeToExtensionIdMap(
|
||||
|
||||
if (MimeTypesHandler* handler = MimeTypesHandler::GetHandler(extension)) {
|
||||
for (const auto& supported_mime_type : handler->mime_type_set()) {
|
||||
DCHECK(!base::Contains(mime_type_to_extension_id_map,
|
||||
supported_mime_type));
|
||||
DCHECK(!mime_type_to_extension_id_map.contains(supported_mime_type));
|
||||
mime_type_to_extension_id_map[supported_mime_type] = extension_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include <string_view>
|
||||
#include "base/base64.h"
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/values.h"
|
||||
#include "content/public/browser/device_service.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
@@ -122,7 +121,7 @@ bool SerialChooserContext::HasPortPermission(
|
||||
auto it = ephemeral_ports_.find(origin);
|
||||
if (it != ephemeral_ports_.end()) {
|
||||
const std::set<base::UnguessableToken>& ports = it->second;
|
||||
if (base::Contains(ports, port.token))
|
||||
if (ports.contains(port.token))
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -240,7 +239,7 @@ base::WeakPtr<SerialChooserContext> SerialChooserContext::AsWeakPtr() {
|
||||
}
|
||||
|
||||
void SerialChooserContext::OnPortAdded(device::mojom::SerialPortInfoPtr port) {
|
||||
if (!base::Contains(port_info_, port->token))
|
||||
if (!port_info_.contains(port->token))
|
||||
port_info_.insert({port->token, port->Clone()});
|
||||
|
||||
for (auto& map_entry : ephemeral_ports_) {
|
||||
|
||||
@@ -221,6 +221,12 @@ using FullScreenTransitionState =
|
||||
[super windowDidResize:notification];
|
||||
shell_->NotifyWindowResize();
|
||||
shell_->RedrawTrafficLights();
|
||||
// When reduce motion is enabled windowDidResize is only called once after
|
||||
// a resize and windowDidEndLiveResize is not called. So we need to call
|
||||
// handleZoomEnd here as well.
|
||||
if (NSWorkspace.sharedWorkspace.accessibilityDisplayShouldReduceMotion) {
|
||||
[self handleZoomEnd];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowWillMove:(NSNotification*)notification {
|
||||
@@ -276,9 +282,7 @@ using FullScreenTransitionState =
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)windowDidEndLiveResize:(NSNotification*)notification {
|
||||
resizingHorizontally_.reset();
|
||||
shell_->NotifyWindowResized();
|
||||
- (void)handleZoomEnd {
|
||||
if (is_zooming_) {
|
||||
if (shell_->IsMaximized())
|
||||
shell_->NotifyWindowMaximize();
|
||||
@@ -288,6 +292,12 @@ using FullScreenTransitionState =
|
||||
}
|
||||
}
|
||||
|
||||
- (void)windowDidEndLiveResize:(NSNotification*)notification {
|
||||
resizingHorizontally_.reset();
|
||||
shell_->NotifyWindowResized();
|
||||
[self handleZoomEnd];
|
||||
}
|
||||
|
||||
- (void)windowWillEnterFullScreen:(NSNotification*)notification {
|
||||
// Store resizable mask so it can be restored after exiting fullscreen.
|
||||
is_resizable_ = shell_->HasStyleMask(NSWindowStyleMaskResizable);
|
||||
|
||||
@@ -334,7 +334,7 @@ static NSString* const ImageScrubberItemIdentifier = @"scrubber.image.item";
|
||||
}
|
||||
|
||||
- (bool)hasItemWithID:(const std::string&)item_id {
|
||||
return settings_.find(item_id) != settings_.end();
|
||||
return settings_.contains(item_id);
|
||||
}
|
||||
|
||||
- (NSColor*)colorFromHexColorString:(const std::string&)colorString {
|
||||
|
||||
@@ -46,22 +46,28 @@ void ElectronDesktopWindowTreeHostLinux::OnWidgetInitDone() {
|
||||
UpdateFrameHints();
|
||||
}
|
||||
|
||||
bool ElectronDesktopWindowTreeHostLinux::IsShowingFrame() const {
|
||||
return !native_window_view_->IsFullscreen() &&
|
||||
!native_window_view_->IsMaximized() &&
|
||||
!native_window_view_->IsMinimized();
|
||||
}
|
||||
|
||||
gfx::Insets ElectronDesktopWindowTreeHostLinux::CalculateInsetsInDIP(
|
||||
ui::PlatformWindowState window_state) const {
|
||||
// If we are not showing frame, the insets should be zero.
|
||||
if (native_window_view_->IsFullscreen()) {
|
||||
return {};
|
||||
if (!IsShowingFrame()) {
|
||||
return gfx::Insets();
|
||||
}
|
||||
|
||||
if (!native_window_view_->has_frame() ||
|
||||
!native_window_view_->has_client_frame()) {
|
||||
return {};
|
||||
return gfx::Insets();
|
||||
}
|
||||
|
||||
auto* view = static_cast<ClientFrameViewLinux*>(
|
||||
native_window_view_->widget()->non_client_view()->frame_view());
|
||||
|
||||
gfx::Insets insets = view->GetBorderDecorationInsets();
|
||||
gfx::Insets insets = view->RestoredMirroredFrameBorderInsets();
|
||||
if (base::i18n::IsRTL())
|
||||
insets.set_left_right(insets.right(), insets.left());
|
||||
return insets;
|
||||
@@ -98,9 +104,14 @@ void ElectronDesktopWindowTreeHostLinux::OnWindowTiledStateChanged(
|
||||
// of view.
|
||||
if (native_window_view_->has_frame() &&
|
||||
native_window_view_->has_client_frame()) {
|
||||
static_cast<ClientFrameViewLinux*>(
|
||||
native_window_view_->widget()->non_client_view()->frame_view())
|
||||
->set_tiled_edges(new_tiled_edges);
|
||||
ClientFrameViewLinux* frame = static_cast<ClientFrameViewLinux*>(
|
||||
native_window_view_->widget()->non_client_view()->frame_view());
|
||||
|
||||
bool maximized = new_tiled_edges.top && new_tiled_edges.left &&
|
||||
new_tiled_edges.bottom && new_tiled_edges.right;
|
||||
bool tiled = new_tiled_edges.top || new_tiled_edges.left ||
|
||||
new_tiled_edges.bottom || new_tiled_edges.right;
|
||||
frame->set_tiled(tiled && !maximized);
|
||||
}
|
||||
UpdateFrameHints();
|
||||
}
|
||||
@@ -192,7 +203,7 @@ void ElectronDesktopWindowTreeHostLinux::UpdateFrameHints() {
|
||||
if (ui::OzonePlatform::GetInstance()->IsWindowCompositingSupported()) {
|
||||
// Set the opaque region.
|
||||
std::vector<gfx::Rect> opaque_region;
|
||||
if (!native_window_view_->IsFullscreen()) {
|
||||
if (!IsShowingFrame()) {
|
||||
// The opaque region is a list of rectangles that contain only fully
|
||||
// opaque pixels of the window. We need to convert the clipping
|
||||
// rounded-rect into this format.
|
||||
|
||||
@@ -64,6 +64,8 @@ class ElectronDesktopWindowTreeHostLinux
|
||||
private:
|
||||
void UpdateWindowState(ui::PlatformWindowState new_state);
|
||||
|
||||
bool IsShowingFrame() const;
|
||||
|
||||
raw_ptr<NativeWindowViews> native_window_view_; // weak ref
|
||||
|
||||
base::ScopedObservation<ui::NativeTheme, ui::NativeThemeObserver>
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
#include "shell/browser/ui/message_box.h"
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/containers/flat_map.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/memory/raw_ptr.h"
|
||||
@@ -232,7 +231,7 @@ int ShowMessageBoxSync(const MessageBoxSettings& settings) {
|
||||
|
||||
void ShowMessageBox(const MessageBoxSettings& settings,
|
||||
MessageBoxCallback callback) {
|
||||
if (settings.id && base::Contains(GetDialogsMap(), *settings.id))
|
||||
if (settings.id && GetDialogsMap().contains(*settings.id))
|
||||
CloseMessageBox(*settings.id);
|
||||
(new GtkMessageBox(settings))->RunAsynchronous(std::move(callback));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/containers/flat_map.h"
|
||||
#include "base/mac/mac_util.h"
|
||||
#include "base/no_destructor.h"
|
||||
@@ -146,7 +145,7 @@ void ShowMessageBox(const MessageBoxSettings& settings,
|
||||
ret, alert.suppressionButton.state == NSControlStateValueOn);
|
||||
} else {
|
||||
if (settings.id) {
|
||||
if (base::Contains(GetDialogsMap(), *settings.id))
|
||||
if (GetDialogsMap().contains(*settings.id))
|
||||
CloseMessageBox(*settings.id);
|
||||
GetDialogsMap()[*settings.id] = alert;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/containers/flat_map.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/strings/string_util.h"
|
||||
@@ -242,7 +241,7 @@ DialogResult ShowTaskDialogWstr(gfx::AcceleratedWidget parent,
|
||||
TaskDialogIndirect(&config, &id, nullptr, &verification_flag_checked);
|
||||
|
||||
int button_id;
|
||||
if (base::Contains(id_map, id)) // common button.
|
||||
if (id_map.contains(id)) // common button.
|
||||
button_id = id_map[id];
|
||||
else if (id >= kIDStart) // custom button.
|
||||
button_id = id - kIDStart;
|
||||
@@ -289,7 +288,7 @@ void ShowMessageBox(const MessageBoxSettings& settings,
|
||||
// kHwndReserve in the dialogs map for now.
|
||||
HWND* hwnd = nullptr;
|
||||
if (settings.id) {
|
||||
if (base::Contains(GetDialogsMap(), *settings.id))
|
||||
if (GetDialogsMap().contains(*settings.id))
|
||||
CloseMessageBox(*settings.id);
|
||||
auto it = GetDialogsMap().emplace(*settings.id,
|
||||
std::make_unique<HWND>(kHwndReserve));
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace electron {
|
||||
namespace {
|
||||
|
||||
// These values should be the same as Chromium uses.
|
||||
constexpr int kResizeOutsideBorderSize = 10;
|
||||
constexpr int kResizeBorder = 10;
|
||||
constexpr int kResizeInsideBoundsSize = 5;
|
||||
|
||||
ui::NavButtonProvider::ButtonState ButtonStateToNavButtonProviderState(
|
||||
@@ -142,25 +142,28 @@ void ClientFrameViewLinux::Init(NativeWindowViews* window,
|
||||
UpdateThemeValues();
|
||||
}
|
||||
|
||||
gfx::Insets ClientFrameViewLinux::GetBorderDecorationInsets() const {
|
||||
const auto insets = GetFrameProvider()->GetFrameThicknessDip();
|
||||
gfx::Insets ClientFrameViewLinux::RestoredMirroredFrameBorderInsets() const {
|
||||
auto border = RestoredFrameBorderInsets();
|
||||
return base::i18n::IsRTL() ? gfx::Insets::TLBR(border.top(), border.right(),
|
||||
border.bottom(), border.left())
|
||||
: border;
|
||||
}
|
||||
|
||||
// We shouldn't draw frame decorations for the tiled edges.
|
||||
// See https://wayland.app/protocols/xdg-shell#xdg_toplevel:enum:state
|
||||
const auto& edges = tiled_edges();
|
||||
return gfx::Insets::TLBR(
|
||||
edges.top ? 0 : insets.top(), edges.left ? 0 : insets.left(),
|
||||
edges.bottom ? 0 : insets.bottom(), edges.right ? 0 : insets.right());
|
||||
gfx::Insets ClientFrameViewLinux::RestoredFrameBorderInsets() const {
|
||||
gfx::Insets insets = GetFrameProvider()->GetFrameThicknessDip();
|
||||
insets.SetToMax(GetInputInsets());
|
||||
return insets;
|
||||
}
|
||||
|
||||
gfx::Insets ClientFrameViewLinux::GetInputInsets() const {
|
||||
return gfx::Insets{
|
||||
host_supports_client_frame_shadow_ ? -kResizeOutsideBorderSize : 0};
|
||||
bool showing_shadow = host_supports_client_frame_shadow_ &&
|
||||
!frame_->IsMaximized() && !frame_->IsFullscreen();
|
||||
return gfx::Insets(showing_shadow ? kResizeBorder : 0);
|
||||
}
|
||||
|
||||
gfx::Rect ClientFrameViewLinux::GetWindowContentBounds() const {
|
||||
gfx::Rect content_bounds = bounds();
|
||||
content_bounds.Inset(GetBorderDecorationInsets());
|
||||
content_bounds.Inset(RestoredMirroredFrameBorderInsets());
|
||||
return content_bounds;
|
||||
}
|
||||
|
||||
@@ -194,15 +197,15 @@ void ClientFrameViewLinux::OnWindowButtonOrderingChange() {
|
||||
}
|
||||
|
||||
int ClientFrameViewLinux::ResizingBorderHitTest(const gfx::Point& point) {
|
||||
return ResizingBorderHitTestImpl(
|
||||
point,
|
||||
GetBorderDecorationInsets() + gfx::Insets(kResizeInsideBoundsSize));
|
||||
return ResizingBorderHitTestImpl(point,
|
||||
RestoredMirroredFrameBorderInsets() +
|
||||
gfx::Insets(kResizeInsideBoundsSize));
|
||||
}
|
||||
|
||||
gfx::Rect ClientFrameViewLinux::GetBoundsForClientView() const {
|
||||
gfx::Rect client_bounds = bounds();
|
||||
if (!frame_->IsFullscreen()) {
|
||||
client_bounds.Inset(GetBorderDecorationInsets());
|
||||
client_bounds.Inset(RestoredMirroredFrameBorderInsets());
|
||||
client_bounds.Inset(
|
||||
gfx::Insets::TLBR(GetTitlebarBounds().height(), 0, 0, 0));
|
||||
}
|
||||
@@ -239,10 +242,8 @@ int ClientFrameViewLinux::NonClientHitTest(const gfx::Point& point) {
|
||||
}
|
||||
|
||||
ui::WindowFrameProvider* ClientFrameViewLinux::GetFrameProvider() const {
|
||||
const bool tiled = tiled_edges().top || tiled_edges().left ||
|
||||
tiled_edges().bottom || tiled_edges().right;
|
||||
return ui::LinuxUiTheme::GetForProfile(nullptr)->GetWindowFrameProvider(
|
||||
!host_supports_client_frame_shadow_, tiled, frame_->IsMaximized());
|
||||
!host_supports_client_frame_shadow_, tiled(), frame_->IsMaximized());
|
||||
}
|
||||
|
||||
void ClientFrameViewLinux::GetWindowMask(const gfx::Size& size,
|
||||
@@ -465,7 +466,7 @@ gfx::Rect ClientFrameViewLinux::GetTitlebarBounds() const {
|
||||
std::max(font_height, theme_values_.titlebar_min_height) +
|
||||
GetTitlebarContentInsets().height();
|
||||
|
||||
gfx::Insets decoration_insets = GetBorderDecorationInsets();
|
||||
gfx::Insets decoration_insets = RestoredMirroredFrameBorderInsets();
|
||||
|
||||
// We add the inset height here, so the .Inset() that follows won't reduce it
|
||||
// to be too small.
|
||||
@@ -486,7 +487,7 @@ gfx::Rect ClientFrameViewLinux::GetTitlebarContentBounds() const {
|
||||
}
|
||||
|
||||
gfx::Size ClientFrameViewLinux::SizeWithDecorations(gfx::Size size) const {
|
||||
gfx::Insets decoration_insets = GetBorderDecorationInsets();
|
||||
gfx::Insets decoration_insets = RestoredMirroredFrameBorderInsets();
|
||||
|
||||
size.Enlarge(0, GetTitlebarBounds().height());
|
||||
size.Enlarge(decoration_insets.width(), decoration_insets.height());
|
||||
|
||||
@@ -43,16 +43,16 @@ class ClientFrameViewLinux : public FramelessView,
|
||||
void Init(NativeWindowViews* window, views::Widget* frame) override;
|
||||
|
||||
// These are here for ElectronDesktopWindowTreeHostLinux to use.
|
||||
gfx::Insets GetBorderDecorationInsets() const;
|
||||
gfx::Insets RestoredMirroredFrameBorderInsets() const;
|
||||
gfx::Insets RestoredFrameBorderInsets() const;
|
||||
gfx::Insets GetInputInsets() const;
|
||||
gfx::Rect GetWindowContentBounds() const;
|
||||
SkRRect GetRoundedWindowContentBounds() const;
|
||||
int GetTranslucentTopAreaHeight() const;
|
||||
// Returns which edges of the frame are tiled.
|
||||
const ui::WindowTiledEdges& tiled_edges() const { return tiled_edges_; }
|
||||
void set_tiled_edges(ui::WindowTiledEdges tiled_edges) {
|
||||
tiled_edges_ = tiled_edges;
|
||||
}
|
||||
|
||||
// Returns whether the frame is in a tiled state.
|
||||
bool tiled() const { return tiled_; }
|
||||
void set_tiled(bool tiled) { tiled_ = tiled; }
|
||||
|
||||
protected:
|
||||
// ui::NativeThemeObserver:
|
||||
@@ -149,7 +149,7 @@ class ClientFrameViewLinux : public FramelessView,
|
||||
|
||||
base::CallbackListSubscription paint_as_active_changed_subscription_;
|
||||
|
||||
ui::WindowTiledEdges tiled_edges_;
|
||||
bool tiled_ = false;
|
||||
};
|
||||
|
||||
} // namespace electron
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/observer_list.h"
|
||||
#include "base/scoped_observation.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
@@ -72,7 +71,7 @@ bool IsDevicePermissionAutoGranted(
|
||||
// Note: The `DeviceHasInterfaceWithClass()` call is made after checking the
|
||||
// origin, since that method call is expensive.
|
||||
if (origin.scheme() == extensions::kExtensionScheme &&
|
||||
base::Contains(kSmartCardPrivilegedExtensionIds, origin.host()) &&
|
||||
kSmartCardPrivilegedExtensionIds.contains(origin.host()) &&
|
||||
DeviceHasInterfaceWithClass(device_info,
|
||||
device::mojom::kUsbSmartCardClass)) {
|
||||
return true;
|
||||
@@ -269,7 +268,7 @@ ElectronUsbDelegate::ContextObservation*
|
||||
ElectronUsbDelegate::GetContextObserver(
|
||||
content::BrowserContext* browser_context) {
|
||||
CHECK(browser_context);
|
||||
if (!base::Contains(observations_, browser_context)) {
|
||||
if (!observations_.contains(browser_context)) {
|
||||
observations_.emplace(browser_context, std::make_unique<ContextObservation>(
|
||||
this, browser_context));
|
||||
}
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
|
||||
#include "shell/browser/usb/usb_chooser_context.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <string_view>
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/functional/bind.h"
|
||||
#include "base/task/sequenced_task_runner.h"
|
||||
#include "base/values.h"
|
||||
@@ -158,7 +157,7 @@ UsbChooserContext::~UsbChooserContext() {
|
||||
void UsbChooserContext::RevokeDevicePermissionWebInitiated(
|
||||
const url::Origin& origin,
|
||||
const device::mojom::UsbDeviceInfo& device) {
|
||||
DCHECK(base::Contains(devices_, device.guid));
|
||||
DCHECK(devices_.contains(device.guid));
|
||||
RevokeObjectPermissionInternal(origin, DeviceInfoToValue(device),
|
||||
/*revoked_by_website=*/true);
|
||||
}
|
||||
@@ -217,8 +216,7 @@ bool UsbChooserContext::HasDevicePermission(
|
||||
const url::Origin& origin,
|
||||
const device::mojom::UsbDeviceInfo& device_info) {
|
||||
auto it = ephemeral_devices_.find(origin);
|
||||
if (it != ephemeral_devices_.end() &&
|
||||
base::Contains(it->second, device_info.guid)) {
|
||||
if (it != ephemeral_devices_.end() && it->second.contains(device_info.guid)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -284,7 +282,7 @@ void UsbChooserContext::OnDeviceAdded(
|
||||
device::mojom::UsbDeviceInfoPtr device_info) {
|
||||
DCHECK(device_info);
|
||||
// Update the device list.
|
||||
DCHECK(!base::Contains(devices_, device_info->guid));
|
||||
DCHECK(!devices_.contains(device_info->guid));
|
||||
if (!ShouldExposeDevice(*device_info))
|
||||
return;
|
||||
devices_.insert(std::make_pair(device_info->guid, device_info->Clone()));
|
||||
@@ -299,12 +297,12 @@ void UsbChooserContext::OnDeviceRemoved(
|
||||
DCHECK(device_info);
|
||||
|
||||
if (!ShouldExposeDevice(*device_info)) {
|
||||
DCHECK(!base::Contains(devices_, device_info->guid));
|
||||
DCHECK(!devices_.contains(device_info->guid));
|
||||
return;
|
||||
}
|
||||
|
||||
// Update the device list.
|
||||
DCHECK(base::Contains(devices_, device_info->guid));
|
||||
DCHECK(devices_.contains(device_info->guid));
|
||||
devices_.erase(device_info->guid);
|
||||
|
||||
// Notify all device observers.
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <map>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/containers/to_vector.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
@@ -76,7 +75,7 @@ std::string Clipboard::Read(const std::string& format_string) {
|
||||
clipboard->ExtractCustomPlatformNames(ui::ClipboardBuffer::kCopyPaste,
|
||||
/* data_dst = */ nullptr);
|
||||
#if BUILDFLAG(IS_LINUX)
|
||||
if (!base::Contains(custom_format_names, format_string)) {
|
||||
if (!custom_format_names.contains(format_string)) {
|
||||
custom_format_names =
|
||||
clipboard->ExtractCustomPlatformNames(ui::ClipboardBuffer::kSelection,
|
||||
/* data_dst = */ nullptr);
|
||||
@@ -84,7 +83,7 @@ std::string Clipboard::Read(const std::string& format_string) {
|
||||
#endif
|
||||
|
||||
ui::ClipboardFormatType format;
|
||||
if (base::Contains(custom_format_names, format_string)) {
|
||||
if (custom_format_names.contains(format_string)) {
|
||||
format =
|
||||
ui::ClipboardFormatType(ui::ClipboardFormatType::CustomPlatformType(
|
||||
custom_format_names[format_string]));
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/feature_list.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
@@ -64,7 +63,7 @@ bool DeepFreeze(const v8::Local<v8::Object>& object,
|
||||
const v8::Local<v8::Context>& context,
|
||||
std::set<int> frozen = std::set<int>()) {
|
||||
int hash = object->GetIdentityHash();
|
||||
if (base::Contains(frozen, hash))
|
||||
if (frozen.contains(hash))
|
||||
return true;
|
||||
frozen.insert(hash);
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/numerics/safe_conversions.h"
|
||||
#include "base/strings/utf_string_conversion_utils.h"
|
||||
@@ -190,13 +189,13 @@ void SpellCheckClient::OnSpellCheckDone(
|
||||
auto& word_list = pending_request_param_->wordlist();
|
||||
|
||||
for (const auto& word : word_list) {
|
||||
if (base::Contains(misspelled, word.text)) {
|
||||
if (misspelled.contains(word.text)) {
|
||||
// If this is a contraction, iterate through parts and accept the word
|
||||
// if none of them are misspelled
|
||||
if (!word.contraction_words.empty()) {
|
||||
auto all_correct = true;
|
||||
for (const auto& contraction_word : word.contraction_words) {
|
||||
if (base::Contains(misspelled, contraction_word)) {
|
||||
if (misspelled.contains(contraction_word)) {
|
||||
all_correct = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ void ElectronRendererClient::WillDestroyWorkerContextOnWorkerThread(
|
||||
|
||||
node::Environment* ElectronRendererClient::GetEnvironment(
|
||||
content::RenderFrame* render_frame) const {
|
||||
if (!base::Contains(injected_frames_, render_frame))
|
||||
if (!injected_frames_.contains(render_frame))
|
||||
return nullptr;
|
||||
v8::HandleScope handle_scope(v8::Isolate::GetCurrent());
|
||||
auto context =
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
|
||||
#include "base/base_paths.h"
|
||||
#include "base/command_line.h"
|
||||
#include "base/containers/contains.h"
|
||||
#include "base/process/process_handle.h"
|
||||
#include "base/process/process_metrics.h"
|
||||
#include "content/public/renderer/render_frame.h"
|
||||
#include "shell/common/api/electron_bindings.h"
|
||||
@@ -214,7 +212,7 @@ void ElectronSandboxedRendererClient::WillReleaseScriptContext(
|
||||
void ElectronSandboxedRendererClient::EmitProcessEvent(
|
||||
content::RenderFrame* render_frame,
|
||||
const char* event_name) {
|
||||
if (!base::Contains(injected_frames_, render_frame))
|
||||
if (!injected_frames_.contains(render_frame))
|
||||
return;
|
||||
|
||||
blink::WebLocalFrame* frame = render_frame->GetWebFrame();
|
||||
|
||||
@@ -4,10 +4,12 @@
|
||||
|
||||
#include "shell/renderer/web_worker_observer.h"
|
||||
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/ranges/algorithm.h"
|
||||
#include "base/strings/strcat.h"
|
||||
#include "base/threading/thread_local.h"
|
||||
#include "shell/common/api/electron_bindings.h"
|
||||
#include "shell/common/gin_helper/event_emitter_caller.h"
|
||||
@@ -70,15 +72,14 @@ void WebWorkerObserver::WorkerScriptReadyForEvaluation(
|
||||
// is loaded. See corresponding change in node/init.ts.
|
||||
v8::Local<v8::Object> global = worker_context->Global();
|
||||
|
||||
std::vector<std::string> keys = {"fetch", "Response", "FormData",
|
||||
"Request", "Headers", "EventSource"};
|
||||
for (const auto& key : keys) {
|
||||
for (const std::string_view key :
|
||||
{"fetch", "Response", "FormData", "Request", "Headers", "EventSource"}) {
|
||||
v8::MaybeLocal<v8::Value> value =
|
||||
global->Get(worker_context, gin::StringToV8(isolate, key.c_str()));
|
||||
global->Get(worker_context, gin::StringToV8(isolate, key));
|
||||
if (!value.IsEmpty()) {
|
||||
std::string blink_key = "blink" + key;
|
||||
std::string blink_key = base::StrCat({"blink", key});
|
||||
global
|
||||
->Set(worker_context, gin::StringToV8(isolate, blink_key.c_str()),
|
||||
->Set(worker_context, gin::StringToV8(isolate, blink_key),
|
||||
value.ToLocalChecked())
|
||||
.Check();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user