1 // Copyright 2014 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.
5 package com
.android
.webview
.chromium
;
7 import android
.webkit
.WebSettings
.LayoutAlgorithm
;
8 import android
.webkit
.WebSettings
.PluginState
;
9 import android
.webkit
.WebSettings
.RenderPriority
;
10 import android
.webkit
.WebSettings
.ZoomDensity
;
12 import org
.chromium
.android_webview
.AwSettings
;
13 import org
.chromium
.base
.annotations
.SuppressFBWarnings
;
16 * Type adaptation layer between {@link android.webkit.WebSettings} and
17 * {@link org.chromium.android_webview.AwSettings}.
19 @SuppressWarnings("deprecation")
20 @SuppressFBWarnings("CHROMIUM_SYNCHRONIZED_METHOD")
21 public class ContentSettingsAdapter
extends android
.webkit
.WebSettings
{
22 private AwSettings mAwSettings
;
24 public ContentSettingsAdapter(AwSettings awSettings
) {
25 mAwSettings
= awSettings
;
28 AwSettings
getAwSettings() {
34 public void setNavDump(boolean enabled
) {
40 public boolean getNavDump() {
46 public void setSupportZoom(boolean support
) {
47 mAwSettings
.setSupportZoom(support
);
51 public boolean supportZoom() {
52 return mAwSettings
.supportZoom();
56 public void setBuiltInZoomControls(boolean enabled
) {
57 mAwSettings
.setBuiltInZoomControls(enabled
);
61 public boolean getBuiltInZoomControls() {
62 return mAwSettings
.getBuiltInZoomControls();
66 public void setDisplayZoomControls(boolean enabled
) {
67 mAwSettings
.setDisplayZoomControls(enabled
);
71 public boolean getDisplayZoomControls() {
72 return mAwSettings
.getDisplayZoomControls();
76 public void setAllowFileAccess(boolean allow
) {
77 mAwSettings
.setAllowFileAccess(allow
);
81 public boolean getAllowFileAccess() {
82 return mAwSettings
.getAllowFileAccess();
86 public void setAllowContentAccess(boolean allow
) {
87 mAwSettings
.setAllowContentAccess(allow
);
91 public boolean getAllowContentAccess() {
92 return mAwSettings
.getAllowContentAccess();
96 public void setLoadWithOverviewMode(boolean overview
) {
97 mAwSettings
.setLoadWithOverviewMode(overview
);
101 public boolean getLoadWithOverviewMode() {
102 return mAwSettings
.getLoadWithOverviewMode();
106 public void setAcceptThirdPartyCookies(boolean accept
) {
107 mAwSettings
.setAcceptThirdPartyCookies(accept
);
111 public boolean getAcceptThirdPartyCookies() {
112 return mAwSettings
.getAcceptThirdPartyCookies();
116 public void setEnableSmoothTransition(boolean enable
) {
117 // Intentional no-op.
121 public boolean enableSmoothTransition() {
122 // Intentional no-op.
127 public void setUseWebViewBackgroundForOverscrollBackground(boolean view
) {
128 // Intentional no-op.
132 public boolean getUseWebViewBackgroundForOverscrollBackground() {
133 // Intentional no-op.
138 public void setSaveFormData(boolean save
) {
139 mAwSettings
.setSaveFormData(save
);
143 public boolean getSaveFormData() {
144 return mAwSettings
.getSaveFormData();
148 public void setSavePassword(boolean save
) {
149 // Intentional no-op.
153 public boolean getSavePassword() {
154 // Intentional no-op.
159 public synchronized void setTextZoom(int textZoom
) {
160 mAwSettings
.setTextZoom(textZoom
);
164 public synchronized int getTextZoom() {
165 return mAwSettings
.getTextZoom();
169 public void setDefaultZoom(ZoomDensity zoom
) {
170 mAwSettings
.setDefaultZoom(zoom
);
174 public ZoomDensity
getDefaultZoom() {
175 return mAwSettings
.getDefaultZoom();
179 public void setLightTouchEnabled(boolean enabled
) {
180 // Intentional no-op.
184 public boolean getLightTouchEnabled() {
185 // Intentional no-op.
190 public synchronized void setUserAgent(int ua
) {
191 mAwSettings
.setUserAgent(ua
);
195 public synchronized int getUserAgent() {
196 // Minimal implementation for backwards compatibility: just identifies default vs custom.
197 return AwSettings
.getDefaultUserAgent().equals(getUserAgentString()) ?
0 : -1;
201 public synchronized void setUseWideViewPort(boolean use
) {
202 mAwSettings
.setUseWideViewPort(use
);
206 public synchronized boolean getUseWideViewPort() {
207 return mAwSettings
.getUseWideViewPort();
211 public synchronized void setSupportMultipleWindows(boolean support
) {
212 mAwSettings
.setSupportMultipleWindows(support
);
216 public synchronized boolean supportMultipleWindows() {
217 return mAwSettings
.supportMultipleWindows();
221 public synchronized void setLayoutAlgorithm(LayoutAlgorithm l
) {
222 mAwSettings
.setLayoutAlgorithm(l
);
226 public synchronized LayoutAlgorithm
getLayoutAlgorithm() {
227 return mAwSettings
.getLayoutAlgorithm();
231 public synchronized void setStandardFontFamily(String font
) {
232 mAwSettings
.setStandardFontFamily(font
);
236 public synchronized String
getStandardFontFamily() {
237 return mAwSettings
.getStandardFontFamily();
241 public synchronized void setFixedFontFamily(String font
) {
242 mAwSettings
.setFixedFontFamily(font
);
246 public synchronized String
getFixedFontFamily() {
247 return mAwSettings
.getFixedFontFamily();
251 public synchronized void setSansSerifFontFamily(String font
) {
252 mAwSettings
.setSansSerifFontFamily(font
);
256 public synchronized String
getSansSerifFontFamily() {
257 return mAwSettings
.getSansSerifFontFamily();
261 public synchronized void setSerifFontFamily(String font
) {
262 mAwSettings
.setSerifFontFamily(font
);
266 public synchronized String
getSerifFontFamily() {
267 return mAwSettings
.getSerifFontFamily();
271 public synchronized void setCursiveFontFamily(String font
) {
272 mAwSettings
.setCursiveFontFamily(font
);
276 public synchronized String
getCursiveFontFamily() {
277 return mAwSettings
.getCursiveFontFamily();
281 public synchronized void setFantasyFontFamily(String font
) {
282 mAwSettings
.setFantasyFontFamily(font
);
286 public synchronized String
getFantasyFontFamily() {
287 return mAwSettings
.getFantasyFontFamily();
291 public synchronized void setMinimumFontSize(int size
) {
292 mAwSettings
.setMinimumFontSize(size
);
296 public synchronized int getMinimumFontSize() {
297 return mAwSettings
.getMinimumFontSize();
301 public synchronized void setMinimumLogicalFontSize(int size
) {
302 mAwSettings
.setMinimumLogicalFontSize(size
);
306 public synchronized int getMinimumLogicalFontSize() {
307 return mAwSettings
.getMinimumLogicalFontSize();
311 public synchronized void setDefaultFontSize(int size
) {
312 mAwSettings
.setDefaultFontSize(size
);
316 public synchronized int getDefaultFontSize() {
317 return mAwSettings
.getDefaultFontSize();
321 public synchronized void setDefaultFixedFontSize(int size
) {
322 mAwSettings
.setDefaultFixedFontSize(size
);
326 public synchronized int getDefaultFixedFontSize() {
327 return mAwSettings
.getDefaultFixedFontSize();
331 public synchronized void setLoadsImagesAutomatically(boolean flag
) {
332 mAwSettings
.setLoadsImagesAutomatically(flag
);
336 public synchronized boolean getLoadsImagesAutomatically() {
337 return mAwSettings
.getLoadsImagesAutomatically();
341 public synchronized void setBlockNetworkImage(boolean flag
) {
342 mAwSettings
.setImagesEnabled(!flag
);
346 public synchronized boolean getBlockNetworkImage() {
347 return !mAwSettings
.getImagesEnabled();
351 public synchronized void setBlockNetworkLoads(boolean flag
) {
352 mAwSettings
.setBlockNetworkLoads(flag
);
356 public synchronized boolean getBlockNetworkLoads() {
357 return mAwSettings
.getBlockNetworkLoads();
361 public synchronized void setJavaScriptEnabled(boolean flag
) {
362 mAwSettings
.setJavaScriptEnabled(flag
);
366 public void setAllowUniversalAccessFromFileURLs(boolean flag
) {
367 mAwSettings
.setAllowUniversalAccessFromFileURLs(flag
);
371 public void setAllowFileAccessFromFileURLs(boolean flag
) {
372 mAwSettings
.setAllowFileAccessFromFileURLs(flag
);
376 public synchronized void setPluginsEnabled(boolean flag
) {
377 mAwSettings
.setPluginsEnabled(flag
);
381 public synchronized void setPluginState(PluginState state
) {
382 mAwSettings
.setPluginState(state
);
386 public synchronized void setDatabasePath(String databasePath
) {
387 // Intentional no-op.
391 public synchronized void setGeolocationDatabasePath(String databasePath
) {
392 // Intentional no-op.
396 public synchronized void setAppCacheEnabled(boolean flag
) {
397 mAwSettings
.setAppCacheEnabled(flag
);
401 public synchronized void setAppCachePath(String appCachePath
) {
402 mAwSettings
.setAppCachePath(appCachePath
);
406 public synchronized void setAppCacheMaxSize(long appCacheMaxSize
) {
407 // Intentional no-op.
411 public synchronized void setDatabaseEnabled(boolean flag
) {
412 mAwSettings
.setDatabaseEnabled(flag
);
416 public synchronized void setDomStorageEnabled(boolean flag
) {
417 mAwSettings
.setDomStorageEnabled(flag
);
421 public synchronized boolean getDomStorageEnabled() {
422 return mAwSettings
.getDomStorageEnabled();
426 public synchronized String
getDatabasePath() {
427 // Intentional no-op.
432 public synchronized boolean getDatabaseEnabled() {
433 return mAwSettings
.getDatabaseEnabled();
437 public synchronized void setGeolocationEnabled(boolean flag
) {
438 mAwSettings
.setGeolocationEnabled(flag
);
442 public synchronized boolean getJavaScriptEnabled() {
443 return mAwSettings
.getJavaScriptEnabled();
447 public boolean getAllowUniversalAccessFromFileURLs() {
448 return mAwSettings
.getAllowUniversalAccessFromFileURLs();
452 public boolean getAllowFileAccessFromFileURLs() {
453 return mAwSettings
.getAllowFileAccessFromFileURLs();
457 public synchronized boolean getPluginsEnabled() {
458 return mAwSettings
.getPluginsEnabled();
462 public synchronized PluginState
getPluginState() {
463 return mAwSettings
.getPluginState();
467 public synchronized void setJavaScriptCanOpenWindowsAutomatically(boolean flag
) {
468 mAwSettings
.setJavaScriptCanOpenWindowsAutomatically(flag
);
472 public synchronized boolean getJavaScriptCanOpenWindowsAutomatically() {
473 return mAwSettings
.getJavaScriptCanOpenWindowsAutomatically();
477 public synchronized void setDefaultTextEncodingName(String encoding
) {
478 mAwSettings
.setDefaultTextEncodingName(encoding
);
482 public synchronized String
getDefaultTextEncodingName() {
483 return mAwSettings
.getDefaultTextEncodingName();
487 public synchronized void setUserAgentString(String ua
) {
488 mAwSettings
.setUserAgentString(ua
);
492 public synchronized String
getUserAgentString() {
493 return mAwSettings
.getUserAgentString();
497 public void setNeedInitialFocus(boolean flag
) {
498 mAwSettings
.setShouldFocusFirstNode(flag
);
502 public synchronized void setRenderPriority(RenderPriority priority
) {
503 // Intentional no-op.
507 public void setCacheMode(int mode
) {
508 mAwSettings
.setCacheMode(mode
);
512 public int getCacheMode() {
513 return mAwSettings
.getCacheMode();
517 public void setMediaPlaybackRequiresUserGesture(boolean require
) {
518 mAwSettings
.setMediaPlaybackRequiresUserGesture(require
);
522 public boolean getMediaPlaybackRequiresUserGesture() {
523 return mAwSettings
.getMediaPlaybackRequiresUserGesture();
527 public void setMixedContentMode(int mode
) {
528 mAwSettings
.setMixedContentMode(mode
);
532 public int getMixedContentMode() {
533 return mAwSettings
.getMixedContentMode();
536 public void setOffscreenPreRaster(boolean enabled
) {
537 mAwSettings
.setOffscreenPreRaster(enabled
);
540 public boolean getOffscreenPreRaster() {
541 return mAwSettings
.getOffscreenPreRaster();
545 public void setVideoOverlayForEmbeddedEncryptedVideoEnabled(boolean flag
) {
546 mAwSettings
.setVideoOverlayForEmbeddedVideoEnabled(flag
);
550 public boolean getVideoOverlayForEmbeddedEncryptedVideoEnabled() {
551 return mAwSettings
.getVideoOverlayForEmbeddedVideoEnabled();