Chromium Code Reviews| Index: android_webview/java/src/org/chromium/android_webview/AwContents.java |
| diff --git a/android_webview/java/src/org/chromium/android_webview/AwContents.java b/android_webview/java/src/org/chromium/android_webview/AwContents.java |
| index b48eb8790663a13fed6107c24f77967b78887ff4..9196128e0c4cdabd08a8c66c5882e01f9d89207b 100644 |
| --- a/android_webview/java/src/org/chromium/android_webview/AwContents.java |
| +++ b/android_webview/java/src/org/chromium/android_webview/AwContents.java |
| @@ -78,6 +78,7 @@ import org.chromium.ui.base.ActivityWindowAndroid; |
| import org.chromium.ui.base.PageTransition; |
| import org.chromium.ui.base.ViewAndroidDelegate; |
| import org.chromium.ui.base.WindowAndroid; |
| +import org.chromium.ui.display.DisplayAndroid.DisplayAndroidObserver; |
| import java.io.File; |
| import java.lang.annotation.Annotation; |
| @@ -99,8 +100,8 @@ import java.util.concurrent.Callable; |
| * continuous build & test in the open source SDK-based tree). |
| */ |
| @JNINamespace("android_webview") |
| -public class AwContents implements SmartClipProvider, |
| - PostMessageSender.PostMessageSenderDelegate { |
| +public class AwContents implements SmartClipProvider, PostMessageSender.PostMessageSenderDelegate, |
| + DisplayAndroidObserver { |
|
boliu
2016/10/18 00:26:25
use an inner class
Tima Vaisburd
2016/10/19 01:15:54
Done.
|
| private static final String TAG = "AwContents"; |
| private static final boolean TRACE = false; |
| private static final int NO_WARN = 0; |
| @@ -1065,10 +1066,7 @@ public class AwContents implements SmartClipProvider, |
| installWebContentsObserver(); |
| mSettings.setWebContents(webContents); |
| - float dipScale = mContentViewCore.getDeviceScaleFactor(); |
| - nativeSetDipScale(mNativeAwContents, dipScale); |
| - mLayoutSizer.setDIPScale(dipScale); |
| - mSettings.setDIPScale(dipScale); |
| + onDIPScaleChanged(mWindowAndroid.getWindowAndroid().getDisplay().getDIPScale()); |
| updateContentViewCoreVisibility(); |
| @@ -2275,6 +2273,20 @@ public class AwContents implements SmartClipProvider, |
| sentPortIds); |
| } |
| + // Implements DisplayAndroidObserver interface method. |
| + @Override |
| + public void onRotationChanged(int rotation) {} |
| + |
| + // Implements DisplayAndroidObserver interface method. |
| + @Override |
| + public void onDIPScaleChanged(float dipScale) { |
| + if (TRACE) Log.i(TAG, "%s onDIPScaleChanged dipScale=%f", this, dipScale); |
| + |
| + nativeSetDipScale(mNativeAwContents, dipScale); |
| + mLayoutSizer.setDIPScale(dipScale); |
| + mSettings.setDIPScale(dipScale); |
| + } |
| + |
| /** |
| * Creates a message channel and returns the ports for each end of the channel. |
| */ |
| @@ -2384,6 +2396,7 @@ public class AwContents implements SmartClipProvider, |
| if (TRACE) Log.i(TAG, "%s onAttachedToWindow", this); |
| mTemporarilyDetached = false; |
| mAwViewMethods.onAttachedToWindow(); |
| + mWindowAndroid.getWindowAndroid().getDisplay().addObserver(this); |
| } |
| /** |
| @@ -2392,6 +2405,7 @@ public class AwContents implements SmartClipProvider, |
| @SuppressLint("MissingSuperCall") |
| public void onDetachedFromWindow() { |
| if (TRACE) Log.i(TAG, "%s onDetachedFromWindow", this); |
| + mWindowAndroid.getWindowAndroid().getDisplay().removeObserver(this); |
| mAwViewMethods.onDetachedFromWindow(); |
| } |