[gnome-online-accounts/wip/rishi/webkit-port-to-jscvalue] webview: Port to JSCValue
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/rishi/webkit-port-to-jscvalue] webview: Port to JSCValue
- Date: Thu, 5 Dec 2019 15:35:41 +0000 (UTC)
commit 3060510f854000f3f693ac1e9028483748819669
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Dec 4 19:05:49 2019 +0100
webview: Port to JSCValue
configure.ac | 4 ++++
meson.build | 1 +
src/goabackend/Makefile.am | 2 ++
src/goabackend/goawebview.c | 26 ++++++++------------------
src/goabackend/meson.build | 1 +
5 files changed, 16 insertions(+), 18 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index ebabb5a4..71392e81 100644
--- a/configure.ac
+++ b/configure.ac
@@ -115,6 +115,10 @@ if test "$enable_backend" != "no"; then
AC_SUBST(GTK_CFLAGS)
AC_SUBST(GTK_LIBS)
+ PKG_CHECK_MODULES(JAVASCRIPT_CORE_GTK, [javascriptcoregtk-4.0 >= 2.12.0])
+ AC_SUBST(JAVASCRIPT_CORE_GTK_CFLAGS)
+ AC_SUBST(JAVASCRIPT_CORE_GTK_LIBS)
+
PKG_CHECK_MODULES(WEBKIT_GTK, [webkit2gtk-4.0 >= 2.12.0])
AC_SUBST(WEBKIT_GTK_CFLAGS)
AC_SUBST(WEBKIT_GTK_LIBS)
diff --git a/meson.build b/meson.build
index 23976cc6..ce4b22f2 100644
--- a/meson.build
+++ b/meson.build
@@ -102,6 +102,7 @@ endif
enable_goabackend = get_option('goabackend')
if enable_goabackend
gtk_dep = dependency('gtk+-3.0', version: '>= 3.19.12')
+ javascript_core_gtk_dep = dependency('javascriptcoregtk-4.0', version: '>= 2.12.0')
json_glib_dep = dependency('json-glib-1.0')
libsecret_dep = dependency('libsecret-1')
libsoup_dep = dependency('libsoup-2.4', version: '>= 2.42')
diff --git a/src/goabackend/Makefile.am b/src/goabackend/Makefile.am
index 18b1e5d7..b13534fe 100644
--- a/src/goabackend/Makefile.am
+++ b/src/goabackend/Makefile.am
@@ -113,6 +113,7 @@ libgoa_backend_1_0_la_SOURCES += \
endif
libgoa_backend_1_0_la_CFLAGS = \
+ $(JAVASCRIPT_CORE_GTK_CFLAGS) \
$(WEBKIT_GTK_CFLAGS) \
$(JSON_GLIB_CFLAGS) \
$(GCR_CFLAGS) \
@@ -128,6 +129,7 @@ libgoa_backend_1_0_la_CFLAGS = \
libgoa_backend_1_0_la_LIBADD = \
$(top_builddir)/src/goa/libgoa-1.0.la \
+ $(JAVASCRIPT_CORE_GTK_LIBS) \
$(WEBKIT_GTK_LIBS) \
$(JSON_GLIB_LIBS) \
$(GCR_LIBS) \
diff --git a/src/goabackend/goawebview.c b/src/goabackend/goawebview.c
index 5ff57809..09394f4f 100644
--- a/src/goabackend/goawebview.c
+++ b/src/goabackend/goawebview.c
@@ -25,6 +25,7 @@
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <JavaScriptCore/JavaScript.h>
+#include <jsc/jsc.h>
#include <libsoup/soup.h>
#include <webkit2/webkit2.h>
@@ -244,26 +245,15 @@ web_view_script_message_received_deny_click_cb (GoaWebView *self)
static void
web_view_script_message_received_password_submit_cb (GoaWebView *self, WebKitJavascriptResult *js_result)
{
- JSGlobalContextRef js_context;
- JSStringRef js_string;
- JSValueRef js_value;
- gsize max_size;
-
- js_value = webkit_javascript_result_get_value (js_result);
- js_context = webkit_javascript_result_get_global_context (js_result);
- js_string = JSValueToStringCopy (js_context, js_value, NULL);
- max_size = JSStringGetMaximumUTF8CStringSize (js_string);
- if (max_size > 0)
- {
- gchar *password;
+ JSCValue *jsc_value;
+ gchar *password = NULL;
- password = g_malloc0 (max_size);
- JSStringGetUTF8CString (js_string, password, max_size);
- g_signal_emit (self, signals[PASSWORD_SUBMIT], 0, password);
- g_free (password);
- }
+ jsc_value = webkit_javascript_result_get_js_value (js_result);
+ password = jsc_value_to_string (jsc_value);
+ if (password != NULL && password[0] != '\0')
+ g_signal_emit (self, signals[PASSWORD_SUBMIT], 0, password);
- JSStringRelease (js_string);
+ g_free (password);
}
static void
diff --git a/src/goabackend/meson.build b/src/goabackend/meson.build
index 11912ce0..8654fb4a 100644
--- a/src/goabackend/meson.build
+++ b/src/goabackend/meson.build
@@ -78,6 +78,7 @@ incs = common_incs
deps = [
gtk_dep,
+ javascript_core_gtk_dep,
json_glib_dep,
libgoa_dep,
libsecret_dep,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]