| 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 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ | 5 #ifndef CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ | 6 #define CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include "base/android/jni_weak_ref.h" | 10 #include "base/android/jni_weak_ref.h" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 17 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
| 18 | 18 |
| 19 namespace content { | 19 namespace content { |
| 20 | 20 |
| 21 class BrowserMediaPlayerManager; | 21 class BrowserMediaPlayerManager; |
| 22 class PowerSaveBlocker; | |
| 23 | 22 |
| 24 // Native mirror of ContentVideoView.java. This class is responsible for | 23 // Native mirror of ContentVideoView.java. This class is responsible for |
| 25 // creating the Java video view and pass all the player status change to | 24 // creating the Java video view and pass all the player status change to |
| 26 // it. It accepts media control from Java class, and forwards it to | 25 // it. It accepts media control from Java class, and forwards it to |
| 27 // MediaPlayerManagerImpl. | 26 // MediaPlayerManagerImpl. |
| 28 class ContentVideoView { | 27 class ContentVideoView { |
| 29 public: | 28 public: |
| 30 // Construct a ContentVideoView object. The |manager| will handle all the | 29 // Construct a ContentVideoView object. The |manager| will handle all the |
| 31 // playback controls from the Java class. | 30 // playback controls from the Java class. |
| 32 explicit ContentVideoView(BrowserMediaPlayerManager* manager); | 31 explicit ContentVideoView(BrowserMediaPlayerManager* manager); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 long playback_duration_in_milliseconds_before_orientation_change, | 79 long playback_duration_in_milliseconds_before_orientation_change, |
| 81 long playback_duration_in_milliseconds_after_orientation_change); | 80 long playback_duration_in_milliseconds_after_orientation_change); |
| 82 | 81 |
| 83 // Return the corresponing ContentVideoView Java object if any. | 82 // Return the corresponing ContentVideoView Java object if any. |
| 84 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env); | 83 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(JNIEnv* env); |
| 85 | 84 |
| 86 private: | 85 private: |
| 87 // Creates the corresponding ContentVideoView Java object. | 86 // Creates the corresponding ContentVideoView Java object. |
| 88 JavaObjectWeakGlobalRef CreateJavaObject(); | 87 JavaObjectWeakGlobalRef CreateJavaObject(); |
| 89 | 88 |
| 90 // Returns the associated NativeView | |
| 91 gfx::NativeView GetNativeView(); | |
| 92 | |
| 93 void CreatePowerSaveBlocker(); | |
| 94 | |
| 95 // Object that manages the fullscreen media player. It is responsible for | 89 // Object that manages the fullscreen media player. It is responsible for |
| 96 // handling all the playback controls. | 90 // handling all the playback controls. |
| 97 BrowserMediaPlayerManager* manager_; | 91 BrowserMediaPlayerManager* manager_; |
| 98 | 92 |
| 99 // PowerSaveBlock to keep screen on for fullscreen video. | |
| 100 // There is already blocker when inline video started, and it requires the | |
| 101 // ContentView's container displayed to take effect; but in WebView, apps | |
| 102 // could use another container to hold ContentVideoView, and the blocker in | |
| 103 // ContentView's container can not keep screen on; so we need another blocker | |
| 104 // here, it is no harm, just an additonal blocker. | |
| 105 scoped_ptr<PowerSaveBlocker> power_save_blocker_; | |
| 106 | |
| 107 // Weak reference of corresponding Java object. | 93 // Weak reference of corresponding Java object. |
| 108 JavaObjectWeakGlobalRef j_content_video_view_; | 94 JavaObjectWeakGlobalRef j_content_video_view_; |
| 109 | 95 |
| 110 // Weak pointer for posting tasks. | 96 // Weak pointer for posting tasks. |
| 111 base::WeakPtrFactory<ContentVideoView> weak_factory_; | 97 base::WeakPtrFactory<ContentVideoView> weak_factory_; |
| 112 | 98 |
| 113 DISALLOW_COPY_AND_ASSIGN(ContentVideoView); | 99 DISALLOW_COPY_AND_ASSIGN(ContentVideoView); |
| 114 }; | 100 }; |
| 115 | 101 |
| 116 } // namespace content | 102 } // namespace content |
| 117 | 103 |
| 118 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ | 104 #endif // CONTENT_BROWSER_ANDROID_CONTENT_VIDEO_VIEW_H_ |
| OLD | NEW |