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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/DialogSurfaceActivityMapper.java

Issue 2178973004: DialogSurfaceManager implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moved jni out of content/app Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
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.
+}

Powered by Google App Engine
This is Rietveld 408576698