summaryrefslogtreecommitdiff
path: root/src/window-commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/window-commands.c')
-rw-r--r--src/window-commands.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/window-commands.c b/src/window-commands.c
index 93d9616b8..c52741edd 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -51,6 +51,7 @@
#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"
@@ -1815,6 +1816,23 @@ 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 (),
@@ -1822,13 +1840,11 @@ view_source_embedded (const char *uri, EphyEmbed *embed)
embed,
EPHY_NEW_TAB_JUMP | EPHY_NEW_TAB_APPEND_AFTER);
- /* 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);
+ webkit_web_view_load_uri (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (new_embed), source_uri);
gtk_widget_grab_focus (GTK_WIDGET (new_embed));
+
+ g_free (source_uri);
+ soup_uri_free (soup_uri);
}
static void
@@ -2015,15 +2031,11 @@ 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 ();