|
@@ -14,11 +14,7 @@
|
|
|
#include "chrome/browser/media/webrtc/desktop_media_list.h"
|
|
|
#include "chrome/browser/media/webrtc/window_icon_util.h"
|
|
|
#include "content/public/browser/desktop_capture.h"
|
|
|
-#include "content/public/browser/desktop_streams_registry.h"
|
|
|
-#include "content/public/browser/render_frame_host.h"
|
|
|
-#include "content/public/browser/render_process_host.h"
|
|
|
#include "gin/object_template_builder.h"
|
|
|
-#include "shell/browser/api/electron_api_web_contents.h"
|
|
|
#include "shell/browser/javascript_environment.h"
|
|
|
#include "shell/common/api/electron_api_native_image.h"
|
|
|
#include "shell/common/gin_converters/gfx_converter.h"
|
|
@@ -27,7 +23,6 @@
|
|
|
#include "shell/common/node_includes.h"
|
|
|
#include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
|
|
|
#include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
|
|
|
-#include "url/origin.h"
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
#include "third_party/webrtc/modules/desktop_capture/win/dxgi_duplicator_controller.h"
|
|
@@ -208,52 +203,6 @@ gin::Handle<DesktopCapturer> DesktopCapturer::Create(v8::Isolate* isolate) {
|
|
|
return gin::CreateHandle(isolate, new DesktopCapturer(isolate));
|
|
|
}
|
|
|
|
|
|
-// static
|
|
|
-std::string DesktopCapturer::GetMediaSourceIdForWebContents(
|
|
|
- v8::Isolate* isolate,
|
|
|
- gin_helper::ErrorThrower thrower,
|
|
|
- int32_t request_web_contents_id,
|
|
|
- int32_t web_contents_id) {
|
|
|
- std::string id;
|
|
|
- auto* web_contents = WebContents::FromID(web_contents_id);
|
|
|
-
|
|
|
- if (!web_contents) {
|
|
|
- thrower.ThrowError("Failed to find WebContents with id " +
|
|
|
- std::to_string(web_contents_id));
|
|
|
- return id;
|
|
|
- }
|
|
|
-
|
|
|
- auto* main_frame = web_contents->web_contents()->GetMainFrame();
|
|
|
- DCHECK(main_frame);
|
|
|
- content::DesktopMediaID media_id(
|
|
|
- content::DesktopMediaID::TYPE_WEB_CONTENTS,
|
|
|
- content::DesktopMediaID::kNullId,
|
|
|
- content::WebContentsMediaCaptureId(main_frame->GetProcess()->GetID(),
|
|
|
- main_frame->GetRoutingID()));
|
|
|
-
|
|
|
- auto* request_web_contents = WebContents::FromID(request_web_contents_id);
|
|
|
- if (request_web_contents) {
|
|
|
- // comment copied from
|
|
|
- // chrome/browser/extensions/api/desktop_capture/desktop_capture_base.cc
|
|
|
- // TODO(miu): Once render_frame_host() is being set, we should register the
|
|
|
- // exact RenderFrame requesting the stream, not the main RenderFrame. With
|
|
|
- // that change, also update
|
|
|
- // MediaCaptureDevicesDispatcher::ProcessDesktopCaptureAccessRequest().
|
|
|
- // http://crbug.com/304341
|
|
|
- auto* const request_main_frame =
|
|
|
- request_web_contents->web_contents()->GetMainFrame();
|
|
|
- DCHECK(request_main_frame);
|
|
|
- id = content::DesktopStreamsRegistry::GetInstance()->RegisterStream(
|
|
|
- request_main_frame->GetProcess()->GetID(),
|
|
|
- request_main_frame->GetRoutingID(),
|
|
|
- url::Origin::Create(
|
|
|
- request_main_frame->GetLastCommittedURL().GetOrigin()),
|
|
|
- media_id, "", content::kRegistryStreamTypeTab);
|
|
|
- }
|
|
|
-
|
|
|
- return id;
|
|
|
-}
|
|
|
-
|
|
|
gin::ObjectTemplateBuilder DesktopCapturer::GetObjectTemplateBuilder(
|
|
|
v8::Isolate* isolate) {
|
|
|
return gin::Wrappable<DesktopCapturer>::GetObjectTemplateBuilder(isolate)
|
|
@@ -277,9 +226,6 @@ void Initialize(v8::Local<v8::Object> exports,
|
|
|
gin_helper::Dictionary dict(context->GetIsolate(), exports);
|
|
|
dict.SetMethod("createDesktopCapturer",
|
|
|
&electron::api::DesktopCapturer::Create);
|
|
|
- dict.SetMethod(
|
|
|
- "getMediaSourceIdForWebContents",
|
|
|
- &electron::api::DesktopCapturer::GetMediaSourceIdForWebContents);
|
|
|
}
|
|
|
|
|
|
} // namespace
|