static gboolean webkit_link_clicked (WebKitWebView *web_view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision, Document_Webkit *doc) { if (webkit_web_navigation_action_get_reason (navigation_action) != WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) return FALSE; webkit_web_view_load_request (web_view, request); return TRUE; }
gboolean decidewindow(WebKitWebView *view, WebKitWebFrame *f, WebKitNetworkRequest *r, WebKitWebNavigationAction *n, WebKitWebPolicyDecision *p, Client *c) { Arg arg; if(webkit_web_navigation_action_get_reason(n) == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) { webkit_web_policy_decision_ignore(p); arg.v = (void *)webkit_network_request_get_uri(r); newwindow(NULL, &arg); return TRUE; } return FALSE; }
static gboolean on_navigation_policy_decision_requested (MuMsgBodyView *self, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *nav_action, WebKitWebPolicyDecision *policy_decision, gpointer data) { const char* uri; WebKitWebNavigationReason reason; uri = webkit_network_request_get_uri (request); reason = webkit_web_navigation_action_get_reason (nav_action); /* if it wasn't a user click, don't the navigation */ if (reason != WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) { webkit_web_policy_decision_ignore (policy_decision); return TRUE; } /* we handle links clicked ourselves, no need for navigation */ webkit_web_policy_decision_ignore (policy_decision); /* if there are 'cmd:<action>" links in the body text of * mu-internal messages (ie., notification from mu, not real * e-mail messages), we emit the 'action requested' * signal. this allows e.g triggering a database refresh from * a <a href="cmd:refresh">Refresh</a> link */ if (g_ascii_strncasecmp (uri, "cmd:", 4) == 0) { if (self->_priv->_view_mode == VIEW_MODE_NOTE) { g_signal_emit (G_OBJECT(self), signals[ACTION_REQUESTED], 0, uri + 4); } return TRUE; } /* don't try to play files on our local file system, this is not something * external content should do.*/ if (!mu_util_is_local_file(uri)) mu_util_play (uri, FALSE, TRUE); return TRUE; }
void WindowCheckKeyterms::navigation_policy_decision_requested (WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision) // Callback for clicking a link. { // Store scrolling position for the now active url. GtkAdjustment * adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (scrolledwindow_terms)); scrolling_position[active_url] = gtk_adjustment_get_value (adjustment); // Get the reason for this navigation policy request. WebKitWebNavigationReason reason = webkit_web_navigation_action_get_reason (navigation_action); // If a new page if loaded, allow the navigation, and exit. if (reason == WEBKIT_WEB_NAVIGATION_REASON_OTHER) { webkit_web_policy_decision_use (policy_decision); return; } // Don't follow pseudo-links clicked on this page. webkit_web_policy_decision_ignore (policy_decision); // Load new page depending on the pseudo-link clicked. html_link_clicked (webkit_network_request_get_uri (request)); }
/** * A link has been clicked * * When a link has been clicked the link management is dispatched to Liferea * core in order to manage the different filetypes, remote URLs. */ static gboolean liferea_webkit_link_clicked (WebKitWebView *view, WebKitWebFrame *frame, WebKitNetworkRequest *request, WebKitWebNavigationAction *navigation_action, WebKitWebPolicyDecision *policy_decision) { const gchar *uri; WebKitWebNavigationReason reason; gboolean url_handled; g_return_val_if_fail (WEBKIT_IS_WEB_VIEW (view), FALSE); g_return_val_if_fail (WEBKIT_IS_NETWORK_REQUEST (request), FALSE); reason = webkit_web_navigation_action_get_reason (navigation_action); /* iframes in items return WEBKIT_WEB_NAVIGATION_REASON_OTHER and shouldn't be handled as clicks */ if (reason != WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) return FALSE; uri = webkit_network_request_get_uri (request); if (webkit_web_navigation_action_get_button (navigation_action) == 2) { /* middle click */ browser_tabs_add_new (uri, uri, FALSE); webkit_web_policy_decision_ignore (policy_decision); return TRUE; } url_handled = liferea_htmlview_handle_URL (g_object_get_data (G_OBJECT (view), "htmlview"), uri); if (url_handled) webkit_web_policy_decision_ignore (policy_decision); return url_handled; }
static gboolean formhistory_navigation_decision_cb (WebKitWebView* web_view, WebKitWebFrame* web_frame, WebKitNetworkRequest* request, WebKitWebNavigationAction* action, WebKitWebPolicyDecision* decision, MidoriExtension* extension) { FormHistoryPriv* priv; JSContextRef js_context; gchar* value; /* The script returns form data in the form "field_name|,|value|,|field_type". We are handling only input fields with 'text' or 'password' type. The field separator is "|||" */ const gchar* script = "function dumpForm (inputs) {" " var out = '';" " for (var i = 0; i < inputs.length; i++) {" " if (inputs[i].getAttribute('autocomplete') == 'off' && " " inputs[i].type == 'text')" " continue;" " if (inputs[i].value && (inputs[i].type == 'text' || inputs[i].type == 'password')) {" " var ename = inputs[i].getAttribute('name');" " var eid = inputs[i].getAttribute('id');" " if (!eid && ename)" " eid=ename;" " out += eid+'|,|'+inputs[i].value +'|,|'+inputs[i].type +'|||';" " }" " }" " return out;" "}" "dumpForm (document.getElementsByTagName('input'))"; if (webkit_web_navigation_action_get_reason (action) != WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED) return FALSE; priv = g_object_get_data (G_OBJECT (extension), "priv"); js_context = webkit_web_frame_get_global_context (web_frame); value = sokoke_js_script_eval (js_context, script, NULL); formhistory_suggestions_hide_cb (NULL, NULL, priv); if (value && *value) { gchar** inputs = g_strsplit (value, "|||", 0); guint i = 0; while (inputs[i] != NULL) { gchar** parts = g_strsplit (inputs[i], "|,|", 3); if (parts && parts[0] && parts[1] && parts[2]) { if (strcmp (parts[2], "password")) formhistory_update_database (priv->db, NULL, parts[0], parts[1]); else { #if 0 FormhistoryPasswordEntry* entry; #endif gchar* data = formhistory_get_login_data (priv->db, webkit_web_frame_get_uri (web_frame)); if (data) { g_free (data); break; } #if 0 entry = g_slice_new (FormhistoryPasswordEntry); /* Domain and form data are freed from infopanel callback*/ entry->form_data = g_strdup (value); entry->domain = domain; entry->priv = priv; g_object_set_data (G_OBJECT (web_view), "FormHistoryPasswordEntry", entry); #endif } } g_strfreev (parts); i++; } g_strfreev (inputs); g_free (value); } return FALSE; }