| Index: content/public/android/java/src/org/chromium/content/browser/framehost/RenderFrameHostImpl.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/framehost/RenderFrameHostImpl.java b/content/public/android/java/src/org/chromium/content/browser/framehost/RenderFrameHostImpl.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..a4abedc3d373cddd49ab8a105d1dd3849df11d0a
|
| --- /dev/null
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/framehost/RenderFrameHostImpl.java
|
| @@ -0,0 +1,68 @@
|
| +// Copyright 2017 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.content.browser.framehost;
|
| +
|
| +import org.chromium.base.ThreadUtils;
|
| +import org.chromium.base.annotations.CalledByNative;
|
| +import org.chromium.base.annotations.JNINamespace;
|
| +import org.chromium.content_public.browser.RenderFrameHost;
|
| +import org.chromium.content_public.browser.WebContents;
|
| +
|
| +/**
|
| + * The RenderFrameHostImpl Java wrapper to allow communicating with the native RenderFrameHost
|
| + * object.
|
| + */
|
| +@JNINamespace("content")
|
| +// TODO(tedchoc): Remove the package restriction once this class moves to a non-public content
|
| +// package whose visibility will be enforced via DEPS.
|
| +/* package */ class RenderFrameHostImpl implements RenderFrameHost {
|
| + private long mNativeRenderFrameHostAndroid;
|
| + private final WebContents mWebContents;
|
| +
|
| + private RenderFrameHostImpl(long nativeRenderFrameHostAndroid, WebContents webContents) {
|
| + mNativeRenderFrameHostAndroid = nativeRenderFrameHostAndroid;
|
| + mWebContents = webContents;
|
| + }
|
| +
|
| + @CalledByNative
|
| + private static RenderFrameHostImpl create(
|
| + long nativeRenderFrameHostAndroid, WebContents webContents) {
|
| + return new RenderFrameHostImpl(nativeRenderFrameHostAndroid, webContents);
|
| + }
|
| +
|
| + @CalledByNative
|
| + private void clearNativePtr() {
|
| + mNativeRenderFrameHostAndroid = 0;
|
| + }
|
| +
|
| + @Override
|
| + public void destroy() {
|
| + if (!ThreadUtils.runningOnUiThread()) {
|
| + throw new IllegalStateException("Attempting to destroy WebContents on non-UI thread");
|
| + }
|
| + if (mNativeRenderFrameHostAndroid != 0) {
|
| + nativeDestroyRenderFrameHost(mNativeRenderFrameHostAndroid);
|
| + }
|
| + }
|
| +
|
| + @Override
|
| + public boolean isDestroyed() {
|
| + return mNativeRenderFrameHostAndroid == 0;
|
| + }
|
| +
|
| + @Override
|
| + public WebContents getWebContents() {
|
| + return mWebContents;
|
| + }
|
| +
|
| + @Override
|
| + public String getLastCommittedURL() {
|
| + return nativeGetLastCommittedURL(mNativeRenderFrameHostAndroid);
|
| + }
|
| +
|
| + private static native void nativeDestroyRenderFrameHost(long renderFrameHostAndroid);
|
| +
|
| + private native String nativeGetLastCommittedURL(long nativeRenderFrameHostAndroid);
|
| +}
|
|
|