aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/EventContext.cpp
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-01-13 03:31:40 +0800
committerChristian Persch <chpe@src.gnome.org>2004-01-13 03:31:40 +0800
commit2013edd40e2f4e8c357a6bbcd6d45af9bb3a9e2b (patch)
tree4b7b1c02e46ecc1060c7b8627c168a1fdacb395b /embed/mozilla/EventContext.cpp
parentbec1819707d9735ef7156c0671026d13e4ec0d76 (diff)
downloadgsoc2013-epiphany-2013edd40e2f4e8c357a6bbcd6d45af9bb3a9e2b.tar
gsoc2013-epiphany-2013edd40e2f4e8c357a6bbcd6d45af9bb3a9e2b.tar.gz
gsoc2013-epiphany-2013edd40e2f4e8c357a6bbcd6d45af9bb3a9e2b.tar.bz2
gsoc2013-epiphany-2013edd40e2f4e8c357a6bbcd6d45af9bb3a9e2b.tar.lz
gsoc2013-epiphany-2013edd40e2f4e8c357a6bbcd6d45af9bb3a9e2b.tar.xz
gsoc2013-epiphany-2013edd40e2f4e8c357a6bbcd6d45af9bb3a9e2b.tar.zst
gsoc2013-epiphany-2013edd40e2f4e8c357a6bbcd6d45af9bb3a9e2b.zip
Only allow "Open in New Tab/Window" for certain protocols.
2004-01-12 Christian Persch <chpe@cvs.gnome.org> * embed/mozilla/ContentHandler.cpp: * embed/mozilla/EventContext.cpp: * embed/mozilla/EventContext.h: * src/ephy-tab.c: (address_has_web_scheme): * src/ephy-window.c: (show_embed_popup): Only allow "Open in New Tab/Window" for certain protocols.
Diffstat (limited to 'embed/mozilla/EventContext.cpp')
-rw-r--r--embed/mozilla/EventContext.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/embed/mozilla/EventContext.cpp b/embed/mozilla/EventContext.cpp
index 05ed96306..ea209a3c7 100644
--- a/embed/mozilla/EventContext.cpp
+++ b/embed/mozilla/EventContext.cpp
@@ -32,6 +32,7 @@
#include "nsIDOMElement.h"
#include "nsIDOMXULDocument.h"
#include "nsIURI.h"
+#include "nsNetUtil.h"
#include "nsIDOMNSDocument.h"
#include "nsReadableUtils.h"
#include "nsUnicharUtils.h"
@@ -389,6 +390,7 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
dom_elem->GetAttributeNS (nspace, localname_href, value);
SetStringProperty ("link", value);
+ CheckLinkScheme (value);
}
}
@@ -432,6 +434,7 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
info->context |= EMBED_CONTEXT_LINK;
SetStringProperty ("link", tmp);
+ CheckLinkScheme (tmp);
rv = anchor->GetHreflang (tmp);
if (NS_SUCCEEDED(rv))
SetStringProperty ("link_lang", tmp);
@@ -505,6 +508,7 @@ nsresult EventContext::GetEventContext (nsIDOMEventTarget *EventTarget,
return NS_ERROR_FAILURE;
SetStringProperty ("link", href);
+ CheckLinkScheme (href);
}
}
else if (tag.Equals(NS_LITERAL_STRING("textarea"),
@@ -802,6 +806,29 @@ nsresult EventContext::GetTargetDocument (nsIDOMDocument **domDoc)
return NS_OK;
}
+nsresult EventContext::CheckLinkScheme (const nsAString &link)
+{
+ nsCOMPtr<nsIURI> uri;
+ NS_NewURI (getter_AddRefs (uri), link);
+ if (!uri) return NS_ERROR_FAILURE;
+
+ nsresult rv;
+ nsCAutoString scheme;
+ rv = uri->GetScheme (scheme);
+ if (NS_FAILED (rv)) return NS_ERROR_FAILURE;
+
+ if (scheme.EqualsIgnoreCase ("http") ||
+ scheme.EqualsIgnoreCase ("https") ||
+ scheme.EqualsIgnoreCase ("ftp") ||
+ scheme.EqualsIgnoreCase ("file") ||
+ scheme.EqualsIgnoreCase ("gopher"))
+ {
+ SetIntProperty ("link-has-web-scheme", TRUE);
+ }
+
+ return NS_OK;
+}
+
nsresult EventContext::SetIntProperty (const char *name, int value)
{