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