| Index: chrome/android/java/src/org/chromium/chrome/browser/ContentViewDelegate.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ContentViewDelegate.java b/chrome/android/java/src/org/chromium/chrome/browser/ContentViewDelegate.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d7fc0130d16a2713948057857d1649df664d02ea
|
| --- /dev/null
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ContentViewDelegate.java
|
| @@ -0,0 +1,42 @@
|
| +// 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.chrome.browser;
|
| +
|
| +import org.chromium.base.CalledByNative;
|
| +
|
| +import java.util.concurrent.atomic.AtomicReference;
|
| +
|
| +/**
|
| + * Delegate that lets the chrome/ layer talk to the ContentView embedder.
|
| + */
|
| +public class ContentViewDelegate {
|
| + public interface ContentViewDelegateImpl {
|
| + boolean shouldOverrideUrlLoading(String url);
|
| + }
|
| + private AtomicReference<ContentViewDelegateImpl> mImpl =
|
| + new AtomicReference<ContentViewDelegateImpl>();
|
| +
|
| + public ContentViewDelegate(int nativeWebContents, ContentViewDelegateImpl impl) {
|
| + mImpl.set(impl);
|
| + nativeInit(nativeWebContents);
|
| + }
|
| +
|
| + @CalledByNative
|
| + private boolean shouldOverrideUrlLoading(String url) {
|
| + ContentViewDelegateImpl impl = mImpl.get();
|
| + if (impl == null) {
|
| + return false;
|
| + } else {
|
| + return impl.shouldOverrideUrlLoading(url);
|
| + }
|
| + }
|
| +
|
| + @CalledByNative
|
| + private void onWebContentsDestroyed() {
|
| + mImpl.set(null);
|
| + }
|
| +
|
| + private native void nativeInit(int webContents);
|
| +}
|
|
|