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