| 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);
|
| +}
|
|
|