CB-4788: Modified the onJsPrompt to warn against Cordova calls
This commit is contained in:
parent
1ce5dca61a
commit
de4fd41f8e
@ -95,21 +95,30 @@ public class InAppChromeClient extends WebChromeClient {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
|
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
|
||||||
// See if the prompt string uses the 'gap-iab' protocol. If so, the remainder should be the id of a callback to execute.
|
// See if the prompt string uses the 'gap-iab' protocol. If so, the remainder should be the id of a callback to execute.
|
||||||
if (defaultValue != null && defaultValue.startsWith("gap-iab://")) {
|
if (defaultValue != null && defaultValue.startsWith("gap")) {
|
||||||
PluginResult scriptResult;
|
if(defaultValue.startsWith("gap-iab://")) {
|
||||||
String scriptCallbackId = defaultValue.substring(10);
|
PluginResult scriptResult;
|
||||||
if (scriptCallbackId.startsWith("InAppBrowser")) {
|
String scriptCallbackId = defaultValue.substring(10);
|
||||||
if(message == null || message.length() == 0) {
|
if (scriptCallbackId.startsWith("InAppBrowser")) {
|
||||||
scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray());
|
if(message == null || message.length() == 0) {
|
||||||
} else {
|
scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray());
|
||||||
try {
|
} else {
|
||||||
scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray(message));
|
try {
|
||||||
} catch(JSONException e) {
|
scriptResult = new PluginResult(PluginResult.Status.OK, new JSONArray(message));
|
||||||
scriptResult = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
|
} catch(JSONException e) {
|
||||||
|
scriptResult = new PluginResult(PluginResult.Status.JSON_EXCEPTION, e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
this.webView.sendPluginResult(scriptResult, scriptCallbackId);
|
||||||
|
result.confirm("");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
this.webView.sendPluginResult(scriptResult, scriptCallbackId);
|
}
|
||||||
result.confirm("");
|
else
|
||||||
|
{
|
||||||
|
// Anything else with a gap: prefix should get this message
|
||||||
|
LOG.w(LOG_TAG, "InAppBrowser does not support Cordova API calls: " + url + " " + defaultValue);
|
||||||
|
result.cancel();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user