adding isUrlWhiteListed in shouldOverrideUrlLoading

This commit is contained in:
Anis Kadri 2011-08-29 17:35:11 -07:00
parent f111ea56ed
commit 97faebda41

View File

@ -903,19 +903,8 @@ public class DroidGap extends PhonegapActivity {
// Security check to make sure any requests are coming from the page initially // Security check to make sure any requests are coming from the page initially
// loaded in webview and not another loaded in an iframe. // loaded in webview and not another loaded in an iframe.
boolean reqOk = false; boolean reqOk = false;
// looking for url in whitelist
boolean isUrlWhiteListed = false;
Iterator<Pattern> pit = whiteList.iterator();
while(pit.hasNext()) {
Pattern p = pit.next();
Matcher m = p.matcher(url);
if(m.find()) {
isUrlWhiteListed = true;
break;
}
}
if (url.indexOf(this.ctx.baseUrl) == 0 || isUrlWhiteListed) { if (url.indexOf(this.ctx.baseUrl) == 0 || isUrlWhiteListed(url)) {
reqOk = true; reqOk = true;
} }
@ -1173,7 +1162,7 @@ public class DroidGap extends PhonegapActivity {
// If our app or file:, then load into our webview // If our app or file:, then load into our webview
// NOTE: This replaces our app with new URL. When BACK is pressed, // NOTE: This replaces our app with new URL. When BACK is pressed,
// our app is reloaded and restarted. All state is lost. // our app is reloaded and restarted. All state is lost.
if (this.ctx.loadInWebView || url.startsWith("file://") || url.indexOf(this.ctx.baseUrl) == 0) { if (this.ctx.loadInWebView || url.startsWith("file://") || url.indexOf(this.ctx.baseUrl) == 0 || isUrlWhiteListed(url)) {
try { try {
// Init parameters to new DroidGap activity and propagate existing parameters // Init parameters to new DroidGap activity and propagate existing parameters
HashMap<String, Object> params = new HashMap<String, Object>(); HashMap<String, Object> params = new HashMap<String, Object>();
@ -1596,4 +1585,17 @@ public class DroidGap extends PhonegapActivity {
} }
} }
private boolean isUrlWhiteListed(String url) {
Iterator<Pattern> pit = whiteList.iterator();
while(pit.hasNext()) {
Pattern p = pit.next();
Matcher m = p.matcher(url);
if(m.find()) {
return true;
}
}
return false;
}
} }