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