@capgo/inappbrowser 7.10.11 → 7.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -24,6 +24,8 @@ import android.print.PrintAttributes;
|
|
|
24
24
|
import android.print.PrintDocumentAdapter;
|
|
25
25
|
import android.print.PrintManager;
|
|
26
26
|
import android.provider.MediaStore;
|
|
27
|
+
import android.security.KeyChain;
|
|
28
|
+
import android.security.KeyChainAliasCallback;
|
|
27
29
|
import android.text.TextUtils;
|
|
28
30
|
import android.util.Base64;
|
|
29
31
|
import android.util.Log;
|
|
@@ -65,6 +67,8 @@ import java.io.InputStream;
|
|
|
65
67
|
import java.net.URI;
|
|
66
68
|
import java.net.URISyntaxException;
|
|
67
69
|
import java.nio.charset.StandardCharsets;
|
|
70
|
+
import java.security.PrivateKey;
|
|
71
|
+
import java.security.cert.X509Certificate;
|
|
68
72
|
import java.util.Arrays;
|
|
69
73
|
import java.util.HashMap;
|
|
70
74
|
import java.util.Iterator;
|
|
@@ -186,19 +190,7 @@ public class WebViewDialog extends Dialog {
|
|
|
186
190
|
|
|
187
191
|
activity.runOnUiThread(() -> {
|
|
188
192
|
try {
|
|
189
|
-
String currentUrl =
|
|
190
|
-
if (_webView != null) {
|
|
191
|
-
try {
|
|
192
|
-
currentUrl = _webView.getUrl();
|
|
193
|
-
if (currentUrl == null) {
|
|
194
|
-
currentUrl = "";
|
|
195
|
-
}
|
|
196
|
-
} catch (Exception e) {
|
|
197
|
-
Log.e("InAppBrowser", "Error getting URL: " + e.getMessage());
|
|
198
|
-
currentUrl = "";
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
|
|
193
|
+
String currentUrl = getUrl();
|
|
202
194
|
dismiss();
|
|
203
195
|
|
|
204
196
|
if (_options != null && _options.getCallbacks() != null) {
|
|
@@ -444,11 +436,7 @@ public class WebViewDialog extends Dialog {
|
|
|
444
436
|
// DEBUG: Log details about the file chooser request
|
|
445
437
|
Log.d("InAppBrowser", "onShowFileChooser called");
|
|
446
438
|
Log.d("InAppBrowser", "Accept type: " + acceptType);
|
|
447
|
-
Log.d(
|
|
448
|
-
"InAppBrowser",
|
|
449
|
-
"Current URL: " +
|
|
450
|
-
(webView.getUrl() != null ? webView.getUrl() : "null")
|
|
451
|
-
);
|
|
439
|
+
Log.d("InAppBrowser", "Current URL: " + getUrl());
|
|
452
440
|
Log.d(
|
|
453
441
|
"InAppBrowser",
|
|
454
442
|
"Original URL: " +
|
|
@@ -477,7 +465,7 @@ public class WebViewDialog extends Dialog {
|
|
|
477
465
|
// Direct check for capture attribute in URL (fallback method)
|
|
478
466
|
boolean isCaptureInUrl;
|
|
479
467
|
String captureMode;
|
|
480
|
-
String currentUrl =
|
|
468
|
+
String currentUrl = getUrl();
|
|
481
469
|
|
|
482
470
|
// Look for capture in URL parameters - sometimes the attribute shows up in URL
|
|
483
471
|
if (currentUrl != null && currentUrl.contains("capture=")) {
|
|
@@ -1467,7 +1455,7 @@ public class WebViewDialog extends Dialog {
|
|
|
1467
1455
|
_webView.stopLoading();
|
|
1468
1456
|
|
|
1469
1457
|
// Check if there's a URL to reload
|
|
1470
|
-
String currentUrl =
|
|
1458
|
+
String currentUrl = getUrl();
|
|
1471
1459
|
if (currentUrl != null && !currentUrl.equals("about:blank")) {
|
|
1472
1460
|
// Reload the current page
|
|
1473
1461
|
_webView.reload();
|
|
@@ -1491,7 +1479,16 @@ public class WebViewDialog extends Dialog {
|
|
|
1491
1479
|
}
|
|
1492
1480
|
|
|
1493
1481
|
public String getUrl() {
|
|
1494
|
-
|
|
1482
|
+
try {
|
|
1483
|
+
WebView webView = _webView;
|
|
1484
|
+
if (webView != null) {
|
|
1485
|
+
String url = webView.getUrl();
|
|
1486
|
+
return url != null ? url : "";
|
|
1487
|
+
}
|
|
1488
|
+
} catch (Exception e) {
|
|
1489
|
+
Log.w("InAppBrowser", "Error getting URL: " + e.getMessage());
|
|
1490
|
+
}
|
|
1491
|
+
return "";
|
|
1495
1492
|
}
|
|
1496
1493
|
|
|
1497
1494
|
public void executeScript(String script) {
|
|
@@ -1633,9 +1630,7 @@ public class WebViewDialog extends Dialog {
|
|
|
1633
1630
|
new OnClickListener() {
|
|
1634
1631
|
public void onClick(DialogInterface dialog, int which) {
|
|
1635
1632
|
// Close button clicked, do something
|
|
1636
|
-
String currentUrl =
|
|
1637
|
-
? _webView.getUrl()
|
|
1638
|
-
: "";
|
|
1633
|
+
String currentUrl = getUrl();
|
|
1639
1634
|
dismiss();
|
|
1640
1635
|
if (_options != null && _options.getCallbacks() != null) {
|
|
1641
1636
|
_options.getCallbacks().closeEvent(currentUrl);
|
|
@@ -1646,7 +1641,7 @@ public class WebViewDialog extends Dialog {
|
|
|
1646
1641
|
.setNegativeButton(_options.getCloseModalCancel(), null)
|
|
1647
1642
|
.show();
|
|
1648
1643
|
} else {
|
|
1649
|
-
String currentUrl =
|
|
1644
|
+
String currentUrl = getUrl();
|
|
1650
1645
|
dismiss();
|
|
1651
1646
|
if (_options != null && _options.getCallbacks() != null) {
|
|
1652
1647
|
_options.getCallbacks().closeEvent(currentUrl);
|
|
@@ -1676,7 +1671,7 @@ public class WebViewDialog extends Dialog {
|
|
|
1676
1671
|
_webView.stopLoading();
|
|
1677
1672
|
|
|
1678
1673
|
// Check if there's a URL to reload
|
|
1679
|
-
String currentUrl =
|
|
1674
|
+
String currentUrl = getUrl();
|
|
1680
1675
|
if (currentUrl != null) {
|
|
1681
1676
|
// Reload the current page
|
|
1682
1677
|
_webView.reload();
|
|
@@ -2158,6 +2153,109 @@ public class WebViewDialog extends Dialog {
|
|
|
2158
2153
|
return false;
|
|
2159
2154
|
}
|
|
2160
2155
|
|
|
2156
|
+
@Override
|
|
2157
|
+
public void onReceivedClientCertRequest(
|
|
2158
|
+
WebView view,
|
|
2159
|
+
android.webkit.ClientCertRequest request
|
|
2160
|
+
) {
|
|
2161
|
+
Log.i("InAppBrowser", "onReceivedClientCertRequest CALLED");
|
|
2162
|
+
|
|
2163
|
+
if (request == null) {
|
|
2164
|
+
Log.e("InAppBrowser", "ClientCertRequest is null");
|
|
2165
|
+
return;
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
if (activity == null) {
|
|
2169
|
+
Log.e("InAppBrowser", "Activity is null, canceling request");
|
|
2170
|
+
try {
|
|
2171
|
+
request.cancel();
|
|
2172
|
+
} catch (Exception e) {
|
|
2173
|
+
Log.e(
|
|
2174
|
+
"InAppBrowser",
|
|
2175
|
+
"Error canceling request: " + e.getMessage()
|
|
2176
|
+
);
|
|
2177
|
+
}
|
|
2178
|
+
return;
|
|
2179
|
+
}
|
|
2180
|
+
|
|
2181
|
+
try {
|
|
2182
|
+
Log.i("InAppBrowser", "Host: " + request.getHost());
|
|
2183
|
+
Log.i("InAppBrowser", "Port: " + request.getPort());
|
|
2184
|
+
Log.i(
|
|
2185
|
+
"InAppBrowser",
|
|
2186
|
+
"Principals: " +
|
|
2187
|
+
java.util.Arrays.toString(request.getPrincipals())
|
|
2188
|
+
);
|
|
2189
|
+
Log.i(
|
|
2190
|
+
"InAppBrowser",
|
|
2191
|
+
"KeyTypes: " + java.util.Arrays.toString(request.getKeyTypes())
|
|
2192
|
+
);
|
|
2193
|
+
|
|
2194
|
+
KeyChain.choosePrivateKeyAlias(
|
|
2195
|
+
activity,
|
|
2196
|
+
new KeyChainAliasCallback() {
|
|
2197
|
+
@Override
|
|
2198
|
+
public void alias(String alias) {
|
|
2199
|
+
if (alias != null) {
|
|
2200
|
+
try {
|
|
2201
|
+
PrivateKey privateKey = KeyChain.getPrivateKey(
|
|
2202
|
+
activity,
|
|
2203
|
+
alias
|
|
2204
|
+
);
|
|
2205
|
+
X509Certificate[] certChain =
|
|
2206
|
+
KeyChain.getCertificateChain(activity, alias);
|
|
2207
|
+
request.proceed(privateKey, certChain);
|
|
2208
|
+
Log.i("InAppBrowser", "Selected certificate: " + alias);
|
|
2209
|
+
} catch (Exception e) {
|
|
2210
|
+
try {
|
|
2211
|
+
request.cancel();
|
|
2212
|
+
} catch (Exception cancelEx) {
|
|
2213
|
+
Log.e(
|
|
2214
|
+
"InAppBrowser",
|
|
2215
|
+
"Error canceling request: " + cancelEx.getMessage()
|
|
2216
|
+
);
|
|
2217
|
+
}
|
|
2218
|
+
Log.e(
|
|
2219
|
+
"InAppBrowser",
|
|
2220
|
+
"Error selecting certificate: " + e.getMessage()
|
|
2221
|
+
);
|
|
2222
|
+
}
|
|
2223
|
+
} else {
|
|
2224
|
+
try {
|
|
2225
|
+
request.cancel();
|
|
2226
|
+
} catch (Exception e) {
|
|
2227
|
+
Log.e(
|
|
2228
|
+
"InAppBrowser",
|
|
2229
|
+
"Error canceling request: " + e.getMessage()
|
|
2230
|
+
);
|
|
2231
|
+
}
|
|
2232
|
+
Log.i("InAppBrowser", "No certificate found");
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
},
|
|
2236
|
+
null, // keyTypes
|
|
2237
|
+
null, // issuers
|
|
2238
|
+
request.getHost(),
|
|
2239
|
+
request.getPort(),
|
|
2240
|
+
null // alias (null = system asks user to choose)
|
|
2241
|
+
);
|
|
2242
|
+
} catch (Exception e) {
|
|
2243
|
+
Log.e(
|
|
2244
|
+
"InAppBrowser",
|
|
2245
|
+
"Error in onReceivedClientCertRequest: " + e.getMessage()
|
|
2246
|
+
);
|
|
2247
|
+
try {
|
|
2248
|
+
request.cancel();
|
|
2249
|
+
} catch (Exception cancelEx) {
|
|
2250
|
+
Log.e(
|
|
2251
|
+
"InAppBrowser",
|
|
2252
|
+
"Error canceling request after exception: " +
|
|
2253
|
+
cancelEx.getMessage()
|
|
2254
|
+
);
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
|
|
2161
2259
|
private String randomRequestId() {
|
|
2162
2260
|
return UUID.randomUUID().toString();
|
|
2163
2261
|
}
|
|
@@ -2572,7 +2670,7 @@ public class WebViewDialog extends Dialog {
|
|
|
2572
2670
|
) {
|
|
2573
2671
|
_webView.goBack();
|
|
2574
2672
|
} else if (!_options.getDisableGoBackOnNativeApplication()) {
|
|
2575
|
-
String currentUrl =
|
|
2673
|
+
String currentUrl = getUrl();
|
|
2576
2674
|
_options.getCallbacks().closeEvent(currentUrl);
|
|
2577
2675
|
if (_webView != null) {
|
|
2578
2676
|
_webView.destroy();
|