forked from github/cordova-android
Delete url-filters logic (in 4.0.x branch only)
This commit is contained in:
parent
05a95c699f
commit
dbb196a17e
@ -30,7 +30,6 @@ import org.xmlpull.v1.XmlPullParserException;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.res.XmlResourceParser;
|
import android.content.res.XmlResourceParser;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
public class ConfigXmlParser {
|
public class ConfigXmlParser {
|
||||||
private static String TAG = "ConfigXmlParser";
|
private static String TAG = "ConfigXmlParser";
|
||||||
@ -75,18 +74,11 @@ public class ConfigXmlParser {
|
|||||||
String service = "", pluginClass = "", paramType = "";
|
String service = "", pluginClass = "", paramType = "";
|
||||||
boolean onload = false;
|
boolean onload = false;
|
||||||
boolean insideFeature = false;
|
boolean insideFeature = false;
|
||||||
ArrayList<String> urlMap = null;
|
|
||||||
|
|
||||||
while (eventType != XmlResourceParser.END_DOCUMENT) {
|
while (eventType != XmlResourceParser.END_DOCUMENT) {
|
||||||
if (eventType == XmlResourceParser.START_TAG) {
|
if (eventType == XmlResourceParser.START_TAG) {
|
||||||
String strNode = xml.getName();
|
String strNode = xml.getName();
|
||||||
if (strNode.equals("url-filter")) {
|
if (strNode.equals("feature")) {
|
||||||
Log.w(TAG, "Plugin " + service + " is using deprecated tag <url-filter>");
|
|
||||||
if (urlMap == null) {
|
|
||||||
urlMap = new ArrayList<String>(2);
|
|
||||||
}
|
|
||||||
urlMap.add(xml.getAttributeValue(null, "value"));
|
|
||||||
} else if (strNode.equals("feature")) {
|
|
||||||
//Check for supported feature sets aka. plugins (Accelerometer, Geolocation, etc)
|
//Check for supported feature sets aka. plugins (Accelerometer, Geolocation, etc)
|
||||||
//Set the bit for reading params
|
//Set the bit for reading params
|
||||||
insideFeature = true;
|
insideFeature = true;
|
||||||
@ -124,13 +116,12 @@ public class ConfigXmlParser {
|
|||||||
{
|
{
|
||||||
String strNode = xml.getName();
|
String strNode = xml.getName();
|
||||||
if (strNode.equals("feature")) {
|
if (strNode.equals("feature")) {
|
||||||
pluginEntries.add(new PluginEntry(service, pluginClass, onload, urlMap));
|
pluginEntries.add(new PluginEntry(service, pluginClass, onload));
|
||||||
|
|
||||||
service = "";
|
service = "";
|
||||||
pluginClass = "";
|
pluginClass = "";
|
||||||
insideFeature = false;
|
insideFeature = false;
|
||||||
onload = false;
|
onload = false;
|
||||||
urlMap = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.apache.cordova;
|
package org.apache.cordova;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.cordova.CordovaWebView;
|
import org.apache.cordova.CordovaWebView;
|
||||||
import org.apache.cordova.CordovaInterface;
|
import org.apache.cordova.CordovaInterface;
|
||||||
import org.apache.cordova.CordovaPlugin;
|
import org.apache.cordova.CordovaPlugin;
|
||||||
@ -52,14 +50,12 @@ public class PluginEntry {
|
|||||||
*/
|
*/
|
||||||
public boolean onload = false;
|
public boolean onload = false;
|
||||||
|
|
||||||
private List<String> urlFilters;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param service The name of the service
|
* @param service The name of the service
|
||||||
* @param plugin The plugin associated with this entry
|
* @param plugin The plugin associated with this entry
|
||||||
*/
|
*/
|
||||||
public PluginEntry(String service, CordovaPlugin plugin) {
|
public PluginEntry(String service, CordovaPlugin plugin) {
|
||||||
this(service, plugin.getClass().getName(), true, null);
|
this(service, plugin.getClass().getName(), true);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,19 +65,9 @@ public class PluginEntry {
|
|||||||
* @param onload Create plugin object when HTML page is loaded
|
* @param onload Create plugin object when HTML page is loaded
|
||||||
*/
|
*/
|
||||||
public PluginEntry(String service, String pluginClass, boolean onload) {
|
public PluginEntry(String service, String pluginClass, boolean onload) {
|
||||||
this(service, pluginClass, onload, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public PluginEntry(String service, String pluginClass, boolean onload, List<String> urlFilters) {
|
|
||||||
this.service = service;
|
this.service = service;
|
||||||
this.pluginClass = pluginClass;
|
this.pluginClass = pluginClass;
|
||||||
this.onload = onload;
|
this.onload = onload;
|
||||||
this.urlFilters = urlFilters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getUrlFilters() {
|
|
||||||
return urlFilters;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,10 +51,6 @@ public class PluginManager {
|
|||||||
private final CordovaInterface ctx;
|
private final CordovaInterface ctx;
|
||||||
private final CordovaWebView app;
|
private final CordovaWebView app;
|
||||||
|
|
||||||
// Stores mapping of Plugin Name -> <url-filter> values.
|
|
||||||
// Using <url-filter> is deprecated.
|
|
||||||
protected HashMap<String, List<String>> urlMap = new HashMap<String, List<String>>();
|
|
||||||
|
|
||||||
private Set<String> pluginIdWhitelist;
|
private Set<String> pluginIdWhitelist;
|
||||||
|
|
||||||
PluginManager(CordovaWebView cordovaWebView, CordovaInterface cordova, List<PluginEntry> pluginEntries) {
|
PluginManager(CordovaWebView cordovaWebView, CordovaInterface cordova, List<PluginEntry> pluginEntries) {
|
||||||
@ -68,7 +64,6 @@ public class PluginManager {
|
|||||||
this.onDestroy();
|
this.onDestroy();
|
||||||
this.clearPluginObjects();
|
this.clearPluginObjects();
|
||||||
entries.clear();
|
entries.clear();
|
||||||
urlMap.clear();
|
|
||||||
for (PluginEntry entry : pluginEntries) {
|
for (PluginEntry entry : pluginEntries) {
|
||||||
addService(entry);
|
addService(entry);
|
||||||
}
|
}
|
||||||
@ -211,10 +206,6 @@ public class PluginManager {
|
|||||||
*/
|
*/
|
||||||
public void addService(PluginEntry entry) {
|
public void addService(PluginEntry entry) {
|
||||||
this.entries.put(entry.service, entry);
|
this.entries.put(entry.service, entry);
|
||||||
List<String> urlFilters = entry.getUrlFilters();
|
|
||||||
if (urlFilters != null) {
|
|
||||||
urlMap.put(entry.service, urlFilters);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -300,14 +291,7 @@ public class PluginManager {
|
|||||||
// that they are loaded before this function is called (either by setting
|
// that they are loaded before this function is called (either by setting
|
||||||
// the onload <param> or by making an exec() call to them)
|
// the onload <param> or by making an exec() call to them)
|
||||||
for (PluginEntry entry : this.entries.values()) {
|
for (PluginEntry entry : this.entries.values()) {
|
||||||
List<String> urlFilters = urlMap.get(entry.service);
|
if (entry.plugin != null) {
|
||||||
if (urlFilters != null) {
|
|
||||||
for (String s : urlFilters) {
|
|
||||||
if (url.startsWith(s)) {
|
|
||||||
return getPlugin(entry.service).onOverrideUrlLoading(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (entry.plugin != null) {
|
|
||||||
if (entry.plugin.onOverrideUrlLoading(url)) {
|
if (entry.plugin.onOverrideUrlLoading(url)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user