1/* 2 * Copyright (C) 2007 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.webkit; 18 19import android.content.Context; 20 21/** 22 * Manages settings state for a WebView. When a WebView is first created, it 23 * obtains a set of default settings. These default settings will be returned 24 * from any getter call. A WebSettings object obtained from 25 * WebView.getSettings() is tied to the life of the WebView. If a WebView has 26 * been destroyed, any method call on WebSettings will throw an 27 * IllegalStateException. 28 */ 29// This is an abstract base class: concrete WebViewProviders must 30// create a class derived from this, and return an instance of it in the 31// WebViewProvider.getWebSettingsProvider() method implementation. 32public abstract class WebSettings { 33 /** 34 * Enum for controlling the layout of html. 35 * <ul> 36 * <li>NORMAL means no rendering changes. This is the recommended choice for maximum 37 * compatibility across different platforms and Android versions.</li> 38 * <li>SINGLE_COLUMN moves all content into one column that is the width of the 39 * view.</li> 40 * <li>NARROW_COLUMNS makes all columns no wider than the screen if possible. Only use 41 * this for API levels prior to {@link android.os.Build.VERSION_CODES#KITKAT}.</li> 42 * <li>TEXT_AUTOSIZING boosts font size of paragraphs based on heuristics to make 43 * the text readable when viewing a wide-viewport layout in the overview mode. 44 * It is recommended to enable zoom support {@link #setSupportZoom} when 45 * using this mode. Supported from API level 46 * {@link android.os.Build.VERSION_CODES#KITKAT}</li> 47 * </ul> 48 */ 49 // XXX: These must match LayoutAlgorithm in Settings.h in WebCore. 50 public enum LayoutAlgorithm { 51 NORMAL, 52 /** 53 * @deprecated This algorithm is now obsolete. 54 */ 55 @Deprecated 56 SINGLE_COLUMN, 57 /** 58 * @deprecated This algorithm is now obsolete. 59 */ 60 @Deprecated 61 NARROW_COLUMNS, 62 TEXT_AUTOSIZING 63 } 64 65 /** 66 * Enum for specifying the text size. 67 * <ul> 68 * <li>SMALLEST is 50%</li> 69 * <li>SMALLER is 75%</li> 70 * <li>NORMAL is 100%</li> 71 * <li>LARGER is 150%</li> 72 * <li>LARGEST is 200%</li> 73 * </ul> 74 * 75 * @deprecated Use {@link WebSettings#setTextZoom(int)} and {@link WebSettings#getTextZoom()} instead. 76 */ 77 public enum TextSize { 78 SMALLEST(50), 79 SMALLER(75), 80 NORMAL(100), 81 LARGER(150), 82 LARGEST(200); 83 TextSize(int size) { 84 value = size; 85 } 86 int value; 87 } 88 89 /** 90 * Enum for specifying the WebView's desired density. 91 * <ul> 92 * <li>FAR makes 100% looking like in 240dpi</li> 93 * <li>MEDIUM makes 100% looking like in 160dpi</li> 94 * <li>CLOSE makes 100% looking like in 120dpi</li> 95 * </ul> 96 */ 97 public enum ZoomDensity { 98 FAR(150), // 240dpi 99 MEDIUM(100), // 160dpi 100 CLOSE(75); // 120dpi 101 ZoomDensity(int size) { 102 value = size; 103 } 104 105 /** 106 * @hide Only for use by WebViewProvider implementations 107 */ 108 public int getValue() { 109 return value; 110 } 111 112 int value; 113 } 114 115 /** 116 * Default cache usage mode. If the navigation type doesn't impose any 117 * specific behavior, use cached resources when they are available 118 * and not expired, otherwise load resources from the network. 119 * Use with {@link #setCacheMode}. 120 */ 121 public static final int LOAD_DEFAULT = -1; 122 123 /** 124 * Normal cache usage mode. Use with {@link #setCacheMode}. 125 * 126 * @deprecated This value is obsolete, as from API level 127 * {@link android.os.Build.VERSION_CODES#HONEYCOMB} and onwards it has the 128 * same effect as {@link #LOAD_DEFAULT}. 129 */ 130 @Deprecated 131 public static final int LOAD_NORMAL = 0; 132 133 /** 134 * Use cached resources when they are available, even if they have expired. 135 * Otherwise load resources from the network. 136 * Use with {@link #setCacheMode}. 137 */ 138 public static final int LOAD_CACHE_ELSE_NETWORK = 1; 139 140 /** 141 * Don't use the cache, load from the network. 142 * Use with {@link #setCacheMode}. 143 */ 144 public static final int LOAD_NO_CACHE = 2; 145 146 /** 147 * Don't use the network, load from the cache. 148 * Use with {@link #setCacheMode}. 149 */ 150 public static final int LOAD_CACHE_ONLY = 3; 151 152 public enum RenderPriority { 153 NORMAL, 154 HIGH, 155 LOW 156 } 157 158 /** 159 * The plugin state effects how plugins are treated on a page. ON means 160 * that any object will be loaded even if a plugin does not exist to handle 161 * the content. ON_DEMAND means that if there is a plugin installed that 162 * can handle the content, a placeholder is shown until the user clicks on 163 * the placeholder. Once clicked, the plugin will be enabled on the page. 164 * OFF means that all plugins will be turned off and any fallback content 165 * will be used. 166 */ 167 public enum PluginState { 168 ON, 169 ON_DEMAND, 170 OFF 171 } 172 173 /** 174 * Hidden constructor to prevent clients from creating a new settings 175 * instance or deriving the class. 176 * 177 * @hide 178 */ 179 protected WebSettings() { 180 } 181 182 /** 183 * Enables dumping the pages navigation cache to a text file. The default 184 * is false. 185 * 186 * @deprecated This method is now obsolete. 187 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} 188 */ 189 @Deprecated 190 public void setNavDump(boolean enabled) { 191 throw new MustOverrideException(); 192 } 193 194 /** 195 * Gets whether dumping the navigation cache is enabled. 196 * 197 * @return whether dumping the navigation cache is enabled 198 * @see #setNavDump 199 * @deprecated This method is now obsolete. 200 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} 201 */ 202 @Deprecated 203 public boolean getNavDump() { 204 throw new MustOverrideException(); 205 } 206 207 /** 208 * Sets whether the WebView should support zooming using its on-screen zoom 209 * controls and gestures. The particular zoom mechanisms that should be used 210 * can be set with {@link #setBuiltInZoomControls}. This setting does not 211 * affect zooming performed using the {@link WebView#zoomIn()} and 212 * {@link WebView#zoomOut()} methods. The default is true. 213 * 214 * @param support whether the WebView should support zoom 215 */ 216 public void setSupportZoom(boolean support) { 217 throw new MustOverrideException(); 218 } 219 220 /** 221 * Gets whether the WebView supports zoom. 222 * 223 * @return true if the WebView supports zoom 224 * @see #setSupportZoom 225 */ 226 public boolean supportZoom() { 227 throw new MustOverrideException(); 228 } 229 230 /** 231 * Sets whether the WebView requires a user gesture to play media. 232 * The default is true. 233 * 234 * @param require whether the WebView requires a user gesture to play media 235 */ 236 public void setMediaPlaybackRequiresUserGesture(boolean require) { 237 throw new MustOverrideException(); 238 } 239 240 /** 241 * Gets whether the WebView requires a user gesture to play media. 242 * 243 * @return true if the WebView requires a user gesture to play media 244 * @see #setMediaPlaybackRequiresUserGesture 245 */ 246 public boolean getMediaPlaybackRequiresUserGesture() { 247 throw new MustOverrideException(); 248 } 249 250 /** 251 * Sets whether the WebView should use its built-in zoom mechanisms. The 252 * built-in zoom mechanisms comprise on-screen zoom controls, which are 253 * displayed over the WebView's content, and the use of a pinch gesture to 254 * control zooming. Whether or not these on-screen controls are displayed 255 * can be set with {@link #setDisplayZoomControls}. The default is false. 256 * <p> 257 * The built-in mechanisms are the only currently supported zoom 258 * mechanisms, so it is recommended that this setting is always enabled. 259 * 260 * @param enabled whether the WebView should use its built-in zoom mechanisms 261 */ 262 // This method was intended to select between the built-in zoom mechanisms 263 // and the separate zoom controls. The latter were obtained using 264 // {@link WebView#getZoomControls}, which is now hidden. 265 public void setBuiltInZoomControls(boolean enabled) { 266 throw new MustOverrideException(); 267 } 268 269 /** 270 * Gets whether the zoom mechanisms built into WebView are being used. 271 * 272 * @return true if the zoom mechanisms built into WebView are being used 273 * @see #setBuiltInZoomControls 274 */ 275 public boolean getBuiltInZoomControls() { 276 throw new MustOverrideException(); 277 } 278 279 /** 280 * Sets whether the WebView should display on-screen zoom controls when 281 * using the built-in zoom mechanisms. See {@link #setBuiltInZoomControls}. 282 * The default is true. 283 * 284 * @param enabled whether the WebView should display on-screen zoom controls 285 */ 286 public void setDisplayZoomControls(boolean enabled) { 287 throw new MustOverrideException(); 288 } 289 290 /** 291 * Gets whether the WebView displays on-screen zoom controls when using 292 * the built-in zoom mechanisms. 293 * 294 * @return true if the WebView displays on-screen zoom controls when using 295 * the built-in zoom mechanisms 296 * @see #setDisplayZoomControls 297 */ 298 public boolean getDisplayZoomControls() { 299 throw new MustOverrideException(); 300 } 301 302 /** 303 * Enables or disables file access within WebView. File access is enabled by 304 * default. Note that this enables or disables file system access only. 305 * Assets and resources are still accessible using file:///android_asset and 306 * file:///android_res. 307 */ 308 public void setAllowFileAccess(boolean allow) { 309 throw new MustOverrideException(); 310 } 311 312 /** 313 * Gets whether this WebView supports file access. 314 * 315 * @see #setAllowFileAccess 316 */ 317 public boolean getAllowFileAccess() { 318 throw new MustOverrideException(); 319 } 320 321 /** 322 * Enables or disables content URL access within WebView. Content URL 323 * access allows WebView to load content from a content provider installed 324 * in the system. The default is enabled. 325 */ 326 public void setAllowContentAccess(boolean allow) { 327 throw new MustOverrideException(); 328 } 329 330 /** 331 * Gets whether this WebView supports content URL access. 332 * 333 * @see #setAllowContentAccess 334 */ 335 public boolean getAllowContentAccess() { 336 throw new MustOverrideException(); 337 } 338 339 /** 340 * Sets whether the WebView loads pages in overview mode, that is, 341 * zooms out the content to fit on screen by width. This setting is 342 * taken into account when the content width is greater than the width 343 * of the WebView control, for example, when {@link #getUseWideViewPort} 344 * is enabled. The default is false. 345 */ 346 public void setLoadWithOverviewMode(boolean overview) { 347 throw new MustOverrideException(); 348 } 349 350 /** 351 * Gets whether this WebView loads pages in overview mode. 352 * 353 * @return whether this WebView loads pages in overview mode 354 * @see #setLoadWithOverviewMode 355 */ 356 public boolean getLoadWithOverviewMode() { 357 throw new MustOverrideException(); 358 } 359 360 /** 361 * Sets whether the WebView will enable smooth transition while panning or 362 * zooming or while the window hosting the WebView does not have focus. 363 * If it is true, WebView will choose a solution to maximize the performance. 364 * e.g. the WebView's content may not be updated during the transition. 365 * If it is false, WebView will keep its fidelity. The default value is false. 366 * 367 * @deprecated This method is now obsolete, and will become a no-op in future. 368 */ 369 @Deprecated 370 public void setEnableSmoothTransition(boolean enable) { 371 throw new MustOverrideException(); 372 } 373 374 /** 375 * Gets whether the WebView enables smooth transition while panning or 376 * zooming. 377 * 378 * @see #setEnableSmoothTransition 379 * 380 * @deprecated This method is now obsolete, and will become a no-op in future. 381 */ 382 @Deprecated 383 public boolean enableSmoothTransition() { 384 throw new MustOverrideException(); 385 } 386 387 /** 388 * Sets whether the WebView uses its background for over scroll background. 389 * If true, it will use the WebView's background. If false, it will use an 390 * internal pattern. Default is true. 391 * 392 * @deprecated This method is now obsolete. 393 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} 394 */ 395 @Deprecated 396 public void setUseWebViewBackgroundForOverscrollBackground(boolean view) { 397 throw new MustOverrideException(); 398 } 399 400 /** 401 * Gets whether this WebView uses WebView's background instead of 402 * internal pattern for over scroll background. 403 * 404 * @see #setUseWebViewBackgroundForOverscrollBackground 405 * @deprecated This method is now obsolete. 406 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} 407 */ 408 @Deprecated 409 public boolean getUseWebViewBackgroundForOverscrollBackground() { 410 throw new MustOverrideException(); 411 } 412 413 /** 414 * Sets whether the WebView should save form data. The default is true. 415 */ 416 public void setSaveFormData(boolean save) { 417 throw new MustOverrideException(); 418 } 419 420 /** 421 * Gets whether the WebView saves form data. 422 * 423 * @return whether the WebView saves form data 424 * @see #setSaveFormData 425 */ 426 public boolean getSaveFormData() { 427 throw new MustOverrideException(); 428 } 429 430 /** 431 * Sets whether the WebView should save passwords. The default is true. 432 * @deprecated Saving passwords in WebView will not be supported in future versions. 433 */ 434 @Deprecated 435 public void setSavePassword(boolean save) { 436 throw new MustOverrideException(); 437 } 438 439 /** 440 * Gets whether the WebView saves passwords. 441 * 442 * @return whether the WebView saves passwords 443 * @see #setSavePassword 444 * @deprecated Saving passwords in WebView will not be supported in future versions. 445 */ 446 @Deprecated 447 public boolean getSavePassword() { 448 throw new MustOverrideException(); 449 } 450 451 /** 452 * Sets the text zoom of the page in percent. The default is 100. 453 * 454 * @param textZoom the text zoom in percent 455 */ 456 public synchronized void setTextZoom(int textZoom) { 457 throw new MustOverrideException(); 458 } 459 460 /** 461 * Gets the text zoom of the page in percent. 462 * 463 * @return the text zoom of the page in percent 464 * @see #setTextZoom 465 */ 466 public synchronized int getTextZoom() { 467 throw new MustOverrideException(); 468 } 469 470 /** 471 * Sets the text size of the page. The default is {@link TextSize#NORMAL}. 472 * 473 * @param t the text size as a {@link TextSize} value 474 * @deprecated Use {@link #setTextZoom} instead. 475 */ 476 public synchronized void setTextSize(TextSize t) { 477 setTextZoom(t.value); 478 } 479 480 /** 481 * Gets the text size of the page. If the text size was previously specified 482 * in percent using {@link #setTextZoom}, this will return the closest 483 * matching {@link TextSize}. 484 * 485 * @return the text size as a {@link TextSize} value 486 * @see #setTextSize 487 * @deprecated Use {@link #getTextZoom} instead. 488 */ 489 public synchronized TextSize getTextSize() { 490 TextSize closestSize = null; 491 int smallestDelta = Integer.MAX_VALUE; 492 int textSize = getTextZoom(); 493 for (TextSize size : TextSize.values()) { 494 int delta = Math.abs(textSize - size.value); 495 if (delta == 0) { 496 return size; 497 } 498 if (delta < smallestDelta) { 499 smallestDelta = delta; 500 closestSize = size; 501 } 502 } 503 return closestSize != null ? closestSize : TextSize.NORMAL; 504 } 505 506 /** 507 * Sets the default zoom density of the page. This must be called from the UI 508 * thread. The default is {@link ZoomDensity#MEDIUM}. 509 * 510 * This setting is not recommended for use in new applications. If the WebView 511 * is utilized to display mobile-oriented pages, the desired effect can be achieved by 512 * adjusting 'width' and 'initial-scale' attributes of page's 'meta viewport' 513 * tag. For pages lacking the tag, {@link android.webkit.WebView#setInitialScale} 514 * and {@link #setUseWideViewPort} can be used. 515 * 516 * @param zoom the zoom density 517 * @deprecated This method is no longer supported, see the function documentation for 518 * recommended alternatives. 519 */ 520 @Deprecated 521 public void setDefaultZoom(ZoomDensity zoom) { 522 throw new MustOverrideException(); 523 } 524 525 /** 526 * Gets the default zoom density of the page. This should be called from 527 * the UI thread. 528 * 529 * This setting is not recommended for use in new applications. 530 * 531 * @return the zoom density 532 * @see #setDefaultZoom 533 * @deprecated Will only return the default value. 534 */ 535 public ZoomDensity getDefaultZoom() { 536 throw new MustOverrideException(); 537 } 538 539 /** 540 * Enables using light touches to make a selection and activate mouseovers. 541 * @deprecated From {@link android.os.Build.VERSION_CODES#JELLY_BEAN} this 542 * setting is obsolete and has no effect. 543 */ 544 @Deprecated 545 public void setLightTouchEnabled(boolean enabled) { 546 throw new MustOverrideException(); 547 } 548 549 /** 550 * Gets whether light touches are enabled. 551 * @see #setLightTouchEnabled 552 * @deprecated This setting is obsolete. 553 */ 554 @Deprecated 555 public boolean getLightTouchEnabled() { 556 throw new MustOverrideException(); 557 } 558 559 /** 560 * Controlled a rendering optimization that is no longer present. Setting 561 * it now has no effect. 562 * 563 * @deprecated This setting now has no effect. 564 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} 565 */ 566 @Deprecated 567 public synchronized void setUseDoubleTree(boolean use) { 568 // Specified to do nothing, so no need for derived classes to override. 569 } 570 571 /** 572 * Controlled a rendering optimization that is no longer present. Setting 573 * it now has no effect. 574 * 575 * @deprecated This setting now has no effect. 576 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} 577 */ 578 @Deprecated 579 public synchronized boolean getUseDoubleTree() { 580 // Returns false unconditionally, so no need for derived classes to override. 581 return false; 582 } 583 584 /** 585 * Sets the user-agent string using an integer code. 586 * <ul> 587 * <li>0 means the WebView should use an Android user-agent string</li> 588 * <li>1 means the WebView should use a desktop user-agent string</li> 589 * </ul> 590 * Other values are ignored. The default is an Android user-agent string, 591 * i.e. code value 0. 592 * 593 * @param ua the integer code for the user-agent string 594 * @deprecated Please use {@link #setUserAgentString} instead. 595 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} 596 */ 597 @Deprecated 598 public synchronized void setUserAgent(int ua) { 599 throw new MustOverrideException(); 600 } 601 602 /** 603 * Gets the user-agent as an integer code. 604 * <ul> 605 * <li>-1 means the WebView is using a custom user-agent string set with 606 * {@link #setUserAgentString}</li> 607 * <li>0 means the WebView should use an Android user-agent string</li> 608 * <li>1 means the WebView should use a desktop user-agent string</li> 609 * </ul> 610 * 611 * @return the integer code for the user-agent string 612 * @see #setUserAgent 613 * @deprecated Please use {@link #getUserAgentString} instead. 614 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR1} 615 */ 616 @Deprecated 617 public synchronized int getUserAgent() { 618 throw new MustOverrideException(); 619 } 620 621 /** 622 * Sets whether the WebView should enable support for the "viewport" 623 * HTML meta tag or should use a wide viewport. 624 * When the value of the setting is false, the layout width is always set to the 625 * width of the WebView control in device-independent (CSS) pixels. 626 * When the value is true and the page contains the viewport meta tag, the value 627 * of the width specified in the tag is used. If the page does not contain the tag or 628 * does not provide a width, then a wide viewport will be used. 629 * 630 * @param use whether to enable support for the viewport meta tag 631 */ 632 public synchronized void setUseWideViewPort(boolean use) { 633 throw new MustOverrideException(); 634 } 635 636 /** 637 * Gets whether the WebView supports the "viewport" 638 * HTML meta tag or will use a wide viewport. 639 * 640 * @return true if the WebView supports the viewport meta tag 641 * @see #setUseWideViewPort 642 */ 643 public synchronized boolean getUseWideViewPort() { 644 throw new MustOverrideException(); 645 } 646 647 /** 648 * Sets whether the WebView whether supports multiple windows. If set to 649 * true, {@link WebChromeClient#onCreateWindow} must be implemented by the 650 * host application. The default is false. 651 * 652 * @param support whether to suport multiple windows 653 */ 654 public synchronized void setSupportMultipleWindows(boolean support) { 655 throw new MustOverrideException(); 656 } 657 658 /** 659 * Gets whether the WebView supports multiple windows. 660 * 661 * @return true if the WebView supports multiple windows 662 * @see #setSupportMultipleWindows 663 */ 664 public synchronized boolean supportMultipleWindows() { 665 throw new MustOverrideException(); 666 } 667 668 /** 669 * Sets the underlying layout algorithm. This will cause a relayout of the 670 * WebView. The default is {@link LayoutAlgorithm#NARROW_COLUMNS}. 671 * 672 * @param l the layout algorithm to use, as a {@link LayoutAlgorithm} value 673 */ 674 public synchronized void setLayoutAlgorithm(LayoutAlgorithm l) { 675 throw new MustOverrideException(); 676 } 677 678 /** 679 * Gets the current layout algorithm. 680 * 681 * @return the layout algorithm in use, as a {@link LayoutAlgorithm} value 682 * @see #setLayoutAlgorithm 683 */ 684 public synchronized LayoutAlgorithm getLayoutAlgorithm() { 685 throw new MustOverrideException(); 686 } 687 688 /** 689 * Sets the standard font family name. The default is "sans-serif". 690 * 691 * @param font a font family name 692 */ 693 public synchronized void setStandardFontFamily(String font) { 694 throw new MustOverrideException(); 695 } 696 697 /** 698 * Gets the standard font family name. 699 * 700 * @return the standard font family name as a string 701 * @see #setStandardFontFamily 702 */ 703 public synchronized String getStandardFontFamily() { 704 throw new MustOverrideException(); 705 } 706 707 /** 708 * Sets the fixed font family name. The default is "monospace". 709 * 710 * @param font a font family name 711 */ 712 public synchronized void setFixedFontFamily(String font) { 713 throw new MustOverrideException(); 714 } 715 716 /** 717 * Gets the fixed font family name. 718 * 719 * @return the fixed font family name as a string 720 * @see #setFixedFontFamily 721 */ 722 public synchronized String getFixedFontFamily() { 723 throw new MustOverrideException(); 724 } 725 726 /** 727 * Sets the sans-serif font family name. The default is "sans-serif". 728 * 729 * @param font a font family name 730 */ 731 public synchronized void setSansSerifFontFamily(String font) { 732 throw new MustOverrideException(); 733 } 734 735 /** 736 * Gets the sans-serif font family name. 737 * 738 * @return the sans-serif font family name as a string 739 * @see #setSansSerifFontFamily 740 */ 741 public synchronized String getSansSerifFontFamily() { 742 throw new MustOverrideException(); 743 } 744 745 /** 746 * Sets the serif font family name. The default is "sans-serif". 747 * 748 * @param font a font family name 749 */ 750 public synchronized void setSerifFontFamily(String font) { 751 throw new MustOverrideException(); 752 } 753 754 /** 755 * Gets the serif font family name. The default is "serif". 756 * 757 * @return the serif font family name as a string 758 * @see #setSerifFontFamily 759 */ 760 public synchronized String getSerifFontFamily() { 761 throw new MustOverrideException(); 762 } 763 764 /** 765 * Sets the cursive font family name. The default is "cursive". 766 * 767 * @param font a font family name 768 */ 769 public synchronized void setCursiveFontFamily(String font) { 770 throw new MustOverrideException(); 771 } 772 773 /** 774 * Gets the cursive font family name. 775 * 776 * @return the cursive font family name as a string 777 * @see #setCursiveFontFamily 778 */ 779 public synchronized String getCursiveFontFamily() { 780 throw new MustOverrideException(); 781 } 782 783 /** 784 * Sets the fantasy font family name. The default is "fantasy". 785 * 786 * @param font a font family name 787 */ 788 public synchronized void setFantasyFontFamily(String font) { 789 throw new MustOverrideException(); 790 } 791 792 /** 793 * Gets the fantasy font family name. 794 * 795 * @return the fantasy font family name as a string 796 * @see #setFantasyFontFamily 797 */ 798 public synchronized String getFantasyFontFamily() { 799 throw new MustOverrideException(); 800 } 801 802 /** 803 * Sets the minimum font size. The default is 8. 804 * 805 * @param size a non-negative integer between 1 and 72. Any number outside 806 * the specified range will be pinned. 807 */ 808 public synchronized void setMinimumFontSize(int size) { 809 throw new MustOverrideException(); 810 } 811 812 /** 813 * Gets the minimum font size. 814 * 815 * @return a non-negative integer between 1 and 72 816 * @see #setMinimumFontSize 817 */ 818 public synchronized int getMinimumFontSize() { 819 throw new MustOverrideException(); 820 } 821 822 /** 823 * Sets the minimum logical font size. The default is 8. 824 * 825 * @param size a non-negative integer between 1 and 72. Any number outside 826 * the specified range will be pinned. 827 */ 828 public synchronized void setMinimumLogicalFontSize(int size) { 829 throw new MustOverrideException(); 830 } 831 832 /** 833 * Gets the minimum logical font size. 834 * 835 * @return a non-negative integer between 1 and 72 836 * @see #setMinimumLogicalFontSize 837 */ 838 public synchronized int getMinimumLogicalFontSize() { 839 throw new MustOverrideException(); 840 } 841 842 /** 843 * Sets the default font size. The default is 16. 844 * 845 * @param size a non-negative integer between 1 and 72. Any number outside 846 * the specified range will be pinned. 847 */ 848 public synchronized void setDefaultFontSize(int size) { 849 throw new MustOverrideException(); 850 } 851 852 /** 853 * Gets the default font size. 854 * 855 * @return a non-negative integer between 1 and 72 856 * @see #setDefaultFontSize 857 */ 858 public synchronized int getDefaultFontSize() { 859 throw new MustOverrideException(); 860 } 861 862 /** 863 * Sets the default fixed font size. The default is 16. 864 * 865 * @param size a non-negative integer between 1 and 72. Any number outside 866 * the specified range will be pinned. 867 */ 868 public synchronized void setDefaultFixedFontSize(int size) { 869 throw new MustOverrideException(); 870 } 871 872 /** 873 * Gets the default fixed font size. 874 * 875 * @return a non-negative integer between 1 and 72 876 * @see #setDefaultFixedFontSize 877 */ 878 public synchronized int getDefaultFixedFontSize() { 879 throw new MustOverrideException(); 880 } 881 882 /** 883 * Sets whether the WebView should load image resources. Note that this method 884 * controls loading of all images, including those embedded using the data 885 * URI scheme. Use {@link #setBlockNetworkImage} to control loading only 886 * of images specified using network URI schemes. Note that if the value of this 887 * setting is changed from false to true, all images resources referenced 888 * by content currently displayed by the WebView are loaded automatically. 889 * The default is true. 890 * 891 * @param flag whether the WebView should load image resources 892 */ 893 public synchronized void setLoadsImagesAutomatically(boolean flag) { 894 throw new MustOverrideException(); 895 } 896 897 /** 898 * Gets whether the WebView loads image resources. This includes 899 * images embedded using the data URI scheme. 900 * 901 * @return true if the WebView loads image resources 902 * @see #setLoadsImagesAutomatically 903 */ 904 public synchronized boolean getLoadsImagesAutomatically() { 905 throw new MustOverrideException(); 906 } 907 908 /** 909 * Sets whether the WebView should not load image resources from the 910 * network (resources accessed via http and https URI schemes). Note 911 * that this method has no effect unless 912 * {@link #getLoadsImagesAutomatically} returns true. Also note that 913 * disabling all network loads using {@link #setBlockNetworkLoads} 914 * will also prevent network images from loading, even if this flag is set 915 * to false. When the value of this setting is changed from true to false, 916 * network images resources referenced by content currently displayed by 917 * the WebView are fetched automatically. The default is false. 918 * 919 * @param flag whether the WebView should not load image resources from the 920 * network 921 * @see #setBlockNetworkLoads 922 */ 923 public synchronized void setBlockNetworkImage(boolean flag) { 924 throw new MustOverrideException(); 925 } 926 927 /** 928 * Gets whether the WebView does not load image resources from the network. 929 * 930 * @return true if the WebView does not load image resources from the network 931 * @see #setBlockNetworkImage 932 */ 933 public synchronized boolean getBlockNetworkImage() { 934 throw new MustOverrideException(); 935 } 936 937 /** 938 * Sets whether the WebView should not load resources from the network. 939 * Use {@link #setBlockNetworkImage} to only avoid loading 940 * image resources. Note that if the value of this setting is 941 * changed from true to false, network resources referenced by content 942 * currently displayed by the WebView are not fetched until 943 * {@link android.webkit.WebView#reload} is called. 944 * If the application does not have the 945 * {@link android.Manifest.permission#INTERNET} permission, attempts to set 946 * a value of false will cause a {@link java.lang.SecurityException} 947 * to be thrown. The default value is false if the application has the 948 * {@link android.Manifest.permission#INTERNET} permission, otherwise it is 949 * true. 950 * 951 * @param flag whether the WebView should not load any resources from the 952 * network 953 * @see android.webkit.WebView#reload 954 */ 955 public synchronized void setBlockNetworkLoads(boolean flag) { 956 throw new MustOverrideException(); 957 } 958 959 /** 960 * Gets whether the WebView does not load any resources from the network. 961 * 962 * @return true if the WebView does not load any resources from the network 963 * @see #setBlockNetworkLoads 964 */ 965 public synchronized boolean getBlockNetworkLoads() { 966 throw new MustOverrideException(); 967 } 968 969 /** 970 * Tells the WebView to enable JavaScript execution. 971 * <b>The default is false.</b> 972 * 973 * @param flag true if the WebView should execute JavaScript 974 */ 975 public synchronized void setJavaScriptEnabled(boolean flag) { 976 throw new MustOverrideException(); 977 } 978 979 /** 980 * Sets whether JavaScript running in the context of a file scheme URL 981 * should be allowed to access content from any origin. This includes 982 * access to content from other file scheme URLs. See 983 * {@link #setAllowFileAccessFromFileURLs}. To enable the most restrictive, 984 * and therefore secure policy, this setting should be disabled. 985 * Note that this setting affects only JavaScript access to file scheme 986 * resources. Other access to such resources, for example, from image HTML 987 * elements, is unaffected. 988 * <p> 989 * The default value is true for API level 990 * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below, 991 * and false for API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN} 992 * and above. 993 * 994 * @param flag whether JavaScript running in the context of a file scheme 995 * URL should be allowed to access content from any origin 996 */ 997 public abstract void setAllowUniversalAccessFromFileURLs(boolean flag); 998 999 /** 1000 * Sets whether JavaScript running in the context of a file scheme URL 1001 * should be allowed to access content from other file scheme URLs. To 1002 * enable the most restrictive, and therefore secure policy, this setting 1003 * should be disabled. Note that the value of this setting is ignored if 1004 * the value of {@link #getAllowUniversalAccessFromFileURLs} is true. 1005 * Note too, that this setting affects only JavaScript access to file scheme 1006 * resources. Other access to such resources, for example, from image HTML 1007 * elements, is unaffected. 1008 * <p> 1009 * The default value is true for API level 1010 * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH_MR1} and below, 1011 * and false for API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN} 1012 * and above. 1013 * 1014 * @param flag whether JavaScript running in the context of a file scheme 1015 * URL should be allowed to access content from other file 1016 * scheme URLs 1017 */ 1018 public abstract void setAllowFileAccessFromFileURLs(boolean flag); 1019 1020 /** 1021 * Sets whether the WebView should enable plugins. The default is false. 1022 * 1023 * @param flag true if plugins should be enabled 1024 * @deprecated This method has been deprecated in favor of 1025 * {@link #setPluginState} 1026 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2} 1027 */ 1028 @Deprecated 1029 public synchronized void setPluginsEnabled(boolean flag) { 1030 throw new MustOverrideException(); 1031 } 1032 1033 /** 1034 * Tells the WebView to enable, disable, or have plugins on demand. On 1035 * demand mode means that if a plugin exists that can handle the embedded 1036 * content, a placeholder icon will be shown instead of the plugin. When 1037 * the placeholder is clicked, the plugin will be enabled. The default is 1038 * {@link PluginState#OFF}. 1039 * 1040 * @param state a PluginState value 1041 * @deprecated Plugins will not be supported in future, and should not be used. 1042 */ 1043 @Deprecated 1044 public synchronized void setPluginState(PluginState state) { 1045 throw new MustOverrideException(); 1046 } 1047 1048 /** 1049 * Sets a custom path to plugins used by the WebView. This method is 1050 * obsolete since each plugin is now loaded from its own package. 1051 * 1052 * @param pluginsPath a String path to the directory containing plugins 1053 * @deprecated This method is no longer used as plugins are loaded from 1054 * their own APK via the system's package manager. 1055 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2} 1056 */ 1057 @Deprecated 1058 public synchronized void setPluginsPath(String pluginsPath) { 1059 // Specified to do nothing, so no need for derived classes to override. 1060 } 1061 1062 /** 1063 * Sets the path to where database storage API databases should be saved. 1064 * In order for the database storage API to function correctly, this method 1065 * must be called with a path to which the application can write. This 1066 * method should only be called once: repeated calls are ignored. 1067 * 1068 * @param databasePath a path to the directory where databases should be 1069 * saved. 1070 * @deprecated Database paths are managed by the implementation and calling this method 1071 * will have no effect. 1072 */ 1073 // This will update WebCore when the Sync runs in the C++ side. 1074 // Note that the WebCore Database Tracker only allows the path to be set 1075 // once. 1076 @Deprecated 1077 public synchronized void setDatabasePath(String databasePath) { 1078 throw new MustOverrideException(); 1079 } 1080 1081 /** 1082 * Sets the path where the Geolocation databases should be saved. In order 1083 * for Geolocation permissions and cached positions to be persisted, this 1084 * method must be called with a path to which the application can write. 1085 * 1086 * @param databasePath a path to the directory where databases should be 1087 * saved. 1088 */ 1089 // This will update WebCore when the Sync runs in the C++ side. 1090 public synchronized void setGeolocationDatabasePath(String databasePath) { 1091 throw new MustOverrideException(); 1092 } 1093 1094 /** 1095 * Sets whether the Application Caches API should be enabled. The default 1096 * is false. Note that in order for the Application Caches API to be 1097 * enabled, a valid database path must also be supplied to 1098 * {@link #setAppCachePath}. 1099 * 1100 * @param flag true if the WebView should enable Application Caches 1101 */ 1102 public synchronized void setAppCacheEnabled(boolean flag) { 1103 throw new MustOverrideException(); 1104 } 1105 1106 /** 1107 * Sets the path to the Application Caches files. In order for the 1108 * Application Caches API to be enabled, this method must be called with a 1109 * path to which the application can write. This method should only be 1110 * called once: repeated calls are ignored. 1111 * 1112 * @param appCachePath a String path to the directory containing 1113 * Application Caches files. 1114 * @see #setAppCacheEnabled 1115 */ 1116 public synchronized void setAppCachePath(String appCachePath) { 1117 throw new MustOverrideException(); 1118 } 1119 1120 /** 1121 * Sets the maximum size for the Application Cache content. The passed size 1122 * will be rounded to the nearest value that the database can support, so 1123 * this should be viewed as a guide, not a hard limit. Setting the 1124 * size to a value less than current database size does not cause the 1125 * database to be trimmed. The default size is {@link Long#MAX_VALUE}. 1126 * It is recommended to leave the maximum size set to the default value. 1127 * 1128 * @param appCacheMaxSize the maximum size in bytes 1129 * @deprecated In future quota will be managed automatically. 1130 */ 1131 @Deprecated 1132 public synchronized void setAppCacheMaxSize(long appCacheMaxSize) { 1133 throw new MustOverrideException(); 1134 } 1135 1136 /** 1137 * Sets whether the database storage API is enabled. The default value is 1138 * false. See also {@link #setDatabasePath} for how to correctly set up the 1139 * database storage API. 1140 * 1141 * This setting is global in effect, across all WebView instances in a process. 1142 * Note you should only modify this setting prior to making <b>any</b> WebView 1143 * page load within a given process, as the WebView implementation may ignore 1144 * changes to this setting after that point. 1145 * 1146 * @param flag true if the WebView should use the database storage API 1147 */ 1148 public synchronized void setDatabaseEnabled(boolean flag) { 1149 throw new MustOverrideException(); 1150 } 1151 1152 /** 1153 * Sets whether the DOM storage API is enabled. The default value is false. 1154 * 1155 * @param flag true if the WebView should use the DOM storage API 1156 */ 1157 public synchronized void setDomStorageEnabled(boolean flag) { 1158 throw new MustOverrideException(); 1159 } 1160 1161 /** 1162 * Gets whether the DOM Storage APIs are enabled. 1163 * 1164 * @return true if the DOM Storage APIs are enabled 1165 * @see #setDomStorageEnabled 1166 */ 1167 public synchronized boolean getDomStorageEnabled() { 1168 throw new MustOverrideException(); 1169 } 1170 /** 1171 * Gets the path to where database storage API databases are saved. 1172 * 1173 * @return the String path to the database storage API databases 1174 * @see #setDatabasePath 1175 * @deprecated Database paths are managed by the implementation this method is obsolete. 1176 */ 1177 @Deprecated 1178 public synchronized String getDatabasePath() { 1179 throw new MustOverrideException(); 1180 } 1181 1182 /** 1183 * Gets whether the database storage API is enabled. 1184 * 1185 * @return true if the database storage API is enabled 1186 * @see #setDatabaseEnabled 1187 */ 1188 public synchronized boolean getDatabaseEnabled() { 1189 throw new MustOverrideException(); 1190 } 1191 1192 /** 1193 * Sets whether Geolocation is enabled. The default is true. 1194 * <p> 1195 * Please note that in order for the Geolocation API to be usable 1196 * by a page in the WebView, the following requirements must be met: 1197 * <ul> 1198 * <li>an application must have permission to access the device location, 1199 * see {@link android.Manifest.permission#ACCESS_COARSE_LOCATION}, 1200 * {@link android.Manifest.permission#ACCESS_FINE_LOCATION}; 1201 * <li>an application must provide an implementation of the 1202 * {@link WebChromeClient#onGeolocationPermissionsShowPrompt} callback 1203 * to receive notifications that a page is requesting access to location 1204 * via the JavaScript Geolocation API. 1205 * </ul> 1206 * <p> 1207 * As an option, it is possible to store previous locations and web origin 1208 * permissions in a database. See {@link #setGeolocationDatabasePath}. 1209 * 1210 * @param flag whether Geolocation should be enabled 1211 */ 1212 public synchronized void setGeolocationEnabled(boolean flag) { 1213 throw new MustOverrideException(); 1214 } 1215 1216 /** 1217 * Gets whether JavaScript is enabled. 1218 * 1219 * @return true if JavaScript is enabled 1220 * @see #setJavaScriptEnabled 1221 */ 1222 public synchronized boolean getJavaScriptEnabled() { 1223 throw new MustOverrideException(); 1224 } 1225 1226 /** 1227 * Gets whether JavaScript running in the context of a file scheme URL can 1228 * access content from any origin. This includes access to content from 1229 * other file scheme URLs. 1230 * 1231 * @return whether JavaScript running in the context of a file scheme URL 1232 * can access content from any origin 1233 * @see #setAllowUniversalAccessFromFileURLs 1234 */ 1235 public abstract boolean getAllowUniversalAccessFromFileURLs(); 1236 1237 /** 1238 * Gets whether JavaScript running in the context of a file scheme URL can 1239 * access content from other file scheme URLs. 1240 * 1241 * @return whether JavaScript running in the context of a file scheme URL 1242 * can access content from other file scheme URLs 1243 * @see #setAllowFileAccessFromFileURLs 1244 */ 1245 public abstract boolean getAllowFileAccessFromFileURLs(); 1246 1247 /** 1248 * Gets whether plugins are enabled. 1249 * 1250 * @return true if plugins are enabled 1251 * @see #setPluginsEnabled 1252 * @deprecated This method has been replaced by {@link #getPluginState} 1253 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2} 1254 */ 1255 @Deprecated 1256 public synchronized boolean getPluginsEnabled() { 1257 throw new MustOverrideException(); 1258 } 1259 1260 /** 1261 * Gets the current state regarding whether plugins are enabled. 1262 * 1263 * @return the plugin state as a {@link PluginState} value 1264 * @see #setPluginState 1265 * @deprecated Plugins will not be supported in future, and should not be used. 1266 */ 1267 @Deprecated 1268 public synchronized PluginState getPluginState() { 1269 throw new MustOverrideException(); 1270 } 1271 1272 /** 1273 * Gets the directory that contains the plugin libraries. This method is 1274 * obsolete since each plugin is now loaded from its own package. 1275 * 1276 * @return an empty string 1277 * @deprecated This method is no longer used as plugins are loaded from 1278 * their own APK via the system's package manager. 1279 * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN_MR2} 1280 */ 1281 @Deprecated 1282 public synchronized String getPluginsPath() { 1283 // Unconditionally returns empty string, so no need for derived classes to override. 1284 return ""; 1285 } 1286 1287 /** 1288 * Tells JavaScript to open windows automatically. This applies to the 1289 * JavaScript function window.open(). The default is false. 1290 * 1291 * @param flag true if JavaScript can open windows automatically 1292 */ 1293 public synchronized void setJavaScriptCanOpenWindowsAutomatically(boolean flag) { 1294 throw new MustOverrideException(); 1295 } 1296 1297 /** 1298 * Gets whether JavaScript can open windows automatically. 1299 * 1300 * @return true if JavaScript can open windows automatically during 1301 * window.open() 1302 * @see #setJavaScriptCanOpenWindowsAutomatically 1303 */ 1304 public synchronized boolean getJavaScriptCanOpenWindowsAutomatically() { 1305 throw new MustOverrideException(); 1306 } 1307 /** 1308 * Sets the default text encoding name to use when decoding html pages. 1309 * The default is "Latin-1". 1310 * 1311 * @param encoding the text encoding name 1312 */ 1313 public synchronized void setDefaultTextEncodingName(String encoding) { 1314 throw new MustOverrideException(); 1315 } 1316 1317 /** 1318 * Gets the default text encoding name. 1319 * 1320 * @return the default text encoding name as a string 1321 * @see #setDefaultTextEncodingName 1322 */ 1323 public synchronized String getDefaultTextEncodingName() { 1324 throw new MustOverrideException(); 1325 } 1326 1327 /** 1328 * Sets the WebView's user-agent string. If the string is null or empty, 1329 * the system default value will be used. 1330 */ 1331 public synchronized void setUserAgentString(String ua) { 1332 throw new MustOverrideException(); 1333 } 1334 1335 /** 1336 * Gets the WebView's user-agent string. 1337 * 1338 * @return the WebView's user-agent string 1339 * @see #setUserAgentString 1340 */ 1341 public synchronized String getUserAgentString() { 1342 throw new MustOverrideException(); 1343 } 1344 1345 /** 1346 * Returns the default User-Agent used by a WebView. 1347 * An instance of WebView could use a different User-Agent if a call 1348 * is made to {@link WebSettings#setUserAgentString(String)}. 1349 * 1350 * @param context a Context object used to access application assets 1351 */ 1352 public static String getDefaultUserAgent(Context context) { 1353 return WebViewFactory.getProvider().getStatics().getDefaultUserAgent(context); 1354 } 1355 1356 /** 1357 * Tells the WebView whether it needs to set a node to have focus when 1358 * {@link WebView#requestFocus(int, android.graphics.Rect)} is called. The 1359 * default value is true. 1360 * 1361 * @param flag whether the WebView needs to set a node 1362 */ 1363 public void setNeedInitialFocus(boolean flag) { 1364 throw new MustOverrideException(); 1365 } 1366 1367 /** 1368 * Sets the priority of the Render thread. Unlike the other settings, this 1369 * one only needs to be called once per process. The default value is 1370 * {@link RenderPriority#NORMAL}. 1371 * 1372 * @param priority the priority 1373 * @deprecated It is not recommended to adjust thread priorities, and this will 1374 * not be supported in future versions. 1375 */ 1376 @Deprecated 1377 public synchronized void setRenderPriority(RenderPriority priority) { 1378 throw new MustOverrideException(); 1379 } 1380 1381 /** 1382 * Overrides the way the cache is used. The way the cache is used is based 1383 * on the navigation type. For a normal page load, the cache is checked 1384 * and content is re-validated as needed. When navigating back, content is 1385 * not revalidated, instead the content is just retrieved from the cache. 1386 * This method allows the client to override this behavior by specifying 1387 * one of {@link #LOAD_DEFAULT}, 1388 * {@link #LOAD_CACHE_ELSE_NETWORK}, {@link #LOAD_NO_CACHE} or 1389 * {@link #LOAD_CACHE_ONLY}. The default value is {@link #LOAD_DEFAULT}. 1390 * 1391 * @param mode the mode to use 1392 */ 1393 public void setCacheMode(int mode) { 1394 throw new MustOverrideException(); 1395 } 1396 1397 /** 1398 * Gets the current setting for overriding the cache mode. 1399 * 1400 * @return the current setting for overriding the cache mode 1401 * @see #setCacheMode 1402 */ 1403 public int getCacheMode() { 1404 throw new MustOverrideException(); 1405 } 1406} 1407