• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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          */
findAddress(String addr)44         String findAddress(String addr);
45 
46         /**
47          * Implements the API method:
48          * {@link android.webkit.WebSettings#getDefaultUserAgent(Context) }
49          */
getDefaultUserAgent(Context context)50         String getDefaultUserAgent(Context context);
51 
52         /**
53          * Used for tests only.
54          */
freeMemoryForTests()55          void freeMemoryForTests();
56 
57         /**
58          * Implements the API method:
59          * {@link android.webkit.WebView#setWebContentsDebuggingEnabled(boolean) }
60          */
setWebContentsDebuggingEnabled(boolean enable)61         void setWebContentsDebuggingEnabled(boolean enable);
62 
63         /**
64          * Implements the API method:
65          * {@link android.webkit.WebView#clearClientCertPreferences(Runnable) }
66          */
clearClientCertPreferences(Runnable onCleared)67         void clearClientCertPreferences(Runnable onCleared);
68 
69         /**
70          * Implements the API method:
71          * {@link android.webkit.WebView#setSlowWholeDocumentDrawEnabled(boolean) }
72          */
enableSlowWholeDocumentDraw()73         void enableSlowWholeDocumentDraw();
74 
75         /**
76          * Implement the API method
77          * {@link android.webkit.WebChromeClient.FileChooserParams#parseResult(int, Intent)}
78          */
parseFileChooserResult(int resultCode, Intent intent)79         Uri[] parseFileChooserResult(int resultCode, Intent intent);
80 
81         /**
82          * Implement the API method
83          * {@link android.webkit.WebView#startSafeBrowsing(Context , ValueCallback<Boolean>)}
84          */
initSafeBrowsing(Context context, ValueCallback<Boolean> callback)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         */
setSafeBrowsingWhitelist(List<String> urls, ValueCallback<Boolean> callback)92         void setSafeBrowsingWhitelist(List<String> urls, ValueCallback<Boolean> callback);
93 
94         /**
95          * Implement the API method
96          * {@link android.webkit.WebView#getSafeBrowsingPrivacyPolicyUrl()}
97          */
98         @NonNull
getSafeBrowsingPrivacyPolicyUrl()99         Uri getSafeBrowsingPrivacyPolicyUrl();
100     }
101 
getStatics()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      */
createWebView(WebView webView, WebView.PrivateAccess privateAccess)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      */
getGeolocationPermissions()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      */
getCookieManager()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      */
getTokenBindingService()134     TokenBindingService getTokenBindingService();
135 
136     /**
137      * Gets the ServiceWorkerController instance for this WebView implementation. The
138      * implementation must return the same instance on subsequent calls.
139      *
140      * @return the ServiceWorkerController instance
141      */
getServiceWorkerController()142     ServiceWorkerController getServiceWorkerController();
143 
144     /**
145      * Gets the singleton WebIconDatabase instance for this WebView implementation. The
146      * implementation must return the same instance on subsequent calls.
147      *
148      * @return the singleton WebIconDatabase instance
149      */
getWebIconDatabase()150     WebIconDatabase getWebIconDatabase();
151 
152     /**
153      * Gets the singleton WebStorage instance for this WebView implementation. The
154      * implementation must return the same instance on subsequent calls.
155      *
156      * @return the singleton WebStorage instance
157      */
getWebStorage()158     WebStorage getWebStorage();
159 
160     /**
161      * Gets the singleton WebViewDatabase instance for this WebView implementation. The
162      * implementation must return the same instance on subsequent calls.
163      *
164      * @return the singleton WebViewDatabase instance
165      */
getWebViewDatabase(Context context)166     WebViewDatabase getWebViewDatabase(Context context);
167 }
168