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