Improve WebKit2 extension loading: make the code cleaner and safer. See https://github.com/wxWidgets/wxWidgets/pull/2075