Chromium Code Reviews| Index: content/browser/media/android/dialog_surface_activity_mapper.cc |
| diff --git a/content/browser/media/android/dialog_surface_activity_mapper.cc b/content/browser/media/android/dialog_surface_activity_mapper.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e075327e324a61b2d1274c80cac8e27e546570c2 |
| --- /dev/null |
| +++ b/content/browser/media/android/dialog_surface_activity_mapper.cc |
| @@ -0,0 +1,61 @@ |
| +// 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. |
| + |
| +#include "content/browser/media/android/dialog_surface_activity_mapper.h" |
| + |
| +// TODO(liberato): browser_media_player_manager only does this if !USE_AURA |
| +#include "content/browser/android/content_view_core_impl.h" |
| +#include "content/browser/frame_host/render_frame_host_impl.h" |
| +#include "content/public/browser/render_process_host.h" |
| +#include "content/public/browser/web_contents.h" |
| +#include "jni/DialogSurfaceActivityMapper_jni.h" |
| + |
| +using namespace content; |
| + |
| +static ScopedJavaLocalRef<jobject> GetContentViewCore( |
| + JNIEnv* env, |
| + const JavaParamRef<jclass>& jcaller, |
| + jint renderHandle, |
|
watk
2016/07/26 21:34:30
Java side calls this renderer_pid (which I prefer
liberato (no reviews please)
2016/07/26 22:49:15
Done.
|
| + jint renderFrameId) { |
|
watk
2016/07/26 21:34:30
render_frame_id
liberato (no reviews please)
2016/07/26 22:49:15
Done.
|
| + base::android::ScopedJavaLocalRef<jobject> nullref; |
| + |
| + // Get the id from the handle. |
|
watk
2016/07/26 21:34:30
Probably worth noting that on android a handle is
liberato (no reviews please)
2016/07/26 22:49:15
Done.
|
| + RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator(); |
| + int render_process_id = 0; |
| + while (!it.IsAtEnd()) { |
| + if (it.GetCurrentValue()->GetHandle() == renderHandle) { |
| + render_process_id = it.GetCurrentValue()->GetID(); |
| + break; |
| + } |
| + it.Advance(); |
| + } |
| + if (!render_process_id) { |
| + DVLOG(1) << "Cannot find render process for render_process_handle " |
|
watk
2016/07/26 21:34:30
render_process_handle doesn't exist
liberato (no reviews please)
2016/07/26 22:49:15
Done.
|
| + << renderHandle; |
| + return nullref; |
| + } |
| + |
| + // Get the frame from the id. |
| + RenderFrameHostImpl* frame = |
| + RenderFrameHostImpl::FromID(render_process_id, renderFrameId); |
| + if (!frame) |
| + return nullref; |
| + |
| + WebContents* web_contents = WebContents::FromRenderFrameHost(frame); |
| + if (!web_contents) |
| + return nullref; |
| + |
| + ContentViewCore* cvc = ContentViewCoreImpl::FromWebContents(web_contents); |
| + if (!cvc) |
| + return nullref; |
| + |
| + return base::android::ScopedJavaLocalRef<jobject>(cvc->GetJavaObject()); |
| +} |
| + |
| +namespace content { |
| + |
|
watk
2016/07/26 21:34:30
asymmetric newline in namespace
liberato (no reviews please)
2016/07/26 22:49:15
Done.
|
| +bool RegisterDialogSurfaceActivityMapper(JNIEnv* env) { |
| + return RegisterNativesImpl(env); |
| +} |
| +} |