[epiphany] ephy-window: sandbox app-mode instances to the app domain



commit 207f5b355abbaf2b91e9b684f3cc45387b5119cb
Author: Xan Lopez <xlopez igalia com>
Date:   Mon Aug 29 14:32:07 2011 +0200

    ephy-window: sandbox app-mode instances to the app domain
    
    If the user tries to navigate to other domain spawn a new process with
    "gvfs-open" and the requested URI.

 src/ephy-window.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index a54ee25..f6ce48d 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2606,6 +2606,45 @@ policy_decision_required_cb (WebKitWebView *web_view,
 		return TRUE;
 	}
 
+	if (reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED &&
+	    ephy_embed_shell_get_mode (embed_shell) == EPHY_EMBED_SHELL_MODE_APPLICATION)
+	{
+		/* The only thing we allow here is to either navigate
+		 * in the same window and tab to the current domain,
+		 * or launch a new (non app mode) epiphany instance
+		 * for all the other cases. */
+		gboolean return_value;
+		SoupURI *soup_uri = soup_uri_new (uri);
+		SoupURI *current_soup_uri = soup_uri_new (webkit_web_view_get_uri (web_view));
+
+		if (g_str_equal (soup_uri->host, current_soup_uri->host))
+		{
+			return_value = FALSE;
+		}
+		else
+		{
+			char *command_line;
+			GError *error = NULL;
+
+			return_value = TRUE;
+			command_line = g_strdup_printf ("gvfs-open %s", uri);
+			g_spawn_command_line_async (command_line, &error);
+
+			if (error)
+			{
+				g_debug ("Error opening %s: %s", uri, error->message);
+				g_error_free (error);
+			}
+
+			g_free (command_line);
+		}
+
+		soup_uri_free (soup_uri);
+		soup_uri_free (current_soup_uri);
+
+		return return_value;
+	}
+
 	if (reason == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
 		EphyEmbed *embed;
 		EphyNewTabFlags flags;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]