Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/androidoverlay/DialogOverlayOperationsImpl.java

Issue 2765443004: AndroidOverlay implementation using Dialog. (Closed)
Patch Set: fixes after rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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.os.Handler;
8 import android.os.IBinder;
9 import android.view.Surface;
10
11 import org.chromium.base.annotations.CalledByNative;
12 import org.chromium.base.annotations.JNINamespace;
13
14 /**
15 * Basic impl of DialogOverlayOperations.
16 */
17 @JNINamespace("content")
18 class DialogOverlayOperationsImpl implements DialogOverlayOperations {
19 private long mNativeHandle;
20 private Handler mOverlayUiHandler;
21
22 // Runnable that we'll run when the overlay notifies us that it's been relea sed.
23 private Runnable mReleasedRunnable;
24
25 // Listener to which we'll forward window token information.
26 private WindowTokenListener mListener;
27
28 public DialogOverlayOperationsImpl(Handler overlayUiHandler, Runnable releas edRunnable) {
29 mOverlayUiHandler = overlayUiHandler;
30 mReleasedRunnable = releasedRunnable;
31 }
32
33 @Override
34 public void notifyReleased() {
35 mReleasedRunnable.run();
36 }
37
38 @Override
39 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.
40 return mOverlayUiHandler;
41 }
42
43 @Override
44 public void registerWindowTokenListener(
45 org.chromium.mojo.common.mojom.UnguessableToken token, WindowTokenLi stener listener) {
46 mListener = listener;
47 mNativeHandle = nativeRegisterForTokens(token.high, token.low);
48 assert mNativeHandle != 0;
49 }
50
51 @Override
52 public void unregisterWindowTokenListenerIfNeeded() {
53 if (mNativeHandle == 0) return;
54
55 nativeUnregisterForTokens(mNativeHandle);
56 mNativeHandle = 0;
57 }
58
59 @Override
60 public int registerSurface(Surface surface) {
61 return nativeRegisterSurface(surface);
62 }
63
64 @Override
65 public void unregisterSurface(int surfaceId) {
66 nativeUnregisterSurface(surfaceId);
67 }
68
69 // Called on the browser UI (not overlay) thread.
70 @CalledByNative
71 private void onWindowToken(final IBinder token) {
72 mListener.onWindowToken(token);
73 }
74
75 // Called on the browser UI thread.
76 // We're not getting any more window tokens.
77 @CalledByNative
78 private void onDismissed() {
79 mListener.onDismissed();
80 }
81
82 // Initializes native side. Will register for onWindowToken callbacks on |t his|. Returns a
83 // handle that should be provided to nativeUnregisterForTokens.
84 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.
85
86 // Stops native side.
87 static native void nativeUnregisterForTokens(long handle);
88
89 static native int nativeRegisterSurface(Surface surface);
90 static native void nativeUnregisterSurface(int surfaceId);
91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698