aboutsummaryrefslogtreecommitdiffstats
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
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.
-rw-r--r--ChangeLog10
-rw-r--r--embed/mozilla/EventContext.cpp27
-rw-r--r--src/ephy-window.c7
3 files changed, 43 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 0057dbddf..fb8fcd42d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+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.
+
2004-01-10 Christian Persch <chpe@cvs.gnome.org>
* data/epiphany.xhtml:
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)
{
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 896a5dcf8..d78d6013c 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1256,7 +1256,7 @@ show_embed_popup (EphyWindow *window, EphyTab *tab, EphyEmbedEvent *event)
EmbedEventContext context;
const char *popup;
const GValue *value;
- gboolean framed, has_background;
+ gboolean framed, has_background, can_open_in_new;
GtkWidget *widget;
EphyEmbedEventType type;
gboolean showing_edit_actions = FALSE;
@@ -1271,6 +1271,7 @@ show_embed_popup (EphyWindow *window, EphyTab *tab, EphyEmbedEvent *event)
framed = g_value_get_int (value);
has_background = ephy_embed_event_has_property (event, "background_image");
+ can_open_in_new = ephy_embed_event_has_property (event, "link-has-web-scheme");
context = ephy_embed_event_get_context (event);
@@ -1310,6 +1311,10 @@ show_embed_popup (EphyWindow *window, EphyTab *tab, EphyEmbedEvent *event)
action = gtk_action_group_get_action (action_group, "SaveBackgroundAs");
g_object_set (action, "sensitive", has_background,
"visible", has_background, NULL);
+ action = gtk_action_group_get_action (action_group, "OpenLinkInNewWindow");
+ g_object_set (action, "sensitive", can_open_in_new, FALSE);
+ action = gtk_action_group_get_action (action_group, "OpenLinkInNewTab");
+ g_object_set (action, "sensitive", can_open_in_new, FALSE);
if (showing_edit_actions)
{