chore: update patch:

This commit is contained in:
George Xu
2025-03-28 15:29:14 -07:00
parent bb092132be
commit 6b6ef0b9ef
2 changed files with 45 additions and 54 deletions

View File

@@ -143,6 +143,4 @@ fix_win32_synchronous_spellcheck.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.patch
feat_allow_desktop_capturer_to_return_either_screen_window_or_both.patch
feat_make_macos_sccontentsharingpicker_work_in_electron_and_return_screen_window_or_both.patch

View File

@@ -9,10 +9,10 @@ This patch is a work in progress that contains assorted changes to make the MacO
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 85320190d406bdd37175ddb5d207d124b278b648..2fd7b9a89e2baebf5c5c4c2554c72d93c7ef0b0b 100644
index 36797f37627d534bd446e0d8270618722ed9a2fa..32222cb526dc047a02cd9382814edd71cca0a378 100644
--- a/chrome/browser/media/webrtc/capture_policy_utils.cc
+++ b/chrome/browser/media/webrtc/capture_policy_utils.cc
@@ -362,7 +362,9 @@ void FilterMediaList(std::vector<DesktopMediaList::Type>& media_types,
@@ -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:
@@ -66,10 +66,10 @@ index 08400be4d1bae18502d19beed6b2d9057e55dd4f..d83487885d566336d72bc5c4232d50a6
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 0ac8e20073bd2db507e49200fd0b48f8535d666b..ffea8d7c257fc68a66a9804d45861131e4716b63 100644
index 312882d656f9f6b3d3fd98128131cea63f818e0d..be28789ccbd3cb8b28fa5ae4017305177a914e22 100644
--- a/chrome/browser/media/webrtc/native_desktop_media_list.cc
+++ b/chrome/browser/media/webrtc/native_desktop_media_list.cc
@@ -46,6 +46,7 @@
@@ -45,6 +45,7 @@
#endif
#if BUILDFLAG(IS_MAC)
@@ -77,7 +77,7 @@ index 0ac8e20073bd2db507e49200fd0b48f8535d666b..ffea8d7c257fc68a66a9804d45861131
#include "components/remote_cocoa/browser/scoped_cg_window_id.h"
#endif
@@ -186,9 +187,10 @@ content::DesktopMediaID::Type ConvertToDesktopMediaIDType(
@@ -162,9 +163,10 @@ content::DesktopMediaID::Type ConvertToDesktopMediaIDType(
return content::DesktopMediaID::Type::TYPE_SCREEN;
case DesktopMediaList::Type::kWindow:
return content::DesktopMediaID::Type::TYPE_WINDOW;
@@ -89,7 +89,7 @@ index 0ac8e20073bd2db507e49200fd0b48f8535d666b..ffea8d7c257fc68a66a9804d45861131
break;
}
NOTREACHED();
@@ -411,7 +413,8 @@ NativeDesktopMediaList::Worker::Worker(
@@ -372,7 +374,8 @@ NativeDesktopMediaList::Worker::Worker(
nullptr) {
DCHECK(capturer_);
@@ -99,7 +99,7 @@ index 0ac8e20073bd2db507e49200fd0b48f8535d666b..ffea8d7c257fc68a66a9804d45861131
!add_current_process_windows_);
}
@@ -545,17 +548,33 @@ NativeDesktopMediaList::Worker::FormatSources(
@@ -505,11 +508,24 @@ NativeDesktopMediaList::Worker::FormatSources(
break;
case DesktopMediaID::Type::TYPE_WINDOW:
@@ -124,16 +124,7 @@ index 0ac8e20073bd2db507e49200fd0b48f8535d666b..ffea8d7c257fc68a66a9804d45861131
break;
default:
NOTREACHED();
}
DesktopMediaID source_id(source_type, sources[i].id);
+ // for each source log its id
+ for (size_t j = 0; j < sources.size(); ++j) {
+ }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
// We need to communicate this in_process_id to
// |RefreshForVizFrameSinkWindows|, so we'll use the window_id. If
@@ -820,14 +839,10 @@ NativeDesktopMediaList::NativeDesktopMediaList(
@@ -775,14 +791,10 @@ NativeDesktopMediaList::NativeDesktopMediaList(
is_source_list_delegated_(capturer->GetDelegatedSourceListController() !=
nullptr) {
type_ = type;
@@ -149,7 +140,7 @@ index 0ac8e20073bd2db507e49200fd0b48f8535d666b..ffea8d7c257fc68a66a9804d45861131
base::MessagePumpType thread_type = base::MessagePumpType::UI;
#else
base::MessagePumpType thread_type = base::MessagePumpType::DEFAULT;
@@ -839,8 +854,9 @@ NativeDesktopMediaList::NativeDesktopMediaList(
@@ -794,8 +806,9 @@ NativeDesktopMediaList::NativeDesktopMediaList(
std::move(capturer), add_current_process_windows_,
auto_show_delegated_source_list);
@@ -175,7 +166,7 @@ index 12a74f8f32cc00a7f3d7802865ae4b309961341d..acbcfb08ae8c44e24a04b32609628942
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 47a5ad2b7e2bc86a614488fd3fe85da1e3e2d6f2..fcc63aaf488b598db705e07274914eadffd29628 100644
index 744f2447dc2d43c4f6be695bf561474993468705..1eb7465481e3a2a70a99c173cae3e18f420a6681 100644
--- a/chrome/browser/media/webrtc/thumbnail_capturer_mac.mm
+++ b/chrome/browser/media/webrtc/thumbnail_capturer_mac.mm
@@ -13,6 +13,7 @@
@@ -186,7 +177,7 @@ index 47a5ad2b7e2bc86a614488fd3fe85da1e3e2d6f2..fcc63aaf488b598db705e07274914ead
#include "base/apple/bridging.h"
#include "base/apple/foundation_util.h"
#include "base/apple/scoped_cftyperef.h"
@@ -80,11 +81,11 @@
@@ -71,11 +72,11 @@
return content::DesktopMediaID::Type::TYPE_SCREEN;
case DesktopMediaList::Type::kWindow:
return content::DesktopMediaID::Type::TYPE_WINDOW;
@@ -200,8 +191,8 @@ index 47a5ad2b7e2bc86a614488fd3fe85da1e3e2d6f2..fcc63aaf488b598db705e07274914ead
}
NOTREACHED();
}
@@ -480,7 +481,7 @@ void OnCapturedFrame(base::apple::ScopedCFTypeRef<CGImageRef> image,
minimum_window_size_(kThumbnailCapturerMacMinWindowSize.Get()),
@@ -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);
@@ -209,7 +200,7 @@ index 47a5ad2b7e2bc86a614488fd3fe85da1e3e2d6f2..fcc63aaf488b598db705e07274914ead
}
ThumbnailCapturerMac::~ThumbnailCapturerMac() {
@@ -761,17 +762,18 @@ void OnCapturedFrame(base::apple::ScopedCFTypeRef<CGImageRef> image,
@@ -680,17 +681,18 @@ void OnCapturedFrame(base::apple::ScopedCFTypeRef<CGImageRef> image,
source_id);
}
@@ -230,7 +221,7 @@ index 47a5ad2b7e2bc86a614488fd3fe85da1e3e2d6f2..fcc63aaf488b598db705e07274914ead
bool ShouldUseThumbnailCapturerMac(DesktopMediaList::Type type) {
// There was a bug in ScreenCaptureKit that was fixed in 14.4,
// see b/40076027.
@@ -785,6 +787,9 @@ bool ShouldUseThumbnailCapturerMac(DesktopMediaList::Type type) {
@@ -704,6 +706,9 @@ bool ShouldUseThumbnailCapturerMac(DesktopMediaList::Type type) {
return ShouldUseSCContentSharingPicker() ||
base::FeatureList::IsEnabled(kScreenCaptureKitPickerScreen);
case DesktopMediaList::Type::kNone:
@@ -241,10 +232,10 @@ index 47a5ad2b7e2bc86a614488fd3fe85da1e3e2d6f2..fcc63aaf488b598db705e07274914ead
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 6618477648b7148ba66f5bb695be8eb6da045849..a8888d359324a826a2c8188e8631b643a8e1df5d 100644
index b4b1e9ee805a8565a04737e0898ad8e46709c4d8..7b856f89028fe8f5594c1ff35900019250865ab5 100644
--- a/content/browser/media/capture/desktop_capture_device.cc
+++ b/content/browser/media/capture/desktop_capture_device.cc
@@ -808,7 +808,6 @@ std::unique_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create(
@@ -899,7 +899,6 @@ std::unique_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create(
result.reset(new DesktopCaptureDevice(std::move(capturer), source.type));
return result;
}
@@ -252,7 +243,7 @@ index 6618477648b7148ba66f5bb695be8eb6da045849..a8888d359324a826a2c8188e8631b643
switch (source.type) {
case DesktopMediaID::TYPE_SCREEN: {
std::unique_ptr<webrtc::DesktopCapturer> screen_capturer;
@@ -829,7 +828,7 @@ std::unique_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create(
@@ -920,7 +919,7 @@ std::unique_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create(
}
break;
}
@@ -274,10 +265,10 @@ index 152f3aa78032ee3f8c48fbefe052a2f1d85bed6b..d57df80dff9c6867cddf669efe3f90c4
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 f3dbdd0db5f6c3d07b600f3dfa3267d0a5a57b81..2b37a27d37a994694855afed441ae82fe2671c90 100644
index 0dbc7ebc4ba6066eb6b20f8e66f50a1dff4d94f3..f36948241260f39665375a105c40d7725561d776 100644
--- a/content/browser/media/capture/native_screen_capture_picker_mac.mm
+++ b/content/browser/media/capture/native_screen_capture_picker_mac.mm
@@ -138,8 +138,11 @@ void Open(DesktopMediaID::Type type,
@@ -206,8 +206,11 @@ void Open(DesktopMediaID::Type type,
base::OnceClosure cancel_callback,
base::OnceClosure error_callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
@@ -289,8 +280,8 @@ index f3dbdd0db5f6c3d07b600f3dfa3267d0a5a57b81..2b37a27d37a994694855afed441ae82f
+ type == DesktopMediaID::Type::TYPE_NONE);
if (@available(macOS 14.0, *)) {
NSNumber* source_id = @(next_id_);
auto picker_observer = [[PickerObserver alloc]
@@ -157,19 +160,26 @@ void Open(DesktopMediaID::Type type,
PickerObserver* picker_observer = [[PickerObserver alloc]
@@ -226,25 +229,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.
@@ -302,11 +293,17 @@ index f3dbdd0db5f6c3d07b600f3dfa3267d0a5a57b81..2b37a27d37a994694855afed441ae82f
- 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,
@@ -321,27 +318,25 @@ index f3dbdd0db5f6c3d07b600f3dfa3267d0a5a57b81..2b37a27d37a994694855afed441ae82f
+ // 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();
}
@@ -209,7 +219,6 @@ void Open(DesktopMediaID::Type type,
filter = [picker_observer contentFilter];
cached_content_filters_[source_id] = filter;
}
-
return CreateScreenCaptureKitDeviceMac(source, filter);
}
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 e99684a6b70f5d344cfcd4b1271c4abb349f3797..a2c3f28de65d35bc81a3d49c7ae777613a7a4b3e 100644
index 0e4a68f2fd8179640f877cb258b4049610fd49da..0fb8d036b7696e5303fbcd463114114aa3227a08 100644
--- a/content/browser/media/capture/screen_capture_kit_device_mac.mm
+++ b/content/browser/media/capture/screen_capture_kit_device_mac.mm
@@ -340,6 +340,7 @@ void OnShareableContentCreated(SCShareableContent* content) {
@@ -364,6 +364,7 @@ void OnShareableContentCreated(SCShareableContent* content) {
if (!fullscreen_module_) {
fullscreen_module_ = MaybeCreateScreenCaptureKitFullscreenModule(
device_task_runner_, *this, window);
@@ -349,7 +344,7 @@ index e99684a6b70f5d344cfcd4b1271c4abb349f3797..a2c3f28de65d35bc81a3d49c7ae77761
}
}
}
@@ -700,6 +701,7 @@ void ResetStreamTo(SCWindow* window) override {
@@ -728,6 +729,7 @@ void ResetStreamTo(SCWindow* window) override {
SCContentFilter* filter) {
switch (source.type) {
case DesktopMediaID::TYPE_SCREEN:
@@ -358,10 +353,10 @@ index e99684a6b70f5d344cfcd4b1271c4abb349f3797..a2c3f28de65d35bc81a3d49c7ae77761
// 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 ee080009f75a0b9e07a12f929086008454ef8621..7163b1c4ce38a1ad0e0df105a6e28cf213934ae0 100644
index f0f08a834f06c7669da6030640434308a5cbd056..819c295157cc8240ea2f9034491fb998f67dc643 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
@@ -189,13 +189,13 @@ DesktopCaptureImplementation CreatePlatformDependentVideoCaptureDevice(
@@ -177,19 +177,21 @@ DesktopCaptureImplementation CreatePlatformDependentVideoCaptureDevice(
#if BUILDFLAG(IS_MAC)
// Use ScreenCaptureKit with picker if specified. `desktop_id` for the picker
// is not compatible with the other implementations.
@@ -382,9 +377,7 @@ index ee080009f75a0b9e07a12f929086008454ef8621..7163b1c4ce38a1ad0e0df105a6e28cf2
// Prefer using ScreenCaptureKit. After that try DesktopCaptureDeviceMac, and
// if both fail, use the generic DesktopCaptureDevice.
@@ -203,7 +203,9 @@ DesktopCaptureImplementation CreatePlatformDependentVideoCaptureDevice(
(desktop_id.type == DesktopMediaID::TYPE_WINDOW &&
base::FeatureList::IsEnabled(kScreenCaptureKitMacWindow)) ||
if (desktop_id.type == DesktopMediaID::TYPE_WINDOW ||
(desktop_id.type == DesktopMediaID::TYPE_SCREEN &&
- base::FeatureList::IsEnabled(kScreenCaptureKitMacScreen))) {
+ base::FeatureList::IsEnabled(kScreenCaptureKitMacScreen)) ||
@@ -393,7 +386,7 @@ index ee080009f75a0b9e07a12f929086008454ef8621..7163b1c4ce38a1ad0e0df105a6e28cf2
device_out = CreateScreenCaptureKitDeviceMac(desktop_id);
if (device_out) {
return kScreenCaptureKitDeviceMac;
@@ -249,6 +251,9 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
@@ -237,6 +239,9 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
DCHECK(state_ == State::READY_TO_LAUNCH);
if (receiver_on_io_thread) {
@@ -403,7 +396,7 @@ index ee080009f75a0b9e07a12f929086008454ef8621..7163b1c4ce38a1ad0e0df105a6e28cf2
std::ostringstream string_stream;
string_stream
<< "InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync: Posting "
@@ -269,12 +274,14 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
@@ -257,12 +262,14 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
base::BindPostTaskToCurrentDefault(base::BindOnce(
&InProcessVideoCaptureDeviceLauncher::OnDeviceStarted,
base::Unretained(this), callbacks, std::move(done_cb)));
@@ -423,7 +416,7 @@ index ee080009f75a0b9e07a12f929086008454ef8621..7163b1c4ce38a1ad0e0df105a6e28cf2
#if BUILDFLAG(ENABLE_SCREEN_CAPTURE)
case blink::mojom::MediaStreamType::GUM_TAB_VIDEO_CAPTURE:
start_capture_closure = base::BindOnce(
@@ -286,10 +293,10 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
@@ -274,10 +281,10 @@ 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:
@@ -436,7 +429,7 @@ index ee080009f75a0b9e07a12f929086008454ef8621..7163b1c4ce38a1ad0e0df105a6e28cf2
start_capture_closure =
base::BindOnce(std::move(after_start_capture_callback), nullptr);
break;
@@ -331,6 +338,7 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
@@ -319,6 +326,7 @@ void InProcessVideoCaptureDeviceLauncher::LaunchDeviceAsync(
#if defined(USE_AURA)
bool allow_window_id = false;
#elif BUILDFLAG(IS_MAC)
@@ -444,7 +437,7 @@ index ee080009f75a0b9e07a12f929086008454ef8621..7163b1c4ce38a1ad0e0df105a6e28cf2
bool allow_window_id =
desktop_id.id == DesktopMediaID::kMacOsNativePickerId;
#endif
@@ -517,7 +525,8 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread(
@@ -505,7 +513,8 @@ void InProcessVideoCaptureDeviceLauncher::DoStartDesktopCaptureOnDeviceThread(
std::unique_ptr<media::VideoCaptureDeviceClient> device_client,
ReceiveDeviceCallback result_callback) {
DCHECK(device_task_runner_->BelongsToCurrentThread());