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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java

Issue 682223006: Make ContentVideoView accept application contexts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698