Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: content/browser/android/content_video_view.cc

Issue 157783004: Partial revert of "Restart fullscreen video playback when switching back from background" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "content/browser/android/content_view_core_impl.h" 10 #include "content/browser/android/content_view_core_impl.h"
(...skipping 27 matching lines...) Expand all
38 return RegisterNativesImpl(env); 38 return RegisterNativesImpl(env);
39 } 39 }
40 40
41 ContentVideoView* ContentVideoView::GetInstance() { 41 ContentVideoView* ContentVideoView::GetInstance() {
42 return g_content_video_view; 42 return g_content_video_view;
43 } 43 }
44 44
45 ContentVideoView::ContentVideoView( 45 ContentVideoView::ContentVideoView(
46 BrowserMediaPlayerManager* manager) 46 BrowserMediaPlayerManager* manager)
47 : manager_(manager), 47 : manager_(manager),
48 fullscreen_state_(ENTERED),
49 weak_factory_(this) { 48 weak_factory_(this) {
50 DCHECK(!g_content_video_view); 49 DCHECK(!g_content_video_view);
51 j_content_video_view_ = CreateJavaObject(); 50 j_content_video_view_ = CreateJavaObject();
52 g_content_video_view = this; 51 g_content_video_view = this;
53 CreatePowerSaveBlocker(); 52 CreatePowerSaveBlocker();
54 } 53 }
55 54
56 ContentVideoView::~ContentVideoView() { 55 ContentVideoView::~ContentVideoView() {
57 DCHECK(g_content_video_view); 56 DCHECK(g_content_video_view);
58 DestroyContentVideoView(true); 57 DestroyContentVideoView(true);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 163 }
165 164
166 void ContentVideoView::Pause(JNIEnv*, jobject obj) { 165 void ContentVideoView::Pause(JNIEnv*, jobject obj) {
167 power_save_blocker_.reset(); 166 power_save_blocker_.reset();
168 manager_->FullscreenPlayerPause(); 167 manager_->FullscreenPlayerPause();
169 } 168 }
170 169
171 void ContentVideoView::ExitFullscreen( 170 void ContentVideoView::ExitFullscreen(
172 JNIEnv*, jobject, jboolean release_media_player) { 171 JNIEnv*, jobject, jboolean release_media_player) {
173 power_save_blocker_.reset(); 172 power_save_blocker_.reset();
174 if (fullscreen_state_ == SUSPENDED)
175 return;
176 j_content_video_view_.reset(); 173 j_content_video_view_.reset();
177 manager_->ExitFullscreen(release_media_player); 174 manager_->ExitFullscreen(release_media_player);
178 } 175 }
179 176
180 void ContentVideoView::SuspendFullscreen() {
181 power_save_blocker_.reset();
182 if (fullscreen_state_ != ENTERED)
183 return;
184 fullscreen_state_ = SUSPENDED;
185 DestroyContentVideoView(false);
186 manager_->SuspendFullscreen();
187 }
188
189 void ContentVideoView::ResumeFullscreenIfSuspended() {
190 if (fullscreen_state_ != SUSPENDED)
191 return;
192 JNIEnv* env = AttachCurrentThread();
193 DCHECK(!GetJavaObject(env).obj());
194 fullscreen_state_ = RESUME;
195 j_content_video_view_ = CreateJavaObject();
196 CreatePowerSaveBlocker();
197 }
198
199 void ContentVideoView::SetSurface(JNIEnv* env, jobject obj, 177 void ContentVideoView::SetSurface(JNIEnv* env, jobject obj,
200 jobject surface) { 178 jobject surface) {
201 gfx::ScopedJavaSurface scoped_surface = 179 manager_->SetVideoSurface(
202 gfx::ScopedJavaSurface::AcquireExternalSurface(surface); 180 gfx::ScopedJavaSurface::AcquireExternalSurface(surface));
203 if (fullscreen_state_ == RESUME) {
204 DCHECK(surface);
205 manager_->ResumeFullscreen(scoped_surface.Pass());
206 fullscreen_state_ = ENTERED;
207 } else {
208 manager_->SetVideoSurface(scoped_surface.Pass());
209 }
210 } 181 }
211 182
212 void ContentVideoView::RequestMediaMetadata(JNIEnv* env, jobject obj) { 183 void ContentVideoView::RequestMediaMetadata(JNIEnv* env, jobject obj) {
213 base::MessageLoop::current()->PostTask( 184 base::MessageLoop::current()->PostTask(
214 FROM_HERE, 185 FROM_HERE,
215 base::Bind(&ContentVideoView::UpdateMediaMetadata, 186 base::Bind(&ContentVideoView::UpdateMediaMetadata,
216 weak_factory_.GetWeakPtr())); 187 weak_factory_.GetWeakPtr()));
217 } 188 }
218 189
219 ScopedJavaLocalRef<jobject> ContentVideoView::GetJavaObject(JNIEnv* env) { 190 ScopedJavaLocalRef<jobject> ContentVideoView::GetJavaObject(JNIEnv* env) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 void ContentVideoView::DestroyContentVideoView(bool native_view_destroyed) { 231 void ContentVideoView::DestroyContentVideoView(bool native_view_destroyed) {
261 JNIEnv* env = AttachCurrentThread(); 232 JNIEnv* env = AttachCurrentThread();
262 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env); 233 ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env);
263 if (!content_video_view.is_null()) { 234 if (!content_video_view.is_null()) {
264 Java_ContentVideoView_destroyContentVideoView(env, 235 Java_ContentVideoView_destroyContentVideoView(env,
265 content_video_view.obj(), native_view_destroyed); 236 content_video_view.obj(), native_view_destroyed);
266 j_content_video_view_.reset(); 237 j_content_video_view_.reset();
267 } 238 }
268 } 239 }
269 } // namespace content 240 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_video_view.h ('k') | content/browser/android/content_view_core_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698