feat: add support for system picker in setDisplayMediaRequestHandler (#43679)

* tmp

Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>

* feat: add support for system picker in setDisplayMediaRequestHandler

Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>

* oops

Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>

* Apply suggestions from code review

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

Co-authored-by: Samuel Attard <sam@electronjs.org>

* stuff

Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>

* well...

Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>

* seems legit

Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>

* chore: update patch to handle screenCapturer

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* feat: modify API to use useSystemPicker

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* fix: gate ScreenCaptureKitPicker to macos 15 or higher

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* fix: don't use native picker with legacy media selection

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* chore: code review, boolean set & docs update

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* fix: add cancelCallback

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* docs: clarify session & desktopCapturer docs

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* chore: remove incorrect backport patches

* chore: update SCKP patch

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Samuel Attard <marshallofsound@electronjs.org>
Co-authored-by: Samuel Attard <sam@electronjs.org>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
This commit is contained in:
trop[bot] 2024-09-11 09:56:47 -07:00 committed by GitHub
parent fa1311e550
commit 097c6b796d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 409 additions and 6 deletions

View file

@ -502,6 +502,13 @@ gin::Handle<DesktopCapturer> DesktopCapturer::Create(v8::Isolate* isolate) {
return handle;
}
// static
#if !BUILDFLAG(IS_MAC)
bool DesktopCapturer::IsDisplayMediaSystemPickerAvailable() {
return false;
}
#endif
gin::ObjectTemplateBuilder DesktopCapturer::GetObjectTemplateBuilder(
v8::Isolate* isolate) {
return gin::Wrappable<DesktopCapturer>::GetObjectTemplateBuilder(isolate)
@ -523,6 +530,9 @@ void Initialize(v8::Local<v8::Object> exports,
gin_helper::Dictionary dict(context->GetIsolate(), exports);
dict.SetMethod("createDesktopCapturer",
&electron::api::DesktopCapturer::Create);
dict.SetMethod(
"isDisplayMediaSystemPickerAvailable",
&electron::api::DesktopCapturer::IsDisplayMediaSystemPickerAvailable);
}
} // namespace

View file

@ -32,6 +32,8 @@ class DesktopCapturer final : public gin::Wrappable<DesktopCapturer>,
static gin::Handle<DesktopCapturer> Create(v8::Isolate* isolate);
static bool IsDisplayMediaSystemPickerAvailable();
void StartHandling(bool capture_window,
bool capture_screen,
const gfx::Size& thumbnail_size,

View file

@ -0,0 +1,17 @@
// Copyright (c) 2024 Salesforce, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#include "shell/browser/api/electron_api_desktop_capturer.h"
namespace electron::api {
// static
bool DesktopCapturer::IsDisplayMediaSystemPickerAvailable() {
if (@available(macOS 15.0, *)) {
return true;
}
return false;
}
} // namespace electron::api

View file

@ -1607,7 +1607,7 @@ void Session::FillObjectTemplate(v8::Isolate* isolate,
&Session::SetPermissionRequestHandler)
.SetMethod("setPermissionCheckHandler",
&Session::SetPermissionCheckHandler)
.SetMethod("setDisplayMediaRequestHandler",
.SetMethod("_setDisplayMediaRequestHandler",
&Session::SetDisplayMediaRequestHandler)
.SetMethod("setDevicePermissionHandler",
&Session::SetDevicePermissionHandler)