capacitor icon indicating copy to clipboard operation
capacitor copied to clipboard

feat(android): Allow overriding web chrome client

Open SimonBackx opened this issue 3 years ago • 1 comments

Currently it is not possible to override the WebChromeClient of the Bridge. With this change, it becomes possible to override the web chrome client in plugins (the same way this currently is possible for the web view client).

SimonBackx avatar Jan 06 '22 10:01 SimonBackx

Any update on this? This would help me implement some changes on WebChromeClient via our own plugins. Let me know if you have questions! :) Thanks!

SimonBackx avatar Jan 12 '22 21:01 SimonBackx

Thanks for the pull request, but it has always been possible to override the WebChromeClient by calling bridge.getWebView().setWebChromeClient() from the MainActivity.java's onCreate method or from a plugin's handleOnStart() as the WebView has the setters for the WebViewClient and WebChromeClient.

For WebViewClient we added the setWebViewClient helper in the bridge as we wanted people to keep using a BridgeWebViewClient since it's essential for Capacitor's inner working, but the BridgeWebChromeClient is not essential and users overriding the WebChromeClient are free to use a WebChromeClient subclass or a BridgeWebChromeClient subclass if they want to take advantage of the methods we already implement and just change some others or implement new ones.

jcesarmobile avatar Jan 24 '24 14:01 jcesarmobile