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 #include "content/browser/media/android/dialog_surface_activity_mapper.h" | |
6 | |
7 // TODO(liberato): browser_media_player_manager only does this if !USE_AURA | |
8 #include "content/browser/android/content_view_core_impl.h" | |
9 #include "content/browser/frame_host/render_frame_host_impl.h" | |
10 #include "content/public/browser/render_process_host.h" | |
11 #include "content/public/browser/web_contents.h" | |
12 #include "jni/DialogSurfaceActivityMapper_jni.h" | |
13 | |
14 static ScopedJavaLocalRef<jobject> GetContentViewCore( | |
15 JNIEnv* env, | |
16 const JavaParamRef<jclass>& jcaller, | |
17 jint renderer_pid, | |
18 jint render_frame_id) { | |
19 base::android::ScopedJavaLocalRef<jobject> nullref; | |
20 | |
21 // Get the id from the handle. On android, the handle is the pid. | |
22 content::RenderProcessHost::iterator it = | |
23 content::RenderProcessHost::AllHostsIterator(); | |
24 int render_process_id = 0; | |
25 while (!it.IsAtEnd()) { | |
26 if (it.GetCurrentValue()->GetHandle() == renderer_pid) { | |
27 render_process_id = it.GetCurrentValue()->GetID(); | |
28 break; | |
29 } | |
30 it.Advance(); | |
31 } | |
32 if (!render_process_id) { | |
33 DVLOG(1) << "Cannot find render process for renderer_pid " << renderer_pid; | |
34 return nullref; | |
35 } | |
36 | |
37 // Get the frame from the id. | |
38 content::RenderFrameHostImpl* frame = | |
39 content::RenderFrameHostImpl::FromID(render_process_id, render_frame_id); | |
40 if (!frame) | |
Tima Vaisburd
2016/08/03 18:05:13
Similar DVLOG(1) as l.33 (and below)? Or not havin
liberato (no reviews please)
2016/08/03 23:11:54
Done.
| |
41 return nullref; | |
42 | |
43 content::WebContents* web_contents = | |
44 content::WebContents::FromRenderFrameHost(frame); | |
45 if (!web_contents) | |
46 return nullref; | |
47 | |
48 content::ContentViewCore* cvc = | |
49 content::ContentViewCoreImpl::FromWebContents(web_contents); | |
50 if (!cvc) | |
51 return nullref; | |
52 | |
53 return base::android::ScopedJavaLocalRef<jobject>(cvc->GetJavaObject()); | |
54 } | |
55 | |
56 namespace content { | |
57 bool RegisterDialogSurfaceActivityMapper(JNIEnv* env) { | |
58 return RegisterNativesImpl(env); | |
59 } | |
60 } | |
OLD | NEW |