Skip to content

Commit 0f62096

Browse files
Added screen sharing option for systemPreferences.AskForMediaAccess
1 parent 22a876a commit 0f62096

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

shell/browser/api/electron_api_system_preferences_mac.mm

+7-2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "shell/common/node_includes.h"
3333
#include "shell/common/process_util.h"
3434
#include "skia/ext/skia_utils_mac.h"
35+
#include "ui/base/cocoa/permissions_utils.h"
3536
#include "ui/native_theme/native_theme.h"
3637

3738
namespace gin {
@@ -604,8 +605,12 @@ AVMediaType ParseMediaType(const std::string& media_type) {
604605
const std::string& media_type) {
605606
gin_helper::Promise<bool> promise(isolate);
606607
v8::Local<v8::Promise> handle = promise.GetHandle();
607-
608-
if (auto type = ParseMediaType(media_type)) {
608+
if (media_type == "screen") {
609+
if (@available(macOS 10.15, *)) {
610+
CGWindowListCreateImage(CGRectMake(0, 0, 1, 1), kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault);
611+
}
612+
promise.Resolve(ui::TryPromptUserForScreenCapture());
613+
} else if (auto type = ParseMediaType(media_type)) {
609614
if (@available(macOS 10.14, *)) {
610615
__block gin_helper::Promise<bool> p = std::move(promise);
611616
[AVCaptureDevice requestAccessForMediaType:type

0 commit comments

Comments
 (0)