| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.app.AlertDialog; | 8 import android.app.AlertDialog; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.ContextWrapper; | 10 import android.content.ContextWrapper; |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 @CalledByNative | 412 @CalledByNative |
| 413 private static ContentVideoView createContentVideoView( | 413 private static ContentVideoView createContentVideoView( |
| 414 ContentViewCore contentViewCore, long nativeContentVideoView) { | 414 ContentViewCore contentViewCore, long nativeContentVideoView) { |
| 415 Context context = contentViewCore.getContext(); | 415 Context context = contentViewCore.getContext(); |
| 416 ThreadUtils.assertOnUiThread(); | 416 ThreadUtils.assertOnUiThread(); |
| 417 // The context needs be Activity to create the ContentVideoView correctl
y. | 417 // The context needs be Activity to create the ContentVideoView correctl
y. |
| 418 if (!isActivityContext(context)) { | 418 if (!isActivityContext(context)) { |
| 419 Log.e(TAG, "Wrong type of context, can't create fullscreen video"); | 419 Log.e(TAG, "Wrong type of context, can't create fullscreen video"); |
| 420 return null; | 420 return null; |
| 421 } | 421 } |
| 422 return new ContentVideoView(context, nativeContentVideoView, | 422 ContentVideoViewClient client = contentViewCore.getContentVideoViewClien
t(); |
| 423 contentViewCore.getContentVideoViewClient()); | 423 ContentVideoView videoView = new ContentVideoView(context, nativeContent
VideoView, client); |
| 424 client.enterFullscreenVideo(videoView); |
| 425 return videoView; |
| 424 } | 426 } |
| 425 | 427 |
| 426 private static boolean isActivityContext(Context context) { | 428 private static boolean isActivityContext(Context context) { |
| 427 // Only retrieve the base context if the supplied context is a ContextWr
apper but not | 429 // Only retrieve the base context if the supplied context is a ContextWr
apper but not |
| 428 // an Activity, given that Activity is already a subclass of ContextWrap
per. | 430 // an Activity, given that Activity is already a subclass of ContextWrap
per. |
| 429 if (context instanceof ContextWrapper && !(context instanceof Activity))
{ | 431 if (context instanceof ContextWrapper && !(context instanceof Activity))
{ |
| 430 context = ((ContextWrapper) context).getBaseContext(); | 432 context = ((ContextWrapper) context).getBaseContext(); |
| 431 } | 433 } |
| 432 return context instanceof Activity; | 434 return context instanceof Activity; |
| 433 } | 435 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 467 |
| 466 /** | 468 /** |
| 467 * This method shall only be called by native and exitFullscreen, | 469 * This method shall only be called by native and exitFullscreen, |
| 468 * To exit fullscreen, use exitFullscreen in Java. | 470 * To exit fullscreen, use exitFullscreen in Java. |
| 469 */ | 471 */ |
| 470 @CalledByNative | 472 @CalledByNative |
| 471 protected void destroyContentVideoView(boolean nativeViewDestroyed) { | 473 protected void destroyContentVideoView(boolean nativeViewDestroyed) { |
| 472 if (mVideoSurfaceView != null) { | 474 if (mVideoSurfaceView != null) { |
| 473 removeSurfaceView(); | 475 removeSurfaceView(); |
| 474 setVisibility(View.GONE); | 476 setVisibility(View.GONE); |
| 477 |
| 478 // To prevent re-entrance, call this after removeSurfaceView. |
| 479 mClient.exitFullscreenVideo(); |
| 475 } | 480 } |
| 476 if (nativeViewDestroyed) { | 481 if (nativeViewDestroyed) { |
| 477 mNativeContentVideoView = 0; | 482 mNativeContentVideoView = 0; |
| 478 } | 483 } |
| 479 } | 484 } |
| 480 | 485 |
| 481 public static ContentVideoView getContentVideoView() { | 486 public static ContentVideoView getContentVideoView() { |
| 482 return nativeGetSingletonJavaContentVideoView(); | 487 return nativeGetSingletonJavaContentVideoView(); |
| 483 } | 488 } |
| 484 | 489 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 513 private native void nativePlay(long nativeContentVideoView); | 518 private native void nativePlay(long nativeContentVideoView); |
| 514 private native void nativeSeekTo(long nativeContentVideoView, int msec); | 519 private native void nativeSeekTo(long nativeContentVideoView, int msec); |
| 515 private native void nativeSetSurface(long nativeContentVideoView, Surface su
rface); | 520 private native void nativeSetSurface(long nativeContentVideoView, Surface su
rface); |
| 516 private native void nativeRecordFullscreenPlayback( | 521 private native void nativeRecordFullscreenPlayback( |
| 517 long nativeContentVideoView, boolean isVideoPortrait, boolean isOrie
ntationPortrait); | 522 long nativeContentVideoView, boolean isVideoPortrait, boolean isOrie
ntationPortrait); |
| 518 private native void nativeRecordExitFullscreenPlayback( | 523 private native void nativeRecordExitFullscreenPlayback( |
| 519 long nativeContentVideoView, boolean isOrientationPortrait, | 524 long nativeContentVideoView, boolean isOrientationPortrait, |
| 520 long playbackDurationBeforeOrientationChange, | 525 long playbackDurationBeforeOrientationChange, |
| 521 long playbackDurationAfterOrientationChange); | 526 long playbackDurationAfterOrientationChange); |
| 522 } | 527 } |
| OLD | NEW |