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

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

Issue 778183002: [android_webview] Correctly handle ContextWrapper in AwContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2214
Patch Set: Created 6 years 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 | « content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java ('k') | 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/ContentViewCore.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 8e4645f648db40141090dbb4602750968261f22d..b5bdeaa766d7e9f73204643ceeb0659a62766ae7 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -10,6 +10,7 @@ import android.app.SearchManager;
import android.content.ClipboardManager;
import android.content.ContentResolver;
import android.content.Context;
+import android.content.ContextWrapper;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
@@ -358,6 +359,22 @@ public class ContentViewCore
public void onSmartClipDataExtracted(String text, String html, Rect clipRect);
}
+ /**
+ * Cast from Context to Activity taking ContextWrapper into account.
+ */
+ public static Activity activityFromContext(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 Activity) {
+ return ((Activity) context);
+ } else if (context instanceof ContextWrapper) {
+ context = ((ContextWrapper) context).getBaseContext();
+ return activityFromContext(context);
+ } else {
+ return null;
+ }
+ }
+
private final Context mContext;
private ViewGroup mContainerView;
private InternalAccessDelegate mContainerViewInternals;
@@ -1930,7 +1947,7 @@ public class ContentViewCore
i.putExtra(SearchManager.EXTRA_NEW_SEARCH, true);
i.putExtra(SearchManager.QUERY, query);
i.putExtra(Browser.EXTRA_APPLICATION_ID, getContext().getPackageName());
- if (!(getContext() instanceof Activity)) {
+ if (activityFromContext(getContext()) == null) {
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
try {
« no previous file with comments | « content/public/android/java/src/org/chromium/content/browser/ContentVideoView.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698