Commit 3df6f8c4 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos Committed by Carlos Garcia Campos
Browse files

Remove all WebKit1 code

We are using WebKit2 unconditionally already.
parent 7213d38a
......@@ -79,8 +79,6 @@ GCR_REQUIRED=3.5.5
AVAHI_REQUIRED=0.6.22
WEBKIT_GTK_PC_NAME=webkit2gtk-3.0
AC_DEFINE([HAVE_WEBKIT2],[1],[Define if building with WebKit2])
AM_CONDITIONAL(WITH_WEBKIT2, [test "yes" = "yes"])
# Tests
......
......@@ -199,10 +199,6 @@ webkit_pref_callback_user_agent (GSettings *settings,
"Epiphany", VERSION);
}
/* This doesn't contain WebKit2 specific API, but it's only used inside
* HAVE_WEBKIT2 blocks, so it gives a compile warning when building
* with WebKit1.
*/
static gdouble
get_screen_dpi (GdkScreen *screen)
{
......
......@@ -2549,7 +2549,6 @@ ephy_web_view_set_typed_address (EphyWebView *view,
g_object_notify (G_OBJECT (view), "typed-address");
}
#ifdef HAVE_WEBKIT2
static void
has_modified_forms_cb (GDBusProxy *web_extension,
GAsyncResult *result,
......@@ -2567,7 +2566,6 @@ has_modified_forms_cb (GDBusProxy *web_extension,
g_task_return_boolean (task, retval);
g_object_unref (task);
}
#endif
/**
* ephy_web_view_has_modified_forms:
......@@ -2590,7 +2588,6 @@ ephy_web_view_has_modified_forms (EphyWebView *view,
gpointer user_data)
{
GTask *task = g_task_new (view, cancellable, callback, user_data);
#ifdef HAVE_WEBKIT2
GDBusProxy *web_extension;
web_extension = ephy_embed_shell_get_web_extension_proxy (ephy_embed_shell_get_default ());
......@@ -2606,11 +2603,6 @@ ephy_web_view_has_modified_forms (EphyWebView *view,
} else {
g_task_return_boolean (task, FALSE);
}
#else
WebKitDOMDocument *document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (view));
g_task_return_boolean (task, ephy_web_dom_utils_has_modified_forms (document));
#endif
g_object_unref (task);
}
......
......@@ -66,7 +66,6 @@ typedef enum {
EPHY_PROCESS_OTHER
} EphyProcess;
#ifdef HAVE_WEBKIT2
static const char *get_ephy_process_name (EphyProcess process)
{
switch (process) {
......@@ -82,7 +81,6 @@ static const char *get_ephy_process_name (EphyProcess process)
return NULL;
}
#endif
static void vma_free (VMA_t* vma)
{
......@@ -306,9 +304,7 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
g_slist_free (vma_entries);
#ifdef HAVE_WEBKIT2
g_string_append_printf (str, "<h2>%s</h2>", get_ephy_process_name (process));
#endif
/* Anon table. */
print_vma_table (str, anon_hash, "Anonymous memory");
......@@ -321,7 +317,6 @@ static void ephy_smaps_pid_to_html (EphySMaps *smaps, GString *str, pid_t pid, E
g_hash_table_unref (mapped_hash);
}
#ifdef HAVE_WEBKIT2
static pid_t get_pid_from_proc_name (const char *name)
{
guint i;
......@@ -442,7 +437,6 @@ static void ephy_smaps_pid_children_to_html (EphySMaps *smaps, GString *str, pid
}
g_dir_close (proc);
}
#endif
char* ephy_smaps_to_html (EphySMaps *smaps)
{
......@@ -452,10 +446,7 @@ char* ephy_smaps_to_html (EphySMaps *smaps)
g_string_append (str, "<body>");
ephy_smaps_pid_to_html (smaps, str, pid, EPHY_PROCESS_EPIPHANY);
#ifdef HAVE_WEBKIT2
ephy_smaps_pid_children_to_html (smaps, str, pid);
#endif
g_string_append (str, "</body>");
......
......@@ -27,11 +27,7 @@
#define GNOME_DESKTOP_USE_UNSTABLE_API
#endif
#include <libgnome-desktop/gnome-desktop-thumbnail.h>
#ifdef HAVE_WEBKIT2
#include <webkit2/webkit2.h>
#else
#include <webkit/webkit.h>
#endif
#define EPHY_SNAPSHOT_SERVICE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), EPHY_TYPE_SNAPSHOT_SERVICE, EphySnapshotServicePrivate))
......@@ -182,7 +178,6 @@ save_snapshot (cairo_surface_t *surface,
(GAsyncReadyCallback)snapshot_saved, result);
}
#ifdef HAVE_WEBKIT2
static void
on_snapshot_ready (WebKitWebView *webview,
GAsyncResult *result,
......@@ -202,46 +197,22 @@ on_snapshot_ready (WebKitWebView *webview,
save_snapshot (surface, simple);
cairo_surface_destroy (surface);
}
#endif
static gboolean
retrieve_snapshot_from_web_view (GSimpleAsyncResult *result)
{
#ifndef HAVE_WEBKIT2
cairo_surface_t *surface;
#endif
SnapshotAsyncData *data;
data = (SnapshotAsyncData *)g_simple_async_result_get_op_res_gpointer (result);
#ifdef HAVE_WEBKIT2
webkit_web_view_get_snapshot (data->web_view,
WEBKIT_SNAPSHOT_REGION_VISIBLE,
WEBKIT_SNAPSHOT_OPTIONS_NONE,
NULL, (GAsyncReadyCallback)on_snapshot_ready,
result);
#else
surface = webkit_web_view_get_snapshot (data->web_view);
if (surface == NULL) {
g_simple_async_result_set_error (result,
EPHY_SNAPSHOT_SERVICE_ERROR,
EPHY_SNAPSHOT_SERVICE_ERROR_WEB_VIEW,
"%s", "Error getting snapshot from web view");
g_simple_async_result_complete (result);
g_object_unref (result);
return FALSE;
}
save_snapshot (surface, result);
cairo_surface_destroy (surface);
#endif
return FALSE;
}
#ifdef HAVE_WEBKIT2
static void
webview_load_changed_cb (WebKitWebView *webview,
WebKitLoadEvent load_event,
......@@ -277,33 +248,6 @@ webview_load_failed_cb (WebKitWebView *webview,
return FALSE;
}
#else
static void
webview_load_status_changed_cb (WebKitWebView *webview,
GParamSpec *pspec,
GSimpleAsyncResult *result)
{
switch (webkit_web_view_get_load_status (webview)) {
case WEBKIT_LOAD_FINISHED:
/* Load finished doesn't ensure that we actually have visible
content yet, so hold a bit before retrieving the snapshot. */
g_idle_add ((GSourceFunc) retrieve_snapshot_from_web_view, result);
g_signal_handlers_disconnect_by_func (webview, webview_load_status_changed_cb, result);
break;
case WEBKIT_LOAD_FAILED:
g_signal_handlers_disconnect_by_func (webview, webview_load_status_changed_cb, result);
g_simple_async_result_set_error (result,
EPHY_SNAPSHOT_SERVICE_ERROR,
EPHY_SNAPSHOT_SERVICE_ERROR_WEB_VIEW,
"%s", "Error getting snapshot, web view failed to load");
g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
break;
default:
break;
}
}
#endif
static gboolean
ephy_snapshot_service_take_from_webview (GSimpleAsyncResult *result)
......@@ -312,7 +256,6 @@ ephy_snapshot_service_take_from_webview (GSimpleAsyncResult *result)
data = (SnapshotAsyncData *)g_simple_async_result_get_op_res_gpointer (result);
#ifdef HAVE_WEBKIT2
if (webkit_web_view_get_estimated_load_progress (WEBKIT_WEB_VIEW (data->web_view)) == 1.0)
retrieve_snapshot_from_web_view (result);
else {
......@@ -321,14 +264,6 @@ ephy_snapshot_service_take_from_webview (GSimpleAsyncResult *result)
g_signal_connect (data->web_view, "load-failed",
G_CALLBACK (webview_load_failed_cb), result);
}
#else
if (webkit_web_view_get_load_status (data->web_view) == WEBKIT_LOAD_FINISHED)
retrieve_snapshot_from_web_view (result);
else
g_signal_connect (data->web_view, "notify::load-status",
G_CALLBACK (webview_load_status_changed_cb),
result);
#endif
return FALSE;
}
......
......@@ -22,11 +22,7 @@
#define _EPHY_SNAPSHOT_SERVICE_H
#include <gtk/gtk.h>
#ifdef HAVE_WEBKIT2
#include <webkit2/webkit2.h>
#else
#include <webkit/webkit.h>
#endif
#include <glib-object.h>
......
......@@ -27,11 +27,7 @@
#include <glib/gstdio.h>
#include <libsoup/soup.h>
#ifdef HAVE_WEBKIT2
#include <webkit2/webkit2.h>
#else
#include <webkit/webkit.h>
#endif
#define EPHY_WEB_APP_DESKTOP_FILE_PREFIX "epiphany-"
......@@ -257,7 +253,6 @@ out:
return desktop_file_path;
}
#ifdef HAVE_WEBKIT2
static SoupCookieJar *get_current_cookie_jar (void)
{
char *filename;
......@@ -273,19 +268,6 @@ static SoupCookieJar *get_current_cookie_jar (void)
return jar;
}
#else
static SoupCookieJar *get_current_cookie_jar (void)
{
SoupSession *session = webkit_get_default_session ();
SoupCookieJar *jar;
jar = (SoupCookieJar*)soup_session_get_feature (session, SOUP_TYPE_COOKIE_JAR);
/* WebKit might not have a cookie jar yet, if it has not needed one
* and none has been set by Epiphany. */
return jar ? g_object_ref (jar) : NULL;
}
#endif
static void
create_cookie_jar_for_domain (const char *address, const char *directory)
......
......@@ -26,12 +26,7 @@
#include <glib.h>
#include <gtk/gtk.h>
#ifdef HAVE_WEBKIT2
#include <webkit2/webkit2.h>
#else
#include <webkit/webkit.h>
#endif
G_BEGIN_DECLS
......
......@@ -31,11 +31,7 @@
#include "totem-glow-button.h"
#include <glib/gi18n.h>
#ifdef HAVE_WEBKIT2
#include <webkit2/webkit2.h>
#else
#include <webkit/webkit.h>
#endif
G_DEFINE_TYPE (EphyDownloadWidget, ephy_download_widget, GTK_TYPE_BOX)
......@@ -88,11 +84,7 @@ get_destination_basename_from_download (EphyDownload *ephy_download)
char *unescaped;
download = ephy_download_get_webkit_download (ephy_download);
#ifdef HAVE_WEBKIT2
dest = webkit_download_get_destination (download);
#else
dest = webkit_download_get_destination_uri (download);
#endif
if (!dest)
return NULL;
......@@ -134,17 +126,11 @@ get_remaining_time (WebKitDownload *download)
gdouble elapsed_time;
gdouble remaining_time;
gdouble per_byte_time;
#ifdef HAVE_WEBKIT2
WebKitURIResponse *response;
response = webkit_download_get_response (download);
total = webkit_uri_response_get_content_length (response);
cur = webkit_download_get_received_data_length (download);
#else
total = webkit_download_get_total_size (download);
cur = webkit_download_get_current_size (download);
#endif
elapsed_time = webkit_download_get_elapsed_time (download);
if (cur <= 0)
......@@ -193,11 +179,7 @@ update_download_label_and_tooltip (EphyDownloadWidget *widget,
char *destination;
download = ephy_download_get_webkit_download (widget->priv->download);
#ifdef HAVE_WEBKIT2
destination = g_filename_display_basename (webkit_download_get_destination (download));
#else
destination = g_filename_display_basename (webkit_download_get_destination_uri (download));
#endif
remaining_tooltip = g_markup_printf_escaped ("%s\n%s", destination, download_label);
g_free (destination);
......@@ -210,19 +192,10 @@ update_download_label_and_tooltip (EphyDownloadWidget *widget,
static gboolean
download_content_length_is_known (WebKitDownload *download)
{
#ifdef HAVE_WEBKIT2
WebKitURIResponse *response;
response = webkit_download_get_response (download);
return webkit_uri_response_get_content_length (response);
#else
WebKitNetworkResponse *response;
SoupMessage* message;
response = webkit_download_get_network_response (download);
message = webkit_network_response_get_message (response);
return soup_message_headers_get_content_length (message->response_headers) > 0;
#endif
}
static void
......@@ -233,14 +206,10 @@ widget_progress_cb (WebKitDownload *download,
int progress;
char *download_label = NULL;
#ifdef HAVE_WEBKIT2
if (!webkit_download_get_destination (download))
return;
progress = webkit_download_get_estimated_progress (download) * 100;
#else
progress = webkit_download_get_progress (download) * 100;
#endif
if (progress % 10 == 0)
update_download_icon (widget);
......@@ -260,11 +229,7 @@ widget_progress_cb (WebKitDownload *download,
gint64 current_size;
/* Unknown content length, show received bytes instead. */
#ifdef HAVE_WEBKIT2
current_size = webkit_download_get_received_data_length (download);
#else
current_size = webkit_download_get_current_size (download);
#endif
if (current_size > 0)
download_label = g_format_size (current_size);
}
......@@ -275,7 +240,6 @@ widget_progress_cb (WebKitDownload *download,
}
}
#ifdef HAVE_WEBKIT2
static void
widget_destination_changed_cb (WebKitDownload *download,
GParamSpec *pspec,
......@@ -296,26 +260,7 @@ widget_finished_cb (WebKitDownload *download,
update_download_label_and_tooltip (widget, _("Finished"));
totem_glow_button_set_glow (TOTEM_GLOW_BUTTON (widget->priv->button), TRUE);
}
#else
static void
widget_status_cb (WebKitDownload *download,
GParamSpec *pspec,
EphyDownloadWidget *widget)
{
WebKitDownloadStatus status;
status = webkit_download_get_status (download);
if (status != WEBKIT_DOWNLOAD_STATUS_FINISHED)
return;
widget->priv->finished = TRUE;
update_download_label_and_tooltip (widget, _("Finished"));
totem_glow_button_set_glow (TOTEM_GLOW_BUTTON (widget->priv->button), TRUE);
}
#endif
#ifdef HAVE_WEBKIT2
static void
widget_failed_cb (WebKitDownload *download,
GError *error,
......@@ -330,31 +275,6 @@ widget_failed_cb (WebKitDownload *download,
gtk_widget_set_tooltip_text (GTK_WIDGET (widget), error_msg);
g_free (error_msg);
}
#else
static gboolean
widget_error_cb (WebKitDownload *download,
gint error_code,
gint error_detail,
char *reason,
EphyDownloadWidget *widget)
{
char *error_msg;
g_signal_handlers_disconnect_by_func (download, widget_status_cb, widget);
g_signal_handlers_disconnect_by_func (download, widget_progress_cb, widget);
error_msg = g_strdup_printf (_("Error downloading: %s"), reason);
gtk_label_set_text (GTK_LABEL (widget->priv->remaining), error_msg);
gtk_widget_set_tooltip_text (GTK_WIDGET (widget), error_msg);
g_free (error_msg);
totem_glow_button_set_glow (TOTEM_GLOW_BUTTON (widget->priv->button), TRUE);
return FALSE;
}
#endif
static void
open_activate_cb (GtkMenuItem *item, EphyDownloadWidget *widget)
......@@ -391,11 +311,7 @@ download_menu_clicked_cb (GtkWidget *button,
download = ephy_download_get_webkit_download (widget->priv->download);
#ifdef HAVE_WEBKIT2
basename = g_filename_display_basename (webkit_download_get_destination (download));
#else
basename = g_filename_display_basename (webkit_download_get_destination_uri (download));
#endif
name = g_uri_unescape_string (basename, NULL);
box = gtk_widget_get_parent (button);
......@@ -491,16 +407,10 @@ ephy_download_widget_dispose (GObject *object)
if (widget->priv->download != NULL) {
download = ephy_download_get_webkit_download (widget->priv->download);
#ifdef HAVE_WEBKIT2
g_signal_handlers_disconnect_by_func (download, widget_progress_cb, widget);
g_signal_handlers_disconnect_by_func (download, widget_destination_changed_cb, widget);
g_signal_handlers_disconnect_by_func (download, widget_finished_cb, widget);
g_signal_handlers_disconnect_by_func (download, widget_failed_cb, widget);
#else
g_signal_handlers_disconnect_by_func (download, widget_progress_cb, widget);
g_signal_handlers_disconnect_by_func (download, widget_status_cb, widget);
g_signal_handlers_disconnect_by_func (download, widget_error_cb, widget);
#endif
g_object_unref (widget->priv->download);
widget->priv->download = NULL;
......@@ -642,7 +552,6 @@ ephy_download_widget_new (EphyDownload *ephy_download)
widget->priv->remaining = remain;
widget->priv->menu = menu;
#ifdef HAVE_WEBKIT2
g_signal_connect (download, "notify::estimated-progress",
G_CALLBACK (widget_progress_cb), widget);
g_signal_connect (download, "notify::destination",
......@@ -651,14 +560,6 @@ ephy_download_widget_new (EphyDownload *ephy_download)
G_CALLBACK (widget_finished_cb), widget);
g_signal_connect (download, "failed",
G_CALLBACK (widget_failed_cb), widget);
#else
g_signal_connect (download, "notify::progress",
G_CALLBACK (widget_progress_cb), widget);
g_signal_connect (download, "notify::status",
G_CALLBACK (widget_status_cb), widget);
g_signal_connect (download, "error",
G_CALLBACK (widget_error_cb), widget);
#endif
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_HALF);
gtk_button_set_relief (GTK_BUTTON (menu), GTK_RELIEF_NORMAL);
......
......@@ -26,9 +26,7 @@
#include "ephy-hosts-store.h"
#include <glib/gi18n.h>
#ifdef HAVE_WEBKIT2
#include <libsoup/soup.h>
#endif
G_DEFINE_TYPE (EphyHostsStore, ephy_hosts_store, GTK_TYPE_LIST_STORE)
......@@ -45,22 +43,16 @@ async_update_favicon_icon (GObject *source, GAsyncResult *result, gpointer user_
IconLoadData *data = (IconLoadData *)user_data;
WebKitFaviconDatabase *database;
GdkPixbuf *favicon = NULL;
#ifdef HAVE_WEBKIT2
cairo_surface_t *icon_surface;
#endif
database = WEBKIT_FAVICON_DATABASE (source);
#ifdef HAVE_WEBKIT2
icon_surface = webkit_favicon_database_get_favicon_finish (database, result, NULL);
if (icon_surface) {
favicon = ephy_pixbuf_get_from_surface_scaled (icon_surface, FAVICON_SIZE, FAVICON_SIZE);
cairo_surface_destroy (icon_surface);
}
#else
favicon = webkit_favicon_database_get_favicon_pixbuf_finish (database, result, NULL);
#endif
if (favicon) {
/* The completion model might have changed its contents */
......@@ -82,9 +74,7 @@ async_update_favicon_icon (GObject *source, GAsyncResult *result, gpointer user_
static void
icon_changed_cb (WebKitFaviconDatabase *database,
const char *page_uri,
#ifdef HAVE_WEBKIT2
const char *favicon_uri,
#endif
GtkTreeModel *model)
{
GtkTreeIter iter;
......@@ -108,7 +98,6 @@ icon_changed_cb (WebKitFaviconDatabase *database,
g_free (host_address);
if (cmp == 0) {
#ifdef HAVE_WEBKIT2
IconLoadData *data;
GtkTreePath *path;
......@@ -123,19 +112,6 @@ icon_changed_cb (WebKitFaviconDatabase *database,
0,
async_update_favicon_icon,
data);
#else
GdkPixbuf *favicon = webkit_favicon_database_try_get_favicon_pixbuf (database,
page_uri,
FAVICON_SIZE,
FAVICON_SIZE);
if (favicon) {
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
EPHY_HOSTS_STORE_COLUMN_FAVICON, favicon,
-1);
g_object_unref (favicon);
}
#endif
}
valid = gtk_tree_model_iter_next (model, &iter);
......@@ -152,11 +128,7 @@ ephy_hosts_store_finalize (GObject *object)
EphyHostsStore *store = EPHY_HOSTS_STORE (object);
WebKitFaviconDatabase *database;
#ifdef HAVE_WEBKIT2
database = webkit_web_context_get_favicon_database (webkit_web_context_get_default ());
#else
database = webkit_get_favicon_database ();
#endif
g_signal_handlers_disconnect_by_func (database, icon_changed_cb, store);
......@@ -189,13 +161,8 @@ ephy_hosts_store_init (EphyHostsStore *self)
EPHY_HOSTS_STORE_COLUMN_ADDRESS,
GTK_SORT_ASCENDING);
#ifdef HAVE_WEBKIT2
g_signal_connect (webkit_web_context_get_favicon_database (webkit_web_context_get_default ()),
"favicon-changed", G_CALLBACK (icon_changed_cb), self);
#else
g_signal_connect (webkit_get_favicon_database (), "icon-loaded",
G_CALLBACK (icon_changed_cb), self);
#endif
}
EphyHostsStore *
......@@ -213,25 +180,13 @@ ephy_hosts_store_add_hosts (EphyHostsStore *store,
GtkTreeIter treeiter;
GtkTreePath *path;
GList *iter;
GdkPixbuf *favicon;
IconLoadData *data;
WebKitFaviconDatabase *database;
#ifdef HAVE_WEBKIT2
database = webkit_web_context_get_favicon_database (webkit_web_context_get_default ());
#else
database = webkit_get_favicon_database ();
#endif
for (iter = hosts; iter != NULL; iter = iter->next) {
host = (EphyHistoryHost *)iter->data;
#ifdef HAVE_WEBKIT2
/* Flag favicon to NULL to reuse some code later on */
favicon = NULL;
#else
favicon = webkit_favicon_database_try_get_favicon_pixbuf (database, host->url,
FAVICON_SIZE, FAVICON_SIZE);
#endif
gtk_list_store_insert_with_values (GTK_LIST_STORE (store),
&treeiter, G_MAXINT,
......@@ -239,31 +194,19 @@ ephy_hosts_store_add_hosts (EphyHostsStore *store,
EPHY_HOSTS_STORE_COLUMN_TITLE, host->title,
EPHY_HOSTS_STORE_COLUMN_ADDRESS, host->url,
EPHY_HOSTS_STORE_COLUMN_VISIT_COUNT, host->visit_count,
#ifndef HAVE_WEBKIT2
EPHY_HOSTS_STORE_COLUMN_FAVICON, favicon,
#endif