Ejemplo n.º 1
0
/* ghtml_get_security */
SurferSecurity ghtml_get_security(GtkWidget * widget)
{
	SurferSecurity security = SS_NONE;
#if WEBKIT_CHECK_VERSION(1, 1, 0)
	GHtml * ghtml;
	WebKitWebFrame * frame;
	char const * location;
	WebKitWebDataSource *source;
	WebKitNetworkRequest *request;
	SoupMessage * message;
#endif

#if WEBKIT_CHECK_VERSION(1, 1, 0)
	ghtml = g_object_get_data(G_OBJECT(widget), "ghtml");
	frame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(ghtml->view));
	if((location = webkit_web_frame_get_uri(frame)) != NULL
			&& strncmp(location, "https://", 8) == 0)
	{
		security = SS_UNTRUSTED;
		source = webkit_web_frame_get_data_source(frame);
		request = webkit_web_data_source_get_request(source);
		message = webkit_network_request_get_message(request);
		if(ghtml->ssl == TRUE && message != NULL
				&& soup_message_get_flags(message)
				& SOUP_MESSAGE_CERTIFICATE_TRUSTED)
			security = SS_TRUSTED;
	}
#endif
	return security;
}
Ejemplo n.º 2
0
int
edit_src(struct tab *t, struct karg *args)
{
	WebKitWebFrame		*frame;
	WebKitWebDataSource	*ds;
	GString			*contents;
	struct edit_src_cb_args	*ext_args;

	if (external_editor == NULL){
		show_oops(t,"Setting external_editor not set");
		return (1);
	}

	frame = webkit_web_view_get_focused_frame(t->wv);
	ds = webkit_web_frame_get_data_source(frame);
	if (webkit_web_data_source_is_loading(ds)) {
		show_oops(t,"Webpage is still loading.");
		return (1);
	}

	contents = webkit_web_data_source_get_data(ds);
	if (!contents)
		show_oops(t,"No contents - opening empty file");

	ext_args = g_malloc(sizeof(struct edit_src_cb_args));
	ext_args->frame = frame;
	ext_args->data_src = ds;

	/* Check every 100 ms if file has changed */
	open_external_editor(t, contents ? contents->str : "", &edit_src_cb,
	    ext_args);
	return (0);
}
Ejemplo n.º 3
0
void cb_wv_notify_load_status(WebKitWebView *view, GParamSpec *pspec, Browser *b)
{
	WebKitWebFrame *frame;
	WebKitWebDataSource *source;
	WebKitNetworkRequest *request;
	SoupMessage *message;
	char *uri;

	switch (webkit_web_view_get_load_status(b->UI.view)) {
	case WEBKIT_LOAD_COMMITTED:
		uri = browser_get_uri(b);
		if (strstr(uri, "https://") == uri) {
			/* get ssl state */
			frame = webkit_web_view_get_main_frame(b->UI.view);
			source = webkit_web_frame_get_data_source(frame);
			request = webkit_web_data_source_get_request(source);
			message = webkit_network_request_get_message(request);
			b->State.ssl = soup_message_get_flags(message)
				^ SOUP_MESSAGE_CERTIFICATE_TRUSTED;
		}
		break;
	case WEBKIT_LOAD_FINISHED:
		/* add uri to history */
		if (!private_browsing && (uri = (char *)webkit_web_view_get_uri(b->UI.view))) {
			history_add(uri);
		}
		b->State.progress = 100;
		break;
	default:
		break;
	}

	/* update browser (statusbar, progress, position) */
	browser_update(b);
}
static void notify_load_status_cb(WebKitWebView* view, GParamSpec* pspec, GMainLoop* loop)
{
    WebKitLoadStatus status = webkit_web_view_get_load_status (view);
    WebKitWebFrame* frame = webkit_web_view_get_main_frame(view);
    WebKitWebDataSource* dataSource = webkit_web_frame_get_data_source(frame);

    if (status == WEBKIT_LOAD_COMMITTED) {
        g_assert(webkit_web_data_source_is_loading(dataSource));
        return;
    }
    else if (status != WEBKIT_LOAD_FINISHED)
        return;

    /* Test get_request */
    g_test_message("Testing webkit_web_data_source_get_request");
    WebKitNetworkRequest* request = webkit_web_data_source_get_request(dataSource);
    g_assert_cmpstr(webkit_network_request_get_uri(request), ==, "http://www.webkit.org/");

    /* Test get_main_resource */
    g_test_message("Testing webkit_web_data_source_get_main_resource");
    WebKitWebResource* resource = webkit_web_data_source_get_main_resource(dataSource);
    g_assert_cmpstr("text/html", ==, webkit_web_resource_get_mime_type(resource));
    g_assert_cmpstr("http://www.webkit.org/", ==, webkit_web_resource_get_uri(resource));

    /* Test get_data. We just test if data has certain size for the mean time */
    g_test_message("Testing webkit_web_data_source_get_data has certain size");
    GString* data = webkit_web_data_source_get_data(dataSource);
    g_assert(data->len > 100);

    /* FIXME: Add test for get_encoding */

    g_main_loop_quit(loop);
}
Ejemplo n.º 5
0
JNIEXPORT jintLong JNICALL WebKitGTK_NATIVE(_1webkit_1web_1frame_1get_1data_1source)
	(JNIEnv *env, jclass that, jintLong arg0)
{
	jintLong rc = 0;
	WebKitGTK_NATIVE_ENTER(env, that, _1webkit_1web_1frame_1get_1data_1source_FUNC);
	rc = (jintLong)webkit_web_frame_get_data_source((WebKitWebFrame *)arg0);
	WebKitGTK_NATIVE_EXIT(env, that, _1webkit_1web_1frame_1get_1data_1source_FUNC);
	return rc;
}
Ejemplo n.º 6
0
wxString wxWebViewWebKit::GetPageSource() const
{
    WebKitWebFrame* frame = webkit_web_view_get_main_frame(m_web_view);
    WebKitWebDataSource* src = webkit_web_frame_get_data_source (frame);

    // TODO: check encoding with
    // const gchar*
    // webkit_web_data_source_get_encoding(WebKitWebDataSource *data_source);
    return wxString(webkit_web_data_source_get_data (src)->str, wxConvUTF8);
}
static void notify_load_status_lifetime_cb(WebKitWebView* view, GParamSpec* pspec, GMainLoop* loop)
{
    WebKitLoadStatus status = webkit_web_view_get_load_status (view);
    WebKitWebFrame* frame = webkit_web_view_get_main_frame(view);
    WebKitWebDataSource* dataSource = webkit_web_frame_get_data_source(frame);

    if (status == WEBKIT_LOAD_COMMITTED) {
        g_assert(webkit_web_data_source_is_loading(dataSource));
        return;
    } else if (status != WEBKIT_LOAD_FINISHED)
        return;

    g_main_loop_quit(loop);
}
static void notify_load_status_unreachable_cb(WebKitWebView* view, GParamSpec* pspec, GMainLoop* loop)
{
    WebKitLoadStatus status = webkit_web_view_get_load_status (view);
    WebKitWebFrame* frame = webkit_web_view_get_main_frame(view);

    g_assert(status != WEBKIT_LOAD_FINISHED);

    if (status != WEBKIT_LOAD_FAILED)
        return;

    WebKitWebDataSource* datasource = webkit_web_frame_get_data_source(frame);

    g_assert_cmpstr("http://this.host.does.not.exist/doireallyexist.html", ==,
                    webkit_web_data_source_get_unreachable_uri(datasource));

    g_main_loop_quit(loop);
}
Ejemplo n.º 9
0
/* ghtml_get_source */
char const * ghtml_get_source(GtkWidget * widget)
{
#if WEBKIT_CHECK_VERSION(1, 1, 0)
	GHtml * ghtml;
	WebKitWebFrame * frame;
	WebKitWebDataSource * source;
	GString * str;

	ghtml = g_object_get_data(G_OBJECT(widget), "ghtml");
	frame = webkit_web_view_get_main_frame(WEBKIT_WEB_VIEW(ghtml->view));
	source = webkit_web_frame_get_data_source(frame);
	if((str = webkit_web_data_source_get_data(source)) == NULL)
		return NULL;
	return str->str;
#else
	return NULL;
#endif
}
static void test_webkit_web_data_source_lifetime()
{
    WebKitWebView* view;
    GMainLoop* loop;

    view = WEBKIT_WEB_VIEW(webkit_web_view_new());
    g_object_ref_sink(view);
    loop = g_main_loop_new(NULL, TRUE);
    g_signal_connect(view, "notify::load-status", G_CALLBACK(notify_load_status_lifetime_cb), loop);
    webkit_web_view_load_uri(view, "http://www.webkit.org");

    waitTimer = g_timeout_add_seconds(defaultTimeout, (GSourceFunc)wait_timer_fired, loop);

    g_main_loop_run(loop);

    WebKitWebDataSource* dataSource = webkit_web_frame_get_data_source(webkit_web_view_get_main_frame(view));
    GList* subResources = webkit_web_data_source_get_subresources(dataSource);
    gint numberOfResources = g_list_length(subResources);
    g_list_free(subResources);

    g_assert_cmpint(webkit_web_view_get_load_status(view), ==, WEBKIT_LOAD_FINISHED);

    webkit_web_view_load_uri(view, "http://gnome.org");

    g_assert_cmpint(webkit_web_view_get_load_status(view), ==, WEBKIT_LOAD_PROVISIONAL);

    webkit_web_view_stop_loading(view);

    g_assert_cmpint(webkit_web_view_get_load_status(view), ==, WEBKIT_LOAD_FAILED);

    subResources = webkit_web_data_source_get_subresources(dataSource);
    g_assert_cmpint(numberOfResources, ==, g_list_length(subResources));
    g_list_free(subResources);

    if (waitTimer)
        g_source_remove(waitTimer);

    waitTimer = 0;

    g_main_loop_unref(loop);
    g_object_unref(view);
}
Ejemplo n.º 11
0
GSList *
domain_get_cookie_domains(WebKitWebView *wv) 
{
    GSList *ret = NULL;
    WebKitWebFrame *frame = webkit_web_view_get_main_frame(wv);
    WebKitWebDataSource *data = webkit_web_frame_get_data_source(frame);
    if (data == NULL)
        return NULL;

    WebKitNetworkRequest *request = webkit_web_data_source_get_request(data);
    if (request == NULL)
        return NULL;

    SoupMessage *msg = webkit_network_request_get_message(request);
    if (msg == NULL)
        return NULL;

    SoupURI *uri = soup_message_get_uri(msg);
    if (uri == NULL)
        return NULL;

    const char *host = soup_uri_get_host(uri);
    char *base_host = g_strconcat(".", host, NULL);
    const char *base_domain = domain_get_base_for_host(base_host);

    char *cur = base_host;
    char *nextdot;

    while (cur != base_domain) 
    {
        nextdot = strchr(cur, '.');
        ret = g_slist_append(ret, nextdot);
        cur = nextdot+1;
        ret = g_slist_append(ret, cur);
    }
    return ret;
}