OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH |
| 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. |
| 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
| 16 */ |
| 17 |
| 18 package org.adblockplus.libadblockplus.android.webview; |
| 19 |
| 20 import android.util.Log; |
| 21 |
| 22 import org.adblockplus.libadblockplus.android.Utils; |
| 23 |
| 24 import java.lang.reflect.InvocationHandler; |
| 25 import java.lang.reflect.Method; |
| 26 import java.lang.reflect.UndeclaredThrowableException; |
| 27 |
| 28 public class IoThreadClientInvocationHandler implements InvocationHandler |
| 29 { |
| 30 private final String TAG = Utils.getTag(IoThreadClientInvocationHandler.class)
; |
| 31 |
| 32 public static transient Boolean isMainFrame; |
| 33 private Object wrappedObject; |
| 34 |
| 35 public IoThreadClientInvocationHandler(Object wrappedObject) |
| 36 { |
| 37 this.wrappedObject = wrappedObject; |
| 38 } |
| 39 |
| 40 @Override |
| 41 public Object invoke(Object proxy, Method method, Object[] args) throws Throwa
ble |
| 42 { |
| 43 // intercept invocation and store 'isMainFrame' argument |
| 44 if (method.getName().startsWith("shouldInterceptRequest") && args.length ==
2) |
| 45 { |
| 46 String url = (String)args[0]; |
| 47 isMainFrame = (Boolean)args[1]; |
| 48 |
| 49 Log.d(TAG, "isMainFrame=" + isMainFrame + " for " + url); |
| 50 } |
| 51 return method.invoke(wrappedObject, args); |
| 52 } |
| 53 } |
OLD | NEW |