AwSettings.java revision effb81e5f8246d0db0270817048dc992db66e9fb
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 3// found in the LICENSE file. 4 5package org.chromium.android_webview; 6 7import android.content.Context; 8import android.content.pm.PackageManager; 9import android.os.Handler; 10import android.os.Message; 11import android.os.Process; 12import android.provider.Settings; 13import android.util.Log; 14import android.webkit.WebSettings; 15import android.webkit.WebSettings.PluginState; 16 17import org.chromium.base.CalledByNative; 18import org.chromium.base.JNINamespace; 19import org.chromium.base.ThreadUtils; 20 21/** 22 * Stores Android WebView specific settings that does not need to be synced to WebKit. 23 * Use {@link org.chromium.content.browser.ContentSettings} for WebKit settings. 24 * 25 * Methods in this class can be called from any thread, including threads created by 26 * the client of WebView. 27 */ 28@JNINamespace("android_webview") 29public class AwSettings { 30 // This enum corresponds to WebSettings.LayoutAlgorithm. We use our own to be 31 // able to extend it. 32 public enum LayoutAlgorithm { 33 NORMAL, 34 SINGLE_COLUMN, 35 NARROW_COLUMNS, 36 TEXT_AUTOSIZING, 37 } 38 39 private static final String TAG = "AwSettings"; 40 41 // This class must be created on the UI thread. Afterwards, it can be 42 // used from any thread. Internally, the class uses a message queue 43 // to call native code on the UI thread only. 44 45 // Values passed in on construction. 46 private final boolean mHasInternetPermission; 47 48 private ZoomSupportChangeListener mZoomChangeListener; 49 private double mDIPScale = 1.0; 50 51 // Lock to protect all settings. 52 private final Object mAwSettingsLock = new Object(); 53 54 private LayoutAlgorithm mLayoutAlgorithm = LayoutAlgorithm.NARROW_COLUMNS; 55 private int mTextSizePercent = 100; 56 private String mStandardFontFamily = "sans-serif"; 57 private String mFixedFontFamily = "monospace"; 58 private String mSansSerifFontFamily = "sans-serif"; 59 private String mSerifFontFamily = "serif"; 60 private String mCursiveFontFamily = "cursive"; 61 private String mFantasyFontFamily = "fantasy"; 62 private String mDefaultTextEncoding; 63 private String mUserAgent; 64 private int mMinimumFontSize = 8; 65 private int mMinimumLogicalFontSize = 8; 66 private int mDefaultFontSize = 16; 67 private int mDefaultFixedFontSize = 13; 68 private boolean mLoadsImagesAutomatically = true; 69 private boolean mImagesEnabled = true; 70 private boolean mJavaScriptEnabled = false; 71 private boolean mAllowUniversalAccessFromFileURLs = false; 72 private boolean mAllowFileAccessFromFileURLs = false; 73 private boolean mJavaScriptCanOpenWindowsAutomatically = false; 74 private boolean mSupportMultipleWindows = false; 75 private PluginState mPluginState = PluginState.OFF; 76 private boolean mAppCacheEnabled = false; 77 private boolean mDomStorageEnabled = false; 78 private boolean mDatabaseEnabled = false; 79 private boolean mUseWideViewport = false; 80 private boolean mLoadWithOverviewMode = false; 81 private boolean mMediaPlaybackRequiresUserGesture = true; 82 private String mDefaultVideoPosterURL; 83 private float mInitialPageScalePercent = 0; 84 private boolean mSpatialNavigationEnabled; // Default depends on device features. 85 private boolean mEnableSupportedHardwareAcceleratedFeatures = false; 86 87 private final boolean mSupportLegacyQuirks; 88 89 private final boolean mPasswordEchoEnabled; 90 91 // Not accessed by the native side. 92 private boolean mBlockNetworkLoads; // Default depends on permission of embedding APK. 93 private boolean mAllowContentUrlAccess = true; 94 private boolean mAllowFileUrlAccess = true; 95 private int mCacheMode = WebSettings.LOAD_DEFAULT; 96 private boolean mShouldFocusFirstNode = true; 97 private boolean mGeolocationEnabled = true; 98 private boolean mAutoCompleteEnabled = true; 99 private boolean mSupportZoom = true; 100 private boolean mBuiltInZoomControls = false; 101 private boolean mDisplayZoomControls = true; 102 103 static class LazyDefaultUserAgent{ 104 // Lazy Holder pattern 105 private static final String sInstance = nativeGetDefaultUserAgent(); 106 } 107 108 // Protects access to settings global fields. 109 private static final Object sGlobalContentSettingsLock = new Object(); 110 // For compatibility with the legacy WebView, we can only enable AppCache when the path is 111 // provided. However, we don't use the path, so we just check if we have received it from the 112 // client. 113 private static boolean sAppCachePathIsSet = false; 114 115 // The native side of this object. It's lifetime is bounded by the WebContent it is attached to. 116 private long mNativeAwSettings = 0; 117 118 // Custom handler that queues messages to call native code on the UI thread. 119 private final EventHandler mEventHandler; 120 121 private static final int MINIMUM_FONT_SIZE = 1; 122 private static final int MAXIMUM_FONT_SIZE = 72; 123 124 // Class to handle messages to be processed on the UI thread. 125 private class EventHandler { 126 // Message id for running a Runnable with mAwSettingsLock held. 127 private static final int RUN_RUNNABLE_BLOCKING = 0; 128 // Actual UI thread handler 129 private Handler mHandler; 130 // Synchronization flag. 131 private boolean mSynchronizationPending = false; 132 133 EventHandler() { 134 } 135 136 void bindUiThread() { 137 if (mHandler != null) return; 138 mHandler = new Handler(ThreadUtils.getUiThreadLooper()) { 139 @Override 140 public void handleMessage(Message msg) { 141 switch (msg.what) { 142 case RUN_RUNNABLE_BLOCKING: 143 synchronized (mAwSettingsLock) { 144 if (mNativeAwSettings != 0) { 145 ((Runnable)msg.obj).run(); 146 } 147 mSynchronizationPending = false; 148 mAwSettingsLock.notifyAll(); 149 } 150 break; 151 } 152 } 153 }; 154 } 155 156 void runOnUiThreadBlockingAndLocked(Runnable r) { 157 assert Thread.holdsLock(mAwSettingsLock); 158 if (mHandler == null) return; 159 if (ThreadUtils.runningOnUiThread()) { 160 r.run(); 161 } else { 162 assert !mSynchronizationPending; 163 mSynchronizationPending = true; 164 mHandler.sendMessage(Message.obtain(null, RUN_RUNNABLE_BLOCKING, r)); 165 try { 166 while (mSynchronizationPending) { 167 mAwSettingsLock.wait(); 168 } 169 } catch (InterruptedException e) { 170 Log.e(TAG, "Interrupted waiting a Runnable to complete", e); 171 mSynchronizationPending = false; 172 } 173 } 174 } 175 176 void maybePostOnUiThread(Runnable r) { 177 if (mHandler != null) { 178 mHandler.post(r); 179 } 180 } 181 182 void updateWebkitPreferencesLocked() { 183 runOnUiThreadBlockingAndLocked(new Runnable() { 184 @Override 185 public void run() { 186 updateWebkitPreferencesOnUiThreadLocked(); 187 } 188 }); 189 } 190 } 191 192 interface ZoomSupportChangeListener { 193 public void onGestureZoomSupportChanged( 194 boolean supportsDoubleTapZoom, boolean supportsMultiTouchZoom); 195 } 196 197 public AwSettings(Context context, 198 boolean isAccessFromFileURLsGrantedByDefault, 199 boolean supportsLegacyQuirks) { 200 boolean hasInternetPermission = context.checkPermission( 201 android.Manifest.permission.INTERNET, 202 Process.myPid(), 203 Process.myUid()) == PackageManager.PERMISSION_GRANTED; 204 synchronized (mAwSettingsLock) { 205 mHasInternetPermission = hasInternetPermission; 206 mBlockNetworkLoads = !hasInternetPermission; 207 mEventHandler = new EventHandler(); 208 if (isAccessFromFileURLsGrantedByDefault) { 209 mAllowUniversalAccessFromFileURLs = true; 210 mAllowFileAccessFromFileURLs = true; 211 } 212 213 mDefaultTextEncoding = AwResource.getDefaultTextEncoding(); 214 mUserAgent = LazyDefaultUserAgent.sInstance; 215 216 // Best-guess a sensible initial value based on the features supported on the device. 217 mSpatialNavigationEnabled = !context.getPackageManager().hasSystemFeature( 218 PackageManager.FEATURE_TOUCHSCREEN); 219 220 // Respect the system setting for password echoing. 221 mPasswordEchoEnabled = Settings.System.getInt(context.getContentResolver(), 222 Settings.System.TEXT_SHOW_PASSWORD, 1) == 1; 223 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().fontScale; 227 228 mSupportLegacyQuirks = supportsLegacyQuirks; 229 } 230 // Defer initializing the native side until a native WebContents instance is set. 231 } 232 233 @CalledByNative 234 private void nativeAwSettingsGone(long nativeAwSettings) { 235 assert mNativeAwSettings != 0 && mNativeAwSettings == nativeAwSettings; 236 mNativeAwSettings = 0; 237 } 238 239 @CalledByNative 240 private double getDIPScaleLocked() { 241 assert Thread.holdsLock(mAwSettingsLock); 242 return mDIPScale; 243 } 244 245 void setDIPScale(double dipScale) { 246 synchronized (mAwSettingsLock) { 247 mDIPScale = dipScale; 248 // TODO(joth): This should also be synced over to native side, but right now 249 // the setDIPScale call is always followed by a setWebContents() which covers this. 250 } 251 } 252 253 void setZoomListener(ZoomSupportChangeListener zoomChangeListener) { 254 synchronized (mAwSettingsLock) { 255 mZoomChangeListener = zoomChangeListener; 256 } 257 } 258 259 void setWebContents(long nativeWebContents) { 260 synchronized (mAwSettingsLock) { 261 if (mNativeAwSettings != 0) { 262 nativeDestroy(mNativeAwSettings); 263 assert mNativeAwSettings == 0; // nativeAwSettingsGone should have been called. 264 } 265 if (nativeWebContents != 0) { 266 mEventHandler.bindUiThread(); 267 mNativeAwSettings = nativeInit(nativeWebContents); 268 nativeUpdateEverythingLocked(mNativeAwSettings); 269 onGestureZoomSupportChanged( 270 supportsDoubleTapZoomLocked(), supportsMultiTouchZoomLocked()); 271 } 272 } 273 } 274 275 /** 276 * See {@link android.webkit.WebSettings#setBlockNetworkLoads}. 277 */ 278 public void setBlockNetworkLoads(boolean flag) { 279 synchronized (mAwSettingsLock) { 280 if (!flag && !mHasInternetPermission) { 281 throw new SecurityException("Permission denied - " + 282 "application missing INTERNET permission"); 283 } 284 mBlockNetworkLoads = flag; 285 } 286 } 287 288 /** 289 * See {@link android.webkit.WebSettings#getBlockNetworkLoads}. 290 */ 291 public boolean getBlockNetworkLoads() { 292 synchronized (mAwSettingsLock) { 293 return mBlockNetworkLoads; 294 } 295 } 296 297 /** 298 * See {@link android.webkit.WebSettings#setAllowFileAccess}. 299 */ 300 public void setAllowFileAccess(boolean allow) { 301 synchronized (mAwSettingsLock) { 302 if (mAllowFileUrlAccess != allow) { 303 mAllowFileUrlAccess = allow; 304 } 305 } 306 } 307 308 /** 309 * See {@link android.webkit.WebSettings#getAllowFileAccess}. 310 */ 311 public boolean getAllowFileAccess() { 312 synchronized (mAwSettingsLock) { 313 return mAllowFileUrlAccess; 314 } 315 } 316 317 /** 318 * See {@link android.webkit.WebSettings#setAllowContentAccess}. 319 */ 320 public void setAllowContentAccess(boolean allow) { 321 synchronized (mAwSettingsLock) { 322 if (mAllowContentUrlAccess != allow) { 323 mAllowContentUrlAccess = allow; 324 } 325 } 326 } 327 328 /** 329 * See {@link android.webkit.WebSettings#getAllowContentAccess}. 330 */ 331 public boolean getAllowContentAccess() { 332 synchronized (mAwSettingsLock) { 333 return mAllowContentUrlAccess; 334 } 335 } 336 337 /** 338 * See {@link android.webkit.WebSettings#setCacheMode}. 339 */ 340 public void setCacheMode(int mode) { 341 synchronized (mAwSettingsLock) { 342 if (mCacheMode != mode) { 343 mCacheMode = mode; 344 } 345 } 346 } 347 348 /** 349 * See {@link android.webkit.WebSettings#getCacheMode}. 350 */ 351 public int getCacheMode() { 352 synchronized (mAwSettingsLock) { 353 return mCacheMode; 354 } 355 } 356 357 /** 358 * See {@link android.webkit.WebSettings#setNeedInitialFocus}. 359 */ 360 public void setShouldFocusFirstNode(boolean flag) { 361 synchronized (mAwSettingsLock) { 362 mShouldFocusFirstNode = flag; 363 } 364 } 365 366 /** 367 * See {@link android.webkit.WebView#setInitialScale}. 368 */ 369 public void setInitialPageScale(final float scaleInPercent) { 370 synchronized (mAwSettingsLock) { 371 if (mInitialPageScalePercent != scaleInPercent) { 372 mInitialPageScalePercent = scaleInPercent; 373 mEventHandler.runOnUiThreadBlockingAndLocked(new Runnable() { 374 @Override 375 public void run() { 376 nativeUpdateInitialPageScaleLocked(mNativeAwSettings); 377 } 378 }); 379 } 380 } 381 } 382 383 @CalledByNative 384 private float getInitialPageScalePercentLocked() { 385 assert Thread.holdsLock(mAwSettingsLock); 386 return mInitialPageScalePercent; 387 } 388 389 void setSpatialNavigationEnabled(boolean enable) { 390 synchronized (mAwSettingsLock) { 391 if (mSpatialNavigationEnabled != enable) { 392 mSpatialNavigationEnabled = enable; 393 mEventHandler.updateWebkitPreferencesLocked(); 394 } 395 } 396 } 397 398 @CalledByNative 399 private boolean getSpatialNavigationLocked() { 400 assert Thread.holdsLock(mAwSettingsLock); 401 return mSpatialNavigationEnabled; 402 } 403 404 void setEnableSupportedHardwareAcceleratedFeatures(boolean enable) { 405 synchronized (mAwSettingsLock) { 406 if (mEnableSupportedHardwareAcceleratedFeatures != enable) { 407 mEnableSupportedHardwareAcceleratedFeatures = enable; 408 mEventHandler.updateWebkitPreferencesLocked(); 409 } 410 } 411 } 412 413 @CalledByNative 414 private boolean getEnableSupportedHardwareAcceleratedFeaturesLocked() { 415 assert Thread.holdsLock(mAwSettingsLock); 416 return mEnableSupportedHardwareAcceleratedFeatures; 417 } 418 419 /** 420 * See {@link android.webkit.WebSettings#setNeedInitialFocus}. 421 */ 422 public boolean shouldFocusFirstNode() { 423 synchronized (mAwSettingsLock) { 424 return mShouldFocusFirstNode; 425 } 426 } 427 428 /** 429 * See {@link android.webkit.WebSettings#setGeolocationEnabled}. 430 */ 431 public void setGeolocationEnabled(boolean flag) { 432 synchronized (mAwSettingsLock) { 433 if (mGeolocationEnabled != flag) { 434 mGeolocationEnabled = flag; 435 } 436 } 437 } 438 439 /** 440 * @return Returns if geolocation is currently enabled. 441 */ 442 boolean getGeolocationEnabled() { 443 synchronized (mAwSettingsLock) { 444 return mGeolocationEnabled; 445 } 446 } 447 448 /** 449 * See {@link android.webkit.WebSettings#setSaveFormData}. 450 */ 451 public void setSaveFormData(final boolean enable) { 452 synchronized (mAwSettingsLock) { 453 if (mAutoCompleteEnabled != enable) { 454 mAutoCompleteEnabled = enable; 455 mEventHandler.runOnUiThreadBlockingAndLocked(new Runnable() { 456 @Override 457 public void run() { 458 nativeUpdateFormDataPreferencesLocked(mNativeAwSettings); 459 } 460 }); 461 } 462 } 463 } 464 465 /** 466 * See {@link android.webkit.WebSettings#getSaveFormData}. 467 */ 468 public boolean getSaveFormData() { 469 synchronized (mAwSettingsLock) { 470 return getSaveFormDataLocked(); 471 } 472 } 473 474 @CalledByNative 475 private boolean getSaveFormDataLocked() { 476 assert Thread.holdsLock(mAwSettingsLock); 477 return mAutoCompleteEnabled; 478 } 479 480 /** 481 * @returns the default User-Agent used by each ContentViewCore instance, i.e. unless 482 * overridden by {@link #setUserAgentString()} 483 */ 484 public static String getDefaultUserAgent() { 485 return LazyDefaultUserAgent.sInstance; 486 } 487 488 /** 489 * See {@link android.webkit.WebSettings#setUserAgentString}. 490 */ 491 public void setUserAgentString(String ua) { 492 synchronized (mAwSettingsLock) { 493 final String oldUserAgent = mUserAgent; 494 if (ua == null || ua.length() == 0) { 495 mUserAgent = LazyDefaultUserAgent.sInstance; 496 } else { 497 mUserAgent = ua; 498 } 499 if (!oldUserAgent.equals(mUserAgent)) { 500 mEventHandler.runOnUiThreadBlockingAndLocked(new Runnable() { 501 @Override 502 public void run() { 503 nativeUpdateUserAgentLocked(mNativeAwSettings); 504 } 505 }); 506 } 507 } 508 } 509 510 /** 511 * See {@link android.webkit.WebSettings#getUserAgentString}. 512 */ 513 public String getUserAgentString() { 514 synchronized (mAwSettingsLock) { 515 return mUserAgent; 516 } 517 } 518 519 @CalledByNative 520 private String getUserAgentLocked() { 521 assert Thread.holdsLock(mAwSettingsLock); 522 return mUserAgent; 523 } 524 525 /** 526 * See {@link android.webkit.WebSettings#setLoadWithOverviewMode}. 527 */ 528 public void setLoadWithOverviewMode(boolean overview) { 529 synchronized (mAwSettingsLock) { 530 if (mLoadWithOverviewMode != overview) { 531 mLoadWithOverviewMode = overview; 532 mEventHandler.runOnUiThreadBlockingAndLocked(new Runnable() { 533 @Override 534 public void run() { 535 updateWebkitPreferencesOnUiThreadLocked(); 536 nativeResetScrollAndScaleState(mNativeAwSettings); 537 } 538 }); 539 } 540 } 541 } 542 543 /** 544 * See {@link android.webkit.WebSettings#getLoadWithOverviewMode}. 545 */ 546 public boolean getLoadWithOverviewMode() { 547 synchronized (mAwSettingsLock) { 548 return mLoadWithOverviewMode; 549 } 550 } 551 552 @CalledByNative 553 private boolean getLoadWithOverviewModeLocked() { 554 assert Thread.holdsLock(mAwSettingsLock); 555 return mLoadWithOverviewMode; 556 } 557 558 /** 559 * See {@link android.webkit.WebSettings#setTextZoom}. 560 */ 561 public void setTextZoom(final int textZoom) { 562 synchronized (mAwSettingsLock) { 563 if (mTextSizePercent != textZoom) { 564 mTextSizePercent = textZoom; 565 mEventHandler.updateWebkitPreferencesLocked(); 566 } 567 } 568 } 569 570 /** 571 * See {@link android.webkit.WebSettings#getTextZoom}. 572 */ 573 public int getTextZoom() { 574 synchronized (mAwSettingsLock) { 575 return mTextSizePercent; 576 } 577 } 578 579 @CalledByNative 580 private int getTextSizePercentLocked() { 581 assert Thread.holdsLock(mAwSettingsLock); 582 return mTextSizePercent; 583 } 584 585 /** 586 * See {@link android.webkit.WebSettings#setStandardFontFamily}. 587 */ 588 public void setStandardFontFamily(String font) { 589 synchronized (mAwSettingsLock) { 590 if (font != null && !mStandardFontFamily.equals(font)) { 591 mStandardFontFamily = font; 592 mEventHandler.updateWebkitPreferencesLocked(); 593 } 594 } 595 } 596 597 /** 598 * See {@link android.webkit.WebSettings#getStandardFontFamily}. 599 */ 600 public String getStandardFontFamily() { 601 synchronized (mAwSettingsLock) { 602 return mStandardFontFamily; 603 } 604 } 605 606 @CalledByNative 607 private String getStandardFontFamilyLocked() { 608 assert Thread.holdsLock(mAwSettingsLock); 609 return mStandardFontFamily; 610 } 611 612 /** 613 * See {@link android.webkit.WebSettings#setFixedFontFamily}. 614 */ 615 public void setFixedFontFamily(String font) { 616 synchronized (mAwSettingsLock) { 617 if (font != null && !mFixedFontFamily.equals(font)) { 618 mFixedFontFamily = font; 619 mEventHandler.updateWebkitPreferencesLocked(); 620 } 621 } 622 } 623 624 /** 625 * See {@link android.webkit.WebSettings#getFixedFontFamily}. 626 */ 627 public String getFixedFontFamily() { 628 synchronized (mAwSettingsLock) { 629 return mFixedFontFamily; 630 } 631 } 632 633 @CalledByNative 634 private String getFixedFontFamilyLocked() { 635 assert Thread.holdsLock(mAwSettingsLock); 636 return mFixedFontFamily; 637 } 638 639 /** 640 * See {@link android.webkit.WebSettings#setSansSerifFontFamily}. 641 */ 642 public void setSansSerifFontFamily(String font) { 643 synchronized (mAwSettingsLock) { 644 if (font != null && !mSansSerifFontFamily.equals(font)) { 645 mSansSerifFontFamily = font; 646 mEventHandler.updateWebkitPreferencesLocked(); 647 } 648 } 649 } 650 651 /** 652 * See {@link android.webkit.WebSettings#getSansSerifFontFamily}. 653 */ 654 public String getSansSerifFontFamily() { 655 synchronized (mAwSettingsLock) { 656 return mSansSerifFontFamily; 657 } 658 } 659 660 @CalledByNative 661 private String getSansSerifFontFamilyLocked() { 662 assert Thread.holdsLock(mAwSettingsLock); 663 return mSansSerifFontFamily; 664 } 665 666 /** 667 * See {@link android.webkit.WebSettings#setSerifFontFamily}. 668 */ 669 public void setSerifFontFamily(String font) { 670 synchronized (mAwSettingsLock) { 671 if (font != null && !mSerifFontFamily.equals(font)) { 672 mSerifFontFamily = font; 673 mEventHandler.updateWebkitPreferencesLocked(); 674 } 675 } 676 } 677 678 /** 679 * See {@link android.webkit.WebSettings#getSerifFontFamily}. 680 */ 681 public String getSerifFontFamily() { 682 synchronized (mAwSettingsLock) { 683 return mSerifFontFamily; 684 } 685 } 686 687 @CalledByNative 688 private String getSerifFontFamilyLocked() { 689 assert Thread.holdsLock(mAwSettingsLock); 690 return mSerifFontFamily; 691 } 692 693 /** 694 * See {@link android.webkit.WebSettings#setCursiveFontFamily}. 695 */ 696 public void setCursiveFontFamily(String font) { 697 synchronized (mAwSettingsLock) { 698 if (font != null && !mCursiveFontFamily.equals(font)) { 699 mCursiveFontFamily = font; 700 mEventHandler.updateWebkitPreferencesLocked(); 701 } 702 } 703 } 704 705 /** 706 * See {@link android.webkit.WebSettings#getCursiveFontFamily}. 707 */ 708 public String getCursiveFontFamily() { 709 synchronized (mAwSettingsLock) { 710 return mCursiveFontFamily; 711 } 712 } 713 714 @CalledByNative 715 private String getCursiveFontFamilyLocked() { 716 assert Thread.holdsLock(mAwSettingsLock); 717 return mCursiveFontFamily; 718 } 719 720 /** 721 * See {@link android.webkit.WebSettings#setFantasyFontFamily}. 722 */ 723 public void setFantasyFontFamily(String font) { 724 synchronized (mAwSettingsLock) { 725 if (font != null && !mFantasyFontFamily.equals(font)) { 726 mFantasyFontFamily = font; 727 mEventHandler.updateWebkitPreferencesLocked(); 728 } 729 } 730 } 731 732 /** 733 * See {@link android.webkit.WebSettings#getFantasyFontFamily}. 734 */ 735 public String getFantasyFontFamily() { 736 synchronized (mAwSettingsLock) { 737 return mFantasyFontFamily; 738 } 739 } 740 741 @CalledByNative 742 private String getFantasyFontFamilyLocked() { 743 assert Thread.holdsLock(mAwSettingsLock); 744 return mFantasyFontFamily; 745 } 746 747 /** 748 * See {@link android.webkit.WebSettings#setMinimumFontSize}. 749 */ 750 public void setMinimumFontSize(int size) { 751 synchronized (mAwSettingsLock) { 752 size = clipFontSize(size); 753 if (mMinimumFontSize != size) { 754 mMinimumFontSize = size; 755 mEventHandler.updateWebkitPreferencesLocked(); 756 } 757 } 758 } 759 760 /** 761 * See {@link android.webkit.WebSettings#getMinimumFontSize}. 762 */ 763 public int getMinimumFontSize() { 764 synchronized (mAwSettingsLock) { 765 return mMinimumFontSize; 766 } 767 } 768 769 @CalledByNative 770 private int getMinimumFontSizeLocked() { 771 assert Thread.holdsLock(mAwSettingsLock); 772 return mMinimumFontSize; 773 } 774 775 /** 776 * See {@link android.webkit.WebSettings#setMinimumLogicalFontSize}. 777 */ 778 public void setMinimumLogicalFontSize(int size) { 779 synchronized (mAwSettingsLock) { 780 size = clipFontSize(size); 781 if (mMinimumLogicalFontSize != size) { 782 mMinimumLogicalFontSize = size; 783 mEventHandler.updateWebkitPreferencesLocked(); 784 } 785 } 786 } 787 788 /** 789 * See {@link android.webkit.WebSettings#getMinimumLogicalFontSize}. 790 */ 791 public int getMinimumLogicalFontSize() { 792 synchronized (mAwSettingsLock) { 793 return mMinimumLogicalFontSize; 794 } 795 } 796 797 @CalledByNative 798 private int getMinimumLogicalFontSizeLocked() { 799 assert Thread.holdsLock(mAwSettingsLock); 800 return mMinimumLogicalFontSize; 801 } 802 803 /** 804 * See {@link android.webkit.WebSettings#setDefaultFontSize}. 805 */ 806 public void setDefaultFontSize(int size) { 807 synchronized (mAwSettingsLock) { 808 size = clipFontSize(size); 809 if (mDefaultFontSize != size) { 810 mDefaultFontSize = size; 811 mEventHandler.updateWebkitPreferencesLocked(); 812 } 813 } 814 } 815 816 /** 817 * See {@link android.webkit.WebSettings#getDefaultFontSize}. 818 */ 819 public int getDefaultFontSize() { 820 synchronized (mAwSettingsLock) { 821 return mDefaultFontSize; 822 } 823 } 824 825 @CalledByNative 826 private int getDefaultFontSizeLocked() { 827 assert Thread.holdsLock(mAwSettingsLock); 828 return mDefaultFontSize; 829 } 830 831 /** 832 * See {@link android.webkit.WebSettings#setDefaultFixedFontSize}. 833 */ 834 public void setDefaultFixedFontSize(int size) { 835 synchronized (mAwSettingsLock) { 836 size = clipFontSize(size); 837 if (mDefaultFixedFontSize != size) { 838 mDefaultFixedFontSize = size; 839 mEventHandler.updateWebkitPreferencesLocked(); 840 } 841 } 842 } 843 844 /** 845 * See {@link android.webkit.WebSettings#getDefaultFixedFontSize}. 846 */ 847 public int getDefaultFixedFontSize() { 848 synchronized (mAwSettingsLock) { 849 return mDefaultFixedFontSize; 850 } 851 } 852 853 @CalledByNative 854 private int getDefaultFixedFontSizeLocked() { 855 assert Thread.holdsLock(mAwSettingsLock); 856 return mDefaultFixedFontSize; 857 } 858 859 /** 860 * See {@link android.webkit.WebSettings#setJavaScriptEnabled}. 861 */ 862 public void setJavaScriptEnabled(boolean flag) { 863 synchronized (mAwSettingsLock) { 864 if (mJavaScriptEnabled != flag) { 865 mJavaScriptEnabled = flag; 866 mEventHandler.updateWebkitPreferencesLocked(); 867 } 868 } 869 } 870 871 /** 872 * See {@link android.webkit.WebSettings#setAllowUniversalAccessFromFileURLs}. 873 */ 874 public void setAllowUniversalAccessFromFileURLs(boolean flag) { 875 synchronized (mAwSettingsLock) { 876 if (mAllowUniversalAccessFromFileURLs != flag) { 877 mAllowUniversalAccessFromFileURLs = flag; 878 mEventHandler.updateWebkitPreferencesLocked(); 879 } 880 } 881 } 882 883 /** 884 * See {@link android.webkit.WebSettings#setAllowFileAccessFromFileURLs}. 885 */ 886 public void setAllowFileAccessFromFileURLs(boolean flag) { 887 synchronized (mAwSettingsLock) { 888 if (mAllowFileAccessFromFileURLs != flag) { 889 mAllowFileAccessFromFileURLs = flag; 890 mEventHandler.updateWebkitPreferencesLocked(); 891 } 892 } 893 } 894 895 /** 896 * See {@link android.webkit.WebSettings#setLoadsImagesAutomatically}. 897 */ 898 public void setLoadsImagesAutomatically(boolean flag) { 899 synchronized (mAwSettingsLock) { 900 if (mLoadsImagesAutomatically != flag) { 901 mLoadsImagesAutomatically = flag; 902 mEventHandler.updateWebkitPreferencesLocked(); 903 } 904 } 905 } 906 907 /** 908 * See {@link android.webkit.WebSettings#getLoadsImagesAutomatically}. 909 */ 910 public boolean getLoadsImagesAutomatically() { 911 synchronized (mAwSettingsLock) { 912 return mLoadsImagesAutomatically; 913 } 914 } 915 916 @CalledByNative 917 private boolean getLoadsImagesAutomaticallyLocked() { 918 assert Thread.holdsLock(mAwSettingsLock); 919 return mLoadsImagesAutomatically; 920 } 921 922 /** 923 * See {@link android.webkit.WebSettings#setImagesEnabled}. 924 */ 925 public void setImagesEnabled(boolean flag) { 926 synchronized (mAwSettingsLock) { 927 if (mImagesEnabled != flag) { 928 mImagesEnabled = flag; 929 mEventHandler.updateWebkitPreferencesLocked(); 930 } 931 } 932 } 933 934 /** 935 * See {@link android.webkit.WebSettings#getImagesEnabled}. 936 */ 937 public boolean getImagesEnabled() { 938 synchronized (mAwSettingsLock) { 939 return mImagesEnabled; 940 } 941 } 942 943 @CalledByNative 944 private boolean getImagesEnabledLocked() { 945 assert Thread.holdsLock(mAwSettingsLock); 946 return mImagesEnabled; 947 } 948 949 /** 950 * See {@link android.webkit.WebSettings#getJavaScriptEnabled}. 951 */ 952 public boolean getJavaScriptEnabled() { 953 synchronized (mAwSettingsLock) { 954 return mJavaScriptEnabled; 955 } 956 } 957 958 @CalledByNative 959 private boolean getJavaScriptEnabledLocked() { 960 assert Thread.holdsLock(mAwSettingsLock); 961 return mJavaScriptEnabled; 962 } 963 964 /** 965 * See {@link android.webkit.WebSettings#getAllowUniversalAccessFromFileURLs}. 966 */ 967 public boolean getAllowUniversalAccessFromFileURLs() { 968 synchronized (mAwSettingsLock) { 969 return mAllowUniversalAccessFromFileURLs; 970 } 971 } 972 973 @CalledByNative 974 private boolean getAllowUniversalAccessFromFileURLsLocked() { 975 assert Thread.holdsLock(mAwSettingsLock); 976 return mAllowUniversalAccessFromFileURLs; 977 } 978 979 /** 980 * See {@link android.webkit.WebSettings#getAllowFileAccessFromFileURLs}. 981 */ 982 public boolean getAllowFileAccessFromFileURLs() { 983 synchronized (mAwSettingsLock) { 984 return mAllowFileAccessFromFileURLs; 985 } 986 } 987 988 @CalledByNative 989 private boolean getAllowFileAccessFromFileURLsLocked() { 990 assert Thread.holdsLock(mAwSettingsLock); 991 return mAllowFileAccessFromFileURLs; 992 } 993 994 /** 995 * See {@link android.webkit.WebSettings#setPluginsEnabled}. 996 */ 997 public void setPluginsEnabled(boolean flag) { 998 setPluginState(flag ? PluginState.ON : PluginState.OFF); 999 } 1000 1001 /** 1002 * See {@link android.webkit.WebSettings#setPluginState}. 1003 */ 1004 public void setPluginState(PluginState state) { 1005 synchronized (mAwSettingsLock) { 1006 if (mPluginState != state) { 1007 mPluginState = state; 1008 mEventHandler.updateWebkitPreferencesLocked(); 1009 } 1010 } 1011 } 1012 1013 /** 1014 * See {@link android.webkit.WebSettings#getPluginsEnabled}. 1015 */ 1016 public boolean getPluginsEnabled() { 1017 synchronized (mAwSettingsLock) { 1018 return mPluginState == PluginState.ON; 1019 } 1020 } 1021 1022 /** 1023 * Return true if plugins are disabled. 1024 * @return True if plugins are disabled. 1025 */ 1026 @CalledByNative 1027 private boolean getPluginsDisabledLocked() { 1028 assert Thread.holdsLock(mAwSettingsLock); 1029 return mPluginState == PluginState.OFF; 1030 } 1031 1032 /** 1033 * See {@link android.webkit.WebSettings#getPluginState}. 1034 */ 1035 public PluginState getPluginState() { 1036 synchronized (mAwSettingsLock) { 1037 return mPluginState; 1038 } 1039 } 1040 1041 1042 /** 1043 * See {@link android.webkit.WebSettings#setJavaScriptCanOpenWindowsAutomatically}. 1044 */ 1045 public void setJavaScriptCanOpenWindowsAutomatically(boolean flag) { 1046 synchronized (mAwSettingsLock) { 1047 if (mJavaScriptCanOpenWindowsAutomatically != flag) { 1048 mJavaScriptCanOpenWindowsAutomatically = flag; 1049 mEventHandler.updateWebkitPreferencesLocked(); 1050 } 1051 } 1052 } 1053 1054 /** 1055 * See {@link android.webkit.WebSettings#getJavaScriptCanOpenWindowsAutomatically}. 1056 */ 1057 public boolean getJavaScriptCanOpenWindowsAutomatically() { 1058 synchronized (mAwSettingsLock) { 1059 return mJavaScriptCanOpenWindowsAutomatically; 1060 } 1061 } 1062 1063 @CalledByNative 1064 private boolean getJavaScriptCanOpenWindowsAutomaticallyLocked() { 1065 assert Thread.holdsLock(mAwSettingsLock); 1066 return mJavaScriptCanOpenWindowsAutomatically; 1067 } 1068 1069 /** 1070 * See {@link android.webkit.WebSettings#setLayoutAlgorithm}. 1071 */ 1072 public void setLayoutAlgorithm(LayoutAlgorithm l) { 1073 synchronized (mAwSettingsLock) { 1074 if (mLayoutAlgorithm != l) { 1075 mLayoutAlgorithm = l; 1076 mEventHandler.updateWebkitPreferencesLocked(); 1077 } 1078 } 1079 } 1080 1081 /** 1082 * See {@link android.webkit.WebSettings#getLayoutAlgorithm}. 1083 */ 1084 public LayoutAlgorithm getLayoutAlgorithm() { 1085 synchronized (mAwSettingsLock) { 1086 return mLayoutAlgorithm; 1087 } 1088 } 1089 1090 /** 1091 * Gets whether Text Auto-sizing layout algorithm is enabled. 1092 * 1093 * @return true if Text Auto-sizing layout algorithm is enabled 1094 */ 1095 @CalledByNative 1096 private boolean getTextAutosizingEnabledLocked() { 1097 assert Thread.holdsLock(mAwSettingsLock); 1098 return mLayoutAlgorithm == LayoutAlgorithm.TEXT_AUTOSIZING; 1099 } 1100 1101 /** 1102 * See {@link android.webkit.WebSettings#setSupportMultipleWindows}. 1103 */ 1104 public void setSupportMultipleWindows(boolean support) { 1105 synchronized (mAwSettingsLock) { 1106 if (mSupportMultipleWindows != support) { 1107 mSupportMultipleWindows = support; 1108 mEventHandler.updateWebkitPreferencesLocked(); 1109 } 1110 } 1111 } 1112 1113 /** 1114 * See {@link android.webkit.WebSettings#supportMultipleWindows}. 1115 */ 1116 public boolean supportMultipleWindows() { 1117 synchronized (mAwSettingsLock) { 1118 return mSupportMultipleWindows; 1119 } 1120 } 1121 1122 @CalledByNative 1123 private boolean getSupportMultipleWindowsLocked() { 1124 assert Thread.holdsLock(mAwSettingsLock); 1125 return mSupportMultipleWindows; 1126 } 1127 1128 @CalledByNative 1129 private boolean getSupportLegacyQuirksLocked() { 1130 assert Thread.holdsLock(mAwSettingsLock); 1131 return mSupportLegacyQuirks; 1132 } 1133 1134 /** 1135 * See {@link android.webkit.WebSettings#setUseWideViewPort}. 1136 */ 1137 public void setUseWideViewPort(boolean use) { 1138 synchronized (mAwSettingsLock) { 1139 if (mUseWideViewport != use) { 1140 mUseWideViewport = use; 1141 onGestureZoomSupportChanged( 1142 supportsDoubleTapZoomLocked(), supportsMultiTouchZoomLocked()); 1143 mEventHandler.updateWebkitPreferencesLocked(); 1144 } 1145 } 1146 } 1147 1148 /** 1149 * See {@link android.webkit.WebSettings#getUseWideViewPort}. 1150 */ 1151 public boolean getUseWideViewPort() { 1152 synchronized (mAwSettingsLock) { 1153 return mUseWideViewport; 1154 } 1155 } 1156 1157 @CalledByNative 1158 private boolean getUseWideViewportLocked() { 1159 assert Thread.holdsLock(mAwSettingsLock); 1160 return mUseWideViewport; 1161 } 1162 1163 @CalledByNative 1164 private boolean getPasswordEchoEnabledLocked() { 1165 assert Thread.holdsLock(mAwSettingsLock); 1166 return mPasswordEchoEnabled; 1167 } 1168 1169 /** 1170 * See {@link android.webkit.WebSettings#setAppCacheEnabled}. 1171 */ 1172 public void setAppCacheEnabled(boolean flag) { 1173 synchronized (mAwSettingsLock) { 1174 if (mAppCacheEnabled != flag) { 1175 mAppCacheEnabled = flag; 1176 mEventHandler.updateWebkitPreferencesLocked(); 1177 } 1178 } 1179 } 1180 1181 /** 1182 * See {@link android.webkit.WebSettings#setAppCachePath}. 1183 */ 1184 public void setAppCachePath(String path) { 1185 boolean needToSync = false; 1186 synchronized (sGlobalContentSettingsLock) { 1187 // AppCachePath can only be set once. 1188 if (!sAppCachePathIsSet && path != null && !path.isEmpty()) { 1189 sAppCachePathIsSet = true; 1190 needToSync = true; 1191 } 1192 } 1193 // The obvious problem here is that other WebViews will not be updated, 1194 // until they execute synchronization from Java to the native side. 1195 // But this is the same behaviour as it was in the legacy WebView. 1196 if (needToSync) { 1197 synchronized (mAwSettingsLock) { 1198 mEventHandler.updateWebkitPreferencesLocked(); 1199 } 1200 } 1201 } 1202 1203 /** 1204 * Gets whether Application Cache is enabled. 1205 * 1206 * @return true if Application Cache is enabled 1207 */ 1208 @CalledByNative 1209 private boolean getAppCacheEnabledLocked() { 1210 assert Thread.holdsLock(mAwSettingsLock); 1211 if (!mAppCacheEnabled) { 1212 return false; 1213 } 1214 synchronized (sGlobalContentSettingsLock) { 1215 return sAppCachePathIsSet; 1216 } 1217 } 1218 1219 /** 1220 * See {@link android.webkit.WebSettings#setDomStorageEnabled}. 1221 */ 1222 public void setDomStorageEnabled(boolean flag) { 1223 synchronized (mAwSettingsLock) { 1224 if (mDomStorageEnabled != flag) { 1225 mDomStorageEnabled = flag; 1226 mEventHandler.updateWebkitPreferencesLocked(); 1227 } 1228 } 1229 } 1230 1231 /** 1232 * See {@link android.webkit.WebSettings#getDomStorageEnabled}. 1233 */ 1234 public boolean getDomStorageEnabled() { 1235 synchronized (mAwSettingsLock) { 1236 return mDomStorageEnabled; 1237 } 1238 } 1239 1240 @CalledByNative 1241 private boolean getDomStorageEnabledLocked() { 1242 assert Thread.holdsLock(mAwSettingsLock); 1243 return mDomStorageEnabled; 1244 } 1245 1246 /** 1247 * See {@link android.webkit.WebSettings#setDatabaseEnabled}. 1248 */ 1249 public void setDatabaseEnabled(boolean flag) { 1250 synchronized (mAwSettingsLock) { 1251 if (mDatabaseEnabled != flag) { 1252 mDatabaseEnabled = flag; 1253 mEventHandler.updateWebkitPreferencesLocked(); 1254 } 1255 } 1256 } 1257 1258 /** 1259 * See {@link android.webkit.WebSettings#getDatabaseEnabled}. 1260 */ 1261 public boolean getDatabaseEnabled() { 1262 synchronized (mAwSettingsLock) { 1263 return mDatabaseEnabled; 1264 } 1265 } 1266 1267 @CalledByNative 1268 private boolean getDatabaseEnabledLocked() { 1269 assert Thread.holdsLock(mAwSettingsLock); 1270 return mDatabaseEnabled; 1271 } 1272 1273 /** 1274 * See {@link android.webkit.WebSettings#setDefaultTextEncodingName}. 1275 */ 1276 public void setDefaultTextEncodingName(String encoding) { 1277 synchronized (mAwSettingsLock) { 1278 if (encoding != null && !mDefaultTextEncoding.equals(encoding)) { 1279 mDefaultTextEncoding = encoding; 1280 mEventHandler.updateWebkitPreferencesLocked(); 1281 } 1282 } 1283 } 1284 1285 /** 1286 * See {@link android.webkit.WebSettings#getDefaultTextEncodingName}. 1287 */ 1288 public String getDefaultTextEncodingName() { 1289 synchronized (mAwSettingsLock) { 1290 return mDefaultTextEncoding; 1291 } 1292 } 1293 1294 @CalledByNative 1295 private String getDefaultTextEncodingLocked() { 1296 assert Thread.holdsLock(mAwSettingsLock); 1297 return mDefaultTextEncoding; 1298 } 1299 1300 /** 1301 * See {@link android.webkit.WebSettings#setMediaPlaybackRequiresUserGesture}. 1302 */ 1303 public void setMediaPlaybackRequiresUserGesture(boolean require) { 1304 synchronized (mAwSettingsLock) { 1305 if (mMediaPlaybackRequiresUserGesture != require) { 1306 mMediaPlaybackRequiresUserGesture = require; 1307 mEventHandler.updateWebkitPreferencesLocked(); 1308 } 1309 } 1310 } 1311 1312 /** 1313 * See {@link android.webkit.WebSettings#getMediaPlaybackRequiresUserGesture}. 1314 */ 1315 public boolean getMediaPlaybackRequiresUserGesture() { 1316 synchronized (mAwSettingsLock) { 1317 return mMediaPlaybackRequiresUserGesture; 1318 } 1319 } 1320 1321 @CalledByNative 1322 private boolean getMediaPlaybackRequiresUserGestureLocked() { 1323 assert Thread.holdsLock(mAwSettingsLock); 1324 return mMediaPlaybackRequiresUserGesture; 1325 } 1326 1327 /** 1328 * See {@link android.webkit.WebSettings#setDefaultVideoPosterURL}. 1329 */ 1330 public void setDefaultVideoPosterURL(String url) { 1331 synchronized (mAwSettingsLock) { 1332 if (mDefaultVideoPosterURL != null && !mDefaultVideoPosterURL.equals(url) || 1333 mDefaultVideoPosterURL == null && url != null) { 1334 mDefaultVideoPosterURL = url; 1335 mEventHandler.updateWebkitPreferencesLocked(); 1336 } 1337 } 1338 } 1339 1340 /** 1341 * See {@link android.webkit.WebSettings#getDefaultVideoPosterURL}. 1342 */ 1343 public String getDefaultVideoPosterURL() { 1344 synchronized (mAwSettingsLock) { 1345 return mDefaultVideoPosterURL; 1346 } 1347 } 1348 1349 @CalledByNative 1350 private String getDefaultVideoPosterURLLocked() { 1351 assert Thread.holdsLock(mAwSettingsLock); 1352 return mDefaultVideoPosterURL; 1353 } 1354 1355 private void onGestureZoomSupportChanged( 1356 final boolean supportsDoubleTapZoom, final boolean supportsMultiTouchZoom) { 1357 // Always post asynchronously here, to avoid doubling back onto the caller. 1358 mEventHandler.maybePostOnUiThread(new Runnable() { 1359 @Override 1360 public void run() { 1361 synchronized (mAwSettingsLock) { 1362 if (mZoomChangeListener != null) { 1363 mZoomChangeListener.onGestureZoomSupportChanged( 1364 supportsDoubleTapZoom, supportsMultiTouchZoom); 1365 } 1366 } 1367 } 1368 }); 1369 } 1370 1371 /** 1372 * See {@link android.webkit.WebSettings#setSupportZoom}. 1373 */ 1374 public void setSupportZoom(boolean support) { 1375 synchronized (mAwSettingsLock) { 1376 if (mSupportZoom != support) { 1377 mSupportZoom = support; 1378 onGestureZoomSupportChanged( 1379 supportsDoubleTapZoomLocked(), supportsMultiTouchZoomLocked()); 1380 } 1381 } 1382 } 1383 1384 /** 1385 * See {@link android.webkit.WebSettings#supportZoom}. 1386 */ 1387 public boolean supportZoom() { 1388 synchronized (mAwSettingsLock) { 1389 return mSupportZoom; 1390 } 1391 } 1392 1393 /** 1394 * See {@link android.webkit.WebSettings#setBuiltInZoomControls}. 1395 */ 1396 public void setBuiltInZoomControls(boolean enabled) { 1397 synchronized (mAwSettingsLock) { 1398 if (mBuiltInZoomControls != enabled) { 1399 mBuiltInZoomControls = enabled; 1400 onGestureZoomSupportChanged( 1401 supportsDoubleTapZoomLocked(), supportsMultiTouchZoomLocked()); 1402 } 1403 } 1404 } 1405 1406 /** 1407 * See {@link android.webkit.WebSettings#getBuiltInZoomControls}. 1408 */ 1409 public boolean getBuiltInZoomControls() { 1410 synchronized (mAwSettingsLock) { 1411 return mBuiltInZoomControls; 1412 } 1413 } 1414 1415 /** 1416 * See {@link android.webkit.WebSettings#setDisplayZoomControls}. 1417 */ 1418 public void setDisplayZoomControls(boolean enabled) { 1419 synchronized (mAwSettingsLock) { 1420 mDisplayZoomControls = enabled; 1421 } 1422 } 1423 1424 /** 1425 * See {@link android.webkit.WebSettings#getDisplayZoomControls}. 1426 */ 1427 public boolean getDisplayZoomControls() { 1428 synchronized (mAwSettingsLock) { 1429 return mDisplayZoomControls; 1430 } 1431 } 1432 1433 @CalledByNative 1434 private boolean supportsDoubleTapZoomLocked() { 1435 assert Thread.holdsLock(mAwSettingsLock); 1436 return mSupportZoom && mBuiltInZoomControls && mUseWideViewport; 1437 } 1438 1439 private boolean supportsMultiTouchZoomLocked() { 1440 assert Thread.holdsLock(mAwSettingsLock); 1441 return mSupportZoom && mBuiltInZoomControls; 1442 } 1443 1444 boolean supportsMultiTouchZoom() { 1445 synchronized (mAwSettingsLock) { 1446 return supportsMultiTouchZoomLocked(); 1447 } 1448 } 1449 1450 boolean shouldDisplayZoomControls() { 1451 synchronized (mAwSettingsLock) { 1452 return supportsMultiTouchZoomLocked() && mDisplayZoomControls; 1453 } 1454 } 1455 1456 private int clipFontSize(int size) { 1457 if (size < MINIMUM_FONT_SIZE) { 1458 return MINIMUM_FONT_SIZE; 1459 } else if (size > MAXIMUM_FONT_SIZE) { 1460 return MAXIMUM_FONT_SIZE; 1461 } 1462 return size; 1463 } 1464 1465 @CalledByNative 1466 private void updateEverything() { 1467 synchronized (mAwSettingsLock) { 1468 nativeUpdateEverythingLocked(mNativeAwSettings); 1469 } 1470 } 1471 1472 @CalledByNative 1473 private void populateWebPreferences(long webPrefsPtr) { 1474 synchronized (mAwSettingsLock) { 1475 nativePopulateWebPreferencesLocked(mNativeAwSettings, webPrefsPtr); 1476 } 1477 } 1478 1479 private void updateWebkitPreferencesOnUiThreadLocked() { 1480 assert mEventHandler.mHandler != null; 1481 ThreadUtils.assertOnUiThread(); 1482 nativeUpdateWebkitPreferencesLocked(mNativeAwSettings); 1483 } 1484 1485 private native long nativeInit(long webContentsPtr); 1486 1487 private native void nativeDestroy(long nativeAwSettings); 1488 1489 private native void nativePopulateWebPreferencesLocked(long nativeAwSettings, long webPrefsPtr); 1490 1491 private native void nativeResetScrollAndScaleState(long nativeAwSettings); 1492 1493 private native void nativeUpdateEverythingLocked(long nativeAwSettings); 1494 1495 private native void nativeUpdateInitialPageScaleLocked(long nativeAwSettings); 1496 1497 private native void nativeUpdateUserAgentLocked(long nativeAwSettings); 1498 1499 private native void nativeUpdateWebkitPreferencesLocked(long nativeAwSettings); 1500 1501 private static native String nativeGetDefaultUserAgent(); 1502 1503 private native void nativeUpdateFormDataPreferencesLocked(long nativeAwSettings); 1504} 1505