Index: content/browser/android/content_video_view.cc |
diff --git a/content/browser/android/content_video_view.cc b/content/browser/android/content_video_view.cc |
index 116e7b4d5981785cdfb1d39937ea652643bad0dd..9800dba53f7090d6944988bd4a6331c87069d2f0 100644 |
--- a/content/browser/android/content_video_view.cc |
+++ b/content/browser/android/content_video_view.cc |
@@ -6,6 +6,7 @@ |
#include "base/command_line.h" |
#include "base/logging.h" |
+#include "content/browser/android/content_view_core_impl.h" |
#include "content/browser/media/android/browser_media_player_manager.h" |
#include "content/common/android/surface_texture_peer.h" |
#include "content/public/common/content_switches.h" |
@@ -35,20 +36,17 @@ bool ContentVideoView::RegisterContentVideoView(JNIEnv* env) { |
return RegisterNativesImpl(env); |
} |
-bool ContentVideoView::HasContentVideoView() { |
+ContentVideoView* ContentVideoView::GetInstance() { |
return g_content_video_view; |
} |
ContentVideoView::ContentVideoView( |
- const ScopedJavaLocalRef<jobject>& context, |
- const ScopedJavaLocalRef<jobject>& client, |
BrowserMediaPlayerManager* manager) |
- : manager_(manager) { |
+ : manager_(manager), |
+ fullscreen_state_(Entered) { |
DCHECK(!g_content_video_view); |
- JNIEnv *env = AttachCurrentThread(); |
- j_content_video_view_ = JavaObjectWeakGlobalRef(env, |
- Java_ContentVideoView_createContentVideoView(env, context.obj(), |
- reinterpret_cast<intptr_t>(this), client.obj()).obj()); |
+ ContentViewCoreImpl* content_view = manager_->GetContentViewCore(); |
+ j_content_video_view_ = CreateJavaObject(content_view); |
g_content_video_view = this; |
} |
@@ -148,15 +146,38 @@ void ContentVideoView::Pause(JNIEnv*, jobject obj) { |
} |
void ContentVideoView::ExitFullscreen( |
- JNIEnv*, jobject, jboolean release_media_player) { |
+ JNIEnv* env, jobject, jboolean release_media_player) { |
+ DCHECK(fullscreen_state_ == Entered); |
j_content_video_view_.reset(); |
manager_->ExitFullscreen(release_media_player); |
} |
+void ContentVideoView::SuspendFullscreen() { |
+ if (fullscreen_state_ != Entered) |
+ return; |
+ fullscreen_state_ = Suspend; |
+ DestroyContentVideoView(false); |
+ manager_->SuspendFullscreen(); |
+} |
+ |
+void ContentVideoView::ResumeFullscreenIfSuspended() { |
+ if (fullscreen_state_ != Suspend) |
+ return; |
+ JNIEnv* env = AttachCurrentThread(); |
+ DCHECK(!GetJavaObject(env).obj()); |
+ fullscreen_state_ = Resume; |
+ j_content_video_view_ = CreateJavaObject(manager_->GetContentViewCore()); |
+} |
+ |
void ContentVideoView::SetSurface(JNIEnv* env, jobject obj, |
jobject surface) { |
- manager_->SetVideoSurface( |
- gfx::ScopedJavaSurface::AcquireExternalSurface(surface)); |
+ gfx::ScopedJavaSurface scoped_surface = |
+ gfx::ScopedJavaSurface::AcquireExternalSurface(surface); |
+ if (fullscreen_state_ == Resume) |
+ manager_->ResumeFullscreen(scoped_surface.Pass()); |
+ else |
+ manager_->SetVideoSurface(scoped_surface.Pass()); |
+ fullscreen_state_ = Entered; |
} |
void ContentVideoView::UpdateMediaMetadata(JNIEnv* env, jobject obj) { |
@@ -172,6 +193,16 @@ ScopedJavaLocalRef<jobject> ContentVideoView::GetJavaObject(JNIEnv* env) { |
return j_content_video_view_.get(env); |
} |
+JavaObjectWeakGlobalRef ContentVideoView::CreateJavaObject( |
+ ContentViewCoreImpl* content_view_core) { |
+ JNIEnv *env = AttachCurrentThread(); |
+ return JavaObjectWeakGlobalRef(env, |
+ Java_ContentVideoView_createContentVideoView(env, |
qinmin
2013/12/18 02:09:46
nit:fix the indentation
|
+ content_view_core->GetContext().obj(), |
+ reinterpret_cast<intptr_t>(this), |
+ content_view_core->GetContentVideoViewClient().obj()).obj()); |
+} |
+ |
void ContentVideoView::DestroyContentVideoView(bool native_view_destroyed) { |
JNIEnv *env = AttachCurrentThread(); |
ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); |