Bug 1028588 - Fix dangerous public destructors in xpfe/ - r=ndeakin
authorBenoit Jacob <bjacob@mozilla.com>
Tue, 24 Jun 2014 12:36:45 -0400
changeset 190543 20428bf68d89af418789f85b0aceef8bdc9b7e6e
parent 190542 6a0a566bc00389559e06ad263a1d827af6d73243
child 190544 5307410e3a3b11729a4699a5e8e8f8919a59f49f
push idunknown
push userunknown
push dateunknown
reviewersndeakin
bugs1028588
milestone33.0a1
Bug 1028588 - Fix dangerous public destructors in xpfe/ - r=ndeakin
xpfe/appshell/src/nsAppShellService.cpp
xpfe/appshell/src/nsAppShellWindowEnumerator.h
xpfe/appshell/src/nsContentTreeOwner.cpp
xpfe/appshell/src/nsWebShellWindow.cpp
xpfe/appshell/src/nsWindowMediator.h
xpfe/components/directory/nsDirectoryViewer.h
xpfe/components/windowds/nsWindowDataSource.h
--- a/xpfe/appshell/src/nsAppShellService.cpp
+++ b/xpfe/appshell/src/nsAppShellService.cpp
@@ -209,18 +209,19 @@ nsAppShellService::CreateTopLevelWindow(
 
 /*
  * This class provides a stub implementation of nsIWebBrowserChrome2, as needed
  * by nsAppShellService::CreateWindowlessBrowser
  */
 class WebBrowserChrome2Stub : public nsIWebBrowserChrome2,
                               public nsIInterfaceRequestor,
                               public nsSupportsWeakReference {
+protected:
+    virtual ~WebBrowserChrome2Stub() {}
 public:
-    virtual ~WebBrowserChrome2Stub() {}
     NS_DECL_ISUPPORTS
     NS_DECL_NSIWEBBROWSERCHROME
     NS_DECL_NSIWEBBROWSERCHROME2
     NS_DECL_NSIINTERFACEREQUESTOR
 };
 
 NS_INTERFACE_MAP_BEGIN(WebBrowserChrome2Stub)
   NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIWebBrowserChrome)
@@ -327,16 +328,17 @@ public:
     mWebNavigation = do_QueryInterface(aBrowser);
     mInterfaceRequestor = do_QueryInterface(aBrowser);
     mContainer = aContainer;
   }
   NS_DECL_ISUPPORTS
   NS_FORWARD_NSIWEBNAVIGATION(mWebNavigation->)
   NS_FORWARD_NSIINTERFACEREQUESTOR(mInterfaceRequestor->)
 private:
+  ~WindowlessBrowserStub() {}
   nsCOMPtr<nsIWebBrowser> mBrowser;
   nsCOMPtr<nsIWebNavigation> mWebNavigation;
   nsCOMPtr<nsIInterfaceRequestor> mInterfaceRequestor;
   // we don't use the container but just hold a reference to it.
   nsCOMPtr<nsISupports> mContainer;
 };
 
 NS_INTERFACE_MAP_BEGIN(WindowlessBrowserStub)
--- a/xpfe/appshell/src/nsAppShellWindowEnumerator.h
+++ b/xpfe/appshell/src/nsAppShellWindowEnumerator.h
@@ -45,24 +45,25 @@ struct nsWindowInfo
 
 class nsAppShellWindowEnumerator : public nsISimpleEnumerator {
 
 friend class nsWindowMediator;
 
 public:
   nsAppShellWindowEnumerator(const char16_t* aTypeString,
                              nsWindowMediator& inMediator);
-  virtual ~nsAppShellWindowEnumerator();
   NS_IMETHOD GetNext(nsISupports **retval) = 0;
   NS_IMETHOD HasMoreElements(bool *retval);
 
   NS_DECL_ISUPPORTS
 
 protected:
 
+  virtual ~nsAppShellWindowEnumerator();
+
   void AdjustInitialPosition();
   virtual nsWindowInfo *FindNext() = 0;
 
   void WindowRemoved(nsWindowInfo *inInfo);
 
   nsWindowMediator *mWindowMediator;
   nsString          mType;
   nsWindowInfo     *mCurrentPosition;
--- a/xpfe/appshell/src/nsContentTreeOwner.cpp
+++ b/xpfe/appshell/src/nsContentTreeOwner.cpp
@@ -63,16 +63,24 @@ public:
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIEMBEDDINGSITEWINDOW
 
 private:
   nsContentTreeOwner *mAggregator;
 };
 
+namespace mozilla {
+template<>
+struct HasDangerousPublicDestructor<nsSiteWindow>
+{
+  static const bool value = true;
+};
+}
+
 //*****************************************************************************
 //***    nsContentTreeOwner: Object Management
 //*****************************************************************************
 
 nsContentTreeOwner::nsContentTreeOwner(bool fPrimary) : mXULWindow(nullptr), 
    mPrimary(fPrimary), mContentTitleSetting(false)
 {
   // note if this fails, QI on nsIEmbeddingSiteWindow(2) will simply fail
--- a/xpfe/appshell/src/nsWebShellWindow.cpp
+++ b/xpfe/appshell/src/nsWebShellWindow.cpp
@@ -455,16 +455,18 @@ public:
     // -> mSPTimer -> this), mSPTimer is a one-shot timer and releases this
     // after it fires.  So we don't need to release mWindow here.
 
     mWindow->FirePersistenceTimer();
     return NS_OK;
   }
 
 private:
+  ~WebShellWindowTimerCallback() {}
+
   nsRefPtr<nsWebShellWindow> mWindow;
 };
 
 NS_IMPL_ISUPPORTS(WebShellWindowTimerCallback, nsITimerCallback)
 
 } // namespace mozilla
 
 void
--- a/xpfe/appshell/src/nsWindowMediator.h
+++ b/xpfe/appshell/src/nsWindowMediator.h
@@ -34,19 +34,21 @@ class nsWindowMediator :
 friend class nsAppShellWindowEnumerator;
 friend class nsASXULWindowEarlyToLateEnumerator;
 friend class nsASDOMWindowEarlyToLateEnumerator;
 friend class nsASDOMWindowFrontToBackEnumerator;
 friend class nsASXULWindowFrontToBackEnumerator;
 friend class nsASDOMWindowBackToFrontEnumerator;
 friend class nsASXULWindowBackToFrontEnumerator;
 
+protected:
+  virtual ~nsWindowMediator();
+
 public:
   nsWindowMediator();
-  virtual ~nsWindowMediator();
 
   nsresult Init();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIWINDOWMEDIATOR
   NS_DECL_NSIOBSERVER
 
   static nsresult GetDOMWindow(nsIXULWindow* inWindow,
--- a/xpfe/components/directory/nsDirectoryViewer.h
+++ b/xpfe/components/directory/nsDirectoryViewer.h
@@ -20,21 +20,23 @@
 #include "nsIDirIndexListener.h"
 #include "nsIFTPChannel.h"
 #include "nsCycleCollectionParticipant.h"
 
 class nsDirectoryViewerFactory : public nsIDocumentLoaderFactory
 {
 public:
     nsDirectoryViewerFactory();
-    virtual ~nsDirectoryViewerFactory();
 
     // nsISupports interface
     NS_DECL_ISUPPORTS
     NS_DECL_NSIDOCUMENTLOADERFACTORY
+
+protected:
+    virtual ~nsDirectoryViewerFactory();
 };
 
 class nsHTTPIndex : public nsIHTTPIndex,
                     public nsIRDFDataSource,
                     public nsIStreamListener,
                     public nsIDirIndexListener,
                     public nsIInterfaceRequestor,
                     public nsIFTPEventSink
@@ -82,19 +84,20 @@ protected:
     nsresult Init(nsIURI* aBaseURL);
     void        GetDestination(nsIRDFResource* r, nsXPIDLCString& dest);
     bool        isWellknownContainerURI(nsIRDFResource *r);
     nsresult    AddElement(nsIRDFResource *parent, nsIRDFResource *prop,
                            nsIRDFNode *child);
 
     static void FireTimer(nsITimer* aTimer, void* aClosure);
 
+    virtual ~nsHTTPIndex();
+
 public:
     nsHTTPIndex();
-    virtual ~nsHTTPIndex();
     nsresult Init(void);
 
     static nsresult Create(nsIURI* aBaseURI, nsIInterfaceRequestor* aContainer,
                            nsIHTTPIndex** aResult);
 
     // nsIHTTPIndex interface
     NS_DECL_NSIHTTPINDEX
 
--- a/xpfe/components/windowds/nsWindowDataSource.h
+++ b/xpfe/components/windowds/nsWindowDataSource.h
@@ -22,28 +22,30 @@
 
 class nsWindowDataSource : public nsIRDFDataSource,
                            public nsIObserver,
                            public nsIWindowMediatorListener,
                            public nsIWindowDataSource
 {
  public:
     nsWindowDataSource() { }
-    virtual ~nsWindowDataSource();
 
     nsresult Init();
 
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(nsWindowDataSource,
                                              nsIRDFDataSource)
     NS_DECL_NSIOBSERVER
     NS_DECL_NSIWINDOWMEDIATORLISTENER
     NS_DECL_NSIWINDOWDATASOURCE
     NS_DECL_NSIRDFDATASOURCE
 
+ protected:
+    virtual ~nsWindowDataSource();
+
  private:
 
     // mapping of window -> RDF resource
     nsInterfaceHashtable<nsPtrHashKey<nsIXULWindow>, nsIRDFResource> mWindowResources;
 
     static uint32_t windowCount;
     static uint32_t gRefCnt;