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

Unified 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: gyp Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
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..6a57fe9b56a77795437a76e82b8af1336dcef004
--- /dev/null
+++ b/content/browser/media/android/dialog_surface_activity_mapper.cc
@@ -0,0 +1,59 @@
+// 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;
DaleCurtis 2016/07/27 18:14:19 We don't typically use "using"
liberato (no reviews please) 2016/07/28 15:33:30 Done.
+
+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
+ JNIEnv* env,
+ const JavaParamRef<jclass>& jcaller,
+ jint renderer_pid,
+ jint render_frame_id) {
+ 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
+
+ // Get the id from the handle. On android, the handle is the pid.
+ RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator();
+ int render_process_id = 0;
+ while (!it.IsAtEnd()) {
+ if (it.GetCurrentValue()->GetHandle() == renderer_pid) {
+ render_process_id = it.GetCurrentValue()->GetID();
+ break;
+ }
+ it.Advance();
+ }
+ if (!render_process_id) {
+ DVLOG(1) << "Cannot find render process for renderer_pid " << renderer_pid;
+ return nullref;
+ }
+
+ // Get the frame from the id.
+ RenderFrameHostImpl* frame =
+ RenderFrameHostImpl::FromID(render_process_id, render_frame_id);
+ 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 {
+bool RegisterDialogSurfaceActivityMapper(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+}

Powered by Google App Engine
This is Rietveld 408576698