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.SystemApi; 20 import android.content.Context; 21 import android.content.Intent; 22 import 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 31 public 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 */ findAddress(String addr)41 String findAddress(String addr); 42 43 /** 44 * Implements the API method: 45 * {@link android.webkit.WebSettings#getDefaultUserAgent(Context) } 46 */ getDefaultUserAgent(Context context)47 String getDefaultUserAgent(Context context); 48 49 /** 50 * Used for tests only. 51 */ freeMemoryForTests()52 void freeMemoryForTests(); 53 54 /** 55 * Implements the API method: 56 * {@link android.webkit.WebView#setWebContentsDebuggingEnabled(boolean) } 57 */ setWebContentsDebuggingEnabled(boolean enable)58 void setWebContentsDebuggingEnabled(boolean enable); 59 60 /** 61 * Implements the API method: 62 * {@link android.webkit.WebView#clearClientCertPreferences(Runnable) } 63 */ clearClientCertPreferences(Runnable onCleared)64 void clearClientCertPreferences(Runnable onCleared); 65 66 /** 67 * Implements the API method: 68 * {@link android.webkit.WebView#setSlowWholeDocumentDrawEnabled(boolean) } 69 */ enableSlowWholeDocumentDraw()70 void enableSlowWholeDocumentDraw(); 71 72 /** 73 * Implement the API method 74 * {@link android.webkit.WebChromeClient.FileChooserParams#parseResult(int, Intent)} 75 */ parseFileChooserResult(int resultCode, Intent intent)76 Uri[] parseFileChooserResult(int resultCode, Intent intent); 77 } 78 getStatics()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 */ createWebView(WebView webView, WebView.PrivateAccess privateAccess)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 */ getGeolocationPermissions()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 */ getCookieManager()103 CookieManager getCookieManager(); 104 105 /** 106 * Gets the singleton WebIconDatabase instance for this WebView implementation. The 107 * implementation must return the same instance on subsequent calls. 108 * 109 * @return the singleton WebIconDatabase instance 110 */ getWebIconDatabase()111 WebIconDatabase getWebIconDatabase(); 112 113 /** 114 * Gets the singleton WebStorage instance for this WebView implementation. The 115 * implementation must return the same instance on subsequent calls. 116 * 117 * @return the singleton WebStorage instance 118 */ getWebStorage()119 WebStorage getWebStorage(); 120 121 /** 122 * Gets the singleton WebViewDatabase instance for this WebView implementation. The 123 * implementation must return the same instance on subsequent calls. 124 * 125 * @return the singleton WebViewDatabase instance 126 */ getWebViewDatabase(Context context)127 WebViewDatabase getWebViewDatabase(Context context); 128 } 129