| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.pm.PackageManager; |
| 7 import android.content.Context; | 8 import android.content.Context; |
| 8 import android.os.Handler; | 9 import android.os.Handler; |
| 9 import android.os.Looper; | 10 import android.os.Looper; |
| 10 import android.os.Message; | 11 import android.os.Message; |
| 11 import android.provider.Settings; | 12 import android.provider.Settings; |
| 12 import android.webkit.WebSettings.PluginState; | 13 import android.webkit.WebSettings.PluginState; |
| 13 import android.webkit.WebSettings; | 14 import android.webkit.WebSettings; |
| 14 import android.webkit.WebView; | 15 import android.webkit.WebView; |
| 15 | 16 |
| 16 import org.chromium.base.CalledByNative; | 17 import org.chromium.base.CalledByNative; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 private boolean mSupportMultipleWindows = false; | 75 private boolean mSupportMultipleWindows = false; |
| 75 private PluginState mPluginState = PluginState.OFF; | 76 private PluginState mPluginState = PluginState.OFF; |
| 76 private boolean mAppCacheEnabled = false; | 77 private boolean mAppCacheEnabled = false; |
| 77 private boolean mDomStorageEnabled = false; | 78 private boolean mDomStorageEnabled = false; |
| 78 private boolean mDatabaseEnabled = false; | 79 private boolean mDatabaseEnabled = false; |
| 79 private boolean mUseWideViewport = false; | 80 private boolean mUseWideViewport = false; |
| 80 private boolean mLoadWithOverviewMode = false; | 81 private boolean mLoadWithOverviewMode = false; |
| 81 private boolean mMediaPlaybackRequiresUserGesture = true; | 82 private boolean mMediaPlaybackRequiresUserGesture = true; |
| 82 private String mDefaultVideoPosterURL; | 83 private String mDefaultVideoPosterURL; |
| 83 private float mInitialPageScalePercent = 0; | 84 private float mInitialPageScalePercent = 0; |
| 85 private boolean mSpatialNavigationEnabled; // Default depends on device fea
tures. |
| 84 | 86 |
| 85 private final boolean mSupportLegacyQuirks; | 87 private final boolean mSupportLegacyQuirks; |
| 86 | 88 |
| 87 private final boolean mPasswordEchoEnabled; | 89 private final boolean mPasswordEchoEnabled; |
| 88 | 90 |
| 89 // Not accessed by the native side. | 91 // Not accessed by the native side. |
| 90 private boolean mBlockNetworkLoads; // Default depends on permission of emb
edding APK. | 92 private boolean mBlockNetworkLoads; // Default depends on permission of emb
edding APK. |
| 91 private boolean mAllowContentUrlAccess = true; | 93 private boolean mAllowContentUrlAccess = true; |
| 92 private boolean mAllowFileUrlAccess = true; | 94 private boolean mAllowFileUrlAccess = true; |
| 93 private int mCacheMode = WebSettings.LOAD_DEFAULT; | 95 private int mCacheMode = WebSettings.LOAD_DEFAULT; |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 mBlockNetworkLoads = !hasInternetPermission; | 188 mBlockNetworkLoads = !hasInternetPermission; |
| 187 | 189 |
| 188 if (isAccessFromFileURLsGrantedByDefault) { | 190 if (isAccessFromFileURLsGrantedByDefault) { |
| 189 mAllowUniversalAccessFromFileURLs = true; | 191 mAllowUniversalAccessFromFileURLs = true; |
| 190 mAllowFileAccessFromFileURLs = true; | 192 mAllowFileAccessFromFileURLs = true; |
| 191 } | 193 } |
| 192 | 194 |
| 193 mUserAgent = LazyDefaultUserAgent.sInstance; | 195 mUserAgent = LazyDefaultUserAgent.sInstance; |
| 194 onGestureZoomSupportChanged(supportsGestureZoomLocked()); | 196 onGestureZoomSupportChanged(supportsGestureZoomLocked()); |
| 195 | 197 |
| 198 // Best-guess a sensible initial value based on the features support
ed on the device. |
| 199 mSpatialNavigationEnabled = !context.getPackageManager().hasSystemFe
ature( |
| 200 PackageManager.FEATURE_TOUCHSCREEN); |
| 201 |
| 196 // Respect the system setting for password echoing. | 202 // Respect the system setting for password echoing. |
| 197 mPasswordEchoEnabled = Settings.System.getInt(context.getContentReso
lver(), | 203 mPasswordEchoEnabled = Settings.System.getInt(context.getContentReso
lver(), |
| 198 Settings.System.TEXT_SHOW_PASSWORD, 1) == 1; | 204 Settings.System.TEXT_SHOW_PASSWORD, 1) == 1; |
| 199 | 205 |
| 200 mSupportLegacyQuirks = supportsLegacyQuirks; | 206 mSupportLegacyQuirks = supportsLegacyQuirks; |
| 201 } | 207 } |
| 202 // Defer initializing the native side until a native WebContents instanc
e is set. | 208 // Defer initializing the native side until a native WebContents instanc
e is set. |
| 203 } | 209 } |
| 204 | 210 |
| 205 @CalledByNative | 211 @CalledByNative |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 }); | 340 }); |
| 335 } | 341 } |
| 336 } | 342 } |
| 337 } | 343 } |
| 338 | 344 |
| 339 @CalledByNative | 345 @CalledByNative |
| 340 private float getInitialPageScalePercentLocked() { | 346 private float getInitialPageScalePercentLocked() { |
| 341 return mInitialPageScalePercent; | 347 return mInitialPageScalePercent; |
| 342 } | 348 } |
| 343 | 349 |
| 350 void setSpatialNavigationEnabled(boolean enable) { |
| 351 synchronized (mAwSettingsLock) { |
| 352 if (mSpatialNavigationEnabled != enable) { |
| 353 mSpatialNavigationEnabled = enable; |
| 354 mEventHandler.updateWebkitPreferencesLocked(); |
| 355 } |
| 356 } |
| 357 } |
| 358 |
| 359 @CalledByNative |
| 360 private boolean getSpatialNavigationLocked() { |
| 361 return mSpatialNavigationEnabled; |
| 362 } |
| 363 |
| 344 /** | 364 /** |
| 345 * See {@link android.webkit.WebSettings#setNeedInitialFocus}. | 365 * See {@link android.webkit.WebSettings#setNeedInitialFocus}. |
| 346 */ | 366 */ |
| 347 public boolean shouldFocusFirstNode() { | 367 public boolean shouldFocusFirstNode() { |
| 348 synchronized(mAwSettingsLock) { | 368 synchronized(mAwSettingsLock) { |
| 349 return mShouldFocusFirstNode; | 369 return mShouldFocusFirstNode; |
| 350 } | 370 } |
| 351 } | 371 } |
| 352 | 372 |
| 353 /** | 373 /** |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 return mUseWideViewport; | 1080 return mUseWideViewport; |
| 1061 } | 1081 } |
| 1062 } | 1082 } |
| 1063 | 1083 |
| 1064 @CalledByNative | 1084 @CalledByNative |
| 1065 private boolean getUseWideViewportLocked() { | 1085 private boolean getUseWideViewportLocked() { |
| 1066 return mUseWideViewport; | 1086 return mUseWideViewport; |
| 1067 } | 1087 } |
| 1068 | 1088 |
| 1069 @CalledByNative | 1089 @CalledByNative |
| 1070 private boolean getPasswordEchoEnabled() { | 1090 private boolean getPasswordEchoEnabledLocked() { |
| 1071 return mPasswordEchoEnabled; | 1091 return mPasswordEchoEnabled; |
| 1072 } | 1092 } |
| 1073 | 1093 |
| 1074 /** | 1094 /** |
| 1075 * See {@link android.webkit.WebSettings#setAppCacheEnabled}. | 1095 * See {@link android.webkit.WebSettings#setAppCacheEnabled}. |
| 1076 */ | 1096 */ |
| 1077 public void setAppCacheEnabled(boolean flag) { | 1097 public void setAppCacheEnabled(boolean flag) { |
| 1078 synchronized (mAwSettingsLock) { | 1098 synchronized (mAwSettingsLock) { |
| 1079 if (mAppCacheEnabled != flag) { | 1099 if (mAppCacheEnabled != flag) { |
| 1080 mAppCacheEnabled = flag; | 1100 mAppCacheEnabled = flag; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1373 private native void nativeUpdateInitialPageScaleLocked(int nativeAwSettings)
; | 1393 private native void nativeUpdateInitialPageScaleLocked(int nativeAwSettings)
; |
| 1374 | 1394 |
| 1375 private native void nativeUpdateUserAgentLocked(int nativeAwSettings); | 1395 private native void nativeUpdateUserAgentLocked(int nativeAwSettings); |
| 1376 | 1396 |
| 1377 private native void nativeUpdateWebkitPreferencesLocked(int nativeAwSettings
); | 1397 private native void nativeUpdateWebkitPreferencesLocked(int nativeAwSettings
); |
| 1378 | 1398 |
| 1379 private static native String nativeGetDefaultUserAgent(); | 1399 private static native String nativeGetDefaultUserAgent(); |
| 1380 | 1400 |
| 1381 private native void nativeUpdateFormDataPreferencesLocked(int nativeAwSettin
gs); | 1401 private native void nativeUpdateFormDataPreferencesLocked(int nativeAwSettin
gs); |
| 1382 } | 1402 } |
| OLD | NEW |