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..626e5dfc44f6a4b464853554503293dd39482b4b |
| --- /dev/null |
| +++ b/content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayOperationsImpl.java |
| @@ -0,0 +1,102 @@ |
| +// 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.app.Dialog; |
| +import android.content.Context; |
| +import android.os.Handler; |
| +import android.os.IBinder; |
| +import android.view.Surface; |
| +import android.view.Window; |
| + |
| +import org.chromium.base.annotations.CalledByNative; |
| +import org.chromium.base.annotations.JNINamespace; |
| + |
| +/** |
| + * Basic impl of DialogOverlayOperations |
|
boliu
2017/03/30 22:42:02
nit: java doc require a period at the end
liberato (no reviews please)
2017/04/04 17:49:28
Done.
|
| + */ |
| +@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(); |
| + } |
| + |
| + // Remember: this will be called on the overlay-ui thread! |
| + @Override |
| + public Dialog createDialog(Context context) { |
|
boliu
2017/03/30 22:42:02
static, but I guess no longer overridable..
was t
liberato (no reviews please)
2017/04/04 17:49:28
yeah, initially it was for DialogOverlayCoreTest.
|
| + // Create the dialog, but don't lay it out or show it yet. We'll do that when we get a new |
| + // window token. |
| + Dialog dialog = new Dialog(context, android.R.style.Theme_NoDisplay); |
| + dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); |
| + dialog.setCancelable(false); |
| + |
| + return dialog; |
| + } |
| + |
| + @Override |
| + public Handler getOverlayUiHandler() { |
| + return mOverlayUiHandler; |
| + } |
| + |
| + @Override |
| + public void registerWindowTokenListener( |
| + org.chromium.mojo.common.mojom.UnguessableToken token, WindowTokenListener listener) { |
| + mListener = listener; |
| + mNativeHandle = nativeRegisterForTokens(token.high, token.low); |
|
boliu
2017/03/30 22:42:02
assert mNativeHandle == 0?
liberato (no reviews please)
2017/04/04 17:49:28
Done.
|
| + } |
| + |
| + @Override |
| + public void unregisterWindowTokenListener() { |
| + nativeUnregisterForTokens(mNativeHandle); |
| + mNativeHandle = 0; |
|
boliu
2017/03/30 22:42:02
probably should check or assert for non-0 before u
liberato (no reviews please)
2017/04/04 17:49:28
switched to do-nothing if |!mNativeHandle|. simpl
|
| + } |
| + |
| + @Override |
| + public int registerSurface(Surface surface) { |
| + return nativeRegisterSurface(surface); |
| + } |
| + |
| + @Override |
| + public void unregisterSurface(int surfaceId) { |
| + nativeUnregisterSurface(surfaceId); |
| + } |
| + |
| + // Called on the browser UI (not overlay-ui) thread. |
| + @CalledByNative |
| + public void onWindowToken(final IBinder token) { |
|
boliu
2017/03/30 22:42:02
@CalledByNative should be private
liberato (no reviews please)
2017/04/04 17:49:28
Done, and elsewhere.
|
| + mListener.onWindowToken(token); |
| + } |
| + |
| + // Called on the browser UI thread. |
| + // We're not getting any more window tokens. |
| + @CalledByNative |
| + public void onDismissed() { |
| + mListener.onDismissed(); |
| + } |
| + |
| + // Initializes native side. Will register for onWindowToken callbacks. |
| + native long nativeRegisterForTokens(long high, long low); |
|
boliu
2017/03/30 22:42:02
all native methods private, and looks like should
liberato (no reviews please)
2017/04/04 17:49:28
Done, except for nativeRegisterForTokens which req
|
| + |
| + // Stops native side. |
| + native void nativeUnregisterForTokens(long handle); |
| + |
| + native int nativeRegisterSurface(Surface surface); |
| + native void nativeUnregisterSurface(int surfaceId); |
| +} |