Chromium Code Reviews| 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..f663572c4612ef2933ec7c156d16bfe84abf2f14 |
| --- /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 WebContents mWebContents; |
|
please use gerrit instead
2017/02/14 18:31:10
final
rwlbuis
2017/02/14 19:26:27
Done.
|
| + |
| + 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 getUrl() { |
| + return nativeGetURL(mNativeRenderFrameHostAndroid); |
| + } |
| + |
| + private static native void nativeDestroyRenderFrameHost(long renderFrameHostAndroid); |
| + |
| + private native String nativeGetURL(long nativeRenderFrameHostAndroid); |
| +} |