aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla
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
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')
-rw-r--r--embed/mozilla/EphyBrowser.cpp54
-rw-r--r--embed/mozilla/EphyBrowser.h7
-rw-r--r--embed/mozilla/mozilla-embed-single.cpp16
3 files changed, 71 insertions, 6 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;
}
diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h
index 07023887c..72d69a8a7 100644
--- a/embed/mozilla/EphyBrowser.h
+++ b/embed/mozilla/EphyBrowser.h
@@ -66,6 +66,12 @@ private:
nsresult HandleFaviconLink (nsIDOMNode *node);
};
+class EphyPopupBlockEventListener : public EphyEventListener
+{
+public:
+ NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
+};
+
class EphyBrowser
{
public:
@@ -128,6 +134,7 @@ private:
nsCOMPtr<nsIDOMEventReceiver> mEventReceiver;
nsCOMPtr<nsIDOMWindow> mDOMWindow;
EphyFaviconEventListener *mFaviconEventListener;
+ EphyPopupBlockEventListener *mPopupBlockEventListener;
PRBool mInitialized;
nsresult GetListener (void);
diff --git a/embed/mozilla/mozilla-embed-single.cpp b/embed/mozilla/mozilla-embed-single.cpp
index bf74c9305..6513c8095 100644
--- a/embed/mozilla/mozilla-embed-single.cpp
+++ b/embed/mozilla/mozilla-embed-single.cpp
@@ -840,13 +840,15 @@ impl_permission_manager_list (EphyPermissionManager *manager,
return list;
}
-void
-mozilla_embed_single_open_window (EphyEmbedSingle *single,
- EphyEmbed *parent,
- const char *address,
- const char *features)
+static void
+impl_open_window (EphyEmbedSingle *single,
+ EphyEmbed *parent,
+ const char *address,
+ const char *features)
{
nsCOMPtr<nsIDOMWindow> domWindow;
+ nsCOMPtr<nsIDOMWindow> dummy;
+
if (parent)
{
EphyBrowser *browser;
@@ -858,7 +860,8 @@ mozilla_embed_single_open_window (EphyEmbedSingle *single,
}
nsCOMPtr<nsIWindowWatcher> wWatch(do_GetService ("@mozilla.org/embedcomp/window-watcher;1"));
- wWatch->OpenWindow (domWindow, address, "", features, nsnull, nsnull);
+ wWatch->OpenWindow (domWindow, address, "", features, nsnull,
+ getter_AddRefs (dummy));
}
static void
@@ -881,6 +884,7 @@ ephy_embed_single_iface_init (EphyEmbedSingleIface *iface)
iface->set_offline_mode = impl_set_offline_mode;
iface->load_proxy_autoconf = impl_load_proxy_autoconf;
iface->get_font_list = impl_get_font_list;
+ iface->open_window = impl_open_window;
}
static void