Compare commits

..

79 Commits

Author SHA1 Message Date
Keeley Hammond
589272e065 chore(todo): debug patch 2025-04-15 16:36:03 -07:00
George Xu
e364a20ba1 intense debug session with not many results... 2025-04-09 17:40:57 -07:00
George Xu
6b6ef0b9ef chore: update patch: 2025-03-28 15:29:14 -07:00
George Xu
bb092132be kick ci 2025-03-19 14:32:44 -07:00
George Xu
0cdf1012bb remove old patch and lint 2025-03-19 14:32:44 -07:00
George Xu
eaa952361c wrap macos code in buildflag 2025-03-19 14:32:44 -07:00
George Xu
8ef66cade3 remove log statements 2025-03-19 14:32:43 -07:00
George Xu
2fb1bfec42 cleaning up 2025-03-19 14:32:43 -07:00
George Xu
65864f6203 test 2025-03-19 14:32:43 -07:00
George Xu
75eb7aabd6 add more logging 2025-03-19 14:32:43 -07:00
George Xu
f8aae32c6c some linting and fixing 2025-03-19 14:32:43 -07:00
George Xu
3e6834099e make things work with type none 2025-03-19 14:32:43 -07:00
George Xu
3d5d5f5cb0 happy path share window: 2025-03-19 14:32:43 -07:00
George Xu
3268c6ba76 new changes 2025-03-19 14:32:43 -07:00
George Xu
50f96692df add more logging, picker works on macos 2025-03-19 14:32:43 -07:00
George Xu
53a7802e95 update patches 2025-03-19 14:32:43 -07:00
George Xu
b6c4c727d1 UNDO ME- onpush for ci 2025-03-19 14:32:43 -07:00
Keeley Hammond
4aa9773388 feat: allow screen or window to return depending on preferredDisplaySurface set 2025-03-19 14:32:43 -07:00
Keeley Hammond
7b6b5bf224 chore: skip skip_refresh_callback if ShouldUseSCContentSharingPicker is false 2025-03-19 14:32:43 -07:00
Keeley Hammond
bd1ed17c02 feat: modify API to use useSystemPicker option 2025-03-19 14:32:43 -07:00
Keeley Hammond
813fc3af58 docs: add documentation 2025-03-19 14:32:43 -07:00
Keeley Hammond
e7675a1a1c chore: remove OnSourceAdded (re-add in the future) 2025-03-19 14:32:43 -07:00
Keeley Hammond
729ca429b8 feat: add getNativePickerSource() API option 2025-03-19 14:32:43 -07:00
Keeley Hammond
da56809b62 fix: make capturer work on both screens and windows 2025-03-19 14:32:43 -07:00
Keeley Hammond
12ca8b30be fix: make window capturer work, still issue with first refresh 2025-03-19 14:32:43 -07:00
Keeley Hammond
56d4433e46 feat: use upstream MacOS SCContentSharingPicker implementation pt. 1 2025-03-19 14:32:43 -07:00
Keeley Hammond
0ee7150832 feat: partially implement IsDisplayMediaSystemPickerAvailable 2025-03-19 14:32:43 -07:00
Shelley Vohr
d424c3aee7 test: disable parallel/test-worker-resource-limits (#46105)
test: disable parallel/test-worker-resource-limits
2025-03-19 22:03:26 +01:00
Niklas Wenzel
e4d660af86 docs: fix code example in breaking-changes.md (#46093) 2025-03-19 11:20:22 +01:00
Shelley Vohr
2efd75e2ca build: fail for out of date patches on forks (#46080) 2025-03-19 10:05:51 +01:00
electron-roller[bot]
b13f05e2dc chore: bump chromium to 136.0.7067.0 (main) (#46018)
* chore: bump chromium in DEPS to 136.0.7066.0

* chore: bump chromium in DEPS to 136.0.7067.0

* 6325710: [LNA] Add Local Network Access permission type

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6325710

* 6342514: Create frame mojo endpoints in renderer during window.open()

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6342514

* 6344040: Create widget mojo endpoints in renderer process for window.open()

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6344040

* chore: update patches

* 6349218: Move ExtensionService::install_directory() to ExtensionRegistrar

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6349218

* 6349395: Move ExtensionService::extensions_enabled() to ExtensionRegistrar

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6349395

* 6331510: Migrate views::Background class to ui::ColorVariant | https://chromium-review.googlesource.com/c/chromium/src/+/6331510

* build: reorder set-cookie step https://github.com/electron/electron/pull/46091

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
Co-authored-by: alice <alice@makenotion.com>
2025-03-18 19:20:54 -04:00
Shelley Vohr
dcbab692c0 test: fix app.dock for corrected type (#46110)
test: fix app.dock for corrected type
2025-03-18 17:44:39 -04:00
Niklas Wenzel
71f3ff6bf2 docs: fix types of app.dock (#46073) 2025-03-18 13:14:08 +01:00
Alice Zhao
ff0a14a7c6 build: move set chromium cookie before build tools step (#46091)
build: move set cookie before build tools
2025-03-18 10:07:05 +01:00
Charles Kerr
4bf99c9bea refactor: add ElectronBrowserContext::GetDefaultBrowserContext() (#46065)
* refactor: add ElectronBrowserContext::DestroyAllContexts()

Simpler semantics than previous implementation; also hides the
"default context must be destroyed last" implementation detail.

* refactor: add ElectronBrowserContext::GetDefaultBrowserContext()

clearer semantics than everyone calling From("", false)
2025-03-17 08:43:23 -05:00
Charles Kerr
9513486bf3 refactor: use GetDefaultStoragePartition() instead of GetStoragePartition(nullptr) (#46064)
refactor: use GetDefaultStoragePartition()

Use GetDefaultStorageParition() instead of GetStoragePartition(nullptr)

- It improves code uniformity, since we use get-default everywhere else
- It's more readable
- It's marginally faster, since GetStoragePartition() has more steps

Added in 49b0a1bf4a
2025-03-17 08:39:55 -05:00
Charles Kerr
bea7d618f1 fix: warning in file picker UI (#46067) 2025-03-16 20:49:15 -05:00
Charles Kerr
4ad20ccb39 chore: e patches all (#46068) 2025-03-16 14:04:01 -05:00
Charles Kerr
73a017577e perf: avoid redundant map lookup in ElectronBrowserContext::From() (#46044)
perf: avoid redundant map lookup in ElectronBrowserContext::FromPath()
2025-03-15 09:51:20 -05:00
Shelley Vohr
2d8a547692 build: fix compound bash conditional in patchup (#46047) 2025-03-15 09:57:59 +01:00
Charles Kerr
5f0603ed28 fix: ElectronBrowserContext raw_ptr bug + remove dead code (#46030)
refactor: remove unused ElectronBrowserContext::extension_system()

Last use removed on Jul 21, 2020 by 2fb14f5 in PR #24575

This fixes a raw_ptr warning by letting us remove the raw_ptr field
`ElectronBrowserContext::extension_system_`.
2025-03-14 23:35:10 -05:00
Sam Maddock
afca4e271e feat: ServiceWorkerMain.scriptURL (#45863)
feat: serviceWorker.scriptURL
2025-03-14 21:00:13 -04:00
Charles Kerr
30d2fadb28 refactor: replace base::StringPrintf() calls with absl::StrFormat() (#46024)
The former is now a pass-through for the latter and is slated for removal

Xref: https://issues.chromium.org/issues/40241565

https://chromium-review.googlesource.com/c/chromium/src/+/4907781
2025-03-14 17:14:32 -05:00
Charles Kerr
3271b82094 refactor: remove unused system header includes (#46015)
* chore: remove unused #include <string>

* chore: remove unused #include <optional>

* chore: remove unused #include <vector>

* chore: remove unused #include <string_view>

* chore: remove unused #include <memory>

* chore: remove unused #include <utility>

* chore: remove unused #include <tuple>

* chore: remove unused #include <unordered_set>

* chore: remove unused #include <functional>

* chore: iwyu <set>

* chore: iwyu <map>
2025-03-14 10:59:15 -05:00
Shelley Vohr
c0e180758b fix: don't crash Utility Processes on unhandled rejections (#45921)
* fix: don't crash on unhandled rejections

* Update docs/breaking-changes.md

Co-authored-by: Niklas Wenzel <dev@nikwen.de>

---------

Co-authored-by: Niklas Wenzel <dev@nikwen.de>
2025-03-14 09:09:02 -05:00
Shelley Vohr
5817d27429 fix: take Snapped status into account when showing a window (#46006) 2025-03-14 09:07:27 -05:00
Michaela Laurencin
4812b4e6c2 fix: prevent title change for within page navigation (#45981)
* fix: prevent title change for on page navigation

* add back and forward testing

* update Chromium comment

* remove errant script tag
2025-03-14 12:10:23 +01:00
Shelley Vohr
7c0b7b417b fix: emit context-menu event in Windows draggable regions (#45851)
fix: emit context-menu event in Windows draggable regions
2025-03-14 10:29:29 +01:00
Charles Kerr
785fe5f3b6 refactor: make a variadic gin_helper::internal::InvokeFactory() (#45988)
refactor: make a variadic gin_helper::internal::InvokeFactory()
2025-03-13 17:24:49 -05:00
Shelley Vohr
502a6b0166 build: roll sysroots again (#46016) 2025-03-13 16:28:53 -05:00
Shelley Vohr
4a28e60e89 fix: package import existence verification (#45997) 2025-03-13 14:51:43 -05:00
Shelley Vohr
a90d50e13f fix: don't crash Web Workers on unhandled rejections (#45992) 2025-03-13 13:09:23 -05:00
electron-roller[bot]
962d8b325a chore: bump chromium to 136.0.7064.0 (main) (#45985)
* chore: bump chromium in DEPS to 136.0.7063.0

* chore: bump chromium in DEPS to 136.0.7064.0

* 6169919: Instantiate Linux (or CrOS) system fonts using Fontations

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6169919

* 6341209: Remove file-wide unsafe buffer suppression from content/ [1 of N].

Refs https://chromium-review.googlesource.com/c/chromium/src/+/6341209

* chore: update patches

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: David Sanders <dsanders11@ucsbalum.com>
2025-03-13 12:02:06 -05:00
Charles Kerr
c813bc2a92 refactor: use private inheritance from mojo::MessageReceiver (#45973)
* refactor: make UtilityProcessWrapper inherit privately from mojo::MessageReceiver

* refactor: make ParentPort inherit privately from mojo::MessageReceiver

* refactor: make MessagePort inherit privately from mojo::MessageReceiver
2025-03-12 19:06:41 +01:00
Shelley Vohr
5ce41bac8d fix: system-context-menu should only fire in draggable regions (#45893)
fix: system-context-menu should only fire in draggable regions
2025-03-12 13:47:58 +01:00
David Sanders
6bc7bde229 ci: don't fail branch created workflow if previous board not found (#45986) 2025-03-12 09:27:40 +01:00
electron-roller[bot]
2de8fd7d93 chore: bump chromium to 136.0.7062.0 (main) (#45957)
* chore: bump chromium in DEPS to 136.0.7059.0

* chore: bump chromium in DEPS to 136.0.7060.0

* chore: bump chromium in DEPS to 136.0.7062.0

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
2025-03-11 17:44:08 -04:00
Shelley Vohr
dcd319cfbe build: roll sysroots to pick up glibc fix (#45974) 2025-03-11 17:31:48 -04:00
Shelley Vohr
cd56b96544 refactor: remove usage of V8's {Attach|Detach}CppHeap() (#45922)
* refactor: remove usage of V8's {Attach|Detach}CppHeap()

* chore: remove revert patch
2025-03-11 18:54:33 +01:00
Charles Kerr
22262c14f1 test: fix timing issue in utilityProcess test fixtures (#45964)
* fix: potential timing issue in utilityProcess test

* fix: potential timing issue in utilityProcess esm test
2025-03-11 17:41:42 +01:00
dependabot[bot]
6e056709be build(deps): bump github/codeql-action from 3.28.10 to 3.28.11 (#45970)
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.10 to 3.28.11.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](b56ba49b26...6bb031afdd)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-11 10:44:00 -05:00
dependabot[bot]
2f63b20acf build(deps): bump dsanders11/project-actions from 1.5.2 to 1.7.0 (#45969)
Bumps [dsanders11/project-actions](https://github.com/dsanders11/project-actions) from 1.5.2 to 1.7.0.
- [Release notes](https://github.com/dsanders11/project-actions/releases)
- [Changelog](https://github.com/dsanders11/project-actions/blob/main/.releaserc.json)
- [Commits](7fc3c5441a...2134fe7cc7)

---
updated-dependencies:
- dependency-name: dsanders11/project-actions
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-11 10:43:46 -05:00
Felix Rieseberg
eb126eecb0 docs: Add 'Native Code and Electron' (#45882)
* docs: Add 'Native Code and Electron'

* docs: Add node-gyp requirements

* Update docs/tutorial/native-code-and-electron.md

Co-authored-by: Erick Zhao <erick@hotmail.ca>

* Cross-platform clean command

* Mention napi-rs

* Apply suggestions from code review

Co-authored-by: Erick Zhao <erick@hotmail.ca>

* Fix lint, fix more comments

* Apply suggestions from code review

Co-authored-by: Erick Zhao <erick@hotmail.ca>

---------

Co-authored-by: Erick Zhao <erick@hotmail.ca>
2025-03-10 13:45:33 -07:00
Shelley Vohr
4e1a915f1a build: remove patches merged upstream (#45963) 2025-03-10 20:00:28 +01:00
Charles Kerr
f2b09ff0bd fix: remove redundant MediaCaptureDevicesDispatcher::GetInstance() call (#45929)
fix: remove redundant MediaCaptureDevicesDispatcher::GetInstance() call

This appears to be a copy-paste error introduced in 465dee2c
2025-03-10 09:44:24 -05:00
electron-roller[bot]
b0c11371e0 chore: bump chromium to 136.0.7058.1 (main) (#45928)
* chore: bump chromium in DEPS to 136.0.7056.0

* chore: update mas_avoid_private_macos_api_usage.patch.patch

no manual changes; patch applied with fuzz

* chore: update fix_adapt_exclusive_access_for_electron_needs.patch

patch applied manually due to context shear

6319958: [FS] Replace GURL with url::Origin for Excluisve Access Bubble | https://chromium-review.googlesource.com/c/chromium/src/+/6319958

* chore: update feat_allow_usage_of_sccontentsharingpicker_on_supported_platforms.patch

no manual changes; patch applied with fuzz

6311876: Expose captured surface resolution for MacOS | https://chromium-review.googlesource.com/c/chromium/src/+/6311876

* chore: e patches all

* 6319958: [FS] Replace GURL with url::Origin for Excluisve Access Bubble | https://chromium-review.googlesource.com/c/chromium/src/+/6319958

* 6326673: views: Delete the single-parameter Widget::InitParams constructor. | https://chromium-review.googlesource.com/c/chromium/src/+/6326673

* https://chromium-review.googlesource.com/c/chromium/src/+/6331102

* 6331102: [A11yPerformance] Rename AXMode::kScreenReader to kExtendedProperties | https://chromium-review.googlesource.com/c/chromium/src/+/6331102

Sync with shell/browser/ui/webui/accessibility_ui.cc to
upstream chrome/browser/accessibility/accessibility_ui.cc
changes in 4af8657

* chore: bump Chromium 136.0.7058.1 (#45933)

chore: bump chromium in DEPS to 136.0.7058.1

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-10 00:30:34 -05:00
Samuel Attard
9b2e7db469 chore: cherry-pick 9dacf5694dfd from chromium (#45936) 2025-03-09 16:26:06 -07:00
Samuel Attard
f04c06a0db chore: cherry-pick 521faebc8a7c from chromium (#45941) 2025-03-09 16:23:04 -07:00
Charles Kerr
8ac061ebe7 fix: race condition in utilityProcess tests (#45926) 2025-03-09 17:37:35 -05:00
Milan Burda
b30f31e1f6 refactor: eliminate duplicate code in spec/api-process-spec.ts (#45927) 2025-03-09 17:37:14 -05:00
Charles Kerr
288ef37b1d perf: prefer base::SplitStringPiece() over base::SplitString() (#45924)
* perf: use base::SplitStringPiece() in SetNodeOptions()

* perf: use base::SplitStringPiece() in StringToAccelerator()

* refactor: StringToAccelerator() now takes a std::string_view
2025-03-09 17:36:13 -05:00
electron-roller[bot]
20414f66ca chore!: bump chromium to 136.0.7054.0 (main) (#45923)
* chore: bump chromium in DEPS to 136.0.7054.0

* chore: update allow_in-process_windows_to_have_different_web_prefs.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/5906158

patch applied manually due to context shear

* chore: e patches all

* refactor!: Session.clearStorageData(syncable)

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/6309405

Remove syncable type from opts.quota in Session.clearStorageData(opts)
because it that category has been removed upstream.

BREAKING CHANGE: Removed ses.clearDataStorage({ quota: 'syncable' })

* docs: deprecate Session.clearDataStorage({ quota })

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-07 17:49:21 -06:00
electron-roller[bot]
458b14b8ed chore: bump chromium to 136.0.7053.1 (main) (#45906)
* chore: bump chromium in DEPS to 136.0.7052.0

* chore: update mas_avoid_private_macos_api_usage.patch.patch

https://chromium-review.googlesource.com/c/chromium/src/+/6318359

patch applied manually due to context shear

* chore: update preconnect_manager.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/6318420

patch applied manually due to context shear

* chore: e patches all

* chore: bump chromium to 136.0.7053.1

* chore: update fix_remove_profiles_from_spellcheck_service.patch

Xref: https://chromium-review.googlesource.com/c/chromium/src/+/6326575

patch applied manually due to context shear

* chore: e patches all

* chore: revert removal of v8 API used by Node.js

* devtools: Remove DevToolsUIBindings::SendJsonRequest() | https://chromium-review.googlesource.com/c/chromium/src/+/6326236

* 6244461: Merge //content/common/user_agent.cc into //components/embedder_support:user_agent | https://chromium-review.googlesource.com/c/chromium/src/+/6244461

* 6313744: Migrate views::Background factory methods to ColorVariant | https://chromium-review.googlesource.com/c/chromium/src/+/6313744

* 6314545: Remove multiple argument support from base::ToString() | https://chromium-review.googlesource.com/c/chromium/src/+/6314545

* 6317362: [Extensions] Inline MessagingDelegate::CreateReceiverForTab() | https://chromium-review.googlesource.com/c/chromium/src/+/6317362

* 6308998: Add SettingAccess structured metrics event for DevTools | https://chromium-review.googlesource.com/c/chromium/src/+/6308998

* 6295214: Remove redundant state field in per-extension preferences | https://chromium-review.googlesource.com/c/chromium/src/+/6295214

NB: this change is copied from the upstream change to extensions/shell/browser/shell_extension_loader.cc

* fix: ui/ linter error

This is showing up in an eslint build step in Electron:

> /__w/electron/electron/src/out/Default/gen/ui/webui/resources/cr_elements/preprocessed/cr_menu_selector/cr_menu_selector.ts
>   77:23  error  This assertion is unnecessary since the receiver accepts the original type of the expression  @typescript-eslint/no-unnecessary-type-assertion
>
> ✖ 1 problem (1 error, 0 warnings)
>   1 error and 0 warnings potentially fixable with the `--fix` option.

However, removing the assertion causes a typescript build failure:

> gen/ui/webui/resources/cr_elements/preprocessed/cr_menu_selector/cr_menu_selector.ts:77:23 - error TS2345: Argument of type 'HTMLElement | null' is not assignable to parameter of type 'HTMLElement'.
>   Type 'null' is not assignable to type 'HTMLElement'.
>
> 77         items.indexOf(this.querySelector<HTMLElement>(':focus'));
>                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

So I think the two different steps may be picking up typescript definitions.

This patch should be removed after the issue is tracked down
and fixed in a followup task.

* fix: -Wnonnull warning

Fixes this warning:

> 2025-03-07T01:05:01.8637705Z ../../third_party/electron_node/src/debug_utils.cc(257,12): error: null passed to a callee that requires a non-null argument [-Werror,-Wnonnull]
> 2025-03-07T01:05:01.8638267Z   257 |     return nullptr;
> 2025-03-07T01:05:01.8638481Z       |            ^~~~~~~
> 2025-03-07T01:05:01.8638700Z 1 error generated.

Not sure why this warning was never triggered before; `git blame`
indicates this code hasn't changed in ages:

> c40a8273ef2 (Michaël Zasso    2024-05-10 09:50:20 +0200 255) #endif  // DEBUG
> 8e2d33f1562 (Anna Henningsen  2018-06-07 16:54:29 +0200 256)     }
> 247b5130595 (Refael Ackermann 2018-10-22 15:07:00 -0400 257)     return nullptr;
> 247b5130595 (Refael Ackermann 2018-10-22 15:07:00 -0400 258)   }

Presumably this is failing in this Chromium roll due to a
clang version bump.

We should remove this patch after upstreaming it.

* docs: add upstream pr link for Node patch

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2025-03-07 11:35:59 -06:00
Robo
530ccfe350 fix: resolve font list in default prefernce values (#45905)
* fix: resolve font list in default prefernce values

* chore: fix unsafe buffer usage

* docs: add code comment
2025-03-07 18:22:03 +09:00
Robo
041ada1586 build: match upstream with unsafe buffer paths (#45853)
* build: match upstream with unsafe buffer paths

* Don't assume STL iterators are pointers

Refs https://issues.chromium.org/issues/328308661

* chore: spanify process_singleton_win.cc
2025-03-06 16:04:18 -05:00
yangllu
d987bee007 fix: javascript heap OOM is not raised (#45895)
fix: javascript heap oom is not raised in node::OOMErrorHandler

node::OOMErrorHandler terminates the process directly without raising an
oom exception. To fix it, set an oom handler into node from electron.
2025-03-06 17:34:19 +01:00
Erick Zhao
431a791a99 chore: emphasize documentation style guide (#45639)
docs: emphasize documentation style guide
2025-03-06 17:17:06 +01:00
dependabot[bot]
9441cf4627 build(deps): bump dsanders11/project-actions from 1.5.1 to 1.5.2 (#45901)
Bumps [dsanders11/project-actions](https://github.com/dsanders11/project-actions) from 1.5.1 to 1.5.2.
- [Release notes](https://github.com/dsanders11/project-actions/releases)
- [Changelog](https://github.com/dsanders11/project-actions/blob/main/.releaserc.json)
- [Commits](9c80cd31f5...7fc3c5441a)

---
updated-dependencies:
- dependency-name: dsanders11/project-actions
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-06 16:38:31 +01:00
Charles Kerr
bb1c3dff21 chore: bump chromium to 135.0.7049.7 (main) (#45900)
chore: bump chromium in DEPS to 135.0.7049.7
2025-03-05 16:36:52 -05:00
214 changed files with 2294 additions and 5270 deletions

View File

@@ -2,7 +2,7 @@ version: '3'
services:
buildtools:
image: ghcr.io/electron/devcontainer:9f11982e806f439d0a0a8ebbbf566cd5e0d9e952
image: ghcr.io/electron/devcontainer:77262e58c37631ab082482f42c33cdf68c6c394b
volumes:
- ..:/workspaces/gclient/src/electron:cached

View File

@@ -9,8 +9,6 @@ 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:
@@ -24,30 +22,36 @@ runs:
uses: ./src/electron/.github/actions/set-chromium-cookie
- name: Install Build Tools
uses: ./src/electron/.github/actions/install-build-tools
- 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: Generate DEPS Hash
shell: bash
run: |
node src/electron/script/generate-deps-hash.js
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
echo "DEPSHASH=v1-src-cache-$(cat src/electron/.depshash)" >> $GITHUB_ENV
- name: Generate SAS Key
if: ${{ inputs.generate-sas-token == 'true' }}
shell: bash
run: |
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$CACHE_FILE?platform=${{ inputs.target-platform }}" > sas-token
curl --unix-socket /var/run/sas/sas.sock --fail "http://foo/$DEPSHASH.tar" > sas-token
- name: Save SAS Key
if: ${{ inputs.generate-sas-token == 'true' }}
uses: actions/cache/save@d4323d4df104b026a6aa633fdb11d772146be0bf
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: sas-token
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-${{ github.run_attempt }}
enableCrossOsArchive: true
path: |
sas-token
key: sas-key-${{ github.run_number }}-${{ github.run_attempt }}
- name: Check If Cache Exists
id: check-cache
shell: bash
@@ -56,7 +60,7 @@ runs:
echo "Not using cache this time..."
echo "cache_exists=false" >> $GITHUB_OUTPUT
else
cache_path=$CACHE_DRIVE/$CACHE_FILE
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
echo "Using cache key: $DEPSHASH"
echo "Checking for cache in: $cache_path"
if [ ! -f "$cache_path" ] || [ `du $cache_path | cut -f1` = "0" ]; then
@@ -72,8 +76,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 $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
freespace_human=`df -h $CACHE_DRIVE | grep -w $CACHE_DRIVE | awk '{print $4}'`
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}'`
if [ $freespace -le 35000 ]; then
echo "The cross mount cache has $freespace_human free space which is not enough - exiting"
exit 1
@@ -163,14 +167,14 @@ runs:
shell: bash
run: |
echo "Uncompressed src size: $(du -sh src | cut -f1 -d' ')"
tar -cf $CACHE_FILE src
echo "Compressed src to $(du -sh $CACHE_FILE | cut -f1 -d' ')"
cp ./$CACHE_FILE $CACHE_DRIVE/
tar -cf $DEPSHASH.tar src
echo "Compressed src to $(du -sh $DEPSHASH.tar | cut -f1 -d' ')"
cp ./$DEPSHASH.tar /mnt/cross-instance-cache/
- name: Persist Src Cache
if: ${{ steps.check-cache.outputs.cache_exists == 'false' && inputs.use-cache == 'true' }}
shell: bash
run: |
final_cache_path=$CACHE_DRIVE/$CACHE_FILE
final_cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
echo "Using cache key: $DEPSHASH"
echo "Checking path: $final_cache_path"
if [ ! -f "$final_cache_path" ]; then

View File

@@ -1,40 +0,0 @@
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

View File

@@ -0,0 +1,61 @@
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

View File

@@ -1,120 +0,0 @@
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
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 $nodedeps.object_name
- 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

View File

@@ -14,9 +14,7 @@ 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

View File

@@ -1,20 +1,12 @@
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: |
if [ "${{ inputs.target-platform }}" = "win" ]; then
cache_path=/mnt/win-cache/$DEPSHASH.tar
else
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
fi
cache_path=/mnt/cross-instance-cache/$DEPSHASH.tar
echo "Using cache key: $DEPSHASH"
echo "Checking for cache in: $cache_path"
if [ ! -f "$cache_path" ]; then

View File

@@ -1,25 +1,22 @@
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@d4323d4df104b026a6aa633fdb11d772146be0bf
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: sas-token
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-1
enableCrossOsArchive: true
path: |
sas-token
key: sas-key-${{ github.run_number }}-1
- name: Obtain SAS Key
continue-on-error: true
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
with:
path: sas-token
key: sas-key-${{ inputs.target-platform }}-${{ github.run_number }}-${{ github.run_attempt }}
enableCrossOsArchive: true
path: |
sas-token
key: sas-key-${{ github.run_number }}-${{ github.run_attempt }}
- 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
@@ -29,30 +26,21 @@ 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)"
@@ -80,45 +68,4 @@ runs:
fi
echo "Wiping Electron Directory"
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
rm -rf src/electron

View File

@@ -4,14 +4,9 @@ runs:
using: "composite"
steps:
- name: Set the git cookie from chromium.googlesource.com (Unix)
if: ${{ runner.os != 'Windows' }}
if: ${{ runner.os != 'Windows' && env.CHROMIUM_GIT_COOKIE }}
shell: bash
run: |
if [[ -z "${{ env.CHROMIUM_GIT_COOKIE }}" ]]; then
echo "CHROMIUM_GIT_COOKIE is not set - cannot authenticate."
exit 0
fi
eval 'set +o history' 2>/dev/null || setopt HIST_IGNORE_SPACE 2>/dev/null
touch ~/.gitcookies
chmod 0600 ~/.gitcookies
@@ -22,37 +17,10 @@ runs:
${{ env.CHROMIUM_GIT_COOKIE }}
__END__
eval 'set -o history' 2>/dev/null || unsetopt HIST_IGNORE_SPACE 2>/dev/null
RESPONSE=$(curl -s -b ~/.gitcookies https://chromium-review.googlesource.com/a/accounts/self)
if [[ $RESPONSE == ")]}'"* ]]; then
# Extract account email for verification
EMAIL=$(echo "$RESPONSE" | tail -c +5 | jq -r '.email // "No email found"')
echo "Cookie authentication successful - authenticated as: $EMAIL"
else
echo "Cookie authentication failed - ensure CHROMIUM_GIT_COOKIE is set correctly"
echo $RESPONSE
fi
- name: Set the git cookie from chromium.googlesource.com (Windows)
if: ${{ runner.os == 'Windows' }}
if: ${{ runner.os == 'Windows' && env.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
shell: cmd
run: |
if "%CHROMIUM_GIT_COOKIE_WINDOWS_STRING%"=="" (
echo CHROMIUM_GIT_COOKIE_WINDOWS_STRING is not set - cannot authenticate.
exit /b 0
)
git config --global http.cookiefile "%USERPROFILE%\.gitcookies"
powershell -noprofile -nologo -command Write-Output "${{ env.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}" >>"%USERPROFILE%\.gitcookies"
curl -s -b "%USERPROFILE%\.gitcookies" https://chromium-review.googlesource.com/a/accounts/self > response.txt
findstr /B /C:")]}'" response.txt > nul
if %ERRORLEVEL% EQU 0 (
echo Cookie authentication successful
powershell -NoProfile -Command "& {$content = Get-Content -Raw response.txt; $content = $content.Substring(4); try { $json = ConvertFrom-Json $content; if($json.email) { Write-Host 'Authenticated as:' $json.email } else { Write-Host 'No email found in response' } } catch { Write-Host 'Error parsing JSON:' $_ }}"
) else (
echo Cookie authentication failed - ensure CHROMIUM_GIT_COOKIE_WINDOWS_STRING is set correctly
type response.txt
)
del response.txt

View File

@@ -94,7 +94,7 @@ jobs:
}))
- name: Create Release Project Board
if: ${{ steps.check-major-version.outputs.MAJOR }}
uses: dsanders11/project-actions/copy-project@9c80cd31f58599941c64f74636bea95ba5d46090 # v1.5.1
uses: dsanders11/project-actions/copy-project@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
id: create-release-board
with:
drafts: true
@@ -114,14 +114,15 @@ jobs:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: Find Previous Release Project Board
if: ${{ steps.check-major-version.outputs.MAJOR }}
uses: dsanders11/project-actions/find-project@9c80cd31f58599941c64f74636bea95ba5d46090 # v1.5.1
uses: dsanders11/project-actions/find-project@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
id: find-prev-release-board
with:
fail-if-project-not-found: false
title: ${{ steps.generate-project-metadata.outputs.prev-prev-major }}-x-y
token: ${{ steps.generate-token.outputs.token }}
- name: Close Previous Release Project Board
if: ${{ steps.check-major-version.outputs.MAJOR }}
uses: dsanders11/project-actions/close-project@9c80cd31f58599941c64f74636bea95ba5d46090 # v1.5.1
if: ${{ steps.find-prev-release-board.outputs.number }}
uses: dsanders11/project-actions/close-project@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
with:
project-number: ${{ steps.find-prev-release-board.outputs.number }}
token: ${{ steps.generate-token.outputs.token }}

View File

@@ -6,7 +6,7 @@ on:
build-image-sha:
type: string
description: 'SHA for electron/build image'
default: '9f11982e806f439d0a0a8ebbbf566cd5e0d9e952'
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
required: true
skip-macos:
type: boolean
@@ -30,7 +30,7 @@ on:
required: false
push:
branches:
- main
- sckp-macos15
- '[1-9][0-9]-x-y'
pull_request:
@@ -64,7 +64,7 @@ jobs:
id: set-output
run: |
if [ -z "${{ inputs.build-image-sha }}" ]; then
echo "build-image-sha=9f11982e806f439d0a0a8ebbbf566cd5e0d9e952" >> "$GITHUB_OUTPUT"
echo "build-image-sha=bc2f48b2415a670de18d13605b1cf0eb5fdbaae1" >> "$GITHUB_OUTPUT"
else
echo "build-image-sha=${{ inputs.build-image-sha }}" >> "$GITHUB_OUTPUT"
fi
@@ -115,7 +115,6 @@ jobs:
uses: ./src/electron/.github/actions/checkout
with:
generate-sas-token: 'true'
target-platform: macos
checkout-linux:
needs: setup
@@ -151,8 +150,7 @@ jobs:
image: ghcr.io/electron/build:${{ needs.setup.outputs.build-image-sha }}
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
volumes:
- /mnt/win-cache:/mnt/win-cache
- /var/run/sas:/var/run/sas
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
env:
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
@@ -170,9 +168,6 @@ 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:
@@ -203,7 +198,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/win-cache:/mnt/win-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/cross-instance-cache:/mnt/cross-instance-cache"]}'
gn-build-type: testing
secrets: inherit
@@ -331,7 +326,7 @@ jobs:
issues: read
pull-requests: read
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
needs: checkout-windows
needs: setup
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
with:
build-runs-on: electron-arc-windows-amd64-16core
@@ -350,7 +345,7 @@ jobs:
issues: read
pull-requests: read
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
needs: checkout-windows
needs: setup
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
with:
build-runs-on: electron-arc-windows-amd64-16core
@@ -369,7 +364,7 @@ jobs:
issues: read
pull-requests: read
uses: ./.github/workflows/pipeline-electron-build-and-test.yml
needs: checkout-windows
needs: setup
if: ${{ needs.setup.outputs.src == 'true' && !inputs.skip-windows }}
with:
build-runs-on: electron-arc-windows-amd64-16core

View File

@@ -16,7 +16,6 @@ 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
@@ -24,6 +23,3 @@ 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

View File

@@ -20,7 +20,7 @@ jobs:
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
org: electron
- name: Set status
uses: dsanders11/project-actions/edit-item@9c80cd31f58599941c64f74636bea95ba5d46090 # v1.5.1
uses: dsanders11/project-actions/edit-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
with:
token: ${{ steps.generate-token.outputs.token }}
project-number: 90
@@ -39,7 +39,7 @@ jobs:
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
org: electron
- name: Set status
uses: dsanders11/project-actions/edit-item@9c80cd31f58599941c64f74636bea95ba5d46090 # v1.5.1
uses: dsanders11/project-actions/edit-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
with:
token: ${{ steps.generate-token.outputs.token }}
project-number: 90

View File

@@ -19,7 +19,7 @@ jobs:
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
org: electron
- name: Add to Issue Triage
uses: dsanders11/project-actions/add-item@9c80cd31f58599941c64f74636bea95ba5d46090 # v1.5.1
uses: dsanders11/project-actions/add-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
with:
field: Reporter
field-value: ${{ github.event.issue.user.login }}

View File

@@ -19,7 +19,7 @@ jobs:
creds: ${{ secrets.ISSUE_TRIAGE_GH_APP_CREDS }}
org: electron
- name: Remove from issue triage
uses: dsanders11/project-actions/delete-item@9c80cd31f58599941c64f74636bea95ba5d46090 # v1.5.1
uses: dsanders11/project-actions/delete-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
with:
token: ${{ steps.generate-token.outputs.token }}
project-number: 90

View File

@@ -30,7 +30,7 @@ jobs:
org: electron
- name: Set status
if: ${{ steps.check-for-blocked-labels.outputs.NOT_BLOCKED }}
uses: dsanders11/project-actions/edit-item@9c80cd31f58599941c64f74636bea95ba5d46090 # v1.5.1
uses: dsanders11/project-actions/edit-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
with:
token: ${{ steps.generate-token.outputs.token }}
project-number: 90

View File

@@ -6,7 +6,7 @@ on:
build-image-sha:
type: string
description: 'SHA for electron/build image'
default: '9f11982e806f439d0a0a8ebbbf566cd5e0d9e952'
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
upload-to-storage:
description: 'Uploads to Azure storage'
required: false
@@ -27,7 +27,6 @@ jobs:
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
- /var/run/sas:/var/run/sas
env:
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_arm=True --custom-var=checkout_arm64=True'
steps:
- name: Checkout Electron

View File

@@ -6,7 +6,7 @@ on:
build-image-sha:
type: string
description: 'SHA for electron/build image'
default: '9f11982e806f439d0a0a8ebbbf566cd5e0d9e952'
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
required: true
upload-to-storage:
description: 'Uploads to Azure storage'
@@ -28,7 +28,6 @@ jobs:
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
- /var/run/sas:/var/run/sas
env:
CHROMIUM_GIT_COOKIE: ${{ secrets.CHROMIUM_GIT_COOKIE }}
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_mac=True --custom-var=host_os=mac'
steps:
- name: Checkout Electron
@@ -40,7 +39,6 @@ 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

View File

@@ -129,8 +129,24 @@ jobs:
echo "GN_EXTRA_ARGS=$GN_EXTRA_ARGS" >> $GITHUB_ENV
- 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: 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: Generate DEPS Hash
run: |
node src/electron/script/generate-deps-hash.js
@@ -138,26 +154,24 @@ jobs:
echo "DEPSHASH=$DEPSHASH" >> $GITHUB_ENV
echo "CACHE_PATH=$DEPSHASH.tar" >> $GITHUB_ENV
- name: Restore src cache via AZCopy
if: ${{ inputs.target-platform != 'linux' }}
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' }}
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@11bd71901bbe5b1630ceea73d27597364c9af683
with:
path: src/electron
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- 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: Install Build Tools
uses: ./src/electron/.github/actions/install-build-tools
- 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 }}
@@ -170,6 +184,9 @@ 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

View File

@@ -65,9 +65,7 @@ jobs:
sudo rm -rf $TMPDIR/del-target
- name: Check disk space after freeing up space
if: ${{ inputs.target-platform == 'macos' }}
run: df -h
- name: Set Chromium Git Cookie
uses: ./src/electron/.github/actions/set-chromium-cookie
run: df -h
- name: Install Build Tools
uses: ./src/electron/.github/actions/install-build-tools
- name: Enable windows toolchain
@@ -83,13 +81,9 @@ 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

View File

@@ -60,6 +60,15 @@ 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: 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@cc203385981b70ca67e1cc392babf9cc229d5806
with:
@@ -105,8 +114,6 @@ 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
@@ -114,6 +121,17 @@ 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@cc203385981b70ca67e1cc392babf9cc229d5806
with:

View File

@@ -33,7 +33,7 @@ jobs:
creds: ${{ secrets.RELEASE_BOARD_GH_APP_CREDS }}
org: electron
- name: Set status
uses: dsanders11/project-actions/edit-item@9c80cd31f58599941c64f74636bea95ba5d46090 # v1.5.1
uses: dsanders11/project-actions/edit-item@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
with:
token: ${{ steps.generate-token.outputs.token }}
project-number: 94

View File

@@ -50,6 +50,6 @@ jobs:
# Upload the results to GitHub's code scanning dashboard.
- name: "Upload to code-scanning"
uses: github/codeql-action/upload-sarif@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10
uses: github/codeql-action/upload-sarif@6bb031afdd8eb862ea3fc1848194185e076637e5 # v3.28.11
with:
sarif_file: results.sarif

View File

@@ -27,7 +27,7 @@ jobs:
PROJECT_NUMBER=$(gh project list --owner electron --format json | jq -r '.projects | map(select(.title | test("^[0-9]+-x-y$"))) | max_by(.number) | .number')
echo "PROJECT_NUMBER=$PROJECT_NUMBER" >> "$GITHUB_OUTPUT"
- name: Update Completed Stable Prep Items
uses: dsanders11/project-actions/completed-by@9c80cd31f58599941c64f74636bea95ba5d46090 # v1.5.1
uses: dsanders11/project-actions/completed-by@2134fe7cc71c58b7ae259c82a8e63c6058255678 # v1.7.0
with:
field: Prep Status
field-value: ✅ Complete

View File

@@ -6,7 +6,7 @@ on:
build-image-sha:
type: string
description: 'SHA for electron/build image'
default: '9f11982e806f439d0a0a8ebbbf566cd5e0d9e952'
default: 'bc2f48b2415a670de18d13605b1cf0eb5fdbaae1'
required: true
upload-to-storage:
description: 'Uploads to Azure storage'
@@ -25,10 +25,8 @@ jobs:
image: ghcr.io/electron/build:${{ inputs.build-image-sha }}
options: --user root --device /dev/fuse --cap-add SYS_ADMIN
volumes:
- /mnt/win-cache:/mnt/win-cache
- /var/run/sas:/var/run/sas
- /mnt/cross-instance-cache:/mnt/cross-instance-cache
env:
CHROMIUM_GIT_COOKIE_WINDOWS_STRING: ${{ secrets.CHROMIUM_GIT_COOKIE_WINDOWS_STRING }}
GCLIENT_EXTRA_ARGS: '--custom-var=checkout_win=True'
TARGET_OS: 'win'
ELECTRON_DEPOT_TOOLS_WIN_TOOLCHAIN: '1'
@@ -42,9 +40,6 @@ 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

View File

@@ -1246,7 +1246,7 @@ if (is_mac) {
"//components/crash/core/app:run_as_crashpad_handler",
]
ldflags = [ "/DELAYLOAD:ffmpeg.dll" ]
ldflags = []
libs = [
"comctl32.lib",

View File

@@ -73,5 +73,3 @@ enterprise_cloud_content_analysis = false
# TODO: remove dependency on legacy ipc
# https://issues.chromium.org/issues/40943039
content_enable_legacy_ipc = true
clang_unsafe_buffers_paths = "//electron/electron_unsafe_buffers_paths.txt"

View File

@@ -96,9 +96,8 @@ These individual tutorials expand on topics discussed in the guide above.
* [Chrome Extensions Support](api/extensions.md)
* [Breaking API Changes](breaking-changes.md)
### Custom Web Features:
### Custom DOM Elements:
* [`-electron-corner-smoothing` CSS Rule](api/corner-smoothing-css.md)
* [`<webview>` Tag](api/webview-tag.md)
* [`window.open` Function](api/window-open.md)

View File

@@ -342,12 +342,12 @@ Emitted when the window has closed a sheet.
Emitted when the native new tab button is clicked.
#### Event: 'system-context-menu' _Windows_ _Linux_
#### Event: 'system-context-menu' _Windows_
Returns:
* `event` Event
* `point` [Point](structures/point.md) - The screen coordinates where the context menu was triggered.
* `point` [Point](structures/point.md) - The screen coordinates the context menu was triggered at
Emitted when the system context menu is triggered on the window, this is
normally only triggered when the user right clicks on the non-client area
@@ -356,8 +356,6 @@ as `-webkit-app-region: drag` in a frameless window.
Calling `event.preventDefault()` will prevent the menu from being displayed.
To convert `point` to DIP, use [`screen.screenToDipPoint(point)`](./screen.md#screenscreentodippointpoint-windows).
### Static Methods
The `BaseWindow` class has the following static methods:
@@ -513,10 +511,6 @@ A `string` property that defines an alternative title provided only to
accessibility tools such as screen readers. This string is not directly
visible to users.
#### `win.snapped` _Windows_ _Readonly_
A `boolean` property that indicates whether the window is arranged via [Snap.](https://support.microsoft.com/en-us/windows/snap-your-windows-885a9b1e-a983-a3b1-16cd-c531795e6241)
### Instance Methods
Objects created with `new BaseWindow` have the following instance methods:
@@ -1270,13 +1264,6 @@ Sets whether the menu bar should be visible. If the menu bar is auto-hide, users
Returns `boolean` - Whether the menu bar is visible.
#### `win.isSnapped()` _Windows_
Returns `boolean` - whether the window is arranged via [Snap.](https://support.microsoft.com/en-us/windows/snap-your-windows-885a9b1e-a983-a3b1-16cd-c531795e6241)
The window is snapped via buttons shown when the mouse is hovered over window
maximize button, or by dragging it to the edges of the screen.
#### `win.setVisibleOnAllWorkspaces(visible[, options])` _macOS_ _Linux_
* `visible` boolean

View File

@@ -421,12 +421,12 @@ Emitted when the window has closed a sheet.
Emitted when the native new tab button is clicked.
#### Event: 'system-context-menu' _Windows_ _Linux_
#### Event: 'system-context-menu' _Windows_
Returns:
* `event` Event
* `point` [Point](structures/point.md) - The screen coordinates where the context menu was triggered.
* `point` [Point](structures/point.md) - The screen coordinates the context menu was triggered at
Emitted when the system context menu is triggered on the window, this is
normally only triggered when the user right clicks on the non-client area
@@ -435,8 +435,6 @@ as `-webkit-app-region: drag` in a frameless window.
Calling `event.preventDefault()` will prevent the menu from being displayed.
To convert `point` to DIP, use [`screen.screenToDipPoint(point)`](./screen.md#screenscreentodippointpoint-windows).
### Static Methods
The `BrowserWindow` class has the following static methods:
@@ -613,10 +611,6 @@ A `string` property that defines an alternative title provided only to
accessibility tools such as screen readers. This string is not directly
visible to users.
#### `win.snapped` _Windows_ _Readonly_
A `boolean` property that indicates whether the window is arranged via [Snap.](https://support.microsoft.com/en-us/windows/snap-your-windows-885a9b1e-a983-a3b1-16cd-c531795e6241)
### Instance Methods
Objects created with `new BrowserWindow` have the following instance methods:
@@ -1451,13 +1445,6 @@ Sets whether the menu bar should be visible. If the menu bar is auto-hide, users
Returns `boolean` - Whether the menu bar is visible.
#### `win.isSnapped()` _Windows_
Returns `boolean` - whether the window is arranged via [Snap.](https://support.microsoft.com/en-us/windows/snap-your-windows-885a9b1e-a983-a3b1-16cd-c531795e6241)
The window is snapped via buttons shown when the mouse is hovered over window
maximize button, or by dragging it to the edges of the screen.
#### `win.setVisibleOnAllWorkspaces(visible[, options])` _macOS_ _Linux_
* `visible` boolean

View File

@@ -20,87 +20,45 @@ document.
#### `commandLine.appendSwitch(switch[, value])`
* `switch` string - A command-line switch, without the leading `--`.
* `value` string (optional) - A value for the given switch.
* `switch` string - A command-line switch, without the leading `--`
* `value` string (optional) - A value for the given switch
Append a switch (with optional `value`) to Chromium's command line.
**Note:** This will not affect `process.argv`. The intended usage of this function is to
control Chromium's behavior.
```js
const { app } = require('electron')
app.commandLine.appendSwitch('remote-debugging-port', '8315')
```
#### `commandLine.appendArgument(value)`
* `value` string - The argument to append to the command line.
* `value` string - The argument to append to the command line
Append an argument to Chromium's command line. The argument will be quoted
correctly. Switches will precede arguments regardless of appending order.
If you're appending an argument like `--switch=value`, consider using `appendSwitch('switch', 'value')` instead.
```js
const { app } = require('electron')
app.commandLine.appendArgument('--enable-experimental-web-platform-features')
```
**Note:** This will not affect `process.argv`. The intended usage of this function is to
control Chromium's behavior.
#### `commandLine.hasSwitch(switch)`
* `switch` string - A command-line switch.
* `switch` string - A command-line switch
Returns `boolean` - Whether the command-line switch is present.
```js
const { app } = require('electron')
app.commandLine.appendSwitch('remote-debugging-port', '8315')
const hasPort = app.commandLine.hasSwitch('remote-debugging-port')
console.log(hasPort) // true
```
#### `commandLine.getSwitchValue(switch)`
* `switch` string - A command-line switch.
* `switch` string - A command-line switch
Returns `string` - The command-line switch value.
This function is meant to obtain Chromium command line switches. It is not
meant to be used for application-specific command line arguments. For the
latter, please use `process.argv`.
```js
const { app } = require('electron')
app.commandLine.appendSwitch('remote-debugging-port', '8315')
const portValue = app.commandLine.getSwitchValue('remote-debugging-port')
console.log(portValue) // '8315'
```
**Note:** When the switch is not present or has no value, it returns empty string.
#### `commandLine.removeSwitch(switch)`
* `switch` string - A command-line switch.
* `switch` string - A command-line switch
Removes the specified switch from Chromium's command line.
```js
const { app } = require('electron')
app.commandLine.appendSwitch('remote-debugging-port', '8315')
console.log(app.commandLine.hasSwitch('remote-debugging-port')) // true
app.commandLine.removeSwitch('remote-debugging-port')
console.log(app.commandLine.hasSwitch('remote-debugging-port')) // false
```
**Note:** This will not affect `process.argv`. The intended usage of this function is to
control Chromium's behavior.

View File

@@ -1,78 +0,0 @@
## CSS Rule: `-electron-corner-smoothing`
> Smoothes out the corner rounding of the `border-radius` CSS rule.
The rounded corners of elements with [the `border-radius` CSS rule](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius) can be smoothed out using the `-electron-corner-smoothing` CSS rule. This smoothness is very similar to Apple's "continuous" rounded corners in SwiftUI and Figma's "corner smoothing" control on design elements.
![There is a black rectangle on the left using simple rounded corners, and a blue rectangle on the right using smooth rounded corners. In between those rectangles is a magnified view of the same corner from both rectangles overlapping to show the subtle difference in shape.](../images/corner-smoothing-summary.svg)
Integrating with the operating system and its design language is important to many desktop applications. The shape of a rounded corner can be a subtle detail to many users. However, aligning closely to the system's design language that users are familiar with makes the application's design feel familiar too. Beyond matching the design language of macOS, designers may decide to use smoother round corners for many other reasons.
`-electron-corner-smoothing` affects the shape of borders, outlines, and shadows on the target element. Mirroring the behavior of `border-radius`, smoothing will gradually back off if an element's size is too small for the chosen value.
The `-electron-corner-smoothing` CSS rule is **only implemented for Electron** and has no effect in browsers. Avoid using this rule outside of Electron. This CSS rule is considered experimental and may require migration in the future if replaced by a CSS standard.
### Example
The following example shows the effect of corner smoothing at different percents.
```css
.box {
width: 128px;
height: 128px;
background-color: cornflowerblue;
border-radius: 24px;
-electron-corner-smoothing: var(--percent); /* Column header in table below. */
}
```
| 0% | 30% | 60% | 100% |
| --- | --- | --- | --- |
| ![A rectangle with round corners at 0% smoothness](../images/corner-smoothing-example-0.svg) | ![A rectangle with round corners at 30% smoothness](../images/corner-smoothing-example-30.svg) | ![A rectangle with round corners at 60% smoothness](../images/corner-smoothing-example-60.svg) | ![A rectangle with round corners at 100% smoothness](../images/corner-smoothing-example-100.svg) |
### Matching the system UI
Use the `system-ui` keyword to match the smoothness to the OS design language.
```css
.box {
width: 128px;
height: 128px;
background-color: cornflowerblue;
border-radius: 24px;
-electron-corner-smoothing: system-ui; /* Match the system UI design. */
}
```
| OS: | macOS | Windows, Linux |
| --- | --- | --- |
| Value: | `60%` | `0%` |
| Example: | ![A rectangle with round corners whose smoothness matches macOS](../images/corner-smoothing-example-60.svg) | ![A rectangle with round corners whose smoothness matches Windows and Linux](../images/corner-smoothing-example-0.svg) |
### Controlling availibility
This CSS rule can be disabled by setting [the `cornerSmoothingCSS` web preference](./structures/web-preferences.md) to `false`.
```js
const myWindow = new BrowserWindow({
// [...]
webPreferences: {
enableCornerSmoothingCSS: false // Disables the `-electron-corner-smoothing` CSS rule
}
})
```
The CSS rule will still parse, but will have no visual effect.
### Formal reference
* **Initial value**: `0%`
* **Inherited**: No
* **Animatable**: No
* **Computed value**: As specified
```css
-electron-corner-smoothing =
<percentage [0,100]> |
system-ui
```

View File

@@ -17,7 +17,8 @@ app.whenReady().then(() => {
session.defaultSession.setDisplayMediaRequestHandler((request, callback) => {
desktopCapturer.getSources({ types: ['screen'] }).then((sources) => {
// Grant access to the first screen found.
// Your app shows some UI, but in this example
// grant access to the first screen found.
callback({ video: sources[0], audio: 'loopback' })
})
// If true, use the system picker if available.
@@ -42,7 +43,8 @@ startButton.addEventListener('click', () => {
video: {
width: 320,
height: 240,
frameRate: 30
frameRate: 30,
displaySurface: 'monitor'
}
}).then(stream => {
video.srcObject = stream
@@ -98,6 +100,16 @@ which can detected by [`systemPreferences.getMediaAccessStatus`][].
[`navigator.mediaDevices.getUserMedia`]: https://developer.mozilla.org/en/docs/Web/API/MediaDevices/getUserMedia
[`systemPreferences.getMediaAccessStatus`]: system-preferences.md#systempreferencesgetmediaaccessstatusmediatype-windows-macos
### `desktopCapturer.isDisplayMediaSystemPickerAvailable()` _Experimental_ _macOS_
Returns `Boolean`, whether or not requesting desktop content via
the system picker is supported on this platform.
Currently this will only return `true` on macOS 14.4 and higher. When
true, use the `getNativePickerSource` method to return the system picker's
selected media stream. Not doing so may cause a warning dialog to your users
on macOS 15 and higher.
## Caveats
`navigator.mediaDevices.getUserMedia` does not work on macOS for audio capture due to a fundamental limitation whereby apps that want to access the system's audio require a [signed kernel extension](https://developer.apple.com/library/archive/documentation/Security/Conceptual/System_Integrity_Protection_Guide/KernelExtensions/KernelExtensions.html). Chromium, and by extension Electron, does not provide this.

View File

@@ -9,7 +9,7 @@ The following example shows how to bounce your icon on the dock.
```js
const { app } = require('electron')
app.dock?.bounce()
app.dock.bounce()
```
### Instance Methods

View File

@@ -73,8 +73,6 @@ The `menu` object has the following instance methods:
* `options` Object (optional)
* `window` [BaseWindow](base-window.md) (optional) - Default is the focused window.
* `frame` [WebFrameMain](web-frame-main.md) (optional) - Provide the relevant frame
if you want certain OS-level features such as Writing Tools on macOS to function correctly. Typically, this should be `params.frame` from the [`context-menu` event](web-contents.md#event-context-menu) on a WebContents.
* `x` number (optional) - Default is the current mouse cursor position.
Must be declared if `y` is declared.
* `y` number (optional) - Default is the current mouse cursor position.

View File

@@ -46,7 +46,4 @@ See: https://developer.apple.com/documentation/appkit/nsapplication/1428476-regi
### `pushNotifications.unregisterForAPNSNotifications()` _macOS_
Unregisters the app from notifications received from APNS.
Apps unregistered through this method can always reregister.
See: https://developer.apple.com/documentation/appkit/nsapplication/1428747-unregisterforremotenotifications?language=objc

View File

@@ -46,6 +46,10 @@ An [`IpcMainServiceWorker`](ipc-main-service-worker.md) instance scoped to the s
A `string` representing the scope URL of the service worker.
#### `serviceWorker.scriptURL` _Readonly_ _Experimental_
A `string` representing the script URL of the service worker.
#### `serviceWorker.versionId` _Readonly_ _Experimental_
A `number` representing the ID of the specific version of the service worker script in its scope.

View File

@@ -971,6 +971,7 @@ session.fromPartition('some-partition').setPermissionCheckHandler((webContents,
* `videoRequested` Boolean - true if the web content requested a video stream.
* `audioRequested` Boolean - true if the web content requested an audio stream.
* `userGesture` Boolean - Whether a user gesture was active when this request was triggered.
* `preferredDisplaySurface` String - The preferred display used for sharing screen in this request.
* `callback` Function
* `streams` Object
* `video` Object | [WebFrameMain](web-frame-main.md) (optional)

View File

@@ -93,7 +93,7 @@
**Note:** This option is currently experimental.
* `titleBarOverlay` Object | Boolean (optional) - When using a frameless window in conjunction with `win.setWindowButtonVisibility(true)` on macOS or using a `titleBarStyle` so that the standard window controls ("traffic lights" on macOS) are visible, this property enables the Window Controls Overlay [JavaScript APIs][overlay-javascript-apis] and [CSS Environment Variables][overlay-css-env-vars]. Specifying `true` will result in an overlay with default system colors. Default is `false`.
* `color` String (optional) _Windows_ _Linux_ - The CSS color of the Window Controls Overlay when enabled. Default is the system color.
* `symbolColor` String (optional) _Windows_ _Linux_ - The CSS color of the symbols on the Window Controls Overlay when enabled. Default is the system color.
* `symbolColor` String (optional) _Windows_ - The CSS color of the symbols on the Window Controls Overlay when enabled. Default is the system color.
* `height` Integer (optional) - The height of the title bar and Window Controls Overlay in pixels. Default is system height.
* `trafficLightPosition` [Point](point.md) (optional) _macOS_ -
Set a custom position for the traffic light buttons in frameless windows.

View File

@@ -12,6 +12,6 @@
`pointerDown`, `pointerUp`, `pointerMove`, `pointerRawUpdate`,
`pointerCancel` or `pointerCausedUaAction`.
* `modifiers` string[] (optional) - An array of modifiers of the event, can
be `shift`, `control`, `ctrl`, `alt`, `meta`, `command`, `cmd`, `iskeypad`,
`isautorepeat`, `leftbuttondown`, `middlebuttondown`, `rightbuttondown`,
`capslock`, `numlock`, `left`, `right`.
be `shift`, `control`, `ctrl`, `alt`, `meta`, `command`, `cmd`, `isKeypad`,
`isAutoRepeat`, `leftButtonDown`, `middleButtonDown`, `rightButtonDown`,
`capsLock`, `numLock`, `left`, `right`.

View File

@@ -149,7 +149,6 @@
`WebContents` when the preferred size changes. Default is `false`.
* `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.
* `enableDeprecatedPaste` boolean (optional) _Deprecated_ - Whether to enable the `paste` [execCommand](https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand). Default is `false`.
* `enableCornerSmoothingCSS` boolean (optional) _Experimental_ - Whether the [`-electron-corner-smoothing` CSS rule](../corner-smoothing-css.md) is enabled. Default is `true`.
[chrome-content-scripts]: https://developer.chrome.com/extensions/content_scripts#execution-environment
[runtime-enabled-features]: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/runtime_enabled_features.json5

View File

@@ -44,8 +44,6 @@ Process: [Main](../glossary.md#main-process)<br />
Returns [`UtilityProcess`](utility-process.md#class-utilityprocess)
**Note:** `utilityProcess.fork` can only be called after the `ready` event has been emitted on `App`.
## Class: UtilityProcess
> Instances of the `UtilityProcess` represent the Chromium spawned child process

View File

@@ -16,7 +16,7 @@ Returns `string` - The file system path that this `File` object points to. In th
This method superseded the previous augmentation to the `File` object with the `path` property. An example is included below.
```js @ts-nocheck
```js
// Before
const oldPath = document.querySelector('input').files[0].path

View File

@@ -12,23 +12,21 @@ This document uses the following convention to categorize breaking changes:
* **Deprecated:** An API was marked as deprecated. The API will continue to function, but will emit a deprecation warning, and will be removed in a future release.
* **Removed:** An API or feature was removed, and is no longer supported by Electron.
## Planned Breaking API Changes (37.0)
### Behavior Changed: `BrowserWindow.IsVisibleOnAllWorkspaces()` on Linux
`BrowserWindow.IsVisibleOnAllWorkspaces()` will now return false on Linux if the
window is not currently visible.
### Behavior Changes: `app.commandLine`
`app.commandLine` will convert upper-cases switches and arguments to lowercase.
`app.commandLine` was only meant to handle chromium switches (which aren't case-sensitive) and switches passed via `app.commandLine` will not be passed down to any of the child processes.
If you were using `app.commandLine` to control the behavior of the main process, you should do this via `process.argv`.
## Planned Breaking API Changes (36.0)
### Utility Process unhandled rejection behavior change
Utility Processes will now warn with an error message when an unhandled
rejection occurs instead of crashing the process.
To restore the previous behavior, you can use:
```js
process.on('unhandledRejection', () => {
process.exit(1)
})
```
### Removed:`isDefault` and `status` properties on `PrinterInfo`
These properties have been removed from the PrinterInfo Object
@@ -47,16 +45,6 @@ When calling `Session.clearStorageData(options)`, the `options.quota`
property is deprecated. Since the `syncable` type was removed, there
is only type left -- `'temporary'` -- so specifying it is unnecessary.
### Deprecated: `null` value for `session` property in `ProtocolResponse`
Previously, setting the ProtocolResponse.session property to `null`
Would create a random independent session. This is no longer supported.
Using single-purpose sessions here is discouraged due to overhead costs;
however, old code that needs to preserve this behavior can emulate it by
creating a random session with `session.fromPartition(some_random_string)`
and then using it in `ProtocolResponse.session`.
### Deprecated: Extension methods and events on `session`
`session.loadExtension`, `session.removeExtension`, `session.getExtension`,

View File

@@ -24,7 +24,9 @@ const dockMenu = Menu.buildFromTemplate([
])
app.whenReady().then(() => {
app.dock?.setMenu(dockMenu)
if (process.platform === 'darwin') {
app.dock.setMenu(dockMenu)
}
}).then(createWindow)
app.on('window-all-closed', () => {

View File

@@ -1,3 +0,0 @@
<svg width="192" height="192" viewBox="0 0 192 192" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 48C0 21.4903 21.4903 0 48 0H144C170.51 0 192 21.4903 192 48V144C192 170.51 170.51 192 144 192H48C21.4903 192 0 170.51 0 144V48Z" fill="#6495ED"/>
</svg>

Before

Width:  |  Height:  |  Size: 265 B

View File

@@ -1,3 +0,0 @@
<svg width="192" height="192" viewBox="0 0 192 192" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 96C0 50.7452 0 28.1177 14.0589 14.0589C28.1177 0 50.7452 0 96 0C141.255 0 163.882 0 177.941 14.0589C192 28.1177 192 50.7452 192 96C192 141.255 192 163.882 177.941 177.941C163.882 192 141.255 192 96 192C50.7452 192 28.1177 192 14.0589 177.941C0 163.882 0 141.255 0 96Z" fill="#6495ED"/>
</svg>

Before

Width:  |  Height:  |  Size: 405 B

View File

@@ -1,3 +0,0 @@
<svg width="192" height="192" viewBox="0 0 192 192" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 62.4C0 49.0126 0 42.3188 1.32624 36.7946C5.5399 19.2435 19.2435 5.5399 36.7946 1.32624C42.3188 0 49.0126 0 62.4 0H129.6C142.987 0 149.681 0 155.205 1.32624C172.757 5.5399 186.46 19.2435 190.674 36.7946C192 42.3188 192 49.0126 192 62.4V129.6C192 142.987 192 149.681 190.674 155.205C186.46 172.757 172.757 186.46 155.205 190.674C149.681 192 142.987 192 129.6 192H62.4C49.0126 192 42.3188 192 36.7946 190.674C19.2435 186.46 5.5399 172.757 1.32624 155.205C0 149.681 0 142.987 0 129.6V62.4Z" fill="#6495ED"/>
</svg>

Before

Width:  |  Height:  |  Size: 623 B

View File

@@ -1,3 +0,0 @@
<svg width="192" height="192" viewBox="0 0 192 192" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 76.8C0 49.9175 0 36.4762 5.23169 26.2085C9.83361 17.1767 17.1767 9.83361 26.2085 5.23169C36.4762 0 49.9175 0 76.8 0H115.2C142.083 0 155.524 0 165.792 5.23169C174.823 9.83361 182.166 17.1767 186.768 26.2085C192 36.4762 192 49.9175 192 76.8V115.2C192 142.083 192 155.524 186.768 165.792C182.166 174.823 174.823 182.166 165.792 186.768C155.524 192 142.083 192 115.2 192H76.8C49.9175 192 36.4762 192 26.2085 186.768C17.1767 182.166 9.83361 174.823 5.23169 165.792C0 155.524 0 142.083 0 115.2V76.8Z" fill="#6495ED"/>
</svg>

Before

Width:  |  Height:  |  Size: 631 B

View File

@@ -1,15 +0,0 @@
<svg width="1024" height="512" viewBox="0 0 1024 512" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="1024" height="512" fill="#EEEEEE"/>
<rect x="32" y="128" width="256" height="256" fill="white"/>
<rect x="64" y="160" width="192" height="192" rx="48" stroke="#444444" stroke-width="4"/>
<rect x="320" y="64" width="384" height="384" fill="white"/>
<mask id="mask0_1_2" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="320" y="64" width="384" height="384">
<rect x="320" y="64" width="384" height="384" fill="white"/>
</mask>
<g mask="url(#mask0_1_2)">
<rect x="85" y="171" width="512" height="512" rx="128" stroke="#444444" stroke-width="8"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M340.677 167H341.323C401.39 167 446.862 167 481.984 171.722C517.284 176.468 542.726 186.05 562.338 205.662C581.95 225.274 591.532 250.716 596.278 286.016C601 321.138 601 366.61 601 426.677V427.323C601 487.39 601 532.862 596.278 567.984C591.532 603.284 581.95 628.726 562.338 648.338C542.726 667.95 517.284 677.532 481.984 682.278C446.862 687 401.39 687 341.323 687H340.677C280.61 687 235.138 687 200.016 682.278C164.716 677.532 139.274 667.95 119.662 648.338C100.05 628.726 90.4679 603.284 85.722 567.984C81 532.862 81 487.39 81 427.323V426.677C81 366.61 81 321.138 85.722 286.016C90.4679 250.716 100.05 225.274 119.662 205.662C139.274 186.05 164.716 176.468 200.016 171.722C235.138 167 280.61 167 340.677 167ZM201.082 179.651C166.67 184.277 143.197 193.441 125.319 211.319C107.441 229.197 98.2773 252.67 93.6506 287.082C89.0085 321.61 89 366.547 89 427C89 487.453 89.0085 532.39 93.6506 566.918C98.2773 601.33 107.441 624.803 125.319 642.681C143.197 660.559 166.67 669.723 201.082 674.349C235.61 678.992 280.547 679 341 679C401.453 679 446.39 678.992 480.918 674.349C515.33 669.723 538.803 660.559 556.681 642.681C574.559 624.803 583.723 601.33 588.349 566.918C592.992 532.39 593 487.453 593 427C593 366.547 592.992 321.61 588.349 287.082C583.723 252.67 574.559 229.197 556.681 211.319C538.803 193.441 515.33 184.277 480.918 179.651C446.39 175.008 401.453 175 341 175C280.547 175 235.61 175.008 201.082 179.651Z" fill="#2A90D9"/>
</g>
<rect x="731" y="128" width="256" height="256" fill="white"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M863.839 158H864.161C886.652 158 903.732 158 916.936 159.775C930.228 161.562 939.892 165.182 947.355 172.645C954.818 180.108 958.438 189.772 960.225 203.064C962 216.268 962 233.348 962 255.839V256.161C962 278.652 962 295.732 960.225 308.936C958.438 322.228 954.818 331.892 947.355 339.355C939.892 346.818 930.228 350.438 916.936 352.225C903.732 354 886.652 354 864.161 354H863.839C841.348 354 824.268 354 811.064 352.225C797.772 350.438 788.108 346.818 780.645 339.355C773.182 331.892 769.562 322.228 767.775 308.936C766 295.732 766 278.652 766 256.161V255.839C766 233.348 766 216.268 767.775 203.064C769.562 189.772 773.182 180.108 780.645 172.645C788.108 165.182 797.772 161.562 811.064 159.775C824.268 158 841.348 158 863.839 158ZM811.597 163.74C798.748 165.467 790.069 168.877 783.473 175.473C776.877 182.069 773.467 190.748 771.74 203.597C770.004 216.504 770 233.316 770 256C770 278.684 770.004 295.496 771.74 308.403C773.467 321.252 776.877 329.931 783.473 336.527C790.069 343.123 798.748 346.533 811.597 348.26C824.504 349.996 841.316 350 864 350C886.684 350 903.496 349.996 916.403 348.26C929.252 346.533 937.931 343.123 944.527 336.527C951.123 329.931 954.533 321.252 956.26 308.403C957.996 295.496 958 278.684 958 256C958 233.316 957.996 216.504 956.26 203.597C954.533 190.748 951.123 182.069 944.527 175.473C937.931 168.877 929.252 165.467 916.403 163.74C903.496 162.004 886.684 162 864 162C841.316 162 824.504 162.004 811.597 163.74Z" fill="#2A90D9"/>
</svg>

Before

Width:  |  Height:  |  Size: 3.6 KiB

View File

@@ -50,7 +50,9 @@ const dockMenu = Menu.buildFromTemplate([
])
app.whenReady().then(() => {
app.dock?.setMenu(dockMenu)
if (process.platform === 'darwin') {
app.dock.setMenu(dockMenu)
}
}).then(createWindow)
app.on('window-all-closed', () => {

File diff suppressed because it is too large Load Diff

View File

@@ -1,34 +0,0 @@
# Copyright 2024 The Electron Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# The set of path prefixes that should be checked for unsafe buffer usage (see
# -Wunsafe-buffer-usage in Clang).
#
# ***
# Paths should be written as relative to the root of the source tree with
# unix-style path separators. Directory prefixes should end with `/`, such
# as `base/`.
# ***
#
# Files in this set are known to not use pointer arithmetic/subscripting, and
# make use of constructs like base::span or containers like std::vector instead.
#
# See `docs/unsafe_buffers.md`.
# These directories are excluded because they come from outside Electron and
# we don't have control over their contents.
-base/
-chrome/
-components/
-device/
-extensions/
-google_apis/
-net/
-services/
-skia/
-third_party/
-tools/
-ui/
-url/
-v8/

View File

@@ -14,7 +14,6 @@ auto_filenames = {
"docs/api/content-tracing.md",
"docs/api/context-bridge.md",
"docs/api/cookies.md",
"docs/api/corner-smoothing-css.md",
"docs/api/crash-reporter.md",
"docs/api/debugger.md",
"docs/api/desktop-capturer.md",

View File

@@ -453,6 +453,8 @@ filenames = {
"shell/browser/net/system_network_context_manager.h",
"shell/browser/net/url_loader_network_observer.cc",
"shell/browser/net/url_loader_network_observer.h",
"shell/browser/net/url_pipe_loader.cc",
"shell/browser/net/url_pipe_loader.h",
"shell/browser/net/web_request_api_interface.h",
"shell/browser/network_hints_handler_impl.cc",
"shell/browser/network_hints_handler_impl.h",
@@ -592,6 +594,8 @@ filenames = {
"shell/common/gin_converters/callback_converter.h",
"shell/common/gin_converters/content_converter.cc",
"shell/common/gin_converters/content_converter.h",
"shell/common/gin_converters/display_surface_converter.cc",
"shell/common/gin_converters/display_surface_converter.h",
"shell/common/gin_converters/file_dialog_converter.cc",
"shell/common/gin_converters/file_dialog_converter.h",
"shell/common/gin_converters/file_path_converter.h",
@@ -718,8 +722,6 @@ filenames = {
"shell/renderer/electron_renderer_client.h",
"shell/renderer/electron_sandboxed_renderer_client.cc",
"shell/renderer/electron_sandboxed_renderer_client.h",
"shell/renderer/electron_smooth_round_rect.cc",
"shell/renderer/electron_smooth_round_rect.h",
"shell/renderer/preload_realm_context.cc",
"shell/renderer/preload_realm_context.h",
"shell/renderer/preload_utils.cc",

View File

@@ -16,13 +16,13 @@ function isValid (options: Electron.SourcesOptions) {
export { isDisplayMediaSystemPickerAvailable };
export async function getSources (args: Electron.SourcesOptions) {
export async function getSources (args: Electron.SourcesOptions, useSystemPicker: boolean = false) {
if (!isValid(args)) throw new Error('Invalid options');
const resizableValues = new Map();
if (process.platform === 'darwin') {
// Fix for bug in ScreenCaptureKit that modifies a window's styleMask the first time
// it captures a non-resizable window. We record each non-resizable window's styleMask,
// it captures a non-resizable window. We record each non-resizable window's styleMask
// and we restore modified styleMasks later, after the screen capture.
for (const win of BrowserWindow.getAllWindows()) {
resizableValues.set([win.id], win.resizable);
@@ -32,14 +32,15 @@ export async function getSources (args: Electron.SourcesOptions) {
const captureWindow = args.types.includes('window');
const captureScreen = args.types.includes('screen');
const { thumbnailSize = { width: 150, height: 150 } } = args;
const { thumbnailSize = { width: 0, height: 0 } } = args;
const { fetchWindowIcons = false } = args;
const options = {
captureWindow,
captureScreen,
thumbnailSize,
fetchWindowIcons
fetchWindowIcons,
useSystemPicker
};
for (const running of currentlyRunning) {
@@ -81,7 +82,7 @@ export async function getSources (args: Electron.SourcesOptions) {
resolve(sources);
};
capturer.startHandling(captureWindow, captureScreen, thumbnailSize, fetchWindowIcons);
capturer.startHandling(captureWindow, captureScreen, thumbnailSize, fetchWindowIcons, useSystemPicker);
});
currentlyRunning.push({

View File

@@ -93,7 +93,7 @@ Menu.prototype.popup = function (options = {}) {
}
}
this.popupAt(window as unknown as BaseWindow, options.frame, x, y, positioningItem, sourceType, callback);
this.popupAt(window as unknown as BaseWindow, x, y, positioningItem, sourceType, callback);
return { browserWindow: window, x, y, position: positioningItem };
};

View File

@@ -2,25 +2,61 @@ import { fetchWithSession } from '@electron/internal/browser/api/net-fetch';
import { addIpcDispatchListeners } from '@electron/internal/browser/ipc-dispatch';
import * as deprecate from '@electron/internal/common/deprecate';
import { net } from 'electron/main';
import { desktopCapturer, net } from 'electron/main';
const { fromPartition, fromPath, Session } = process._linkedBinding('electron_browser_session');
const { isDisplayMediaSystemPickerAvailable } = process._linkedBinding('electron_browser_desktop_capturer');
// Fake video window that activates the native system picker
// This is used to get around the need for a screen/window
// id in Chrome's desktopCapturer.
let fakeVideoWindowId = -1;
// See content/public/browser/desktop_media_id.h
const kMacOsNativePickerId = -4;
const systemPickerVideoSource = Object.create(null);
Object.defineProperty(systemPickerVideoSource, 'id', {
get () {
return `window:${kMacOsNativePickerId}:${fakeVideoWindowId--}`;
async function getNativePickerSource (preferredDisplaySurface: string) {
console.log('SESSION.TS getNativePickerSource');
// Fake video window that activates the native system picker
// This is used to get around the need for a screen/window
// id in Chrome's desktopCapturer.
// let fakeVideoWindowId = -1;
// const kMacOsNativePickerId = -4;
if (process.platform !== 'darwin') {
throw new Error('Native system picker option is currently only supported on MacOS');
}
});
systemPickerVideoSource.name = '';
Object.freeze(systemPickerVideoSource);
if (!isDisplayMediaSystemPickerAvailable) {
throw new Error(`Native system picker unavailable.
Note: This is an experimental API; please check the API documentation for updated restrictions`);
}
let types: Electron.SourcesOptions['types'];
switch (preferredDisplaySurface) {
case 'no_preference':
types = ['screen', 'window'];
break;
case 'monitor':
types = ['screen'];
break;
case 'window':
types = ['window'];
break;
default:
types = ['screen', 'window'];
}
// Pass in the needed options for a more native experience
// screen & windows by default, no thumbnails, since the native picker doesn't return them
const options: Electron.SourcesOptions = {
types,
thumbnailSize: { width: 0, height: 0 },
fetchWindowIcons: false
};
const mediaStreams = await desktopCapturer.getSources(options);
if (mediaStreams.length === 0) {
throw new Error('No media streams found');
}
// mediaStreams[0].id = `none:${kMacOsNativePickerId}:${fakeVideoWindowId--}`;
console.log('SESSION.TS mediaStreams', mediaStreams);
return mediaStreams[0];
}
Session.prototype._init = function () {
addIpcDispatchListeners(this);
@@ -48,12 +84,12 @@ Session.prototype.fetch = function (input: RequestInfo, init?: RequestInit) {
Session.prototype.setDisplayMediaRequestHandler = function (handler, opts) {
if (!handler) return this._setDisplayMediaRequestHandler(handler, opts);
this._setDisplayMediaRequestHandler(async (req, callback) => {
this._setDisplayMediaRequestHandler(async (request, callback) => {
if (opts && opts.useSystemPicker && isDisplayMediaSystemPickerAvailable()) {
return callback({ video: systemPickerVideoSource });
return callback({ video: await getNativePickerSource(request.preferredDisplaySurface) });
}
return handler(req, callback);
// return handler(request, callback);
}, opts);
};

View File

@@ -667,10 +667,10 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
return p(pathArgument, options);
};
function readFileFromArchiveSync (
pathInfo: { asarPath: string; filePath: string },
options: any
): ReturnType<typeof readFileSync> {
const { readFileSync } = fs;
fs.readFileSync = function (pathArgument: string, options: any) {
const pathInfo = splitPath(pathArgument);
if (!pathInfo.isAsar) return readFileSync.apply(this, arguments);
const { asarPath, filePath } = pathInfo;
const archive = getOrCreateArchive(asarPath);
@@ -704,14 +704,6 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
fs.readSync(fd, buffer, 0, info.size, info.offset);
validateBufferIntegrity(buffer, info.integrity);
return (encoding) ? buffer.toString(encoding) : buffer;
}
const { readFileSync } = fs;
fs.readFileSync = function (pathArgument: string, options: any) {
const pathInfo = splitPath(pathArgument);
if (!pathInfo.isAsar) return readFileSync.apply(this, arguments);
return readFileFromArchiveSync(pathInfo, options);
};
type ReaddirOptions = { encoding: BufferEncoding | null; withFileTypes?: false, recursive?: false } | undefined | null;
@@ -988,19 +980,25 @@ export const wrapFsWithAsar = (fs: Record<string, any>) => {
};
const modBinding = internalBinding('modules');
modBinding.overrideReadFileSync((jsonPath: string): Buffer | false | undefined => {
const { readPackageJSON } = modBinding;
internalBinding('modules').readPackageJSON = (
jsonPath: string,
isESM: boolean,
base: undefined | string,
specifier: undefined | string
) => {
const pathInfo = splitPath(jsonPath);
if (!pathInfo.isAsar) return readPackageJSON(jsonPath, isESM, base, specifier);
const { asarPath, filePath } = pathInfo;
// Fallback to Node.js internal implementation
if (!pathInfo.isAsar) return undefined;
const archive = getOrCreateArchive(asarPath);
if (!archive) return undefined;
try {
return readFileFromArchiveSync(pathInfo, undefined);
} catch {
// Not found
return false;
}
});
const realPath = archive.copyFileOut(filePath);
if (!realPath) return undefined;
return readPackageJSON(realPath, isESM, base, specifier);
};
const { internalModuleStat } = binding;
internalBinding('fs').internalModuleStat = (receiver: unknown, pathArgument: string) => {

View File

@@ -10,7 +10,7 @@
"@electron/fiddle-core": "^1.3.4",
"@electron/github-app-auth": "^2.2.1",
"@electron/lint-roller": "^2.4.0",
"@electron/typescript-definitions": "^9.1.2",
"@electron/typescript-definitions": "^9.0.0",
"@octokit/rest": "^20.0.2",
"@primer/octicons": "^10.0.0",
"@types/minimist": "^1.2.5",

View File

@@ -128,20 +128,19 @@ chore_remove_reference_to_chrome_browser_themes.patch
feat_enable_customizing_symbol_color_in_framecaptionbutton.patch
build_allow_electron_mojom_interfaces_to_depend_on_blink.patch
osr_shared_texture_remove_keyed_mutex_on_win_dxgi.patch
feat_allow_usage_of_sccontentsharingpicker_on_supported_platforms.patch
chore_partial_revert_of.patch
fix_software_compositing_infinite_loop.patch
fix_add_method_which_disables_headless_mode_on_native_widget.patch
refactor_unfilter_unresponsive_events.patch
build_disable_thin_lto_mac.patch
feat_corner_smoothing_css_rule_and_blink_painting.patch
build_add_public_config_simdutf_config.patch
fix_multiple_scopedpumpmessagesinprivatemodes_instances.patch
revert_code_health_clean_up_stale_macwebcontentsocclusion.patch
ignore_parse_errors_for_resolveshortcutproperties.patch
ignore_parse_errors_for_pkey_appusermodel_toastactivatorclsid.patch
feat_add_signals_when_embedder_cleanup_callbacks_run_for.patch
feat_separate_content_settings_callback_for_sync_and_async_clipboard.patch
fix_win32_synchronous_spellcheck.patch
chore_remove_conflicting_allow_unsafe_libc_calls.patch
fix_enable_wrap_iter_in_string_view_and_array.patch
fix_linter_error.patch
fix_take_snapped_status_into_account_when_showing_a_window.patch
feat_make_macos_sccontentsharingpicker_work_in_electron_and_return_screen_window_or_both.patch
fix_debug_desktop_capturer_picture.patch

View File

@@ -1,49 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Charles Kerr <charles@charleskerr.com>
Date: Sat, 22 Feb 2025 13:15:39 -0600
Subject: chore: remove conflicting allow_unsafe_libc_calls
We want builds to fail if a buffer warning comes from Electron code but
not from code that we don't maintain (e.g. upstream Chromium code), so
//electron/electron_unsafe_buffer_paths.txt turns off Chromium warnings.
There are some upstream files that generate warnings *and* also have
pragmas that override //electron/electron_unsafe_buffer_paths.txt,
forcing them to be tested. This breaks our build.
Files can be removed from this patch when upstream either removes the
pragma or fixes the other warnings. This patch can be removed when no
files are left.
diff --git a/net/cookies/parsed_cookie.cc b/net/cookies/parsed_cookie.cc
index 7d5d0106a3675b3fa21b0e00a755f5c0ed11c87b..d26c645d70b54b31815c8140954ee6d0a34fa8af 100644
--- a/net/cookies/parsed_cookie.cc
+++ b/net/cookies/parsed_cookie.cc
@@ -2,11 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifdef UNSAFE_BUFFERS_BUILD
-// TODO(crbug.com/390223051): Remove C-library calls to fix the errors.
-#pragma allow_unsafe_libc_calls
-#endif
-
// Portions of this code based on Mozilla:
// (netwerk/cookie/src/nsCookieService.cpp)
/* ***** BEGIN LICENSE BLOCK *****
diff --git a/net/http/http_response_headers.cc b/net/http/http_response_headers.cc
index 2235a264ff87ef400734a7308c2735886c63c92c..2310a951c5b4d34447a39c7585bdf1027a9953cc 100644
--- a/net/http/http_response_headers.cc
+++ b/net/http/http_response_headers.cc
@@ -2,11 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifdef UNSAFE_BUFFERS_BUILD
-// TODO(crbug.com/390223051): Remove C-library calls to fix the errors.
-#pragma allow_unsafe_libc_calls
-#endif
-
// The rules for header parsing were borrowed from Firefox:
// http://lxr.mozilla.org/seamonkey/source/netwerk/protocol/http/src/nsHttpResponseHead.cpp
// The rules for parsing content-types were also borrowed from Firefox:

View File

@@ -179,7 +179,7 @@ index 08cbe32a258bf478f1da0a07064d3e9ef14c44a5..b9f2a43cb90fac4b031a4b4da38d6435
if (!WriteToSocket(socket.fd(), to_send.data(), to_send.length())) {
// Try to kill the other process, because it might have been dead.
diff --git a/chrome/browser/process_singleton_win.cc b/chrome/browser/process_singleton_win.cc
index d91f58ebe3a024bc41ed72121c49172f68e0d862..255160d6bd6b2ea1cd640fde8f4b4ce598148418 100644
index d91f58ebe3a024bc41ed72121c49172f68e0d862..7b85ba5ed8d0c2a152899ad65f275e6680a93dba 100644
--- a/chrome/browser/process_singleton_win.cc
+++ b/chrome/browser/process_singleton_win.cc
@@ -81,10 +81,12 @@ BOOL CALLBACK BrowserWindowEnumeration(HWND window, LPARAM param) {
@@ -197,7 +197,7 @@ index d91f58ebe3a024bc41ed72121c49172f68e0d862..255160d6bd6b2ea1cd640fde8f4b4ce5
static const int min_message_size = 7;
if (cds->cbData < min_message_size * sizeof(wchar_t) ||
cds->cbData % sizeof(wchar_t) != 0) {
@@ -134,6 +136,37 @@ bool ParseCommandLine(const COPYDATASTRUCT* cds,
@@ -134,6 +136,23 @@ bool ParseCommandLine(const COPYDATASTRUCT* cds,
const std::wstring cmd_line =
msg.substr(second_null + 1, third_null - second_null);
*parsed_command_line = base::CommandLine::FromString(cmd_line);
@@ -210,32 +210,18 @@ index d91f58ebe3a024bc41ed72121c49172f68e0d862..255160d6bd6b2ea1cd640fde8f4b4ce5
+ return true;
+ }
+
+ // Get length of the additional data.
+ const std::wstring additional_data_length_string =
+ msg.substr(third_null + 1, fourth_null - third_null);
+ size_t additional_data_length;
+ base::StringToSizeT(additional_data_length_string, &additional_data_length);
+
+ const std::wstring::size_type fifth_null =
+ msg.find_first_of(L'\0', fourth_null + 1);
+ if (fifth_null == std::wstring::npos ||
+ fifth_null == msg.length()) {
+ LOG(WARNING) << "Invalid format for start command, we need a string in 6 "
+ "parts separated by NULLs";
+ }
+
+ // Get the actual additional data.
+ const std::wstring additional_data =
+ msg.substr(fourth_null + 1, fifth_null - fourth_null);
+ const uint8_t* additional_data_bytes =
+ reinterpret_cast<const uint8_t*>(additional_data.c_str());
+ *parsed_additional_data = std::vector<uint8_t>(additional_data_bytes,
+ additional_data_bytes + additional_data_length);
+ msg.substr(third_null + 1, fourth_null - third_null);
+ base::span<const uint8_t> additional_data_bytes =
+ base::as_byte_span(additional_data);
+ *parsed_additional_data = std::vector<uint8_t>(
+ additional_data_bytes.begin(), additional_data_bytes.end());
+
return true;
}
return false;
@@ -155,13 +188,14 @@ bool ProcessLaunchNotification(
@@ -155,13 +174,14 @@ bool ProcessLaunchNotification(
base::CommandLine parsed_command_line(base::CommandLine::NO_PROGRAM);
base::FilePath current_directory;
@@ -253,7 +239,7 @@ index d91f58ebe3a024bc41ed72121c49172f68e0d862..255160d6bd6b2ea1cd640fde8f4b4ce5
return true;
}
@@ -265,9 +299,11 @@ bool ProcessSingleton::EscapeVirtualization(
@@ -265,9 +285,11 @@ bool ProcessSingleton::EscapeVirtualization(
ProcessSingleton::ProcessSingleton(
const std::string& program_name,
const base::FilePath& user_data_dir,
@@ -265,7 +251,7 @@ index d91f58ebe3a024bc41ed72121c49172f68e0d862..255160d6bd6b2ea1cd640fde8f4b4ce5
program_name_(program_name),
is_app_sandboxed_(is_app_sandboxed),
is_virtualized_(false),
@@ -294,7 +330,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() {
@@ -294,7 +316,7 @@ ProcessSingleton::NotifyResult ProcessSingleton::NotifyOtherProcess() {
return PROCESS_NONE;
}
@@ -275,7 +261,7 @@ index d91f58ebe3a024bc41ed72121c49172f68e0d862..255160d6bd6b2ea1cd640fde8f4b4ce5
return PROCESS_NOTIFIED;
case NotifyChromeResult::NOTIFY_FAILED:
diff --git a/chrome/browser/win/chrome_process_finder.cc b/chrome/browser/win/chrome_process_finder.cc
index 019ac7e93e009a713ce56ee8bcacf467b4fe769d..9417403bb9cacd0572b37493ab2d98130313db4d 100644
index 019ac7e93e009a713ce56ee8bcacf467b4fe769d..283693966c041340983aa78a95f8a274db601fb4 100644
--- a/chrome/browser/win/chrome_process_finder.cc
+++ b/chrome/browser/win/chrome_process_finder.cc
@@ -39,7 +39,9 @@ HWND FindRunningChromeWindow(const base::FilePath& user_data_dir) {
@@ -289,13 +275,13 @@ index 019ac7e93e009a713ce56ee8bcacf467b4fe769d..9417403bb9cacd0572b37493ab2d9813
TRACE_EVENT0("startup", "AttemptToNotifyRunningChrome");
DCHECK(remote_window);
@@ -68,12 +70,29 @@ NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window) {
@@ -68,12 +70,24 @@ NotifyChromeResult AttemptToNotifyRunningChrome(HWND remote_window) {
new_command_line.AppendSwitchNative(switches::kSourceShortcut, si.lpTitle);
// Send the command line to the remote chrome window.
- // Format is "START\0<<<current directory>>>\0<<<commandline>>>".
+ // Format is
+ // "START\0<current-directory>\0<command-line>\0<additional-data-length>\0<additional-data>".
+ // "START\0<current-directory>\0<command-line>\0<additional-data>".
std::wstring to_send = base::StrCat(
{std::wstring_view{L"START\0", 6}, cur_dir.value(),
std::wstring_view{L"\0", 1}, new_command_line.GetCommandLineString(),
@@ -303,11 +289,6 @@ index 019ac7e93e009a713ce56ee8bcacf467b4fe769d..9417403bb9cacd0572b37493ab2d9813
+ size_t additional_data_size = additional_data.size_bytes();
+ if (additional_data_size) {
+ // Send over the size, because the reinterpret cast to wchar_t could
+ // add padding.
+ to_send.append(base::UTF8ToWide(base::NumberToString(additional_data_size)));
+ to_send.append(L"\0", 1); // Null separator.
+
+ size_t padded_size = additional_data_size / sizeof(wchar_t);
+ if (additional_data_size % sizeof(wchar_t) != 0) {
+ padded_size++;

View File

@@ -1,383 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Samuel Attard <marshallofsound@electronjs.org>
Date: Thu, 8 Aug 2024 08:39:10 -0700
Subject: feat: allow usage of SCContentSharingPicker on supported platforms
This is implemented as a magic "window id" that instead of pulling an SCStream manually
instead farms out to the screen picker.
diff --git a/content/browser/media/capture/desktop_capture_device_mac.cc b/content/browser/media/capture/desktop_capture_device_mac.cc
index afb657b7c9e1ede1273532b16428d37cc5d75c59..16707cf516cd34682c84ea2ccebddaa0f84e01f8 100644
--- a/content/browser/media/capture/desktop_capture_device_mac.cc
+++ b/content/browser/media/capture/desktop_capture_device_mac.cc
@@ -29,7 +29,7 @@ class DesktopCaptureDeviceMac : public IOSurfaceCaptureDeviceBase {
~DesktopCaptureDeviceMac() override = default;
// IOSurfaceCaptureDeviceBase:
- void OnStart() override {
+ void OnStart(std::optional<bool> use_native_picker) override {
requested_format_ = capture_params().requested_format;
requested_format_.pixel_format = media::PIXEL_FORMAT_NV12;
DCHECK_GT(requested_format_.frame_size.GetArea(), 0);
diff --git a/content/browser/media/capture/io_surface_capture_device_base_mac.cc b/content/browser/media/capture/io_surface_capture_device_base_mac.cc
index 4ec4c895423151d2c907d97de1461cbde8c8a639..0e59797833b81c07299b8c342f591e192183c6f1 100644
--- a/content/browser/media/capture/io_surface_capture_device_base_mac.cc
+++ b/content/browser/media/capture/io_surface_capture_device_base_mac.cc
@@ -20,7 +20,7 @@ void IOSurfaceCaptureDeviceBase::AllocateAndStart(
client_ = std::move(client);
capture_params_ = params;
- OnStart();
+ OnStart(params.use_native_picker);
}
void IOSurfaceCaptureDeviceBase::StopAndDeAllocate() {
diff --git a/content/browser/media/capture/io_surface_capture_device_base_mac.h b/content/browser/media/capture/io_surface_capture_device_base_mac.h
index e2771b7b281274cdcb601a5bc78a948ad592087b..48d116823a28213e50775f378e6ce04ce3af5072 100644
--- a/content/browser/media/capture/io_surface_capture_device_base_mac.h
+++ b/content/browser/media/capture/io_surface_capture_device_base_mac.h
@@ -25,7 +25,7 @@ class CONTENT_EXPORT IOSurfaceCaptureDeviceBase
~IOSurfaceCaptureDeviceBase() override;
// OnStart is called by AllocateAndStart.
- virtual void OnStart() = 0;
+ virtual void OnStart(std::optional<bool> use_native_picker) = 0;
// OnStop is called by StopAndDeAllocate.
virtual void OnStop() = 0;
diff --git a/content/browser/media/capture/screen_capture_kit_device_mac.mm b/content/browser/media/capture/screen_capture_kit_device_mac.mm
index 7e17594c30ac3cf8cb484b53563b03fc75bd2e0b..0e4a68f2fd8179640f877cb258b4049610fd49da 100644
--- a/content/browser/media/capture/screen_capture_kit_device_mac.mm
+++ b/content/browser/media/capture/screen_capture_kit_device_mac.mm
@@ -27,6 +27,61 @@
std::optional<float>,
bool)>;
using ErrorCallback = base::RepeatingClosure;
+using CancelCallback = base::RepeatingClosure;
+
+API_AVAILABLE(macos(15.0))
+@interface ScreenCaptureKitPickerHelper
+ : NSObject <SCContentSharingPickerObserver>
+
+- (void)contentSharingPicker:(SCContentSharingPicker *)picker
+ didCancelForStream:(SCStream *)stream;
+
+- (void)contentSharingPicker:(SCContentSharingPicker *)picker
+ didUpdateWithFilter:(SCContentFilter *)filter
+ forStream:(SCStream *)stream;
+
+- (void)contentSharingPickerStartDidFailWithError:(NSError *)error;
+
+@end
+
+@implementation ScreenCaptureKitPickerHelper {
+ base::RepeatingCallback<void(SCContentFilter *)> _pickerCallback;
+ ErrorCallback _errorCallback;
+ CancelCallback _cancelCallback;
+}
+
+- (void)contentSharingPicker:(SCContentSharingPicker *)picker
+ didCancelForStream:(SCStream *)stream {
+ // TODO: This doesn't appear to be called on Apple's side;
+ // implement this logic
+ _cancelCallback.Run();
+}
+
+- (void)contentSharingPicker:(SCContentSharingPicker *)picker
+ didUpdateWithFilter:(SCContentFilter *)filter
+ forStream:(SCStream *)stream {
+ if (stream == nil) {
+ _pickerCallback.Run(filter);
+ [picker removeObserver:self];
+ }
+}
+
+- (void)contentSharingPickerStartDidFailWithError:(NSError *)error {
+ _errorCallback.Run();
+}
+
+- (instancetype)initWithStreamPickCallback:(base::RepeatingCallback<void(SCContentFilter *)>)pickerCallback
+ cancelCallback:(CancelCallback)cancelCallback
+ errorCallback:(ErrorCallback)errorCallback {
+ if (self = [super init]) {
+ _pickerCallback = pickerCallback;
+ _cancelCallback = cancelCallback;
+ _errorCallback = errorCallback;
+ }
+ return self;
+}
+
+@end
namespace {
API_AVAILABLE(macos(12.3))
@@ -123,18 +178,22 @@ @interface ScreenCaptureKitDeviceHelper
: NSObject <SCStreamDelegate, SCStreamOutput>
- (instancetype)initWithSampleCallback:(SampleCallback)sampleCallback
+ cancelCallback:(CancelCallback)cancelCallback
errorCallback:(ErrorCallback)errorCallback;
@end
@implementation ScreenCaptureKitDeviceHelper {
SampleCallback _sampleCallback;
+ CancelCallback _cancelCallback;
ErrorCallback _errorCallback;
}
- (instancetype)initWithSampleCallback:(SampleCallback)sampleCallback
+ cancelCallback:(CancelCallback)cancelCallback
errorCallback:(ErrorCallback)errorCallback {
if (self = [super init]) {
_sampleCallback = sampleCallback;
+ _cancelCallback = cancelCallback;
_errorCallback = errorCallback;
}
return self;
@@ -211,29 +270,53 @@ + (SCStreamConfiguration*)streamConfigurationWithFrameSize:(gfx::Size)frameSize
class API_AVAILABLE(macos(12.3)) ScreenCaptureKitDeviceMac
: public IOSurfaceCaptureDeviceBase,
- public ScreenCaptureKitResetStreamInterface {
+ public ScreenCaptureKitResetStreamInterface
+ {
public:
explicit ScreenCaptureKitDeviceMac(const DesktopMediaID& source,
- SCContentFilter* filter)
+ [[maybe_unused]] SCContentFilter* filter)
: source_(source),
- filter_(filter),
device_task_runner_(base::SingleThreadTaskRunner::GetCurrentDefault()) {
SampleCallback sample_callback = base::BindPostTask(
device_task_runner_,
base::BindRepeating(&ScreenCaptureKitDeviceMac::OnStreamSample,
weak_factory_.GetWeakPtr()));
+ CancelCallback cancel_callback = base::BindPostTask(
+ device_task_runner_,
+ base::BindRepeating(&ScreenCaptureKitDeviceMac::OnStreamError,
+ weak_factory_.GetWeakPtr()));
ErrorCallback error_callback = base::BindPostTask(
device_task_runner_,
base::BindRepeating(&ScreenCaptureKitDeviceMac::OnStreamError,
weak_factory_.GetWeakPtr()));
helper_ = [[ScreenCaptureKitDeviceHelper alloc]
initWithSampleCallback:sample_callback
+ cancelCallback:cancel_callback
errorCallback:error_callback];
+
+ if (@available(macOS 15.0, *)) {
+ auto picker_callback = base::BindPostTask(
+ device_task_runner_,
+ base::BindRepeating(&ScreenCaptureKitDeviceMac::OnContentFilterReady, weak_factory_.GetWeakPtr())
+ );
+ picker_helper_ = [[ScreenCaptureKitPickerHelper alloc] initWithStreamPickCallback:picker_callback cancelCallback:cancel_callback errorCallback:error_callback];
+ [[SCContentSharingPicker sharedPicker] addObserver:picker_helper_];
+ }
}
ScreenCaptureKitDeviceMac(const ScreenCaptureKitDeviceMac&) = delete;
ScreenCaptureKitDeviceMac& operator=(const ScreenCaptureKitDeviceMac&) =
delete;
- ~ScreenCaptureKitDeviceMac() override = default;
+ ~ScreenCaptureKitDeviceMac() override {
+ if (@available(macOS 15.0, *)) {
+ auto* picker = [SCContentSharingPicker sharedPicker];
+ ScreenCaptureKitDeviceMac::active_streams_--;
+ picker.maximumStreamCount = @(ScreenCaptureKitDeviceMac::active_streams_);
+ if (ScreenCaptureKitDeviceMac::active_streams_ == 0 && picker.active) {
+ picker.active = false;
+ [[SCContentSharingPicker sharedPicker] removeObserver:picker_helper_];
+ }
+ }
+ }
void OnShareableContentCreated(SCShareableContent* content) {
DCHECK(device_task_runner_->RunsTasksInCurrentSequence());
@@ -301,7 +384,7 @@ void CreateStream(SCContentFilter* filter) {
return;
}
- if (@available(macOS 14.0, *)) {
+ if (@available(macOS 15.0, *)) {
// Update the content size. This step is neccessary when used together
// with SCContentSharingPicker. If the Chrome picker is used, it will
// change to retina resolution if applicable.
@@ -310,6 +393,9 @@ void CreateStream(SCContentFilter* filter) {
filter.contentRect.size.height * filter.pointPixelScale);
}
+ OnContentFilterReady(filter);
+ }
+ void OnContentFilterReady(SCContentFilter* filter) {
gfx::RectF dest_rect_in_frame;
actual_capture_format_ = capture_params().requested_format;
actual_capture_format_.pixel_format = media::PIXEL_FORMAT_NV12;
@@ -323,6 +409,7 @@ void CreateStream(SCContentFilter* filter) {
stream_ = [[SCStream alloc] initWithFilter:filter
configuration:config
delegate:helper_];
+
{
NSError* error = nil;
bool add_stream_output_result =
@@ -480,7 +567,7 @@ void OnStreamError() {
if (fullscreen_module_) {
fullscreen_module_->Reset();
}
- OnStart();
+ OnStart(std::nullopt);
} else {
client()->OnError(media::VideoCaptureError::kScreenCaptureKitStreamError,
FROM_HERE, "Stream delegate called didStopWithError");
@@ -503,23 +590,41 @@ void OnUpdateConfigurationError() {
}
// IOSurfaceCaptureDeviceBase:
- void OnStart() override {
+ void OnStart(std::optional<bool> use_native_picker) override {
DCHECK(device_task_runner_->RunsTasksInCurrentSequence());
- if (filter_) {
- // SCContentSharingPicker is used where filter_ is set on creation.
- CreateStream(filter_);
- } else {
- // Chrome picker is used.
- auto content_callback = base::BindPostTask(
- device_task_runner_,
- base::BindRepeating(
- &ScreenCaptureKitDeviceMac::OnShareableContentCreated,
- weak_factory_.GetWeakPtr()));
- auto handler = ^(SCShareableContent* content, NSError* error) {
- content_callback.Run(content);
- };
- [SCShareableContent getShareableContentWithCompletionHandler:handler];
+
+ if (@available(macOS 15.0, *)) {
+ constexpr bool DefaultUseNativePicker = true;
+ if (use_native_picker.value_or(DefaultUseNativePicker) &&
+ source_.id == DesktopMediaID::kMacOsNativePickerId &&
+ source_.window_id < 0) {
+ auto* picker = [SCContentSharingPicker sharedPicker];
+ ScreenCaptureKitDeviceMac::active_streams_++;
+ picker.maximumStreamCount = @(ScreenCaptureKitDeviceMac::active_streams_);
+ if (!picker.active) {
+ picker.active = true;
+ }
+ NSMutableArray<NSNumber*>* exclude_ns_windows = [NSMutableArray array];
+ [[[[NSApplication sharedApplication] windows] filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(NSWindow* win, NSDictionary *bindings) {
+ return [win sharingType] == NSWindowSharingNone;
+ }]] enumerateObjectsUsingBlock:^(NSWindow* win, NSUInteger idx, BOOL *stop) {
+ [exclude_ns_windows addObject:@([win windowNumber])];
+ }];
+ picker.defaultConfiguration.excludedWindowIDs = exclude_ns_windows;
+ [picker present];
+ return;
+ }
}
+
+ auto content_callback = base::BindPostTask(
+ device_task_runner_,
+ base::BindRepeating(
+ &ScreenCaptureKitDeviceMac::OnShareableContentCreated,
+ weak_factory_.GetWeakPtr()));
+ auto handler = ^(SCShareableContent* content, NSError* error) {
+ content_callback.Run(content);
+ };
+ [SCShareableContent getShareableContentWithCompletionHandler:handler];
}
void OnStop() override {
DCHECK(device_task_runner_->RunsTasksInCurrentSequence());
@@ -577,8 +682,9 @@ void ResetStreamTo(SCWindow* window) override {
}
private:
+ static int active_streams_;
+
const DesktopMediaID source_;
- SCContentFilter* const filter_;
const scoped_refptr<base::SingleThreadTaskRunner> device_task_runner_;
// The actual format of the video frames that are sent to `client`.
@@ -594,6 +700,10 @@ void ResetStreamTo(SCWindow* window) override {
// Helper class that acts as output and delegate for `stream_`.
ScreenCaptureKitDeviceHelper* __strong helper_;
+ // Helper class that acts as an observer for SCContentSharingPicker
+ API_AVAILABLE(macos(15.0))
+ ScreenCaptureKitPickerHelper* __strong picker_helper_;
+
// This is used to detect when a captured presentation enters fullscreen mode.
// If this happens, the module will call the ResetStreamTo function.
std::unique_ptr<ScreenCaptureKitFullscreenModule> fullscreen_module_;
@@ -606,6 +716,8 @@ void ResetStreamTo(SCWindow* window) override {
base::WeakPtrFactory<ScreenCaptureKitDeviceMac> weak_factory_{this};
};
+int ScreenCaptureKitDeviceMac::active_streams_ = 0;
+
} // namespace
// Although ScreenCaptureKit is available in 12.3 there were some bugs that
diff --git a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
index 0ab684dc8e792359abb90b91917eddae42e6123d..f0f08a834f06c7669da6030640434308a5cbd056 100644
--- a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
+++ b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
@@ -316,8 +316,16 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
break;
}
+#if defined(USE_AURA)
+ bool allow_window_id = false;
+#elif BUILDFLAG(IS_MAC)
+ bool allow_window_id =
+ desktop_id.id == DesktopMediaID::kMacOsNativePickerId;
+#endif
+
#if defined(USE_AURA) || BUILDFLAG(IS_MAC)
- if (desktop_id.window_id != DesktopMediaID::kNullId) {
+ if (!allow_window_id &&
+ desktop_id.window_id != DesktopMediaID::kNullId) {
// For the other capturers, when a bug reports the type of capture it's
// easy enough to determine which capturer was used, but it's a little
// fuzzier with window capture.
@@ -333,13 +341,15 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
}
#endif // defined(USE_AURA) || BUILDFLAG(IS_MAC)
+ media::VideoCaptureParams updated_params = params;
+ updated_params.use_native_picker = stream_type != blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE;
// All cases other than tab capture or Aura desktop/window capture.
TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("video_and_image_capture"),
"UsingDesktopCapturer", TRACE_EVENT_SCOPE_THREAD);
start_capture_closure = base::BindOnce(
&InProcessVideoCaptureDeviceLauncher::
DoStartDesktopCaptureOnDeviceThread,
- base::Unretained(this), desktop_id, params,
+ base::Unretained(this), desktop_id, updated_params,
CreateDeviceClient(media::VideoCaptureBufferType::kSharedMemory,
kMaxNumberOfBuffers, std::move(receiver),
std::move(receiver_on_io_thread)),
diff --git a/content/public/browser/desktop_media_id.h b/content/public/browser/desktop_media_id.h
index 415156d403a59bf426cf4561a9d58ecdb27524b4..78aa7b2359c684d5305bf6352751dfbb7ca00d29 100644
--- a/content/public/browser/desktop_media_id.h
+++ b/content/public/browser/desktop_media_id.h
@@ -27,6 +27,8 @@ struct CONTENT_EXPORT DesktopMediaID {
static constexpr Id kNullId = 0;
// Represents a fake id to create a dummy capturer for autotests.
static constexpr Id kFakeId = -3;
+ // Represents an id to use native macOS picker for screenshare
+ static constexpr Id kMacOsNativePickerId = -4;
#if defined(USE_AURA) || BUILDFLAG(IS_MAC)
// Assigns integer identifier to the |window| and returns its DesktopMediaID.
diff --git a/media/capture/video_capture_types.h b/media/capture/video_capture_types.h
index 53e8077c9c0b635df0abdeca43fa9a6373c68252..2805e36cc42190d8197d83f5df235094570e3d5d 100644
--- a/media/capture/video_capture_types.h
+++ b/media/capture/video_capture_types.h
@@ -355,6 +355,8 @@ struct CAPTURE_EXPORT VideoCaptureParams {
// Flag indicating whether HiDPI mode should be enabled for tab capture
// sessions.
bool is_high_dpi_enabled = true;
+
+ std::optional<bool> use_native_picker;
};
CAPTURE_EXPORT std::ostream& operator<<(

View File

@@ -1,485 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Calvin Watford <watfordcalvin@gmail.com>
Date: Mon, 9 Dec 2024 16:58:15 -0700
Subject: feat: Corner Smoothing CSS rule and Blink painting
This patch implements the `-electron-corner-smoothing` CSS rule by
making three primary changes to Blink:
1. Adds the `-electron-corner-smoothing` CSS rule:
* Metadata in `blink/renderer/core/css/css_properties.json5`
* Parsing in `blink/renderer/core/css/properties/longhands/longhands_custom.cc`
* Other required definitions for all CSS rules (`css_property_id.mojom`, `css_property_equality.cc`)
2. Modifies how Blink paints rounded rectangles:
* Augments `blink::ContouredRect` to add smoothness.
* Modifies graphics to handle smooth `ContouredRect`s, delegating to
`//electron/shell/renderer/electron_smooth_round_rect`.
3. Adds a renderer preference / web setting:
* Controls whether the CSS rule is available.
* Mostly simple "plumbing" for the setting through blink.
diff --git a/third_party/blink/common/renderer_preferences/renderer_preferences_mojom_traits.cc b/third_party/blink/common/renderer_preferences/renderer_preferences_mojom_traits.cc
index 25cf6b544dcee15a9616b6963eaae0264aba3db6..13d5b30d00ce8dca96eb3bc5454f9d353375d4c6 100644
--- a/third_party/blink/common/renderer_preferences/renderer_preferences_mojom_traits.cc
+++ b/third_party/blink/common/renderer_preferences/renderer_preferences_mojom_traits.cc
@@ -128,6 +128,8 @@ bool StructTraits<blink::mojom::RendererPreferencesDataView,
return false;
}
+ out->electron_corner_smoothing_css = data.electron_corner_smoothing_css();
+
return true;
}
diff --git a/third_party/blink/public/common/renderer_preferences/renderer_preferences.h b/third_party/blink/public/common/renderer_preferences/renderer_preferences.h
index cae096396b0635f1c4bba6ac8fee47fd957dc698..03db6cddab5cd1b9f3f7c90390bc53baa9e14b65 100644
--- a/third_party/blink/public/common/renderer_preferences/renderer_preferences.h
+++ b/third_party/blink/public/common/renderer_preferences/renderer_preferences.h
@@ -91,6 +91,7 @@ struct BLINK_COMMON_EXPORT RendererPreferences {
bool caret_browsing_enabled{false};
bool uses_platform_autofill{false};
std::vector<uint16_t> explicitly_allowed_network_ports;
+ bool electron_corner_smoothing_css;
RendererPreferences();
RendererPreferences(const RendererPreferences& other);
diff --git a/third_party/blink/public/common/renderer_preferences/renderer_preferences_mojom_traits.h b/third_party/blink/public/common/renderer_preferences/renderer_preferences_mojom_traits.h
index 33b4bd3f0c9488f1013aea026c7fe559ba750cd8..6b4157199c14a4c276e65512e89f2429253aec5c 100644
--- a/third_party/blink/public/common/renderer_preferences/renderer_preferences_mojom_traits.h
+++ b/third_party/blink/public/common/renderer_preferences/renderer_preferences_mojom_traits.h
@@ -275,6 +275,11 @@ struct BLINK_COMMON_EXPORT
return data.explicitly_allowed_network_ports;
}
+ static const bool& electron_corner_smoothing_css(
+ const ::blink::RendererPreferences& data) {
+ return data.electron_corner_smoothing_css;
+ }
+
static bool Read(blink::mojom::RendererPreferencesDataView,
::blink::RendererPreferences* out);
};
diff --git a/third_party/blink/public/mojom/renderer_preferences.mojom b/third_party/blink/public/mojom/renderer_preferences.mojom
index bbcec1dcdaaaf932b3d82c64e8aeb2e7c04b05bf..689205607a763c1d6e040069b1357d84e8ba4bd5 100644
--- a/third_party/blink/public/mojom/renderer_preferences.mojom
+++ b/third_party/blink/public/mojom/renderer_preferences.mojom
@@ -201,4 +201,6 @@ struct RendererPreferences {
bool uses_platform_autofill = false;
array<uint16> explicitly_allowed_network_ports;
+
+ bool electron_corner_smoothing_css;
};
diff --git a/third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom b/third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom
index 3e3d56992ab135ee88257681f93e39a470192857..26e87c2be381c0fd7d5116d95a107082e2549eae 100644
--- a/third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom
+++ b/third_party/blink/public/mojom/use_counter/metrics/css_property_id.mojom
@@ -48,6 +48,7 @@ enum CSSSampleId {
kInternalForcedVisitedColor = 0,
kInternalOverflowBlock = 0,
kInternalOverflowInline = 0,
+ kElectronCornerSmoothing = 0,
// This CSSSampleId represents page load for CSS histograms. It is recorded once
// per page visit for each CSS histogram being logged on the blink side and the
diff --git a/third_party/blink/public/web/web_settings.h b/third_party/blink/public/web/web_settings.h
index a53b4901dde0dc83dce6c9b56616eef0d02d94a5..b419672af985f673f375fbb63b4d2b2c419e3e03 100644
--- a/third_party/blink/public/web/web_settings.h
+++ b/third_party/blink/public/web/web_settings.h
@@ -285,6 +285,7 @@ class WebSettings {
virtual void SetRequireTransientActivationAndAuthorizationForSubAppsAPIs(
bool) = 0;
virtual void SetRootScrollbarThemeColor(std::optional<SkColor>) = 0;
+ virtual void SetCornerSmoothingCSS(bool) = 0;
protected:
~WebSettings() = default;
diff --git a/third_party/blink/renderer/build/scripts/core/css/css_properties.py b/third_party/blink/renderer/build/scripts/core/css/css_properties.py
index 753ba8990f722bafd1770a5e70307cff3764d3f1..16cec517d72887c089f85867e8e37c03199ab394 100755
--- a/third_party/blink/renderer/build/scripts/core/css/css_properties.py
+++ b/third_party/blink/renderer/build/scripts/core/css/css_properties.py
@@ -311,7 +311,13 @@ class CSSProperties(object):
name_without_leading_dash = property_.name.original
if name_without_leading_dash.startswith('-'):
name_without_leading_dash = name_without_leading_dash[1:]
+ # Extra sort level to avoid -internal-* properties being assigned
+ # values too large to fit in a byte.
+ internal_weight = 0
+ if property_.name.original.startswith('-internal'):
+ internal_weight = -1
property_.sorting_key = (-property_.priority,
+ internal_weight,
name_without_leading_dash)
sorting_keys = {}
diff --git a/third_party/blink/renderer/core/css/css_properties.json5 b/third_party/blink/renderer/core/css/css_properties.json5
index 6cf39b4a15ac290891d56a8d1d7b30846a329f79..5a0d840d5c01fb1ed95bacd36cc4f01443afdf94 100644
--- a/third_party/blink/renderer/core/css/css_properties.json5
+++ b/third_party/blink/renderer/core/css/css_properties.json5
@@ -8724,6 +8724,24 @@
property_methods: ["ParseShorthand", "CSSValueFromComputedStyleInternal"],
},
+ {
+ name: "-electron-corner-smoothing",
+ property_methods: ["ParseSingleValue"],
+ field_group: "*",
+ field_template: "external",
+ // To keep this patch small, Length is used instead of a more descriptive
+ // custom type.
+ // - `system-ui` = `Length::Auto()`
+ // - percent = `Length::Percent`
+ type_name: "Length",
+ converter: "ConvertCornerSmoothing",
+ keywords: ["system-ui"],
+ default_value: "Length::None()",
+ typedom_types: ["Keyword", "Percentage"],
+ is_border_radius: true,
+ invalidate: ["paint", "border-radius", "clip"],
+ },
+
// Visited properties.
{
name: "-internal-visited-color",
diff --git a/third_party/blink/renderer/core/css/css_property_equality.cc b/third_party/blink/renderer/core/css/css_property_equality.cc
index 998fb2cfb682e61d89bb6f832cd91efa658f9773..8ad689bd9327569d26eb5f449a707d6b0d7c2536 100644
--- a/third_party/blink/renderer/core/css/css_property_equality.cc
+++ b/third_party/blink/renderer/core/css/css_property_equality.cc
@@ -346,6 +346,8 @@ bool CSSPropertyEquality::PropertiesEqual(const PropertyHandle& property,
return a.DominantBaseline() == b.DominantBaseline();
case CSSPropertyID::kDynamicRangeLimit:
return a.GetDynamicRangeLimit() == b.GetDynamicRangeLimit();
+ case CSSPropertyID::kElectronCornerSmoothing:
+ return a.ElectronCornerSmoothing() == b.ElectronCornerSmoothing();
case CSSPropertyID::kEmptyCells:
return a.EmptyCells() == b.EmptyCells();
case CSSPropertyID::kFill:
diff --git a/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc b/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
index c1aa3851a8530f1993de160773d3fae107c4d8bd..d0b87808b0d0466473d21720e44366228daed218 100644
--- a/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
+++ b/third_party/blink/renderer/core/css/properties/longhands/longhands_custom.cc
@@ -11857,5 +11857,25 @@ const CSSValue* InternalEmptyLineHeight::ParseSingleValue(
CSSValueID::kNone>(stream);
}
+const CSSValue* ElectronCornerSmoothing::ParseSingleValue(
+ CSSParserTokenStream& stream,
+ const CSSParserContext& context,
+ const CSSParserLocalContext&) const {
+ // Fail parsing if this rule is disabled by document settings.
+ if (Settings* settings = context.GetDocument()->GetSettings();
+ settings && !settings->GetElectronCornerSmoothingCSS()) {
+ return nullptr;
+ }
+
+ // Try to parse `system-ui` keyword first.
+ if (auto* ident =
+ css_parsing_utils::ConsumeIdent<CSSValueID::kSystemUi>(stream)) {
+ return ident;
+ }
+ // Try to parse as percent.
+ return css_parsing_utils::ConsumePercent(
+ stream, context, CSSPrimitiveValue::ValueRange::kNonNegative);
+}
+
} // namespace css_longhand
} // namespace blink
diff --git a/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc b/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
index 797c8e2d7ee777bcd88e0e4e6a65992342c2a098..c8d024213eb4dfe1ae82e0543f066df55555213e 100644
--- a/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
+++ b/third_party/blink/renderer/core/css/resolver/style_builder_converter.cc
@@ -3861,4 +3861,12 @@ PositionArea StyleBuilderConverter::ConvertPositionArea(
return PositionArea(span[0], span[1], span[2], span[3]);
}
+Length StyleBuilderConverter::ConvertCornerSmoothing(StyleResolverState& state, const CSSValue& value) {
+ auto* ident = DynamicTo<CSSIdentifierValue>(value);
+ if (ident && ident->GetValueID() == CSSValueID::kSystemUi) {
+ return Length::Auto();
+ }
+ return ConvertLength(state, value);
+}
+
} // namespace blink
diff --git a/third_party/blink/renderer/core/css/resolver/style_builder_converter.h b/third_party/blink/renderer/core/css/resolver/style_builder_converter.h
index c0f4544a38dc486708dec5a4b3646fb3f15ff2e0..8b3d4e95fb690f9e7b38265be0a77d6e49271944 100644
--- a/third_party/blink/renderer/core/css/resolver/style_builder_converter.h
+++ b/third_party/blink/renderer/core/css/resolver/style_builder_converter.h
@@ -421,6 +421,8 @@ class StyleBuilderConverter {
const CSSValue&);
static PositionArea ConvertPositionArea(StyleResolverState&, const CSSValue&);
+
+ static Length ConvertCornerSmoothing(StyleResolverState&, const CSSValue&);
};
template <typename T>
diff --git a/third_party/blink/renderer/core/exported/web_settings_impl.cc b/third_party/blink/renderer/core/exported/web_settings_impl.cc
index 4a29a2200eaab5084078e928a68c862296c6ff91..fcd879deec0e68b3b6988402d19570cf0065daa2 100644
--- a/third_party/blink/renderer/core/exported/web_settings_impl.cc
+++ b/third_party/blink/renderer/core/exported/web_settings_impl.cc
@@ -816,4 +816,8 @@ void WebSettingsImpl::SetRootScrollbarThemeColor(
settings_->SetRootScrollbarThemeColor(theme_color);
}
+void WebSettingsImpl::SetCornerSmoothingCSS(bool available) {
+ settings_->SetElectronCornerSmoothingCSS(available);
+}
+
} // namespace blink
diff --git a/third_party/blink/renderer/core/exported/web_settings_impl.h b/third_party/blink/renderer/core/exported/web_settings_impl.h
index eabcddfa5f17497ef0611fa43f77dd13e2a54e00..96266c4f8c17b589f3d9c549e2836a147b7401ce 100644
--- a/third_party/blink/renderer/core/exported/web_settings_impl.h
+++ b/third_party/blink/renderer/core/exported/web_settings_impl.h
@@ -237,6 +237,7 @@ class CORE_EXPORT WebSettingsImpl final : public WebSettings {
void SetRequireTransientActivationAndAuthorizationForSubAppsAPIs(
bool) override;
void SetRootScrollbarThemeColor(std::optional<SkColor>) override;
+ void SetCornerSmoothingCSS(bool) override;
bool RenderVSyncNotificationEnabled() const {
return render_v_sync_notification_enabled_;
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 9810991e0a5d8b931a70e056b6651b8e5fdb9881..2b37a0209d370629f08e9065a22b92ff52053141 100644
--- a/third_party/blink/renderer/core/exported/web_view_impl.cc
+++ b/third_party/blink/renderer/core/exported/web_view_impl.cc
@@ -3574,6 +3574,9 @@ void WebViewImpl::UpdateRendererPreferences(
#endif
MaybePreloadSystemFonts(GetPage());
+
+ GetSettings()->SetCornerSmoothingCSS(
+ renderer_preferences_.electron_corner_smoothing_css);
}
void WebViewImpl::SetHistoryIndexAndLength(int32_t history_index,
diff --git a/third_party/blink/renderer/core/frame/settings.json5 b/third_party/blink/renderer/core/frame/settings.json5
index f4cdee12ea4352067f5de3e074e43d51ef56d2e5..6377e4b1ea8aa46b0bf69f8420b6c439bea70dba 100644
--- a/third_party/blink/renderer/core/frame/settings.json5
+++ b/third_party/blink/renderer/core/frame/settings.json5
@@ -1261,5 +1261,10 @@
initial: false,
type: "bool"
},
+ {
+ name: "electronCornerSmoothingCSS",
+ initial: true,
+ invalidate: ["Style"],
+ },
],
}
diff --git a/third_party/blink/renderer/core/paint/box_painter_base.cc b/third_party/blink/renderer/core/paint/box_painter_base.cc
index 68dbf4accafc0ce8100d6d488195e9dcde8b1502..dcd13e67acde42b181b219b2f690e2fc76ad917d 100644
--- a/third_party/blink/renderer/core/paint/box_painter_base.cc
+++ b/third_party/blink/renderer/core/paint/box_painter_base.cc
@@ -324,8 +324,9 @@ void BoxPainterBase::PaintNormalBoxShadow(const PaintInfo& info,
if (has_border_radius) {
FloatRoundedRect rounded_fill_rect(fill_rect, border.GetRadii());
ApplySpreadToShadowShape(rounded_fill_rect, shadow.Spread());
- context.FillRoundedRect(
- rounded_fill_rect, Color::kBlack,
+ ContouredRect contoured_fill_rect(rounded_fill_rect, border.GetCornerCurvature());
+ context.FillContouredRect(
+ contoured_fill_rect, Color::kBlack,
PaintAutoDarkMode(style, DarkModeFilter::ElementRole::kBackground));
} else {
fill_rect.Outset(shadow.Spread());
@@ -413,16 +414,20 @@ void BoxPainterBase::PaintInsetBoxShadow(const PaintInfo& info,
AdjustRectForSideClipping(inner_rect, shadow, sides_to_include);
FloatRoundedRect inner_rounded_rect(inner_rect, bounds.GetRadii());
ApplySpreadToShadowShape(inner_rounded_rect, -shadow.Spread());
+ ContouredRect contoured_bounds(
+ bounds, ContouredBorderGeometry::ContouredBorder(
+ style, PhysicalRect::EnclosingRect(bounds.Rect()))
+ .GetCornerCurvature());
if (inner_rounded_rect.IsEmpty()) {
// |AutoDarkMode::Disabled()| is used because |shadow_color| has already
// been adjusted for dark mode.
- context.FillRoundedRect(bounds, shadow_color, AutoDarkMode::Disabled());
+ context.FillContouredRect(contoured_bounds, shadow_color, AutoDarkMode::Disabled());
continue;
}
GraphicsContextStateSaver state_saver(context);
if (bounds.IsRounded()) {
// TODO(crbug.com/397459628) render corner-shape with box-shadow
- context.ClipContouredRect(ContouredRect(bounds));
+ context.ClipContouredRect(contoured_bounds);
} else {
context.Clip(bounds.Rect());
}
diff --git a/third_party/blink/renderer/core/paint/contoured_border_geometry.cc b/third_party/blink/renderer/core/paint/contoured_border_geometry.cc
index b96a3ba1e16b15807086c8e6a256b256b48e8adb..1396fd3214e18e1ded8fd8a83d964c8c824fbc5e 100644
--- a/third_party/blink/renderer/core/paint/contoured_border_geometry.cc
+++ b/third_party/blink/renderer/core/paint/contoured_border_geometry.cc
@@ -43,6 +43,24 @@ float EffectiveCurvature(Superellipse superellipse, const gfx::SizeF& radius) {
: superellipse.Exponent();
}
+float SmoothnessFromLength(const Length& length) {
+ // `none` = 0%
+ if (length.IsNone()) {
+ return 0.0f;
+ }
+
+ // `system-ui` keyword, represented internally as "auto" length
+ if (length.HasAuto()) {
+#if BUILDFLAG(IS_MAC)
+ return 0.6f;
+#else
+ return 0.0f;
+#endif // BUILDFLAG(IS_MAC)
+ }
+
+ return length.Percent() / 100.0f;
+}
+
ContouredRect::CornerCurvature CalcCurvatureFor(
const ComputedStyle& style,
const FloatRoundedRect::Radii& radii) {
@@ -50,7 +68,8 @@ ContouredRect::CornerCurvature CalcCurvatureFor(
EffectiveCurvature(style.CornerTopLeftShape(), radii.TopLeft()),
EffectiveCurvature(style.CornerTopRightShape(), radii.TopRight()),
EffectiveCurvature(style.CornerBottomRightShape(), radii.BottomRight()),
- EffectiveCurvature(style.CornerBottomLeftShape(), radii.BottomLeft()));
+ EffectiveCurvature(style.CornerBottomLeftShape(), radii.BottomLeft()),
+ SmoothnessFromLength(style.ElectronCornerSmoothing()));
}
ContouredRect PixelSnappedContouredBorderInternal(
diff --git a/third_party/blink/renderer/platform/BUILD.gn b/third_party/blink/renderer/platform/BUILD.gn
index ae923ecf6c58d608ed3583312edb48ecb6b7f576..759d991162702d31e77590474bc5764c8fd8229b 100644
--- a/third_party/blink/renderer/platform/BUILD.gn
+++ b/third_party/blink/renderer/platform/BUILD.gn
@@ -1642,6 +1642,8 @@ component("platform") {
"widget/widget_base.h",
"widget/widget_base_client.h",
"windows_keyboard_codes.h",
+ "//electron/shell/renderer/electron_smooth_round_rect.h",
+ "//electron/shell/renderer/electron_smooth_round_rect.cc",
]
sources -= blink_platform_avx_files
diff --git a/third_party/blink/renderer/platform/geometry/contoured_rect.h b/third_party/blink/renderer/platform/geometry/contoured_rect.h
index 1a5d76b145307c11ac71cd5840f7ca166655fde2..a40aee431d9ecf8bdb011ccc4e8a9ecd813ffe3a 100644
--- a/third_party/blink/renderer/platform/geometry/contoured_rect.h
+++ b/third_party/blink/renderer/platform/geometry/contoured_rect.h
@@ -42,19 +42,29 @@ class PLATFORM_EXPORT ContouredRect {
constexpr CornerCurvature(float top_left,
float top_right,
float bottom_right,
- float bottom_left)
+ float bottom_left,
+ float smoothness)
: top_left_(top_left),
top_right_(top_right),
bottom_right_(bottom_right),
- bottom_left_(bottom_left) {
+ bottom_left_(bottom_left),
+ smoothness_(smoothness) {
DCHECK_GE(top_left, 0);
DCHECK_GE(top_right, 0);
DCHECK_GE(bottom_right, 0);
DCHECK_GE(bottom_left, 0);
+ DCHECK_GE(smoothness, 0);
}
+ constexpr CornerCurvature(float top_left,
+ float top_right,
+ float bottom_right,
+ float bottom_left)
+ : CornerCurvature(top_left, top_right, bottom_right, bottom_left, 0) {}
+
+ constexpr bool IsSmooth() const { return smoothness_ > 0.0f; }
constexpr bool IsRound() const {
- return (top_left_ == kRound) && IsUniform();
+ return (top_left_ == kRound) && IsUniform() && !IsSmooth();
}
constexpr bool IsUniform() const {
@@ -66,6 +76,7 @@ class PLATFORM_EXPORT ContouredRect {
constexpr float TopRight() const { return top_right_; }
constexpr float BottomRight() const { return bottom_right_; }
constexpr float BottomLeft() const { return bottom_left_; }
+ constexpr float Smoothness() const { return smoothness_; }
constexpr bool operator==(const CornerCurvature&) const = default;
@@ -76,6 +87,7 @@ class PLATFORM_EXPORT ContouredRect {
float top_right_ = kRound;
float bottom_right_ = kRound;
float bottom_left_ = kRound;
+ float smoothness_ = 0.0f;
};
constexpr ContouredRect() = default;
diff --git a/third_party/blink/renderer/platform/geometry/path.cc b/third_party/blink/renderer/platform/geometry/path.cc
index 4b63f7f3e113e77bf91810b91c5fad1b6bf5de92..6121bd490717ce6bf4ba7d933e1a9f3eae1752e1 100644
--- a/third_party/blink/renderer/platform/geometry/path.cc
+++ b/third_party/blink/renderer/platform/geometry/path.cc
@@ -33,6 +33,7 @@
#include <algorithm>
+#include "electron/shell/renderer/electron_smooth_round_rect.h"
#include "third_party/blink/renderer/platform/geometry/contoured_rect.h"
#include "third_party/blink/renderer/platform/geometry/float_rounded_rect.h"
#include "third_party/blink/renderer/platform/geometry/skia_geometry_utils.h"
@@ -660,6 +661,18 @@ void Path::AddContouredRect(const ContouredRect& contoured_rect) {
return;
}
+ // TODO(clavin): decompose `electron::DrawSmoothRoundRect` into corners
+ if (contoured_rect.GetCornerCurvature().IsSmooth()) {
+ const gfx::RectF& box = rect.Rect();
+ const FloatRoundedRect::Radii& radii = rect.GetRadii();
+ path_.addPath(electron::DrawSmoothRoundRect(
+ box.x(), box.y(), box.width(), box.height(),
+ std::min(contoured_rect.GetCornerCurvature().Smoothness(), 1.0f),
+ radii.TopLeft().width(), radii.TopRight().width(),
+ radii.BottomRight().width(), radii.BottomLeft().width()));
+ return;
+ }
+
const ContouredRect::CornerCurvature& curvature =
contoured_rect.GetCornerCurvature();
path_.moveTo(gfx::PointFToSkPoint(rect.TopLeftCorner().top_right()));
diff --git a/third_party/blink/renderer/platform/graphics/graphics_context.cc b/third_party/blink/renderer/platform/graphics/graphics_context.cc
index 6361cc655af8c2bef6803efe6f3c382c1eadb851..9439df63a7d265d1f93c89c275d84a8a1dde30c6 100644
--- a/third_party/blink/renderer/platform/graphics/graphics_context.cc
+++ b/third_party/blink/renderer/platform/graphics/graphics_context.cc
@@ -924,6 +924,19 @@ void GraphicsContext::FillRectWithRoundedHole(
DarkModeFlags(this, auto_dark_mode, flags));
}
+void GraphicsContext::FillContouredRect(const ContouredRect& contoured_rect,
+ const Color& color,
+ const AutoDarkMode& auto_dark_mode) {
+ if (contoured_rect.HasRoundCurvature()) {
+ FillRoundedRect(contoured_rect.AsRoundedRect(), color, auto_dark_mode);
+ return;
+ }
+
+ cc::PaintFlags flags = ImmutableState()->FillFlags();
+ flags.setColor(color.toSkColor4f());
+ canvas_->drawPath(contoured_rect.GetPath().GetSkPath(), flags);
+}
+
void GraphicsContext::FillEllipse(const gfx::RectF& ellipse,
const AutoDarkMode& auto_dark_mode) {
DrawOval(gfx::RectFToSkRect(ellipse), ImmutableState()->FillFlags(),
diff --git a/third_party/blink/renderer/platform/graphics/graphics_context.h b/third_party/blink/renderer/platform/graphics/graphics_context.h
index 632b0ec1faebc87d13a5538812333bf14f9e402a..ee51cb455600f507e3a97fe3e6f293ff0f47bbd6 100644
--- a/third_party/blink/renderer/platform/graphics/graphics_context.h
+++ b/third_party/blink/renderer/platform/graphics/graphics_context.h
@@ -318,6 +318,9 @@ class PLATFORM_EXPORT GraphicsContext {
const FloatRoundedRect& rounded_hole_rect,
const Color&,
const AutoDarkMode& auto_dark_mode);
+ void FillContouredRect(const ContouredRect& contoured_rect,
+ const Color& color,
+ const AutoDarkMode& auto_dark_mode);
void StrokeRect(const gfx::RectF&,
const AutoDarkMode& auto_dark_mode);

View File

@@ -0,0 +1,737 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Keeley Hammond <khammond@slack-corp.com>
Date: Tue, 14 Jan 2025 15:50:29 -0800
Subject: feat: allow desktop capturer to return either screen, window or both
and make MacOS SCContentSharingPicker work in Electron
This patch is a work in progress that contains assorted changes to make the MacOS SCContentSharingPicker upstream implementation work within Electron. If this comment is still in this patch during PR review, it is not ready for prime time
This patch can be removed after our desktopCapturer is refactored.
diff --git a/chrome/browser/media/webrtc/capture_policy_utils.cc b/chrome/browser/media/webrtc/capture_policy_utils.cc
index 36797f37627d534bd446e0d8270618722ed9a2fa..32222cb526dc047a02cd9382814edd71cca0a378 100644
--- a/chrome/browser/media/webrtc/capture_policy_utils.cc
+++ b/chrome/browser/media/webrtc/capture_policy_utils.cc
@@ -356,7 +356,9 @@ void FilterMediaList(std::vector<DesktopMediaList::Type>& media_types,
media_types, [capture_level](const DesktopMediaList::Type& type) {
switch (type) {
case DesktopMediaList::Type::kNone:
- NOTREACHED();
+ //TODO(review): are we able to remove this?
+ return capture_level < AllowedScreenCaptureLevel::kDesktop;
+ // NOTREACHED();
// SameOrigin is more restrictive than just Tabs, so as long as
// at least SameOrigin is allowed, these entries should stay.
// They should be filtered later by the caller.
diff --git a/chrome/browser/media/webrtc/desktop_media_list_base.cc b/chrome/browser/media/webrtc/desktop_media_list_base.cc
index 08400be4d1bae18502d19beed6b2d9057e55dd4f..4df1a9f44959db1f73d6a8a535d297343f7f0c00 100644
--- a/chrome/browser/media/webrtc/desktop_media_list_base.cc
+++ b/chrome/browser/media/webrtc/desktop_media_list_base.cc
@@ -12,9 +12,11 @@
#include <set>
#include <utility>
+#include "base/logging.h"
#include "base/functional/bind.h"
#include "base/hash/hash.h"
#include "chrome/browser/media/webrtc/desktop_media_list.h"
+#include "chrome/browser/media/webrtc/thumbnail_capturer_mac.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -60,24 +62,34 @@ void DesktopMediaListBase::StartUpdating(DesktopMediaListObserver* observer) {
// If there is a delegated source list, it may not have been started yet.
if (IsSourceListDelegated())
StartDelegatedCapturer();
+ LOG(ERROR) << "start delegated capturer";
// Process sources previously discovered by a call to Update().
if (observer_) {
for (size_t i = 0; i < sources_.size(); i++) {
observer_->OnSourceAdded(i);
+ LOG(ERROR) << "OnSourceAdded, i: " << i;
}
}
-
+ LOG(INFO)<< "Refresh callback_ is null: " << refresh_callback_.is_null() << ";";
DCHECK(!refresh_callback_);
+ LOG(INFO) << "dcheck passed";
refresh_callback_ = base::BindOnce(&DesktopMediaListBase::ScheduleNextRefresh,
weak_factory_.GetWeakPtr());
Refresh(true);
}
void DesktopMediaListBase::Update(UpdateCallback callback, bool refresh_thumbnails) {
+ LOG(ERROR) << "Update";
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(sources_.empty());
- DCHECK(!refresh_callback_);
+ #if BUILDFLAG(IS_MAC)
+ if (!ShouldUseSCContentSharingPicker()) {
+ DCHECK(!refresh_callback_);
+ };
+ #else
+ DCHECK(!refresh_callback_);
+ #endif
refresh_callback_ = std::move(callback);
Refresh(refresh_thumbnails);
}
diff --git a/chrome/browser/media/webrtc/native_desktop_media_list.cc b/chrome/browser/media/webrtc/native_desktop_media_list.cc
index 312882d656f9f6b3d3fd98128131cea63f818e0d..f61697e1717fcfa0500974e8523438389fbab5ae 100644
--- a/chrome/browser/media/webrtc/native_desktop_media_list.cc
+++ b/chrome/browser/media/webrtc/native_desktop_media_list.cc
@@ -45,6 +45,7 @@
#endif
#if BUILDFLAG(IS_MAC)
+#include "chrome/browser/media/webrtc/thumbnail_capturer_mac.h"
#include "components/remote_cocoa/browser/scoped_cg_window_id.h"
#endif
@@ -162,9 +163,10 @@ content::DesktopMediaID::Type ConvertToDesktopMediaIDType(
return content::DesktopMediaID::Type::TYPE_SCREEN;
case DesktopMediaList::Type::kWindow:
return content::DesktopMediaID::Type::TYPE_WINDOW;
+ case DesktopMediaList::Type::kNone:
+ return content::DesktopMediaID::Type::TYPE_NONE;
case DesktopMediaList::Type::kWebContents:
case DesktopMediaList::Type::kCurrentTab:
- case DesktopMediaList::Type::kNone:
break;
}
NOTREACHED();
@@ -372,7 +374,8 @@ NativeDesktopMediaList::Worker::Worker(
nullptr) {
DCHECK(capturer_);
- DCHECK(source_type_ == DesktopMediaID::Type::TYPE_WINDOW ||
+ DCHECK(source_type_ == DesktopMediaID::Type::TYPE_WINDOW || source_type_ ==
+ DesktopMediaID::Type::TYPE_NONE ||
!add_current_process_windows_);
}
@@ -505,11 +508,27 @@ NativeDesktopMediaList::Worker::FormatSources(
break;
case DesktopMediaID::Type::TYPE_WINDOW:
+ case DesktopMediaID::Type::TYPE_NONE:
+ #if BUILDFLAG(IS_MAC)
+ // If using NativeScreenCapturePickerMac,
+ // skipping the picker will skip the first window selection.
+ if (ShouldUseSCContentSharingPicker()) {
+ title = base::UTF8ToUTF16(sources[i].title);
+ LOG(ERROR) << "formatting native picker source, id: " << sources[i].id << " title: " << title;
+ LOG(ERROR) << "sources size: " << sources.size();
+ LOG(ERROR) << "excluded window id: " << excluded_window_id;
+ } else if (sources[i].id == excluded_window_id) {
+ // Skip the picker dialog window.
+ continue;
+ }
+ title = base::UTF8ToUTF16(sources[i].title);
+ #else
// Skip the picker dialog window.
if (sources[i].id == excluded_window_id) {
continue;
}
title = base::UTF8ToUTF16(sources[i].title);
+ #endif
break;
default:
@@ -775,14 +794,10 @@ NativeDesktopMediaList::NativeDesktopMediaList(
is_source_list_delegated_(capturer->GetDelegatedSourceListController() !=
nullptr) {
type_ = type;
-
- DCHECK(type_ == DesktopMediaList::Type::kWindow ||
+ DCHECK(type_ == DesktopMediaList::Type::kWindow || type_ == DesktopMediaList::Type::kNone ||
!add_current_process_windows_);
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
- // webrtc::DesktopCapturer implementations on Windows, MacOS and Fuchsia
- // expect to run on a thread with a UI message pump. Under Fuchsia the
- // capturer needs an async loop to support FIDL I/O.
base::MessagePumpType thread_type = base::MessagePumpType::UI;
#else
base::MessagePumpType thread_type = base::MessagePumpType::DEFAULT;
@@ -794,8 +809,9 @@ NativeDesktopMediaList::NativeDesktopMediaList(
std::move(capturer), add_current_process_windows_,
auto_show_delegated_source_list);
- if (!is_source_list_delegated_)
+ if (!is_source_list_delegated_) {
StartCapturer();
+ }
}
NativeDesktopMediaList::~NativeDesktopMediaList() {
@@ -903,7 +919,7 @@ void NativeDesktopMediaList::ShowDelegatedList() {
}
void NativeDesktopMediaList::Refresh(bool update_thumbnails) {
- DCHECK(can_refresh());
+ DCHECK(can_refresh());
#if defined(USE_AURA)
DCHECK_EQ(pending_aura_capture_requests_, 0);
diff --git a/chrome/browser/media/webrtc/thumbnail_capturer_mac.h b/chrome/browser/media/webrtc/thumbnail_capturer_mac.h
index 12a74f8f32cc00a7f3d7802865ae4b309961341d..acbcfb08ae8c44e24a04b326096289428bc6ff60 100644
--- a/chrome/browser/media/webrtc/thumbnail_capturer_mac.h
+++ b/chrome/browser/media/webrtc/thumbnail_capturer_mac.h
@@ -8,6 +8,9 @@
#include "chrome/browser/media/webrtc/desktop_media_list.h"
#include "chrome/browser/media/webrtc/thumbnail_capturer.h"
+// Returns true if the SCK sharing picker is available and enabled.
+bool ShouldUseSCContentSharingPicker();
+
// Returns true if the SCK thumbnail capturer is available and enabled.
bool ShouldUseThumbnailCapturerMac(DesktopMediaList::Type type);
diff --git a/chrome/browser/media/webrtc/thumbnail_capturer_mac.mm b/chrome/browser/media/webrtc/thumbnail_capturer_mac.mm
index 744f2447dc2d43c4f6be695bf561474993468705..bb5781b0f0df11422f8355dcc59f5f0f46ebcf89 100644
--- a/chrome/browser/media/webrtc/thumbnail_capturer_mac.mm
+++ b/chrome/browser/media/webrtc/thumbnail_capturer_mac.mm
@@ -13,6 +13,7 @@
#include <optional>
#include <unordered_map>
+#include "base/logging.h"
#include "base/apple/bridging.h"
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
@@ -71,11 +72,11 @@
return content::DesktopMediaID::Type::TYPE_SCREEN;
case DesktopMediaList::Type::kWindow:
return content::DesktopMediaID::Type::TYPE_WINDOW;
+ case DesktopMediaList::Type::kNone:
+ return content::DesktopMediaID::Type::TYPE_NONE;
case DesktopMediaList::Type::kWebContents:
case DesktopMediaList::Type::kCurrentTab:
return content::DesktopMediaID::Type::TYPE_WEB_CONTENTS;
- case DesktopMediaList::Type::kNone:
- break;
}
NOTREACHED();
}
@@ -442,7 +443,7 @@ void OnCapturedFrame(base::apple::ScopedCFTypeRef<CGImageRef> image,
max_frame_rate_(kThumbnailCapturerMacMaxFrameRate),
shareable_windows_([[NSArray<SCWindow*> alloc] init]) {
CHECK(type_ == DesktopMediaList::Type::kWindow ||
- type_ == DesktopMediaList::Type::kScreen);
+ type_ == DesktopMediaList::Type::kScreen || type_ == DesktopMediaList::Type::kNone);
}
ThumbnailCapturerMac::~ThumbnailCapturerMac() {
@@ -680,17 +681,15 @@ void OnCapturedFrame(base::apple::ScopedCFTypeRef<CGImageRef> image,
source_id);
}
+} // namespace
+
bool ShouldUseSCContentSharingPicker() {
if (@available(macOS 15.0, *)) {
- if (base::FeatureList::IsEnabled(media::kUseSCContentSharingPicker)) {
- return true;
- }
+ return base::FeatureList::IsEnabled(media::kUseSCContentSharingPicker);
}
return false;
}
-} // namespace
-
bool ShouldUseThumbnailCapturerMac(DesktopMediaList::Type type) {
// There was a bug in ScreenCaptureKit that was fixed in 14.4,
// see b/40076027.
@@ -704,6 +703,9 @@ bool ShouldUseThumbnailCapturerMac(DesktopMediaList::Type type) {
return ShouldUseSCContentSharingPicker() ||
base::FeatureList::IsEnabled(kScreenCaptureKitPickerScreen);
case DesktopMediaList::Type::kNone:
+ return ShouldUseSCContentSharingPicker() ||
+ base::FeatureList::IsEnabled(kScreenCaptureKitStreamPickerSonoma) ||
+ base::FeatureList::IsEnabled(kScreenCaptureKitPickerScreen);
case DesktopMediaList::Type::kCurrentTab:
case DesktopMediaList::Type::kWebContents:
return false;
diff --git a/content/browser/media/capture/desktop_capture_device.cc b/content/browser/media/capture/desktop_capture_device.cc
index b4b1e9ee805a8565a04737e0898ad8e46709c4d8..7b856f89028fe8f5594c1ff35900019250865ab5 100644
--- a/content/browser/media/capture/desktop_capture_device.cc
+++ b/content/browser/media/capture/desktop_capture_device.cc
@@ -899,7 +899,6 @@ std::unique_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create(
result.reset(new DesktopCaptureDevice(std::move(capturer), source.type));
return result;
}
-
switch (source.type) {
case DesktopMediaID::TYPE_SCREEN: {
std::unique_ptr<webrtc::DesktopCapturer> screen_capturer;
@@ -920,7 +919,7 @@ std::unique_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create(
}
break;
}
-
+ case DesktopMediaID::TYPE_NONE:
case DesktopMediaID::TYPE_WINDOW: {
std::unique_ptr<webrtc::DesktopCapturer> window_capturer;
if (auto generic_capturer =
diff --git a/content/browser/media/capture/native_screen_capture_picker.cc b/content/browser/media/capture/native_screen_capture_picker.cc
index 152f3aa78032ee3f8c48fbefe052a2f1d85bed6b..d57df80dff9c6867cddf669efe3f90c43c03a0a7 100644
--- a/content/browser/media/capture/native_screen_capture_picker.cc
+++ b/content/browser/media/capture/native_screen_capture_picker.cc
@@ -7,6 +7,7 @@
#if BUILDFLAG(IS_MAC)
#include "content/browser/media/capture/native_screen_capture_picker_mac.h"
#include "media/base/media_switches.h"
+#include "base/logging.h"
#endif
namespace content {
diff --git a/content/browser/media/capture/native_screen_capture_picker_mac.mm b/content/browser/media/capture/native_screen_capture_picker_mac.mm
index 0dbc7ebc4ba6066eb6b20f8e66f50a1dff4d94f3..17d658ee011b81208b77ee1e65925ae9ad1e68f7 100644
--- a/content/browser/media/capture/native_screen_capture_picker_mac.mm
+++ b/content/browser/media/capture/native_screen_capture_picker_mac.mm
@@ -206,8 +206,12 @@ void Open(DesktopMediaID::Type type,
base::OnceClosure cancel_callback,
base::OnceClosure error_callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
+ LOG(ERROR) << "Open";
+ // Chrome doesn't allow both screens & windows in their picker,
+ // but Electron does - add a check for TYPE_NONE.
CHECK(type == DesktopMediaID::Type::TYPE_SCREEN ||
- type == DesktopMediaID::Type::TYPE_WINDOW);
+ type == DesktopMediaID::Type::TYPE_WINDOW ||
+ type == DesktopMediaID::Type::TYPE_NONE);
if (@available(macOS 14.0, *)) {
NSNumber* source_id = @(next_id_);
PickerObserver* picker_observer = [[PickerObserver alloc]
@@ -226,25 +230,32 @@ void Open(DesktopMediaID::Type type,
// TODO(https://crbug.com/360781940): Add support for changing selected
// content. The problem to solve is how this should interact with stream
// restart.
- config.allowsChangingSelectedContent = false;
+ config.allowsChangingSelectedContent = true;
NSNumber* max_stream_count = @(kMaxContentShareCountValue.Get());
- if (type == DesktopMediaID::Type::TYPE_SCREEN) {
- config.allowedPickerModes = SCContentSharingPickerModeSingleDisplay;
- picker.defaultConfiguration = config;
- picker.maximumStreamCount = max_stream_count;
- [picker presentPickerUsingContentStyle:SCShareableContentStyleDisplay];
- VLOG(1) << "NSCPM: Show screen-sharing picker for source_id = "
- << source_id.longValue;
- LogToUma(SCContentSharingPickerOperation::kPresentScreen_Start);
- } else {
- config.allowedPickerModes = SCContentSharingPickerModeSingleWindow;
- picker.defaultConfiguration = config;
- picker.maximumStreamCount = max_stream_count;
- [picker presentPickerUsingContentStyle:SCShareableContentStyleWindow];
- VLOG(1) << "NSCPM: Show window-sharing picker for source_id = "
- << source_id.longValue;
- LogToUma(SCContentSharingPickerOperation::kPresentWindow_Start);
- }
+ // LOG(ERROR) << "Type: " << type;
+ // Chrome doesn't allow both screens & windows in their picker,
+ // but Electron does; we patch out the MediaID::Type conditional here
+ // if (type == DesktopMediaID::Type::TYPE_SCREEN) {
+ // config.allowedPickerModes = SCContentSharingPickerModeSingleDisplay;
+ // picker.defaultConfiguration = config;
+ // picker.maximumStreamCount = max_stream_count;
+ // [picker presentPickerUsingContentStyle:SCShareableContentStyleDisplay];
+ // } else if (type == DesktopMediaID::Type::TYPE_WINDOW) {
+ // config.allowedPickerModes = SCContentSharingPickerModeSingleWindow;
+ // picker.defaultConfiguration = config;
+ // picker.maximumStreamCount = max_stream_count;
+ // [picker presentPickerUsingContentStyle:SCShareableContentStyleWindow];
+ // VLOG(1) << "NSCPM: Show screen-sharing picker for source_id = "
+ // << source_id.longValue;
+ // LogToUma(SCContentSharingPickerOperation::kPresentScreen_Start);
+ // } else {
+ picker.defaultConfiguration = config;
+ picker.maximumStreamCount = max_stream_count;
+ [picker present];
+ // VLOG(1) << "NSCPM: Show window-sharing picker for source_id = "
+ // << source_id.longValue;
+ // LogToUma(SCContentSharingPickerOperation::kPresentWindow_Start);
+ // }
} else {
NOTREACHED();
}
diff --git a/content/browser/media/capture/screen_capture_kit_device_mac.mm b/content/browser/media/capture/screen_capture_kit_device_mac.mm
index 7e17594c30ac3cf8cb484b53563b03fc75bd2e0b..fef50841f472bf3e76c171d9e106c689157adaae 100644
--- a/content/browser/media/capture/screen_capture_kit_device_mac.mm
+++ b/content/browser/media/capture/screen_capture_kit_device_mac.mm
@@ -281,6 +281,7 @@ void OnShareableContentCreated(SCShareableContent* content) {
if (!fullscreen_module_) {
fullscreen_module_ = MaybeCreateScreenCaptureKitFullscreenModule(
device_task_runner_, *this, window);
+ break;
}
}
}
@@ -616,6 +617,7 @@ void ResetStreamTo(SCWindow* window) override {
SCContentFilter* filter) {
switch (source.type) {
case DesktopMediaID::TYPE_SCREEN:
+ case DesktopMediaID::TYPE_NONE:
// ScreenCaptureKitDeviceMac only supports a single display at a time.
// It will not stitch desktops together. If
// kScreenCaptureKitFullDesktopFallback is enabled, we will fallback to
diff --git a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
index 0ab684dc8e792359abb90b91917eddae42e6123d..2351919905fbec6c1bfe9ce59d799192a9e2e0e6 100644
--- a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
+++ b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
@@ -177,19 +177,20 @@ DesktopCaptureImplementation CreatePlatformDependentVideoCaptureDevice(
#if BUILDFLAG(IS_MAC)
// Use ScreenCaptureKit with picker if specified. `desktop_id` for the picker
// is not compatible with the other implementations.
- if (picker) {
- device_out = picker->CreateDevice(desktop_id);
- if (device_out) {
- return kScreenCaptureKitDeviceMac;
- }
- return kNoImplementation;
- }
+ // if (picker) {
+ // device_out = picker->CreateDevice(desktop_id);
+ // if (device_out) {
+ // return kScreenCaptureKitDeviceMac;
+ // }
+ // return kNoImplementation;
+ // }
// Prefer using ScreenCaptureKit. After that try DesktopCaptureDeviceMac, and
// if both fail, use the generic DesktopCaptureDevice.
if (desktop_id.type == DesktopMediaID::TYPE_WINDOW ||
(desktop_id.type == DesktopMediaID::TYPE_SCREEN &&
- base::FeatureList::IsEnabled(kScreenCaptureKitMacScreen))) {
+ base::FeatureList::IsEnabled(kScreenCaptureKitMacScreen)) ||
+ (desktop_id.type == DesktopMediaID::TYPE_NONE && base::FeatureList::IsEnabled(kScreenCaptureKitMacScreen))) {
device_out = CreateScreenCaptureKitDeviceMac(desktop_id);
if (device_out) {
return kScreenCaptureKitDeviceMac;
@@ -237,6 +238,9 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
DCHECK(state_ == State::READY_TO_LAUNCH);
if (receiver_on_io_thread) {
+ LOG(INFO) << "InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync: Posting "
+ "start request to device thread for device_id = "
+ << device_id;
std::ostringstream string_stream;
string_stream
<< "InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync: Posting "
@@ -244,7 +248,7 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
<< device_id;
receiver_on_io_thread->OnLog(string_stream.str());
}
-
+ LOG(ERROR) << "receiver_on_io_thread: ";
// Wrap the receiver, to trampoline all its method calls from the device
// to the IO thread.
auto receiver = std::make_unique<media::VideoFrameReceiverOnTaskRunner>(
@@ -257,12 +261,14 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
base::BindPostTaskToCurrentDefault(base::BindOnce(
&InProcessVideoCaptureDeviceLauncher::OnDeviceStarted,
base::Unretained(this), callbacks, std::move(done_cb)));
-
+ LOG(ERROR) << "stream type: " << stream_type;
+ LOG(ERROR) << "gum tab video capture: " << blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE;
switch (stream_type) {
- case blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE:
- // Only the Service-based device launcher is supported for device capture
- // from cameras etc.
- NOTREACHED();
+ // case blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE:
+ // // Only the Service-based device launcher is supported for device capture
+ // // from cameras etc.
+ // LOG(INFO) << "device video capture not reached";
+ // NOTREACHED();
#if BUILDFLAG(ENABLE_SCREEN_CAPTURE)
case blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE:
start_capture_closure = base::BindOnce(
@@ -274,10 +280,14 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
case blink::mojom::MediaStreamType::GUM_DESKTOP_VIDEO_CAPTURE:
case blink::mojom::MediaStreamType::DISPLAY_VIDEO_CAPTURE:
case blink::mojom::MediaStreamType::DISPLAY_VIDEO_CAPTURE_THIS_TAB:
+ case blink::mojom::MediaStreamType::DEVICE_VIDEO_CAPTURE:
case blink::mojom::MediaStreamType::DISPLAY_VIDEO_CAPTURE_SET: {
const DesktopMediaID desktop_id = DesktopMediaID::Parse(device_id);
- if (desktop_id.is_null()) {
- DLOG(ERROR) << "Desktop media ID is null";
+ LOG(ERROR) << "desktop_id.is_null(): " << desktop_id.is_null();
+ LOG(ERROR) << "desktop_id.id: " << desktop_id.id;
+ LOG(ERROR) << "DesktopMediaID::kMacOsNativePickerId: " << DesktopMediaID::kMacOsNativePickerId;
+ if (desktop_id.is_null() && desktop_id.id != DesktopMediaID::kMacOsNativePickerId) {
+ LOG(ERROR) << "in null case";
start_capture_closure =
base::BindOnce(std::move(after_start_capture_callback), nullptr);
break;
@@ -316,8 +326,21 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
break;
}
+#if defined(USE_AURA)
+ bool allow_window_id = false;
+#elif BUILDFLAG(IS_MAC)
+
+ bool allow_window_id =
+ desktop_id.id == DesktopMediaID::kMacOsNativePickerId;
+
+ LOG(ERROR) << "allow_window_id: " << allow_window_id << " desktop_id.id: " << desktop_id.id;
+#endif
+
#if defined(USE_AURA) || BUILDFLAG(IS_MAC)
- if (desktop_id.window_id != DesktopMediaID::kNullId) {
+ LOG(ERROR) << "in if block";
+ if (!allow_window_id &&
+ desktop_id.window_id != DesktopMediaID::kNullId) {
+ LOG(ERROR) << "allow_window_id: " << allow_window_id << " desktop_id.window_id: " << desktop_id.window_id;
// For the other capturers, when a bug reports the type of capture it's
// easy enough to determine which capturer was used, but it's a little
// fuzzier with window capture.
@@ -344,6 +367,7 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
kMaxNumberOfBuffers, std::move(receiver),
std::move(receiver_on_io_thread)),
std::move(after_start_capture_callback));
+ LOG(ERROR) << "capture closure";
break;
}
#endif // BUILDFLAG(ENABLE_SCREEN_CAPTURE)
@@ -358,6 +382,7 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
// above are NOTREACHED() then.
#if BUILDFLAG(ENABLE_SCREEN_CAPTURE)
state_ = State::DEVICE_START_IN_PROGRESS;
+ LOG(ERROR) << "start capture closure";
device_task_runner_->PostTask(FROM_HERE, std::move(start_capture_closure));
#endif
}
@@ -408,9 +433,11 @@ void InProcessVideoCaptureDeviceLauncher::OnDeviceStarted(
base::OnceClosure done_cb,
std::unique_ptr<media::VideoCaptureDevice> device) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ LOG(ERROR) << "on device started";
State state_copy = state_;
state_ = State::READY_TO_LAUNCH;
if (!device) {
+ LOG(ERROR) << "device is null";
switch (state_copy) {
case State::DEVICE_START_IN_PROGRESS:
callbacks->OnDeviceLaunchFailed(
@@ -429,13 +456,15 @@ void InProcessVideoCaptureDeviceLauncher::OnDeviceStarted(
auto launched_device = std::make_unique<InProcessLaunchedVideoCaptureDevice>(
std::move(device), device_task_runner_);
-
+ LOG(ERROR) << "launched device";
switch (state_copy) {
case State::DEVICE_START_IN_PROGRESS:
+ LOG(ERROR) << "on device started, case 1";
callbacks->OnDeviceLaunched(std::move(launched_device));
std::move(done_cb).Run();
return;
case State::DEVICE_START_ABORTING:
+ LOG(ERROR) << "on device started, case 2";
launched_device.reset();
callbacks->OnDeviceLaunchAborted();
std::move(done_cb).Run();
@@ -495,7 +524,8 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread(
std::unique_ptr<media::VideoCaptureDeviceClient> device_client,
ReceiveDeviceCallback result_callback) {
DCHECK(device_task_runner_->BelongsToCurrentThread());
- DCHECK(!desktop_id.is_null());
+ LOG(INFO) << "DO START DESKTOP CAPTURE ON DEVICE THREAD " << desktop_id.id;
+ DCHECK(!desktop_id.is_null() || desktop_id.id == DesktopMediaID::kMacOsNativePickerId);
std::unique_ptr<media::VideoCaptureDevice> video_capture_device;
DesktopCaptureImplementation implementation =
@@ -504,8 +534,10 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread(
DVLOG(1) << __func__ << " implementation " << implementation << " type "
<< desktop_id.type;
ReportDesktopCaptureImplementationAndType(implementation, desktop_id.type);
- if (video_capture_device)
+ if (video_capture_device) {
+ LOG(ERROR) << "allocate and start capture device";
video_capture_device->AllocateAndStart(params, std::move(device_client));
+ }
std::move(result_callback).Run(std::move(video_capture_device));
}
diff --git a/content/browser/renderer_host/media/in_process_video_capture_provider.cc b/content/browser/renderer_host/media/in_process_video_capture_provider.cc
index 4462efa154a2be9cc25f82688fdbc7edf71a7bb1..4207dd1a79c16df5cc972943da32699f414f81fa 100644
--- a/content/browser/renderer_host/media/in_process_video_capture_provider.cc
+++ b/content/browser/renderer_host/media/in_process_video_capture_provider.cc
@@ -9,6 +9,7 @@
#include "base/functional/bind.h"
#include "base/task/single_thread_task_runner.h"
#include "content/browser/renderer_host/media/in_process_video_capture_device_launcher.h"
+#include "content/browser/media/capture/native_screen_capture_picker.h"
namespace content {
diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc
index 2949c2abd5f97e66719ec0f77cb23813865bb701..bd11a0fcdc084da00407c80e4ee229a130fdedc8 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -283,6 +283,7 @@ void VideoCaptureManager::QueueStartDevice(
mojo::PendingRemote<media::mojom::ReadonlyVideoEffectsManager>
readonly_video_effects_manager) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ LOG(ERROR) << "QueueStartDevice";
DCHECK(lock_time_.is_null());
device_start_request_queue_.push_back(
CaptureDeviceStartRequest(std::move(controller), session_id, params,
@@ -297,6 +298,7 @@ void VideoCaptureManager::DoStopDevice(VideoCaptureController* controller) {
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("video_and_image_capture"),
"VideoCaptureManager::DoStopDevice");
DCHECK(base::Contains(controllers_, controller));
+ LOG(ERROR) << "DoStopDevice called for stream type: " << controller->stream_type();
// If start request has not yet started processing, i.e. if it is not at the
// beginning of the queue, remove it from the queue.
@@ -327,6 +329,7 @@ void VideoCaptureManager::DoStopDevice(VideoCaptureController* controller) {
void VideoCaptureManager::ProcessDeviceStartRequestQueue() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
+ LOG(ERROR) << "ProcessDeviceStartRequestQueue";
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("video_and_image_capture"),
"VideoCaptureManager::ProcessDeviceStartRequestQueue");
auto request = device_start_request_queue_.begin();
@@ -335,7 +338,7 @@ void VideoCaptureManager::ProcessDeviceStartRequestQueue() {
scoped_refptr<VideoCaptureController> const controller =
request->controller();
-
+ LOG(ERROR) << "ProcessDeviceStartRequestQueue, controller: " << controller->device_id();
EmitLogMessage("VideoCaptureManager::ProcessDeviceStartRequestQueue", 3);
// The unit test VideoCaptureManagerTest.OpenNotExisting requires us to fail
// synchronously if the stream_type is MEDIA_DEVICE_VIDEO_CAPTURE and no
@@ -351,6 +354,7 @@ void VideoCaptureManager::ProcessDeviceStartRequestQueue() {
const media::VideoCaptureDeviceInfo* device_info =
GetDeviceInfoById(controller->device_id());
if (!device_info) {
+ LOG(ERROR) << "ProcessDeviceStartRequestQueue, device_info not found";
OnDeviceLaunchFailed(
controller.get(),
media::VideoCaptureError::
@@ -381,6 +385,7 @@ void VideoCaptureManager::ProcessDeviceStartRequestQueue() {
void VideoCaptureManager::OnDeviceLaunched(VideoCaptureController* controller) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
std::ostringstream string_stream;
+ LOG(ERROR) << "OnDeviceLaunched";
string_stream << "Launching device has succeeded. device_id = "
<< controller->device_id();
EmitLogMessage(string_stream.str(), 1);
@@ -391,7 +396,9 @@ void VideoCaptureManager::OnDeviceLaunched(VideoCaptureController* controller) {
if (blink::IsVideoDesktopCaptureMediaType(controller->stream_type())) {
const media::VideoCaptureSessionId session_id =
device_start_request_queue_.front().session_id();
+ LOG(ERROR) << "isvideodesktopcapturemediatype";
DCHECK_NE(session_id, FakeSessionId());
+ LOG(ERROR) << "maybe post desktop capture window id";
MaybePostDesktopCaptureWindowId(session_id);
}
@@ -407,7 +414,9 @@ void VideoCaptureManager::OnDeviceLaunched(VideoCaptureController* controller) {
}
}
+ LOG(ERROR) << "OnDeviceLaunched, device_start_request_queue_.pop_front";
device_start_request_queue_.pop_front();
+ LOG(ERROR) << "OnDeviceLaunched, ProcessDeviceStartRequestQueue";
ProcessDeviceStartRequestQueue();
}
@@ -467,6 +476,7 @@ void VideoCaptureManager::ConnectClient(
DCHECK_CURRENTLY_ON(BrowserThread::IO);
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("video_and_image_capture"),
"VideoCaptureManager::ConnectClient");
+ LOG(ERROR) << "ConnectClient";
{
std::ostringstream string_stream;
string_stream << "ConnectClient: session_id = " << session_id
@@ -479,6 +489,7 @@ void VideoCaptureManager::ConnectClient(
scoped_refptr<VideoCaptureController> controller =
GetOrCreateController(session_id, params);
if (!controller) {
+ LOG(ERROR) << "ConnectClient, controller not found";
std::move(done_cb).Run(nullptr);
return;
}
@@ -502,6 +513,7 @@ void VideoCaptureManager::ConnectClient(
string_stream
<< "VideoCaptureManager queueing device start for device_id = "
<< controller->device_id();
+ LOG(ERROR) << "ConnectClient, videocapturemanager queueing device start for device_id = " << controller->device_id();
EmitLogMessage(string_stream.str(), 1);
mojo::PendingRemote<video_effects::mojom::VideoEffectsProcessor>
video_effects_processor;
@@ -524,6 +536,7 @@ void VideoCaptureManager::ConnectClient(
readonly_video_effects_manager.InitWithNewPipeAndPassReceiver());
}
#endif // BUILDFLAG(ENABLE_VIDEO_EFFECTS)
+ LOG(ERROR) << "ConnectClient, videocapturemanager queueing device start for device_id = " << controller->device_id();
QueueStartDevice(session_id, controller, params,
std::move(video_effects_processor),
std::move(readonly_video_effects_manager));
diff --git a/content/public/browser/desktop_media_id.cc b/content/public/browser/desktop_media_id.cc
index b39b684ff84baaf292eef1a23b7f9fb4585023c5..55507f7a782a9472800221f1e908618a5bad2914 100644
--- a/content/public/browser/desktop_media_id.cc
+++ b/content/public/browser/desktop_media_id.cc
@@ -21,6 +21,7 @@ namespace content {
const char kScreenPrefix[] = "screen";
const char kWindowPrefix[] = "window";
+const char kNonePrefix[] = "none";
#if defined(USE_AURA) || BUILDFLAG(IS_MAC)
// static
@@ -82,6 +83,8 @@ DesktopMediaID DesktopMediaID::Parse(const std::string& str) {
type = TYPE_SCREEN;
} else if (parts[0] == kWindowPrefix) {
type = TYPE_WINDOW;
+ } else if (parts[0] == kNonePrefix) {
+ type = TYPE_NONE;
} else {
return DesktopMediaID();
}
@@ -104,6 +107,8 @@ std::string DesktopMediaID::ToString() const {
std::string prefix;
switch (type) {
case TYPE_NONE:
+ prefix = kNonePrefix;
+ break;
NOTREACHED();
case TYPE_SCREEN:
prefix = kScreenPrefix;
diff --git a/media/base/media_switches.cc b/media/base/media_switches.cc
index c458c1e87dc46cf4f92d5c4423ab837f29067aa0..1749fb96bbd0c69ad5c6377eabb4bbab12e3f7c3 100644
--- a/media/base/media_switches.cc
+++ b/media/base/media_switches.cc
@@ -356,7 +356,7 @@ BASE_FEATURE(kMacLoopbackAudioForScreenShare,
// is required to avoid recurring permission dialogs.
BASE_FEATURE(kUseSCContentSharingPicker,
"UseSCContentSharingPicker",
- base::FEATURE_DISABLED_BY_DEFAULT);
+ base::FEATURE_ENABLED_BY_DEFAULT);
#endif // BUILDFLAG(IS_MAC)
#if BUILDFLAG(IS_LINUX)
diff --git a/media/capture/video/file_video_capture_device.cc b/media/capture/video/file_video_capture_device.cc
index 5090aae198e4e0e52212eb502bb4de0475c79b04..c74887a14bcc4249e433d2afd545029d36f744bf 100644
--- a/media/capture/video/file_video_capture_device.cc
+++ b/media/capture/video/file_video_capture_device.cc
@@ -482,6 +482,7 @@ void FileVideoCaptureDevice::AllocateAndStart(
CHECK(!capture_thread_.IsRunning());
capture_thread_.Start();
+ LOG(ERROR) << "allocate and start file video capture device";
capture_thread_.task_runner()->PostTask(
FROM_HERE,
base::BindOnce(&FileVideoCaptureDevice::OnAllocateAndStart,
@@ -604,6 +605,7 @@ void FileVideoCaptureDevice::TakePhoto(TakePhotoCallback callback) {
void FileVideoCaptureDevice::OnAllocateAndStart(
const VideoCaptureParams& params,
std::unique_ptr<VideoCaptureDevice::Client> client) {
+ LOG(ERROR) << "on allocate and start file video capture device";
DCHECK(capture_thread_.task_runner()->BelongsToCurrentThread());
client_ = std::move(client);

View File

@@ -0,0 +1,130 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Keeley Hammond <khammond@slack-corp.com>
Date: Tue, 15 Apr 2025 16:34:52 -0700
Subject: fix: debug desktop capturer picture
diff --git a/content/browser/media/capture/screen_capture_kit_device_mac.mm b/content/browser/media/capture/screen_capture_kit_device_mac.mm
index fef50841f472bf3e76c171d9e106c689157adaae..1e9ffc1e097439eea731e2cff6193c5f50c984d8 100644
--- a/content/browser/media/capture/screen_capture_kit_device_mac.mm
+++ b/content/browser/media/capture/screen_capture_kit_device_mac.mm
@@ -286,6 +286,25 @@ void OnShareableContentCreated(SCShareableContent* content) {
}
}
break;
+ case DesktopMediaID::TYPE_NONE:
+ for (SCWindow* window in content.windows) {
+ LOG(ERROR) << "Inside TYPE_NONE for loop";
+ LOG(ERROR) << "source_.id: " << source_.id;
+ LOG(ERROR) << "window.windowID: " << window.windowID;
+ if (source_.id == window.windowID) {
+ LOG(ERROR) << "window.windowID: " << window.windowID;
+ filter = [[SCContentFilter alloc]
+ initWithDesktopIndependentWindow:window];
+ CGRect frame = window.frame;
+ stream_config_content_size_ = gfx::Size(frame.size);
+ if (!fullscreen_module_) {
+ fullscreen_module_ = MaybeCreateScreenCaptureKitFullscreenModule(
+ device_task_runner_, *this, window);
+ break;
+ }
+ }
+ }
+ break;
default:
NOTREACHED();
}
diff --git a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
index 2351919905fbec6c1bfe9ce59d799192a9e2e0e6..aa97cad0ca0fecc8dfc1ee44760ab1d36086785c 100644
--- a/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
+++ b/content/browser/renderer_host/media/in_process_video_capture_device_launcher.cc
@@ -104,6 +104,7 @@ void IncrementDesktopCaptureCounters(const DesktopMediaID& device_id) {
: SCREEN_CAPTURER_CREATED_WITHOUT_AUDIO);
break;
case DesktopMediaID::TYPE_WINDOW:
+ case DesktopMediaID::TYPE_NONE:
IncrementDesktopCaptureCounter(WINDOW_CAPTURER_CREATED);
break;
case DesktopMediaID::TYPE_WEB_CONTENTS:
@@ -112,8 +113,8 @@ void IncrementDesktopCaptureCounters(const DesktopMediaID& device_id) {
device_id.audio_share ? TAB_VIDEO_CAPTURER_CREATED_WITH_AUDIO
: TAB_VIDEO_CAPTURER_CREATED_WITHOUT_AUDIO);
break;
- case DesktopMediaID::TYPE_NONE:
- NOTREACHED();
+ // case DesktopMediaID::TYPE_NONE:
+ // NOTREACHED();
}
}
@@ -285,13 +286,15 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
const DesktopMediaID desktop_id = DesktopMediaID::Parse(device_id);
LOG(ERROR) << "desktop_id.is_null(): " << desktop_id.is_null();
LOG(ERROR) << "desktop_id.id: " << desktop_id.id;
- LOG(ERROR) << "DesktopMediaID::kMacOsNativePickerId: " << DesktopMediaID::kMacOsNativePickerId;
- if (desktop_id.is_null() && desktop_id.id != DesktopMediaID::kMacOsNativePickerId) {
- LOG(ERROR) << "in null case";
- start_capture_closure =
- base::BindOnce(std::move(after_start_capture_callback), nullptr);
- break;
- }
+ // TODO(Keeley): kMacOsNativePickerId seems to have been removed upstream.
+ // Reconcile this with the upstream changes.
+ // LOG(ERROR) << "DesktopMediaID::kMacOsNativePickerId: " << DesktopMediaID::kMacOsNativePickerId;
+ // if (desktop_id.is_null() && desktop_id.id != DesktopMediaID::kMacOsNativePickerId) {
+ // LOG(ERROR) << "in null case";
+ // start_capture_closure =
+ // base::BindOnce(std::move(after_start_capture_callback), nullptr);
+ // break;
+ // }
if (desktop_id.id == DesktopMediaID::kFakeId) {
start_capture_closure = base::BindOnce(
@@ -329,18 +332,16 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
#if defined(USE_AURA)
bool allow_window_id = false;
#elif BUILDFLAG(IS_MAC)
-
- bool allow_window_id =
- desktop_id.id == DesktopMediaID::kMacOsNativePickerId;
-
- LOG(ERROR) << "allow_window_id: " << allow_window_id << " desktop_id.id: " << desktop_id.id;
+ // bool allow_window_id =
+ // desktop_id.id == DesktopMediaID::kMacOsNativePickerId;
+ // LOG(ERROR) << "allow_window_id: " << allow_window_id << " desktop_id.id: " << desktop_id.id;
#endif
#if defined(USE_AURA) || BUILDFLAG(IS_MAC)
- LOG(ERROR) << "in if block";
- if (!allow_window_id &&
- desktop_id.window_id != DesktopMediaID::kNullId) {
- LOG(ERROR) << "allow_window_id: " << allow_window_id << " desktop_id.window_id: " << desktop_id.window_id;
+ // if (!allow_window_id &&
+ // desktop_id.window_id != DesktopMediaID::kNullId) {
+ if (desktop_id.window_id != DesktopMediaID::kNullId) {
+ // LOG(ERROR) << "allow_window_id: " << allow_window_id << " desktop_id.window_id: " << desktop_id.window_id;
// For the other capturers, when a bug reports the type of capture it's
// easy enough to determine which capturer was used, but it's a little
// fuzzier with window capture.
@@ -525,7 +526,7 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread(
ReceiveDeviceCallback result_callback) {
DCHECK(device_task_runner_->BelongsToCurrentThread());
LOG(INFO) << "DO START DESKTOP CAPTURE ON DEVICE THREAD " << desktop_id.id;
- DCHECK(!desktop_id.is_null() || desktop_id.id == DesktopMediaID::kMacOsNativePickerId);
+ // DCHECK(!desktop_id.is_null() || desktop_id.id == DesktopMediaID::kMacOsNativePickerId);
std::unique_ptr<media::VideoCaptureDevice> video_capture_device;
DesktopCaptureImplementation implementation =
diff --git a/content/browser/renderer_host/media/video_capture_manager.cc b/content/browser/renderer_host/media/video_capture_manager.cc
index bd11a0fcdc084da00407c80e4ee229a130fdedc8..74d9ce9facea9cda90073ca6b70e8c4be3b62f6f 100644
--- a/content/browser/renderer_host/media/video_capture_manager.cc
+++ b/content/browser/renderer_host/media/video_capture_manager.cc
@@ -920,6 +920,8 @@ void VideoCaptureManager::DestroyControllerIfNoClients(
// closed.
CloseNativeScreenCapturePicker(
DesktopMediaID::Parse(controller->device_id()));
+ LOG(ERROR) << "Closing native screen capture picker";
+ LOG(ERROR) << "VideoCaptureManager: " << string_stream.str();
// The VideoCaptureController is removed from |controllers_| immediately.
// The controller is deleted immediately, and the device is freed

View File

@@ -0,0 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Sat, 1 Mar 2025 05:11:41 +0900
Subject: fix: enable __wrap_iter in string_view and array
Refs https://github.com/electron/electron/issues/45810#issuecomment-2691417213
Patch can be removed when build_make_libcxx_abi_unstable_false_for_electron.patch is removed.
diff --git a/buildtools/third_party/libc++/__config_site b/buildtools/third_party/libc++/__config_site
index e240ff6fff94a6cebf8662996712fe7eb22e5fff..ddf1693002aa171b3d91aa4ef08f5b360e4adddc 100644
--- a/buildtools/third_party/libc++/__config_site
+++ b/buildtools/third_party/libc++/__config_site
@@ -19,6 +19,8 @@
#define _LIBCPP_ABI_NAMESPACE __Cr
#define _LIBCPP_ABI_VERSION 1
+#define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY
+#define _LIBCPP_ABI_USE_WRAP_ITER_IN_STD_STRING_VIEW
#define _LIBCPP_ABI_FORCE_ITANIUM 0
#define _LIBCPP_ABI_FORCE_MICROSOFT 0

View File

@@ -1,51 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Calvin Watford <watfordcalvin@gmail.com>
Date: Wed, 5 Mar 2025 15:26:28 -0700
Subject: fix: multiple ScopedPumpMessagesInPrivateModes instances
Context: When swapping `Menu.popup` to use `ui::ShowContextMenu`, we
found that its use of `ScopedPumpMessagesInPrivateModes` may potentially
be used multiple times simultaneously. This class was designed to work
with only one global instance.
This patch adds a global reference count to keep track of
`ScopedPumpMessagesInPrivateModes` instances and gate its
enable/disable behavior on this reference count.
diff --git a/base/message_loop/message_pump_apple.mm b/base/message_loop/message_pump_apple.mm
index 52ed68ac3150bdeef3c5032f3f5f7df3d5aaac51..1658aece3e8fbcef89944a849e311f7949a68de9 100644
--- a/base/message_loop/message_pump_apple.mm
+++ b/base/message_loop/message_pump_apple.mm
@@ -760,20 +760,29 @@ explicit OptionalAutoreleasePool(MessagePumpCFRunLoopBase* pump) {
#else
+static int g_private_mode_ref_count = 0;
+
ScopedPumpMessagesInPrivateModes::ScopedPumpMessagesInPrivateModes() {
DCHECK(g_app_pump);
- DCHECK_EQ(kNSApplicationModalSafeModeMask, g_app_pump->GetModeMask());
// Pumping events in private runloop modes is known to interact badly with
// app modal windows like NSAlert.
if (NSApp.modalWindow) {
return;
}
- g_app_pump->SetModeMask(kAllModesMask);
+
+ g_private_mode_ref_count += 1;
+ if (g_private_mode_ref_count == 1) {
+ g_app_pump->SetModeMask(kAllModesMask);
+ }
}
ScopedPumpMessagesInPrivateModes::~ScopedPumpMessagesInPrivateModes() {
DCHECK(g_app_pump);
- g_app_pump->SetModeMask(kNSApplicationModalSafeModeMask);
+ DCHECK(g_private_mode_ref_count > 0);
+ g_private_mode_ref_count -= 1;
+ if (g_private_mode_ref_count == 0) {
+ g_app_pump->SetModeMask(kNSApplicationModalSafeModeMask);
+ }
}
int ScopedPumpMessagesInPrivateModes::GetModeMaskForTest() {

View File

@@ -0,0 +1,40 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20L=C3=B6nnhager?= <dv.lnh.d@gmail.com>
Date: Fri, 17 Jan 2025 14:30:48 +0100
Subject: Ignore parse errors for PKEY_AppUserModel_ToastActivatorCLSID
Some shortcuts store this as a string UUID as opposed to VT_CLSID,
hitting NOTREACHED() and sometimes breaking parsing in Electron.
Ignore this error instead.
Bug: N/A
Change-Id: I9fc472212b2d3afac2c8e18a2159bc2d50bbdf98
diff --git a/AUTHORS b/AUTHORS
index b55c6916e97a7c8e317145f5239a34d8abca810e..dbd924a91a8fca8ff9d85bf6addcdb5a7b17ca3a 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -341,6 +341,7 @@ David Futcher <david.mike.futcher@gmail.com>
David Jin <davidjin@amazon.com>
David Lechner <david@pybricks.com>
David Leen <davileen@amazon.com>
+David Lönnhager <dv.lnh.d@gmail.com>
David Manouchehri <david@davidmanouchehri.com>
David McAllister <mcdavid@amazon.com>
David Michael Barr <david.barr@samsung.com>
diff --git a/base/win/shortcut.cc b/base/win/shortcut.cc
index 967e130e823f41c402411dfadb53b805e8a8c92b..3a9df7f31861ca69168fd24513ee554d0984798d 100644
--- a/base/win/shortcut.cc
+++ b/base/win/shortcut.cc
@@ -356,8 +356,9 @@ bool ResolveShortcutProperties(const FilePath& shortcut_path,
*(pv_toast_activator_clsid.get().puuid));
break;
default:
- NOTREACHED() << "Unexpected variant type: "
- << pv_toast_activator_clsid.get().vt;
+ // Shortcuts may use strings to represent the CLSID. This case is
+ // ignored.
+ break;
}
}
}

View File

@@ -1,45 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20L=C3=B6nnhager?= <dv.lnh.d@gmail.com>
Date: Fri, 17 Jan 2025 14:30:48 +0100
Subject: Ignore parse errors in ResolveShortcutProperties
Some shortcuts store this as a string UUID as opposed to VT_CLSID,
hitting NOTREACHED() and sometimes breaking parsing in Electron.
Ignore this error instead.
diff --git a/base/win/shortcut.cc b/base/win/shortcut.cc
index 967e130e823f41c402411dfadb53b805e8a8c92b..c1cc95fa8993cc5bdab422710934fb6217272b96 100644
--- a/base/win/shortcut.cc
+++ b/base/win/shortcut.cc
@@ -317,7 +317,8 @@ bool ResolveShortcutProperties(const FilePath& shortcut_path,
break;
}
default: {
- NOTREACHED() << "Unexpected variant type: " << pv_app_id.get().vt;
+ LOG(WARNING) << "Unexpected variant type: " << pv_app_id.get().vt;
+ break;
}
}
}
@@ -336,7 +337,8 @@ bool ResolveShortcutProperties(const FilePath& shortcut_path,
properties->set_dual_mode(pv_dual_mode.get().boolVal == VARIANT_TRUE);
break;
default:
- NOTREACHED() << "Unexpected variant type: " << pv_dual_mode.get().vt;
+ LOG(WARNING) << "Unexpected variant type: " << pv_dual_mode.get().vt;
+ break;
}
}
@@ -356,8 +358,9 @@ bool ResolveShortcutProperties(const FilePath& shortcut_path,
*(pv_toast_activator_clsid.get().puuid));
break;
default:
- NOTREACHED() << "Unexpected variant type: "
- << pv_toast_activator_clsid.get().vt;
+ LOG(INFO) << "Unexpected variant type: "
+ << pv_toast_activator_clsid.get().vt;
+ break;
}
}
}

View File

@@ -47,6 +47,3 @@ chore_add_createexternalizabletwobytestring_to_globals.patch
feat_add_oom_error_callback_in_node_isolatesettings.patch
fix_-wnonnull_warning.patch
refactor_attach_cppgc_heap_on_v8_isolate_creation.patch
fix_ensure_traverseparent_bails_on_resource_path_exit.patch
fix_expose_readfilesync_override_for_modules.patch
zlib_fix_pointer_alignment.patch

View File

@@ -1,68 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Tue, 18 Mar 2025 10:41:27 +0100
Subject: fix: ensure TraverseParent bails on resource path exit
Electron's security model requires that we do not traverse outside of the
resource path. This commit ensures that the TraverseParent function
bails out if the parent path is outside of the resource path.
diff --git a/src/node_modules.cc b/src/node_modules.cc
index 210a01d24e11764dc9fc37a77b354f11383693f8..4e9f70a1c41b44d2a1863b778d4f1e37279178d9 100644
--- a/src/node_modules.cc
+++ b/src/node_modules.cc
@@ -290,8 +290,41 @@ const BindingData::PackageConfig* BindingData::TraverseParent(
Realm* realm, const std::filesystem::path& check_path) {
std::filesystem::path current_path = check_path;
auto env = realm->env();
+ Isolate* isolate = env->isolate();
const bool is_permissions_enabled = env->permission()->enabled();
+ // Get the resources path with trailing slash.
+ std::string resources_path;
+ {
+ HandleScope handle_scope(isolate);
+ Local<Value> resources_path_value;
+ Local<Object> process_object = env->process_object();
+
+ Local<String> resources_path_key =
+ String::NewFromUtf8Literal(isolate, "resourcesPath");
+ if (process_object->Get(env->context(), resources_path_key)
+ .ToLocal(&resources_path_value) &&
+ resources_path_value->IsString()) {
+ resources_path = *String::Utf8Value(isolate, resources_path_value);
+ if (!resources_path.empty() && !resources_path.ends_with(kPathSeparator)) {
+ resources_path += kPathSeparator;
+ }
+ }
+ }
+
+ auto starts_with = [](const std::string& str, const std::string& prefix) -> bool {
+ if (prefix.size() > str.size()) return false;
+ return std::equal(
+ prefix.begin(), prefix.end(), str.begin(),
+ [](char a, char b) {
+ return std::tolower(static_cast<unsigned char>(a)) ==
+ std::tolower(static_cast<unsigned char>(b));
+ });
+ };
+
+ bool did_original_path_start_with_resources_path = starts_with(check_path.
+ generic_string(), resources_path);
+
do {
current_path = current_path.parent_path();
@@ -310,6 +343,12 @@ const BindingData::PackageConfig* BindingData::TraverseParent(
return nullptr;
}
+ // If current path is outside the resources path, bail.
+ if (did_original_path_start_with_resources_path &&
+ !starts_with(current_path.generic_string(), resources_path)) {
+ return nullptr;
+ }
+
// Check if the path ends with `/node_modules`
if (current_path.generic_string().ends_with("/node_modules")) {
return nullptr;

View File

@@ -1,123 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Fedor Indutny <indutny@signal.org>
Date: Mon, 31 Mar 2025 11:21:29 -0700
Subject: fix: expose ReadFileSync override for modules
To avoid copying out `package.json` files out of the ASAR file we need
an API override to replace the native `ReadFileSync` in the `modules`
binding.
diff --git a/src/env_properties.h b/src/env_properties.h
index 9f89823170782242093bc5ee0df6a2a2ef5b919f..b9374ee1acceb3d0aab51c6c5ae6a79be1cc71a9 100644
--- a/src/env_properties.h
+++ b/src/env_properties.h
@@ -478,6 +478,7 @@
V(maybe_cache_generated_source_map, v8::Function) \
V(messaging_deserialize_create_object, v8::Function) \
V(message_port, v8::Object) \
+ V(modules_read_file_sync, v8::Function) \
V(builtin_module_require, v8::Function) \
V(performance_entry_callback, v8::Function) \
V(prepare_stack_trace_callback, v8::Function) \
diff --git a/src/node_modules.cc b/src/node_modules.cc
index 4e9f70a1c41b44d2a1863b778d4f1e37279178d9..c56a32885b8debbd5b95a2c11f3838d4088e05ac 100644
--- a/src/node_modules.cc
+++ b/src/node_modules.cc
@@ -21,6 +21,7 @@ namespace modules {
using v8::Array;
using v8::Context;
+using v8::Function;
using v8::FunctionCallbackInfo;
using v8::HandleScope;
using v8::Isolate;
@@ -88,6 +89,7 @@ Local<Array> BindingData::PackageConfig::Serialize(Realm* realm) const {
const BindingData::PackageConfig* BindingData::GetPackageJSON(
Realm* realm, std::string_view path, ErrorContext* error_context) {
+ auto isolate = realm->isolate();
auto binding_data = realm->GetBindingData<BindingData>();
auto cache_entry = binding_data->package_configs_.find(path.data());
@@ -97,8 +99,36 @@ const BindingData::PackageConfig* BindingData::GetPackageJSON(
PackageConfig package_config{};
package_config.file_path = path;
+
+ Local<Function> modules_read_file_sync = realm->modules_read_file_sync();
+
+ int read_err;
// No need to exclude BOM since simdjson will skip it.
- if (ReadFileSync(&package_config.raw_json, path.data()) < 0) {
+ if (modules_read_file_sync.IsEmpty()) {
+ read_err = ReadFileSync(&package_config.raw_json, path.data());
+ } else {
+ Local<Value> args[] = {
+ v8::String::NewFromUtf8(isolate, path.data()).ToLocalChecked(),
+ };
+ Local<Value> result = modules_read_file_sync->Call(
+ realm->context(),
+ Undefined(isolate),
+ arraysize(args),
+ args).ToLocalChecked();
+
+ if (result->IsUndefined()) {
+ // Fallback
+ read_err = ReadFileSync(&package_config.raw_json, path.data());
+ } else if (result->IsFalse()) {
+ // Not found
+ read_err = -1;
+ } else {
+ BufferValue data(isolate, result);
+ package_config.raw_json = data.ToString();
+ read_err = 0;
+ }
+ }
+ if (read_err < 0) {
return nullptr;
}
// In some systems, std::string is annotated to generate an
@@ -248,6 +278,12 @@ const BindingData::PackageConfig* BindingData::GetPackageJSON(
return &cached.first->second;
}
+void BindingData::OverrideReadFileSync(const FunctionCallbackInfo<Value>& args) {
+ Realm* realm = Realm::GetCurrent(args);
+ CHECK(args[0]->IsFunction());
+ realm->set_modules_read_file_sync(args[0].As<Function>());
+}
+
void BindingData::ReadPackageJSON(const FunctionCallbackInfo<Value>& args) {
CHECK_GE(args.Length(), 1); // path, [is_esm, base, specifier]
CHECK(args[0]->IsString()); // path
@@ -556,6 +592,8 @@ void GetCompileCacheDir(const FunctionCallbackInfo<Value>& args) {
void BindingData::CreatePerIsolateProperties(IsolateData* isolate_data,
Local<ObjectTemplate> target) {
Isolate* isolate = isolate_data->isolate();
+ SetMethod(isolate, target, "overrideReadFileSync", OverrideReadFileSync);
+
SetMethod(isolate, target, "readPackageJSON", ReadPackageJSON);
SetMethod(isolate,
target,
@@ -595,6 +633,8 @@ void BindingData::CreatePerContextProperties(Local<Object> target,
void BindingData::RegisterExternalReferences(
ExternalReferenceRegistry* registry) {
+ registry->Register(OverrideReadFileSync);
+
registry->Register(ReadPackageJSON);
registry->Register(GetNearestParentPackageJSONType);
registry->Register(GetNearestParentPackageJSON);
diff --git a/src/node_modules.h b/src/node_modules.h
index 17909b2270454b3275c7bf2e50d4b9b35673ecc8..3d5b0e3ac65524adfe221bfd6f85360dee1f0bee 100644
--- a/src/node_modules.h
+++ b/src/node_modules.h
@@ -54,6 +54,8 @@ class BindingData : public SnapshotableObject {
SET_SELF_SIZE(BindingData)
SET_MEMORY_INFO_NAME(BindingData)
+ static void OverrideReadFileSync(
+ const v8::FunctionCallbackInfo<v8::Value>& args);
static void ReadPackageJSON(const v8::FunctionCallbackInfo<v8::Value>& args);
static void GetNearestParentPackageJSON(
const v8::FunctionCallbackInfo<v8::Value>& args);

View File

@@ -165,20 +165,10 @@ index 4119ac1b002681d39711eac810ca2fcc2702ffc7..790347056cde949ffe6cf8498a7eca0c
ExitCode NodeMainInstance::Run() {
diff --git a/src/node_worker.cc b/src/node_worker.cc
index 1fc3774948dae3c0aae7d2aef563e18ecd4243a3..9d35cbf3dff538f38e8d5b8660d40c1fbaa56474 100644
index 1fc3774948dae3c0aae7d2aef563e18ecd4243a3..a610ee24ff18bddc3849aec3a43c2037b9ab5d53 100644
--- a/src/node_worker.cc
+++ b/src/node_worker.cc
@@ -162,6 +162,9 @@ class WorkerThreadData {
SetIsolateCreateParamsForNode(&params);
w->UpdateResourceConstraints(&params.constraints);
params.array_buffer_allocator_shared = allocator;
+ params.cpp_heap =
+ v8::CppHeap::Create(w->platform_, v8::CppHeapCreateParams{{}})
+ .release();
Isolate* isolate =
NewIsolate(&params, &loop_, w->platform_, w->snapshot_data());
if (isolate == nullptr) {
@@ -230,13 +233,8 @@ class WorkerThreadData {
@@ -230,13 +230,8 @@ class WorkerThreadData {
*static_cast<bool*>(data) = true;
}, &platform_finished);

View File

@@ -1,50 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jeroen Hofstee <jhofstee@victronenergy.com>
Date: Tue, 1 Apr 2025 20:09:31 +0000
Subject: zlib: fix pointer alignment
The function AllocForBrotli prefixes the allocated memory with its
size, and returns a pointer to the region after it. This pointer can
however no longer be suitably aligned. Correct this by allocating
the maximum of the the size of the size_t and the max alignment.
On Arm 32bits the size_t is 4 bytes long, but the alignment is 8 for
some NEON instructions. When Brotli is compiled with optimizations
enabled newer GCC versions will use the NEON instructions and trigger
a bus error killing node.
see https://github.com/google/brotli/issues/1159
diff --git a/src/node_zlib.cc b/src/node_zlib.cc
index 90307cd4984ae5aa55386f2980ad9cd540322dfd..6f12b5034d1a98da50c064cf2cfdf12fc88137eb 100644
--- a/src/node_zlib.cc
+++ b/src/node_zlib.cc
@@ -493,7 +493,8 @@ class CompressionStream : public AsyncWrap, public ThreadPoolWork {
}
static void* AllocForBrotli(void* data, size_t size) {
- size += sizeof(size_t);
+ constexpr size_t offset = std::max(sizeof(size_t), alignof(max_align_t));
+ size += offset;
CompressionStream* ctx = static_cast<CompressionStream*>(data);
char* memory = UncheckedMalloc(size);
if (memory == nullptr) [[unlikely]] {
@@ -502,7 +503,7 @@ class CompressionStream : public AsyncWrap, public ThreadPoolWork {
*reinterpret_cast<size_t*>(memory) = size;
ctx->unreported_allocations_.fetch_add(size,
std::memory_order_relaxed);
- return memory + sizeof(size_t);
+ return memory + offset;
}
static void FreeForZlib(void* data, void* pointer) {
@@ -510,7 +511,8 @@ class CompressionStream : public AsyncWrap, public ThreadPoolWork {
return;
}
CompressionStream* ctx = static_cast<CompressionStream*>(data);
- char* real_pointer = static_cast<char*>(pointer) - sizeof(size_t);
+ constexpr size_t offset = std::max(sizeof(size_t), alignof(max_align_t));
+ char* real_pointer = static_cast<char*>(pointer) - offset;
size_t real_size = *reinterpret_cast<size_t*>(real_pointer);
ctx->unreported_allocations_.fetch_sub(real_size,
std::memory_order_relaxed);

View File

@@ -1,3 +1,2 @@
chore_allow_customizing_microtask_policy_per_context.patch
deps_add_v8_object_setinternalfieldfornodecore.patch
revert_api_delete_deprecated_attachcppheap_and_detachcppheap.patch

View File

@@ -1,137 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Charles Kerr <charles@charleskerr.com>
Date: Thu, 6 Mar 2025 14:31:19 -0600
Subject: Revert "[api] Delete deprecated AttachCppHeap and DetachCppHeap"
Restore this API because Node.js needs it.
This patch can be removed after an upstream fix lands in Node.js,
e.g. in https://github.com/nodejs/node-v8/tree/canary
diff --git a/include/v8-isolate.h b/include/v8-isolate.h
index 97f1030dd2ca47ca4b58ac64e2e11e615bc46130..24ef6b5e0af63179e557b9896134838e112c59db 100644
--- a/include/v8-isolate.h
+++ b/include/v8-isolate.h
@@ -1172,6 +1172,28 @@ class V8_EXPORT Isolate {
*/
void SetEmbedderRootsHandler(EmbedderRootsHandler* handler);
+ /**
+ * Attaches a managed C++ heap as an extension to the JavaScript heap. The
+ * embedder maintains ownership of the CppHeap. At most one C++ heap can be
+ * attached to V8.
+ *
+ * Multi-threaded use requires the use of v8::Locker/v8::Unlocker, see
+ * CppHeap.
+ *
+ * If a CppHeap is set via CreateParams, then this call is a noop.
+ */
+ V8_DEPRECATED("Set the heap on Isolate creation using CreateParams instead.")
+ void AttachCppHeap(CppHeap*);
+
+ /**
+ * Detaches a managed C++ heap if one was attached using `AttachCppHeap()`.
+ *
+ * If a CppHeap is set via CreateParams, then this call is a noop.
+ */
+ V8_DEPRECATED(
+ "The CppHeap gets detached automatically during Isolate tear down.")
+ void DetachCppHeap();
+
using ReleaseCppHeapCallback = void (*)(std::unique_ptr<CppHeap>);
/**
@@ -1219,7 +1241,6 @@ class V8_EXPORT Isolate {
class V8_DEPRECATED("AtomicsWaitWakeHandle is unused and will be removed.")
#endif
V8_EXPORT AtomicsWaitWakeHandle {
-
public:
/**
* Stop this `Atomics.wait()` call and call the |AtomicsWaitCallback|
diff --git a/src/api/api.cc b/src/api/api.cc
index f4ed96bf45183c8a7453ebac994904c2ea7d9707..59327d4619661a138c407b468794e6a0f60a91e3 100644
--- a/src/api/api.cc
+++ b/src/api/api.cc
@@ -9878,6 +9878,16 @@ void Isolate::SetEmbedderRootsHandler(EmbedderRootsHandler* handler) {
i_isolate->heap()->SetEmbedderRootsHandler(handler);
}
+void Isolate::AttachCppHeap(CppHeap* cpp_heap) {
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
+ i_isolate->heap()->AttachCppHeap(cpp_heap);
+}
+
+void Isolate::DetachCppHeap() {
+ i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(this);
+ i_isolate->heap()->DetachCppHeap();
+}
+
CppHeap* Isolate::GetCppHeap() const {
const i::Isolate* i_isolate = reinterpret_cast<const i::Isolate*>(this);
return i_isolate->heap()->cpp_heap();
diff --git a/src/heap/cppgc-js/cpp-heap.cc b/src/heap/cppgc-js/cpp-heap.cc
index a03e4d6fdb8acb2623434f08b1f63ff86cb1e77a..756e5f89a3b947761c01fc3cc59c654eb99836d7 100644
--- a/src/heap/cppgc-js/cpp-heap.cc
+++ b/src/heap/cppgc-js/cpp-heap.cc
@@ -513,6 +513,11 @@ CppHeap::CppHeap(
}
CppHeap::~CppHeap() {
+ if (isolate_) {
+ // TODO(ahaas): Delete this code once `v8::Isolate::DetachCppHeap` has been
+ // deleted.
+ isolate_->heap()->DetachCppHeap();
+ }
Terminate();
}
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index 3823f26158a12d93636bb3376065ba7ce9d8d4d6..86cdcc8c3c4c09134db8d89f93fd3405cabcf385 100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -6070,6 +6070,21 @@ void Heap::AttachCppHeap(v8::CppHeap* cpp_heap) {
cpp_heap_ = cpp_heap;
}
+void Heap::DetachCppHeap() {
+ // The API function should be a noop in case a CppHeap was passed on Isolate
+ // creation.
+ if (owning_cpp_heap_) {
+ return;
+ }
+
+ // The CppHeap may have been detached already.
+ if (!cpp_heap_) return;
+
+ CppHeap::From(cpp_heap_)->StartDetachingIsolate();
+ CppHeap::From(cpp_heap_)->DetachIsolate();
+ cpp_heap_ = nullptr;
+}
+
std::optional<StackState> Heap::overridden_stack_state() const {
if (!embedder_stack_state_origin_) return {};
return embedder_stack_state_;
diff --git a/src/heap/heap.h b/src/heap/heap.h
index 645340bda0137810497a9885b066e500b51428d4..b83def4691341c595dfba0b4f996345849ead640 100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -1110,6 +1110,9 @@ class Heap final {
// Unified heap (C++) support. ===============================================
// ===========================================================================
+ V8_EXPORT_PRIVATE void AttachCppHeap(v8::CppHeap* cpp_heap);
+ V8_EXPORT_PRIVATE void DetachCppHeap();
+
v8::CppHeap* cpp_heap() const { return cpp_heap_; }
std::optional<StackState> overridden_stack_state() const;
@@ -1651,8 +1654,6 @@ class Heap final {
private:
class AllocationTrackerForDebugging;
- void AttachCppHeap(v8::CppHeap* cpp_heap);
-
using ExternalStringTableUpdaterCallback =
Tagged<String> (*)(Heap* heap, FullObjectSlot pointer);

View File

@@ -1 +1,3 @@
fix_handle_pipewire_capturer_initialization_and_management.patch
fix_fallback_to_x11_capturer_on_wayland.patch
fix_mark_pipewire_capturer_as_failed_after_session_is_closed.patch
fix_check_pipewire_init_before_creating_generic_capturer.patch

View File

@@ -0,0 +1,23 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Athul Iddya <athul@iddya.com>
Date: Tue, 12 Sep 2023 22:19:46 -0700
Subject: fix: check PipeWire init before creating generic capturer
Check if PipeWire can be initialized before creating generic capturer.
This harmonizes the conditions with the ones used in Linux
implementations of DesktopCapturer::CreateRawScreenCapturer and
DesktopCapturer::CreateRawWindowCapturer.
diff --git a/modules/desktop_capture/desktop_capturer.cc b/modules/desktop_capture/desktop_capturer.cc
index 7fd0fc31d81bf4d5eca5f8aa7106388ea4c518e4..51dde063a78be7aade1953fbee8bb2db71b72ce5 100644
--- a/modules/desktop_capture/desktop_capturer.cc
+++ b/modules/desktop_capture/desktop_capturer.cc
@@ -113,7 +113,7 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateGenericCapturer(
std::unique_ptr<DesktopCapturer> capturer;
#if defined(WEBRTC_USE_PIPEWIRE)
- if (options.allow_pipewire() && DesktopCapturer::IsRunningUnderWayland()) {
+ if (options.allow_pipewire() && BaseCapturerPipeWire::IsSupported()) {
capturer = std::make_unique<BaseCapturerPipeWire>(
options, CaptureType::kAnyScreenContent);
}

View File

@@ -0,0 +1,58 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: VerteDinde <keeleymhammond@gmail.com>
Date: Sun, 5 Mar 2023 21:04:37 -0800
Subject: fix: fallback to X11 capturer on Wayland
CL: https://webrtc-review.googlesource.com/c/src/+/279163
Desktop Capturer behaves inconsistently on Wayland. PipeWire does not
always successfully start; if it does not, we return a nullptr rather
than falling back on the X11 capturer, crashing the application.
If the X11 capturer is enabled, we should at minimum try to fallback
to X11 for desktop capturer. This patch re-enables that fallback,
which was previously default behavior.
This patch can be removed when 1) this fix is upstreamed, or 2) the
stability of PipeWire initialization is improved upstream.
Patch_Filename: fix_fallback_to_x11_desktop_capturer_wayland.patch
diff --git a/modules/desktop_capture/screen_capturer_linux.cc b/modules/desktop_capture/screen_capturer_linux.cc
index 44993837e8bbd84a11ec9d187349a95f83258910..cd9f8b0be6a19d057fe9150382fb72bc4032b343 100644
--- a/modules/desktop_capture/screen_capturer_linux.cc
+++ b/modules/desktop_capture/screen_capturer_linux.cc
@@ -34,11 +34,10 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
#endif // defined(WEBRTC_USE_PIPEWIRE)
#if defined(WEBRTC_USE_X11)
- if (!DesktopCapturer::IsRunningUnderWayland())
- return ScreenCapturerX11::CreateRawScreenCapturer(options);
-#endif // defined(WEBRTC_USE_X11)
-
+ return ScreenCapturerX11::CreateRawScreenCapturer(options);
+#else
return nullptr;
+#endif // defined(WEBRTC_USE_X11)
}
} // namespace webrtc
diff --git a/modules/desktop_capture/window_capturer_linux.cc b/modules/desktop_capture/window_capturer_linux.cc
index 4205bf9bc0eede48cdc39353c77ceb6e7529fd51..785dc01a1911fd027401b1461223668333e05558 100644
--- a/modules/desktop_capture/window_capturer_linux.cc
+++ b/modules/desktop_capture/window_capturer_linux.cc
@@ -34,11 +34,10 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
#endif // defined(WEBRTC_USE_PIPEWIRE)
#if defined(WEBRTC_USE_X11)
- if (!DesktopCapturer::IsRunningUnderWayland())
- return WindowCapturerX11::CreateRawWindowCapturer(options);
-#endif // defined(WEBRTC_USE_X11)
-
+ return WindowCapturerX11::CreateRawWindowCapturer(options);
+#else
return nullptr;
+#endif // defined(WEBRTC_USE_X11)
}
} // namespace webrtc

View File

@@ -1,100 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Athul Iddya <athul@iddya.com>
Date: Tue, 12 Sep 2023 22:19:46 -0700
Subject: fix: Handle PipeWire capturer initialization and management
This patch handles several fixes related to PipeWire capturer initialization
and management.
1. Mark PipeWire capturer as failed after session is closed
After a PipeWire screencast session is successfully started, the
consumer is expected to keep calling CaptureFrame() from the
DesktopCapturer interface in a loop to pull frames. A PipeWire
screencast session can be closed by the server on user action. Once the
session is closed, there's no point in calling CaptureFrame() again as
the capture has to be restarted. Inform the caller of the failure by
returning Result::ERROR_PERMANENT on the next invocation of
CaptureFrame().
2. Check PipeWire init before creating generic capturer
Check if PipeWire can be initialized before creating generic capturer.
This harmonizes the conditions with the ones used in Linux
implementations of DesktopCapturer::CreateRawScreenCapturer and
DesktopCapturer::CreateRawWindowCapturer.
3. Establishes fallback to X11 capturer when PipeWire fails to start
CL: https://webrtc-review.googlesource.com/c/src/+/279163
Desktop Capturer behaves inconsistently on Wayland. PipeWire does not
always successfully start; if it does not, we return a nullptr rather
than falling back on the X11 capturer, crashing the application. If the
X11 capturer is enabled, we should at minimum try to fallback to X11
for desktop capturer. This change re-enables that fallback, which was
previously default behavior.
diff --git a/modules/desktop_capture/desktop_capturer.cc b/modules/desktop_capture/desktop_capturer.cc
index 7fd0fc31d81bf4d5eca5f8aa7106388ea4c518e4..51dde063a78be7aade1953fbee8bb2db71b72ce5 100644
--- a/modules/desktop_capture/desktop_capturer.cc
+++ b/modules/desktop_capture/desktop_capturer.cc
@@ -113,7 +113,7 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateGenericCapturer(
std::unique_ptr<DesktopCapturer> capturer;
#if defined(WEBRTC_USE_PIPEWIRE)
- if (options.allow_pipewire() && DesktopCapturer::IsRunningUnderWayland()) {
+ if (options.allow_pipewire() && BaseCapturerPipeWire::IsSupported()) {
capturer = std::make_unique<BaseCapturerPipeWire>(
options, CaptureType::kAnyScreenContent);
}
diff --git a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc
index 81caa9bd2d97ec73120c07c17d7290b2c3c5d598..3ba5267bf5c7de420131b2c14fcadffd1f5b1326 100644
--- a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc
+++ b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc
@@ -111,6 +111,7 @@ void BaseCapturerPipeWire::OnScreenCastRequestResult(RequestResponse result,
void BaseCapturerPipeWire::OnScreenCastSessionClosed() {
if (!capturer_failed_) {
options_.screencast_stream()->StopScreenCastStream();
+ capturer_failed_ = true;
}
capturer_failed_ = true;
}
diff --git a/modules/desktop_capture/screen_capturer_linux.cc b/modules/desktop_capture/screen_capturer_linux.cc
index 44993837e8bbd84a11ec9d187349a95f83258910..cd9f8b0be6a19d057fe9150382fb72bc4032b343 100644
--- a/modules/desktop_capture/screen_capturer_linux.cc
+++ b/modules/desktop_capture/screen_capturer_linux.cc
@@ -34,11 +34,10 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawScreenCapturer(
#endif // defined(WEBRTC_USE_PIPEWIRE)
#if defined(WEBRTC_USE_X11)
- if (!DesktopCapturer::IsRunningUnderWayland())
- return ScreenCapturerX11::CreateRawScreenCapturer(options);
-#endif // defined(WEBRTC_USE_X11)
-
+ return ScreenCapturerX11::CreateRawScreenCapturer(options);
+#else
return nullptr;
+#endif // defined(WEBRTC_USE_X11)
}
} // namespace webrtc
diff --git a/modules/desktop_capture/window_capturer_linux.cc b/modules/desktop_capture/window_capturer_linux.cc
index 4205bf9bc0eede48cdc39353c77ceb6e7529fd51..785dc01a1911fd027401b1461223668333e05558 100644
--- a/modules/desktop_capture/window_capturer_linux.cc
+++ b/modules/desktop_capture/window_capturer_linux.cc
@@ -34,11 +34,10 @@ std::unique_ptr<DesktopCapturer> DesktopCapturer::CreateRawWindowCapturer(
#endif // defined(WEBRTC_USE_PIPEWIRE)
#if defined(WEBRTC_USE_X11)
- if (!DesktopCapturer::IsRunningUnderWayland())
- return WindowCapturerX11::CreateRawWindowCapturer(options);
-#endif // defined(WEBRTC_USE_X11)
-
+ return WindowCapturerX11::CreateRawWindowCapturer(options);
+#else
return nullptr;
+#endif // defined(WEBRTC_USE_X11)
}
} // namespace webrtc

View File

@@ -0,0 +1,26 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Athul Iddya <athul@iddya.com>
Date: Sat, 22 Jul 2023 11:11:01 -0700
Subject: fix: mark PipeWire capturer as failed after session is closed
After a PipeWire screencast session is successfully started, the
consumer is expected to keep calling CaptureFrame() from the
DesktopCapturer interface in a loop to pull frames. A PipeWire
screencast session can be closed by the server on user action. Once the
session is closed, there's no point in calling CaptureFrame() again as
the capture has to be restarted. Inform the caller of the failure by
returning Result::ERROR_PERMANENT on the next invocation of
CaptureFrame().
diff --git a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc
index 81caa9bd2d97ec73120c07c17d7290b2c3c5d598..3ba5267bf5c7de420131b2c14fcadffd1f5b1326 100644
--- a/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc
+++ b/modules/desktop_capture/linux/wayland/base_capturer_pipewire.cc
@@ -111,6 +111,7 @@ void BaseCapturerPipeWire::OnScreenCastRequestResult(RequestResponse result,
void BaseCapturerPipeWire::OnScreenCastSessionClosed() {
if (!capturer_failed_) {
options_.screencast_stream()->StopScreenCastStream();
+ capturer_failed_ = true;
}
capturer_failed_ = true;
}

View File

@@ -90,10 +90,7 @@
#if BUILDFLAG(IS_MAC)
#include <CoreFoundation/CoreFoundation.h>
#include "base/no_destructor.h"
#include "content/browser/mac_helpers.h"
#include "shell/browser/ui/cocoa/electron_bundle_mover.h"
#include "shell/common/process_util.h"
#endif
#if BUILDFLAG(IS_LINUX)
@@ -164,7 +161,7 @@ struct Converter<JumpListItem::Type> {
if (item_val == val)
return gin::ConvertToV8(isolate, name);
return v8::String::Empty(isolate);
return gin::ConvertToV8(isolate, "");
}
private:
@@ -255,7 +252,7 @@ struct Converter<JumpListCategory::Type> {
if (type_val == val)
return gin::ConvertToV8(isolate, name);
return v8::String::Empty(isolate);
return gin::ConvertToV8(isolate, "");
}
private:
@@ -408,7 +405,7 @@ int GetPathConstant(std::string_view name) {
{"videos", chrome::DIR_USER_VIDEOS},
});
// clang-format on
const auto* iter = Lookup.find(name);
auto iter = Lookup.find(name);
return iter != Lookup.end() ? iter->second : -1;
}
@@ -904,21 +901,6 @@ bool App::IsPackaged() {
#if BUILDFLAG(IS_WIN)
return base_name != FILE_PATH_LITERAL("electron.exe");
#elif BUILDFLAG(IS_MAC)
static const base::NoDestructor<std::string> default_helper(
"electron helper" +
base::ToLowerASCII(content::kMacHelperSuffix_default));
static const base::NoDestructor<std::string> renderer_helper(
"electron helper" +
base::ToLowerASCII(content::kMacHelperSuffix_renderer));
static const base::NoDestructor<std::string> plugin_helper(
"electron helper" + base::ToLowerASCII(content::kMacHelperSuffix_plugin));
if (IsRendererProcess()) {
return base_name != *renderer_helper;
} else if (IsUtilityProcess()) {
return base_name != *default_helper && base_name != *plugin_helper;
}
return base_name != FILE_PATH_LITERAL("electron");
#else
return base_name != FILE_PATH_LITERAL("electron");
#endif

View File

@@ -34,6 +34,10 @@ namespace base {
class FilePath;
}
namespace gfx {
class Image;
}
namespace gin {
template <typename T>
class Handle;
@@ -61,6 +65,9 @@ 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();

View File

@@ -1091,10 +1091,6 @@ void BaseWindow::SetAppDetails(const gin_helper::Dictionary& options) {
relaunch_command, relaunch_display_name,
window_->GetAcceleratedWidget());
}
bool BaseWindow::IsSnapped() const {
return window_->IsSnapped();
}
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)
@@ -1339,8 +1335,6 @@ void BaseWindow::BuildPrototype(v8::Isolate* isolate,
.SetMethod("setIcon", &BaseWindow::SetIcon)
#endif
#if BUILDFLAG(IS_WIN)
.SetMethod("isSnapped", &BaseWindow::IsSnapped)
.SetProperty("snapped", &BaseWindow::IsSnapped)
.SetMethod("hookWindowMessage", &BaseWindow::HookWindowMessage)
.SetMethod("isWindowMessageHooked", &BaseWindow::IsWindowMessageHooked)
.SetMethod("unhookWindowMessage", &BaseWindow::UnhookWindowMessage)

View File

@@ -252,7 +252,6 @@ class BaseWindow : public gin_helper::TrackableObject<BaseWindow>,
bool SetThumbnailClip(const gfx::Rect& region);
bool SetThumbnailToolTip(const std::string& tooltip);
void SetAppDetails(const gin_helper::Dictionary& options);
bool IsSnapped() const;
#endif
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_LINUX)

View File

@@ -9,16 +9,18 @@
#include <vector>
#include "base/containers/flat_map.h"
#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "chrome/browser/media/webrtc/desktop_capturer_wrapper.h"
#include "chrome/browser/media/webrtc/desktop_media_list.h"
#include "chrome/browser/media/webrtc/thumbnail_capturer_mac.h"
#include "chrome/browser/media/webrtc/window_icon_util.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/desktop_capture.h"
#include "gin/handle.h"
#include "gin/object_template_builder.h"
#include "media/base/media_switches.h"
#include "shell/browser/javascript_environment.h"
#include "shell/common/api/electron_api_native_image.h"
#include "shell/common/gin_converters/gfx_converter.h"
@@ -144,6 +146,21 @@ base::flat_map<int32_t, uint32_t> MonitorAtomIdToDisplayId() {
}
#endif
std::unique_ptr<ThumbnailCapturer> MakeScreenAndWindowCapturer() {
#if BUILDFLAG(IS_MAC)
if (ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kNone)) {
LOG(ERROR) << "creating thumbnail capturer, knone *****";
return CreateThumbnailCapturerMac(DesktopMediaList::Type::kNone);
}
#endif // BUILDFLAG(IS_MAC)
LOG(ERROR) << "should not hit this *****";
std::unique_ptr<webrtc::DesktopCapturer> window_capturer =
content::desktop_capture::CreateWindowCapturer();
return window_capturer ? std::make_unique<DesktopCapturerWrapper>(
std::move(window_capturer))
: nullptr;
}
std::unique_ptr<ThumbnailCapturer> MakeWindowCapturer() {
#if BUILDFLAG(IS_MAC)
if (ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kWindow)) {
@@ -253,14 +270,14 @@ void DesktopCapturer::DesktopListListener::OnSourceThumbnailChanged(int index) {
}
void DesktopCapturer::DesktopListListener::OnDelegatedSourceListDismissed() {
content::GetUIThreadTaskRunner({})->PostTask(FROM_HERE,
std::move(failure_callback_));
std::move(failure_callback_).Run();
}
void DesktopCapturer::StartHandling(bool capture_window,
bool capture_screen,
const gfx::Size& thumbnail_size,
bool fetch_window_icons) {
bool fetch_window_icons,
bool use_system_picker) {
fetch_window_icons_ = fetch_window_icons;
#if BUILDFLAG(IS_WIN)
if (content::desktop_capture::CreateDesktopCaptureOptions()
@@ -274,35 +291,76 @@ void DesktopCapturer::StartHandling(bool capture_window,
// clear any existing captured sources.
captured_sources_.clear();
LOG(ERROR) << "capture_window: " << capture_window << " capture_screen: " << capture_screen;
if (capture_window && capture_screen) {
// Some capturers like PipeWire support a single capturer for both screens
// and windows. Use it if possible, treating both as window capture
std::unique_ptr<webrtc::DesktopCapturer> desktop_capturer =
webrtc::DesktopCapturer::CreateGenericCapturer(
content::desktop_capture::CreateDesktopCaptureOptions());
auto capturer = desktop_capturer ? std::make_unique<DesktopCapturerWrapper>(
std::move(desktop_capturer))
: nullptr;
if (capturer && capturer->GetDelegatedSourceListController()) {
capture_screen_ = false;
if (IsDisplayMediaSystemPickerAvailable()) {
auto capturer = MakeScreenAndWindowCapturer();
capture_screen_ = capture_screen;
capture_window_ = capture_window;
window_capturer_ = std::make_unique<NativeDesktopMediaList>(
DesktopMediaList::Type::kWindow, std::move(capturer), true, true);
window_capturer_->SetThumbnailSize(thumbnail_size);
// TODO(review): Maybe just call this a capturer
screen_capturer_ = std::make_unique<NativeDesktopMediaList>(
DesktopMediaList::Type::kNone, std::move(capturer), true, true);
screen_capturer_->SetThumbnailSize(thumbnail_size);
screen_capturer_->ShowDelegatedList();
#if BUILDFLAG(IS_MAC)
screen_capturer_->skip_next_refresh_ =
ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kNone) ? 2 : 0;
LOG(ERROR) << "SET SKIP NEXT REFRESH TO 2";
#endif
LOG(ERROR) << "screen_capturer_->skip_next_refresh_ " << screen_capturer_->skip_next_refresh_;
OnceCallback update_callback = base::BindOnce(
&DesktopCapturer::UpdateSourcesList, weak_ptr_factory_.GetWeakPtr(),
window_capturer_.get());
OnceCallback failure_callback = base::BindOnce(
&DesktopCapturer::HandleFailure, weak_ptr_factory_.GetWeakPtr());
screen_capturer_.get());
window_listener_ = std::make_unique<DesktopListListener>(
std::move(update_callback), std::move(failure_callback),
thumbnail_size.IsEmpty());
window_capturer_->StartUpdating(window_listener_.get());
// Needed to force a refresh for the native MacOS Picker
OnceCallback wrapped_update_callback = base::BindOnce(
&DesktopCapturer::RequestUpdate, weak_ptr_factory_.GetWeakPtr(),
screen_capturer_.get(), std::move(update_callback));
if (screen_capturer_->IsSourceListDelegated()) {
OnceCallback failure_callback = base::BindOnce(
&DesktopCapturer::HandleFailure, weak_ptr_factory_.GetWeakPtr());
screen_listener_ = std::make_unique<DesktopListListener>(
std::move(wrapped_update_callback), std::move(failure_callback),
thumbnail_size.IsEmpty());
screen_capturer_->StartUpdating(screen_listener_.get());
} else {
screen_capturer_->Update(std::move(update_callback),
/* refresh_thumbnails = */ true);
}
return;
} else {
// Some capturers like PipeWire support a single capturer for both screens
// and windows. Use it if possible, treating both as window capture
std::unique_ptr<webrtc::DesktopCapturer> desktop_capturer =
webrtc::DesktopCapturer::CreateGenericCapturer(
content::desktop_capture::CreateDesktopCaptureOptions());
auto capturer = desktop_capturer
? std::make_unique<DesktopCapturerWrapper>(
std::move(desktop_capturer))
: nullptr;
if (capturer && capturer->GetDelegatedSourceListController()) {
capture_screen_ = false;
capture_window_ = capture_window;
window_capturer_ = std::make_unique<NativeDesktopMediaList>(
DesktopMediaList::Type::kWindow, std::move(capturer));
window_capturer_->SetThumbnailSize(thumbnail_size);
OnceCallback update_callback = base::BindOnce(
&DesktopCapturer::UpdateSourcesList, weak_ptr_factory_.GetWeakPtr(),
window_capturer_.get());
OnceCallback failure_callback = base::BindOnce(
&DesktopCapturer::HandleFailure, weak_ptr_factory_.GetWeakPtr());
window_listener_ = std::make_unique<DesktopListListener>(
std::move(update_callback), std::move(failure_callback),
thumbnail_size.IsEmpty());
window_capturer_->StartUpdating(window_listener_.get());
return;
}
}
}
@@ -321,22 +379,30 @@ void DesktopCapturer::StartHandling(bool capture_window,
// Initialize the source list.
// Apply the new thumbnail size and restart capture.
if (capture_window) {
LOG(ERROR) << "WE SHOULDNT BE HERE *****";
auto capturer = MakeWindowCapturer();
if (capturer) {
window_capturer_ = std::make_unique<NativeDesktopMediaList>(
DesktopMediaList::Type::kWindow, std::move(capturer), true, true);
window_capturer_->SetThumbnailSize(thumbnail_size);
#if BUILDFLAG(IS_MAC)
window_capturer_->skip_next_refresh_ =
ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kWindow)
? thumbnail_size.IsEmpty() ? 1 : 2
: 0;
#endif
OnceCallback update_callback = base::BindOnce(
&DesktopCapturer::UpdateSourcesList, weak_ptr_factory_.GetWeakPtr(),
window_capturer_.get());
#if BUILDFLAG(IS_MAC)
window_capturer_->skip_next_refresh_ =
ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kWindow) ? 2
: 0;
if (base::FeatureList::IsEnabled(media::kUseSCContentSharingPicker)) {
window_capturer_->ShowDelegatedList();
// Needed to force a refresh for the native MacOS Picker
update_callback = base::BindOnce(
&DesktopCapturer::RequestUpdate, weak_ptr_factory_.GetWeakPtr(),
window_capturer_.get(), std::move(update_callback));
}
#endif
if (window_capturer_->IsSourceListDelegated()) {
OnceCallback failure_callback = base::BindOnce(
&DesktopCapturer::HandleFailure, weak_ptr_factory_.GetWeakPtr());
@@ -357,17 +423,25 @@ void DesktopCapturer::StartHandling(bool capture_window,
screen_capturer_ = std::make_unique<NativeDesktopMediaList>(
DesktopMediaList::Type::kScreen, std::move(capturer));
screen_capturer_->SetThumbnailSize(thumbnail_size);
#if BUILDFLAG(IS_MAC)
screen_capturer_->skip_next_refresh_ =
ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kScreen)
? thumbnail_size.IsEmpty() ? 1 : 2
: 0;
#endif
OnceCallback update_callback = base::BindOnce(
&DesktopCapturer::UpdateSourcesList, weak_ptr_factory_.GetWeakPtr(),
screen_capturer_.get());
#if BUILDFLAG(IS_MAC)
screen_capturer_->skip_next_refresh_ =
ShouldUseThumbnailCapturerMac(DesktopMediaList::Type::kScreen) ? 2
: 0;
if (base::FeatureList::IsEnabled(media::kUseSCContentSharingPicker)) {
screen_capturer_->ShowDelegatedList();
// Needed to force a refresh for the native MacOS Picker
update_callback = base::BindOnce(
&DesktopCapturer::RequestUpdate, weak_ptr_factory_.GetWeakPtr(),
screen_capturer_.get(), std::move(update_callback));
}
#endif
if (screen_capturer_->IsSourceListDelegated()) {
OnceCallback failure_callback = base::BindOnce(
&DesktopCapturer::HandleFailure, weak_ptr_factory_.GetWeakPtr());
@@ -384,9 +458,15 @@ void DesktopCapturer::StartHandling(bool capture_window,
}
}
void DesktopCapturer::RequestUpdate(DesktopMediaList* list,
OnceCallback update_callback) {
list->Update(std::move(update_callback));
}
void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
if (capture_window_ &&
list->GetMediaListType() == DesktopMediaList::Type::kWindow) {
(list->GetMediaListType() == DesktopMediaList::Type::kWindow ||
list->GetMediaListType() == DesktopMediaList::Type::kNone)) {
capture_window_ = false;
std::vector<DesktopCapturer::Source> window_sources;
window_sources.reserve(list->GetSourceCount());
@@ -399,7 +479,8 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
}
if (capture_screen_ &&
list->GetMediaListType() == DesktopMediaList::Type::kScreen) {
(list->GetMediaListType() == DesktopMediaList::Type::kScreen ||
list->GetMediaListType() == DesktopMediaList::Type::kNone)) {
capture_screen_ = false;
std::vector<DesktopCapturer::Source> screen_sources;
screen_sources.reserve(list->GetSourceCount());
@@ -469,7 +550,6 @@ void DesktopCapturer::UpdateSourcesList(DesktopMediaList* list) {
std::move(screen_sources.begin(), screen_sources.end(),
std::back_inserter(captured_sources_));
}
if (!capture_window_ && !capture_screen_)
HandleSuccess();
}

View File

@@ -41,7 +41,8 @@ class DesktopCapturer final : public gin::Wrappable<DesktopCapturer>,
void StartHandling(bool capture_window,
bool capture_screen,
const gfx::Size& thumbnail_size,
bool fetch_window_icons);
bool fetch_window_icons,
bool use_system_picker);
// gin::Wrappable
static gin::WrapperInfo kWrapperInfo;
@@ -94,6 +95,7 @@ class DesktopCapturer final : public gin::Wrappable<DesktopCapturer>,
bool have_thumbnail_ = false;
};
void RequestUpdate(DesktopMediaList* list, OnceCallback update_callback);
void UpdateSourcesList(DesktopMediaList* list);
void HandleFailure();
void HandleSuccess();

View File

@@ -7,7 +7,6 @@
#include <string>
#include <vector>
#include "base/containers/map_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/uuid.h"
#include "components/prefs/pref_service.h"
@@ -58,24 +57,22 @@ GlobalShortcut::~GlobalShortcut() {
}
void GlobalShortcut::OnKeyPressed(const ui::Accelerator& accelerator) {
if (auto* cb = base::FindOrNull(accelerator_callback_map_, accelerator)) {
cb->Run();
} else {
if (!accelerator_callback_map_.contains(accelerator)) {
// This should never occur, because if it does,
// ui::GlobalAcceleratorListener notifies us with wrong accelerator.
NOTREACHED();
}
accelerator_callback_map_[accelerator].Run();
}
void GlobalShortcut::ExecuteCommand(const extensions::ExtensionId& extension_id,
const std::string& command_id) {
if (auto* cb = base::FindOrNull(command_callback_map_, command_id)) {
cb->Run();
} else {
if (!command_callback_map_.contains(command_id)) {
// This should never occur, because if it does, GlobalAcceleratorListener
// notifies us with wrong command.
NOTREACHED();
}
command_callback_map_[command_id].Run();
}
bool GlobalShortcut::RegisterAll(

View File

@@ -7,7 +7,6 @@
#include <utility>
#include "shell/browser/api/electron_api_base_window.h"
#include "shell/browser/api/electron_api_web_frame_main.h"
#include "shell/browser/api/ui_event.h"
#include "shell/browser/javascript_environment.h"
#include "shell/browser/native_window.h"
@@ -17,7 +16,6 @@
#include "shell/common/gin_converters/file_path_converter.h"
#include "shell/common/gin_converters/gurl_converter.h"
#include "shell/common/gin_converters/image_converter.h"
#include "shell/common/gin_converters/optional_converter.h"
#include "shell/common/gin_helper/dictionary.h"
#include "shell/common/gin_helper/object_template_builder.h"
#include "shell/common/node_includes.h"

View File

@@ -22,7 +22,6 @@ class Arguments;
namespace electron::api {
class BaseWindow;
class WebFrameMain;
class Menu : public gin::Wrappable<Menu>,
public gin_helper::EventEmitterMixin<Menu>,
@@ -82,7 +81,6 @@ class Menu : public gin::Wrappable<Menu>,
void OnMenuWillShow(ui::SimpleMenuModel* source) override;
virtual void PopupAt(BaseWindow* window,
std::optional<WebFrameMain*> frame,
int x,
int y,
int positioning_item,

View File

@@ -13,7 +13,6 @@
namespace electron {
class NativeWindow;
class WebFrameMain;
namespace api {
@@ -24,14 +23,12 @@ class MenuMac : public Menu {
// Menu
void PopupAt(BaseWindow* window,
std::optional<WebFrameMain*> frame,
int x,
int y,
int positioning_item,
ui::mojom::MenuSourceType source_type,
base::OnceClosure callback) override;
void PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
const base::WeakPtr<WebFrameMain>& frame,
int32_t window_id,
int x,
int y,

View File

@@ -11,15 +11,11 @@
#include "base/strings/sys_string_conversions.h"
#include "base/task/current_thread.h"
#include "base/task/sequenced_task_runner.h"
#include "content/app_shim_remote_cocoa/render_widget_host_view_cocoa.h" // nogncheck
#include "content/browser/renderer_host/render_widget_host_view_mac.h" // nogncheck
#include "content/public/browser/browser_task_traits.h"
#include "shell/browser/api/electron_api_base_window.h"
#include "shell/browser/api/electron_api_web_frame_main.h"
#include "shell/browser/native_window.h"
#include "shell/common/keyboard_util.h"
#include "shell/common/node_includes.h"
#include "ui/base/cocoa/menu_utils.h"
namespace {
@@ -52,7 +48,6 @@ MenuMac::MenuMac(gin::Arguments* args) : Menu(args) {}
MenuMac::~MenuMac() = default;
void MenuMac::PopupAt(BaseWindow* window,
std::optional<WebFrameMain*> frame,
int x,
int y,
int positioning_item,
@@ -62,19 +57,14 @@ void MenuMac::PopupAt(BaseWindow* window,
if (!native_window)
return;
base::WeakPtr<WebFrameMain> weak_frame;
if (frame && frame.value()) {
weak_frame = frame.value()->GetWeakPtr();
}
// Make sure the Menu object would not be garbage-collected until the callback
// has run.
base::OnceClosure callback_with_ref = BindSelfToClosure(std::move(callback));
auto popup = base::BindOnce(&MenuMac::PopupOnUI, weak_factory_.GetWeakPtr(),
native_window->GetWeakPtr(), weak_frame,
window->weak_map_id(), x, y, positioning_item,
std::move(callback_with_ref));
auto popup =
base::BindOnce(&MenuMac::PopupOnUI, weak_factory_.GetWeakPtr(),
native_window->GetWeakPtr(), window->weak_map_id(), x, y,
positioning_item, std::move(callback_with_ref));
base::SequencedTaskRunner::GetCurrentDefault()->PostTask(FROM_HERE,
std::move(popup));
}
@@ -105,7 +95,6 @@ v8::Local<v8::Value> Menu::GetUserAcceleratorAt(int command_id) const {
}
void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
const base::WeakPtr<WebFrameMain>& frame,
int32_t window_id,
int x,
int y,
@@ -156,27 +145,18 @@ void MenuMac::PopupOnUI(const base::WeakPtr<NativeWindow>& native_window,
position.x = position.x - [menu size].width;
[popup_controllers_[window_id] setCloseCallback:std::move(close_callback)];
// Make sure events can be pumped while the menu is up.
base::CurrentThread::ScopedAllowApplicationTasksInNativeNestedLoop allow;
if (frame && frame->render_frame_host()) {
auto* rfh = frame->render_frame_host()->GetOutermostMainFrameOrEmbedder();
if (rfh && rfh->IsRenderFrameLive()) {
auto* rwhvm =
static_cast<content::RenderWidgetHostViewMac*>(rfh->GetView());
RenderWidgetHostViewCocoa* cocoa_view = rwhvm->GetInProcessNSView();
view = cocoa_view;
}
}
// One of the events that could be pumped is |window.close()|.
// User-initiated event-tracking loops protect against this by
// setting flags in -[CrApplication sendEvent:], but since
// web-content menus are initiated by IPC message the setup has to
// be done manually.
base::mac::ScopedSendingEvent sendingEventScoper;
NSEvent* dummy_event = [NSEvent mouseEventWithType:NSEventTypeRightMouseDown
location:position
modifierFlags:0
timestamp:0
windowNumber:nswindow.windowNumber
context:nil
eventNumber:0
clickCount:1
pressure:0];
ui::ShowContextMenu(menu, dummy_event, view, true);
// Don't emit unresponsive event when showing menu.
[menu popUpMenuPositioningItem:item atLocation:position inView:view];
}
void MenuMac::ClosePopupAt(int32_t window_id) {

View File

@@ -8,7 +8,6 @@
#include <utility>
#include "shell/browser/api/electron_api_base_window.h"
#include "shell/browser/api/electron_api_web_frame_main.h"
#include "shell/browser/native_window_views.h"
#include "ui/display/screen.h"
@@ -21,7 +20,6 @@ MenuViews::MenuViews(gin::Arguments* args) : Menu(args) {}
MenuViews::~MenuViews() = default;
void MenuViews::PopupAt(BaseWindow* window,
std::optional<WebFrameMain*> frame,
int x,
int y,
int positioning_item,

View File

@@ -22,7 +22,6 @@ class MenuViews : public Menu {
protected:
// Menu
void PopupAt(BaseWindow* window,
std::optional<WebFrameMain*> frame,
int x,
int y,
int positioning_item,

View File

@@ -14,6 +14,7 @@
#include "gin/handle.h"
#include "gin/object_template_builder.h"
#include "shell/browser/browser.h"
#include "shell/browser/electron_browser_context.h"
#include "shell/browser/protocol_registry.h"
#include "shell/common/gin_converters/callback_converter.h"
#include "shell/common/gin_converters/net_converter.h"
@@ -193,39 +194,41 @@ const char* const kBuiltinSchemes[] = {
"about", "file", "http", "https", "data", "filesystem",
};
} // namespace
Protocol::Protocol(ProtocolRegistry* protocol_registry)
: protocol_registry_{protocol_registry} {}
// Convert error code to string.
// static
std::string_view Protocol::ErrorCodeToString(Error error) {
constexpr std::string_view ErrorCodeToString(ProtocolError error) {
switch (error) {
case Error::kRegistered:
case ProtocolError::kRegistered:
return "The scheme has been registered";
case Error::kNotRegistered:
case ProtocolError::kNotRegistered:
return "The scheme has not been registered";
case Error::kIntercepted:
case ProtocolError::kIntercepted:
return "The scheme has been intercepted";
case Error::kNotIntercepted:
case ProtocolError::kNotIntercepted:
return "The scheme has not been intercepted";
default:
return "Unexpected error";
}
}
Protocol::Error Protocol::RegisterProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
} // namespace
Protocol::Protocol(v8::Isolate* isolate, ProtocolRegistry* protocol_registry)
: protocol_registry_(protocol_registry) {}
Protocol::~Protocol() = default;
ProtocolError Protocol::RegisterProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
bool added = protocol_registry_->RegisterProtocol(type, scheme, handler);
return added ? Error::kOK : Error::kRegistered;
return added ? ProtocolError::kOK : ProtocolError::kRegistered;
}
bool Protocol::UnregisterProtocol(const std::string& scheme,
gin::Arguments* args) {
bool removed = protocol_registry_->UnregisterProtocol(scheme);
HandleOptionalCallback(args, removed ? Error::kOK : Error::kNotRegistered);
HandleOptionalCallback(
args, removed ? ProtocolError::kOK : ProtocolError::kNotRegistered);
return removed;
}
@@ -233,17 +236,18 @@ bool Protocol::IsProtocolRegistered(const std::string& scheme) {
return protocol_registry_->FindRegistered(scheme) != nullptr;
}
Protocol::Error Protocol::InterceptProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
ProtocolError Protocol::InterceptProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler) {
bool added = protocol_registry_->InterceptProtocol(type, scheme, handler);
return added ? Error::kOK : Error::kIntercepted;
return added ? ProtocolError::kOK : ProtocolError::kIntercepted;
}
bool Protocol::UninterceptProtocol(const std::string& scheme,
gin::Arguments* args) {
bool removed = protocol_registry_->UninterceptProtocol(scheme);
HandleOptionalCallback(args, removed ? Error::kOK : Error::kNotIntercepted);
HandleOptionalCallback(
args, removed ? ProtocolError::kOK : ProtocolError::kNotIntercepted);
return removed;
}
@@ -271,14 +275,15 @@ v8::Local<v8::Promise> Protocol::IsProtocolHandled(const std::string& scheme,
base::Contains(kBuiltinSchemes, scheme));
}
void Protocol::HandleOptionalCallback(gin::Arguments* args, Error error) {
void Protocol::HandleOptionalCallback(gin::Arguments* args,
ProtocolError error) {
base::RepeatingCallback<void(v8::Local<v8::Value>)> callback;
if (args->GetNext(&callback)) {
util::EmitWarning(
args->isolate(),
"The callback argument of protocol module APIs is no longer needed.",
"ProtocolDeprecateCallback");
if (error == Error::kOK)
if (error == ProtocolError::kOK)
callback.Run(v8::Null(args->isolate()));
else
callback.Run(v8::Exception::Error(
@@ -287,9 +292,11 @@ void Protocol::HandleOptionalCallback(gin::Arguments* args, Error error) {
}
// static
gin::Handle<Protocol> Protocol::Create(v8::Isolate* isolate,
ProtocolRegistry* protocol_registry) {
return gin::CreateHandle(isolate, new Protocol{protocol_registry});
gin::Handle<Protocol> Protocol::Create(
v8::Isolate* isolate,
ElectronBrowserContext* browser_context) {
return gin::CreateHandle(
isolate, new Protocol(isolate, browser_context->protocol_registry()));
}
// static

View File

@@ -22,6 +22,7 @@ class Handle;
namespace electron {
class ElectronBrowserContext;
class ProtocolRegistry;
namespace api {
@@ -34,12 +35,21 @@ void AddServiceWorkerScheme(const std::string& scheme);
void RegisterSchemesAsPrivileged(gin_helper::ErrorThrower thrower,
v8::Local<v8::Value> val);
// Possible errors.
enum class ProtocolError {
kOK, // no error
kRegistered,
kNotRegistered,
kIntercepted,
kNotIntercepted,
};
// Protocol implementation based on network services.
class Protocol final : public gin::Wrappable<Protocol>,
public gin_helper::Constructible<Protocol> {
public:
static gin::Handle<Protocol> Create(v8::Isolate* isolate,
ProtocolRegistry* protocol_registry);
ElectronBrowserContext* browser_context);
// gin_helper::Constructible
static gin::Handle<Protocol> New(gin_helper::ErrorThrower thrower);
@@ -53,34 +63,23 @@ class Protocol final : public gin::Wrappable<Protocol>,
const char* GetTypeName() override;
private:
// Possible errors.
enum class Error {
kOK, // no error
kRegistered,
kNotRegistered,
kIntercepted,
kNotIntercepted,
};
Protocol(v8::Isolate* isolate, ProtocolRegistry* protocol_registry);
~Protocol() override;
// Callback types.
using CompletionCallback =
base::RepeatingCallback<void(v8::Local<v8::Value>)>;
explicit Protocol(ProtocolRegistry* protocol_registry);
~Protocol() override = default;
[[nodiscard]] static std::string_view ErrorCodeToString(Error error);
// JS APIs.
Error RegisterProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler);
ProtocolError RegisterProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler);
bool UnregisterProtocol(const std::string& scheme, gin::Arguments* args);
bool IsProtocolRegistered(const std::string& scheme);
Error InterceptProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler);
ProtocolError InterceptProtocol(ProtocolType type,
const std::string& scheme,
const ProtocolHandler& handler);
bool UninterceptProtocol(const std::string& scheme, gin::Arguments* args);
bool IsProtocolIntercepted(const std::string& scheme);
@@ -93,21 +92,21 @@ class Protocol final : public gin::Wrappable<Protocol>,
bool RegisterProtocolFor(const std::string& scheme,
const ProtocolHandler& handler,
gin::Arguments* args) {
const auto result = RegisterProtocol(type, scheme, handler);
auto result = RegisterProtocol(type, scheme, handler);
HandleOptionalCallback(args, result);
return result == Error::kOK;
return result == ProtocolError::kOK;
}
template <ProtocolType type>
bool InterceptProtocolFor(const std::string& scheme,
const ProtocolHandler& handler,
gin::Arguments* args) {
const auto result = InterceptProtocol(type, scheme, handler);
auto result = InterceptProtocol(type, scheme, handler);
HandleOptionalCallback(args, result);
return result == Error::kOK;
return result == ProtocolError::kOK;
}
// Be compatible with old interface, which accepts optional callback.
void HandleOptionalCallback(gin::Arguments* args, Error error);
void HandleOptionalCallback(gin::Arguments* args, ProtocolError error);
// Weak pointer; the lifetime of the ProtocolRegistry is guaranteed to be
// longer than the lifetime of this JS interface.

View File

@@ -19,7 +19,10 @@ v8::Local<v8::Promise> PushNotifications::RegisterForAPNSNotifications(
gin_helper::Promise<std::string> promise(isolate);
v8::Local<v8::Promise> handle = promise.GetHandle();
[[AtomApplication sharedApplication] registerForRemoteNotifications];
[[AtomApplication sharedApplication]
registerForRemoteNotificationTypes:NSRemoteNotificationTypeBadge |
NSRemoteNotificationTypeAlert |
NSRemoteNotificationTypeSound];
PushNotifications::apns_promise_set_.emplace_back(std::move(promise));
return handle;
@@ -27,7 +30,8 @@ v8::Local<v8::Promise> PushNotifications::RegisterForAPNSNotifications(
void PushNotifications::ResolveAPNSPromiseSetWithToken(
const std::string& token_string) {
auto promises = std::move(PushNotifications::apns_promise_set_);
std::vector<gin_helper::Promise<std::string>> promises =
std::move(PushNotifications::apns_promise_set_);
for (auto& promise : promises) {
promise.Resolve(token_string);
}
@@ -35,7 +39,8 @@ void PushNotifications::ResolveAPNSPromiseSetWithToken(
void PushNotifications::RejectAPNSPromiseSetWithError(
const std::string& error_message) {
auto promises = std::move(PushNotifications::apns_promise_set_);
std::vector<gin_helper::Promise<std::string>> promises =
std::move(PushNotifications::apns_promise_set_);
for (auto& promise : promises) {
promise.RejectWithErrorMessage(error_message);
}

View File

@@ -5,6 +5,7 @@
#include "shell/browser/api/electron_api_service_worker_main.h"
#include <string>
#include <unordered_map>
#include <utility>
#include "base/logging.h"
@@ -27,7 +28,6 @@
#include "shell/common/gin_helper/promise.h"
#include "shell/common/node_includes.h"
#include "shell/common/v8_util.h"
#include "third_party/abseil-cpp/absl/container/flat_hash_map.h"
namespace {
@@ -58,9 +58,10 @@ std::optional<content::ServiceWorkerVersionBaseInfo> GetLiveVersionInfo(
namespace electron::api {
// ServiceWorkerKey -> ServiceWorkerMain*
using VersionIdMap = absl::flat_hash_map<ServiceWorkerKey,
ServiceWorkerMain*,
ServiceWorkerKey::Hasher>;
typedef std::unordered_map<ServiceWorkerKey,
ServiceWorkerMain*,
ServiceWorkerKey::Hasher>
VersionIdMap;
VersionIdMap& GetVersionIdMap() {
static base::NoDestructor<VersionIdMap> instance;
@@ -281,6 +282,12 @@ GURL ServiceWorkerMain::ScopeURL() const {
return version_info()->scope;
}
GURL ServiceWorkerMain::ScriptURL() const {
if (version_destroyed_)
return {};
return version_info()->script_url;
}
// static
gin::Handle<ServiceWorkerMain> ServiceWorkerMain::New(v8::Isolate* isolate) {
return gin::Handle<ServiceWorkerMain>();
@@ -329,6 +336,7 @@ void ServiceWorkerMain::FillObjectTemplate(
&ServiceWorkerMain::CountExternalRequestsForTest)
.SetProperty("versionId", &ServiceWorkerMain::VersionID)
.SetProperty("scope", &ServiceWorkerMain::ScopeURL)
.SetProperty("scriptURL", &ServiceWorkerMain::ScriptURL)
.Build();
}

Some files were not shown because too many files have changed in this diff Show More