diff --git a/atom/browser/api/atom_api_web_contents.cc b/atom/browser/api/atom_api_web_contents.cc index 244c52654c..708b9c902b 100644 --- a/atom/browser/api/atom_api_web_contents.cc +++ b/atom/browser/api/atom_api_web_contents.cc @@ -1783,6 +1783,16 @@ void WebContents::SetEmbedder(const WebContents* embedder) { } } +v8::Local WebContents::GetNativeView() const { + gfx::NativeView ptr = web_contents()->GetNativeView(); + auto buffer = node::Buffer::Copy( + isolate(), reinterpret_cast(&ptr), sizeof(gfx::NativeView)); + if (buffer.IsEmpty()) + return v8::Null(isolate()); + else + return buffer.ToLocalChecked(); +} + v8::Local WebContents::DevToolsWebContents(v8::Isolate* isolate) { if (devtools_web_contents_.IsEmpty()) return v8::Null(isolate); @@ -1894,6 +1904,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate, .SetMethod("copyImageAt", &WebContents::CopyImageAt) .SetMethod("capturePage", &WebContents::CapturePage) .SetMethod("setEmbedder", &WebContents::SetEmbedder) + .SetMethod("getNativeView", &WebContents::GetNativeView) .SetMethod("setWebRTCIPHandlingPolicy", &WebContents::SetWebRTCIPHandlingPolicy) .SetMethod("getWebRTCIPHandlingPolicy", diff --git a/atom/browser/api/atom_api_web_contents.h b/atom/browser/api/atom_api_web_contents.h index b287cff325..6aeab4e4c7 100644 --- a/atom/browser/api/atom_api_web_contents.h +++ b/atom/browser/api/atom_api_web_contents.h @@ -125,6 +125,7 @@ class WebContents : public mate::TrackableObject, void Print(mate::Arguments* args); std::vector GetPrinterList(); void SetEmbedder(const WebContents* embedder); + v8::Local GetNativeView() const; // Print current page as PDF. void PrintToPDF(const base::DictionaryValue& setting,