White list support. Pull request https://github.com/phonegap/phonegap-android/pull/211 from imhotep would not merge, so combined it with enhancements for this commit.

This commit is contained in:
Bryce Curtis
2011-09-26 10:58:41 -05:00
parent bb777c096c
commit 80df4a8fb2
4 changed files with 119 additions and 2 deletions

View File

@@ -54,6 +54,9 @@ public class App extends Plugin {
else if (action.equals("exitApp")) {
this.exitApp();
}
else if (action.equals("addWhiteListEntry")) {
this.addWhiteListEntry(args.getString(0), args.optBoolean(1));
}
return new PluginResult(status, result);
} catch (JSONException e) {
return new PluginResult(PluginResult.Status.JSON_EXCEPTION);
@@ -172,4 +175,13 @@ public class App extends Plugin {
((DroidGap)this.ctx).finish();
}
/**
* Add entry to approved list of URLs (whitelist)
*
* @param origin URL regular expression to allow
* @param subdomains T=include all subdomains under origin
*/
public void addWhiteListEntry(String origin, boolean subdomains) {
((DroidGap)this.ctx).addWhiteListEntry(origin, subdomains);
}
}