Fix sharing system in page

This commit is contained in:
jun7 2018-05-22 12:02:56 +09:00
parent 4feef09576
commit 3edc7d8e99
3 changed files with 30 additions and 16 deletions

View File

@ -34,7 +34,7 @@ webkit_web_context_set_web_extensions_initialization_user_data;
Runtime:
g_object_set_data(G_OBJECT(webkitwebpage), "adblock", GINT_TO_POINTER('n'));
g_object_set_data(G_OBJECT(webkitwebpage), "wyebab", GINT_TO_POINTER('n'));
in any extension.

View File

@ -927,10 +927,19 @@ ephy_uri_tester_load (EphyUriTester *tester)
#include <webkit2/webkit-web-extension.h>
static bool first = true;
static bool check(const char *requri, const char *pageuri)
{
char *uris = g_strconcat(requri, " ", pageuri, NULL);
char *ruri = wyebreq(EXE, uris);
g_free(uris);
if (ruri && !*ruri) return false;
return true;
}
static gboolean reqcb(WebKitWebPage *page, WebKitURIRequest *req,
WebKitURIResponse *r, gpointer p)
{
if (g_object_get_data(G_OBJECT(page), "adblock") == (gpointer)'n')
if (g_object_get_data(G_OBJECT(page), "wyebab") == (gpointer)'n')
return false;
const char *requri = webkit_uri_request_get_uri(req);
@ -944,23 +953,21 @@ static gboolean reqcb(WebKitWebPage *page, WebKitURIRequest *req,
return false;
}
char *uris = g_strconcat(requri, " ", pageuri, NULL);
char *ruri = wyebreq(EXE, uris);
g_free(uris);
if (check(requri, pageuri)) return false;
if (!ruri) return false; //wyebab failed
if (!*ruri) return true;
if (g_strcmp0(requri, ruri))
webkit_uri_request_set_uri(req, ruri);
return false;
void (*rf)(gpointer p, const char *) =
g_object_get_data(G_OBJECT(page), "blockedreport");
if (rf)
rf(g_object_get_data(G_OBJECT(page), "blockedreportto"), requri);
return true;
}
static void pageinit(WebKitWebExtension *ex, WebKitWebPage *wp)
{
DD(pageinit)
g_signal_connect(wp, "send-request", G_CALLBACK(reqcb), NULL);
g_object_set_data(G_OBJECT(wp), "wyebabcheck", check);
}
G_MODULE_EXPORT void webkit_web_extension_initialize_with_user_data(

View File

@ -415,18 +415,25 @@ static gboolean tcinputcb(GIOChannel *ch, GIOCondition c, char *exe)
exit(0);
#if DEBUG
if (!strcmp(line, "l"))
if (g_str_has_prefix(line, "l"))
{
start = g_get_monotonic_time();
for (int i = 0; i < 10000; i++)
for (int i = 0; i < 1000; i++)
{
char *is = g_strdup_printf("l%d", i);
//g_print("loop %d ret %s\n", i, wyebreq(exe, is));
if (*(line + 1) == 's')
wyebsend(exe, is);
else if (*(line + 1) == 'p')
D(pint %s, is)
else
wyebreq(exe, is);
g_free(is);
}
gint64 now = g_get_monotonic_time();
D(time %f, (now - start) / 1000000.0)
char *time = g_strdup_printf("time %f", (now - start) / 1000000.0);
wyebsend(exe, time);
g_free(time);
}
else
g_print("RET is %s\n", wyebreq(exe, line));