| 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.Context; | 7 import android.content.Context; |
| 8 import android.os.Handler; | 8 import android.os.Handler; |
| 9 import android.os.Looper; | 9 import android.os.Looper; |
| 10 import android.os.Message; | 10 import android.os.Message; |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 try { | 162 try { |
| 163 while (mIsUpdateWebkitPrefsMessagePending) { | 163 while (mIsUpdateWebkitPrefsMessagePending) { |
| 164 mAwSettingsLock.wait(); | 164 mAwSettingsLock.wait(); |
| 165 } | 165 } |
| 166 } catch (InterruptedException e) {} | 166 } catch (InterruptedException e) {} |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 | 170 |
| 171 interface ZoomSupportChangeListener { | 171 interface ZoomSupportChangeListener { |
| 172 public void onMultiTouchZoomSupportChanged(boolean supportsMultiTouchZoo
m); | 172 public void onGestureZoomSupportChanged(boolean supportsGestureZoom); |
| 173 } | 173 } |
| 174 | 174 |
| 175 public AwSettings(Context context, boolean hasInternetPermission, | 175 public AwSettings(Context context, boolean hasInternetPermission, |
| 176 ZoomSupportChangeListener zoomChangeListener, | 176 ZoomSupportChangeListener zoomChangeListener, |
| 177 boolean isAccessFromFileURLsGrantedByDefault, | 177 boolean isAccessFromFileURLsGrantedByDefault, |
| 178 double dipScale) { | 178 double dipScale) { |
| 179 ThreadUtils.assertOnUiThread(); | 179 ThreadUtils.assertOnUiThread(); |
| 180 synchronized (mAwSettingsLock) { | 180 synchronized (mAwSettingsLock) { |
| 181 mHasInternetPermission = hasInternetPermission; | 181 mHasInternetPermission = hasInternetPermission; |
| 182 mZoomChangeListener = zoomChangeListener; | 182 mZoomChangeListener = zoomChangeListener; |
| 183 mDIPScale = dipScale; | 183 mDIPScale = dipScale; |
| 184 mEventHandler = new EventHandler(); | 184 mEventHandler = new EventHandler(); |
| 185 mBlockNetworkLoads = !hasInternetPermission; | 185 mBlockNetworkLoads = !hasInternetPermission; |
| 186 | 186 |
| 187 if (isAccessFromFileURLsGrantedByDefault) { | 187 if (isAccessFromFileURLsGrantedByDefault) { |
| 188 mAllowUniversalAccessFromFileURLs = true; | 188 mAllowUniversalAccessFromFileURLs = true; |
| 189 mAllowFileAccessFromFileURLs = true; | 189 mAllowFileAccessFromFileURLs = true; |
| 190 } | 190 } |
| 191 | 191 |
| 192 mUserAgent = LazyDefaultUserAgent.sInstance; | 192 mUserAgent = LazyDefaultUserAgent.sInstance; |
| 193 onMultiTouchZoomSupportChanged(supportsMultiTouchZoomLocked()); | 193 onGestureZoomSupportChanged(supportsGestureZoomLocked()); |
| 194 | 194 |
| 195 // Respect the system setting for password echoing. | 195 // Respect the system setting for password echoing. |
| 196 mPasswordEchoEnabled = Settings.System.getInt(context.getContentReso
lver(), | 196 mPasswordEchoEnabled = Settings.System.getInt(context.getContentReso
lver(), |
| 197 Settings.System.TEXT_SHOW_PASSWORD, 1) == 1; | 197 Settings.System.TEXT_SHOW_PASSWORD, 1) == 1; |
| 198 } | 198 } |
| 199 // Defer initializing the native side until a native WebContents instanc
e is set. | 199 // Defer initializing the native side until a native WebContents instanc
e is set. |
| 200 } | 200 } |
| 201 | 201 |
| 202 @CalledByNative | 202 @CalledByNative |
| 203 private void nativeAwSettingsGone(int nativeAwSettings) { | 203 private void nativeAwSettingsGone(int nativeAwSettings) { |
| (...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1242 synchronized (mAwSettingsLock) { | 1242 synchronized (mAwSettingsLock) { |
| 1243 return mDefaultVideoPosterURL; | 1243 return mDefaultVideoPosterURL; |
| 1244 } | 1244 } |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 @CalledByNative | 1247 @CalledByNative |
| 1248 private String getDefaultVideoPosterURLLocked() { | 1248 private String getDefaultVideoPosterURLLocked() { |
| 1249 return mDefaultVideoPosterURL; | 1249 return mDefaultVideoPosterURL; |
| 1250 } | 1250 } |
| 1251 | 1251 |
| 1252 private void onMultiTouchZoomSupportChanged(final boolean supportsMultiTouch
Zoom) { | 1252 private void onGestureZoomSupportChanged(final boolean supportsGestureZoom)
{ |
| 1253 // Always post asynchronously here, to avoid doubling back onto the call
er. | 1253 // Always post asynchronously here, to avoid doubling back onto the call
er. |
| 1254 ThreadUtils.postOnUiThread(new Runnable() { | 1254 ThreadUtils.postOnUiThread(new Runnable() { |
| 1255 @Override | 1255 @Override |
| 1256 public void run() { | 1256 public void run() { |
| 1257 mZoomChangeListener.onMultiTouchZoomSupportChanged(supportsMulti
TouchZoom); | 1257 mZoomChangeListener.onGestureZoomSupportChanged(supportsGestureZ
oom); |
| 1258 } | 1258 } |
| 1259 }); | 1259 }); |
| 1260 } | 1260 } |
| 1261 | 1261 |
| 1262 /** | 1262 /** |
| 1263 * See {@link android.webkit.WebSettings#setSupportZoom}. | 1263 * See {@link android.webkit.WebSettings#setSupportZoom}. |
| 1264 */ | 1264 */ |
| 1265 public void setSupportZoom(boolean support) { | 1265 public void setSupportZoom(boolean support) { |
| 1266 synchronized (mAwSettingsLock) { | 1266 synchronized (mAwSettingsLock) { |
| 1267 if (mSupportZoom != support) { | 1267 if (mSupportZoom != support) { |
| 1268 mSupportZoom = support; | 1268 mSupportZoom = support; |
| 1269 onMultiTouchZoomSupportChanged(supportsMultiTouchZoomLocked()); | 1269 onGestureZoomSupportChanged(supportsGestureZoomLocked()); |
| 1270 } | 1270 } |
| 1271 } | 1271 } |
| 1272 } | 1272 } |
| 1273 | 1273 |
| 1274 /** | 1274 /** |
| 1275 * See {@link android.webkit.WebSettings#supportZoom}. | 1275 * See {@link android.webkit.WebSettings#supportZoom}. |
| 1276 */ | 1276 */ |
| 1277 public boolean supportZoom() { | 1277 public boolean supportZoom() { |
| 1278 synchronized (mAwSettingsLock) { | 1278 synchronized (mAwSettingsLock) { |
| 1279 return mSupportZoom; | 1279 return mSupportZoom; |
| 1280 } | 1280 } |
| 1281 } | 1281 } |
| 1282 | 1282 |
| 1283 /** | 1283 /** |
| 1284 * See {@link android.webkit.WebSettings#setBuiltInZoomControls}. | 1284 * See {@link android.webkit.WebSettings#setBuiltInZoomControls}. |
| 1285 */ | 1285 */ |
| 1286 public void setBuiltInZoomControls(boolean enabled) { | 1286 public void setBuiltInZoomControls(boolean enabled) { |
| 1287 synchronized (mAwSettingsLock) { | 1287 synchronized (mAwSettingsLock) { |
| 1288 if (mBuiltInZoomControls != enabled) { | 1288 if (mBuiltInZoomControls != enabled) { |
| 1289 mBuiltInZoomControls = enabled; | 1289 mBuiltInZoomControls = enabled; |
| 1290 onMultiTouchZoomSupportChanged(supportsMultiTouchZoomLocked()); | 1290 onGestureZoomSupportChanged(supportsGestureZoomLocked()); |
| 1291 } | 1291 } |
| 1292 } | 1292 } |
| 1293 } | 1293 } |
| 1294 | 1294 |
| 1295 /** | 1295 /** |
| 1296 * See {@link android.webkit.WebSettings#getBuiltInZoomControls}. | 1296 * See {@link android.webkit.WebSettings#getBuiltInZoomControls}. |
| 1297 */ | 1297 */ |
| 1298 public boolean getBuiltInZoomControls() { | 1298 public boolean getBuiltInZoomControls() { |
| 1299 synchronized (mAwSettingsLock) { | 1299 synchronized (mAwSettingsLock) { |
| 1300 return mBuiltInZoomControls; | 1300 return mBuiltInZoomControls; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1312 | 1312 |
| 1313 /** | 1313 /** |
| 1314 * See {@link android.webkit.WebSettings#getDisplayZoomControls}. | 1314 * See {@link android.webkit.WebSettings#getDisplayZoomControls}. |
| 1315 */ | 1315 */ |
| 1316 public boolean getDisplayZoomControls() { | 1316 public boolean getDisplayZoomControls() { |
| 1317 synchronized (mAwSettingsLock) { | 1317 synchronized (mAwSettingsLock) { |
| 1318 return mDisplayZoomControls; | 1318 return mDisplayZoomControls; |
| 1319 } | 1319 } |
| 1320 } | 1320 } |
| 1321 | 1321 |
| 1322 private boolean supportsMultiTouchZoomLocked() { | 1322 private boolean supportsGestureZoomLocked() { |
| 1323 assert Thread.holdsLock(mAwSettingsLock); | 1323 assert Thread.holdsLock(mAwSettingsLock); |
| 1324 return mSupportZoom && mBuiltInZoomControls; | 1324 return mSupportZoom && mBuiltInZoomControls; |
| 1325 } | 1325 } |
| 1326 | 1326 |
| 1327 boolean supportsMultiTouchZoom() { | 1327 boolean supportsGestureZoom() { |
| 1328 synchronized (mAwSettingsLock) { | 1328 synchronized (mAwSettingsLock) { |
| 1329 return supportsMultiTouchZoomLocked(); | 1329 return supportsGestureZoomLocked(); |
| 1330 } | 1330 } |
| 1331 } | 1331 } |
| 1332 | 1332 |
| 1333 boolean shouldDisplayZoomControls() { | 1333 boolean shouldDisplayZoomControls() { |
| 1334 synchronized (mAwSettingsLock) { | 1334 synchronized (mAwSettingsLock) { |
| 1335 return supportsMultiTouchZoomLocked() && mDisplayZoomControls; | 1335 return supportsGestureZoomLocked() && mDisplayZoomControls; |
| 1336 } | 1336 } |
| 1337 } | 1337 } |
| 1338 | 1338 |
| 1339 private int clipFontSize(int size) { | 1339 private int clipFontSize(int size) { |
| 1340 if (size < MINIMUM_FONT_SIZE) { | 1340 if (size < MINIMUM_FONT_SIZE) { |
| 1341 return MINIMUM_FONT_SIZE; | 1341 return MINIMUM_FONT_SIZE; |
| 1342 } else if (size > MAXIMUM_FONT_SIZE) { | 1342 } else if (size > MAXIMUM_FONT_SIZE) { |
| 1343 return MAXIMUM_FONT_SIZE; | 1343 return MAXIMUM_FONT_SIZE; |
| 1344 } | 1344 } |
| 1345 return size; | 1345 return size; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1370 private native void nativeUpdateInitialPageScaleLocked(int nativeAwSettings)
; | 1370 private native void nativeUpdateInitialPageScaleLocked(int nativeAwSettings)
; |
| 1371 | 1371 |
| 1372 private native void nativeUpdateUserAgentLocked(int nativeAwSettings); | 1372 private native void nativeUpdateUserAgentLocked(int nativeAwSettings); |
| 1373 | 1373 |
| 1374 private native void nativeUpdateWebkitPreferencesLocked(int nativeAwSettings
); | 1374 private native void nativeUpdateWebkitPreferencesLocked(int nativeAwSettings
); |
| 1375 | 1375 |
| 1376 private static native String nativeGetDefaultUserAgent(); | 1376 private static native String nativeGetDefaultUserAgent(); |
| 1377 | 1377 |
| 1378 private native void nativeUpdateFormDataPreferencesLocked(int nativeAwSettin
gs); | 1378 private native void nativeUpdateFormDataPreferencesLocked(int nativeAwSettin
gs); |
| 1379 } | 1379 } |
| OLD | NEW |