WebView.java revision 72498edd88557218f1b72454c84ec2a2630beab6
1/*
2 * Copyright (C) 2006 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.annotation.Widget;
20import android.content.Context;
21import android.content.res.Configuration;
22import android.graphics.Bitmap;
23import android.graphics.Canvas;
24import android.graphics.Paint;
25import android.graphics.Picture;
26import android.graphics.Rect;
27import android.graphics.drawable.Drawable;
28import android.net.http.SslCertificate;
29import android.os.Bundle;
30import android.os.Looper;
31import android.os.Message;
32import android.os.StrictMode;
33import android.util.AttributeSet;
34import android.util.Log;
35import android.view.KeyEvent;
36import android.view.MotionEvent;
37import android.view.View;
38import android.view.ViewDebug;
39import android.view.ViewGroup;
40import android.view.ViewTreeObserver;
41import android.view.accessibility.AccessibilityEvent;
42import android.view.accessibility.AccessibilityNodeInfo;
43import android.view.inputmethod.EditorInfo;
44import android.view.inputmethod.InputConnection;
45import android.widget.AbsoluteLayout;
46
47import java.io.BufferedWriter;
48import java.io.File;
49import java.util.Map;
50
51/**
52 * <p>A View that displays web pages. This class is the basis upon which you
53 * can roll your own web browser or simply display some online content within your Activity.
54 * It uses the WebKit rendering engine to display
55 * web pages and includes methods to navigate forward and backward
56 * through a history, zoom in and out, perform text searches and more.</p>
57 * <p>To enable the built-in zoom, set
58 * {@link #getSettings() WebSettings}.{@link WebSettings#setBuiltInZoomControls(boolean)}
59 * (introduced in API level {@link android.os.Build.VERSION_CODES#CUPCAKE}).
60 * <p>Note that, in order for your Activity to access the Internet and load web pages
61 * in a WebView, you must add the {@code INTERNET} permissions to your
62 * Android Manifest file:</p>
63 * <pre>&lt;uses-permission android:name="android.permission.INTERNET" /></pre>
64 *
65 * <p>This must be a child of the <a
66 * href="{@docRoot}guide/topics/manifest/manifest-element.html">{@code <manifest>}</a>
67 * element.</p>
68 *
69 * <p>See the <a href="{@docRoot}resources/tutorials/views/hello-webview.html">Web View
70 * tutorial</a>.</p>
71 *
72 * <h3>Basic usage</h3>
73 *
74 * <p>By default, a WebView provides no browser-like widgets, does not
75 * enable JavaScript and web page errors are ignored. If your goal is only
76 * to display some HTML as a part of your UI, this is probably fine;
77 * the user won't need to interact with the web page beyond reading
78 * it, and the web page won't need to interact with the user. If you
79 * actually want a full-blown web browser, then you probably want to
80 * invoke the Browser application with a URL Intent rather than show it
81 * with a WebView. For example:
82 * <pre>
83 * Uri uri = Uri.parse("http://www.example.com");
84 * Intent intent = new Intent(Intent.ACTION_VIEW, uri);
85 * startActivity(intent);
86 * </pre>
87 * <p>See {@link android.content.Intent} for more information.</p>
88 *
89 * <p>To provide a WebView in your own Activity, include a {@code <WebView>} in your layout,
90 * or set the entire Activity window as a WebView during {@link
91 * android.app.Activity#onCreate(Bundle) onCreate()}:</p>
92 * <pre class="prettyprint">
93 * WebView webview = new WebView(this);
94 * setContentView(webview);
95 * </pre>
96 *
97 * <p>Then load the desired web page:</p>
98 * <pre>
99 * // Simplest usage: note that an exception will NOT be thrown
100 * // if there is an error loading this page (see below).
101 * webview.loadUrl("http://slashdot.org/");
102 *
103 * // OR, you can also load from an HTML string:
104 * String summary = "&lt;html>&lt;body>You scored &lt;b>192&lt;/b> points.&lt;/body>&lt;/html>";
105 * webview.loadData(summary, "text/html", null);
106 * // ... although note that there are restrictions on what this HTML can do.
107 * // See the JavaDocs for {@link #loadData(String,String,String) loadData()} and {@link
108 * #loadDataWithBaseURL(String,String,String,String,String) loadDataWithBaseURL()} for more info.
109 * </pre>
110 *
111 * <p>A WebView has several customization points where you can add your
112 * own behavior. These are:</p>
113 *
114 * <ul>
115 *   <li>Creating and setting a {@link android.webkit.WebChromeClient} subclass.
116 *       This class is called when something that might impact a
117 *       browser UI happens, for instance, progress updates and
118 *       JavaScript alerts are sent here (see <a
119 * href="{@docRoot}guide/developing/debug-tasks.html#DebuggingWebPages">Debugging Tasks</a>).
120 *   </li>
121 *   <li>Creating and setting a {@link android.webkit.WebViewClient} subclass.
122 *       It will be called when things happen that impact the
123 *       rendering of the content, eg, errors or form submissions. You
124 *       can also intercept URL loading here (via {@link
125 * android.webkit.WebViewClient#shouldOverrideUrlLoading(WebView,String)
126 * shouldOverrideUrlLoading()}).</li>
127 *   <li>Modifying the {@link android.webkit.WebSettings}, such as
128 * enabling JavaScript with {@link android.webkit.WebSettings#setJavaScriptEnabled(boolean)
129 * setJavaScriptEnabled()}. </li>
130 *   <li>Injecting Java objects into the WebView using the
131 *       {@link android.webkit.WebView#addJavascriptInterface} method. This
132 *       method allows you to inject Java objects into a page's JavaScript
133 *       context, so that they can be accessed by JavaScript in the page.</li>
134 * </ul>
135 *
136 * <p>Here's a more complicated example, showing error handling,
137 *    settings, and progress notification:</p>
138 *
139 * <pre class="prettyprint">
140 * // Let's display the progress in the activity title bar, like the
141 * // browser app does.
142 * getWindow().requestFeature(Window.FEATURE_PROGRESS);
143 *
144 * webview.getSettings().setJavaScriptEnabled(true);
145 *
146 * final Activity activity = this;
147 * webview.setWebChromeClient(new WebChromeClient() {
148 *   public void onProgressChanged(WebView view, int progress) {
149 *     // Activities and WebViews measure progress with different scales.
150 *     // The progress meter will automatically disappear when we reach 100%
151 *     activity.setProgress(progress * 1000);
152 *   }
153 * });
154 * webview.setWebViewClient(new WebViewClient() {
155 *   public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
156 *     Toast.makeText(activity, "Oh no! " + description, Toast.LENGTH_SHORT).show();
157 *   }
158 * });
159 *
160 * webview.loadUrl("http://slashdot.org/");
161 * </pre>
162 *
163 * <h3>Cookie and window management</h3>
164 *
165 * <p>For obvious security reasons, your application has its own
166 * cache, cookie store etc.&mdash;it does not share the Browser
167 * application's data. Cookies are managed on a separate thread, so
168 * operations like index building don't block the UI
169 * thread. Follow the instructions in {@link android.webkit.CookieSyncManager}
170 * if you want to use cookies in your application.
171 * </p>
172 *
173 * <p>By default, requests by the HTML to open new windows are
174 * ignored. This is true whether they be opened by JavaScript or by
175 * the target attribute on a link. You can customize your
176 * {@link WebChromeClient} to provide your own behaviour for opening multiple windows,
177 * and render them in whatever manner you want.</p>
178 *
179 * <p>The standard behavior for an Activity is to be destroyed and
180 * recreated when the device orientation or any other configuration changes. This will cause
181 * the WebView to reload the current page. If you don't want that, you
182 * can set your Activity to handle the {@code orientation} and {@code keyboardHidden}
183 * changes, and then just leave the WebView alone. It'll automatically
184 * re-orient itself as appropriate. Read <a
185 * href="{@docRoot}guide/topics/resources/runtime-changes.html">Handling Runtime Changes</a> for
186 * more information about how to handle configuration changes during runtime.</p>
187 *
188 *
189 * <h3>Building web pages to support different screen densities</h3>
190 *
191 * <p>The screen density of a device is based on the screen resolution. A screen with low density
192 * has fewer available pixels per inch, where a screen with high density
193 * has more &mdash; sometimes significantly more &mdash; pixels per inch. The density of a
194 * screen is important because, other things being equal, a UI element (such as a button) whose
195 * height and width are defined in terms of screen pixels will appear larger on the lower density
196 * screen and smaller on the higher density screen.
197 * For simplicity, Android collapses all actual screen densities into three generalized densities:
198 * high, medium, and low.</p>
199 * <p>By default, WebView scales a web page so that it is drawn at a size that matches the default
200 * appearance on a medium density screen. So, it applies 1.5x scaling on a high density screen
201 * (because its pixels are smaller) and 0.75x scaling on a low density screen (because its pixels
202 * are bigger).
203 * Starting with API level {@link android.os.Build.VERSION_CODES#ECLAIR}, WebView supports DOM, CSS,
204 * and meta tag features to help you (as a web developer) target screens with different screen
205 * densities.</p>
206 * <p>Here's a summary of the features you can use to handle different screen densities:</p>
207 * <ul>
208 * <li>The {@code window.devicePixelRatio} DOM property. The value of this property specifies the
209 * default scaling factor used for the current device. For example, if the value of {@code
210 * window.devicePixelRatio} is "1.0", then the device is considered a medium density (mdpi) device
211 * and default scaling is not applied to the web page; if the value is "1.5", then the device is
212 * considered a high density device (hdpi) and the page content is scaled 1.5x; if the
213 * value is "0.75", then the device is considered a low density device (ldpi) and the content is
214 * scaled 0.75x. However, if you specify the {@code "target-densitydpi"} meta property
215 * (discussed below), then you can stop this default scaling behavior.</li>
216 * <li>The {@code -webkit-device-pixel-ratio} CSS media query. Use this to specify the screen
217 * densities for which this style sheet is to be used. The corresponding value should be either
218 * "0.75", "1", or "1.5", to indicate that the styles are for devices with low density, medium
219 * density, or high density screens, respectively. For example:
220 * <pre>
221 * &lt;link rel="stylesheet" media="screen and (-webkit-device-pixel-ratio:1.5)" href="hdpi.css" /&gt;</pre>
222 * <p>The {@code hdpi.css} stylesheet is only used for devices with a screen pixel ration of 1.5,
223 * which is the high density pixel ratio.</p>
224 * </li>
225 * <li>The {@code target-densitydpi} property for the {@code viewport} meta tag. You can use
226 * this to specify the target density for which the web page is designed, using the following
227 * values:
228 * <ul>
229 * <li>{@code device-dpi} - Use the device's native dpi as the target dpi. Default scaling never
230 * occurs.</li>
231 * <li>{@code high-dpi} - Use hdpi as the target dpi. Medium and low density screens scale down
232 * as appropriate.</li>
233 * <li>{@code medium-dpi} - Use mdpi as the target dpi. High density screens scale up and
234 * low density screens scale down. This is also the default behavior.</li>
235 * <li>{@code low-dpi} - Use ldpi as the target dpi. Medium and high density screens scale up
236 * as appropriate.</li>
237 * <li><em>{@code <value>}</em> - Specify a dpi value to use as the target dpi (accepted
238 * values are 70-400).</li>
239 * </ul>
240 * <p>Here's an example meta tag to specify the target density:</p>
241 * <pre>&lt;meta name="viewport" content="target-densitydpi=device-dpi" /&gt;</pre></li>
242 * </ul>
243 * <p>If you want to modify your web page for different densities, by using the {@code
244 * -webkit-device-pixel-ratio} CSS media query and/or the {@code
245 * window.devicePixelRatio} DOM property, then you should set the {@code target-densitydpi} meta
246 * property to {@code device-dpi}. This stops Android from performing scaling in your web page and
247 * allows you to make the necessary adjustments for each density via CSS and JavaScript.</p>
248 *
249 * <h3>HTML5 Video support</h3>
250 *
251 * <p>In order to support inline HTML5 video in your application, you need to have hardware
252 * acceleration turned on, and set a {@link android.webkit.WebChromeClient}. For full screen support,
253 * implementations of {@link WebChromeClient#onShowCustomView(View, WebChromeClient.CustomViewCallback)}
254 * and {@link WebChromeClient#onHideCustomView()} are required,
255 * {@link WebChromeClient#getVideoLoadingProgressView()} is optional.
256 * </p>
257 */
258// Implementation notes.
259// The WebView is a thin API class that delegates its public API to a backend WebViewProvider
260// class instance. WebView extends {@link AbsoluteLayout} for backward compatibility reasons.
261// Methods are delegated to the provider implementation: all public API methods introduced in this
262// file are fully delegated, whereas public and protected methods from the View base classes are
263// only delegated where a specific need exists for them to do so.
264@Widget
265public class WebView extends AbsoluteLayout
266        implements ViewTreeObserver.OnGlobalFocusChangeListener,
267        ViewGroup.OnHierarchyChangeListener, ViewDebug.HierarchyHandler {
268
269    private static final String LOGTAG = "webview_proxy";
270
271    /**
272     *  Transportation object for returning WebView across thread boundaries.
273     */
274    public class WebViewTransport {
275        private WebView mWebview;
276
277        /**
278         * Sets the WebView to the transportation object.
279         *
280         * @param webview the WebView to transport
281         */
282        public synchronized void setWebView(WebView webview) {
283            mWebview = webview;
284        }
285
286        /**
287         * Gets the WebView object.
288         *
289         * @return the transported WebView object
290         */
291        public synchronized WebView getWebView() {
292            return mWebview;
293        }
294    }
295
296    /**
297     * URI scheme for telephone number.
298     */
299    public static final String SCHEME_TEL = "tel:";
300    /**
301     * URI scheme for email address.
302     */
303    public static final String SCHEME_MAILTO = "mailto:";
304    /**
305     * URI scheme for map address.
306     */
307    public static final String SCHEME_GEO = "geo:0,0?q=";
308
309    /**
310     * Interface to listen for find results.
311     */
312    public interface FindListener {
313        /**
314         * Notifies the listener about progress made by a find operation.
315         *
316         * @param numberOfMatches how many matches have been found
317         * @param activeMatchOrdinal the zero-based ordinal of the currently selected match
318         * @param isDoneCounting whether the find operation has actually completed. The listener
319         *                       may be notified multiple times while the
320         *                       operation is underway, and the numberOfMatches
321         *                       value should not be considered final unless
322         *                       isDoneCounting is true.
323         */
324        public void onFindResultReceived(int numberOfMatches, int activeMatchOrdinal,
325            boolean isDoneCounting);
326    }
327
328    /**
329     * Interface to listen for new pictures as they change.
330     *
331     * @deprecated This interface is now obsolete.
332     */
333    @Deprecated
334    public interface PictureListener {
335        /**
336         * Used to provide notification that the WebView's picture has changed.
337         * See {@link WebView#capturePicture} for details of the picture.
338         *
339         * @param view the WebView that owns the picture
340         * @param picture the new picture
341         * @deprecated Deprecated due to internal changes.
342         */
343        @Deprecated
344        public void onNewPicture(WebView view, Picture picture);
345    }
346
347    public static class HitTestResult {
348        /**
349         * Default HitTestResult, where the target is unknown.
350         */
351        public static final int UNKNOWN_TYPE = 0;
352        /**
353         * @deprecated This type is no longer used.
354         */
355        @Deprecated
356        public static final int ANCHOR_TYPE = 1;
357        /**
358         * HitTestResult for hitting a phone number.
359         */
360        public static final int PHONE_TYPE = 2;
361        /**
362         * HitTestResult for hitting a map address.
363         */
364        public static final int GEO_TYPE = 3;
365        /**
366         * HitTestResult for hitting an email address.
367         */
368        public static final int EMAIL_TYPE = 4;
369        /**
370         * HitTestResult for hitting an HTML::img tag.
371         */
372        public static final int IMAGE_TYPE = 5;
373        /**
374         * @deprecated This type is no longer used.
375         */
376        @Deprecated
377        public static final int IMAGE_ANCHOR_TYPE = 6;
378        /**
379         * HitTestResult for hitting a HTML::a tag with src=http.
380         */
381        public static final int SRC_ANCHOR_TYPE = 7;
382        /**
383         * HitTestResult for hitting a HTML::a tag with src=http + HTML::img.
384         */
385        public static final int SRC_IMAGE_ANCHOR_TYPE = 8;
386        /**
387         * HitTestResult for hitting an edit text area.
388         */
389        public static final int EDIT_TEXT_TYPE = 9;
390
391        private int mType;
392        private String mExtra;
393
394        /**
395         * @hide Only for use by WebViewProvider implementations
396         */
397        public HitTestResult() {
398            mType = UNKNOWN_TYPE;
399        }
400
401        /**
402         * @hide Only for use by WebViewProvider implementations
403         */
404        public void setType(int type) {
405            mType = type;
406        }
407
408        /**
409         * @hide Only for use by WebViewProvider implementations
410         */
411        public void setExtra(String extra) {
412            mExtra = extra;
413        }
414
415        /**
416         * Gets the type of the hit test result. See the XXX_TYPE constants
417         * defined in this class.
418         *
419         * @return the type of the hit test result
420         */
421        public int getType() {
422            return mType;
423        }
424
425        /**
426         * Gets additional type-dependant information about the result. See
427         * {@link WebView#getHitTestResult()} for details. May either be null
428         * or contain extra information about this result.
429         *
430         * @return additional type-dependant information about the result
431         */
432        public String getExtra() {
433            return mExtra;
434        }
435    }
436
437    /**
438     * Constructs a new WebView with a Context object.
439     *
440     * @param context a Context object used to access application assets
441     */
442    public WebView(Context context) {
443        this(context, null);
444    }
445
446    /**
447     * Constructs a new WebView with layout parameters.
448     *
449     * @param context a Context object used to access application assets
450     * @param attrs an AttributeSet passed to our parent
451     */
452    public WebView(Context context, AttributeSet attrs) {
453        this(context, attrs, com.android.internal.R.attr.webViewStyle);
454    }
455
456    /**
457     * Constructs a new WebView with layout parameters and a default style.
458     *
459     * @param context a Context object used to access application assets
460     * @param attrs an AttributeSet passed to our parent
461     * @param defStyle the default style resource ID
462     */
463    public WebView(Context context, AttributeSet attrs, int defStyle) {
464        this(context, attrs, defStyle, false);
465    }
466
467    /**
468     * Constructs a new WebView with layout parameters and a default style.
469     *
470     * @param context a Context object used to access application assets
471     * @param attrs an AttributeSet passed to our parent
472     * @param defStyle the default style resource ID
473     * @param privateBrowsing whether this WebView will be initialized in
474     *                        private mode
475     */
476    public WebView(Context context, AttributeSet attrs, int defStyle,
477            boolean privateBrowsing) {
478        this(context, attrs, defStyle, null, privateBrowsing);
479    }
480
481    /**
482     * Constructs a new WebView with layout parameters, a default style and a set
483     * of custom Javscript interfaces to be added to this WebView at initialization
484     * time. This guarantees that these interfaces will be available when the JS
485     * context is initialized.
486     *
487     * @param context a Context object used to access application assets
488     * @param attrs an AttributeSet passed to our parent
489     * @param defStyle the default style resource ID
490     * @param javaScriptInterfaces a Map of interface names, as keys, and
491     *                             object implementing those interfaces, as
492     *                             values
493     * @param privateBrowsing whether this WebView will be initialized in
494     *                        private mode
495     * @hide This is used internally by dumprendertree, as it requires the javaScript interfaces to
496     *       be added synchronously, before a subsequent loadUrl call takes effect.
497     */
498    @SuppressWarnings("deprecation")  // for super() call into deprecated base class constructor.
499    protected WebView(Context context, AttributeSet attrs, int defStyle,
500            Map<String, Object> javaScriptInterfaces, boolean privateBrowsing) {
501        super(context, attrs, defStyle);
502        if (context == null) {
503            throw new IllegalArgumentException("Invalid context argument");
504        }
505        checkThread();
506
507        ensureProviderCreated();
508        mProvider.init(javaScriptInterfaces, privateBrowsing);
509    }
510
511    /**
512     * Specifies whether the horizontal scrollbar has overlay style.
513     *
514     * @param overlay true if horizontal scrollbar should have overlay style
515     */
516    public void setHorizontalScrollbarOverlay(boolean overlay) {
517        checkThread();
518        mProvider.setHorizontalScrollbarOverlay(overlay);
519    }
520
521    /**
522     * Specifies whether the vertical scrollbar has overlay style.
523     *
524     * @param overlay true if vertical scrollbar should have overlay style
525     */
526    public void setVerticalScrollbarOverlay(boolean overlay) {
527        checkThread();
528        mProvider.setVerticalScrollbarOverlay(overlay);
529    }
530
531    /**
532     * Gets whether horizontal scrollbar has overlay style.
533     *
534     * @return true if horizontal scrollbar has overlay style
535     */
536    public boolean overlayHorizontalScrollbar() {
537        checkThread();
538        return mProvider.overlayHorizontalScrollbar();
539    }
540
541    /**
542     * Gets whether vertical scrollbar has overlay style.
543     *
544     * @return true if vertical scrollbar has overlay style
545     */
546    public boolean overlayVerticalScrollbar() {
547        checkThread();
548        return mProvider.overlayVerticalScrollbar();
549    }
550
551    /**
552     * Gets the visible height (in pixels) of the embedded title bar (if any).
553     *
554     * @deprecated This method is now obsolete.
555     */
556    public int getVisibleTitleHeight() {
557        checkThread();
558        return mProvider.getVisibleTitleHeight();
559    }
560
561    /**
562     * Gets the SSL certificate for the main top-level page or null if there is
563     * no certificate (the site is not secure).
564     *
565     * @return the SSL certificate for the main top-level page
566     */
567    public SslCertificate getCertificate() {
568        checkThread();
569        return mProvider.getCertificate();
570    }
571
572    /**
573     * Sets the SSL certificate for the main top-level page.
574     */
575    public void setCertificate(SslCertificate certificate) {
576        checkThread();
577        mProvider.setCertificate(certificate);
578    }
579
580    //-------------------------------------------------------------------------
581    // Methods called by activity
582    //-------------------------------------------------------------------------
583
584    /**
585     * Saves the username and password for a particular host in this WebView's
586     * internal database.
587     *
588     * @param host the host that required the credentials
589     * @param username the username for the given host
590     * @param password the password for the given host
591     */
592    public void savePassword(String host, String username, String password) {
593        checkThread();
594        mProvider.savePassword(host, username, password);
595    }
596
597    /**
598     * Sets the HTTP authentication credentials for a given host and realm.
599     *
600     * @param host the host for the credentials
601     * @param realm the realm for the credentials
602     * @param username the username for the password. If it is null, it means
603     *                 password can't be saved.
604     * @param password the password
605     */
606    public void setHttpAuthUsernamePassword(String host, String realm,
607            String username, String password) {
608        checkThread();
609        mProvider.setHttpAuthUsernamePassword(host, realm, username, password);
610    }
611
612    /**
613     * Retrieves the HTTP authentication username and password for a given
614     * host and realm pair
615     *
616     * @param host the host for which the credentials apply
617     * @param realm the realm for which the credentials apply
618     * @return String[] if found. String[0] is username, which can be null and
619     *         String[1] is password. Return null if it can't find anything.
620     */
621    public String[] getHttpAuthUsernamePassword(String host, String realm) {
622        checkThread();
623        return mProvider.getHttpAuthUsernamePassword(host, realm);
624    }
625
626    /**
627     * Destroys the internal state of this WebView. This method should be called
628     * after this WebView has been removed from the view system. No other
629     * methods may be called on this WebView after destroy.
630     */
631    public void destroy() {
632        checkThread();
633        mProvider.destroy();
634    }
635
636    /**
637     * Enables platform notifications of data state and proxy changes.
638     * Notifications are enabled by default.
639     *
640     * @deprecated This method is now obsolete.
641     */
642    @Deprecated
643    public static void enablePlatformNotifications() {
644        checkThread();
645        getFactory().getStatics().setPlatformNotificationsEnabled(true);
646    }
647
648    /**
649     * Disables platform notifications of data state and proxy changes.
650     * Notifications are enabled by default.
651     *
652     * @deprecated This method is now obsolete.
653     */
654    @Deprecated
655    public static void disablePlatformNotifications() {
656        checkThread();
657        getFactory().getStatics().setPlatformNotificationsEnabled(false);
658    }
659
660    /**
661     * Informs WebView of the network state. This is used to set
662     * the JavaScript property window.navigator.isOnline and
663     * generates the online/offline event as specified in HTML5, sec. 5.7.7
664     *
665     * @param networkUp a boolean indicating if network is available
666     */
667    public void setNetworkAvailable(boolean networkUp) {
668        checkThread();
669        mProvider.setNetworkAvailable(networkUp);
670    }
671
672    /**
673     * Saves the state of this WebView used in
674     * {@link android.app.Activity#onSaveInstanceState}. Please note that this
675     * method no longer stores the display data for this WebView. The previous
676     * behavior could potentially leak files if {@link #restoreState} was never
677     * called. See {@link #savePicture} and {@link #restorePicture} for saving
678     * and restoring the display data.
679     *
680     * @param outState the Bundle to store this WebView's state
681     * @return the same copy of the back/forward list used to save the state. If
682     *         saveState fails, the returned list will be null.
683     * @see #savePicture
684     * @see #restorePicture
685     */
686    public WebBackForwardList saveState(Bundle outState) {
687        checkThread();
688        return mProvider.saveState(outState);
689    }
690
691    /**
692     * Saves the current display data to the Bundle given. Used in conjunction
693     * with {@link #saveState}.
694     * @param b a Bundle to store the display data
695     * @param dest the file to store the serialized picture data. Will be
696     *             overwritten with this WebView's picture data.
697     * @return true if the picture was successfully saved
698     * @deprecated This method is now obsolete.
699     */
700    @Deprecated
701    public boolean savePicture(Bundle b, final File dest) {
702        checkThread();
703        return mProvider.savePicture(b, dest);
704    }
705
706    /**
707     * Restores the display data that was saved in {@link #savePicture}. Used in
708     * conjunction with {@link #restoreState}. Note that this will not work if
709     * this WebView is hardware accelerated.
710     *
711     * @param b a Bundle containing the saved display data
712     * @param src the file where the picture data was stored
713     * @return true if the picture was successfully restored
714     * @deprecated This method is now obsolete.
715     */
716    @Deprecated
717    public boolean restorePicture(Bundle b, File src) {
718        checkThread();
719        return mProvider.restorePicture(b, src);
720    }
721
722    /**
723     * Restores the state of this WebView from the given Bundle. This method is
724     * intended for use in {@link android.app.Activity#onRestoreInstanceState}
725     * and should be called to restore the state of this WebView. If
726     * it is called after this WebView has had a chance to build state (load
727     * pages, create a back/forward list, etc.) there may be undesirable
728     * side-effects. Please note that this method no longer restores the
729     * display data for this WebView. See {@link #savePicture} and {@link
730     * #restorePicture} for saving and restoring the display data.
731     *
732     * @param inState the incoming Bundle of state
733     * @return the restored back/forward list or null if restoreState failed
734     * @see #savePicture
735     * @see #restorePicture
736     */
737    public WebBackForwardList restoreState(Bundle inState) {
738        checkThread();
739        return mProvider.restoreState(inState);
740    }
741
742    /**
743     * Loads the given URL with the specified additional HTTP headers.
744     *
745     * @param url the URL of the resource to load
746     * @param additionalHttpHeaders the additional headers to be used in the
747     *            HTTP request for this URL, specified as a map from name to
748     *            value. Note that if this map contains any of the headers
749     *            that are set by default by this WebView, such as those
750     *            controlling caching, accept types or the User-Agent, their
751     *            values may be overriden by this WebView's defaults.
752     */
753    public void loadUrl(String url, Map<String, String> additionalHttpHeaders) {
754        checkThread();
755        mProvider.loadUrl(url, additionalHttpHeaders);
756    }
757
758    /**
759     * Loads the given URL.
760     *
761     * @param url the URL of the resource to load
762     */
763    public void loadUrl(String url) {
764        checkThread();
765        mProvider.loadUrl(url);
766    }
767
768    /**
769     * Loads the URL with postData using "POST" method into this WebView. If url
770     * is not a network URL, it will be loaded with {link
771     * {@link #loadUrl(String)} instead.
772     *
773     * @param url the URL of the resource to load
774     * @param postData the data will be passed to "POST" request
775     */
776    public void postUrl(String url, byte[] postData) {
777        checkThread();
778        mProvider.postUrl(url, postData);
779    }
780
781    /**
782     * Loads the given data into this WebView using a 'data' scheme URL.
783     * <p>
784     * Note that JavaScript's same origin policy means that script running in a
785     * page loaded using this method will be unable to access content loaded
786     * using any scheme other than 'data', including 'http(s)'. To avoid this
787     * restriction, use {@link
788     * #loadDataWithBaseURL(String,String,String,String,String)
789     * loadDataWithBaseURL()} with an appropriate base URL.
790     * <p>
791     * If the value of the encoding parameter is 'base64', then the data must
792     * be encoded as base64. Otherwise, the data must use ASCII encoding for
793     * octets inside the range of safe URL characters and use the standard %xx
794     * hex encoding of URLs for octets outside that range. For example,
795     * '#', '%', '\', '?' should be replaced by %23, %25, %27, %3f respectively.
796     * <p>
797     * The 'data' scheme URL formed by this method uses the default US-ASCII
798     * charset. If you need need to set a different charset, you should form a
799     * 'data' scheme URL which explicitly specifies a charset parameter in the
800     * mediatype portion of the URL and call {@link #loadUrl(String)} instead.
801     * Note that the charset obtained from the mediatype portion of a data URL
802     * always overrides that specified in the HTML or XML document itself.
803     *
804     * @param data a String of data in the given encoding
805     * @param mimeType the MIME type of the data, e.g. 'text/html'
806     * @param encoding the encoding of the data
807     */
808    public void loadData(String data, String mimeType, String encoding) {
809        checkThread();
810        mProvider.loadData(data, mimeType, encoding);
811    }
812
813    /**
814     * Loads the given data into this WebView, using baseUrl as the base URL for
815     * the content. The base URL is used both to resolve relative URLs and when
816     * applying JavaScript's same origin policy. The historyUrl is used for the
817     * history entry.
818     * <p>
819     * Note that content specified in this way can access local device files
820     * (via 'file' scheme URLs) only if baseUrl specifies a scheme other than
821     * 'http', 'https', 'ftp', 'ftps', 'about' or 'javascript'.
822     * <p>
823     * If the base URL uses the data scheme, this method is equivalent to
824     * calling {@link #loadData(String,String,String) loadData()} and the
825     * historyUrl is ignored.
826     *
827     * @param baseUrl the URL to use as the page's base URL. If null defaults to
828     *                'about:blank'.
829     * @param data a String of data in the given encoding
830     * @param mimeType the MIMEType of the data, e.g. 'text/html'. If null,
831     *                 defaults to 'text/html'.
832     * @param encoding the encoding of the data
833     * @param historyUrl the URL to use as the history entry. If null defaults
834     *                   to 'about:blank'.
835     */
836    public void loadDataWithBaseURL(String baseUrl, String data,
837            String mimeType, String encoding, String historyUrl) {
838        checkThread();
839        mProvider.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl);
840    }
841
842    /**
843     * Saves the current view as a web archive.
844     *
845     * @param filename the filename where the archive should be placed
846     */
847    public void saveWebArchive(String filename) {
848        checkThread();
849        mProvider.saveWebArchive(filename);
850    }
851
852    /**
853     * Saves the current view as a web archive.
854     *
855     * @param basename the filename where the archive should be placed
856     * @param autoname if false, takes basename to be a file. If true, basename
857     *                 is assumed to be a directory in which a filename will be
858     *                 chosen according to the URL of the current page.
859     * @param callback called after the web archive has been saved. The
860     *                 parameter for onReceiveValue will either be the filename
861     *                 under which the file was saved, or null if saving the
862     *                 file failed.
863     */
864    public void saveWebArchive(String basename, boolean autoname, ValueCallback<String> callback) {
865        checkThread();
866        mProvider.saveWebArchive(basename, autoname, callback);
867    }
868
869    /**
870     * Stops the current load.
871     */
872    public void stopLoading() {
873        checkThread();
874        mProvider.stopLoading();
875    }
876
877    /**
878     * Reloads the current URL.
879     */
880    public void reload() {
881        checkThread();
882        mProvider.reload();
883    }
884
885    /**
886     * Gets whether this WebView has a back history item.
887     *
888     * @return true iff this WebView has a back history item
889     */
890    public boolean canGoBack() {
891        checkThread();
892        return mProvider.canGoBack();
893    }
894
895    /**
896     * Goes back in the history of this WebView.
897     */
898    public void goBack() {
899        checkThread();
900        mProvider.goBack();
901    }
902
903    /**
904     * Gets whether this WebView has a forward history item.
905     *
906     * @return true iff this Webview has a forward history item
907     */
908    public boolean canGoForward() {
909        checkThread();
910        return mProvider.canGoForward();
911    }
912
913    /**
914     * Goes forward in the history of this WebView.
915     */
916    public void goForward() {
917        checkThread();
918        mProvider.goForward();
919    }
920
921    /**
922     * Gets whether the page can go back or forward the given
923     * number of steps.
924     *
925     * @param steps the negative or positive number of steps to move the
926     *              history
927     */
928    public boolean canGoBackOrForward(int steps) {
929        checkThread();
930        return mProvider.canGoBackOrForward(steps);
931    }
932
933    /**
934     * Goes to the history item that is the number of steps away from
935     * the current item. Steps is negative if backward and positive
936     * if forward.
937     *
938     * @param steps the number of steps to take back or forward in the back
939     *              forward list
940     */
941    public void goBackOrForward(int steps) {
942        checkThread();
943        mProvider.goBackOrForward(steps);
944    }
945
946    /**
947     * Gets whether private browsing is enabled in this WebView.
948     */
949    public boolean isPrivateBrowsingEnabled() {
950        checkThread();
951        return mProvider.isPrivateBrowsingEnabled();
952    }
953
954    /**
955     * Scrolls the contents of this WebView up by half the view size.
956     *
957     * @param top true to jump to the top of the page
958     * @return true if the page was scrolled
959     */
960    public boolean pageUp(boolean top) {
961        checkThread();
962        return mProvider.pageUp(top);
963    }
964
965    /**
966     * Scrolls the contents of this WebView down by half the page size.
967     *
968     * @param bottom true to jump to bottom of page
969     * @return true if the page was scrolled
970     */
971    public boolean pageDown(boolean bottom) {
972        checkThread();
973        return mProvider.pageDown(bottom);
974    }
975
976    /**
977     * Clears this WebView so that onDraw() will draw nothing but white background,
978     * and onMeasure() will return 0 if MeasureSpec is not MeasureSpec.EXACTLY.
979     */
980    public void clearView() {
981        checkThread();
982        mProvider.clearView();
983    }
984
985    /**
986     * Gets a new picture that captures the current contents of this WebView.
987     * The picture is of the entire document being displayed, and is not
988     * limited to the area currently displayed by this WebView. Also, the
989     * picture is a static copy and is unaffected by later changes to the
990     * content being displayed.
991     * <p>
992     * Note that due to internal changes, for API levels between
993     * {@link android.os.Build.VERSION_CODES#HONEYCOMB} and
994     * {@link android.os.Build.VERSION_CODES#ICE_CREAM_SANDWICH} inclusive, the
995     * picture does not include fixed position elements or scrollable divs.
996     *
997     * @return a picture that captures the current contents of this WebView
998     */
999    public Picture capturePicture() {
1000        checkThread();
1001        return mProvider.capturePicture();
1002    }
1003
1004    /**
1005     * Gets the current scale of this WebView.
1006     *
1007     * @return the current scale
1008     */
1009    @ViewDebug.ExportedProperty(category = "webview")
1010    public float getScale() {
1011        checkThread();
1012        return mProvider.getScale();
1013    }
1014
1015    /**
1016     * Sets the initial scale for this WebView. 0 means default. If
1017     * {@link WebSettings#getUseWideViewPort()} is true, it zooms out all the
1018     * way. Otherwise it starts with 100%. If initial scale is greater than 0,
1019     * WebView starts with this value as initial scale.
1020     * Please note that unlike the scale properties in the viewport meta tag,
1021     * this method doesn't take the screen density into account.
1022     *
1023     * @param scaleInPercent the initial scale in percent
1024     */
1025    public void setInitialScale(int scaleInPercent) {
1026        checkThread();
1027        mProvider.setInitialScale(scaleInPercent);
1028    }
1029
1030    /**
1031     * Invokes the graphical zoom picker widget for this WebView. This will
1032     * result in the zoom widget appearing on the screen to control the zoom
1033     * level of this WebView.
1034     */
1035    public void invokeZoomPicker() {
1036        checkThread();
1037        mProvider.invokeZoomPicker();
1038    }
1039
1040    /**
1041     * Gets a HitTestResult based on the current cursor node. If a HTML::a
1042     * tag is found and the anchor has a non-JavaScript URL, the HitTestResult
1043     * type is set to SRC_ANCHOR_TYPE and the URL is set in the "extra" field.
1044     * If the anchor does not have a URL or if it is a JavaScript URL, the type
1045     * will be UNKNOWN_TYPE and the URL has to be retrieved through
1046     * {@link #requestFocusNodeHref} asynchronously. If a HTML::img tag is
1047     * found, the HitTestResult type is set to IMAGE_TYPE and the URL is set in
1048     * the "extra" field. A type of
1049     * SRC_IMAGE_ANCHOR_TYPE indicates an anchor with a URL that has an image as
1050     * a child node. If a phone number is found, the HitTestResult type is set
1051     * to PHONE_TYPE and the phone number is set in the "extra" field of
1052     * HitTestResult. If a map address is found, the HitTestResult type is set
1053     * to GEO_TYPE and the address is set in the "extra" field of HitTestResult.
1054     * If an email address is found, the HitTestResult type is set to EMAIL_TYPE
1055     * and the email is set in the "extra" field of HitTestResult. Otherwise,
1056     * HitTestResult type is set to UNKNOWN_TYPE.
1057     */
1058    public HitTestResult getHitTestResult() {
1059        checkThread();
1060        return mProvider.getHitTestResult();
1061    }
1062
1063    /**
1064     * Requests the anchor or image element URL at the last tapped point.
1065     * If hrefMsg is null, this method returns immediately and does not
1066     * dispatch hrefMsg to its target. If the tapped point hits an image,
1067     * an anchor, or an image in an anchor, the message associates
1068     * strings in named keys in its data. The value paired with the key
1069     * may be an empty string.
1070     *
1071     * @param hrefMsg the message to be dispatched with the result of the
1072     *                request. The message data contains three keys. "url"
1073     *                returns the anchor's href attribute. "title" returns the
1074     *                anchor's text. "src" returns the image's src attribute.
1075     */
1076    public void requestFocusNodeHref(Message hrefMsg) {
1077        checkThread();
1078        mProvider.requestFocusNodeHref(hrefMsg);
1079    }
1080
1081    /**
1082     * Requests the URL of the image last touched by the user. msg will be sent
1083     * to its target with a String representing the URL as its object.
1084     *
1085     * @param msg the message to be dispatched with the result of the request
1086     *            as the data member with "url" as key. The result can be null.
1087     */
1088    public void requestImageRef(Message msg) {
1089        checkThread();
1090        mProvider.requestImageRef(msg);
1091    }
1092
1093    /**
1094     * Gets the URL for the current page. This is not always the same as the URL
1095     * passed to WebViewClient.onPageStarted because although the load for
1096     * that URL has begun, the current page may not have changed.
1097     *
1098     * @return the URL for the current page
1099     */
1100    @ViewDebug.ExportedProperty(category = "webview")
1101    public String getUrl() {
1102        checkThread();
1103        return mProvider.getUrl();
1104    }
1105
1106    /**
1107     * Gets the original URL for the current page. This is not always the same
1108     * as the URL passed to WebViewClient.onPageStarted because although the
1109     * load for that URL has begun, the current page may not have changed.
1110     * Also, there may have been redirects resulting in a different URL to that
1111     * originally requested.
1112     *
1113     * @return the URL that was originally requested for the current page
1114     */
1115    @ViewDebug.ExportedProperty(category = "webview")
1116    public String getOriginalUrl() {
1117        checkThread();
1118        return mProvider.getOriginalUrl();
1119    }
1120
1121    /**
1122     * Gets the title for the current page. This is the title of the current page
1123     * until WebViewClient.onReceivedTitle is called.
1124     *
1125     * @return the title for the current page
1126     */
1127    @ViewDebug.ExportedProperty(category = "webview")
1128    public String getTitle() {
1129        checkThread();
1130        return mProvider.getTitle();
1131    }
1132
1133    /**
1134     * Gets the favicon for the current page. This is the favicon of the current
1135     * page until WebViewClient.onReceivedIcon is called.
1136     *
1137     * @return the favicon for the current page
1138     */
1139    public Bitmap getFavicon() {
1140        checkThread();
1141        return mProvider.getFavicon();
1142    }
1143
1144    /**
1145     * Gets the touch icon URL for the apple-touch-icon <link> element, or
1146     * a URL on this site's server pointing to the standard location of a
1147     * touch icon.
1148     *
1149     * @hide
1150     */
1151    public String getTouchIconUrl() {
1152        return mProvider.getTouchIconUrl();
1153    }
1154
1155    /**
1156     * Gets the progress for the current page.
1157     *
1158     * @return the progress for the current page between 0 and 100
1159     */
1160    public int getProgress() {
1161        checkThread();
1162        return mProvider.getProgress();
1163    }
1164
1165    /**
1166     * Gets the height of the HTML content.
1167     *
1168     * @return the height of the HTML content
1169     */
1170    @ViewDebug.ExportedProperty(category = "webview")
1171    public int getContentHeight() {
1172        checkThread();
1173        return mProvider.getContentHeight();
1174    }
1175
1176    /**
1177     * Gets the width of the HTML content.
1178     *
1179     * @return the width of the HTML content
1180     * @hide
1181     */
1182    @ViewDebug.ExportedProperty(category = "webview")
1183    public int getContentWidth() {
1184        return mProvider.getContentWidth();
1185    }
1186
1187    /**
1188     * Pauses all layout, parsing, and JavaScript timers for all WebViews. This
1189     * is a global requests, not restricted to just this WebView. This can be
1190     * useful if the application has been paused.
1191     */
1192    public void pauseTimers() {
1193        checkThread();
1194        mProvider.pauseTimers();
1195    }
1196
1197    /**
1198     * Resumes all layout, parsing, and JavaScript timers for all WebViews.
1199     * This will resume dispatching all timers.
1200     */
1201    public void resumeTimers() {
1202        checkThread();
1203        mProvider.resumeTimers();
1204    }
1205
1206    /**
1207     * Pauses any extra processing associated with this WebView and its
1208     * associated DOM, plugins, JavaScript etc. For example, if this WebView is
1209     * taken offscreen, this could be called to reduce unnecessary CPU or
1210     * network traffic. When this WebView is again "active", call onResume().
1211     * Note that this differs from pauseTimers(), which affects all WebViews.
1212     */
1213    public void onPause() {
1214        checkThread();
1215        mProvider.onPause();
1216    }
1217
1218    /**
1219     * Resumes a WebView after a previous call to onPause().
1220     */
1221    public void onResume() {
1222        checkThread();
1223        mProvider.onResume();
1224    }
1225
1226    /**
1227     * Gets whether this WebView is paused, meaning onPause() was called.
1228     * Calling onResume() sets the paused state back to false.
1229     *
1230     * @hide
1231     */
1232    public boolean isPaused() {
1233        return mProvider.isPaused();
1234    }
1235
1236    /**
1237     * Informs this WebView that memory is low so that it can free any available
1238     * memory.
1239     */
1240    public void freeMemory() {
1241        checkThread();
1242        mProvider.freeMemory();
1243    }
1244
1245    /**
1246     * Clears the resource cache. Note that the cache is per-application, so
1247     * this will clear the cache for all WebViews used.
1248     *
1249     * @param includeDiskFiles if false, only the RAM cache is cleared
1250     */
1251    public void clearCache(boolean includeDiskFiles) {
1252        checkThread();
1253        mProvider.clearCache(includeDiskFiles);
1254    }
1255
1256    /**
1257     * Makes sure that clearing the form data removes the adapter from the
1258     * currently focused textfield if there is one.
1259     */
1260    public void clearFormData() {
1261        checkThread();
1262        mProvider.clearFormData();
1263    }
1264
1265    /**
1266     * Tells this WebView to clear its internal back/forward list.
1267     */
1268    public void clearHistory() {
1269        checkThread();
1270        mProvider.clearHistory();
1271    }
1272
1273    /**
1274     * Clears the SSL preferences table stored in response to proceeding with
1275     * SSL certificate errors.
1276     */
1277    public void clearSslPreferences() {
1278        checkThread();
1279        mProvider.clearSslPreferences();
1280    }
1281
1282    /**
1283     * Gets the WebBackForwardList for this WebView. This contains the
1284     * back/forward list for use in querying each item in the history stack.
1285     * This is a copy of the private WebBackForwardList so it contains only a
1286     * snapshot of the current state. Multiple calls to this method may return
1287     * different objects. The object returned from this method will not be
1288     * updated to reflect any new state.
1289     */
1290    public WebBackForwardList copyBackForwardList() {
1291        checkThread();
1292        return mProvider.copyBackForwardList();
1293
1294    }
1295
1296    /**
1297     * Registers the listener to be notified as find-on-page operations
1298     * progress. This will replace the current listener.
1299     *
1300     * @param listener an implementation of {@link FindListener}
1301     */
1302    public void setFindListener(FindListener listener) {
1303        checkThread();
1304        mProvider.setFindListener(listener);
1305    }
1306
1307    /**
1308     * Highlights and scrolls to the next match found by {@link #findAll} or
1309     * {@link #findAllAsync}, wrapping around page boundaries as necessary.
1310     * Notifies any registered {@link FindListener}. If neither
1311     * {@link #findAll} nor {@link #findAllAsync(String)} has been called yet,
1312     * or if {@link #clearMatches} has been called since the last find
1313     * operation, this function does nothing.
1314     *
1315     * @param forward the direction to search
1316     * @see #setFindListener
1317     */
1318    public void findNext(boolean forward) {
1319        checkThread();
1320        mProvider.findNext(forward);
1321    }
1322
1323    /**
1324     * Finds all instances of find on the page and highlights them.
1325     * Notifies any registered {@link FindListener}.
1326     *
1327     * @param find the string to find
1328     * @return the number of occurances of the String "find" that were found
1329     * @deprecated {@link #findAllAsync} is preferred.
1330     * @see #setFindListener
1331     */
1332    @Deprecated
1333    public int findAll(String find) {
1334        checkThread();
1335        StrictMode.noteSlowCall("findAll blocks UI: prefer findAllAsync");
1336        return mProvider.findAll(find);
1337    }
1338
1339    /**
1340     * Finds all instances of find on the page and highlights them,
1341     * asynchronously. Notifies any registered {@link FindListener}.
1342     * Successive calls to this or {@link #findAll} will cancel any
1343     * pending searches.
1344     *
1345     * @param find the string to find.
1346     * @see #setFindListener
1347     */
1348    public void findAllAsync(String find) {
1349        checkThread();
1350        mProvider.findAllAsync(find);
1351    }
1352
1353    /**
1354     * Starts an ActionMode for finding text in this WebView.  Only works if this
1355     * WebView is attached to the view system.
1356     *
1357     * @param text if non-null, will be the initial text to search for.
1358     *             Otherwise, the last String searched for in this WebView will
1359     *             be used to start.
1360     * @param showIme if true, show the IME, assuming the user will begin typing.
1361     *                If false and text is non-null, perform a find all.
1362     * @return true if the find dialog is shown, false otherwise
1363     */
1364    public boolean showFindDialog(String text, boolean showIme) {
1365        checkThread();
1366        return mProvider.showFindDialog(text, showIme);
1367    }
1368
1369    /**
1370     * Gets the first substring consisting of the address of a physical
1371     * location. Currently, only addresses in the United States are detected,
1372     * and consist of:
1373     * <ul>
1374     *   <li>a house number</li>
1375     *   <li>a street name</li>
1376     *   <li>a street type (Road, Circle, etc), either spelled out or
1377     *       abbreviated</li>
1378     *   <li>a city name</li>
1379     *   <li>a state or territory, either spelled out or two-letter abbr</li>
1380     *   <li>an optional 5 digit or 9 digit zip code</li>
1381     * </ul>
1382     * All names must be correctly capitalized, and the zip code, if present,
1383     * must be valid for the state. The street type must be a standard USPS
1384     * spelling or abbreviation. The state or territory must also be spelled
1385     * or abbreviated using USPS standards. The house number may not exceed
1386     * five digits.
1387     *
1388     * @param addr the string to search for addresses
1389     * @return the address, or if no address is found, null
1390     */
1391    public static String findAddress(String addr) {
1392        checkThread();
1393        return getFactory().getStatics().findAddress(addr);
1394    }
1395
1396    /**
1397     * Clears the highlighting surrounding text matches created by
1398     * {@link #findAll} or {@link #findAllAsync}.
1399     */
1400    public void clearMatches() {
1401        checkThread();
1402        mProvider.clearMatches();
1403    }
1404
1405    /**
1406     * Queries the document to see if it contains any image references. The
1407     * message object will be dispatched with arg1 being set to 1 if images
1408     * were found and 0 if the document does not reference any images.
1409     *
1410     * @param response the message that will be dispatched with the result
1411     */
1412    public void documentHasImages(Message response) {
1413        checkThread();
1414        mProvider.documentHasImages(response);
1415    }
1416
1417    /**
1418     * Sets the WebViewClient that will receive various notifications and
1419     * requests. This will replace the current handler.
1420     *
1421     * @param client an implementation of WebViewClient
1422     */
1423    public void setWebViewClient(WebViewClient client) {
1424        checkThread();
1425        mProvider.setWebViewClient(client);
1426    }
1427
1428    /**
1429     * Registers the interface to be used when content can not be handled by
1430     * the rendering engine, and should be downloaded instead. This will replace
1431     * the current handler.
1432     *
1433     * @param listener an implementation of DownloadListener
1434     */
1435    public void setDownloadListener(DownloadListener listener) {
1436        checkThread();
1437        mProvider.setDownloadListener(listener);
1438    }
1439
1440    /**
1441     * Sets the chrome handler. This is an implementation of WebChromeClient for
1442     * use in handling JavaScript dialogs, favicons, titles, and the progress.
1443     * This will replace the current handler.
1444     *
1445     * @param client an implementation of WebChromeClient
1446     */
1447    public void setWebChromeClient(WebChromeClient client) {
1448        checkThread();
1449        mProvider.setWebChromeClient(client);
1450    }
1451
1452    /**
1453     * Sets the Picture listener. This is an interface used to receive
1454     * notifications of a new Picture.
1455     *
1456     * @param listener an implementation of WebView.PictureListener
1457     * @deprecated This method is now obsolete.
1458     */
1459    @Deprecated
1460    public void setPictureListener(PictureListener listener) {
1461        checkThread();
1462        mProvider.setPictureListener(listener);
1463    }
1464
1465    /**
1466     * Injects the supplied Java object into this WebView. The object is
1467     * injected into the JavaScript context of the main frame, using the
1468     * supplied name. This allows the Java object's public methods to be
1469     * accessed from JavaScript. Note that that injected objects will not
1470     * appear in JavaScript until the page is next (re)loaded. For example:
1471     * <pre> webView.addJavascriptInterface(new Object(), "injectedObject");
1472     * webView.loadData("<!DOCTYPE html><title></title>", "text/html", null);
1473     * webView.loadUrl("javascript:alert(injectedObject.toString())");</pre>
1474     * <p>
1475     * <strong>IMPORTANT:</strong>
1476     * <ul>
1477     * <li> This method can be used to allow JavaScript to control the host
1478     * application. This is a powerful feature, but also presents a security
1479     * risk, particularly as JavaScript could use reflection to access an
1480     * injected object's public fields. Use of this method in a WebView
1481     * containing untrusted content could allow an attacker to manipulate the
1482     * host application in unintended ways, executing Java code with the
1483     * permissions of the host application. Use extreme care when using this
1484     * method in a WebView which could contain untrusted content.</li>
1485     * <li> JavaScript interacts with Java object on a private, background
1486     * thread of this WebView. Care is therefore required to maintain thread
1487     * safety.</li>
1488     * </ul>
1489     *
1490     * @param object the Java object to inject into this WebView's JavaScript
1491     *               context. Null values are ignored.
1492     * @param name the name used to expose the object in JavaScript
1493     */
1494    public void addJavascriptInterface(Object object, String name) {
1495        checkThread();
1496        mProvider.addJavascriptInterface(object, name);
1497    }
1498
1499    /**
1500     * Removes a previously injected Java object from this WebView. Note that
1501     * the removal will not be reflected in JavaScript until the page is next
1502     * (re)loaded. See {@link #addJavascriptInterface}.
1503     *
1504     * @param name the name used to expose the object in JavaScript
1505     */
1506    public void removeJavascriptInterface(String name) {
1507        checkThread();
1508        mProvider.removeJavascriptInterface(name);
1509    }
1510
1511    /**
1512     * Gets the WebSettings object used to control the settings for this
1513     * WebView.
1514     *
1515     * @return a WebSettings object that can be used to control this WebView's
1516     *         settings
1517     */
1518    public WebSettings getSettings() {
1519        checkThread();
1520        return mProvider.getSettings();
1521    }
1522
1523    /**
1524     * Gets the list of currently loaded plugins.
1525     *
1526     * @return the list of currently loaded plugins
1527     * @deprecated This was used for Gears, which has been deprecated.
1528     * @hide
1529     */
1530    @Deprecated
1531    public static synchronized PluginList getPluginList() {
1532        checkThread();
1533        return new PluginList();
1534    }
1535
1536    /**
1537     * @deprecated This was used for Gears, which has been deprecated.
1538     * @hide
1539     */
1540    @Deprecated
1541    public void refreshPlugins(boolean reloadOpenPages) {
1542        checkThread();
1543    }
1544
1545    /**
1546     * Puts this WebView into text selection mode. Do not rely on this
1547     * functionality; it will be deprecated in the future.
1548     *
1549     * @deprecated This method is now obsolete.
1550     */
1551    @Deprecated
1552    public void emulateShiftHeld() {
1553        checkThread();
1554    }
1555
1556    /**
1557     * @deprecated WebView no longer needs to implement
1558     * ViewGroup.OnHierarchyChangeListener.  This method does nothing now.
1559     */
1560    @Override
1561    // Cannot add @hide as this can always be accessed via the interface.
1562    @Deprecated
1563    public void onChildViewAdded(View parent, View child) {}
1564
1565    /**
1566     * @deprecated WebView no longer needs to implement
1567     * ViewGroup.OnHierarchyChangeListener.  This method does nothing now.
1568     */
1569    @Override
1570    // Cannot add @hide as this can always be accessed via the interface.
1571    @Deprecated
1572    public void onChildViewRemoved(View p, View child) {}
1573
1574    /**
1575     * @deprecated WebView should not have implemented
1576     * ViewTreeObserver.OnGlobalFocusChangeListener. This method does nothing now.
1577     */
1578    @Override
1579    // Cannot add @hide as this can always be accessed via the interface.
1580    @Deprecated
1581    public void onGlobalFocusChanged(View oldFocus, View newFocus) {
1582    }
1583
1584    public void setMapTrackballToArrowKeys(boolean setMap) {
1585        checkThread();
1586        mProvider.setMapTrackballToArrowKeys(setMap);
1587    }
1588
1589
1590    public void flingScroll(int vx, int vy) {
1591        checkThread();
1592        mProvider.flingScroll(vx, vy);
1593    }
1594
1595    /**
1596     * Gets the zoom controls for this WebView, as a separate View. The caller
1597     * is responsible for inserting this View into the layout hierarchy.
1598     * <p/>
1599     * API level {@link android.os.Build.VERSION_CODES#CUPCAKE} introduced
1600     * built-in zoom mechanisms for the WebView, as opposed to these separate
1601     * zoom controls. The built-in mechanisms are preferred and can be enabled
1602     * using {@link WebSettings#setBuiltInZoomControls}.
1603     *
1604     * @deprecated the built-in zoom mechanisms are preferred
1605     * @hide Since API level {@link android.os.Build.VERSION_CODES#JELLY_BEAN}
1606     */
1607    @Deprecated
1608    public View getZoomControls() {
1609        checkThread();
1610        return mProvider.getZoomControls();
1611    }
1612
1613    /**
1614     * Gets whether this WebView can be zoomed in.
1615     *
1616     * @return true if this WebView can be zoomed in
1617     */
1618    public boolean canZoomIn() {
1619        checkThread();
1620        return mProvider.canZoomIn();
1621    }
1622
1623    /**
1624     * Gets whether this WebView can be zoomed out.
1625     *
1626     * @return true if this WebView can be zoomed out
1627     */
1628    public boolean canZoomOut() {
1629        checkThread();
1630        return mProvider.canZoomOut();
1631    }
1632
1633    /**
1634     * Performs zoom in in this WebView.
1635     *
1636     * @return true if zoom in succeeds, false if no zoom changes
1637     */
1638    public boolean zoomIn() {
1639        checkThread();
1640        return mProvider.zoomIn();
1641    }
1642
1643    /**
1644     * Performs zoom out in this WebView.
1645     *
1646     * @return true if zoom out succeeds, false if no zoom changes
1647     */
1648    public boolean zoomOut() {
1649        checkThread();
1650        return mProvider.zoomOut();
1651    }
1652
1653    /**
1654     * @deprecated This method is now obsolete.
1655     */
1656    @Deprecated
1657    public void debugDump() {
1658        checkThread();
1659    }
1660
1661    /**
1662     * See {@link ViewDebug.HierarchyHandler#dumpViewHierarchyWithProperties(BufferedWriter, int)}
1663     * @hide
1664     */
1665    @Override
1666    public void dumpViewHierarchyWithProperties(BufferedWriter out, int level) {
1667        mProvider.dumpViewHierarchyWithProperties(out, level);
1668    }
1669
1670    /**
1671     * See {@link ViewDebug.HierarchyHandler#findHierarchyView(String, int)}
1672     * @hide
1673     */
1674    @Override
1675    public View findHierarchyView(String className, int hashCode) {
1676        return mProvider.findHierarchyView(className, hashCode);
1677    }
1678
1679    //-------------------------------------------------------------------------
1680    // Interface for WebView providers
1681    //-------------------------------------------------------------------------
1682
1683    /**
1684     * Gets the WebViewProvider. Used by providers to obtain the underlying
1685     * implementation, e.g. when the appliction responds to
1686     * WebViewClient.onCreateWindow() request.
1687     *
1688     * @hide WebViewProvider is not public API.
1689     */
1690    public WebViewProvider getWebViewProvider() {
1691        return mProvider;
1692    }
1693
1694    /**
1695     * Callback interface, allows the provider implementation to access non-public methods
1696     * and fields, and make super-class calls in this WebView instance.
1697     * @hide Only for use by WebViewProvider implementations
1698     */
1699    public class PrivateAccess {
1700        // ---- Access to super-class methods ----
1701        public int super_getScrollBarStyle() {
1702            return WebView.super.getScrollBarStyle();
1703        }
1704
1705        public void super_scrollTo(int scrollX, int scrollY) {
1706            WebView.super.scrollTo(scrollX, scrollY);
1707        }
1708
1709        public void super_computeScroll() {
1710            WebView.super.computeScroll();
1711        }
1712
1713        public boolean super_onHoverEvent(MotionEvent event) {
1714            return WebView.super.onHoverEvent(event);
1715        }
1716
1717        public boolean super_performAccessibilityAction(int action, Bundle arguments) {
1718            return WebView.super.performAccessibilityAction(action, arguments);
1719        }
1720
1721        public boolean super_performLongClick() {
1722            return WebView.super.performLongClick();
1723        }
1724
1725        public boolean super_setFrame(int left, int top, int right, int bottom) {
1726            return WebView.super.setFrame(left, top, right, bottom);
1727        }
1728
1729        public boolean super_dispatchKeyEvent(KeyEvent event) {
1730            return WebView.super.dispatchKeyEvent(event);
1731        }
1732
1733        public boolean super_onGenericMotionEvent(MotionEvent event) {
1734            return WebView.super.onGenericMotionEvent(event);
1735        }
1736
1737        public boolean super_requestFocus(int direction, Rect previouslyFocusedRect) {
1738            return WebView.super.requestFocus(direction, previouslyFocusedRect);
1739        }
1740
1741        public void super_setLayoutParams(ViewGroup.LayoutParams params) {
1742            WebView.super.setLayoutParams(params);
1743        }
1744
1745        // ---- Access to non-public methods ----
1746        public void overScrollBy(int deltaX, int deltaY,
1747                int scrollX, int scrollY,
1748                int scrollRangeX, int scrollRangeY,
1749                int maxOverScrollX, int maxOverScrollY,
1750                boolean isTouchEvent) {
1751            WebView.this.overScrollBy(deltaX, deltaY, scrollX, scrollY, scrollRangeX, scrollRangeY,
1752                    maxOverScrollX, maxOverScrollY, isTouchEvent);
1753        }
1754
1755        public void awakenScrollBars(int duration) {
1756            WebView.this.awakenScrollBars(duration);
1757        }
1758
1759        public void awakenScrollBars(int duration, boolean invalidate) {
1760            WebView.this.awakenScrollBars(duration, invalidate);
1761        }
1762
1763        public float getVerticalScrollFactor() {
1764            return WebView.this.getVerticalScrollFactor();
1765        }
1766
1767        public float getHorizontalScrollFactor() {
1768            return WebView.this.getHorizontalScrollFactor();
1769        }
1770
1771        public void setMeasuredDimension(int measuredWidth, int measuredHeight) {
1772            WebView.this.setMeasuredDimension(measuredWidth, measuredHeight);
1773        }
1774
1775        public void onScrollChanged(int l, int t, int oldl, int oldt) {
1776            WebView.this.onScrollChanged(l, t, oldl, oldt);
1777        }
1778
1779        public int getHorizontalScrollbarHeight() {
1780            return WebView.this.getHorizontalScrollbarHeight();
1781        }
1782
1783        // ---- Access to (non-public) fields ----
1784        /** Raw setter for the scroll X value, without invoking onScrollChanged handlers etc. */
1785        public void setScrollXRaw(int scrollX) {
1786            WebView.this.mScrollX = scrollX;
1787        }
1788
1789        /** Raw setter for the scroll Y value, without invoking onScrollChanged handlers etc. */
1790        public void setScrollYRaw(int scrollY) {
1791            WebView.this.mScrollY = scrollY;
1792        }
1793
1794    }
1795
1796    //-------------------------------------------------------------------------
1797    // Private internal stuff
1798    //-------------------------------------------------------------------------
1799
1800    private WebViewProvider mProvider;
1801
1802    private void ensureProviderCreated() {
1803        checkThread();
1804        if (mProvider == null) {
1805            // As this can get called during the base class constructor chain, pass the minimum
1806            // number of dependencies here; the rest are deferred to init().
1807            mProvider = getFactory().createWebView(this, new PrivateAccess());
1808        }
1809    }
1810
1811    private static synchronized WebViewFactoryProvider getFactory() {
1812        // For now the main purpose of this function (and the factory abstration) is to keep
1813        // us honest and minimize usage of WebViewClassic internals when binding the proxy.
1814        checkThread();
1815        return WebViewFactory.getProvider();
1816    }
1817
1818    private static void checkThread() {
1819        if (Looper.myLooper() != Looper.getMainLooper()) {
1820            Throwable throwable = new Throwable(
1821                    "Warning: A WebView method was called on thread '" +
1822                    Thread.currentThread().getName() + "'. " +
1823                    "All WebView methods must be called on the UI thread. " +
1824                    "Future versions of WebView may not support use on other threads.");
1825            Log.w(LOGTAG, Log.getStackTraceString(throwable));
1826            StrictMode.onWebViewMethodCalledOnWrongThread(throwable);
1827        }
1828    }
1829
1830    //-------------------------------------------------------------------------
1831    // Override View methods
1832    //-------------------------------------------------------------------------
1833
1834    // TODO: Add a test that enumerates all methods in ViewDelegte & ScrollDelegate, and ensures
1835    // there's a corresponding override (or better, caller) for each of them in here.
1836
1837    @Override
1838    protected void onAttachedToWindow() {
1839        super.onAttachedToWindow();
1840        mProvider.getViewDelegate().onAttachedToWindow();
1841    }
1842
1843    @Override
1844    protected void onDetachedFromWindow() {
1845        mProvider.getViewDelegate().onDetachedFromWindow();
1846        super.onDetachedFromWindow();
1847    }
1848
1849    @Override
1850    public void setLayoutParams(ViewGroup.LayoutParams params) {
1851        mProvider.getViewDelegate().setLayoutParams(params);
1852    }
1853
1854    @Override
1855    public void setOverScrollMode(int mode) {
1856        super.setOverScrollMode(mode);
1857        // This method may called in the constructor chain, before the WebView provider is
1858        // created. (Fortunately, this is the only method we override that can get called by
1859        // any of the base class constructors).
1860        ensureProviderCreated();
1861        mProvider.getViewDelegate().setOverScrollMode(mode);
1862    }
1863
1864    @Override
1865    public void setScrollBarStyle(int style) {
1866        mProvider.getViewDelegate().setScrollBarStyle(style);
1867        super.setScrollBarStyle(style);
1868    }
1869
1870    @Override
1871    protected int computeHorizontalScrollRange() {
1872        return mProvider.getScrollDelegate().computeHorizontalScrollRange();
1873    }
1874
1875    @Override
1876    protected int computeHorizontalScrollOffset() {
1877        return mProvider.getScrollDelegate().computeHorizontalScrollOffset();
1878    }
1879
1880    @Override
1881    protected int computeVerticalScrollRange() {
1882        return mProvider.getScrollDelegate().computeVerticalScrollRange();
1883    }
1884
1885    @Override
1886    protected int computeVerticalScrollOffset() {
1887        return mProvider.getScrollDelegate().computeVerticalScrollOffset();
1888    }
1889
1890    @Override
1891    protected int computeVerticalScrollExtent() {
1892        return mProvider.getScrollDelegate().computeVerticalScrollExtent();
1893    }
1894
1895    @Override
1896    public void computeScroll() {
1897        mProvider.getScrollDelegate().computeScroll();
1898    }
1899
1900    @Override
1901    public boolean onHoverEvent(MotionEvent event) {
1902        return mProvider.getViewDelegate().onHoverEvent(event);
1903    }
1904
1905    @Override
1906    public boolean onTouchEvent(MotionEvent event) {
1907        return mProvider.getViewDelegate().onTouchEvent(event);
1908    }
1909
1910    @Override
1911    public boolean onGenericMotionEvent(MotionEvent event) {
1912        return mProvider.getViewDelegate().onGenericMotionEvent(event);
1913    }
1914
1915    @Override
1916    public boolean onTrackballEvent(MotionEvent event) {
1917        return mProvider.getViewDelegate().onTrackballEvent(event);
1918    }
1919
1920    @Override
1921    public boolean onKeyDown(int keyCode, KeyEvent event) {
1922        return mProvider.getViewDelegate().onKeyDown(keyCode, event);
1923    }
1924
1925    @Override
1926    public boolean onKeyUp(int keyCode, KeyEvent event) {
1927        return mProvider.getViewDelegate().onKeyUp(keyCode, event);
1928    }
1929
1930    @Override
1931    public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) {
1932        return mProvider.getViewDelegate().onKeyMultiple(keyCode, repeatCount, event);
1933    }
1934
1935    /*
1936    TODO: These are not currently implemented in WebViewClassic, but it seems inconsistent not
1937    to be delegating them too.
1938
1939    @Override
1940    public boolean onKeyPreIme(int keyCode, KeyEvent event) {
1941        return mProvider.getViewDelegate().onKeyPreIme(keyCode, event);
1942    }
1943    @Override
1944    public boolean onKeyLongPress(int keyCode, KeyEvent event) {
1945        return mProvider.getViewDelegate().onKeyLongPress(keyCode, event);
1946    }
1947    @Override
1948    public boolean onKeyShortcut(int keyCode, KeyEvent event) {
1949        return mProvider.getViewDelegate().onKeyShortcut(keyCode, event);
1950    }
1951    */
1952
1953    @Deprecated
1954    @Override
1955    public boolean shouldDelayChildPressedState() {
1956        return mProvider.getViewDelegate().shouldDelayChildPressedState();
1957    }
1958
1959    @Override
1960    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) {
1961        super.onInitializeAccessibilityNodeInfo(info);
1962        info.setClassName(WebView.class.getName());
1963        mProvider.getViewDelegate().onInitializeAccessibilityNodeInfo(info);
1964    }
1965
1966    @Override
1967    public void onInitializeAccessibilityEvent(AccessibilityEvent event) {
1968        super.onInitializeAccessibilityEvent(event);
1969        event.setClassName(WebView.class.getName());
1970        mProvider.getViewDelegate().onInitializeAccessibilityEvent(event);
1971    }
1972
1973    @Override
1974    public boolean performAccessibilityAction(int action, Bundle arguments) {
1975        return mProvider.getViewDelegate().performAccessibilityAction(action, arguments);
1976    }
1977
1978    /** @hide */
1979    @Override
1980    protected void onDrawVerticalScrollBar(Canvas canvas, Drawable scrollBar,
1981            int l, int t, int r, int b) {
1982        mProvider.getViewDelegate().onDrawVerticalScrollBar(canvas, scrollBar, l, t, r, b);
1983    }
1984
1985    @Override
1986    protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
1987        mProvider.getViewDelegate().onOverScrolled(scrollX, scrollY, clampedX, clampedY);
1988    }
1989
1990    @Override
1991    protected void onWindowVisibilityChanged(int visibility) {
1992        super.onWindowVisibilityChanged(visibility);
1993        mProvider.getViewDelegate().onWindowVisibilityChanged(visibility);
1994    }
1995
1996    @Override
1997    protected void onDraw(Canvas canvas) {
1998        mProvider.getViewDelegate().onDraw(canvas);
1999    }
2000
2001    @Override
2002    public boolean performLongClick() {
2003        return mProvider.getViewDelegate().performLongClick();
2004    }
2005
2006    @Override
2007    protected void onConfigurationChanged(Configuration newConfig) {
2008        mProvider.getViewDelegate().onConfigurationChanged(newConfig);
2009    }
2010
2011    @Override
2012    public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
2013        return mProvider.getViewDelegate().onCreateInputConnection(outAttrs);
2014    }
2015
2016    @Override
2017    protected void onVisibilityChanged(View changedView, int visibility) {
2018        super.onVisibilityChanged(changedView, visibility);
2019        mProvider.getViewDelegate().onVisibilityChanged(changedView, visibility);
2020    }
2021
2022    @Override
2023    public void onWindowFocusChanged(boolean hasWindowFocus) {
2024        mProvider.getViewDelegate().onWindowFocusChanged(hasWindowFocus);
2025        super.onWindowFocusChanged(hasWindowFocus);
2026    }
2027
2028    @Override
2029    protected void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) {
2030        mProvider.getViewDelegate().onFocusChanged(focused, direction, previouslyFocusedRect);
2031        super.onFocusChanged(focused, direction, previouslyFocusedRect);
2032    }
2033
2034    /** @hide */
2035    @Override
2036    protected boolean setFrame(int left, int top, int right, int bottom) {
2037        return mProvider.getViewDelegate().setFrame(left, top, right, bottom);
2038    }
2039
2040    @Override
2041    protected void onSizeChanged(int w, int h, int ow, int oh) {
2042        super.onSizeChanged(w, h, ow, oh);
2043        mProvider.getViewDelegate().onSizeChanged(w, h, ow, oh);
2044    }
2045
2046    @Override
2047    protected void onScrollChanged(int l, int t, int oldl, int oldt) {
2048        super.onScrollChanged(l, t, oldl, oldt);
2049        mProvider.getViewDelegate().onScrollChanged(l, t, oldl, oldt);
2050    }
2051
2052    @Override
2053    public boolean dispatchKeyEvent(KeyEvent event) {
2054        return mProvider.getViewDelegate().dispatchKeyEvent(event);
2055    }
2056
2057    @Override
2058    public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
2059        return mProvider.getViewDelegate().requestFocus(direction, previouslyFocusedRect);
2060    }
2061
2062    @Deprecated
2063    @Override
2064    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
2065        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
2066        mProvider.getViewDelegate().onMeasure(widthMeasureSpec, heightMeasureSpec);
2067    }
2068
2069    @Override
2070    public boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate) {
2071        return mProvider.getViewDelegate().requestChildRectangleOnScreen(child, rect, immediate);
2072    }
2073
2074    @Override
2075    public void setBackgroundColor(int color) {
2076        mProvider.getViewDelegate().setBackgroundColor(color);
2077    }
2078
2079    @Override
2080    public void setLayerType(int layerType, Paint paint) {
2081        super.setLayerType(layerType, paint);
2082        mProvider.getViewDelegate().setLayerType(layerType, paint);
2083    }
2084}
2085