| OLD | NEW |
| 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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.content.Context; | 8 import android.content.Context; |
| 9 import android.content.pm.PackageManager; | 9 import android.content.pm.PackageManager; |
| 10 import android.os.Handler; | 10 import android.os.Handler; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 private String mCursiveFontFamily = "cursive"; | 61 private String mCursiveFontFamily = "cursive"; |
| 62 private String mFantasyFontFamily = "fantasy"; | 62 private String mFantasyFontFamily = "fantasy"; |
| 63 private String mDefaultTextEncoding = "UTF-8"; | 63 private String mDefaultTextEncoding = "UTF-8"; |
| 64 private String mUserAgent; | 64 private String mUserAgent; |
| 65 private int mMinimumFontSize = 8; | 65 private int mMinimumFontSize = 8; |
| 66 private int mMinimumLogicalFontSize = 8; | 66 private int mMinimumLogicalFontSize = 8; |
| 67 private int mDefaultFontSize = 16; | 67 private int mDefaultFontSize = 16; |
| 68 private int mDefaultFixedFontSize = 13; | 68 private int mDefaultFixedFontSize = 13; |
| 69 private boolean mLoadsImagesAutomatically = true; | 69 private boolean mLoadsImagesAutomatically = true; |
| 70 private boolean mImagesEnabled = true; | 70 private boolean mImagesEnabled = true; |
| 71 private boolean mJavaScriptEnabled = false; | 71 private boolean mJavaScriptEnabled; |
| 72 private boolean mAllowUniversalAccessFromFileURLs = false; | 72 private boolean mAllowUniversalAccessFromFileURLs; |
| 73 private boolean mAllowFileAccessFromFileURLs = false; | 73 private boolean mAllowFileAccessFromFileURLs; |
| 74 private boolean mJavaScriptCanOpenWindowsAutomatically = false; | 74 private boolean mJavaScriptCanOpenWindowsAutomatically; |
| 75 private boolean mSupportMultipleWindows = false; | 75 private boolean mSupportMultipleWindows; |
| 76 private PluginState mPluginState = PluginState.OFF; | 76 private PluginState mPluginState = PluginState.OFF; |
| 77 private boolean mAppCacheEnabled = false; | 77 private boolean mAppCacheEnabled; |
| 78 private boolean mDomStorageEnabled = false; | 78 private boolean mDomStorageEnabled; |
| 79 private boolean mDatabaseEnabled = false; | 79 private boolean mDatabaseEnabled; |
| 80 private boolean mUseWideViewport = false; | 80 private boolean mUseWideViewport; |
| 81 private boolean mZeroLayoutHeightDisablesViewportQuirk = false; | 81 private boolean mZeroLayoutHeightDisablesViewportQuirk; |
| 82 private boolean mForceZeroLayoutHeight = false; | 82 private boolean mForceZeroLayoutHeight; |
| 83 private boolean mLoadWithOverviewMode = false; | 83 private boolean mLoadWithOverviewMode; |
| 84 private boolean mMediaPlaybackRequiresUserGesture = true; | 84 private boolean mMediaPlaybackRequiresUserGesture = true; |
| 85 private String mDefaultVideoPosterURL; | 85 private String mDefaultVideoPosterURL; |
| 86 private float mInitialPageScalePercent = 0; | 86 private float mInitialPageScalePercent; |
| 87 private boolean mSpatialNavigationEnabled; // Default depends on device fea
tures. | 87 private boolean mSpatialNavigationEnabled; // Default depends on device fea
tures. |
| 88 private boolean mEnableSupportedHardwareAcceleratedFeatures = false; | 88 private boolean mEnableSupportedHardwareAcceleratedFeatures; |
| 89 private int mMixedContentMode = WebSettings.MIXED_CONTENT_NEVER_ALLOW; | 89 private int mMixedContentMode = WebSettings.MIXED_CONTENT_NEVER_ALLOW; |
| 90 | 90 |
| 91 private boolean mOffscreenPreRaster = false; | 91 private boolean mOffscreenPreRaster; |
| 92 private int mDisabledMenuItems = MENU_ITEM_NONE; | 92 private int mDisabledMenuItems = MENU_ITEM_NONE; |
| 93 | 93 |
| 94 // Although this bit is stored on AwSettings it is actually controlled via t
he CookieManager. | 94 // Although this bit is stored on AwSettings it is actually controlled via t
he CookieManager. |
| 95 private boolean mAcceptThirdPartyCookies = false; | 95 private boolean mAcceptThirdPartyCookies; |
| 96 | 96 |
| 97 private final boolean mSupportLegacyQuirks; | 97 private final boolean mSupportLegacyQuirks; |
| 98 private final boolean mAllowEmptyDocumentPersistence; | 98 private final boolean mAllowEmptyDocumentPersistence; |
| 99 private final boolean mAllowGeolocationOnInsecureOrigins; | 99 private final boolean mAllowGeolocationOnInsecureOrigins; |
| 100 | 100 |
| 101 private final boolean mPasswordEchoEnabled; | 101 private final boolean mPasswordEchoEnabled; |
| 102 | 102 |
| 103 // Not accessed by the native side. | 103 // Not accessed by the native side. |
| 104 private boolean mBlockNetworkLoads; // Default depends on permission of emb
edding APK. | 104 private boolean mBlockNetworkLoads; // Default depends on permission of emb
edding APK. |
| 105 private boolean mAllowContentUrlAccess = true; | 105 private boolean mAllowContentUrlAccess = true; |
| 106 private boolean mAllowFileUrlAccess = true; | 106 private boolean mAllowFileUrlAccess = true; |
| 107 private int mCacheMode = WebSettings.LOAD_DEFAULT; | 107 private int mCacheMode = WebSettings.LOAD_DEFAULT; |
| 108 private boolean mShouldFocusFirstNode = true; | 108 private boolean mShouldFocusFirstNode = true; |
| 109 private boolean mGeolocationEnabled = true; | 109 private boolean mGeolocationEnabled = true; |
| 110 private boolean mAutoCompleteEnabled = true; | 110 private boolean mAutoCompleteEnabled = true; |
| 111 private boolean mFullscreenSupported = false; | 111 private boolean mFullscreenSupported; |
| 112 private boolean mSupportZoom = true; | 112 private boolean mSupportZoom = true; |
| 113 private boolean mBuiltInZoomControls = false; | 113 private boolean mBuiltInZoomControls; |
| 114 private boolean mDisplayZoomControls = true; | 114 private boolean mDisplayZoomControls = true; |
| 115 | 115 |
| 116 static class LazyDefaultUserAgent{ | 116 static class LazyDefaultUserAgent{ |
| 117 // Lazy Holder pattern | 117 // Lazy Holder pattern |
| 118 private static final String sInstance = nativeGetDefaultUserAgent(); | 118 private static final String sInstance = nativeGetDefaultUserAgent(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 // Protects access to settings global fields. | 121 // Protects access to settings global fields. |
| 122 private static final Object sGlobalContentSettingsLock = new Object(); | 122 private static final Object sGlobalContentSettingsLock = new Object(); |
| 123 // For compatibility with the legacy WebView, we can only enable AppCache wh
en the path is | 123 // For compatibility with the legacy WebView, we can only enable AppCache wh
en the path is |
| 124 // provided. However, we don't use the path, so we just check if we have rec
eived it from the | 124 // provided. However, we don't use the path, so we just check if we have rec
eived it from the |
| 125 // client. | 125 // client. |
| 126 private static boolean sAppCachePathIsSet = false; | 126 private static boolean sAppCachePathIsSet; |
| 127 | 127 |
| 128 // The native side of this object. It's lifetime is bounded by the WebConten
t it is attached to. | 128 // The native side of this object. It's lifetime is bounded by the WebConten
t it is attached to. |
| 129 private long mNativeAwSettings = 0; | 129 private long mNativeAwSettings; |
| 130 | 130 |
| 131 // Custom handler that queues messages to call native code on the UI thread. | 131 // Custom handler that queues messages to call native code on the UI thread. |
| 132 private final EventHandler mEventHandler; | 132 private final EventHandler mEventHandler; |
| 133 | 133 |
| 134 private static final int MINIMUM_FONT_SIZE = 1; | 134 private static final int MINIMUM_FONT_SIZE = 1; |
| 135 private static final int MAXIMUM_FONT_SIZE = 72; | 135 private static final int MAXIMUM_FONT_SIZE = 72; |
| 136 | 136 |
| 137 // Class to handle messages to be processed on the UI thread. | 137 // Class to handle messages to be processed on the UI thread. |
| 138 private class EventHandler { | 138 private class EventHandler { |
| 139 // Message id for running a Runnable with mAwSettingsLock held. | 139 // Message id for running a Runnable with mAwSettingsLock held. |
| 140 private static final int RUN_RUNNABLE_BLOCKING = 0; | 140 private static final int RUN_RUNNABLE_BLOCKING = 0; |
| 141 // Actual UI thread handler | 141 // Actual UI thread handler |
| 142 private Handler mHandler; | 142 private Handler mHandler; |
| 143 // Synchronization flag. | 143 // Synchronization flag. |
| 144 private boolean mSynchronizationPending = false; | 144 private boolean mSynchronizationPending; |
| 145 | 145 |
| 146 EventHandler() { | 146 EventHandler() { |
| 147 } | 147 } |
| 148 | 148 |
| 149 void bindUiThread() { | 149 void bindUiThread() { |
| 150 if (mHandler != null) return; | 150 if (mHandler != null) return; |
| 151 mHandler = new Handler(ThreadUtils.getUiThreadLooper()) { | 151 mHandler = new Handler(ThreadUtils.getUiThreadLooper()) { |
| 152 @Override | 152 @Override |
| 153 public void handleMessage(Message msg) { | 153 public void handleMessage(Message msg) { |
| 154 switch (msg.what) { | 154 switch (msg.what) { |
| (...skipping 1631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 private native void nativeUpdateWebkitPreferencesLocked(long nativeAwSetting
s); | 1786 private native void nativeUpdateWebkitPreferencesLocked(long nativeAwSetting
s); |
| 1787 | 1787 |
| 1788 private static native String nativeGetDefaultUserAgent(); | 1788 private static native String nativeGetDefaultUserAgent(); |
| 1789 | 1789 |
| 1790 private native void nativeUpdateFormDataPreferencesLocked(long nativeAwSetti
ngs); | 1790 private native void nativeUpdateFormDataPreferencesLocked(long nativeAwSetti
ngs); |
| 1791 | 1791 |
| 1792 private native void nativeUpdateRendererPreferencesLocked(long nativeAwSetti
ngs); | 1792 private native void nativeUpdateRendererPreferencesLocked(long nativeAwSetti
ngs); |
| 1793 | 1793 |
| 1794 private native void nativeUpdateOffscreenPreRasterLocked(long nativeAwSettin
gs); | 1794 private native void nativeUpdateOffscreenPreRasterLocked(long nativeAwSettin
gs); |
| 1795 } | 1795 } |
| OLD | NEW |