@@ -2,16 +2,37 @@ diff --git a/node_modules/@metamask/react-native-webview/android/src/main/java/c
22index 3f9aa9c998..62acefe282 100644
33--- a/node_modules/@metamask/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
44+++ b/node_modules/@metamask/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebView.java
5- @@ -26,0 +27 @@ import androidx.webkit.JavaScriptReplyProxy;
5+ @@ -24,6 +24,7 @@ import android.webkit.WebViewClient;
6+ import androidx.annotation.NonNull;
7+ import androidx.annotation.Nullable;
8+ import androidx.webkit.JavaScriptReplyProxy;
69+ import androidx.webkit.ScriptHandler;
7- @@ -61,0 +63 @@ public class RNCWebView extends WebView implements LifecycleEventListener {
10+ import androidx.webkit.WebMessageCompat;
11+ import androidx.webkit.WebViewCompat;
12+ import androidx.webkit.WebViewFeature;
13+ @@ -59,6 +60,7 @@ import java.util.Set;
14+ public class RNCWebView extends WebView implements LifecycleEventListener {
15+ protected @Nullable String injectedJS;
16+ protected @Nullable String injectedJSBeforeContentLoaded;
817+ protected @Nullable ScriptHandler injectedJSBeforeContentLoadedScriptHandler;
9- @@ -371,0 +374,4 @@ public class RNCWebView extends WebView implements LifecycleEventListener {
18+ protected static final String JAVASCRIPT_INTERFACE = "ReactNativeWebView";
19+ protected @Nullable RNCWebViewBridge fallbackBridge;
20+ protected @Nullable WebViewCompat.WebMessageListener bridgeListener = null;
21+ @@ -369,6 +371,10 @@ public class RNCWebView extends WebView implements LifecycleEventListener {
22+ }
23+
24+ public void callInjectedJavaScriptBeforeContentLoaded() {
1025+ if (isDocumentStartJavaScriptSupported()) {
1126+ return;
1227+ }
1328+
14- @@ -379,0 +386,39 @@ public class RNCWebView extends WebView implements LifecycleEventListener {
29+ if (getSettings().getJavaScriptEnabled() &&
30+ injectedJSBeforeContentLoaded != null &&
31+ !TextUtils.isEmpty(injectedJSBeforeContentLoaded)) {
32+ @@ -377,6 +383,45 @@ public class RNCWebView extends WebView implements LifecycleEventListener {
33+ }
34+ }
35+
1536+ public boolean isDocumentStartJavaScriptSupported() {
1637+ return WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT);
1738+ }
@@ -51,18 +72,51 @@ index 3f9aa9c998..62acefe282 100644
5172+ "})();";
5273+ }
5374+
54- @@ -473,0 +519 @@ public class RNCWebView extends WebView implements LifecycleEventListener {
75+ protected String injectedJavaScriptObject = null;
76+
77+ public void setInjectedJavaScriptObject(String obj) {
78+ @@ -471,6 +516,7 @@ public class RNCWebView extends WebView implements LifecycleEventListener {
79+ }
80+
81+ protected void cleanupCallbacksAndDestroy() {
5582+ removeDocumentStartJavaScript();
83+ setWebViewClient(null);
84+ destroy();
85+ }
5686diff --git a/node_modules/@metamask/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt b/node_modules/@metamask/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt
5787index b19f456155..3dfb567f17 100644
5888--- a/node_modules/@metamask/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt
5989+++ b/node_modules/@metamask/react-native-webview/android/src/main/java/com/reactnativecommunity/webview/RNCWebViewManagerImpl.kt
60- @@ -325,0 +326,2 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) {
90+ @@ -323,6 +323,8 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) {
91+ }
92+
93+ fun onAfterUpdateTransaction(viewWrapper: RNCWebViewWrapper) {
6194+ viewWrapper.webView.resetDocumentStartJavaScript()
6295+
63- @@ -551,0 +554 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) {
96+ mPendingSource?.let { source ->
97+ loadSource(viewWrapper, source)
98+ }
99+ @@ -549,6 +551,7 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) {
100+ fun setInjectedJavaScriptBeforeContentLoaded(viewWrapper: RNCWebViewWrapper, value: String?) {
101+ val view = viewWrapper.webView
102+ view.injectedJSBeforeContentLoaded = value
64103+ view.resetDocumentStartJavaScript()
65- @@ -561,0 +565 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) {
104+ }
105+
106+ fun setInjectedJavaScriptForMainFrameOnly(viewWrapper: RNCWebViewWrapper, value: Boolean) {
107+ @@ -559,6 +562,7 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) {
108+ fun setInjectedJavaScriptBeforeContentLoadedForMainFrameOnly(viewWrapper: RNCWebViewWrapper, value: Boolean) {
109+ val view = viewWrapper.webView
110+ view.injectedJavaScriptBeforeContentLoadedForMainFrameOnly = value
66111+ view.resetDocumentStartJavaScript()
67- @@ -601,0 +606 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) {
112+ }
113+
114+ fun setInjectedJavaScriptObject(viewWrapper: RNCWebViewWrapper, value: String?) {
115+ @@ -599,6 +603,7 @@ class RNCWebViewManagerImpl(private val newArch: Boolean = false) {
116+ fun setJavaScriptEnabled(viewWrapper: RNCWebViewWrapper, enabled: Boolean) {
117+ val view = viewWrapper.webView
118+ view.settings.javaScriptEnabled = enabled
68119+ view.resetDocumentStartJavaScript()
120+ }
121+
122+ fun setAllowFileAccess(viewWrapper: RNCWebViewWrapper, allowFileAccess: Boolean) {
0 commit comments