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