[epiphany] Add support for downloads from evince browser plugin



commit d8e50b380dbad791cf0bfeaba0314ec30d88b82a
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Wed Jul 2 09:21:47 2014 +0200

    Add support for downloads from evince browser plugin
    
    Enable javascript popups in WebKit by default and block them from
    epiphany in the policy checker callback. Evince browser plugin allows to
    download the current document only when the user agent contains
    Epiphany, by using a special target frame name. When we detect that
    target name in the policy checker callback we convert the request into a
    download.

 embed/ephy-embed-prefs.c |    5 +----
 src/ephy-window.c        |   18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)
---
diff --git a/embed/ephy-embed-prefs.c b/embed/ephy-embed-prefs.c
index d7cd576..c447caf 100644
--- a/embed/ephy-embed-prefs.c
+++ b/embed/ephy-embed-prefs.c
@@ -537,6 +537,7 @@ ephy_embed_prefs_init (gpointer user_data)
                                                        "enable-fullscreen", TRUE,
                                                        "enable-site-specific-quirks", TRUE,
                                                        "enable-dns-prefetching", TRUE,
+                                                       "javascript-can-open-windows-automatically", TRUE,
                                                        NULL);
 
   for (i = 0; i < G_N_ELEMENTS (webkit_pref_entries); i++) {
@@ -565,10 +566,6 @@ ephy_embed_prefs_init (gpointer user_data)
                    webkit_settings, "enable-caret-browsing",
                    G_SETTINGS_BIND_GET);
   g_settings_bind (EPHY_SETTINGS_WEB,
-                   EPHY_PREFS_WEB_ENABLE_POPUPS,
-                   webkit_settings, "javascript-can-open-windows-automatically",
-                   G_SETTINGS_BIND_GET);
-  g_settings_bind (EPHY_SETTINGS_WEB,
                    EPHY_PREFS_WEB_ENABLE_PLUGINS,
                    webkit_settings, "enable-plugins",
                    G_SETTINGS_BIND_GET);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 6fa09b8..a74442b 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2111,6 +2111,24 @@ decide_policy_cb (WebKitWebView *web_view,
                return TRUE;
        }
 
+       if (decision_type == WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION)
+       {
+               const char *frame_name = webkit_navigation_policy_decision_get_frame_name 
(navigation_decision);
+
+               if (g_strcmp0 (frame_name, "_evince_download") == 0)
+               {
+                       /* The Evince Browser Plugin is requesting us to downlod the document */
+                       webkit_policy_decision_download (decision);
+                       return TRUE;
+               }
+
+               if (!g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_POPUPS))
+               {
+                       webkit_policy_decision_ignore (decision);
+                       return TRUE;
+               }
+       }
+
        navigation_type = webkit_navigation_policy_decision_get_navigation_type (navigation_decision);
 
        if (navigation_type == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED &&


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