Merge pull request #10308 from electron/native-view

Add WebContents.getNativeView() API
This commit is contained in:
Cheng Zhao 2017-08-22 09:19:27 +09:00 committed by GitHub
commit 565ece6986
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) { v8::Local<v8::Value> WebContents::DevToolsWebContents(v8::Isolate* isolate) {
if (devtools_web_contents_.IsEmpty()) if (devtools_web_contents_.IsEmpty())
return v8::Null(isolate); return v8::Null(isolate);
@ -1894,6 +1904,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
.SetMethod("copyImageAt", &WebContents::CopyImageAt) .SetMethod("copyImageAt", &WebContents::CopyImageAt)
.SetMethod("capturePage", &WebContents::CapturePage) .SetMethod("capturePage", &WebContents::CapturePage)
.SetMethod("setEmbedder", &WebContents::SetEmbedder) .SetMethod("setEmbedder", &WebContents::SetEmbedder)
.SetMethod("getNativeView", &WebContents::GetNativeView)
.SetMethod("setWebRTCIPHandlingPolicy", .SetMethod("setWebRTCIPHandlingPolicy",
&WebContents::SetWebRTCIPHandlingPolicy) &WebContents::SetWebRTCIPHandlingPolicy)
.SetMethod("getWebRTCIPHandlingPolicy", .SetMethod("getWebRTCIPHandlingPolicy",

View file

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