WebViewFactoryProvider.java revision 0c28d43fe1423198f99a0518887b69a4205bc6f7
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 * Implement the API method 80 * {@link android.webkit.WebView#initSafeBrowsing(Context , ValueCallback<Boolean>)} 81 * @hide 82 */ 83 default void initSafeBrowsing(Context context, ValueCallback<Boolean> callback) { 84 } 85 86 /** 87 * Implement the API method 88 * {@link android.webkit.WebView#shutdownSafeBrowsing()} 89 * @hide 90 */ 91 default void shutdownSafeBrowsing() { 92 } 93 } 94 95 Statics getStatics(); 96 97 /** 98 * Construct a new WebViewProvider. 99 * @param webView the WebView instance bound to this implementation instance. Note it will not 100 * necessarily be fully constructed at the point of this call: defer real initialization to 101 * WebViewProvider.init(). 102 * @param privateAccess provides access into WebView internal methods. 103 */ 104 WebViewProvider createWebView(WebView webView, WebView.PrivateAccess privateAccess); 105 106 /** 107 * Gets the singleton GeolocationPermissions instance for this WebView implementation. The 108 * implementation must return the same instance on subsequent calls. 109 * @return the single GeolocationPermissions instance. 110 */ 111 GeolocationPermissions getGeolocationPermissions(); 112 113 /** 114 * Gets the singleton CookieManager instance for this WebView implementation. The 115 * implementation must return the same instance on subsequent calls. 116 * 117 * @return the singleton CookieManager instance 118 */ 119 CookieManager getCookieManager(); 120 121 /** 122 * Gets the TokenBindingService instance for this WebView implementation. The 123 * implementation must return the same instance on subsequent calls. 124 * 125 * @return the TokenBindingService instance 126 */ 127 TokenBindingService getTokenBindingService(); 128 129 /** 130 * Gets the ServiceWorkerController instance for this WebView implementation. The 131 * implementation must return the same instance on subsequent calls. 132 * 133 * @return the ServiceWorkerController instance 134 */ 135 ServiceWorkerController getServiceWorkerController(); 136 137 /** 138 * Gets the singleton WebIconDatabase instance for this WebView implementation. The 139 * implementation must return the same instance on subsequent calls. 140 * 141 * @return the singleton WebIconDatabase instance 142 */ 143 WebIconDatabase getWebIconDatabase(); 144 145 /** 146 * Gets the singleton WebStorage instance for this WebView implementation. The 147 * implementation must return the same instance on subsequent calls. 148 * 149 * @return the singleton WebStorage instance 150 */ 151 WebStorage getWebStorage(); 152 153 /** 154 * Gets the singleton WebViewDatabase instance for this WebView implementation. The 155 * implementation must return the same instance on subsequent calls. 156 * 157 * @return the singleton WebViewDatabase instance 158 */ 159 WebViewDatabase getWebViewDatabase(Context context); 160} 161