| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.android_webview; |
| 6 |
| 7 import org.chromium.base.CalledByNative; |
| 8 |
| 9 import java.util.concurrent.atomic.AtomicReference; |
| 10 |
| 11 /** |
| 12 * Delegate for URLRequest intercepting. |
| 13 * |
| 14 * The shouldInterceptRequest method will be called on the IO thread. |
| 15 * You should create a separate instance of this class for every WebContents tha
t requires the |
| 16 * provided functionality. |
| 17 */ |
| 18 public class AwContentsIoThreadDelegate { |
| 19 public interface AwContentsIoThreadDelegateImpl { |
| 20 InterceptedRequestData shouldInterceptRequest(String url); |
| 21 } |
| 22 private AtomicReference<AwContentsIoThreadDelegateImpl> mImpl = |
| 23 new AtomicReference<AwContentsIoThreadDelegateImpl>(); |
| 24 |
| 25 public ContentViewIoThreadDelegate(int nativeWebContents, |
| 26 AwContentsIoThreadDelegateImpl impl) { |
| 27 mImpl.set(impl); |
| 28 nativeInit(nativeWebContents); |
| 29 } |
| 30 |
| 31 @CalledByNative |
| 32 private InterceptedRequestData shouldInterceptRequest(String url) { |
| 33 AwContentsIoThreadDelegateImpl impl = mImpl.get(); |
| 34 if (impl == null) { |
| 35 return null; |
| 36 } else { |
| 37 return impl.shouldInterceptRequest(url); |
| 38 } |
| 39 } |
| 40 |
| 41 @CalledByNative |
| 42 private void onWebContentsDestroyed() { |
| 43 mImpl.set(null); |
| 44 } |
| 45 |
| 46 private native void nativeInit(int webContents); |
| 47 } |
| OLD | NEW |