[epiphany/wip/httpseverywhere: 2/2] Initial libhttpseverywhere integration



commit 946cfe492a1403e5bd982601f8c5706d7d6580f5
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun Sep 18 22:10:47 2016 -0500

    Initial libhttpseverywhere integration
    
    Seems it requires manual database setup, this will require some work....

 configure.ac                             |    1 +
 embed/web-extension/Makefile.am          |   24 +++++++++++++-----------
 embed/web-extension/ephy-web-extension.c |   13 ++++++++++++-
 3 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 703f973..bed5d73 100644
--- a/configure.ac
+++ b/configure.ac
@@ -116,6 +116,7 @@ PKG_CHECK_MODULES([GSETTINGS_DESKTOP_SCHEMAS], [gsettings-desktop-schemas])
 PKG_CHECK_MODULES([GTHREAD], [gthread-2.0 >= $GLIB_REQUIRED])
 PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= $GTK_REQUIRED])
 PKG_CHECK_MODULES([GTK_UNIX_PRINT], [gtk+-unix-print-3.0 >= $GTK_REQUIRED])
+PKG_CHECK_MODULES([HTTPSEVERYWHERE], [httpseverywhere >= 0.0.3])
 PKG_CHECK_MODULES([LIBNOTIFY], [libnotify >= 0.5.1])
 PKG_CHECK_MODULES([LIBSECRET], [libsecret-1 >= 0.14])
 PKG_CHECK_MODULES([LIBSOUP], [libsoup-2.4 >= 2.48.0])
diff --git a/embed/web-extension/Makefile.am b/embed/web-extension/Makefile.am
index d0c2560..e0eaf3d 100644
--- a/embed/web-extension/Makefile.am
+++ b/embed/web-extension/Makefile.am
@@ -19,12 +19,13 @@ libephywebextension_la_SOURCES = \
        ephy-web-overview-model.c
 
 libephywebextension_la_CPPFLAGS = \
-       -I$(top_srcdir)/lib     \
-       $(GIO_CFLAGS)           \
-       $(GLIB_CFLAGS)          \
-       $(GTK_CFLAGS)           \
-       $(LIBSECRET_CFLAGS)     \
-       $(LIBSOUP_CFLAGS)       \
+       -I$(top_srcdir)/lib             \
+       $(GIO_CFLAGS)                   \
+       $(GLIB_CFLAGS)                  \
+       $(GTK_CFLAGS)                   \
+       $(HTTPSEVERYWHERE_CFLAGS)       \
+       $(LIBSECRET_CFLAGS)             \
+       $(LIBSOUP_CFLAGS)               \
        $(WEBKIT2GTK_WEB_EXTENSION_CFLAGS)
 
 libephywebextension_la_CFLAGS = \
@@ -35,11 +36,12 @@ libephywebextension_la_LDFLAGS = \
 
 libephywebextension_la_LIBADD = \
        $(top_builddir)/lib/libephymisc.la \
-       $(GIO_LIBS) \
-       $(GLIB_LIBS) \
-       $(GTK_LIBS) \
-       $(LIBSECRET_LIBS) \
-       $(LIBSOUP_LIBS) \
+       $(GIO_LIBS)             \
+       $(GLIB_LIBS)            \
+       $(GTK_LIBS)             \
+       $(HTTPSEVERYWHERE_LIBS) \
+       $(LIBSECRET_LIBS)       \
+       $(LIBSOUP_LIBS)         \
        $(WEBKIT2GTK_WEB_EXTENSION_LIBS)
 
 -include $(top_srcdir)/git.mk
diff --git a/embed/web-extension/ephy-web-extension.c b/embed/web-extension/ephy-web-extension.c
index 0e57ee3..962e201 100644
--- a/embed/web-extension/ephy-web-extension.c
+++ b/embed/web-extension/ephy-web-extension.c
@@ -36,6 +36,7 @@
 
 #include <gio/gio.h>
 #include <gtk/gtk.h>
+#include <httpseverywhere.h>
 #include <libsoup/soup.h>
 #include <string.h>
 #include <webkit2/webkit-web-extension.h>
@@ -114,13 +115,13 @@ web_page_send_request (WebKitWebPage     *web_page,
 {
   const char *request_uri;
   const char *page_uri;
+  char *new_uri;
   gboolean ret;
 
   request_uri = webkit_uri_request_get_uri (request);
 
   if (g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_DO_NOT_TRACK)) {
     SoupMessageHeaders *headers;
-    char *new_uri;
 
     headers = webkit_uri_request_get_http_headers (request);
     if (headers) {
@@ -138,6 +139,14 @@ web_page_send_request (WebKitWebPage     *web_page,
     g_free (new_uri);
   }
 
+  /* Rewrite URL to use HTTPS if directed by HTTPS Everywhere */
+  new_uri = https_everywhere_rewrite (g_strdup (request_uri));
+  if (g_strcmp0 (request_uri, new_uri) != 0) {
+    webkit_uri_request_set_uri (request, new_uri);
+    request_uri = webkit_uri_request_get_uri (request);
+  }
+  g_free (new_uri);
+
   if (!g_settings_get_boolean (EPHY_SETTINGS_WEB, EPHY_PREFS_WEB_ENABLE_ADBLOCK))
     return FALSE;
 
@@ -1399,6 +1408,8 @@ ephy_web_extension_initialize (EphyWebExtension   *extension,
 
   extension->initialized = TRUE;
 
+  https_everywhere_init ();
+
   extension->extension = g_object_ref (wk_extension);
   extension->uri_tester = ephy_uri_tester_new (dot_dir);
   if (!is_private_profile)


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