Bug 1028588 - Fix dangerous public destructors in xpfe/ - r=ndeakin
--- 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;