OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 package org.chromium.content.browser.androidoverlay; | |
6 | |
7 import android.app.Dialog; | |
8 import android.content.Context; | |
9 import android.os.Handler; | |
10 import android.os.IBinder; | |
11 import android.view.Surface; | |
12 import android.view.Window; | |
13 | |
14 import org.chromium.base.annotations.CalledByNative; | |
15 import org.chromium.base.annotations.JNINamespace; | |
16 | |
17 /** | |
18 * 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.
| |
19 */ | |
20 @JNINamespace("content") | |
21 class DialogOverlayOperationsImpl implements DialogOverlayOperations { | |
22 private long mNativeHandle; | |
23 private Handler mOverlayUiHandler; | |
24 | |
25 // Runnable that we'll run when the overlay notifies us that it's been relea sed. | |
26 private Runnable mReleasedRunnable; | |
27 | |
28 // Listener to which we'll forward window token information. | |
29 private WindowTokenListener mListener; | |
30 | |
31 public DialogOverlayOperationsImpl(Handler overlayUiHandler, Runnable releas edRunnable) { | |
32 mOverlayUiHandler = overlayUiHandler; | |
33 mReleasedRunnable = releasedRunnable; | |
34 } | |
35 | |
36 @Override | |
37 public void notifyReleased() { | |
38 mReleasedRunnable.run(); | |
39 } | |
40 | |
41 // Remember: this will be called on the overlay-ui thread! | |
42 @Override | |
43 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.
| |
44 // Create the dialog, but don't lay it out or show it yet. We'll do tha t when we get a new | |
45 // window token. | |
46 Dialog dialog = new Dialog(context, android.R.style.Theme_NoDisplay); | |
47 dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); | |
48 dialog.setCancelable(false); | |
49 | |
50 return dialog; | |
51 } | |
52 | |
53 @Override | |
54 public Handler getOverlayUiHandler() { | |
55 return mOverlayUiHandler; | |
56 } | |
57 | |
58 @Override | |
59 public void registerWindowTokenListener( | |
60 org.chromium.mojo.common.mojom.UnguessableToken token, WindowTokenLi stener listener) { | |
61 mListener = listener; | |
62 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.
| |
63 } | |
64 | |
65 @Override | |
66 public void unregisterWindowTokenListener() { | |
67 nativeUnregisterForTokens(mNativeHandle); | |
68 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
| |
69 } | |
70 | |
71 @Override | |
72 public int registerSurface(Surface surface) { | |
73 return nativeRegisterSurface(surface); | |
74 } | |
75 | |
76 @Override | |
77 public void unregisterSurface(int surfaceId) { | |
78 nativeUnregisterSurface(surfaceId); | |
79 } | |
80 | |
81 // Called on the browser UI (not overlay-ui) thread. | |
82 @CalledByNative | |
83 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.
| |
84 mListener.onWindowToken(token); | |
85 } | |
86 | |
87 // Called on the browser UI thread. | |
88 // We're not getting any more window tokens. | |
89 @CalledByNative | |
90 public void onDismissed() { | |
91 mListener.onDismissed(); | |
92 } | |
93 | |
94 // Initializes native side. Will register for onWindowToken callbacks. | |
95 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
| |
96 | |
97 // Stops native side. | |
98 native void nativeUnregisterForTokens(long handle); | |
99 | |
100 native int nativeRegisterSurface(Surface surface); | |
101 native void nativeUnregisterSurface(int surfaceId); | |
102 } | |
OLD | NEW |