mirror of
https://github.com/shuto-cn/cordova-plugin-inappbrowser.git
synced 2025-02-24 11:03:10 +08:00
Merge pull request #263 from SailingSteve/CB-14013-InAppBrowser-AllowCustomSchemes
CB-14013: (android) Change the InAppBrowser to allow custom schemes for oAuth
This commit is contained in:
commit
50db5c498c
@ -133,6 +133,7 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
private boolean hideUrlBar = false;
|
private boolean hideUrlBar = false;
|
||||||
private boolean showFooter = false;
|
private boolean showFooter = false;
|
||||||
private String footerColor = "";
|
private String footerColor = "";
|
||||||
|
private String[] allowedSchemes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the request and returns PluginResult.
|
* Executes the request and returns PluginResult.
|
||||||
@ -1110,6 +1111,29 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
LOG.e(LOG_TAG, "Error sending sms " + url + ":" + e.toString());
|
LOG.e(LOG_TAG, "Error sending sms " + url + ":" + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Test for whitelisted custom scheme names like mycoolapp:// or twitteroauthresponse:// (Twitter Oauth Response)
|
||||||
|
else if (!url.startsWith("http:") && !url.startsWith("https:") && url.matches("^[a-z]*://.*?$")) {
|
||||||
|
if (allowedSchemes == null) {
|
||||||
|
String allowed = preferences.getString("AllowedSchemes", "");
|
||||||
|
allowedSchemes = allowed.split(",");
|
||||||
|
}
|
||||||
|
if (allowedSchemes != null) {
|
||||||
|
for (String scheme : allowedSchemes) {
|
||||||
|
if (url.startsWith(scheme)) {
|
||||||
|
try {
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
obj.put("type", "customscheme");
|
||||||
|
obj.put("url", url);
|
||||||
|
sendUpdate(obj, true);
|
||||||
|
return true;
|
||||||
|
} catch (JSONException ex) {
|
||||||
|
LOG.e(LOG_TAG, "Custom Scheme URI passed in has caused a JSON error.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1232,4 +1256,4 @@ public class InAppBrowser extends CordovaPlugin {
|
|||||||
super.onReceivedHttpAuthRequest(view, handler, host, realm);
|
super.onReceivedHttpAuthRequest(view, handler, host, realm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -36,7 +36,8 @@
|
|||||||
'loadstart': channel.create('loadstart'),
|
'loadstart': channel.create('loadstart'),
|
||||||
'loadstop': channel.create('loadstop'),
|
'loadstop': channel.create('loadstop'),
|
||||||
'loaderror': channel.create('loaderror'),
|
'loaderror': channel.create('loaderror'),
|
||||||
'exit': channel.create('exit')
|
'exit': channel.create('exit'),
|
||||||
|
'customscheme': channel.create('customscheme')
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user