]> khamidou — GitHub mirrors - electron.git/commitdiff
Add isDestroyed method for classes with destroy method
authorCheng Zhao <zcbenz@gmail.com>
Thu, 19 Nov 2015 09:08:16 +0000 (17:08 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Thu, 19 Nov 2015 09:08:16 +0000 (17:08 +0800)
atom/browser/api/atom_api_tray.cc
atom/browser/api/atom_api_web_contents.cc
atom/browser/api/atom_api_web_contents.h
atom/browser/api/atom_api_window.cc
atom/browser/api/atom_api_window.h

index d3c5931ad6dae02c1de7a06297e19a40bd8145e0..5e32657f008a305f6c67c7d2d17970b1a3f7e0d7 100644 (file)
@@ -161,6 +161,7 @@ void Tray::BuildPrototype(v8::Isolate* isolate,
                           v8::Local<v8::ObjectTemplate> prototype) {
   mate::ObjectTemplateBuilder(isolate, prototype)
       .SetMethod("destroy", &Tray::Destroy, true)
+      .SetMethod("isDestroyed", &Tray::IsDestroyed, true)
       .SetMethod("setImage", &Tray::SetImage)
       .SetMethod("setPressedImage", &Tray::SetPressedImage)
       .SetMethod("setToolTip", &Tray::SetToolTip)
index 1c3334e93669089948353790f55c3bc3686aebbe..066ca9cc7b65c6a8a7d6da7b46201f97b2107c39 100644 (file)
@@ -604,10 +604,6 @@ void WebContents::Destroy() {
   }
 }
 
-bool WebContents::IsAlive() const {
-  return web_contents() != NULL;
-}
-
 int WebContents::GetID() const {
   return web_contents()->GetRenderProcessHost()->GetID();
 }
@@ -996,7 +992,7 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
   if (template_.IsEmpty())
     template_.Reset(isolate, mate::ObjectTemplateBuilder(isolate)
         .SetMethod("destroy", &WebContents::Destroy, true)
-        .SetMethod("isAlive", &WebContents::IsAlive, true)
+        .SetMethod("isDestroyed", &WebContents::IsDestroyed, true)
         .SetMethod("getId", &WebContents::GetID)
         .SetMethod("equal", &WebContents::Equal)
         .SetMethod("_loadURL", &WebContents::LoadURL)
@@ -1066,7 +1062,7 @@ mate::ObjectTemplateBuilder WebContents::GetObjectTemplateBuilder(
 }
 
 bool WebContents::IsDestroyed() const {
-  return !IsAlive();
+  return !web_contents();
 }
 
 AtomBrowserContext* WebContents::GetBrowserContext() const {
index ae231cd3c61de43a0b75739b0d23c4acfc1d310d..568a563e2c84e29042fcf02e3e9f62583fa3b134 100644 (file)
@@ -57,7 +57,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
   // mate::TrackableObject:
   void Destroy() override;
 
-  bool IsAlive() const;
   int GetID() const;
   bool Equal(const WebContents* web_contents) const;
   void LoadURL(const GURL& url, const mate::Dictionary& options);
index 61f43f9aac387a5a42779f041000816f6e5249e9..7f5b78a79780e7d8819b17493e3443a33e63a16c 100644 (file)
@@ -284,10 +284,6 @@ void Window::Close() {
   window_->Close();
 }
 
-bool Window::IsClosed() {
-  return window_->IsClosed();
-}
-
 void Window::Focus() {
   window_->Focus(true);
 }
@@ -622,8 +618,8 @@ void Window::BuildPrototype(v8::Isolate* isolate,
                             v8::Local<v8::ObjectTemplate> prototype) {
   mate::ObjectTemplateBuilder(isolate, prototype)
       .SetMethod("destroy", &Window::Destroy, true)
+      .SetMethod("isDestroyed", &Window::IsDestroyed, true)
       .SetMethod("close", &Window::Close)
-      .SetMethod("isClosed", &Window::IsClosed)
       .SetMethod("focus", &Window::Focus)
       .SetMethod("isFocused", &Window::IsFocused)
       .SetMethod("show", &Window::Show)
index 1c582551cc937058619e224f0da353649629ff01..4161584206a7e6a2f01412236084668006bf94a6 100644 (file)
@@ -89,7 +89,6 @@ class Window : public mate::TrackableObject<Window>,
 
   // APIs for NativeWindow.
   void Close();
-  bool IsClosed();
   void Focus();
   bool IsFocused();
   void Show();