Add WebContents.getOwnerBrowserWindow

This commit is contained in:
Cheng Zhao 2015-10-01 13:45:59 +08:00
parent 83c514001e
commit f2c7943d42
5 changed files with 30 additions and 1 deletions

View file

@ -92,6 +92,7 @@ Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) {
web_contents->SetOwnerWindow(window_.get());
window_->InitFromOptions(options);
window_->AddObserver(this);
AttachAsUserData(window_.get());
}
Window::~Window() {
@ -592,6 +593,16 @@ void Window::BuildPrototype(v8::Isolate* isolate,
.SetProperty("webContents", &Window::WebContents, true);
}
// static
v8::Local<v8::Value> Window::From(v8::Isolate* isolate,
NativeWindow* native_window) {
auto existing = TrackableObject::FromWrappedClass(isolate, native_window);
if (existing)
return existing->GetWrapper(isolate);
else
return v8::Null(isolate);
}
} // namespace api
} // namespace atom