Commit Graph

47 Commits

Author SHA1 Message Date
Tobias Taschner
c9606d7b5a Implement AddUserScript() for GTK 2021-02-27 10:59:23 +01:00
Tobias Taschner
71f745e647 Implement script message for GTK backend 2021-02-26 21:27:50 +01:00
Tobias Taschner
3af4702b11 Implement wxWebView::EnableAccessToDevTools() for GTK 2021-02-26 18:53:46 +01:00
Joao Matos
152970a52a Fix missing event objects in WebViewGTK events. 2021-02-23 10:04:50 -08:00
Tobias Taschner
a3f85e9cd5 Implement wxEVT_WEBVIEW_FULLSCREEN_CHANGED in GTK 2021-02-09 22:28:29 +01:00
Tobias Taschner
d17e8978a6 Make wxWebView::RunScript() const 2021-02-05 22:18:31 +01:00
Tobias Taschner
b351e7762d Move common wxWebView code to base class
Removes duplicate code in the various webview backends
2021-02-05 22:18:29 +01:00
Tobias Taschner
0d82348328 Add wxWebView::GetBackendVersionInfo()
Allows to get the WebView backend version if available
Currently implemented for IE, Edge and webkit2.
2021-02-05 22:18:28 +01:00
Paul Cornett
b5a554b9a6 Avoid -Wdouble-promotion warnings 2020-10-14 11:07:55 -07:00
Václav Slavík
8756ff4320 Don't load webkit extensions from CWD-relative paths
wxgtk_initialize_web_extensions() tries to find extensions in the
location where "make install" puts them. If that fails, either because
wx wasn't installed yet, or it was deployed (e.g. in static build)
without them, it looks into additional places - paths relative to CWD.
This is to faciliate running wx samples and tests, but by being enabled
in release builds too, it allowed loading unexpected executable code
from untrusted locations. For example, on typical desktops, one could
put malicious .so files into $HOME/lib to have them loaded by
wxWebView-using applications.

Address this by making the helper paths relative to the executable's
location, not working directory.
2020-10-08 19:41:30 +02:00
Václav Slavík
b355e00149 Only warn about missing WebKit extension when used
Don't log failure to load the extension during initialization, because
it isn't needed for many uses of wxWebView. Instead, only report the
failure at the time when functionality depending on it is used.

Also use g_warning() for logging consistently with other failures in
this file. This doesn't interrupt the user, yet shows the problem highly
visibly in the console.
2020-10-08 19:32:49 +02:00
Václav Slavík
40e5152cfc Remove WX_WEB_EXTENSIONS_DIRECTORY define
wxWidgets already has a mechanism for locating plugins under
$libdir/wx/*, there's no reason to duplicate it with another
compile-time symbol.

As a consequence, this makes the library relocatable via WXPREFIX again.
2020-10-05 16:54:16 +02:00
Hertatijanto Hartono
895424ecc0 Add wxWebView::SetZoomFactor(float) and GetZoomFactor()
The new method allows to set the zoom level more precisely than the
existing SetZoom(wxWebViewZoom).

Also improve the webview sample by using radio menu items instead of
check items and manually resetting them.

Closes https://github.com/wxWidgets/wxWidgets/pull/1894

Closes #18769.
2020-06-18 03:13:00 +02:00
Maarten Bent
97f64e9941 CMake: Build the webextensions plugin 2018-12-02 03:23:02 +01:00
Vadim Zeitlin
e5a1a29e77 Fix wxGTK build with glib < 2.32 and streamline the code a bit
Define g_signal_handlers_disconnect_by_data() if it's not available,
i.e. when using glib older than 2.32 where it was added, to fix the
build under old systems such as CentOS 6 broken by the changes of
8278f7b618 (see #18084).

Also use it elsewhere instead of g_signal_handlers_disconnect_matched()
as it's more readable.

Closes https://github.com/wxWidgets/wxWidgets/pull/760
2018-03-11 22:22:45 +01:00
Scott Talbert
1f2173b9be Fix custom scheme handling in wxWebView WebKit2 implementation
The custom scheme handling implementation had been inherited from the
original WebKit1 implementation.  It attempted to intercept navigation
and resource load requests and then inject the resources.  It seems that
this method doesn't work in WebKit2, but fortunately, there is native
support in WebKit2 for custom URI schemes through the
webkit_web_context_register_uri_scheme() API.

Also extend wxGtkError to allow creating it from an existing GError
object as a side-effect of these changes.

See https://github.com/wxWidgets/wxWidgets/pull/716
2018-02-05 14:04:41 +01:00
Vadim Zeitlin
7872e8f7ef Allow using web extension from tests and sample
Check for web extension in ".." and "../.." to find it when running the
webview test and sample, respectively, even if "make install" hadn't
been done yet.

Also give a warning about the missing extension if we can't find it
anywhere.
2017-11-04 16:07:53 +01:00
Vadim Zeitlin
7e0b6d4d81 Merge branch 'webview-js-retval'
Integrate GSoC 2017 work by Jose Lorenzo on allowing returning values
from JavaScript code via wxWebView::RunScript().
2017-11-04 16:07:51 +01:00
Paul Cornett
0cb55df404 Remove test code accidently committed in 44b30c1a60 2017-10-27 10:10:18 -07:00
Paul Cornett
44b30c1a60 Avoid use of GDBusServer object after it is destroyed 2017-10-27 10:05:43 -07:00
Vadim Zeitlin
b22e361245 Restore explicit conversion to UTF-8 in wxGTK wxWebView code
This was somehow removed by af8f7f33c3 but
is needed: implicit conversion uses the current locale encoding, which
is often, but _not_ always, UTF-8, while we always need to use UTF-8
with WebKit functions.
2017-10-22 23:37:44 +02:00
Vadim Zeitlin
9d6bd9a52d Fix webkit_web_view_run_javascript() callback signature
Don't use wrong types and then cast the function pointer to the right
type, but just use the correct type from the beginning.

Also make the callback extern "C", as it should be, to be called from C
code.
2017-10-22 23:37:36 +02:00
Vadim Zeitlin
1bb8cd860a Improve and harmonize error reporting in RunScript()
Errors were reported in different ways (including not being reported at
all in wxMSW) in different ports. Try to consistently do it in the same
way now and use exactly the same sentences to facilitate translators
life.
2017-10-22 23:37:32 +02:00
Vadim Zeitlin
70c8979223 Add wxCHECK_MSG() to wxGTK RunScript() implementation too
Don't crash if RunScript() is called on a not yet created object.

This is also consistent with the macOS version of the code.
2017-10-22 23:37:14 +02:00
Vadim Zeitlin
ee9615b9ac Consistently capitalize "JavaScript"
This is the proper name of the language, not "Javascript".
2017-10-22 00:26:33 +02:00
Vadim Zeitlin
ec54ddb66b No real changes, just reformat the code a little
Put long function calls on multiple lines.
2017-10-22 00:26:33 +02:00
Vadim Zeitlin
9d9f692024 Get rid of nonsensical "&*" construct in RunScriptSync()
Just pass JS result object directly to the WebKit function, there is
really no need to dereference it and then take its address for this.
2017-10-22 00:26:32 +02:00
Vadim Zeitlin
0e2f6e5c52 Fix memory leak in wxGTK RunScriptSync()
We must call g_object_unref() on an object that we called g_object_ref()
before.
2017-10-22 00:26:32 +02:00
Vadim Zeitlin
55beb9f7e8 Get rid of unnecessary casts in RunScriptSync()
No real changes, just simplify the code.
2017-10-22 00:26:32 +02:00
Vadim Zeitlin
4476bd646d Get rid of separate JSResultToString() function
This function was used only once and didn't really help understanding
the code and just required extra casts when passing arguments to it, for
some reason.

Just merge it into RunScriptSync() itself.
2017-10-22 00:26:30 +02:00
Vadim Zeitlin
b309487ef6 Rename RunScriptInternal() to RunScriptSync() in wxGTK
This helper function runs a JavaScript script and blocks until it
finishes executing, so try to use a name at least hinting at this
instead of being totally generic and useless.
2017-10-22 00:25:57 +02:00
Jose Lorenzo
af8f7f33c3 Merge wxWebView JavaScript improvements branch
This is a squashed commit of the SOC2017_WEBVIEW_JS branch from
https://github.com/joseeloren/wxWidgets.git

Closes https://github.com/wxWidgets/wxWidgets/pull/538
2017-10-21 22:42:30 +02:00
Vadim Zeitlin
a43e25c3d6 Fix wxWebViewWebKit build with WebKit2 < 2.8
This allows this code to be compiled with WebKit2 2.6 included in Debian
Jessie.

Closes https://github.com/wxWidgets/wxWidgets/pull/519
2017-07-19 15:58:09 +02:00
Paul Cornett
59acf5ac27 Use correct signature for callback 2017-06-18 13:56:06 -07:00
Paul Cornett
74bde5690c Use reported size for page source string
Avoids a warning from Valgrind about reading uninitialized byte in strlen.
The string does not seem to be nul-terminated.
2017-06-18 13:48:41 -07:00
Paul Cornett
1d3ed51eab Fix indentation, remove trailing whitespace
no real changes
2017-06-15 10:39:06 -07:00
Paul Cornett
820149121b Make local function static 2017-06-15 10:32:57 -07:00
Paul Cornett
fcd2401af7 Simplify flags casting 2017-06-15 10:31:31 -07:00
Paul Cornett
a1fde23d88 Simplify conversion from bool
there is no need to explicitly convert to int
2017-06-15 10:26:31 -07:00
Paul Cornett
47dc046b1e Simplify zoom conversion code
so there is no need to "shut up compilers"
2017-06-15 10:21:54 -07:00
Paul Cornett
4e55fca038 Use explicit conversion to bool 2017-06-15 09:50:26 -07:00
Paul Cornett
e03fd314fd Use correct signature for callback 2017-06-15 09:27:19 -07:00
Paul Cornett
b4a6f39ab2 Use HandleWindowEvent() from C callbacks
Avoids issues with exceptions. Also remove worthless null pointer checks, the
pointer has already been dereferenced, and GetEventHandler() never returns NULL
2017-06-15 09:22:37 -07:00
Paul Cornett
188b249467 Avoid reading uninitialized member variable
m_historyLimit is unused with webkit2
2017-06-15 09:04:05 -07:00
Paul Cornett
b9c9fc3534 Initialize member variables during construction
avoids uninitialized memory accesses later on
2017-06-15 08:57:05 -07:00
Scott Talbert
69e4f491b2 Move wx/gtk/webview_webkit2_extension.h to private directory
Make it more clear that this header is private, i.e. used only by the library
itself.

Close https://github.com/wxWidgets/wxWidgets/pull/473
2017-05-04 18:23:00 +02:00
Scott Talbert
cbe0a1f049 Add support for WebKit2GTK+ in wxWebView 2017-04-22 20:00:48 +01:00