aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/EphyBrowser.cpp
diff options
context:
space:
mode:
authorAdam Hooper <adamh@src.gnome.org>2004-06-21 19:09:56 +0800
committerAdam Hooper <adamh@src.gnome.org>2004-06-21 19:09:56 +0800
commit234742d9a6c75c8163a47bd1f3b1eeeba15e58cc (patch)
tree8901df253d7052f7d0b157f8dcd38c33a927ddfb /embed/mozilla/EphyBrowser.cpp
parent848ded5f81fc73bafd62c6cbf1e2b9b9814e7263 (diff)
downloadgsoc2013-epiphany-234742d9a6c75c8163a47bd1f3b1eeeba15e58cc.tar
gsoc2013-epiphany-234742d9a6c75c8163a47bd1f3b1eeeba15e58cc.tar.gz
gsoc2013-epiphany-234742d9a6c75c8163a47bd1f3b1eeeba15e58cc.tar.bz2
gsoc2013-epiphany-234742d9a6c75c8163a47bd1f3b1eeeba15e58cc.tar.lz
gsoc2013-epiphany-234742d9a6c75c8163a47bd1f3b1eeeba15e58cc.tar.xz
gsoc2013-epiphany-234742d9a6c75c8163a47bd1f3b1eeeba15e58cc.tar.zst
gsoc2013-epiphany-234742d9a6c75c8163a47bd1f3b1eeeba15e58cc.zip
Implement popup-blocking signals. Part of bug #111930.
Diffstat (limited to 'embed/mozilla/EphyBrowser.cpp')
-rw-r--r--embed/mozilla/EphyBrowser.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index eb86d5fd4..8481cee56 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -57,6 +57,7 @@
#include "nsIDOM3Document.h"
#include "nsIDOMEvent.h"
#include "nsIDOMEventTarget.h"
+#include "nsIDOMPopupBlockedEvent.h"
#include "nsIDOMNode.h"
#include "nsIDOMElement.h"
#include "nsIDOMWindow2.h"
@@ -69,6 +70,9 @@
static PRUnichar DOMLinkAdded[] = { 'D', 'O', 'M', 'L', 'i', 'n', 'k',
'A', 'd', 'd', 'e', 'd', '\0' };
+static PRUnichar DOMPopupBlocked[] = { 'D', 'O', 'M', 'P', 'o', 'p',
+ 'u', 'p', 'B', 'l', 'o', 'c',
+ 'k', 'e', 'd', '\0' };
EphyEventListener::EphyEventListener(void)
: mOwner(nsnull)
@@ -160,8 +164,45 @@ EphyFaviconEventListener::HandleEvent(nsIDOMEvent* aDOMEvent)
return NS_OK;
}
+NS_IMETHODIMP
+EphyPopupBlockEventListener::HandleEvent (nsIDOMEvent * aDOMEvent)
+{
+ nsresult rv;
+
+ NS_ENSURE_TRUE (mOwner != NULL, NS_ERROR_FAILURE);
+
+ nsCOMPtr<nsIDOMPopupBlockedEvent> popupEvent =
+ do_QueryInterface (aDOMEvent, &rv);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
+ nsCOMPtr<nsIURI> popupWindowURI;
+ rv = popupEvent->GetPopupWindowURI (getter_AddRefs (popupWindowURI));
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ NS_ENSURE_SUCCESS (popupWindowURI != NULL, NS_ERROR_FAILURE);
+
+ nsEmbedCString popupWindowURIString;
+ rv = popupWindowURI->GetSpec (popupWindowURIString);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
+ nsEmbedString popupWindowFeatures;
+ rv = popupEvent->GetPopupWindowFeatures (popupWindowFeatures);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
+ nsEmbedCString popupWindowFeaturesString;
+ NS_UTF16ToCString (popupWindowFeatures,
+ NS_CSTRING_ENCODING_UTF8,
+ popupWindowFeaturesString);
+
+ g_signal_emit_by_name(mOwner, "ge_popup_blocked",
+ popupWindowURIString.get(),
+ popupWindowFeaturesString.get());
+
+ return NS_OK;
+}
+
EphyBrowser::EphyBrowser ()
: mFaviconEventListener(nsnull)
+, mPopupBlockEventListener(nsnull)
, mInitialized(PR_FALSE)
{
}
@@ -194,6 +235,12 @@ nsresult EphyBrowser::Init (GtkMozEmbed *mozembed)
rv = mFaviconEventListener->Init (EPHY_EMBED (mozembed));
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ mPopupBlockEventListener = new EphyPopupBlockEventListener();
+ if (!mPopupBlockEventListener) return NS_ERROR_OUT_OF_MEMORY;
+
+ rv = mPopupBlockEventListener->Init (EPHY_EMBED (mozembed));
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
rv = GetListener();
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
@@ -236,6 +283,10 @@ EphyBrowser::AttachListeners(void)
mFaviconEventListener, PR_FALSE);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ rv = target->AddEventListener(nsEmbedString(DOMPopupBlocked),
+ mPopupBlockEventListener, PR_FALSE);
+ NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+
return NS_OK;
}
@@ -254,6 +305,9 @@ EphyBrowser::DetachListeners(void)
mFaviconEventListener, PR_FALSE);
NS_ENSURE_SUCCESS (rv, NS_ERROR_FAILURE);
+ rv = target->RemoveEventListener(nsEmbedString(DOMPopupBlocked),
+ mPopupBlockEventListener, PR_FALSE);
+
return NS_OK;
}