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..e526f263f51bf626dba1966deda37eb622ebeb6a |
--- /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 renderPid, int renderFrameId); |
watk
2016/07/26 21:34:30
rendererPid
liberato (no reviews please)
2016/07/26 22:49:15
Done.
|
+} |