Index: content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java |
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 fbecdc3372d26cee5100510f3b80d9a30166593e..a8da8db640471854d28eb0ce02a71b864846ca76 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 |
@@ -134,9 +134,9 @@ public class ContentVideoView extends FrameLayout |
} else { |
// if user quickly switched the orientation back and force, don't |
// count it in UMA. |
- if (!mPossibleAccidentalChange && |
- isOrientationPortrait() == mInitialOrientation && |
- System.currentTimeMillis() - mOrientationChangedTime < 5000) { |
+ if (!mPossibleAccidentalChange |
+ && isOrientationPortrait() == mInitialOrientation |
+ && System.currentTimeMillis() - mOrientationChangedTime < 5000) { |
mPossibleAccidentalChange = true; |
} |
} |
@@ -238,6 +238,11 @@ public class ContentVideoView extends FrameLayout |
mCurrentState = STATE_ERROR; |
+ if (!isActivityContext(getContext())) { |
+ Log.w(TAG, "Unable to show alert dialog because it requires an activity context"); |
+ return; |
+ } |
+ |
/* Pop up an error dialog so the user knows that |
* something bad has happened. Only try and pop up the dialog |
* if we're attached to a window. When we're going away and no |
@@ -419,12 +424,7 @@ public class ContentVideoView extends FrameLayout |
private static ContentVideoView createContentVideoView( |
ContentViewCore contentViewCore, long nativeContentVideoView) { |
ThreadUtils.assertOnUiThread(); |
- // The context needs be Activity to create the ContentVideoView correctly. |
Context context = contentViewCore.getContext(); |
- if (!isActivityContext(context)) { |
- Log.e(TAG, "Wrong type of context, can't create fullscreen video"); |
- return null; |
- } |
ContentVideoViewClient client = contentViewCore.getContentVideoViewClient(); |
ContentVideoView videoView = new ContentVideoView(context, nativeContentVideoView, client); |
client.enterFullscreenVideo(videoView); |
@@ -436,6 +436,7 @@ public class ContentVideoView extends FrameLayout |
// an Activity, given that Activity is already a subclass of ContextWrapper. |
if (context instanceof ContextWrapper && !(context instanceof Activity)) { |
context = ((ContextWrapper) context).getBaseContext(); |
+ return isActivityContext(context); |
} |
return context instanceof Activity; |
} |