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

Side by Side Diff: content/browser/media/android/dialog_surface_activity_mapper.cc

Issue 2178973004: DialogSurfaceManager implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addedd DVLOG Created 4 years, 4 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 unified diff | Download patch
OLDNEW
(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(
DaleCurtis 2016/08/04 00:20:36 This is still pretty crummy to have to do, but if
liberato (no reviews please) 2016/08/04 01:06:20 agree, it's ugly. it's quite similar to what Stre
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) {
41 DVLOG(1) << "Cannot find frame for renderer_pid " << renderer_pid
42 << " render_frame_id " << render_frame_id;
43 return nullref;
44 }
45
46 content::WebContents* web_contents =
47 content::WebContents::FromRenderFrameHost(frame);
48 if (!web_contents) {
49 DVLOG(1) << "Cannot find web_contents for renderer_pid " << renderer_pid
50 << " render_frame_id " << render_frame_id;
51 return nullref;
52 }
53
54 content::ContentViewCore* cvc =
55 content::ContentViewCoreImpl::FromWebContents(web_contents);
56 if (!cvc) {
57 DVLOG(1) << "Cannot find cvc for renderer_pid " << renderer_pid
58 << " render_frame_id " << render_frame_id;
59 return nullref;
60 }
61
62 return base::android::ScopedJavaLocalRef<jobject>(cvc->GetJavaObject());
63 }
64
65 namespace content {
66 bool RegisterDialogSurfaceActivityMapper(JNIEnv* env) {
67 return RegisterNativesImpl(env);
68 }
69 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698