aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--embed/ephy-web-view.c361
1 files changed, 0 insertions, 361 deletions
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 02f5d8c39..7ce358e42 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -527,360 +527,6 @@ ephy_web_view_create_form_auth_save_confirmation_info_bar (EphyWebView *web_view
return info_bar;
}
-#ifndef HAVE_WEBKIT2
-typedef struct {
- WebKitDOMNode *username_node;
- WebKitDOMNode *password_node;
-} FillData;
-
-static void
-fill_data_free (gpointer data)
-{
- FillData *fill_data = (FillData*)data;
-
- g_object_unref (fill_data->username_node);
- g_object_unref (fill_data->password_node);
-
- g_slice_free (FillData, fill_data);
-}
-
-static void
-fill_form_cb (const char *username,
- const char *password,
- gpointer user_data)
-{
- FillData *fill_data = (FillData*)user_data;
-
- if (username == NULL && password == NULL) {
- LOG ("No result");
- return;
- }
-
- LOG ("Found: user %s pass (hidden)", username);
-
- g_object_set (fill_data->username_node,
- "value", username, NULL);
- g_object_set (fill_data->password_node,
- "value", password, NULL);
-}
-
-typedef struct {
- EphyEmbed *embed;
- char *uri;
- char *name_field;
- char *password_field;
- char *name_value;
- char *password_value;
-} StorePasswordData;
-
-static void
-store_password_data_free (gpointer data)
-{
- StorePasswordData *store_data = (StorePasswordData*)data;
-
- g_free (store_data->uri);
- g_free (store_data->name_field);
- g_free (store_data->name_value);
- g_free (store_data->password_field);
- g_free (store_data->password_value);
-
- g_slice_free (StorePasswordData, store_data);
-}
-
-static void
-store_password (GtkInfoBar *info_bar, gint response_id, gpointer data)
-{
- StorePasswordData *store_data = (StorePasswordData*)data;
- EphyWebView *web_view = ephy_embed_get_web_view (store_data->embed);
- char *uri = store_data->uri;
- char *name_field_name = store_data->name_field;
- char *name_field_value = store_data->name_value;
- char *password_field_name = store_data->password_field;
- char *password_field_value = store_data->password_value;
- char *host;
-
- if (response_id != GTK_RESPONSE_YES) {
- LOG ("Response is %d - not saving.", response_id);
- store_password_data_free (store_data);
- gtk_widget_destroy (GTK_WIDGET (info_bar));
- return;
- }
-
- LOG ("Response is GTK_RESPONSE_YES - saving!");
- ephy_form_auth_data_store (uri,
- name_field_name,
- password_field_name,
- name_field_value,
- password_field_value,
- NULL, NULL);
-
- /* Update internal caching */
- host = ephy_string_get_host_name (uri);
- ephy_embed_single_add_form_auth (EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (ephy_embed_shell_get_default ())),
- host,
- name_field_name,
- password_field_name,
- name_field_value);
- g_free (host);
-
- store_password_data_free (store_data);
- gtk_widget_destroy (GTK_WIDGET (info_bar));
-}
-
-static void
-request_decision_on_storing (StorePasswordData *store_data)
-{
- EphyEmbed *embed = store_data->embed;
- EphyWebView *web_view = ephy_embed_get_web_view (embed);
- GtkWidget *info_bar;
- GtkWidget *action_area;
- GtkWidget *content_area;
- GtkWidget *label;
- char *message;
- char *hostname;
-
- hostname = ephy_string_get_host_name (store_data->uri);
- info_bar = ephy_web_view_create_form_auth_save_confirmation_info_bar (web_view,
- hostname,
- store_data->name_value);
- g_free (hostname);
- g_signal_connect (info_bar, "response", G_CALLBACK (store_password), store_data);
- gtk_widget_show (info_bar);
-}
-
-static void
-should_store_cb (const char *username,
- const char *password,
- gpointer user_data)
-{
- StorePasswordData *store_data = (StorePasswordData*)user_data;
-
- if (username == NULL && password == NULL) {
- LOG ("No result on query; asking whether we should store.");
- request_decision_on_storing (store_data);
- return;
- }
-
-
- /* FIXME: We use only the first result, for now; We need to do
- * something smarter here */
- if (g_str_equal (username, store_data->name_value) &&
- g_str_equal (password, store_data->password_value)) {
- LOG ("User/password already stored. Not asking about storing.");
- store_password_data_free (store_data);
- return;
- }
-
- LOG ("User/password not yet stored. Asking about storing.");
- request_decision_on_storing (store_data);
-}
-
-static gboolean
-form_submitted_cb (WebKitDOMHTMLFormElement *dom_form,
- WebKitDOMEvent *dom_event,
- EphyWebView *web_view)
-{
- SoupURI *uri;
- StorePasswordData *store_data;
-
- WebKitDOMNode *username_node = NULL;
- WebKitDOMNode *password_node = NULL;
-
- uri = soup_uri_new (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (web_view)));
- if (!uri)
- return TRUE;
-
- soup_uri_set_query (uri, NULL);
-
- ephy_web_dom_utils_find_form_auth_elements (dom_form, &username_node, &password_node);
-
- store_data = g_slice_new (StorePasswordData);
-
- store_data->uri = soup_uri_to_string (uri, FALSE);
- store_data->embed = EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view);
-
- g_object_get (username_node,
- "name", &store_data->name_field,
- "value", &store_data->name_value, NULL);
-
- g_object_get (password_node,
- "name", &store_data->password_field,
- "value", &store_data->password_value, NULL);
-
- LOG ("Form submitted! %s %s",
- store_data->name_value,
- store_data->password_value);
-
- ephy_form_auth_data_query (store_data->uri,
- store_data->name_field,
- store_data->password_field,
- should_store_cb,
- store_data,
- NULL);
-
- soup_uri_free (uri);
-
- g_object_unref (username_node);
- g_object_unref (password_node);
-
- return TRUE;
-}
-
-static void
-pre_fill_form (WebKitDOMNode *username_node,
- WebKitDOMNode *password_node,
- EphyWebView *view)
-{
- GSList *p = NULL;
- GSList *l = NULL;
- SoupURI *uri = NULL;
- EphyEmbedShell *embed_shell = ephy_embed_shell_get_default ();
-
- uri = soup_uri_new (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (view)));
- if (uri)
- l = ephy_embed_single_get_form_auth (EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell)), uri->host);
-
- for (p = l; p; p = p->next) {
- char *username_field_name;
- char *password_field_name;
- EphyFormAuthData *data = (EphyFormAuthData *)p->data;
-
- g_object_get (username_node,
- "name", &username_field_name, NULL);
- g_object_get (password_node,
- "name", &password_field_name, NULL);
-
- if (g_strcmp0 (username_field_name, data->form_username) == 0 &&
- g_strcmp0 (password_field_name, data->form_password) == 0) {
- FillData *fill_data = g_slice_new (FillData);
- char *uri_str = soup_uri_to_string (uri, FALSE);
-
- fill_data->username_node = g_object_ref (username_node);
- fill_data->password_node = g_object_ref (password_node);
-
- ephy_form_auth_data_query (uri_str,
- data->form_username,
- data->form_password,
- fill_form_cb,
- fill_data,
- fill_data_free);
- g_free (uri_str);
- }
- g_free (username_field_name);
- g_free (password_field_name);
- }
-
- soup_uri_free (uri);
-}
-
-static void
-_ephy_web_view_hook_into_forms (EphyWebView *web_view)
-{
- WebKitDOMHTMLCollection *forms = NULL;
- WebKitDOMDocument *document = NULL;
- gulong forms_n;
- int i;
-
- document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (web_view));
- forms = webkit_dom_document_get_forms (document);
- forms_n = webkit_dom_html_collection_get_length (forms);
-
- if (forms_n == 0) {
- LOG ("No forms found.");
- g_object_unref(forms);
- return;
- }
-
- for (i = 0; i < forms_n; i++) {
- WebKitDOMHTMLFormElement *form;
- WebKitDOMNode *username_node = NULL;
- WebKitDOMNode *password_node = NULL;
-
- form = WEBKIT_DOM_HTML_FORM_ELEMENT (webkit_dom_html_collection_item (forms, i));
-
- /* We have a field that may be the user, and one for a password. */
- if (ephy_web_dom_utils_find_form_auth_elements (form, &username_node, &password_node)) {
- LOG ("Hooking and pre-filling a form");
- webkit_dom_event_target_add_event_listener (WEBKIT_DOM_EVENT_TARGET (form), "submit",
- G_CALLBACK (form_submitted_cb), false,
- web_view);
-
- pre_fill_form (username_node, password_node, web_view);
-
- g_object_unref (username_node);
- g_object_unref (password_node);
- } else
- LOG ("No pre-fillable/hookable form found");
- }
-
- g_object_unref(forms);
-}
-
-static void
-_ephy_web_view_hook_into_links (EphyWebView *web_view)
-{
- WebKitDOMNodeList *links = NULL;
- WebKitDOMDocument *document = NULL;
- gulong links_n;
- int i;
-
- document = webkit_web_view_get_dom_document (WEBKIT_WEB_VIEW (web_view));
- links = webkit_dom_document_get_elements_by_tag_name (document, "link");
- links_n = webkit_dom_node_list_get_length (links);
-
- if (links_n == 0) {
- LOG ("No links found.");
- g_object_unref(links);
- return;
- }
-
- for (i = 0; i < links_n; i++) {
- WebKitDOMNode *link;
- char *rel = NULL;
-
- link = webkit_dom_node_list_item (links, i);
- rel = webkit_dom_html_link_element_get_rel (WEBKIT_DOM_HTML_LINK_ELEMENT (link));
-
- if (g_strcmp0 (rel, "alternate") == 0) {
- char *type = NULL;
- char *title = NULL;
- char *address = NULL;
- SoupURI *feed_uri;
- SoupURI *current_uri;
-
- g_object_get (link,
- "type", &type,
- "title", &title,
- "href", &address,
- NULL);
-
- feed_uri = soup_uri_new (address);
- if (!feed_uri) {
- current_uri = soup_uri_new (ephy_web_view_get_address (web_view));
- feed_uri = soup_uri_new_with_base (current_uri, address);
- soup_uri_free (current_uri);
- }
-
- if (feed_uri) {
- g_free (address);
- address = soup_uri_to_string (feed_uri, FALSE);
- LOG ("Emitting ge-feed-link: %s, %s, %s", type, title, address);
- g_signal_emit_by_name (web_view, "ge-feed-link", type, title, address);
- soup_uri_free (feed_uri);
- }
-
- g_free (type);
- g_free (title);
- g_free (address);
- }
-
- g_free (rel);
- }
-
- g_object_unref(links);
-}
-#endif
-
static void
update_navigation_flags (EphyWebView *view)
{
@@ -1123,14 +769,7 @@ title_changed_cb (WebKitWebView *web_view,
char *title;
EphyHistoryService *history = EPHY_WEB_VIEW (web_view)->priv->history_service;
-#ifndef HAVE_WEBKIT2
- WebKitWebFrame *frame;
-
- frame = webkit_web_view_get_main_frame (web_view);
- uri = webkit_web_frame_get_uri (frame);
-#else
uri = webkit_web_view_get_uri (web_view);
-#endif
g_object_get (web_view, "title", &title, NULL);