OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/android/content_video_view.h" | 5 #include "content/browser/android/content_video_view.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "content/browser/android/content_view_core_impl.h" | 10 #include "content/browser/android/content_view_core_impl.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 j_content_video_view_ = | 55 j_content_video_view_ = |
56 CreateJavaObject(content_view_core, video_natural_size); | 56 CreateJavaObject(content_view_core, video_natural_size); |
57 g_content_video_view = this; | 57 g_content_video_view = this; |
58 } | 58 } |
59 | 59 |
60 ContentVideoView::~ContentVideoView() { | 60 ContentVideoView::~ContentVideoView() { |
61 DCHECK(g_content_video_view); | 61 DCHECK(g_content_video_view); |
62 JNIEnv* env = AttachCurrentThread(); | 62 JNIEnv* env = AttachCurrentThread(); |
63 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 63 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
64 if (!content_video_view.is_null()) { | 64 if (!content_video_view.is_null()) { |
65 Java_ContentVideoView_destroyContentVideoView(env, | 65 Java_ContentVideoView_destroyContentVideoView(env, content_video_view, |
66 content_video_view.obj(), true); | 66 true); |
67 j_content_video_view_.reset(); | 67 j_content_video_view_.reset(); |
68 } | 68 } |
69 g_content_video_view = NULL; | 69 g_content_video_view = NULL; |
70 } | 70 } |
71 | 71 |
72 void ContentVideoView::OpenVideo() { | 72 void ContentVideoView::OpenVideo() { |
73 JNIEnv* env = AttachCurrentThread(); | 73 JNIEnv* env = AttachCurrentThread(); |
74 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 74 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
75 if (!content_video_view.is_null()) { | 75 if (!content_video_view.is_null()) { |
76 Java_ContentVideoView_openVideo(env, content_video_view.obj()); | 76 Java_ContentVideoView_openVideo(env, content_video_view); |
77 } | 77 } |
78 } | 78 } |
79 | 79 |
80 void ContentVideoView::OnMediaPlayerError(int error_type) { | 80 void ContentVideoView::OnMediaPlayerError(int error_type) { |
81 JNIEnv* env = AttachCurrentThread(); | 81 JNIEnv* env = AttachCurrentThread(); |
82 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 82 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
83 if (!content_video_view.is_null()) { | 83 if (!content_video_view.is_null()) { |
84 Java_ContentVideoView_onMediaPlayerError(env, content_video_view.obj(), | 84 Java_ContentVideoView_onMediaPlayerError(env, content_video_view, |
85 error_type); | 85 error_type); |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 void ContentVideoView::OnVideoSizeChanged(int width, int height) { | 89 void ContentVideoView::OnVideoSizeChanged(int width, int height) { |
90 JNIEnv* env = AttachCurrentThread(); | 90 JNIEnv* env = AttachCurrentThread(); |
91 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 91 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
92 if (!content_video_view.is_null()) { | 92 if (!content_video_view.is_null()) { |
93 Java_ContentVideoView_onVideoSizeChanged(env, content_video_view.obj(), | 93 Java_ContentVideoView_onVideoSizeChanged(env, content_video_view, width, |
94 width, height); | 94 height); |
95 } | 95 } |
96 } | 96 } |
97 | 97 |
98 void ContentVideoView::ExitFullscreen() { | 98 void ContentVideoView::ExitFullscreen() { |
99 JNIEnv* env = AttachCurrentThread(); | 99 JNIEnv* env = AttachCurrentThread(); |
100 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 100 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
101 bool release_media_player = false; | 101 bool release_media_player = false; |
102 if (!content_video_view.is_null()) | 102 if (!content_video_view.is_null()) |
103 Java_ContentVideoView_exitFullscreen(env, content_video_view.obj(), | 103 Java_ContentVideoView_exitFullscreen(env, content_video_view, |
104 release_media_player); | 104 release_media_player); |
105 } | 105 } |
106 | 106 |
107 ScopedJavaLocalRef<jobject> ContentVideoView::GetJavaObject(JNIEnv* env) { | 107 ScopedJavaLocalRef<jobject> ContentVideoView::GetJavaObject(JNIEnv* env) { |
108 return j_content_video_view_.get(env); | 108 return j_content_video_view_.get(env); |
109 } | 109 } |
110 | 110 |
111 void ContentVideoView::SetSurface(JNIEnv*, | 111 void ContentVideoView::SetSurface(JNIEnv*, |
112 const JavaParamRef<jobject>&, | 112 const JavaParamRef<jobject>&, |
113 const JavaParamRef<jobject>& surface) { | 113 const JavaParamRef<jobject>& surface) { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 ContentViewCore* content_view_core, | 164 ContentViewCore* content_view_core, |
165 const gfx::Size& video_natural_size) { | 165 const gfx::Size& video_natural_size) { |
166 JNIEnv* env = AttachCurrentThread(); | 166 JNIEnv* env = AttachCurrentThread(); |
167 base::android::ScopedJavaLocalRef<jobject> j_content_view_core = | 167 base::android::ScopedJavaLocalRef<jobject> j_content_view_core = |
168 content_view_core->GetJavaObject(); | 168 content_view_core->GetJavaObject(); |
169 if (j_content_view_core.is_null()) | 169 if (j_content_view_core.is_null()) |
170 return JavaObjectWeakGlobalRef(env, nullptr); | 170 return JavaObjectWeakGlobalRef(env, nullptr); |
171 | 171 |
172 return JavaObjectWeakGlobalRef( | 172 return JavaObjectWeakGlobalRef( |
173 env, Java_ContentVideoView_createContentVideoView( | 173 env, Java_ContentVideoView_createContentVideoView( |
174 env, j_content_view_core.obj(), reinterpret_cast<intptr_t>(this), | 174 env, j_content_view_core, reinterpret_cast<intptr_t>(this), |
175 video_natural_size.width(), video_natural_size.height()) | 175 video_natural_size.width(), video_natural_size.height()) |
176 .obj()); | 176 .obj()); |
177 } | 177 } |
178 } // namespace content | 178 } // namespace content |
OLD | NEW |