Revert "Add PowerSaveBlocker in ContentVideoView"
This reverts commit fae0fbdd42d6d367c67a35e689742f0e4debacca.
diff --git a/content/browser/android/content_video_view.cc b/content/browser/android/content_video_view.cc
index 73e111d..4a0fdc6 100644
--- a/content/browser/android/content_video_view.cc
+++ b/content/browser/android/content_video_view.cc
@@ -7,7 +7,6 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "content/browser/android/browser_media_player_manager.h"
-#include "content/browser/power_save_blocker_impl.h"
#include "content/common/android/surface_texture_peer.h"
#include "content/public/common/content_switches.h"
#include "jni/ContentVideoView_jni.h"
@@ -51,7 +50,6 @@
Java_ContentVideoView_createContentVideoView(env, context.obj(),
reinterpret_cast<int>(this), client.obj()).obj());
g_content_video_view = this;
- CreatePowerSaveBlocker();
}
ContentVideoView::~ContentVideoView() {
@@ -63,17 +61,14 @@
void ContentVideoView::OpenVideo() {
JNIEnv *env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env);
- if (!content_video_view.is_null()) {
- CreatePowerSaveBlocker();
+ if (!content_video_view.is_null())
Java_ContentVideoView_openVideo(env, content_video_view.obj());
- }
}
void ContentVideoView::OnMediaPlayerError(int error_type) {
JNIEnv *env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env);
if (!content_video_view.is_null()) {
- power_save_blocker_.reset();
Java_ContentVideoView_onMediaPlayerError(env, content_video_view.obj(),
error_type);
}
@@ -100,10 +95,8 @@
void ContentVideoView::OnPlaybackComplete() {
JNIEnv *env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env);
- if (!content_video_view.is_null()) {
- power_save_blocker_.reset();
+ if (!content_video_view.is_null())
Java_ContentVideoView_onPlaybackComplete(env, content_video_view.obj());
- }
}
void ContentVideoView::OnExitFullscreen() {
@@ -147,18 +140,15 @@
}
void ContentVideoView::Play(JNIEnv*, jobject obj) {
- CreatePowerSaveBlocker();
manager_->FullscreenPlayerPlay();
}
void ContentVideoView::Pause(JNIEnv*, jobject obj) {
- power_save_blocker_.reset();
manager_->FullscreenPlayerPause();
}
void ContentVideoView::ExitFullscreen(
JNIEnv*, jobject, jboolean release_media_player) {
- power_save_blocker_.reset();
j_content_video_view_.reset();
manager_->ExitFullscreen(release_media_player);
}
@@ -182,35 +172,13 @@
return j_content_video_view_.get(env);
}
-gfx::NativeView ContentVideoView::GetNativeView() {
- JNIEnv* env = AttachCurrentThread();
- ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env);
- if (content_video_view.is_null())
- return NULL;
-
- return reinterpret_cast<gfx::NativeView>(
- Java_ContentVideoView_getNativeViewAndroid(env,
- content_video_view.obj()));
-
-}
-
void ContentVideoView::DestroyContentVideoView(bool native_view_destroyed) {
JNIEnv *env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env);
if (!content_video_view.is_null()) {
- power_save_blocker_.reset();
Java_ContentVideoView_destroyContentVideoView(env,
content_video_view.obj(), native_view_destroyed);
j_content_video_view_.reset();
}
}
-
-void ContentVideoView::CreatePowerSaveBlocker() {
- if (power_save_blocker_) return;
- power_save_blocker_.reset(PowerSaveBlocker::Create(
- PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
- "Playing video").release());
- static_cast<PowerSaveBlockerImpl*>(power_save_blocker_.get())->
- InitDisplaySleepBlocker(GetNativeView());
-}
} // namespace content
diff --git a/content/browser/android/content_video_view.h b/content/browser/android/content_video_view.h
index 633b903..2a86830 100644
--- a/content/browser/android/content_video_view.h
+++ b/content/browser/android/content_video_view.h
@@ -13,12 +13,10 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/timer/timer.h"
-#include "ui/gfx/native_widget_types.h"
namespace content {
class BrowserMediaPlayerManager;
-class PowerSaveBlocker;
// Native mirror of ContentVideoView.java. This class is responsible for
// creating the Java video view and pass all the player status change to
@@ -82,23 +80,10 @@
// no further calls to the native object is allowed.
void DestroyContentVideoView(bool native_view_destroyed);
- // Returns the associated NativeView
- gfx::NativeView GetNativeView();
-
- void CreatePowerSaveBlocker();
-
// Object that manages the fullscreen media player. It is responsible for
// handling all the playback controls.
BrowserMediaPlayerManager* manager_;
- // PowerSaveBlock to keep screen on for fullscreen video.
- // There is already blocker when inline video started, and it requires the
- // ContentView's container displayed to take effect; but in WebView, apps
- // could use another container to hold ContentVideoView, and the blocker in
- // ContentView's container can not keep screen on; so we need another blocker
- // here, it is no harm, just an additonal blocker.
- scoped_ptr<PowerSaveBlocker> power_save_blocker_;
-
// Weak reference of corresponding Java object.
JavaObjectWeakGlobalRef j_content_video_view_;
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java b/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
index 0631f6d..c1fcd58 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java
@@ -34,16 +34,12 @@
import org.chromium.base.ThreadUtils;
import org.chromium.content.common.IChildProcessService;
import org.chromium.content.R;
-import org.chromium.ui.ViewAndroid;
-import org.chromium.ui.ViewAndroidDelegate;
-import org.chromium.ui.WindowAndroid;
@JNINamespace("content")
public class ContentVideoView
extends FrameLayout
implements ContentVideoViewControls.Delegate,
- SurfaceHolder.Callback, View.OnTouchListener, View.OnKeyListener,
- ViewAndroidDelegate {
+ SurfaceHolder.Callback, View.OnTouchListener, View.OnKeyListener {
private static final String TAG = "ContentVideoView";
@@ -102,9 +98,6 @@
// Progress view when the video is loading.
private View mProgressView;
- // The ViewAndroid is used to keep screen on during video playback.
- private ViewAndroid mViewAndroid;
-
private Surface mSurface;
private ContentVideoViewClient mClient;
@@ -216,7 +209,6 @@
ContentVideoViewClient client) {
super(context);
mNativeContentVideoView = nativeContentVideoView;
- mViewAndroid = new ViewAndroid(new WindowAndroid(context.getApplicationContext()), this);
mClient = client;
initResources(context);
mCurrentBufferPercentage = 0;
@@ -654,28 +646,6 @@
return super.onKeyDown(keyCode, event);
}
- @Override
- public View acquireAnchorView() {
- View anchorView = new View(getContext());
- addView(anchorView);
- return anchorView;
- }
-
- @Override
- public void setAnchorViewPosition(View view, float x, float y, float width, float height) {
- Log.e(TAG, "setAnchorViewPosition isn't implemented");
- }
-
- @Override
- public void releaseAnchorView(View anchorView) {
- removeView(anchorView);
- }
-
- @CalledByNative
- private long getNativeViewAndroid() {
- return mViewAndroid.getNativePointer();
- }
-
private static native ContentVideoView nativeGetSingletonJavaContentVideoView();
private native void nativeExitFullscreen(int nativeContentVideoView, boolean relaseMediaPlayer);
private native int nativeGetCurrentPosition(int nativeContentVideoView);