[epiphany] Remove view source handler
- From: Michael Catanzaro <mcatanzaro src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Remove view source handler
- Date: Sun, 12 Feb 2017 01:05:53 +0000 (UTC)
commit d6dba00ad85ab79a3ebea3363b03e16951ce33e6
Author: Michael Catanzaro <mcatanzaro gnome org>
Date: Sat Feb 11 19:02:45 2017 -0600
Remove view source handler
This is still half-baked: it's waaaay too slow. I should never have
pushed it.
https://bugzilla.gnome.org/show_bug.cgi?id=775145
LICENSE.prism | 21 -
Makefile.am | 4 -
embed/Makefile.am | 2 -
embed/ephy-embed-shell.c | 18 -
embed/ephy-embed-utils.c | 4 -
embed/ephy-view-source-handler.c | 172 ++-------
embed/ephy-web-view.c | 2 -
po/POTFILES.in | 1 -
src/Makefile.am | 5 +-
src/resources/epiphany.gresource.xml | 2 -
src/resources/prism.css | 179 --------
src/resources/prism.js | 745 ----------------------------------
src/window-commands.c | 32 +-
13 files changed, 46 insertions(+), 1141 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 8df1220..5b70335 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,10 +3,6 @@ if ENABLE_TESTS
SUBDIRS += tests
endif
-EXTRA_DIST = \
- LICENSE.chromium \
- LICENSE.prism
-
AM_DISTCHECK_CONFIGURE_FLAGS = \
--enable-appstream-util \
--enable-debug
diff --git a/embed/Makefile.am b/embed/Makefile.am
index b57c9d4..cbe2d82 100644
--- a/embed/Makefile.am
+++ b/embed/Makefile.am
@@ -41,8 +41,6 @@ libephyembed_la_SOURCES = \
ephy-find-toolbar.h \
ephy-notification-container.c \
ephy-notification-container.h \
- ephy-view-source-handler.c \
- ephy-view-source-handler.h \
ephy-web-view.c \
ephy-web-view.h \
ephy-web-extension-proxy.c \
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 0153958..258c053 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -36,7 +36,6 @@
#include "ephy-settings.h"
#include "ephy-snapshot-service.h"
#include "ephy-uri-tester-shared.h"
-#include "ephy-view-source-handler.h"
#include "ephy-web-app-utils.h"
#include "ephy-web-extension-proxy.h"
@@ -63,7 +62,6 @@ typedef struct {
EphyDownloadsManager *downloads_manager;
EphyPermissionsManager *permissions_manager;
EphyAboutHandler *about_handler;
- EphyViewSourceHandler *source_handler;
guint update_overview_timeout_id;
guint hiding_overview_item;
GDBusServer *dbus_server;
@@ -117,7 +115,6 @@ ephy_embed_shell_dispose (GObject *object)
g_clear_object (&priv->print_settings);
g_clear_object (&priv->global_history_service);
g_clear_object (&priv->about_handler);
- g_clear_object (&priv->source_handler);
g_clear_object (&priv->user_content);
g_clear_object (&priv->downloads_manager);
g_clear_object (&priv->permissions_manager);
@@ -562,15 +559,6 @@ about_request_cb (WebKitURISchemeRequest *request,
}
static void
-source_request_cb (WebKitURISchemeRequest *request,
- EphyEmbedShell *shell)
-{
- EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
-
- ephy_view_source_handler_handle_request (priv->source_handler, request);
-}
-
-static void
ephy_resource_request_cb (WebKitURISchemeRequest *request)
{
const char *path;
@@ -952,12 +940,6 @@ ephy_embed_shell_startup (GApplication *application)
webkit_security_manager_register_uri_scheme_as_local (webkit_web_context_get_security_manager
(priv->web_context),
EPHY_ABOUT_SCHEME);
- /* view source handler */
- priv->source_handler = ephy_view_source_handler_new ();
- webkit_web_context_register_uri_scheme (priv->web_context, EPHY_VIEW_SOURCE_SCHEME,
- (WebKitURISchemeRequestCallback)source_request_cb,
- shell, NULL);
-
/* ephy-resource handler */
webkit_web_context_register_uri_scheme (priv->web_context, "ephy-resource",
(WebKitURISchemeRequestCallback)ephy_resource_request_cb,
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index 90dcd95..9157583 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -27,7 +27,6 @@
#include "ephy-about-handler.h"
#include "ephy-settings.h"
#include "ephy-string.h"
-#include "ephy-view-source-handler.h"
#include <string.h>
#include <glib/gi18n.h>
@@ -293,9 +292,6 @@ ephy_embed_utils_is_no_show_address (const char *address)
if (g_str_equal (address, do_not_show_address[i]))
return TRUE;
- if (strstr (address, EPHY_VIEW_SOURCE_SCHEME) == address)
- return TRUE;
-
return FALSE;
}
diff --git a/embed/ephy-view-source-handler.c b/embed/ephy-view-source-handler.c
index fe2de71..af62769 100644
--- a/embed/ephy-view-source-handler.c
+++ b/embed/ephy-view-source-handler.c
@@ -21,12 +21,9 @@
#include "config.h"
#include "ephy-view-source-handler.h"
-#include "ephy-embed-container.h"
#include "ephy-embed-shell.h"
-#include "ephy-web-view.h"
#include <gio/gio.h>
-#include <glib/gi18n.h>
#include <string.h>
struct _EphyViewSourceHandler {
@@ -50,11 +47,13 @@ ephy_view_source_request_new (EphyViewSourceHandler *handler,
WebKitURISchemeRequest *request)
{
EphyViewSourceRequest *view_source_request;
+ EphyEmbedShell *shell = ephy_embed_shell_get_default ();
+ WebKitWebContext *context = ephy_embed_shell_get_web_context (shell);
view_source_request = g_slice_new (EphyViewSourceRequest);
- view_source_request->source_handler = g_object_ref (handler);
+ view_source_request->source_handler = handler;
view_source_request->scheme_request = g_object_ref (request);
- view_source_request->web_view = NULL; /* created only if required */
+ view_source_request->web_view = g_object_ref_sink (webkit_web_view_new_with_context (context));
view_source_request->cancellable = g_cancellable_new ();
view_source_request->load_changed_id = 0;
@@ -67,9 +66,8 @@ ephy_view_source_request_free (EphyViewSourceRequest *request)
if (request->load_changed_id > 0)
g_signal_handler_disconnect (request->web_view, request->load_changed_id);
- g_object_unref (request->source_handler);
g_object_unref (request->scheme_request);
- g_clear_object (&request->web_view);
+ g_object_unref (request->web_view);
g_cancellable_cancel (request->cancellable);
g_object_unref (request->cancellable);
@@ -79,28 +77,21 @@ ephy_view_source_request_free (EphyViewSourceRequest *request)
static void
finish_uri_scheme_request (EphyViewSourceRequest *request,
- gchar *data,
- GError *error)
+ gchar *data)
{
GInputStream *stream;
gssize data_length;
- g_assert ((data && !error) || (!data && error));
-
- if (error) {
- webkit_uri_scheme_request_finish_error (request->scheme_request, error);
- } else {
- data_length = MIN (strlen (data), G_MAXSSIZE);
- stream = g_memory_input_stream_new_from_data (data, data_length, g_free);
- webkit_uri_scheme_request_finish (request->scheme_request, stream, data_length, "text/html");
- g_object_unref (stream);
- }
+ data_length = MIN (strlen (data), G_MAXSSIZE);
+ stream = g_memory_input_stream_new_from_data (data, data_length, g_free);
+ webkit_uri_scheme_request_finish (request->scheme_request, stream, data_length, "text/html");
request->source_handler->outstanding_requests =
g_list_remove (request->source_handler->outstanding_requests,
request);
ephy_view_source_request_free (request);
+ g_object_unref (stream);
}
static void
@@ -117,8 +108,10 @@ web_resource_data_cb (WebKitWebResource *resource,
data = webkit_web_resource_get_data_finish (resource, result, &length, &error);
if (error) {
- finish_uri_scheme_request (request, NULL, error);
+ html = g_strdup (error->message);
+ length = strlen (html);
g_error_free (error);
+ finish_uri_scheme_request (request, html);
return;
}
@@ -130,32 +123,15 @@ web_resource_data_cb (WebKitWebResource *resource,
escaped_str = g_markup_escape_text (data_str, -1);
g_free (data_str);
- html = g_strdup_printf ("<head>"
- "<link href=\"ephy-resource:///org/gnome/epiphany/prism.css\"
rel=\"stylesheet\"/>"
- "</head>"
- "<body style=\"background-color: #f5f2f0;\">"
- "<script src=\"ephy-resource:///org/gnome/epiphany/prism.js\"></script>"
- /* http://prismjs.com/plugins/line-numbers/ */
- "<pre class=\"line-numbers\" style=\"overflow: visible\">"
- "<code class=\"language-markup\">%s</code>"
+ html = g_strdup_printf ("<body>"
+ "<pre>"
+ "<code class=\"language-html\">%s</code>"
"</pre>"
"</body>",
escaped_str);
g_free (escaped_str);
- finish_uri_scheme_request (request, html, NULL);
-}
-
-static void
-ephy_view_source_request_begin_get_source_from_web_view (EphyViewSourceRequest *request,
- WebKitWebView *web_view)
-{
- WebKitWebResource *resource = webkit_web_view_get_main_resource (web_view);
- g_assert (resource);
- webkit_web_resource_get_data (resource,
- request->cancellable,
- (GAsyncReadyCallback)(web_resource_data_cb),
- request);
+ finish_uri_scheme_request (request, html);
}
static void
@@ -163,79 +139,13 @@ load_changed_cb (WebKitWebView *web_view,
WebKitLoadEvent load_event,
EphyViewSourceRequest *request)
{
- if (load_event == WEBKIT_LOAD_FINISHED)
- ephy_view_source_request_begin_get_source_from_web_view (request, web_view);
-}
-
-static void
-ephy_view_source_request_begin_get_source_from_uri (EphyViewSourceRequest *request,
- const char *uri)
-{
- EphyEmbedShell *shell = ephy_embed_shell_get_default ();
- WebKitWebContext *context = ephy_embed_shell_get_web_context (shell);
-
- request->web_view = WEBKIT_WEB_VIEW (g_object_ref_sink (webkit_web_view_new_with_context (context)));
-
- g_assert (request->load_changed_id == 0);
- request->load_changed_id = g_signal_connect (request->web_view, "load-changed",
- G_CALLBACK (load_changed_cb),
- request);
-
- webkit_web_view_load_uri (request->web_view, uri);
-}
-
-static gint
-embed_is_displaying_matching_uri (EphyEmbed *embed,
- SoupURI *uri)
-{
- EphyWebView *web_view;
- SoupURI *view_uri;
- gint ret = -1;
-
- if (ephy_embed_has_load_pending (embed))
- return -1;
-
- web_view = ephy_embed_get_web_view (embed);
- if (ephy_web_view_is_loading (web_view))
- return -1;
-
- view_uri = soup_uri_new (ephy_web_view_get_address (web_view));
- if (!view_uri)
- return -1;
-
- soup_uri_set_fragment (view_uri, NULL);
- ret = soup_uri_equal (view_uri, uri) ? 0 : -1;
-
- soup_uri_free (view_uri);
-
- return ret;
-}
-
-static WebKitWebView *
-get_web_view_matching_uri (SoupURI *uri)
-{
- EphyEmbedShell *shell;
- GtkWindow *window;
- GList *embeds = NULL;
- GList *found;
- EphyEmbed *embed = NULL;
-
- shell = ephy_embed_shell_get_default ();
- window = gtk_application_get_active_window (GTK_APPLICATION (shell));
-
- if (!EPHY_IS_EMBED_CONTAINER (window))
- goto out;
-
- embeds = ephy_embed_container_get_children (EPHY_EMBED_CONTAINER (window));
- found = g_list_find_custom (embeds, uri, (GCompareFunc)embed_is_displaying_matching_uri);
-
- if (found)
- embed = found->data;
-
-out:
- g_list_free (embeds);
-
- return embed ? WEBKIT_WEB_VIEW (ephy_embed_get_web_view (embed)) : NULL;
+ if (load_event == WEBKIT_LOAD_FINISHED) {
+ WebKitWebResource *resource = webkit_web_view_get_main_resource (web_view);
+ webkit_web_resource_get_data (resource,
+ request->cancellable,
+ (GAsyncReadyCallback)(web_resource_data_cb),
+ request);
+ }
}
static void
@@ -245,7 +155,6 @@ ephy_view_source_request_start (EphyViewSourceRequest *request)
char *modified_uri;
char *decoded_fragment;
const char *original_uri;
- WebKitWebView *web_view;
request->source_handler->outstanding_requests =
g_list_prepend (request->source_handler->outstanding_requests, request);
@@ -253,29 +162,25 @@ ephy_view_source_request_start (EphyViewSourceRequest *request)
original_uri = webkit_uri_scheme_request_get_uri (request->scheme_request);
soup_uri = soup_uri_new (original_uri);
- if (!soup_uri || !soup_uri->fragment) {
- /* Can't assert because user could theoretically input something weird */
- GError *error = g_error_new (WEBKIT_NETWORK_ERROR,
- WEBKIT_NETWORK_ERROR_FAILED,
- _("%s is not a valid URI"),
- original_uri);
- finish_uri_scheme_request (request, NULL, error);
- g_error_free (error);
+ if (!soup_uri) {
+ g_critical ("Failed to construct SoupURI for %s", original_uri);
+ finish_uri_scheme_request (request, g_strdup (""));
return;
}
/* Convert e.g. ephy-source://gnome.org#https to https://gnome.org */
+ g_assert (soup_uri->fragment);
decoded_fragment = soup_uri_decode (soup_uri->fragment);
soup_uri_set_scheme (soup_uri, decoded_fragment);
soup_uri_set_fragment (soup_uri, NULL);
modified_uri = soup_uri_to_string (soup_uri, FALSE);
- g_assert (modified_uri);
- web_view = get_web_view_matching_uri (soup_uri);
- if (web_view)
- ephy_view_source_request_begin_get_source_from_web_view (request, WEBKIT_WEB_VIEW (web_view));
- else
- ephy_view_source_request_begin_get_source_from_uri (request, modified_uri);
+ g_assert(request->load_changed_id == 0);
+ request->load_changed_id = g_signal_connect (request->web_view, "load-changed",
+ G_CALLBACK (load_changed_cb),
+ request);
+
+ webkit_web_view_load_uri (request->web_view, modified_uri);
g_free (decoded_fragment);
g_free (modified_uri);
@@ -283,19 +188,12 @@ ephy_view_source_request_start (EphyViewSourceRequest *request)
}
static void
-cancel_outstanding_request (EphyViewSourceRequest *request)
-{
- g_cancellable_cancel (request->cancellable);
-}
-
-static void
ephy_view_source_handler_dispose (GObject *object)
{
EphyViewSourceHandler *handler = EPHY_VIEW_SOURCE_HANDLER (object);
if (handler->outstanding_requests) {
- g_list_foreach (handler->outstanding_requests, (GFunc)cancel_outstanding_request, NULL);
- g_list_free (handler->outstanding_requests);
+ g_list_free_full (handler->outstanding_requests, (GDestroyNotify)ephy_view_source_request_free);
handler->outstanding_requests = NULL;
}
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index befeea5..b3bf490 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -42,7 +42,6 @@
#include "ephy-snapshot-service.h"
#include "ephy-string.h"
#include "ephy-uri-helpers.h"
-#include "ephy-view-source-handler.h"
#include "ephy-web-app-utils.h"
#include "ephy-web-extension-proxy.h"
#include "ephy-zoom.h"
@@ -1658,7 +1657,6 @@ update_security_status_for_committed_load (EphyWebView *view,
g_clear_pointer (&view->tls_error_failing_uri, g_free);
if (!soup_uri ||
- strcmp (soup_uri_get_scheme (soup_uri), EPHY_VIEW_SOURCE_SCHEME) == 0 ||
webkit_security_manager_uri_scheme_is_local (security_manager, soup_uri->scheme) ||
webkit_security_manager_uri_scheme_is_empty_document (security_manager, soup_uri->scheme)) {
security_level = EPHY_SECURITY_LEVEL_LOCAL_PAGE;
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 27c53a7..31a1fed 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -10,7 +10,6 @@ embed/ephy-embed-shell.c
embed/ephy-embed-utils.c
embed/ephy-encodings.c
embed/ephy-find-toolbar.c
-embed/ephy-view-source-handler.c
embed/ephy-web-view.c
lib/ephy-file-helpers.c
lib/ephy-form-auth-data.c
diff --git a/src/Makefile.am b/src/Makefile.am
index d860d82..0c9da73 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -169,10 +169,7 @@ RESOURCE_FILES = \
resources/incognito.png \
resources/mime-types-permissions.xml \
resources/missing-thumbnail.png \
- resources/network-error-symbolic.png \
- resources/prism.css \
- resources/prism.js
-
+ resources/network-error-symbolic.png
epiphany-resources.c: resources/epiphany.gresource.xml $(RESOURCE_FILES)
$(AM_V_GEN) glib-compile-resources --target=$@ --sourcedir=$(srcdir)/resources --generate-source
--c-name epiphany $(srcdir)/resources/epiphany.gresource.xml
diff --git a/src/resources/epiphany.gresource.xml b/src/resources/epiphany.gresource.xml
index eca494b..0558568 100644
--- a/src/resources/epiphany.gresource.xml
+++ b/src/resources/epiphany.gresource.xml
@@ -8,8 +8,6 @@
<file>network-error-symbolic.png</file>
<file compressed="true">about.ini</file>
<file compressed="true">epiphany.css</file>
- <file compressed="true">prism.css</file>
- <file compressed="true">prism.js</file>
<file alias="page-templates/about.css" compressed="true">about.css</file>
<file alias="page-templates/error.css" compressed="true">error.css</file>
<file alias="page-templates/error.html" compressed="true">error.html</file>
diff --git a/src/window-commands.c b/src/window-commands.c
index 0838f20..04b27f5 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -51,7 +51,6 @@
#include "ephy-settings.h"
#include "ephy-shell.h"
#include "ephy-string.h"
-#include "ephy-view-source-handler.h"
#include "ephy-web-app-utils.h"
#include "ephy-zoom.h"
@@ -1772,23 +1771,6 @@ static void
view_source_embedded (const char *uri, EphyEmbed *embed)
{
EphyEmbed *new_embed;
- SoupURI *soup_uri;
- char *source_uri;
-
- /* Abort if we're already in view source mode */
- if (strstr (uri, EPHY_VIEW_SOURCE_SCHEME) == uri)
- return;
-
- soup_uri = soup_uri_new (uri);
- if (!soup_uri) {
- g_critical ("Failed to construct SoupURI for %s", uri);
- return;
- }
-
- /* Convert e.g. https://gnome.org to ephy-source://gnome.org#https */
- soup_uri_set_fragment (soup_uri, soup_uri->scheme);
- soup_uri_set_scheme (soup_uri, EPHY_VIEW_SOURCE_SCHEME);
- source_uri = soup_uri_to_string (soup_uri, FALSE);
new_embed = ephy_shell_new_tab
(ephy_shell_get_default (),
@@ -1796,11 +1778,13 @@ view_source_embedded (const char *uri, EphyEmbed *embed)
embed,
EPHY_NEW_TAB_JUMP | EPHY_NEW_TAB_APPEND_AFTER);
- webkit_web_view_load_uri (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (new_embed), source_uri);
+ /* FIXME: Implement embedded view source mode using a custom URI handler and a
+ * javascript library for the syntax highlighting.
+ * https://bugzilla.gnome.org/show_bug.cgi?id=731558
+ */
+ webkit_web_view_load_uri
+ (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (new_embed), uri);
gtk_widget_grab_focus (GTK_WIDGET (new_embed));
-
- g_free (source_uri);
- soup_uri_free (soup_uri);
}
static void
@@ -1987,11 +1971,15 @@ window_cmd_page_source (GSimpleAction *action,
address = ephy_web_view_get_address (ephy_embed_get_web_view (embed));
+#if 0
+ FIXME: Disabled due to bug #738475
+
if (g_settings_get_boolean (EPHY_SETTINGS_MAIN,
EPHY_PREFS_INTERNAL_VIEW_SOURCE)) {
view_source_embedded (address, embed);
return;
}
+#endif
user_time = gtk_get_current_event_time ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]