aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-06-27 19:53:34 +0800
committerChristian Persch <chpe@src.gnome.org>2004-06-27 19:53:34 +0800
commitcc2e070cb399d4581df590127f964add66aa0124 (patch)
tree9ec6e8cf47225097979ddafa37d25f8f025e24d5 /embed/mozilla
parente497b299846293f001ad98f2b7dca3e68db2bf26 (diff)
downloadgsoc2013-epiphany-cc2e070cb399d4581df590127f964add66aa0124.tar
gsoc2013-epiphany-cc2e070cb399d4581df590127f964add66aa0124.tar.gz
gsoc2013-epiphany-cc2e070cb399d4581df590127f964add66aa0124.tar.bz2
gsoc2013-epiphany-cc2e070cb399d4581df590127f964add66aa0124.tar.lz
gsoc2013-epiphany-cc2e070cb399d4581df590127f964add66aa0124.tar.xz
gsoc2013-epiphany-cc2e070cb399d4581df590127f964add66aa0124.tar.zst
gsoc2013-epiphany-cc2e070cb399d4581df590127f964add66aa0124.zip
EphySingle needs to implement nsISupportsWeakReference.
2004-06-27 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/EphySingle.cpp: * embed/mozilla/EphySingle.h: * embed/mozilla/mozilla-embed-single.cpp: EphySingle needs to implement nsISupportsWeakReference. 2004-06-26 Christian Persch <chpe@cvs.gnome.org>
Diffstat (limited to 'embed/mozilla')
-rw-r--r--embed/mozilla/EphySingle.cpp10
-rw-r--r--embed/mozilla/EphySingle.h4
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp20
3 files changed, 22 insertions, 12 deletions
diff --git a/embed/mozilla/EphySingle.cpp b/embed/mozilla/EphySingle.cpp
index e059b5344..b8814d4e6 100644
--- a/embed/mozilla/EphySingle.cpp
+++ b/embed/mozilla/EphySingle.cpp
@@ -34,7 +34,7 @@
#include <nsIServiceManager.h>
#include <nsICookie2.h>
-NS_IMPL_ISUPPORTS1(EphySingle, nsIObserver)
+NS_IMPL_ISUPPORTS2(EphySingle, nsIObserver, nsISupportsWeakReference)
EphySingle::EphySingle()
: mOwner(nsnull)
@@ -45,8 +45,6 @@ EphySingle::EphySingle()
nsresult
EphySingle::Init (EphyEmbedSingle *aOwner)
{
- LOG ("EphySingle::Init")
-
mObserverService = do_GetService ("@mozilla.org/observer-service;1");
NS_ENSURE_TRUE (mObserverService, NS_ERROR_FAILURE);
@@ -59,6 +57,8 @@ EphySingle::Init (EphyEmbedSingle *aOwner)
mOwner = aOwner;
+ LOG ("EphySingle::Init")
+
return NS_OK;
}
@@ -129,6 +129,8 @@ NS_IMETHODIMP EphySingle::Observe(nsISupports *aSubject,
{
nsresult rv = NS_OK;
+ LOG ("EphySingle::Observe topic %s", aTopic)
+
if (strcmp (aTopic, "cookie-changed") == 0)
{
/* "added" */
@@ -221,6 +223,8 @@ NS_IMETHODIMP EphySingle::Observe(nsISupports *aSubject,
rv = NS_ERROR_FAILURE;
}
+ LOG ("EphySingle::Observe %s", NS_SUCCEEDED (rv) ? "success" : "FAILURE")
+
return rv;
}
diff --git a/embed/mozilla/EphySingle.h b/embed/mozilla/EphySingle.h
index ac884ffc0..5c47a5002 100644
--- a/embed/mozilla/EphySingle.h
+++ b/embed/mozilla/EphySingle.h
@@ -29,10 +29,12 @@
#include <nsCOMPtr.h>
#include <nsIObserver.h>
#include <nsIObserverService.h>
+#include <nsWeakReference.h>
#include <nsICookie.h>
#include <nsIPermission.h>
-class EphySingle : public nsIObserver
+class EphySingle : public nsIObserver,
+ public nsSupportsWeakReference
{
public:
NS_DECL_ISUPPORTS
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index 33f14737e..5882b3fae 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -414,18 +414,21 @@ mozilla_init_chrome (void)
static void
mozilla_init_observer (MozillaEmbedSingle *single)
{
- EphySingle *observer;
+ EphySingle *es;
- observer = new EphySingle ();
+ es = new EphySingle ();
+ nsCOMPtr<nsIObserver> guard = NS_STATIC_CAST (nsIObserver *, es);
+ if (!guard) return;
- if (observer)
+ nsresult rv;
+ rv = es->Init (EPHY_EMBED_SINGLE (single));
+ if (NS_FAILED (rv))
{
- nsresult rv;
- rv = observer->Init (EPHY_EMBED_SINGLE (single));
- if (NS_FAILED (rv)) return;
-
- NS_ADDREF (single->priv->mSingleObserver = observer);
+ g_warning ("Failed to initialise EphySingle!\n");
+ return;
}
+
+ NS_ADDREF (single->priv->mSingleObserver = es);
}
static gboolean
@@ -506,6 +509,7 @@ mozilla_embed_single_dispose (GObject *object)
{
single->priv->mSingleObserver->Detach ();
NS_RELEASE (single->priv->mSingleObserver);
+ delete single->priv->mSingleObserver;
single->priv->mSingleObserver = nsnull;
}
}