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.android; |
| 19 |
| 20 import android.util.Log; |
| 21 |
| 22 import java.lang.reflect.InvocationHandler; |
| 23 import java.lang.reflect.Method; |
| 24 |
| 25 public class IoThreadClientInvocationHandler implements InvocationHandler |
| 26 { |
| 27 private final String TAG = Utils.getTag(IoThreadClientInvocationHandler.class)
; |
| 28 |
| 29 public static transient Boolean isMainFrame; |
| 30 private Object wrappedObject; |
| 31 |
| 32 public IoThreadClientInvocationHandler(Object wrappedObject) |
| 33 { |
| 34 this.wrappedObject = wrappedObject; |
| 35 } |
| 36 |
| 37 @Override |
| 38 public Object invoke(Object proxy, Method method, Object[] args) throws Throwa
ble |
| 39 { |
| 40 // intercept invocation and store 'isMainFrame' argument |
| 41 if (method.getName().startsWith("shouldInterceptRequest") && args.length ==
2) |
| 42 { |
| 43 String url = (String)args[0]; |
| 44 isMainFrame = (Boolean)args[1]; |
| 45 |
| 46 Log.d(TAG, "isMainFrame=" + isMainFrame + " for " + url); |
| 47 } |
| 48 return method.invoke(wrappedObject, args); |
| 49 } |
| 50 } |
OLD | NEW |