feat: add support for system picker in setDisplayMediaRequestHandler (#43581)
* tmp * feat: add support for system picker in setDisplayMediaRequestHandler * oops * Apply suggestions from code review Co-authored-by: Erick Zhao <erick@hotmail.ca> * stuff * well... * seems legit * chore: update patch to handle screenCapturer * feat: modify API to use useSystemPicker * fix: gate ScreenCaptureKitPicker to macos 15 or higher * fix: don't use native picker with legacy media selection * chore: code review, boolean set & docs update * fix: add cancelCallback * docs: clarify session & desktopCapturer docs --------- Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> Co-authored-by: Samuel Attard <sam@electronjs.org> Co-authored-by: Erick Zhao <erick@hotmail.ca>
This commit is contained in:
parent
a3df950281
commit
309d5dade3
16 changed files with 432 additions and 6 deletions
|
@ -503,6 +503,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)
|
||||
|
@ -524,6 +531,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
|
||||
|
|
|
@ -36,6 +36,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,
|
||||
|
|
17
shell/browser/api/electron_api_desktop_capturer_mac.mm
Normal file
17
shell/browser/api/electron_api_desktop_capturer_mac.mm
Normal 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
|
|
@ -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)
|
||||
|
|
|
@ -58,6 +58,11 @@ void InitializeFeatureList() {
|
|||
if (platform_specific_enable_features.size() > 0) {
|
||||
enable_features += std::string(",") + platform_specific_enable_features;
|
||||
}
|
||||
std::string platform_specific_disable_features =
|
||||
DisablePlatformSpecificFeatures();
|
||||
if (platform_specific_disable_features.size() > 0) {
|
||||
disable_features += std::string(",") + platform_specific_disable_features;
|
||||
}
|
||||
base::FeatureList::InitInstance(enable_features, disable_features);
|
||||
}
|
||||
|
||||
|
@ -73,6 +78,9 @@ void InitializeFieldTrials() {
|
|||
std::string EnablePlatformSpecificFeatures() {
|
||||
return "";
|
||||
}
|
||||
std::string DisablePlatformSpecificFeatures() {
|
||||
return "";
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace electron
|
||||
|
|
|
@ -11,6 +11,7 @@ namespace electron {
|
|||
void InitializeFeatureList();
|
||||
void InitializeFieldTrials();
|
||||
std::string EnablePlatformSpecificFeatures();
|
||||
std::string DisablePlatformSpecificFeatures();
|
||||
} // namespace electron
|
||||
|
||||
#endif // ELECTRON_SHELL_BROWSER_FEATURE_LIST_H_
|
||||
|
|
|
@ -31,4 +31,13 @@ std::string EnablePlatformSpecificFeatures() {
|
|||
return "";
|
||||
}
|
||||
|
||||
std::string DisablePlatformSpecificFeatures() {
|
||||
if (@available(macOS 14.4, *)) {
|
||||
// Required to stop timing out getDisplayMedia while waiting for
|
||||
// the user to select a window with the picker
|
||||
return "TimeoutHangingVideoCaptureStarts";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
} // namespace electron
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue