Commit 26a51202 authored by Eric Stevenson's avatar Eric Stevenson Committed by Commit Bot

JNI refactor: @NativeMethods conversion (//weblayer).

This CL was generated by
//base/android/jni_generator/jni_refactorer.py.

Bug: 929661
Change-Id: Iad5d2c2c4d2c5a7ae1ed8cf6a844abf8b8946374
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1808592
Commit-Queue: Eric Stevenson <estevenson@chromium.org>
Auto-Submit: Eric Stevenson <estevenson@chromium.org>
Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697612}
parent 4ea728b8
...@@ -22,9 +22,11 @@ android_library("java") { ...@@ -22,9 +22,11 @@ android_library("java") {
deps = [ deps = [
":client_java", ":client_java",
"//base:base_java", "//base:base_java",
"//base:jni_java",
"//content/public/android:content_java", "//content/public/android:content_java",
"//ui/android:ui_java", "//ui/android:ui_java",
] ]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
} }
generate_jni("jni") { generate_jni("jni") {
......
...@@ -15,6 +15,7 @@ import android.view.ViewGroup.LayoutParams; ...@@ -15,6 +15,7 @@ import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.content_public.browser.ViewEventSink; import org.chromium.content_public.browser.ViewEventSink;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.base.ActivityWindowAndroid; import org.chromium.ui.base.ActivityWindowAndroid;
...@@ -78,8 +79,10 @@ public final class BrowserControllerImpl extends IBrowserController.Stub { ...@@ -78,8 +79,10 @@ public final class BrowserControllerImpl extends IBrowserController.Stub {
mContentViewRenderView.onNativeLibraryLoaded( mContentViewRenderView.onNativeLibraryLoaded(
mWindowAndroid, ContentViewRenderView.MODE_SURFACE_VIEW); mWindowAndroid, ContentViewRenderView.MODE_SURFACE_VIEW);
mNativeBrowserController = nativeCreateBrowserController(profile.getNativeProfile()); mNativeBrowserController =
mWebContents = nativeGetWebContents(mNativeBrowserController); BrowserControllerImplJni.get().createBrowserController(profile.getNativeProfile());
mWebContents = BrowserControllerImplJni.get().getWebContents(
mNativeBrowserController, BrowserControllerImpl.this);
mTopControlsContainerView = mTopControlsContainerView =
new TopControlsContainerView(context, mWebContents, mContentViewRenderView); new TopControlsContainerView(context, mWebContents, mContentViewRenderView);
mContentView = ContentView.createContentView( mContentView = ContentView.createContentView(
...@@ -100,8 +103,8 @@ public final class BrowserControllerImpl extends IBrowserController.Stub { ...@@ -100,8 +103,8 @@ public final class BrowserControllerImpl extends IBrowserController.Stub {
new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
FrameLayout.LayoutParams.UNSPECIFIED_GRAVITY)); FrameLayout.LayoutParams.UNSPECIFIED_GRAVITY));
nativeSetTopControlsContainerView( BrowserControllerImplJni.get().setTopControlsContainerView(mNativeBrowserController,
mNativeBrowserController, mTopControlsContainerView.getNativeHandle()); BrowserControllerImpl.this, mTopControlsContainerView.getNativeHandle());
mContentView.addView(mTopControlsContainerView, mContentView.addView(mTopControlsContainerView,
new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT,
Gravity.FILL_HORIZONTAL | Gravity.TOP)); Gravity.FILL_HORIZONTAL | Gravity.TOP));
...@@ -129,13 +132,14 @@ public final class BrowserControllerImpl extends IBrowserController.Stub { ...@@ -129,13 +132,14 @@ public final class BrowserControllerImpl extends IBrowserController.Stub {
@Override @Override
public void destroy() { public void destroy() {
nativeSetTopControlsContainerView(mNativeBrowserController, 0); BrowserControllerImplJni.get().setTopControlsContainerView(
mNativeBrowserController, BrowserControllerImpl.this, 0);
mContentViewRenderView.destroy(); mContentViewRenderView.destroy();
mTopControlsContainerView.destroy(); mTopControlsContainerView.destroy();
if (mBrowserObserverProxy != null) mBrowserObserverProxy.destroy(); if (mBrowserObserverProxy != null) mBrowserObserverProxy.destroy();
mBrowserObserverProxy = null; mBrowserObserverProxy = null;
mNavigationController = null; mNavigationController = null;
nativeDeleteBrowserController(mNativeBrowserController); BrowserControllerImplJni.get().deleteBrowserController(mNativeBrowserController);
mNativeBrowserController = 0; mNativeBrowserController = 0;
} }
...@@ -156,9 +160,12 @@ public final class BrowserControllerImpl extends IBrowserController.Stub { ...@@ -156,9 +160,12 @@ public final class BrowserControllerImpl extends IBrowserController.Stub {
: ContentViewRenderView.MODE_SURFACE_VIEW); : ContentViewRenderView.MODE_SURFACE_VIEW);
} }
private static native long nativeCreateBrowserController(long profile); @NativeMethods
private native void nativeSetTopControlsContainerView( interface Natives {
long nativeBrowserControllerImpl, long nativeTopControlsContainerView); long createBrowserController(long profile);
private static native void nativeDeleteBrowserController(long browserController); void setTopControlsContainerView(long nativeBrowserControllerImpl,
private native WebContents nativeGetWebContents(long nativeBrowserControllerImpl); BrowserControllerImpl caller, long nativeTopControlsContainerView);
void deleteBrowserController(long browserController);
WebContents getWebContents(long nativeBrowserControllerImpl, BrowserControllerImpl caller);
}
} }
...@@ -8,6 +8,7 @@ import android.os.RemoteException; ...@@ -8,6 +8,7 @@ import android.os.RemoteException;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.weblayer_private.aidl.APICallException; import org.chromium.weblayer_private.aidl.APICallException;
import org.chromium.weblayer_private.aidl.IBrowserControllerClient; import org.chromium.weblayer_private.aidl.IBrowserControllerClient;
...@@ -23,11 +24,12 @@ public final class BrowserObserverProxy { ...@@ -23,11 +24,12 @@ public final class BrowserObserverProxy {
BrowserObserverProxy(long browserController, IBrowserControllerClient client) { BrowserObserverProxy(long browserController, IBrowserControllerClient client) {
mClient = client; mClient = client;
mNativeBrowserObserverProxy = nativeCreateBrowserObserverProxy(this, browserController); mNativeBrowserObserverProxy =
BrowserObserverProxyJni.get().createBrowserObserverProxy(this, browserController);
} }
public void destroy() { public void destroy() {
nativeDeleteBrowserObserverProxy(mNativeBrowserObserverProxy); BrowserObserverProxyJni.get().deleteBrowserObserverProxy(mNativeBrowserObserverProxy);
mNativeBrowserObserverProxy = 0; mNativeBrowserObserverProxy = 0;
} }
...@@ -40,7 +42,9 @@ public final class BrowserObserverProxy { ...@@ -40,7 +42,9 @@ public final class BrowserObserverProxy {
} }
} }
private static native long nativeCreateBrowserObserverProxy( @NativeMethods
BrowserObserverProxy proxy, long browserController); interface Natives {
private static native void nativeDeleteBrowserObserverProxy(long proxy); long createBrowserObserverProxy(BrowserObserverProxy proxy, long browserController);
void deleteBrowserObserverProxy(long proxy);
}
} }
...@@ -18,6 +18,7 @@ import androidx.annotation.IntDef; ...@@ -18,6 +18,7 @@ import androidx.annotation.IntDef;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.base.WindowAndroid; import org.chromium.ui.base.WindowAndroid;
import org.chromium.ui.resources.ResourceManager; import org.chromium.ui.resources.ResourceManager;
...@@ -86,7 +87,8 @@ public class ContentViewRenderView extends FrameLayout { ...@@ -86,7 +87,8 @@ public class ContentViewRenderView extends FrameLayout {
*/ */
public void onNativeLibraryLoaded(WindowAndroid rootWindow, @Mode int mode) { public void onNativeLibraryLoaded(WindowAndroid rootWindow, @Mode int mode) {
assert rootWindow != null; assert rootWindow != null;
mNativeContentViewRenderView = nativeInit(rootWindow); mNativeContentViewRenderView =
ContentViewRenderViewJni.get().init(ContentViewRenderView.this, rootWindow);
assert mNativeContentViewRenderView != 0; assert mNativeContentViewRenderView != 0;
mWindowAndroid = rootWindow; mWindowAndroid = rootWindow;
requestMode(mode); requestMode(mode);
...@@ -286,7 +288,8 @@ public class ContentViewRenderView extends FrameLayout { ...@@ -286,7 +288,8 @@ public class ContentViewRenderView extends FrameLayout {
uninitializeSurfaceView(); uninitializeSurfaceView();
uninitializeTextureView(); uninitializeTextureView();
mWindowAndroid = null; mWindowAndroid = null;
nativeDestroy(mNativeContentViewRenderView); ContentViewRenderViewJni.get().destroy(
mNativeContentViewRenderView, ContentViewRenderView.this);
mNativeContentViewRenderView = 0; mNativeContentViewRenderView = 0;
} }
...@@ -296,35 +299,41 @@ public class ContentViewRenderView extends FrameLayout { ...@@ -296,35 +299,41 @@ public class ContentViewRenderView extends FrameLayout {
if (webContents != null) { if (webContents != null) {
webContents.setSize(mWidth, mHeight); webContents.setSize(mWidth, mHeight);
nativeOnPhysicalBackingSizeChanged( ContentViewRenderViewJni.get().onPhysicalBackingSizeChanged(
mNativeContentViewRenderView, webContents, mWidth, mHeight); mNativeContentViewRenderView, ContentViewRenderView.this, webContents, mWidth,
mHeight);
} }
nativeSetCurrentWebContents(mNativeContentViewRenderView, webContents); ContentViewRenderViewJni.get().setCurrentWebContents(
mNativeContentViewRenderView, ContentViewRenderView.this, webContents);
} }
public ResourceManager getResourceManager() { public ResourceManager getResourceManager() {
return nativeGetResourceManager(mNativeContentViewRenderView); return ContentViewRenderViewJni.get().getResourceManager(
mNativeContentViewRenderView, ContentViewRenderView.this);
} }
private void surfaceCreated() { private void surfaceCreated() {
assert mNativeContentViewRenderView != 0; assert mNativeContentViewRenderView != 0;
nativeSurfaceCreated(mNativeContentViewRenderView); ContentViewRenderViewJni.get().surfaceCreated(
mNativeContentViewRenderView, ContentViewRenderView.this);
} }
private void surfaceChanged( private void surfaceChanged(
Surface surface, boolean canBeUsedWithSurfaceControl, int width, int height) { Surface surface, boolean canBeUsedWithSurfaceControl, int width, int height) {
assert mNativeContentViewRenderView != 0; assert mNativeContentViewRenderView != 0;
nativeSurfaceChanged( ContentViewRenderViewJni.get().surfaceChanged(mNativeContentViewRenderView,
mNativeContentViewRenderView, canBeUsedWithSurfaceControl, width, height, surface); ContentViewRenderView.this, canBeUsedWithSurfaceControl, width, height, surface);
if (mWebContents != null) { if (mWebContents != null) {
nativeOnPhysicalBackingSizeChanged( ContentViewRenderViewJni.get().onPhysicalBackingSizeChanged(
mNativeContentViewRenderView, mWebContents, width, height); mNativeContentViewRenderView, ContentViewRenderView.this, mWebContents, width,
height);
} }
} }
private void surfaceDestroyed() { private void surfaceDestroyed() {
assert mNativeContentViewRenderView != 0; assert mNativeContentViewRenderView != 0;
nativeSurfaceDestroyed(mNativeContentViewRenderView); ContentViewRenderViewJni.get().surfaceDestroyed(
mNativeContentViewRenderView, ContentViewRenderView.this);
} }
@CalledByNative @CalledByNative
...@@ -343,15 +352,19 @@ public class ContentViewRenderView extends FrameLayout { ...@@ -343,15 +352,19 @@ public class ContentViewRenderView extends FrameLayout {
return mNativeContentViewRenderView; return mNativeContentViewRenderView;
} }
private native long nativeInit(WindowAndroid rootWindow); @NativeMethods
private native void nativeDestroy(long nativeContentViewRenderView); interface Natives {
private native void nativeSetCurrentWebContents( long init(ContentViewRenderView caller, WindowAndroid rootWindow);
long nativeContentViewRenderView, WebContents webContents); void destroy(long nativeContentViewRenderView, ContentViewRenderView caller);
private native void nativeOnPhysicalBackingSizeChanged( void setCurrentWebContents(long nativeContentViewRenderView, ContentViewRenderView caller,
long nativeContentViewRenderView, WebContents webContents, int width, int height); WebContents webContents);
private native void nativeSurfaceCreated(long nativeContentViewRenderView); void onPhysicalBackingSizeChanged(long nativeContentViewRenderView,
private native void nativeSurfaceDestroyed(long nativeContentViewRenderView); ContentViewRenderView caller, WebContents webContents, int width, int height);
private native void nativeSurfaceChanged(long nativeContentViewRenderView, void surfaceCreated(long nativeContentViewRenderView, ContentViewRenderView caller);
boolean canBeUsedWithSurfaceControl, int width, int height, Surface surface); void surfaceDestroyed(long nativeContentViewRenderView, ContentViewRenderView caller);
private native ResourceManager nativeGetResourceManager(long nativeContentViewRenderView); void surfaceChanged(long nativeContentViewRenderView, ContentViewRenderView caller,
boolean canBeUsedWithSurfaceControl, int width, int height, Surface surface);
ResourceManager getResourceManager(
long nativeContentViewRenderView, ContentViewRenderView caller);
}
} }
...@@ -8,6 +8,7 @@ import android.os.RemoteException; ...@@ -8,6 +8,7 @@ import android.os.RemoteException;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.weblayer_private.aidl.APICallException; import org.chromium.weblayer_private.aidl.APICallException;
import org.chromium.weblayer_private.aidl.INavigationController; import org.chromium.weblayer_private.aidl.INavigationController;
import org.chromium.weblayer_private.aidl.INavigationControllerClient; import org.chromium.weblayer_private.aidl.INavigationControllerClient;
...@@ -25,49 +26,58 @@ public final class NavigationControllerImpl extends INavigationController.Stub { ...@@ -25,49 +26,58 @@ public final class NavigationControllerImpl extends INavigationController.Stub {
BrowserControllerImpl browserController, INavigationControllerClient client) { BrowserControllerImpl browserController, INavigationControllerClient client) {
mNavigationControllerClient = client; mNavigationControllerClient = client;
mBrowserController = browserController; mBrowserController = browserController;
mNativeNavigationController = mNativeNavigationController = NavigationControllerImplJni.get().getNavigationController(
nativeGetNavigationController(browserController.getNativeBrowserController()); browserController.getNativeBrowserController());
nativeSetNavigationControllerImpl(mNativeNavigationController); NavigationControllerImplJni.get().setNavigationControllerImpl(
mNativeNavigationController, NavigationControllerImpl.this);
} }
@Override @Override
public void navigate(String uri) { public void navigate(String uri) {
nativeNavigate(mNativeNavigationController, uri); NavigationControllerImplJni.get().navigate(
mNativeNavigationController, NavigationControllerImpl.this, uri);
} }
@Override @Override
public void goBack() { public void goBack() {
nativeGoBack(mNativeNavigationController); NavigationControllerImplJni.get().goBack(
mNativeNavigationController, NavigationControllerImpl.this);
} }
@Override @Override
public void goForward() { public void goForward() {
nativeGoForward(mNativeNavigationController); NavigationControllerImplJni.get().goForward(
mNativeNavigationController, NavigationControllerImpl.this);
} }
@Override @Override
public void reload() { public void reload() {
nativeReload(mNativeNavigationController); NavigationControllerImplJni.get().reload(
mNativeNavigationController, NavigationControllerImpl.this);
} }
@Override @Override
public void stop() { public void stop() {
nativeStop(mNativeNavigationController); NavigationControllerImplJni.get().stop(
mNativeNavigationController, NavigationControllerImpl.this);
} }
@Override @Override
public int getNavigationListSize() { public int getNavigationListSize() {
return nativeGetNavigationListSize(mNativeNavigationController); return NavigationControllerImplJni.get().getNavigationListSize(
mNativeNavigationController, NavigationControllerImpl.this);
} }
@Override @Override
public int getNavigationListCurrentIndex() { public int getNavigationListCurrentIndex() {
return nativeGetNavigationListCurrentIndex(mNativeNavigationController); return NavigationControllerImplJni.get().getNavigationListCurrentIndex(
mNativeNavigationController, NavigationControllerImpl.this);
} }
@Override @Override
public String getNavigationEntryDisplayUri(int index) { public String getNavigationEntryDisplayUri(int index) {
return nativeGetNavigationEntryDisplayUri(mNativeNavigationController, index); return NavigationControllerImplJni.get().getNavigationEntryDisplayUri(
mNativeNavigationController, NavigationControllerImpl.this, index);
} }
@CalledByNative @CalledByNative
...@@ -120,16 +130,22 @@ public final class NavigationControllerImpl extends INavigationController.Stub { ...@@ -120,16 +130,22 @@ public final class NavigationControllerImpl extends INavigationController.Stub {
} }
} }
private native void nativeSetNavigationControllerImpl(long nativeNavigationControllerImpl); @NativeMethods
interface Natives {
private static native long nativeGetNavigationController(long browserController); void setNavigationControllerImpl(
private native void nativeNavigate(long nativeNavigationControllerImpl, String uri); long nativeNavigationControllerImpl, NavigationControllerImpl caller);
private native void nativeGoBack(long nativeNavigationControllerImpl); long getNavigationController(long browserController);
private native void nativeGoForward(long nativeNavigationControllerImpl); void navigate(
private native void nativeReload(long nativeNavigationControllerImpl); long nativeNavigationControllerImpl, NavigationControllerImpl caller, String uri);
private native void nativeStop(long nativeNavigationControllerImpl); void goBack(long nativeNavigationControllerImpl, NavigationControllerImpl caller);
private native int nativeGetNavigationListSize(long nativeNavigationControllerImpl); void goForward(long nativeNavigationControllerImpl, NavigationControllerImpl caller);
private native int nativeGetNavigationListCurrentIndex(long nativeNavigationControllerImpl); void reload(long nativeNavigationControllerImpl, NavigationControllerImpl caller);
private native String nativeGetNavigationEntryDisplayUri( void stop(long nativeNavigationControllerImpl, NavigationControllerImpl caller);
long nativeNavigationControllerImpl, int index); int getNavigationListSize(
long nativeNavigationControllerImpl, NavigationControllerImpl caller);
int getNavigationListCurrentIndex(
long nativeNavigationControllerImpl, NavigationControllerImpl caller);
String getNavigationEntryDisplayUri(
long nativeNavigationControllerImpl, NavigationControllerImpl caller, int index);
}
} }
...@@ -8,6 +8,7 @@ import android.os.RemoteException; ...@@ -8,6 +8,7 @@ import android.os.RemoteException;
import org.chromium.base.annotations.CalledByNative; import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.weblayer_private.aidl.APICallException; import org.chromium.weblayer_private.aidl.APICallException;
import org.chromium.weblayer_private.aidl.IClientNavigation; import org.chromium.weblayer_private.aidl.IClientNavigation;
import org.chromium.weblayer_private.aidl.INavigation; import org.chromium.weblayer_private.aidl.INavigation;
...@@ -28,7 +29,7 @@ public final class NavigationImpl extends INavigation.Stub { ...@@ -28,7 +29,7 @@ public final class NavigationImpl extends INavigation.Stub {
} catch (RemoteException e) { } catch (RemoteException e) {
throw new APICallException(e); throw new APICallException(e);
} }
nativeSetJavaNavigation(mNativeNavigationImpl); NavigationImplJni.get().setJavaNavigation(mNativeNavigationImpl, NavigationImpl.this);
} }
public IClientNavigation getClientNavigation() { public IClientNavigation getClientNavigation() {
...@@ -38,19 +39,19 @@ public final class NavigationImpl extends INavigation.Stub { ...@@ -38,19 +39,19 @@ public final class NavigationImpl extends INavigation.Stub {
@Override @Override
public int getState() { public int getState() {
throwIfNativeDestroyed(); throwIfNativeDestroyed();
return nativeGetState(mNativeNavigationImpl); return NavigationImplJni.get().getState(mNativeNavigationImpl, NavigationImpl.this);
} }
@Override @Override
public String getUri() { public String getUri() {
throwIfNativeDestroyed(); throwIfNativeDestroyed();
return nativeGetUri(mNativeNavigationImpl); return NavigationImplJni.get().getUri(mNativeNavigationImpl, NavigationImpl.this);
} }
@Override @Override
public List<String> getRedirectChain() { public List<String> getRedirectChain() {
throwIfNativeDestroyed(); throwIfNativeDestroyed();
return nativeGetRedirectChain(mNativeNavigationImpl); return NavigationImplJni.get().getRedirectChain(mNativeNavigationImpl, NavigationImpl.this);
} }
private void throwIfNativeDestroyed() { private void throwIfNativeDestroyed() {
...@@ -65,8 +66,11 @@ public final class NavigationImpl extends INavigation.Stub { ...@@ -65,8 +66,11 @@ public final class NavigationImpl extends INavigation.Stub {
// TODO: this should likely notify delegate in some way. // TODO: this should likely notify delegate in some way.
} }
private native void nativeSetJavaNavigation(long nativeNavigationImpl); @NativeMethods
private native int nativeGetState(long nativeNavigationImpl); interface Natives {
private native String nativeGetUri(long nativeNavigationImpl); void setJavaNavigation(long nativeNavigationImpl, NavigationImpl caller);
private native List<String> nativeGetRedirectChain(long nativeNavigationImpl); int getState(long nativeNavigationImpl, NavigationImpl caller);
String getUri(long nativeNavigationImpl, NavigationImpl caller);
List<String> getRedirectChain(long nativeNavigationImpl, NavigationImpl caller);
}
} }
...@@ -7,6 +7,7 @@ package org.chromium.weblayer_private; ...@@ -7,6 +7,7 @@ package org.chromium.weblayer_private;
import android.content.Context; import android.content.Context;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.weblayer_private.aidl.IBrowserController; import org.chromium.weblayer_private.aidl.IBrowserController;
import org.chromium.weblayer_private.aidl.IObjectWrapper; import org.chromium.weblayer_private.aidl.IObjectWrapper;
import org.chromium.weblayer_private.aidl.IProfile; import org.chromium.weblayer_private.aidl.IProfile;
...@@ -17,18 +18,18 @@ public final class ProfileImpl extends IProfile.Stub { ...@@ -17,18 +18,18 @@ public final class ProfileImpl extends IProfile.Stub {
private long mNativeProfile; private long mNativeProfile;
public ProfileImpl(String path) { public ProfileImpl(String path) {
mNativeProfile = nativeCreateProfile(path); mNativeProfile = ProfileImplJni.get().createProfile(path);
} }
@Override @Override
public void destroy() { public void destroy() {
nativeDeleteProfile(mNativeProfile); ProfileImplJni.get().deleteProfile(mNativeProfile);
mNativeProfile = 0; mNativeProfile = 0;
} }
@Override @Override
public void clearBrowsingData() { public void clearBrowsingData() {
nativeClearBrowsingData(mNativeProfile); ProfileImplJni.get().clearBrowsingData(mNativeProfile);
} }
@Override @Override
...@@ -42,9 +43,10 @@ public final class ProfileImpl extends IProfile.Stub { ...@@ -42,9 +43,10 @@ public final class ProfileImpl extends IProfile.Stub {
return mNativeProfile; return mNativeProfile;
} }
private static native long nativeCreateProfile(String path); @NativeMethods
interface Natives {
private static native void nativeDeleteProfile(long profile); long createProfile(String path);
void deleteProfile(long profile);
private static native void nativeClearBrowsingData(long nativeProfileImpl); void clearBrowsingData(long nativeProfileImpl);
}
} }
...@@ -13,6 +13,7 @@ import android.view.ViewParent; ...@@ -13,6 +13,7 @@ import android.view.ViewParent;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import org.chromium.base.annotations.JNINamespace; import org.chromium.base.annotations.JNINamespace;
import org.chromium.base.annotations.NativeMethods;
import org.chromium.content_public.browser.WebContents; import org.chromium.content_public.browser.WebContents;
import org.chromium.ui.resources.dynamics.ViewResourceAdapter; import org.chromium.ui.resources.dynamics.ViewResourceAdapter;
...@@ -50,7 +51,8 @@ class TopControlsContainerView extends FrameLayout { ...@@ -50,7 +51,8 @@ class TopControlsContainerView extends FrameLayout {
// Used to delay updating the image for the layer. // Used to delay updating the image for the layer.
private final Runnable mRefreshResourceIdRunnable = () -> { private final Runnable mRefreshResourceIdRunnable = () -> {
nativeUpdateTopControlsResource(mNativeTopControlsContainerView); TopControlsContainerViewJni.get().updateTopControlsResource(
mNativeTopControlsContainerView, TopControlsContainerView.this);
}; };
TopControlsContainerView( TopControlsContainerView(
...@@ -70,13 +72,15 @@ class TopControlsContainerView extends FrameLayout { ...@@ -70,13 +72,15 @@ class TopControlsContainerView extends FrameLayout {
mWebContents.getEventForwarder().setCurrentTouchEventOffsets(0, top); mWebContents.getEventForwarder().setCurrentTouchEventOffsets(0, top);
} }
}); });
mNativeTopControlsContainerView = nativeCreateTopControlsContainerView( mNativeTopControlsContainerView =
webContents, contentViewRenderView.getNativeHandle()); TopControlsContainerViewJni.get().createTopControlsContainerView(
webContents, contentViewRenderView.getNativeHandle());
} }
public void destroy() { public void destroy() {
setView(null); setView(null);
nativeDeleteTopControlsContainerView(mNativeTopControlsContainerView); TopControlsContainerViewJni.get().deleteTopControlsContainerView(
mNativeTopControlsContainerView, TopControlsContainerView.this);
} }
public long getNativeHandle() { public long getNativeHandle() {
...@@ -96,7 +100,8 @@ class TopControlsContainerView extends FrameLayout { ...@@ -96,7 +100,8 @@ class TopControlsContainerView extends FrameLayout {
if (mView.getParent() == this) removeView(mView); if (mView.getParent() == this) removeView(mView);
// TODO: need some sort of destroy to drop reference. // TODO: need some sort of destroy to drop reference.
mViewResourceAdapter = null; mViewResourceAdapter = null;
nativeDeleteTopControlsLayer(mNativeTopControlsContainerView); TopControlsContainerViewJni.get().deleteTopControlsLayer(
mNativeTopControlsContainerView, TopControlsContainerView.this);
mContentViewRenderView.getResourceManager() mContentViewRenderView.getResourceManager()
.getDynamicResourceLoader() .getDynamicResourceLoader()
.unregisterResource(TOP_CONTROLS_ID); .unregisterResource(TOP_CONTROLS_ID);
...@@ -154,8 +159,9 @@ class TopControlsContainerView extends FrameLayout { ...@@ -154,8 +159,9 @@ class TopControlsContainerView extends FrameLayout {
if (mViewResourceAdapter == null) { if (mViewResourceAdapter == null) {
createAdapterAndLayer(); createAdapterAndLayer();
} else { } else {
nativeSetTopControlsSize( TopControlsContainerViewJni.get().setTopControlsSize(
mNativeTopControlsContainerView, mLastWidth, mLastHeight); mNativeTopControlsContainerView, TopControlsContainerView.this,
mLastWidth, mLastHeight);
} }
} }
} }
...@@ -183,10 +189,12 @@ class TopControlsContainerView extends FrameLayout { ...@@ -183,10 +189,12 @@ class TopControlsContainerView extends FrameLayout {
// It's important that the layer is created immediately and always kept in sync with the // It's important that the layer is created immediately and always kept in sync with the
// View. Creating the layer only when needed results in a noticeable delay between when // View. Creating the layer only when needed results in a noticeable delay between when
// the layer is created and actually shown. Chrome for Android does the same thing. // the layer is created and actually shown. Chrome for Android does the same thing.
nativeCreateTopControlsLayer(mNativeTopControlsContainerView, TOP_CONTROLS_ID); TopControlsContainerViewJni.get().createTopControlsLayer(
mNativeTopControlsContainerView, TopControlsContainerView.this, TOP_CONTROLS_ID);
mLastWidth = getWidth(); mLastWidth = getWidth();
mLastHeight = getHeight(); mLastHeight = getHeight();
nativeSetTopControlsSize(mNativeTopControlsContainerView, mLastWidth, mLastHeight); TopControlsContainerViewJni.get().setTopControlsSize(mNativeTopControlsContainerView,
TopControlsContainerView.this, mLastWidth, mLastHeight);
} }
private void finishTopControlsScroll(int topContentOffsetY) { private void finishTopControlsScroll(int topContentOffsetY) {
...@@ -197,8 +205,8 @@ class TopControlsContainerView extends FrameLayout { ...@@ -197,8 +205,8 @@ class TopControlsContainerView extends FrameLayout {
private void setTopControlsOffset(int topControlsOffsetY, int topContentOffsetY) { private void setTopControlsOffset(int topControlsOffsetY, int topContentOffsetY) {
mTopContentOffset = topContentOffsetY; mTopContentOffset = topContentOffsetY;
nativeSetTopControlsOffset( TopControlsContainerViewJni.get().setTopControlsOffset(mNativeTopControlsContainerView,
mNativeTopControlsContainerView, topControlsOffsetY, topContentOffsetY); TopControlsContainerView.this, topControlsOffsetY, topContentOffsetY);
} }
private void prepareForTopControlsScroll() { private void prepareForTopControlsScroll() {
...@@ -214,14 +222,21 @@ class TopControlsContainerView extends FrameLayout { ...@@ -214,14 +222,21 @@ class TopControlsContainerView extends FrameLayout {
if (mView != null) mView.setVisibility(View.VISIBLE); if (mView != null) mView.setVisibility(View.VISIBLE);
} }
private static native long nativeCreateTopControlsContainerView( @NativeMethods
WebContents webContents, long nativeContentViewRenderView); interface Natives {
private native void nativeDeleteTopControlsContainerView(long nativeTopControlsContainerView); long createTopControlsContainerView(
private native void nativeCreateTopControlsLayer(long nativeTopControlsContainerView, int id); WebContents webContents, long nativeContentViewRenderView);
private native void nativeDeleteTopControlsLayer(long nativeTopControlsContainerView); void deleteTopControlsContainerView(
private native void nativeSetTopControlsOffset( long nativeTopControlsContainerView, TopControlsContainerView caller);
long nativeTopControlsContainerView, int topControlsOffsetY, int topContentOffsetY); void createTopControlsLayer(
private native void nativeSetTopControlsSize( long nativeTopControlsContainerView, TopControlsContainerView caller, int id);
long nativeTopControlsContainerView, int width, int height); void deleteTopControlsLayer(
private native void nativeUpdateTopControlsResource(long nativeTopControlsContainerView); long nativeTopControlsContainerView, TopControlsContainerView caller);
void setTopControlsOffset(long nativeTopControlsContainerView,
TopControlsContainerView caller, int topControlsOffsetY, int topContentOffsetY);
void setTopControlsSize(long nativeTopControlsContainerView,
TopControlsContainerView caller, int width, int height);
void updateTopControlsResource(
long nativeTopControlsContainerView, TopControlsContainerView caller);
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment