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

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

Issue 1967553002: DO NOT COMMIT - DialogSurface initial implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cleanup 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);
+}

Powered by Google App Engine
This is Rietveld 408576698