Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions patches/chromium/desktop_media_list.patch
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ Date: Thu, 18 Oct 2018 17:07:01 -0700
Subject: desktop_media_list.patch

* Use our grit resources instead of the chrome ones.
* Disabled WindowCaptureMacV2 feature for https://github.com/electron/electron/pull/30507
* Ensure "OnRefreshComplete()" even if there are no items in the list

diff --git a/chrome/browser/media/webrtc/desktop_media_list.h b/chrome/browser/media/webrtc/desktop_media_list.h
Expand Down Expand Up @@ -82,18 +81,9 @@ index 33ca7a53dfb6d2c9e3a33f0065a3acd806e82e01..9fdf2e8ff0056ff407015b914c6b03eb
const Source& GetSource(int index) const override;
DesktopMediaList::Type GetMediaListType() const override;
diff --git a/chrome/browser/media/webrtc/native_desktop_media_list.cc b/chrome/browser/media/webrtc/native_desktop_media_list.cc
index b548c9fbd3c0bf425447b29dcd866cd27e96b14c..f994ac6086c7b4cd3e8534f34691189d78a21601 100644
index b548c9fbd3c0bf425447b29dcd866cd27e96b14c..1e4c572deb0b20416f3fa65f7fe6d33612e3b691 100644
--- a/chrome/browser/media/webrtc/native_desktop_media_list.cc
+++ b/chrome/browser/media/webrtc/native_desktop_media_list.cc
@@ -147,7 +147,7 @@ BOOL CALLBACK AllHwndCollector(HWND hwnd, LPARAM param) {
#if BUILDFLAG(IS_MAC)
BASE_FEATURE(kWindowCaptureMacV2,
"WindowCaptureMacV2",
- base::FEATURE_ENABLED_BY_DEFAULT);
+ base::FEATURE_DISABLED_BY_DEFAULT);
#endif

} // namespace
@@ -457,6 +457,9 @@ void NativeDesktopMediaList::Worker::RefreshNextThumbnail() {
FROM_HERE,
base::BindOnce(&NativeDesktopMediaList::UpdateNativeThumbnailsFinished,
Expand Down
4 changes: 3 additions & 1 deletion shell/browser/api/electron_api_desktop_capturer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,10 @@ struct Converter<electron::api::DesktopCapturer::Source> {
v8::Isolate* isolate,
const electron::api::DesktopCapturer::Source& source) {
gin_helper::Dictionary dict = gin::Dictionary::CreateEmpty(isolate);
content::DesktopMediaID id = source.media_list_source.id;
dict.Set("name", base::UTF16ToUTF8(source.media_list_source.name));
content::DesktopMediaID id = source.media_list_source.id;
if (id.window_id == id.id)
id.window_id = content::DesktopMediaID::kNullId;
dict.Set("id", id.ToString());
dict.Set("thumbnail",
electron::api::NativeImage::Create(
Expand Down
14 changes: 2 additions & 12 deletions shell/browser/native_window_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1240,18 +1240,8 @@ void ViewDidMoveToSuperview(NSView* self, SEL _cmd) {
}

content::DesktopMediaID NativeWindowMac::GetDesktopMediaID() const {
auto desktop_media_id = content::DesktopMediaID(
content::DesktopMediaID::TYPE_WINDOW, GetAcceleratedWidget());
// c.f.
// https://source.chromium.org/chromium/chromium/src/+/main:chrome/browser/media/webrtc/native_desktop_media_list.cc;l=775-780;drc=79502ab47f61bff351426f57f576daef02b1a8dc
// Refs https://github.com/electron/electron/pull/30507
// TODO(deepak1556): Match upstream for `kWindowCaptureMacV2`
#if 0
if (remote_cocoa::ScopedCGWindowID::Get(desktop_media_id.id)) {
desktop_media_id.window_id = desktop_media_id.id;

@deepak1556 deepak1556 Jan 26, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deepak1556 we could do this, but then it would be invalid when for example passed into getUserMedia. I made this change for the same reason i did this one: https://github.com/electron/electron/pull/37014/files#diff-73f755a575b1c517f40cd8358386c43c4ffb0eff9e8a7a9ab80c5f50a248dcf4R156

}
#endif
return desktop_media_id;
return content::DesktopMediaID(content::DesktopMediaID::TYPE_WINDOW,
GetAcceleratedWidget());
}

NativeWindowHandle NativeWindowMac::GetNativeWindowHandle() const {
Expand Down
7 changes: 6 additions & 1 deletion spec/api-desktop-capturer-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ ifdescribe(!process.arch.includes('arm') && process.platform !== 'win32')('deskt
});

it('getSources should not incorrectly duplicate window_id', async () => {
const w = new BrowserWindow({ show: false, width: 100, height: 100, webPreferences: { contextIsolation: false } });
const w = new BrowserWindow({
show: false,
width: 100,
height: 100,
webPreferences: { contextIsolation: false }
});
const wShown = once(w, 'show');
const wFocused = once(w, 'focus');
w.show();
Expand Down