| Index: content/public/android/java/src/org/chromium/content/browser/DialogSurfaceActivityMapper.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/DialogSurfaceActivityMapper.java b/content/public/android/java/src/org/chromium/content/browser/DialogSurfaceActivityMapper.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..c75799e9741f85d9266f23a5bf5c3e9434c91177
|
| --- /dev/null
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/DialogSurfaceActivityMapper.java
|
| @@ -0,0 +1,44 @@
|
| +// Copyright 2016 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;
|
| +
|
| +import android.app.Activity;
|
| +import android.os.IBinder;
|
| +
|
| +import org.chromium.media.IDialogSurfaceActivityMapper;
|
| +
|
| +/**
|
| + * Implementation of IDialogSurfaceActivityMapper.
|
| + * Provided by ChildProcessLauncher to DialogSurfaceManager.
|
| + */
|
| +public class DialogSurfaceActivityMapper extends IDialogSurfaceActivityMapper.Stub {
|
| + /**
|
| + * Return a window token for the (rendererPid, renderFrameId) pair.
|
| + * @param rendererPid the PID of the renderer that we're looking up.
|
| + * @param renderFrameId the ID of the render frame within that PID.
|
| + */
|
| + public IBinder getWindowToken(int rendererPid, int renderFrameId) {
|
| + final Activity activity = getActivity(rendererPid, renderFrameId);
|
| + if (activity == null) return null;
|
| +
|
| + return activity.getWindow().getDecorView().getRootView().getWindowToken();
|
| + }
|
| +
|
| + /**
|
| + * Return the activity for (rendererPid, renderFrameId), or null.
|
| + * @param rendererPid the PID of the renderer that we're looking up.
|
| + * @param renderFrameId the ID of the render frame within that PID.
|
| + */
|
| + private Activity getActivity(int rendererPid, int renderFrameId) {
|
| + ContentViewCore cvc = nativeGetContentViewCore(rendererPid, renderFrameId);
|
| + if (cvc == null) return null;
|
| +
|
| + // Note that this weakref's referent can be null for webview.
|
| + return cvc.getWindowAndroid().getActivity().get();
|
| + }
|
| +
|
| + private static native ContentViewCore nativeGetContentViewCore(
|
| + int rendererPid, int renderFrameId);
|
| +}
|
|
|