Always initailize webContents in BrowserWindow
This commit is contained in:
parent
8c83dfe918
commit
f198148c79
2 changed files with 14 additions and 6 deletions
|
@ -49,6 +49,13 @@ Window::~Window() {
|
|||
Destroy();
|
||||
}
|
||||
|
||||
void Window::AfterInit(v8::Isolate* isolate) {
|
||||
mate::TrackableObject<Window>::AfterInit(isolate);
|
||||
auto web_contents = window_->managed_web_contents();
|
||||
auto handle = WebContents::CreateFrom(isolate, web_contents);
|
||||
web_contents_.Reset(isolate, handle.ToV8());
|
||||
}
|
||||
|
||||
void Window::OnPageTitleUpdated(bool* prevent_default,
|
||||
const std::string& title) {
|
||||
*prevent_default = Emit("page-title-updated", title);
|
||||
|
@ -441,12 +448,10 @@ int32_t Window::ID() const {
|
|||
}
|
||||
|
||||
v8::Local<v8::Value> Window::WebContents(v8::Isolate* isolate) {
|
||||
if (web_contents_.IsEmpty()) {
|
||||
auto handle =
|
||||
WebContents::CreateFrom(isolate, window_->managed_web_contents());
|
||||
web_contents_.Reset(isolate, handle.ToV8());
|
||||
}
|
||||
return v8::Local<v8::Value>::New(isolate, web_contents_);
|
||||
if (web_contents_.IsEmpty())
|
||||
return v8::Null(isolate);
|
||||
else
|
||||
return v8::Local<v8::Value>::New(isolate, web_contents_);
|
||||
}
|
||||
|
||||
v8::Local<v8::Value> Window::DevToolsWebContents(v8::Isolate* isolate) {
|
||||
|
|
|
@ -52,6 +52,9 @@ class Window : public mate::TrackableObject<Window>,
|
|||
explicit Window(const mate::Dictionary& options);
|
||||
virtual ~Window();
|
||||
|
||||
// mate::Wrappable:
|
||||
void AfterInit(v8::Isolate* isolate) override;
|
||||
|
||||
// NativeWindowObserver:
|
||||
void OnPageTitleUpdated(bool* prevent_default,
|
||||
const std::string& title) override;
|
||||
|
|
Loading…
Reference in a new issue