From 3edc7d8e99315b87f7dc2fc9d6adf3b99764aac2 Mon Sep 17 00:00:00 2001 From: jun7 Date: Tue, 22 May 2018 12:02:56 +0900 Subject: [PATCH] Fix sharing system in page --- README.md | 2 +- ephy-uri-tester.c | 29 ++++++++++++++++++----------- wyebrun.c | 15 +++++++++++---- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 049c9f6..4236823 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/ephy-uri-tester.c b/ephy-uri-tester.c index 5c2df69..1d8ac49 100644 --- a/ephy-uri-tester.c +++ b/ephy-uri-tester.c @@ -927,10 +927,19 @@ ephy_uri_tester_load (EphyUriTester *tester) #include 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( diff --git a/wyebrun.c b/wyebrun.c index 633048d..780b4b7 100644 --- a/wyebrun.c +++ b/wyebrun.c @@ -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)); - 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));