feat: session.setDisplayMediaRequestHandler (#30702)
This commit is contained in:
parent
0c04be502c
commit
221bb51326
14 changed files with 711 additions and 11 deletions
|
@ -26,6 +26,19 @@ v8::Local<v8::Value> Converter<content::RenderFrameHost*>::ToV8(
|
|||
return electron::api::WebFrameMain::From(isolate, val).ToV8();
|
||||
}
|
||||
|
||||
// static
|
||||
bool Converter<content::RenderFrameHost*>::FromV8(
|
||||
v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
content::RenderFrameHost** out) {
|
||||
electron::api::WebFrameMain* web_frame_main = nullptr;
|
||||
if (!ConvertFromV8(isolate, val, &web_frame_main))
|
||||
return false;
|
||||
*out = web_frame_main->render_frame_host();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// static
|
||||
v8::Local<v8::Value>
|
||||
Converter<gin_helper::AccessorValue<content::RenderFrameHost*>>::ToV8(
|
||||
|
|
|
@ -18,6 +18,9 @@ template <>
|
|||
struct Converter<content::RenderFrameHost*> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
content::RenderFrameHost* val);
|
||||
static bool FromV8(v8::Isolate* isolate,
|
||||
v8::Local<v8::Value> val,
|
||||
content::RenderFrameHost** out);
|
||||
};
|
||||
|
||||
template <>
|
||||
|
|
36
shell/common/gin_converters/media_converter.cc
Normal file
36
shell/common/gin_converters/media_converter.cc
Normal file
|
@ -0,0 +1,36 @@
|
|||
// Copyright (c) 2021 Slack Technologies, LLC.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/common/gin_converters/media_converter.h"
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "content/public/browser/media_stream_request.h"
|
||||
#include "content/public/browser/render_frame_host.h"
|
||||
#include "gin/data_object_builder.h"
|
||||
#include "shell/common/gin_converters/frame_converter.h"
|
||||
#include "shell/common/gin_converters/gurl_converter.h"
|
||||
#include "shell/common/gin_helper/dictionary.h"
|
||||
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom.h"
|
||||
|
||||
namespace gin {
|
||||
|
||||
v8::Local<v8::Value> Converter<content::MediaStreamRequest>::ToV8(
|
||||
v8::Isolate* isolate,
|
||||
const content::MediaStreamRequest& request) {
|
||||
content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(
|
||||
request.render_process_id, request.render_frame_id);
|
||||
return gin::DataObjectBuilder(isolate)
|
||||
.Set("frame", rfh)
|
||||
.Set("securityOrigin", request.security_origin)
|
||||
.Set("userGesture", request.user_gesture)
|
||||
.Set("videoRequested",
|
||||
request.video_type != blink::mojom::MediaStreamType::NO_SERVICE)
|
||||
.Set("audioRequested",
|
||||
request.audio_type != blink::mojom::MediaStreamType::NO_SERVICE)
|
||||
.Build();
|
||||
}
|
||||
|
||||
} // namespace gin
|
26
shell/common/gin_converters/media_converter.h
Normal file
26
shell/common/gin_converters/media_converter.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright (c) 2021 Slack Technologies, LLC.
|
||||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef ELECTRON_SHELL_COMMON_GIN_CONVERTERS_MEDIA_CONVERTER_H_
|
||||
#define ELECTRON_SHELL_COMMON_GIN_CONVERTERS_MEDIA_CONVERTER_H_
|
||||
|
||||
#include "gin/converter.h"
|
||||
#include "third_party/blink/public/common/mediastream/media_stream_request.h"
|
||||
#include "third_party/blink/public/mojom/mediastream/media_stream.mojom-forward.h"
|
||||
|
||||
namespace content {
|
||||
struct MediaStreamRequest;
|
||||
}
|
||||
|
||||
namespace gin {
|
||||
|
||||
template <>
|
||||
struct Converter<content::MediaStreamRequest> {
|
||||
static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
|
||||
const content::MediaStreamRequest& request);
|
||||
};
|
||||
|
||||
} // namespace gin
|
||||
|
||||
#endif // ELECTRON_SHELL_COMMON_GIN_CONVERTERS_MEDIA_CONVERTER_H_
|
Loading…
Add table
Add a link
Reference in a new issue