From: Cheng Zhao Date: Wed, 24 Jun 2015 11:04:08 +0000 (+0800) Subject: Always initailize webContents in BrowserWindow X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f198148c7987eb1d312927178ab41a5b30774e50;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Always initailize webContents in BrowserWindow --- diff --git a/atom/browser/api/atom_api_window.cc b/atom/browser/api/atom_api_window.cc index d764cee..0ee56db 100644 --- a/atom/browser/api/atom_api_window.cc +++ b/atom/browser/api/atom_api_window.cc @@ -49,6 +49,13 @@ Window::~Window() { Destroy(); } +void Window::AfterInit(v8::Isolate* isolate) { + mate::TrackableObject::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 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::New(isolate, web_contents_); + if (web_contents_.IsEmpty()) + return v8::Null(isolate); + else + return v8::Local::New(isolate, web_contents_); } v8::Local Window::DevToolsWebContents(v8::Isolate* isolate) { diff --git a/atom/browser/api/atom_api_window.h b/atom/browser/api/atom_api_window.h index 0c4cd76..87eabaf 100644 --- a/atom/browser/api/atom_api_window.h +++ b/atom/browser/api/atom_api_window.h @@ -52,6 +52,9 @@ class Window : public mate::TrackableObject, 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;