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

Side by Side 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, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698