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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "content/browser/android/content_view_core_impl.h" | 9 #include "content/browser/android/content_view_core_impl.h" |
10 #include "content/browser/media/android/browser_media_player_manager.h" | 10 #include "content/browser/media/android/browser_media_player_manager.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 } | 90 } |
91 | 91 |
92 void ContentVideoView::OnPlaybackComplete() { | 92 void ContentVideoView::OnPlaybackComplete() { |
93 JNIEnv *env = AttachCurrentThread(); | 93 JNIEnv *env = AttachCurrentThread(); |
94 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 94 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
95 if (!content_video_view.is_null()) | 95 if (!content_video_view.is_null()) |
96 Java_ContentVideoView_onPlaybackComplete(env, content_video_view.obj()); | 96 Java_ContentVideoView_onPlaybackComplete(env, content_video_view.obj()); |
97 } | 97 } |
98 | 98 |
99 void ContentVideoView::OnExitFullscreen() { | 99 void ContentVideoView::OnExitFullscreen() { |
100 DestroyContentVideoView(false); | 100 JNIEnv *env = AttachCurrentThread(); |
| 101 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
| 102 if (!content_video_view.is_null()) { |
| 103 Java_ContentVideoView_onExitFullscreen(env, content_video_view.obj()); |
| 104 j_content_video_view_.reset(); |
| 105 } |
101 } | 106 } |
102 | 107 |
103 void ContentVideoView::UpdateMediaMetadata() { | 108 void ContentVideoView::UpdateMediaMetadata() { |
104 JNIEnv *env = AttachCurrentThread(); | 109 JNIEnv *env = AttachCurrentThread(); |
105 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 110 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
106 if (!content_video_view.is_null()) | 111 if (!content_video_view.is_null()) |
107 UpdateMediaMetadata(env, content_video_view.obj()); | 112 UpdateMediaMetadata(env, content_video_view.obj()); |
108 } | 113 } |
109 | 114 |
110 int ContentVideoView::GetVideoWidth(JNIEnv*, jobject obj) const { | 115 int ContentVideoView::GetVideoWidth(JNIEnv*, jobject obj) const { |
(...skipping 27 matching lines...) Expand all Loading... |
138 | 143 |
139 void ContentVideoView::Play(JNIEnv*, jobject obj) { | 144 void ContentVideoView::Play(JNIEnv*, jobject obj) { |
140 manager_->FullscreenPlayerPlay(); | 145 manager_->FullscreenPlayerPlay(); |
141 } | 146 } |
142 | 147 |
143 void ContentVideoView::Pause(JNIEnv*, jobject obj) { | 148 void ContentVideoView::Pause(JNIEnv*, jobject obj) { |
144 manager_->FullscreenPlayerPause(); | 149 manager_->FullscreenPlayerPause(); |
145 } | 150 } |
146 | 151 |
147 void ContentVideoView::ExitFullscreen( | 152 void ContentVideoView::ExitFullscreen( |
148 JNIEnv* env, jobject, jboolean release_media_player) { | 153 JNIEnv*, jobject, jboolean release_media_player) { |
149 if (fullscreen_state_ == SUSPENDED) | 154 if (fullscreen_state_ == SUSPENDED) |
150 return; | 155 return; |
151 j_content_video_view_.reset(); | 156 j_content_video_view_.reset(); |
152 manager_->ExitFullscreen(release_media_player); | 157 manager_->ExitFullscreen(release_media_player); |
153 } | 158 } |
154 | 159 |
155 void ContentVideoView::SuspendFullscreen() { | 160 void ContentVideoView::SuspendFullscreen() { |
156 if (fullscreen_state_ != ENTERED) | 161 if (fullscreen_state_ != ENTERED) |
157 return; | 162 return; |
158 fullscreen_state_ = SUSPENDED; | 163 fullscreen_state_ = SUSPENDED; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 player->CanSeekForward(), player->CanSeekBackward()); | 196 player->CanSeekForward(), player->CanSeekBackward()); |
192 } | 197 } |
193 | 198 |
194 ScopedJavaLocalRef<jobject> ContentVideoView::GetJavaObject(JNIEnv* env) { | 199 ScopedJavaLocalRef<jobject> ContentVideoView::GetJavaObject(JNIEnv* env) { |
195 return j_content_video_view_.get(env); | 200 return j_content_video_view_.get(env); |
196 } | 201 } |
197 | 202 |
198 JavaObjectWeakGlobalRef ContentVideoView::CreateJavaObject() { | 203 JavaObjectWeakGlobalRef ContentVideoView::CreateJavaObject() { |
199 ContentViewCoreImpl* content_view_core = manager_->GetContentViewCore(); | 204 ContentViewCoreImpl* content_view_core = manager_->GetContentViewCore(); |
200 JNIEnv *env = AttachCurrentThread(); | 205 JNIEnv *env = AttachCurrentThread(); |
| 206 bool legacyMode = !CommandLine::ForCurrentProcess()->HasSwitch( |
| 207 switches::kEnableOverlayFullscreenVideoSubtitle); |
201 return JavaObjectWeakGlobalRef( | 208 return JavaObjectWeakGlobalRef( |
202 env, | 209 env, |
203 Java_ContentVideoView_createContentVideoView( | 210 Java_ContentVideoView_createContentVideoView( |
204 env, | 211 env, |
205 content_view_core->GetContext().obj(), | 212 content_view_core->GetContext().obj(), |
206 reinterpret_cast<intptr_t>(this), | 213 reinterpret_cast<intptr_t>(this), |
207 content_view_core->GetContentVideoViewClient().obj()).obj()); | 214 content_view_core->GetContentVideoViewClient().obj(), |
| 215 legacyMode).obj()); |
208 } | 216 } |
209 | 217 |
210 void ContentVideoView::DestroyContentVideoView(bool native_view_destroyed) { | 218 void ContentVideoView::DestroyContentVideoView(bool native_view_destroyed) { |
211 JNIEnv *env = AttachCurrentThread(); | 219 JNIEnv *env = AttachCurrentThread(); |
212 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); | 220 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |
213 if (!content_video_view.is_null()) { | 221 if (!content_video_view.is_null()) { |
214 Java_ContentVideoView_destroyContentVideoView(env, | 222 Java_ContentVideoView_destroyContentVideoView(env, |
215 content_video_view.obj(), native_view_destroyed); | 223 content_video_view.obj(), native_view_destroyed); |
216 j_content_video_view_.reset(); | 224 j_content_video_view_.reset(); |
217 } | 225 } |
218 } | 226 } |
219 } // namespace content | 227 } // namespace content |
OLD | NEW |