Add WebContents.getNativeView API

This commit is contained in:
Cheng Zhao 2017-08-21 19:50:12 +09:00
parent dede3d6213
commit 2c1984b6ed
2 changed files with 12 additions and 0 deletions

View file

@ -1783,6 +1783,16 @@ void WebContents::SetEmbedder(const WebContents* embedder) {
}
}
v8::Local<v8::Value> WebContents::GetNativeView() const {
gfx::NativeView ptr = web_contents()->GetNativeView();
auto buffer = node::Buffer::Copy(
isolate(), reinterpret_cast<char*>(&ptr), sizeof(gfx::NativeView));
if (buffer.IsEmpty())
return v8::Null(isolate());
else
return buffer.ToLocalChecked();
}
v8::Local<v8::Value> 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",

View file

@ -125,6 +125,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
void Print(mate::Arguments* args);
std::vector<printing::PrinterBasicInfo> GetPrinterList();
void SetEmbedder(const WebContents* embedder);
v8::Local<v8::Value> GetNativeView() const;
// Print current page as PDF.
void PrintToPDF(const base::DictionaryValue& setting,