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

Side by Side Diff: android_webview/java/src/org/chromium/android_webview/AwSettings.java

Issue 173943002: [Android WebView] Allow embedders to override text from scaling by system font scale. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.android_webview; 5 package org.chromium.android_webview;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.content.pm.PackageManager; 8 import android.content.pm.PackageManager;
9 import android.os.Handler; 9 import android.os.Handler;
10 import android.os.Message; 10 import android.os.Message;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 private boolean mMediaPlaybackRequiresUserGesture = true; 81 private boolean mMediaPlaybackRequiresUserGesture = true;
82 private String mDefaultVideoPosterURL; 82 private String mDefaultVideoPosterURL;
83 private float mInitialPageScalePercent = 0; 83 private float mInitialPageScalePercent = 0;
84 private boolean mSpatialNavigationEnabled; // Default depends on device fea tures. 84 private boolean mSpatialNavigationEnabled; // Default depends on device fea tures.
85 private boolean mEnableSupportedHardwareAcceleratedFeatures = false; 85 private boolean mEnableSupportedHardwareAcceleratedFeatures = false;
86 86
87 private final boolean mSupportLegacyQuirks; 87 private final boolean mSupportLegacyQuirks;
88 88
89 private final boolean mPasswordEchoEnabled; 89 private final boolean mPasswordEchoEnabled;
90 90
91 // Font scale factor determined by Android system setting.
92 private final float mFontScale;
93
94 // Not accessed by the native side. 91 // Not accessed by the native side.
95 private boolean mBlockNetworkLoads; // Default depends on permission of emb edding APK. 92 private boolean mBlockNetworkLoads; // Default depends on permission of emb edding APK.
96 private boolean mAllowContentUrlAccess = true; 93 private boolean mAllowContentUrlAccess = true;
97 private boolean mAllowFileUrlAccess = true; 94 private boolean mAllowFileUrlAccess = true;
98 private int mCacheMode = WebSettings.LOAD_DEFAULT; 95 private int mCacheMode = WebSettings.LOAD_DEFAULT;
99 private boolean mShouldFocusFirstNode = true; 96 private boolean mShouldFocusFirstNode = true;
100 private boolean mGeolocationEnabled = true; 97 private boolean mGeolocationEnabled = true;
101 private boolean mAutoCompleteEnabled = true; 98 private boolean mAutoCompleteEnabled = true;
102 private boolean mSupportZoom = true; 99 private boolean mSupportZoom = true;
103 private boolean mBuiltInZoomControls = false; 100 private boolean mBuiltInZoomControls = false;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 mDefaultTextEncoding = AwResource.getDefaultTextEncoding(); 213 mDefaultTextEncoding = AwResource.getDefaultTextEncoding();
217 mUserAgent = LazyDefaultUserAgent.sInstance; 214 mUserAgent = LazyDefaultUserAgent.sInstance;
218 215
219 // Best-guess a sensible initial value based on the features support ed on the device. 216 // Best-guess a sensible initial value based on the features support ed on the device.
220 mSpatialNavigationEnabled = !context.getPackageManager().hasSystemFe ature( 217 mSpatialNavigationEnabled = !context.getPackageManager().hasSystemFe ature(
221 PackageManager.FEATURE_TOUCHSCREEN); 218 PackageManager.FEATURE_TOUCHSCREEN);
222 219
223 // Respect the system setting for password echoing. 220 // Respect the system setting for password echoing.
224 mPasswordEchoEnabled = Settings.System.getInt(context.getContentReso lver(), 221 mPasswordEchoEnabled = Settings.System.getInt(context.getContentReso lver(),
225 Settings.System.TEXT_SHOW_PASSWORD, 1) == 1; 222 Settings.System.TEXT_SHOW_PASSWORD, 1) == 1;
226 mFontScale = context.getResources().getConfiguration().fontScale; 223
227 mTextSizePercent *= mFontScale; 224 // By default, scale the text size by the system font scale factor. Embedders
225 // may override this by invoking setTextZoom().
226 mTextSizePercent *= context.getResources().getConfiguration().fontSc ale;
228 227
229 mSupportLegacyQuirks = supportsLegacyQuirks; 228 mSupportLegacyQuirks = supportsLegacyQuirks;
230 } 229 }
231 // Defer initializing the native side until a native WebContents instanc e is set. 230 // Defer initializing the native side until a native WebContents instanc e is set.
232 } 231 }
233 232
234 @CalledByNative 233 @CalledByNative
235 private void nativeAwSettingsGone(long nativeAwSettings) { 234 private void nativeAwSettingsGone(long nativeAwSettings) {
236 assert mNativeAwSettings != 0 && mNativeAwSettings == nativeAwSettings; 235 assert mNativeAwSettings != 0 && mNativeAwSettings == nativeAwSettings;
237 mNativeAwSettings = 0; 236 mNativeAwSettings = 0;
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 private boolean getLoadWithOverviewModeLocked() { 553 private boolean getLoadWithOverviewModeLocked() {
555 assert Thread.holdsLock(mAwSettingsLock); 554 assert Thread.holdsLock(mAwSettingsLock);
556 return mLoadWithOverviewMode; 555 return mLoadWithOverviewMode;
557 } 556 }
558 557
559 /** 558 /**
560 * See {@link android.webkit.WebSettings#setTextZoom}. 559 * See {@link android.webkit.WebSettings#setTextZoom}.
561 */ 560 */
562 public void setTextZoom(final int textZoom) { 561 public void setTextZoom(final int textZoom) {
563 synchronized (mAwSettingsLock) { 562 synchronized (mAwSettingsLock) {
564 int scaledTextZoomPercent = (int)(textZoom * mFontScale); 563 if (mTextSizePercent != textZoom) {
565 if (mTextSizePercent != scaledTextZoomPercent) { 564 mTextSizePercent = textZoom;
566 mTextSizePercent = scaledTextZoomPercent;
567 mEventHandler.updateWebkitPreferencesLocked(); 565 mEventHandler.updateWebkitPreferencesLocked();
568 } 566 }
569 } 567 }
570 } 568 }
571 569
572 /** 570 /**
573 * See {@link android.webkit.WebSettings#getTextZoom}. 571 * See {@link android.webkit.WebSettings#getTextZoom}.
574 */ 572 */
575 public int getTextZoom() { 573 public int getTextZoom() {
576 synchronized (mAwSettingsLock) { 574 synchronized (mAwSettingsLock) {
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
1497 private native void nativeUpdateInitialPageScaleLocked(long nativeAwSettings ); 1495 private native void nativeUpdateInitialPageScaleLocked(long nativeAwSettings );
1498 1496
1499 private native void nativeUpdateUserAgentLocked(long nativeAwSettings); 1497 private native void nativeUpdateUserAgentLocked(long nativeAwSettings);
1500 1498
1501 private native void nativeUpdateWebkitPreferencesLocked(long nativeAwSetting s); 1499 private native void nativeUpdateWebkitPreferencesLocked(long nativeAwSetting s);
1502 1500
1503 private static native String nativeGetDefaultUserAgent(); 1501 private static native String nativeGetDefaultUserAgent();
1504 1502
1505 private native void nativeUpdateFormDataPreferencesLocked(long nativeAwSetti ngs); 1503 private native void nativeUpdateFormDataPreferencesLocked(long nativeAwSetti ngs);
1506 } 1504 }
OLDNEW
« 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