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