| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "android_webview/native/external_video_surface_container_impl.h" | 5 #include "android_webview/native/external_video_surface_container_impl.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "content/public/browser/android/content_view_core.h" | 8 #include "content/public/browser/android/content_view_core.h" |
| 9 #include "jni/ExternalVideoSurfaceContainer_jni.h" | 9 #include "jni/ExternalVideoSurfaceContainer_jni.h" |
| 10 #include "ui/gfx/rect_f.h" | 10 #include "ui/gfx/rect_f.h" |
| 11 | 11 |
| 12 using android_webview::ExternalVideoSurfaceContainerImpl; | |
| 13 using base::android::AttachCurrentThread; | 12 using base::android::AttachCurrentThread; |
| 14 using content::ContentViewCore; | 13 using content::ContentViewCore; |
| 15 | 14 |
| 16 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ExternalVideoSurfaceContainerImpl); | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 // static | |
| 21 void ExternalVideoSurfaceContainer::CreateForWebContents( | |
| 22 WebContents* web_contents) { | |
| 23 WebContentsUserData<ExternalVideoSurfaceContainerImpl>::CreateForWebContents( | |
| 24 web_contents); | |
| 25 } | |
| 26 | |
| 27 // static | |
| 28 ExternalVideoSurfaceContainer* ExternalVideoSurfaceContainer::FromWebContents( | |
| 29 WebContents* web_contents) { | |
| 30 return WebContentsUserData<ExternalVideoSurfaceContainerImpl>:: | |
| 31 FromWebContents(web_contents); | |
| 32 } | |
| 33 | |
| 34 } // namespace content | |
| 35 | |
| 36 namespace android_webview { | 15 namespace android_webview { |
| 37 | 16 |
| 38 ExternalVideoSurfaceContainerImpl::ExternalVideoSurfaceContainerImpl( | 17 ExternalVideoSurfaceContainerImpl::ExternalVideoSurfaceContainerImpl( |
| 39 content::WebContents* web_contents) { | 18 content::WebContents* web_contents) { |
| 40 ContentViewCore* cvc = ContentViewCore::FromWebContents(web_contents); | 19 ContentViewCore* cvc = ContentViewCore::FromWebContents(web_contents); |
| 41 if (cvc) { | 20 if (cvc) { |
| 42 JNIEnv* env = AttachCurrentThread(); | 21 JNIEnv* env = AttachCurrentThread(); |
| 43 jobject_.Reset( | 22 jobject_.Reset( |
| 44 Java_ExternalVideoSurfaceContainer_create( | 23 Java_ExternalVideoSurfaceContainer_create( |
| 45 env, reinterpret_cast<intptr_t>(this), cvc->GetJavaObject().obj())); | 24 env, reinterpret_cast<intptr_t>(this), cvc->GetJavaObject().obj())); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 JNIEnv* env, jobject obj, jint player_id) { | 82 JNIEnv* env, jobject obj, jint player_id) { |
| 104 if (!surface_destroyed_cb_.is_null()) | 83 if (!surface_destroyed_cb_.is_null()) |
| 105 surface_destroyed_cb_.Run(static_cast<int>(player_id)); | 84 surface_destroyed_cb_.Run(static_cast<int>(player_id)); |
| 106 } | 85 } |
| 107 | 86 |
| 108 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env) { | 87 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env) { |
| 109 return RegisterNativesImpl(env) >= 0; | 88 return RegisterNativesImpl(env) >= 0; |
| 110 } | 89 } |
| 111 | 90 |
| 112 } // namespace android_webview | 91 } // namespace android_webview |
| OLD | NEW |