Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/IoThreadClientInvocationHandler.java

Issue 29351744: Issue 4399 - Add WebView inheritor with ad blocking (Closed)
Patch Set: changed packages, now using AdblockEngine (original ABPEngine), improved demo app Created Oct. 25, 2016, 11:20 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/IoThreadClientInvocationHandler.java
diff --git a/libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/IoThreadClientInvocationHandler.java b/libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/IoThreadClientInvocationHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..9079b742dfa6ca9e3d967f3e2431899b0400ed9d
--- /dev/null
+++ b/libadblockplus-android-webview/src/org/adblockplus/libadblockplus/android/webview/IoThreadClientInvocationHandler.java
@@ -0,0 +1,53 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-2016 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package org.adblockplus.libadblockplus.android.webview;
+
+import android.util.Log;
+
+import org.adblockplus.libadblockplus.android.Utils;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.UndeclaredThrowableException;
+
+public class IoThreadClientInvocationHandler implements InvocationHandler
+{
+ private final String TAG = Utils.getTag(IoThreadClientInvocationHandler.class);
+
+ public static transient Boolean isMainFrame;
+ private Object wrappedObject;
+
+ public IoThreadClientInvocationHandler(Object wrappedObject)
+ {
+ this.wrappedObject = wrappedObject;
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ // intercept invocation and store 'isMainFrame' argument
+ if (method.getName().startsWith("shouldInterceptRequest") && args.length == 2)
+ {
+ String url = (String)args[0];
+ isMainFrame = (Boolean)args[1];
+
+ Log.d(TAG, "isMainFrame=" + isMainFrame + " for " + url);
+ }
+ return method.invoke(wrappedObject, args);
+ }
+}

Powered by Google App Engine
This is Rietveld