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

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

Issue 440143002: Fix ContentVideoView to support a ContextWrapper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix failing tests. Created 6 years, 4 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 7cd3b6ef79fa2c87017696dbe3ac97b8fa42ea6c..6113a087d19ff0c0bac3150518786db2510507af 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
@@ -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);
« 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