Commit aa1cb5a1 authored by b.kelemen@samsung.com's avatar b.kelemen@samsung.com

Partial revert of "Restart fullscreen video playback when switching back from background"

This CL partially reverts r242570 and r243346.

The functionality added in those patches has been removed while some refactoring part
has been kept because those make sense and also because some code came later would have
to be moved otherwise.

The suspend/resume fullscreen video logic does not work well when the browser
activity is destroyed when it is in the background. Unfortunately I could not
find a way to make it work for that case yet so it's better remove it.

BUG=323697

Review URL: https://codereview.chromium.org/157783004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251455 0039d316-1c4b-4281-b951-d872f2087c98
parent 174213ae
...@@ -45,7 +45,6 @@ ContentVideoView* ContentVideoView::GetInstance() { ...@@ -45,7 +45,6 @@ ContentVideoView* ContentVideoView::GetInstance() {
ContentVideoView::ContentVideoView( ContentVideoView::ContentVideoView(
BrowserMediaPlayerManager* manager) BrowserMediaPlayerManager* manager)
: manager_(manager), : manager_(manager),
fullscreen_state_(ENTERED),
weak_factory_(this) { weak_factory_(this) {
DCHECK(!g_content_video_view); DCHECK(!g_content_video_view);
j_content_video_view_ = CreateJavaObject(); j_content_video_view_ = CreateJavaObject();
...@@ -171,42 +170,14 @@ void ContentVideoView::Pause(JNIEnv*, jobject obj) { ...@@ -171,42 +170,14 @@ void ContentVideoView::Pause(JNIEnv*, jobject obj) {
void ContentVideoView::ExitFullscreen( void ContentVideoView::ExitFullscreen(
JNIEnv*, jobject, jboolean release_media_player) { JNIEnv*, jobject, jboolean release_media_player) {
power_save_blocker_.reset(); power_save_blocker_.reset();
if (fullscreen_state_ == SUSPENDED)
return;
j_content_video_view_.reset(); j_content_video_view_.reset();
manager_->ExitFullscreen(release_media_player); manager_->ExitFullscreen(release_media_player);
} }
void ContentVideoView::SuspendFullscreen() {
power_save_blocker_.reset();
if (fullscreen_state_ != ENTERED)
return;
fullscreen_state_ = SUSPENDED;
DestroyContentVideoView(false);
manager_->SuspendFullscreen();
}
void ContentVideoView::ResumeFullscreenIfSuspended() {
if (fullscreen_state_ != SUSPENDED)
return;
JNIEnv* env = AttachCurrentThread();
DCHECK(!GetJavaObject(env).obj());
fullscreen_state_ = RESUME;
j_content_video_view_ = CreateJavaObject();
CreatePowerSaveBlocker();
}
void ContentVideoView::SetSurface(JNIEnv* env, jobject obj, void ContentVideoView::SetSurface(JNIEnv* env, jobject obj,
jobject surface) { jobject surface) {
gfx::ScopedJavaSurface scoped_surface = manager_->SetVideoSurface(
gfx::ScopedJavaSurface::AcquireExternalSurface(surface); gfx::ScopedJavaSurface::AcquireExternalSurface(surface));
if (fullscreen_state_ == RESUME) {
DCHECK(surface);
manager_->ResumeFullscreen(scoped_surface.Pass());
fullscreen_state_ = ENTERED;
} else {
manager_->SetVideoSurface(scoped_surface.Pass());
}
} }
void ContentVideoView::RequestMediaMetadata(JNIEnv* env, jobject obj) { void ContentVideoView::RequestMediaMetadata(JNIEnv* env, jobject obj) {
......
...@@ -29,11 +29,6 @@ class ContentVideoView { ...@@ -29,11 +29,6 @@ class ContentVideoView {
public: public:
// Construct a ContentVideoView object. The |manager| will handle all the // Construct a ContentVideoView object. The |manager| will handle all the
// playback controls from the Java class. // playback controls from the Java class.
ContentVideoView(
const base::android::ScopedJavaLocalRef<jobject>& context,
const base::android::ScopedJavaLocalRef<jobject>& client,
BrowserMediaPlayerManager* manager);
explicit ContentVideoView(BrowserMediaPlayerManager* manager); explicit ContentVideoView(BrowserMediaPlayerManager* manager);
~ContentVideoView(); ~ContentVideoView();
...@@ -60,15 +55,6 @@ class ContentVideoView { ...@@ -60,15 +55,6 @@ class ContentVideoView {
// as we are quitting the app. // as we are quitting the app.
void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player); void ExitFullscreen(JNIEnv*, jobject, jboolean release_media_player);
// Supposed to be called when the application paused or stopped.
// Destroys the fullscreen view in a way that it can be recreated
// via ResumeFullscreenIfSuspended.
void SuspendFullscreen();
// Supposed to be called when the application switches back to foreground.
// Recreates the fullscreen view if it was suspended via SuspendFullscreen.
void ResumeFullscreenIfSuspended();
// Media control method called by the Java class. // Media control method called by the Java class.
void SeekTo(JNIEnv*, jobject obj, jint msec); void SeekTo(JNIEnv*, jobject obj, jint msec);
void Play(JNIEnv*, jobject obj); void Play(JNIEnv*, jobject obj);
...@@ -117,12 +103,6 @@ class ContentVideoView { ...@@ -117,12 +103,6 @@ class ContentVideoView {
// Weak reference of corresponding Java object. // Weak reference of corresponding Java object.
JavaObjectWeakGlobalRef j_content_video_view_; JavaObjectWeakGlobalRef j_content_video_view_;
enum FullscreenState {
ENTERED,
SUSPENDED,
RESUME
} fullscreen_state_;
// Weak pointer for posting tasks. // Weak pointer for posting tasks.
base::WeakPtrFactory<ContentVideoView> weak_factory_; base::WeakPtrFactory<ContentVideoView> weak_factory_;
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "base/values.h" #include "base/values.h"
#include "cc/layers/layer.h" #include "cc/layers/layer.h"
#include "cc/output/begin_frame_args.h" #include "cc/output/begin_frame_args.h"
#include "content/browser/android/content_video_view.h"
#include "content/browser/android/gesture_event_type.h" #include "content/browser/android/gesture_event_type.h"
#include "content/browser/android/interstitial_page_delegate_android.h" #include "content/browser/android/interstitial_page_delegate_android.h"
#include "content/browser/android/load_url_params.h" #include "content/browser/android/load_url_params.h"
...@@ -416,7 +415,6 @@ void ContentViewCoreImpl::OnShow(JNIEnv* env, jobject obj) { ...@@ -416,7 +415,6 @@ void ContentViewCoreImpl::OnShow(JNIEnv* env, jobject obj) {
void ContentViewCoreImpl::Show() { void ContentViewCoreImpl::Show() {
GetWebContents()->WasShown(); GetWebContents()->WasShown();
ResumeVideo();
} }
void ContentViewCoreImpl::Hide() { void ContentViewCoreImpl::Hide() {
...@@ -428,13 +426,6 @@ void ContentViewCoreImpl::PauseVideo() { ...@@ -428,13 +426,6 @@ void ContentViewCoreImpl::PauseVideo() {
RenderViewHost* host = web_contents_->GetRenderViewHost(); RenderViewHost* host = web_contents_->GetRenderViewHost();
if (host) if (host)
host->Send(new ViewMsg_PauseVideo(host->GetRoutingID())); host->Send(new ViewMsg_PauseVideo(host->GetRoutingID()));
if (ContentVideoView::GetInstance())
ContentVideoView::GetInstance()->SuspendFullscreen();
}
void ContentViewCoreImpl::ResumeVideo() {
if (ContentVideoView::GetInstance())
ContentVideoView::GetInstance()->ResumeFullscreenIfSuspended();
} }
void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) { void ContentViewCoreImpl::PauseOrResumeGeolocation(bool should_pause) {
......
...@@ -66,7 +66,6 @@ class ContentViewCoreImpl : public ContentViewCore, ...@@ -66,7 +66,6 @@ class ContentViewCoreImpl : public ContentViewCore,
virtual void RequestContentClipping(const gfx::Rect& clipping, virtual void RequestContentClipping(const gfx::Rect& clipping,
const gfx::Size& content_size) OVERRIDE; const gfx::Size& content_size) OVERRIDE;
virtual void PauseVideo() OVERRIDE; virtual void PauseVideo() OVERRIDE;
virtual void ResumeVideo() OVERRIDE;
virtual void PauseOrResumeGeolocation(bool should_pause) OVERRIDE; virtual void PauseOrResumeGeolocation(bool should_pause) OVERRIDE;
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
...@@ -116,6 +116,7 @@ BrowserMediaPlayerManager::BrowserMediaPlayerManager( ...@@ -116,6 +116,7 @@ BrowserMediaPlayerManager::BrowserMediaPlayerManager(
: WebContentsObserver(WebContents::FromRenderViewHost(render_view_host)), : WebContentsObserver(WebContents::FromRenderViewHost(render_view_host)),
fullscreen_player_id_(-1), fullscreen_player_id_(-1),
pending_fullscreen_player_id_(-1), pending_fullscreen_player_id_(-1),
fullscreen_player_is_released_(false),
web_contents_(WebContents::FromRenderViewHost(render_view_host)), web_contents_(WebContents::FromRenderViewHost(render_view_host)),
weak_ptr_factory_(this) { weak_ptr_factory_(this) {
} }
...@@ -156,6 +157,10 @@ bool BrowserMediaPlayerManager::OnMessageReceived(const IPC::Message& msg) { ...@@ -156,6 +157,10 @@ bool BrowserMediaPlayerManager::OnMessageReceived(const IPC::Message& msg) {
void BrowserMediaPlayerManager::FullscreenPlayerPlay() { void BrowserMediaPlayerManager::FullscreenPlayerPlay() {
MediaPlayerAndroid* player = GetFullscreenPlayer(); MediaPlayerAndroid* player = GetFullscreenPlayer();
if (player) { if (player) {
if (fullscreen_player_is_released_) {
video_view_->OpenVideo();
fullscreen_player_is_released_ = false;
}
player->Start(); player->Start();
Send(new MediaPlayerMsg_DidMediaPlayerPlay( Send(new MediaPlayerMsg_DidMediaPlayerPlay(
routing_id(), fullscreen_player_id_)); routing_id(), fullscreen_player_id_));
...@@ -207,19 +212,6 @@ void BrowserMediaPlayerManager::ExitFullscreen(bool release_media_player) { ...@@ -207,19 +212,6 @@ void BrowserMediaPlayerManager::ExitFullscreen(bool release_media_player) {
player->SetVideoSurface(gfx::ScopedJavaSurface()); player->SetVideoSurface(gfx::ScopedJavaSurface());
} }
void BrowserMediaPlayerManager::SuspendFullscreen() {
MediaPlayerAndroid* player = GetFullscreenPlayer();
if (player)
player->SetVideoSurface(gfx::ScopedJavaSurface());
}
void BrowserMediaPlayerManager::ResumeFullscreen(
gfx::ScopedJavaSurface surface) {
MediaPlayerAndroid* player = GetFullscreenPlayer();
if (player)
player->SetVideoSurface(surface.Pass());
}
void BrowserMediaPlayerManager::OnTimeUpdate(int player_id, void BrowserMediaPlayerManager::OnTimeUpdate(int player_id,
base::TimeDelta current_time) { base::TimeDelta current_time) {
Send(new MediaPlayerMsg_MediaTimeUpdate( Send(new MediaPlayerMsg_MediaTimeUpdate(
...@@ -576,6 +568,8 @@ void BrowserMediaPlayerManager::OnReleaseResources(int player_id) { ...@@ -576,6 +568,8 @@ void BrowserMediaPlayerManager::OnReleaseResources(int player_id) {
MediaPlayerAndroid* player = GetPlayer(player_id); MediaPlayerAndroid* player = GetPlayer(player_id);
if (player) if (player)
player->Release(); player->Release();
if (player_id == fullscreen_player_id_)
fullscreen_player_is_released_ = true;
#if defined(VIDEO_HOLE) #if defined(VIDEO_HOLE)
WebContentsViewAndroid* view = WebContentsViewAndroid* view =
......
...@@ -62,8 +62,6 @@ class CONTENT_EXPORT BrowserMediaPlayerManager ...@@ -62,8 +62,6 @@ class CONTENT_EXPORT BrowserMediaPlayerManager
virtual void FullscreenPlayerSeek(int msec); virtual void FullscreenPlayerSeek(int msec);
virtual void ExitFullscreen(bool release_media_player); virtual void ExitFullscreen(bool release_media_player);
virtual void SetVideoSurface(gfx::ScopedJavaSurface surface); virtual void SetVideoSurface(gfx::ScopedJavaSurface surface);
virtual void SuspendFullscreen();
virtual void ResumeFullscreen(gfx::ScopedJavaSurface surface);
// Called when browser player wants the renderer media element to seek. // Called when browser player wants the renderer media element to seek.
// Any actual seek started by renderer will be handled by browser in OnSeek(). // Any actual seek started by renderer will be handled by browser in OnSeek().
...@@ -233,6 +231,9 @@ class CONTENT_EXPORT BrowserMediaPlayerManager ...@@ -233,6 +231,9 @@ class CONTENT_EXPORT BrowserMediaPlayerManager
// The player ID pending to enter fullscreen. // The player ID pending to enter fullscreen.
int pending_fullscreen_player_id_; int pending_fullscreen_player_id_;
// Whether the fullscreen player has been Release()-d.
bool fullscreen_player_is_released_;
WebContents* web_contents_; WebContents* web_contents_;
// Object for retrieving resources media players. // Object for retrieving resources media players.
......
...@@ -63,7 +63,6 @@ class CONTENT_EXPORT ContentViewCore { ...@@ -63,7 +63,6 @@ class CONTENT_EXPORT ContentViewCore {
virtual void RequestContentClipping(const gfx::Rect& clipping, virtual void RequestContentClipping(const gfx::Rect& clipping,
const gfx::Size& content_size) = 0; const gfx::Size& content_size) = 0;
virtual void PauseVideo() = 0; virtual void PauseVideo() = 0;
virtual void ResumeVideo() = 0;
virtual void PauseOrResumeGeolocation(bool should_pause) = 0; virtual void PauseOrResumeGeolocation(bool should_pause) = 0;
// Observer callback for frame metadata updates. // Observer callback for frame metadata updates.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment