Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayOperationsImpl.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayOperationsImpl.java b/content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayOperationsImpl.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..984117b065cfcb0f54f2b5b338cc5ba440d77466 |
| --- /dev/null |
| +++ b/content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayOperationsImpl.java |
| @@ -0,0 +1,91 @@ |
| +// 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.androidoverlay; |
| + |
| +import android.os.Handler; |
| +import android.os.IBinder; |
| +import android.view.Surface; |
| + |
| +import org.chromium.base.annotations.CalledByNative; |
| +import org.chromium.base.annotations.JNINamespace; |
| + |
| +/** |
| + * Basic impl of DialogOverlayOperations. |
| + */ |
| +@JNINamespace("content") |
| +class DialogOverlayOperationsImpl implements DialogOverlayOperations { |
| + private long mNativeHandle; |
| + private Handler mOverlayUiHandler; |
| + |
| + // Runnable that we'll run when the overlay notifies us that it's been released. |
| + private Runnable mReleasedRunnable; |
| + |
| + // Listener to which we'll forward window token information. |
| + private WindowTokenListener mListener; |
| + |
| + public DialogOverlayOperationsImpl(Handler overlayUiHandler, Runnable releasedRunnable) { |
| + mOverlayUiHandler = overlayUiHandler; |
| + mReleasedRunnable = releasedRunnable; |
| + } |
| + |
| + @Override |
| + public void notifyReleased() { |
| + mReleasedRunnable.run(); |
| + } |
| + |
| + @Override |
| + public Handler getOverlayUiHandler() { |
|
boliu
2017/04/04 23:53:21
this is named OverlayUi :p
liberato (no reviews please)
2017/04/05 15:13:30
Done.
|
| + return mOverlayUiHandler; |
| + } |
| + |
| + @Override |
| + public void registerWindowTokenListener( |
| + org.chromium.mojo.common.mojom.UnguessableToken token, WindowTokenListener listener) { |
| + mListener = listener; |
| + mNativeHandle = nativeRegisterForTokens(token.high, token.low); |
| + assert mNativeHandle != 0; |
| + } |
| + |
| + @Override |
| + public void unregisterWindowTokenListenerIfNeeded() { |
| + if (mNativeHandle == 0) return; |
| + |
| + nativeUnregisterForTokens(mNativeHandle); |
| + mNativeHandle = 0; |
| + } |
| + |
| + @Override |
| + public int registerSurface(Surface surface) { |
| + return nativeRegisterSurface(surface); |
| + } |
| + |
| + @Override |
| + public void unregisterSurface(int surfaceId) { |
| + nativeUnregisterSurface(surfaceId); |
| + } |
| + |
| + // Called on the browser UI (not overlay) thread. |
| + @CalledByNative |
| + private void onWindowToken(final IBinder token) { |
| + mListener.onWindowToken(token); |
| + } |
| + |
| + // Called on the browser UI thread. |
| + // We're not getting any more window tokens. |
| + @CalledByNative |
| + private void onDismissed() { |
| + mListener.onDismissed(); |
| + } |
| + |
| + // Initializes native side. Will register for onWindowToken callbacks on |this|. Returns a |
| + // handle that should be provided to nativeUnregisterForTokens. |
| + native long nativeRegisterForTokens(long high, long low); |
|
boliu
2017/04/04 23:53:21
all native methods should be private
liberato (no reviews please)
2017/04/05 15:13:30
Done.
|
| + |
| + // Stops native side. |
| + static native void nativeUnregisterForTokens(long handle); |
| + |
| + static native int nativeRegisterSurface(Surface surface); |
| + static native void nativeUnregisterSurface(int surfaceId); |
| +} |