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

Unified Diff: ui/android/java/src/org/chromium/ui/base/WindowAndroid.java

Issue 1144333004: Make WebView work for external displays (over Presentations). Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fixes according to boliu/jdduke's comments Created 5 years, 5 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
Index: ui/android/java/src/org/chromium/ui/base/WindowAndroid.java
diff --git a/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java b/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java
index 27579e6e3ad4a3888f486f246f4f13e1c17e0c20..071b33fb29738e7b5252f9c265e32e153a94f32b 100644
--- a/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java
+++ b/ui/android/java/src/org/chromium/ui/base/WindowAndroid.java
@@ -76,6 +76,12 @@ public class WindowAndroid {
protected Context mApplicationContext;
protected SparseArray<IntentCallback> mOutstandingIntents;
+ // For WebView to render properly on an external display through a Presentation we need to fetch
boliu 2015/07/16 14:36:56 Avoid mentioning webview. This is needed in chrome
+ // display metrics from the context provided by the Presentation.
+ // The display context differs from mApplicationContext in that mApplicationContext targets the
+ // primary display while the display context could target an external display (if WebView is
+ // shown in a Presentation).
+ protected WeakReference<Context> mDisplayContextRef;
// Ideally, this would be a SparseArray<String>, but there's no easy way to store a
// SparseArray<String> in a bundle during saveInstanceState(). So we use a HashMap and suppress
@@ -132,13 +138,13 @@ public class WindowAndroid {
*/
@SuppressLint("UseSparseArrays")
public WindowAndroid(Context context) {
- assert context == context.getApplicationContext();
- mApplicationContext = context;
+ mApplicationContext = context.getApplicationContext();
boliu 2015/10/20 15:07:22 probably at a comment there that context may be th
+ mDisplayContextRef = new WeakReference<Context>(context);
mOutstandingIntents = new SparseArray<IntentCallback>();
mIntentErrors = new HashMap<Integer, String>();
mVSyncMonitor = new VSyncMonitor(context, mVSyncListener);
- mAccessibilityManager = (AccessibilityManager)
- context.getSystemService(Context.ACCESSIBILITY_SERVICE);
+ mAccessibilityManager = (AccessibilityManager) mApplicationContext.getSystemService(
+ Context.ACCESSIBILITY_SERVICE);
}
/**
@@ -562,6 +568,11 @@ public class WindowAndroid {
});
}
+ @CalledByNative
+ private Context getDisplayContext() {
+ return mDisplayContextRef.get();
+ }
+
/**
* Update whether the placeholder is 'drawn' based on whether an animation is running
* or touch exploration is enabled - if either of those are true, we call

Powered by Google App Engine
This is Rietveld 408576698