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 using namespace content; | |
DaleCurtis
2016/07/27 18:14:19
We don't typically use "using"
liberato (no reviews please)
2016/07/28 15:33:30
Done.
| |
15 | |
16 static ScopedJavaLocalRef<jobject> GetContentViewCore( | |
DaleCurtis
2016/07/27 18:14:19
Seems unused? It looks like you're calling this fr
liberato (no reviews please)
2016/07/28 15:33:30
I don't think that it's called right now, since it
| |
17 JNIEnv* env, | |
18 const JavaParamRef<jclass>& jcaller, | |
19 jint renderer_pid, | |
20 jint render_frame_id) { | |
21 base::android::ScopedJavaLocalRef<jobject> nullref; | |
DaleCurtis
2016/07/27 18:14:19
Does return nullptr fail?
liberato (no reviews please)
2016/07/28 15:33:30
unfortunately, yes. i hadn't tried it, though, so
| |
22 | |
23 // Get the id from the handle. On android, the handle is the pid. | |
24 RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); | |
25 int render_process_id = 0; | |
26 while (!it.IsAtEnd()) { | |
27 if (it.GetCurrentValue()->GetHandle() == renderer_pid) { | |
28 render_process_id = it.GetCurrentValue()->GetID(); | |
29 break; | |
30 } | |
31 it.Advance(); | |
32 } | |
33 if (!render_process_id) { | |
34 DVLOG(1) << "Cannot find render process for renderer_pid " << renderer_pid; | |
35 return nullref; | |
36 } | |
37 | |
38 // Get the frame from the id. | |
39 RenderFrameHostImpl* frame = | |
40 RenderFrameHostImpl::FromID(render_process_id, render_frame_id); | |
41 if (!frame) | |
42 return nullref; | |
43 | |
44 WebContents* web_contents = WebContents::FromRenderFrameHost(frame); | |
45 if (!web_contents) | |
46 return nullref; | |
47 | |
48 ContentViewCore* cvc = ContentViewCoreImpl::FromWebContents(web_contents); | |
49 if (!cvc) | |
50 return nullref; | |
51 | |
52 return base::android::ScopedJavaLocalRef<jobject>(cvc->GetJavaObject()); | |
53 } | |
54 | |
55 namespace content { | |
56 bool RegisterDialogSurfaceActivityMapper(JNIEnv* env) { | |
57 return RegisterNativesImpl(env); | |
58 } | |
59 } | |
OLD | NEW |