Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 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; | |
| 6 | |
| 7 import android.app.Activity; | |
| 8 import android.os.IBinder; | |
| 9 | |
| 10 import org.chromium.media.IDialogSurfaceActivityMapper; | |
| 11 | |
| 12 /** | |
| 13 * Implementation of IDialogSurfaceActivityMapper. | |
| 14 * Provided by ChildProcessLauncher to DialogSurfaceManager. | |
| 15 */ | |
| 16 public class DialogSurfaceActivityMapper extends IDialogSurfaceActivityMapper.St ub { | |
| 17 /** | |
| 18 * Return a window token for the (rendererPid, renderFrameId) pair. | |
| 19 * @param rendererPid the PID of the renderer that we're looking up. | |
| 20 * @param renderFrameId the ID of the render frame within that PID. | |
| 21 */ | |
| 22 public IBinder getWindowToken(int rendererPid, int renderFrameId) { | |
| 23 final Activity activity = getActivity(rendererPid, renderFrameId); | |
| 24 if (activity == null) return null; | |
| 25 | |
| 26 return activity.getWindow().getDecorView().getRootView().getWindowToken( ); | |
| 27 } | |
| 28 | |
| 29 /** | |
| 30 * Return the activity for (rendererPid, renderFrameId), or null. | |
| 31 * @param rendererPid the PID of the renderer that we're looking up. | |
| 32 * @param renderFrameId the ID of the render frame within that PID. | |
| 33 */ | |
| 34 private Activity getActivity(int rendererPid, int renderFrameId) { | |
| 35 ContentViewCore cvc = nativeGetContentViewCore(rendererPid, renderFrameI d); | |
| 36 if (cvc == null) return null; | |
| 37 | |
| 38 // Note that this weakref's referent can be null for webview. | |
| 39 return cvc.getWindowAndroid().getActivity().get(); | |
| 40 } | |
| 41 | |
| 42 private static native ContentViewCore nativeGetContentViewCore( | |
| 43 int renderPid, int renderFrameId); | |
|
watk
2016/07/26 21:34:30
rendererPid
liberato (no reviews please)
2016/07/26 22:49:15
Done.
| |
| 44 } | |
| OLD | NEW |