}
try {
// get old web progress listener instance and dispose
Field f_Mozilla_webProgressListener = mozClass.getDeclaredField("webProgressListener");
f_Mozilla_webProgressListener.setAccessible(true);
final XPCOMObject oldWebProgressListener =
(XPCOMObject) f_Mozilla_webProgressListener.get(m_webBrowser);
oldWebProgressListener.dispose();
// get methods which needed to delegate to
final Method m_Mozilla_QueryInterface =
mozClass.getDeclaredMethod("QueryInterface", new Class[]{long.class, long.class});
final Method m_Mozilla_AddRef = mozClass.getDeclaredMethod("AddRef", new Class[0]);
final Method m_Mozilla_Release = mozClass.getDeclaredMethod("Release", new Class[0]);
final Method m_Mozilla_OnLocationChange;
final Method[] m_Mozilla_OnStateChange = new Method[1];
final Method[] m_Mozilla_OnProgressChange = new Method[1];
final Method[] m_Mozilla_OnStatusChange = new Method[1];
final Method[] m_Mozilla_OnSecurityChange = new Method[1];
try {
// eclipse 3.3
m_Mozilla_OnStateChange[0] =
mozClass.getDeclaredMethod("OnStateChange", new Class[]{
long.class,
long.class,
long.class,
long.class});
} catch (NoSuchMethodException nsme) {
// eclipse 3.4
m_Mozilla_OnStateChange[0] =
mozClass.getDeclaredMethod("OnStateChange", new Class[]{
long.class,
long.class,
int.class,
int.class});
}
try {
m_Mozilla_OnProgressChange[0] =
mozClass.getDeclaredMethod("OnProgressChange", new Class[]{
long.class,
long.class,
long.class,
long.class,
long.class,
long.class});
} catch (NoSuchMethodException nsme) {
m_Mozilla_OnProgressChange[0] =
mozClass.getDeclaredMethod("OnProgressChange", new Class[]{
long.class,
long.class,
int.class,
int.class,
int.class,
int.class});
}
m_Mozilla_OnLocationChange =
mozClass.getDeclaredMethod("OnLocationChange", new Class[]{
long.class,
long.class,
long.class});
try {
m_Mozilla_OnStatusChange[0] =
mozClass.getDeclaredMethod("OnStatusChange", new Class[]{
long.class,
long.class,
long.class,
long.class});
} catch (NoSuchMethodException nsme) {
m_Mozilla_OnStatusChange[0] =
mozClass.getDeclaredMethod("OnStatusChange", new Class[]{
long.class,
long.class,
int.class,
long.class});
}
try {
m_Mozilla_OnSecurityChange[0] =
mozClass.getDeclaredMethod("OnSecurityChange", new Class[]{
long.class,
long.class,
long.class});
} catch (NoSuchMethodException nsme) {
m_Mozilla_OnSecurityChange[0] =
mozClass.getDeclaredMethod("OnSecurityChange", new Class[]{
long.class,
long.class,
int.class});
}
// get them accessible
m_Mozilla_QueryInterface.setAccessible(true);
m_Mozilla_AddRef.setAccessible(true);
m_Mozilla_Release.setAccessible(true);
m_Mozilla_OnLocationChange.setAccessible(true);
m_Mozilla_OnStateChange[0].setAccessible(true);
m_Mozilla_OnProgressChange[0].setAccessible(true);
m_Mozilla_OnStatusChange[0].setAccessible(true);
m_Mozilla_OnSecurityChange[0].setAccessible(true);
// create own web progress listener instance
XPCOMObject webProgressListener = new XPCOMObject(new int[]{2, 0, 0, 4, 6, 3, 4, 3}) {
private Object[] prepareArgs(Method method, long[] args) {
Class<?>[] parameterTypes = method.getParameterTypes();
int count = parameterTypes.length;
Object[] result = new Object[count];
for (int i = 0; i < count; ++i) {