示例#1
0
wxString wxWebViewWebKit::GetPageSource() const
{
    WebKitWebResource *resource = webkit_web_view_get_main_resource(m_web_view);
    if (!resource)
    {
        return wxString();
    }

    GAsyncResult *result = NULL;
    webkit_web_resource_get_data(resource, NULL,
                                 (GAsyncReadyCallback)wxgtk_web_resource_get_data_cb,
                                 &result);

    GMainContext *main_context = g_main_context_get_thread_default();
    while (!result)
    {
        g_main_context_iteration(main_context, TRUE);
    }

    guchar *source = webkit_web_resource_get_data_finish(resource, result,
                                                         NULL, NULL);
    if (result)
    {
        g_object_unref(result);
    }

    if (source)
    {
        wxString wxs = wxString(source, wxConvUTF8);
        free(source);
        return wxs;
    }
    return wxString();
}
示例#2
0
    void checkResourceData(WebKitWebResource* resource)
    {
        m_resourceDataSize = 0;
        webkit_web_resource_get_data(resource, 0, resourceGetDataCallback, this);
        g_main_loop_run(m_mainLoop);

        const char* uri = webkit_web_resource_get_uri(resource);
        if (uri == kServer->getURIForPath("/")) {
            g_assert_cmpint(m_resourceDataSize, ==, strlen(kIndexHtml));
            g_assert(!strncmp(m_resourceData.get(), kIndexHtml, m_resourceDataSize));
        } else if (uri == kServer->getURIForPath("/style.css")) {
示例#3
0
const char* WebViewTest::mainResourceData(size_t& mainResourceDataSize)
{
    m_resourceDataSize = 0;
    m_resourceData.clear();
    WebKitWebResource* resource = webkit_web_view_get_main_resource(m_webView);
    g_assert(resource);

    webkit_web_resource_get_data(resource, 0, resourceGetDataCallback, this);
    g_main_loop_run(m_mainLoop);

    mainResourceDataSize = m_resourceDataSize;
    return m_resourceData.get();
}
示例#4
0
文件: normal.c 项目: fanglingsu/vimb
static VbResult normal_view_source(Client *c, const NormalCmdInfo *info)
{
    WebKitWebResource *resource;

    if ((resource = webkit_web_view_get_main_resource(c->webview)) == NULL) {
        return RESULT_ERROR;
    }

    webkit_web_resource_get_data(resource, NULL,
            (GAsyncReadyCallback)normal_view_source_loaded, c);

    return RESULT_COMPLETE;
}
示例#5
0
static VALUE
WebResource_data(VALUE self)
{
  VALUE __p_retval = Qnil;
  WebKitWebResource *_self = ((WebKitWebResource*)RVAL2GOBJ(self));

#line 182 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"

  do {
  GString * data  =
 webkit_web_resource_get_data(_self);
  do { __p_retval = rb_str_new(data->str, data->len); goto out; } while(0);

  } while(0);

out:
  return __p_retval;
}
示例#6
0
文件: urlsnap.c 项目: epitron/scripts
static void load_changed(WebKitWebView *web_view, WebKitLoadEvent load_event, gpointer user_data) {
    if (load_event != WEBKIT_LOAD_FINISHED) {
        return;
    }

    if (mhtml_file != NULL) {
        GFile *f = g_file_new_for_path(mhtml_file);
        webkit_web_view_save_to_file(web_view, f, WEBKIT_SAVE_MODE_MHTML, NULL, mhtml_finished, NULL);
    }

    if (html_file != NULL) {
        WebKitWebResource *wr = webkit_web_view_get_main_resource(web_view);
        webkit_web_resource_get_data(wr, NULL, html_finished, NULL);
    }

    if (png_file != NULL) {
        webkit_web_view_get_snapshot(
            web_view,
            WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT,
            WEBKIT_SNAPSHOT_OPTIONS_NONE,
            NULL,
            png_finished,
            NULL
        );
    }

    if (title_file != NULL) {
        const gchar *title = webkit_web_view_get_title(web_view);
        GString *s = g_string_new(title);
        g_string_append_c(s, '\n');
        FILE *f = open_file(title_file, "w");
        if (fwrite(s->str, s->len, 1, f) != 1) {
            errx(1, "error saving title");
        }
        fclose(f);
        done();
    }
}
示例#7
0
static VALUE
WebResource_data_equals(VALUE self, VALUE data)
{
  VALUE __p_retval = data;
  WebKitWebResource *_self = ((WebKitWebResource*)RVAL2GOBJ(self));
  Check_Type(data, T_STRING);

#line 186 "/home/geoff/Projects/gtk-webkit-ruby/ext/webkit/webkit.cr"

  do {
  GString * odata  =
 webkit_web_resource_get_data(_self);
  g_free(odata->str);
  odata->str = g_malloc(RSTRING_LEN(data)+1);
  odata->len = odata->allocated_len = RSTRING_LEN(data);
  memcpy(RSTRING_PTR(data), odata->str, RSTRING_LEN(data));
  do { __p_retval = data; goto out; } while(0);

  } while(0);

out:
  return __p_retval;
}
static void test_webkit_web_resource_get_data(WebResourceFixture* fixture, gconstpointer data)
{
    GString* charData = webkit_web_resource_get_data(fixture->webResource);
    g_assert_cmpstr(charData->str, ==, "<html></html>");
}