Commit b3a4d2b1 authored by igsolla@chromium.org's avatar igsolla@chromium.org

Fix ContentVideoView to support a ContextWrapper.

BUG=400755

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287764 0039d316-1c4b-4281-b951-d872f2087c98
parent c6163973
......@@ -7,6 +7,7 @@ package org.chromium.content.browser;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.ContextWrapper;
import android.content.DialogInterface;
import android.util.Log;
import android.view.Gravity;
......@@ -377,8 +378,8 @@ public class ContentVideoView extends FrameLayout
boolean legacy) {
ThreadUtils.assertOnUiThread();
// The context needs be Activity to create the ContentVideoView correctly.
if (!(context instanceof Activity)) {
Log.w(TAG, "Wrong type of context, can't create fullscreen video");
if (!isActivityContext(context)) {
Log.e(TAG, "Wrong type of context, can't create fullscreen video");
return null;
}
ContentVideoView videoView = null;
......@@ -394,6 +395,15 @@ public class ContentVideoView extends FrameLayout
return null;
}
private static boolean isActivityContext(Context context) {
// Only retrieve the base context if the supplied context is a ContextWrapper but not
// an Activity, given that Activity is already a subclass of ContextWrapper.
if (context instanceof ContextWrapper && !(context instanceof Activity)) {
context = ((ContextWrapper) context).getBaseContext();
}
return context instanceof Activity;
}
public void removeSurfaceView() {
removeView(mVideoSurfaceView);
removeView(mProgressView);
......
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