Index: ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java |
diff --git a/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java |
index 895d3472ca7bc446f0d3363b0e9d512c1a359433..89325fb96f3d4f4a1a134e63a611b809d89dae04 100644 |
--- a/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java |
+++ b/ui/android/java/src/org/chromium/ui/gfx/DeviceDisplayInfo.java |
@@ -5,6 +5,8 @@ |
package org.chromium.ui.gfx; |
import android.content.Context; |
+import android.content.ComponentCallbacks; |
+import android.content.res.Configuration; |
import android.graphics.PixelFormat; |
import android.os.Build; |
import android.util.DisplayMetrics; |
@@ -124,6 +126,26 @@ public class DeviceDisplayInfo { |
return mAppContext.getResources().getConfiguration().smallestScreenWidthDp; |
} |
+ private void registerListener() { |
+ mAppContext.registerComponentCallbacks( |
+ new ComponentCallbacks() { |
+ @Override |
+ public void onConfigurationChanged(Configuration configuration) { |
+ updateNativeSharedDisplayInfo(); |
+ } |
+ |
+ @Override |
+ public void onLowMemory() { |
+ } |
+ }); |
+ } |
+ |
+ private void updateNativeSharedDisplayInfo() { |
+ nativeUpdateSharedDeviceDisplayInfo(getDisplayHeight(), |
+ getDisplayWidth(), getBitsPerPixel(), getBitsPerComponent(), |
+ getDIPScale(), getSmallestDIPWidth()); |
+ } |
+ |
private Display getDisplay() { |
return mWinManager.getDefaultDisplay(); |
} |
@@ -137,8 +159,20 @@ public class DeviceDisplayInfo { |
* @param context A context to use. |
* @return DeviceDisplayInfo associated with a given Context. |
*/ |
- @CalledByNative |
public static DeviceDisplayInfo create(Context context) { |
return new DeviceDisplayInfo(context); |
} |
+ |
+ @CalledByNative |
+ private static DeviceDisplayInfo createWithListener(Context context) { |
+ DeviceDisplayInfo deviceDisplayInfo = new DeviceDisplayInfo(context); |
+ deviceDisplayInfo.registerListener(); |
+ return deviceDisplayInfo; |
+ } |
+ |
+ private native void nativeUpdateSharedDeviceDisplayInfo(int displayHeight, |
+ int displayWidth, int bitsPerPixel, |
+ int bitsPerComponent, double dipScale, |
+ int smallestDIPWidth); |
+ |
} |