From a2ac8ca7dd579263c826d87dded5265749900da4 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 20 Jul 2004 18:15:45 +0000 Subject: Pass single to the sniffer and weak ref it. Fix #141928 2004-07-20 Marco Pesenti Gritti * embed/mozilla/EphyHeaderSniffer.cpp: * embed/mozilla/EphyHeaderSniffer.h: * embed/mozilla/mozilla-embed-persist.cpp: Pass single to the sniffer and weak ref it. Fix #141928 --- ChangeLog | 9 +++++++++ embed/mozilla/EphyHeaderSniffer.cpp | 24 ++++++++++++++++-------- embed/mozilla/EphyHeaderSniffer.h | 6 ++++-- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8f35d0ca7..b28ca8336 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2004-07-20 Marco Pesenti Gritti + + * embed/mozilla/EphyHeaderSniffer.cpp: + * embed/mozilla/EphyHeaderSniffer.h: + * embed/mozilla/mozilla-embed-persist.cpp: + + Pass single to the sniffer and weak ref it. + Fix #141928 + 2004-07-19 Marco Pesenti Gritti * NEWS: diff --git a/embed/mozilla/EphyHeaderSniffer.cpp b/embed/mozilla/EphyHeaderSniffer.cpp index e455f80b9..91ce298c0 100644 --- a/embed/mozilla/EphyHeaderSniffer.cpp +++ b/embed/mozilla/EphyHeaderSniffer.cpp @@ -47,8 +47,6 @@ #include "MozDownload.h" #include "EphyHeaderSniffer.h" -#include "ephy-embed-single.h" -#include "ephy-embed-shell.h" #include "ephy-file-chooser.h" #include "ephy-prefs.h" #include "ephy-gui.h" @@ -70,7 +68,8 @@ #include EphyHeaderSniffer::EphyHeaderSniffer (nsIWebBrowserPersist* aPersist, MozillaEmbedPersist *aEmbedPersist, - nsIFile* aFile, nsIURI* aURL, nsIDOMDocument* aDocument, nsIInputStream* aPostData) + nsIFile* aFile, nsIURI* aURL, nsIDOMDocument* aDocument, nsIInputStream* aPostData, + EphyEmbedSingle *single) : mPersist(aPersist) , mEmbedPersist(aEmbedPersist) , mTmpFile(aFile) @@ -86,11 +85,21 @@ EphyHeaderSniffer::EphyHeaderSniffer (nsIWebBrowserPersist* aPersist, MozillaEmb if (!watcher) return; watcher->GetNewAuthPrompter (nsnull, getter_AddRefs (mAuthPrompt)); + + mSingle = single; + g_object_add_weak_pointer (G_OBJECT (mSingle), + (gpointer *)&mSingle); } EphyHeaderSniffer::~EphyHeaderSniffer() { LOG ("EphyHeaderSniffer dtor (%p)", this) + + if (mSingle) + { + g_object_remove_weak_pointer (G_OBJECT (mSingle), + (gpointer *)&mSingle); + } } NS_IMPL_ISUPPORTS2(EphyHeaderSniffer, nsIWebProgressListener, nsIAuthPrompt) @@ -98,15 +107,14 @@ NS_IMPL_ISUPPORTS2(EphyHeaderSniffer, nsIWebProgressListener, nsIAuthPrompt) NS_IMETHODIMP EphyHeaderSniffer::HandleContent () { - EphyEmbedSingle *single; gboolean handled = FALSE; nsEmbedCString uriSpec; - if (mPostData) return NS_ERROR_FAILURE; + if (mPostData || !mSingle) return NS_ERROR_FAILURE; - mURL->GetSpec (uriSpec); - single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell)); - g_signal_emit_by_name (single, "handle_content", mContentType.get(), + mURL->GetSpec (uriSpec); + + g_signal_emit_by_name (mSingle, "handle_content", mContentType.get(), uriSpec.get(), &handled); return handled ? NS_OK : NS_ERROR_FAILURE; diff --git a/embed/mozilla/EphyHeaderSniffer.h b/embed/mozilla/EphyHeaderSniffer.h index 4aa7d1fa8..f58bebe01 100644 --- a/embed/mozilla/EphyHeaderSniffer.h +++ b/embed/mozilla/EphyHeaderSniffer.h @@ -40,6 +40,7 @@ */ #include "mozilla-embed-persist.h" +#include "ephy-embed-single.h" #include #include @@ -56,8 +57,8 @@ class EphyHeaderSniffer : public nsIWebProgressListener, { public: EphyHeaderSniffer (nsIWebBrowserPersist* aPersist, MozillaEmbedPersist *aEmbedPersist, - nsIFile* aFile, nsIURI* aURL, - nsIDOMDocument* aDocument, nsIInputStream* aPostData); + nsIFile* aFile, nsIURI* aURL, nsIDOMDocument* aDocument, + nsIInputStream* aPostData, EphyEmbedSingle *single); virtual ~EphyHeaderSniffer (); NS_DECL_ISUPPORTS @@ -73,6 +74,7 @@ protected: private: nsIWebBrowserPersist* mPersist; /* Weak. It owns us as a listener. */ MozillaEmbedPersist *mEmbedPersist; + EphyEmbedSingle *mSingle; nsCOMPtr mTmpFile; nsCOMPtr mURL; nsCOMPtr mOriginalURI; -- cgit v1.2.3