Home | History | Annotate | Download | only in webkit
      1 /*
      2  * Copyright (C) 2012 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 
     17 package android.webkit;
     18 
     19 import android.annotation.NonNull;
     20 import android.annotation.SystemApi;
     21 import android.content.Context;
     22 import android.content.Intent;
     23 import android.net.Uri;
     24 
     25 import java.util.List;
     26 
     27 /**
     28  * This is the main entry-point into the WebView back end implementations, which the WebView
     29  * proxy class uses to instantiate all the other objects as needed. The backend must provide an
     30  * implementation of this interface, and make it available to the WebView via mechanism TBD.
     31  * @hide
     32  */
     33 @SystemApi
     34 public interface WebViewFactoryProvider {
     35     /**
     36      * This Interface provides glue for implementing the backend of WebView static methods which
     37      * cannot be implemented in-situ in the proxy class.
     38      */
     39     interface Statics {
     40         /**
     41          * Implements the API method:
     42          * {@link android.webkit.WebView#findAddress(String)}
     43          */
     44         String findAddress(String addr);
     45 
     46         /**
     47          * Implements the API method:
     48          * {@link android.webkit.WebSettings#getDefaultUserAgent(Context) }
     49          */
     50         String getDefaultUserAgent(Context context);
     51 
     52         /**
     53          * Used for tests only.
     54          */
     55          void freeMemoryForTests();
     56 
     57         /**
     58          * Implements the API method:
     59          * {@link android.webkit.WebView#setWebContentsDebuggingEnabled(boolean) }
     60          */
     61         void setWebContentsDebuggingEnabled(boolean enable);
     62 
     63         /**
     64          * Implements the API method:
     65          * {@link android.webkit.WebView#clearClientCertPreferences(Runnable) }
     66          */
     67         void clearClientCertPreferences(Runnable onCleared);
     68 
     69         /**
     70          * Implements the API method:
     71          * {@link android.webkit.WebView#setSlowWholeDocumentDrawEnabled(boolean) }
     72          */
     73         void enableSlowWholeDocumentDraw();
     74 
     75         /**
     76          * Implement the API method
     77          * {@link android.webkit.WebChromeClient.FileChooserParams#parseResult(int, Intent)}
     78          */
     79         Uri[] parseFileChooserResult(int resultCode, Intent intent);
     80 
     81         /**
     82          * Implement the API method
     83          * {@link android.webkit.WebView#startSafeBrowsing(Context , ValueCallback<Boolean>)}
     84          */
     85         void initSafeBrowsing(Context context, ValueCallback<Boolean> callback);
     86 
     87         /**
     88         * Implement the API method
     89         * {@link android.webkit.WebView#setSafeBrowsingWhitelist(List<String>,
     90         * ValueCallback<Boolean>)}
     91         */
     92         void setSafeBrowsingWhitelist(List<String> hosts, ValueCallback<Boolean> callback);
     93 
     94         /**
     95          * Implement the API method
     96          * {@link android.webkit.WebView#getSafeBrowsingPrivacyPolicyUrl()}
     97          */
     98         @NonNull
     99         Uri getSafeBrowsingPrivacyPolicyUrl();
    100     }
    101 
    102     Statics getStatics();
    103 
    104     /**
    105      * Construct a new WebViewProvider.
    106      * @param webView the WebView instance bound to this implementation instance. Note it will not
    107      * necessarily be fully constructed at the point of this call: defer real initialization to
    108      * WebViewProvider.init().
    109      * @param privateAccess provides access into WebView internal methods.
    110      */
    111     WebViewProvider createWebView(WebView webView, WebView.PrivateAccess privateAccess);
    112 
    113     /**
    114      * Gets the singleton GeolocationPermissions instance for this WebView implementation. The
    115      * implementation must return the same instance on subsequent calls.
    116      * @return the single GeolocationPermissions instance.
    117      */
    118     GeolocationPermissions getGeolocationPermissions();
    119 
    120     /**
    121      * Gets the singleton CookieManager instance for this WebView implementation. The
    122      * implementation must return the same instance on subsequent calls.
    123      *
    124      * @return the singleton CookieManager instance
    125      */
    126     CookieManager getCookieManager();
    127 
    128     /**
    129      * Gets the TokenBindingService instance for this WebView implementation. The
    130      * implementation must return the same instance on subsequent calls.
    131      *
    132      * @return the TokenBindingService instance
    133      */
    134     TokenBindingService getTokenBindingService();
    135 
    136     /**
    137      * Gets the TracingController instance for this WebView implementation. The
    138      * implementation must return the same instance on subsequent calls.
    139      *
    140      * @return the TracingController instance
    141      */
    142     TracingController getTracingController();
    143 
    144     /**
    145      * Gets the ServiceWorkerController instance for this WebView implementation. The
    146      * implementation must return the same instance on subsequent calls.
    147      *
    148      * @return the ServiceWorkerController instance
    149      */
    150     ServiceWorkerController getServiceWorkerController();
    151 
    152     /**
    153      * Gets the singleton WebIconDatabase instance for this WebView implementation. The
    154      * implementation must return the same instance on subsequent calls.
    155      *
    156      * @return the singleton WebIconDatabase instance
    157      */
    158     WebIconDatabase getWebIconDatabase();
    159 
    160     /**
    161      * Gets the singleton WebStorage instance for this WebView implementation. The
    162      * implementation must return the same instance on subsequent calls.
    163      *
    164      * @return the singleton WebStorage instance
    165      */
    166     WebStorage getWebStorage();
    167 
    168     /**
    169      * Gets the singleton WebViewDatabase instance for this WebView implementation. The
    170      * implementation must return the same instance on subsequent calls.
    171      *
    172      * @return the singleton WebViewDatabase instance
    173      */
    174     WebViewDatabase getWebViewDatabase(Context context);
    175 
    176     /**
    177      * Gets the classloader used to load internal WebView implementation classes. This interface
    178      * should only be used by the WebView Support Library.
    179      */
    180     ClassLoader getWebViewClassLoader();
    181 }
    182