Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(908)

Unified Diff: android_webview/java/src/org/chromium/android_webview/AwWebContentsIoThreadDelegate.java

Issue 10702083: Add ContentViewDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rewritten for the new android_webview folder Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: android_webview/java/src/org/chromium/android_webview/AwWebContentsIoThreadDelegate.java
diff --git a/android_webview/java/src/org/chromium/android_webview/AwWebContentsIoThreadDelegate.java b/android_webview/java/src/org/chromium/android_webview/AwWebContentsIoThreadDelegate.java
new file mode 100644
index 0000000000000000000000000000000000000000..6e1ee14d23c5753ec68e0fafcd78b0d5f9d307bb
--- /dev/null
+++ b/android_webview/java/src/org/chromium/android_webview/AwWebContentsIoThreadDelegate.java
@@ -0,0 +1,47 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.android_webview;
+
+import org.chromium.base.CalledByNative;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+/**
+ * Delegate for URLRequest intercepting.
+ *
+ * The shouldInterceptRequest method will be called on the IO thread.
+ * You should create a separate instance of this class for every WebContents that requires the
+ * provided functionality.
+ */
+public class AwContentsIoThreadDelegate {
+ public interface AwContentsIoThreadDelegateImpl {
+ InterceptedRequestData shouldInterceptRequest(String url);
+ }
+ private AtomicReference<AwContentsIoThreadDelegateImpl> mImpl =
+ new AtomicReference<AwContentsIoThreadDelegateImpl>();
+
+ public ContentViewIoThreadDelegate(int nativeWebContents,
+ AwContentsIoThreadDelegateImpl impl) {
+ mImpl.set(impl);
+ nativeInit(nativeWebContents);
+ }
+
+ @CalledByNative
+ private InterceptedRequestData shouldInterceptRequest(String url) {
+ AwContentsIoThreadDelegateImpl impl = mImpl.get();
+ if (impl == null) {
+ return null;
+ } else {
+ return impl.shouldInterceptRequest(url);
+ }
+ }
+
+ @CalledByNative
+ private void onWebContentsDestroyed() {
+ mImpl.set(null);
+ }
+
+ private native void nativeInit(int webContents);
+}

Powered by Google App Engine
This is Rietveld 408576698