Jonathan Dixon | 3c90952 | 2012-02-28 18:45:06 +0000 | [diff] [blame] | 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 | |
Nate Fischer | 3898ac1 | 2017-08-09 23:02:36 -0700 | [diff] [blame] | 19 | import android.annotation.NonNull; |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 20 | import android.annotation.SystemApi; |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 21 | import android.content.Context; |
Tao Bai | e8df27a | 2014-09-02 14:09:49 -0700 | [diff] [blame] | 22 | import android.content.Intent; |
| 23 | import android.net.Uri; |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 24 | |
Nate Fischer | 520a8ba | 2017-07-12 17:37:07 -0700 | [diff] [blame] | 25 | import java.util.List; |
| 26 | |
Jonathan Dixon | 3c90952 | 2012-02-28 18:45:06 +0000 | [diff] [blame] | 27 | /** |
| 28 | * This is the main entry-point into the WebView back end implementations, which the WebView |
| 29 | * proxy class uses to instantiate all the other objects as needed. The backend must provide an |
| 30 | * implementation of this interface, and make it available to the WebView via mechanism TBD. |
| 31 | * @hide |
| 32 | */ |
Ignacio Solla | 451e338 | 2014-11-10 10:35:54 +0000 | [diff] [blame] | 33 | @SystemApi |
Jonathan Dixon | 3c90952 | 2012-02-28 18:45:06 +0000 | [diff] [blame] | 34 | public interface WebViewFactoryProvider { |
Jonathan Dixon | 3c90952 | 2012-02-28 18:45:06 +0000 | [diff] [blame] | 35 | /** |
| 36 | * This Interface provides glue for implementing the backend of WebView static methods which |
| 37 | * cannot be implemented in-situ in the proxy class. |
| 38 | */ |
| 39 | interface Statics { |
| 40 | /** |
| 41 | * Implements the API method: |
| 42 | * {@link android.webkit.WebView#findAddress(String)} |
| 43 | */ |
| 44 | String findAddress(String addr); |
| 45 | |
| 46 | /** |
Jonathan Dixon | d1c4faa | 2012-08-20 16:37:15 -0700 | [diff] [blame] | 47 | * Implements the API method: |
| 48 | * {@link android.webkit.WebSettings#getDefaultUserAgent(Context) } |
| 49 | */ |
| 50 | String getDefaultUserAgent(Context context); |
Primiano Tucci | 2442675 | 2013-09-05 12:01:51 +0100 | [diff] [blame] | 51 | |
| 52 | /** |
| 53 | * Used for tests only. |
| 54 | */ |
| 55 | void freeMemoryForTests(); |
Jonathan Dixon | 90102e2 | 2013-09-21 10:47:22 -0700 | [diff] [blame] | 56 | |
| 57 | /** |
Mikhail Naganov | 057989e | 2013-09-06 16:35:25 -0700 | [diff] [blame] | 58 | * Implements the API method: |
| 59 | * {@link android.webkit.WebView#setWebContentsDebuggingEnabled(boolean) } |
| 60 | */ |
| 61 | void setWebContentsDebuggingEnabled(boolean enable); |
Selim Gurun | e1c6c3a | 2014-04-28 14:21:21 -0700 | [diff] [blame] | 62 | |
| 63 | /** |
| 64 | * Implements the API method: |
| 65 | * {@link android.webkit.WebView#clearClientCertPreferences(Runnable) } |
| 66 | */ |
| 67 | void clearClientCertPreferences(Runnable onCleared); |
| 68 | |
Selim Gurun | 7871554 | 2014-07-09 14:40:13 -0700 | [diff] [blame] | 69 | /** |
| 70 | * Implements the API method: |
Bo Liu | 9f3ed85 | 2014-07-18 10:03:12 -0700 | [diff] [blame] | 71 | * {@link android.webkit.WebView#setSlowWholeDocumentDrawEnabled(boolean) } |
| 72 | */ |
| 73 | void enableSlowWholeDocumentDraw(); |
Tao Bai | e8df27a | 2014-09-02 14:09:49 -0700 | [diff] [blame] | 74 | |
| 75 | /** |
| 76 | * Implement the API method |
| 77 | * {@link android.webkit.WebChromeClient.FileChooserParams#parseResult(int, Intent)} |
| 78 | */ |
| 79 | Uri[] parseFileChooserResult(int resultCode, Intent intent); |
Nate Fischer | 0e72c18 | 2017-05-30 11:25:17 -0700 | [diff] [blame] | 80 | |
| 81 | /** |
| 82 | * Implement the API method |
Nate Fischer | 2b108d8 | 2017-08-21 17:59:55 -0700 | [diff] [blame] | 83 | * {@link android.webkit.WebView#startSafeBrowsing(Context , ValueCallback<Boolean>)} |
Nate Fischer | 0e72c18 | 2017-05-30 11:25:17 -0700 | [diff] [blame] | 84 | */ |
Jeff Sharkey | 9039636 | 2017-06-12 16:26:53 -0600 | [diff] [blame] | 85 | void initSafeBrowsing(Context context, ValueCallback<Boolean> callback); |
Nate Fischer | 0e72c18 | 2017-05-30 11:25:17 -0700 | [diff] [blame] | 86 | |
| 87 | /** |
Nate Fischer | bf158ec | 2017-06-27 22:52:20 -0700 | [diff] [blame] | 88 | * Implement the API method |
Nate Fischer | d6385d3 | 2017-07-17 12:58:18 -0700 | [diff] [blame] | 89 | * {@link android.webkit.WebView#setSafeBrowsingWhitelist(List<String>, |
| 90 | * ValueCallback<Boolean>)} |
Nate Fischer | bf158ec | 2017-06-27 22:52:20 -0700 | [diff] [blame] | 91 | */ |
Nate Fischer | 5a6ae8c | 2018-02-21 15:27:01 -0800 | [diff] [blame] | 92 | void setSafeBrowsingWhitelist(List<String> hosts, ValueCallback<Boolean> callback); |
Nate Fischer | 3898ac1 | 2017-08-09 23:02:36 -0700 | [diff] [blame] | 93 | |
| 94 | /** |
| 95 | * Implement the API method |
| 96 | * {@link android.webkit.WebView#getSafeBrowsingPrivacyPolicyUrl()} |
| 97 | */ |
| 98 | @NonNull |
| 99 | Uri getSafeBrowsingPrivacyPolicyUrl(); |
Jonathan Dixon | 3c90952 | 2012-02-28 18:45:06 +0000 | [diff] [blame] | 100 | } |
Jonathan Dixon | d3101b1 | 2012-04-12 20:51:51 +0100 | [diff] [blame] | 101 | |
| 102 | Statics getStatics(); |
| 103 | |
| 104 | /** |
| 105 | * Construct a new WebViewProvider. |
| 106 | * @param webView the WebView instance bound to this implementation instance. Note it will not |
| 107 | * necessarily be fully constructed at the point of this call: defer real initialization to |
| 108 | * WebViewProvider.init(). |
| 109 | * @param privateAccess provides access into WebView internal methods. |
| 110 | */ |
| 111 | WebViewProvider createWebView(WebView webView, WebView.PrivateAccess privateAccess); |
| 112 | |
| 113 | /** |
| 114 | * Gets the singleton GeolocationPermissions instance for this WebView implementation. The |
| 115 | * implementation must return the same instance on subsequent calls. |
| 116 | * @return the single GeolocationPermissions instance. |
| 117 | */ |
| 118 | GeolocationPermissions getGeolocationPermissions(); |
| 119 | |
| 120 | /** |
| 121 | * Gets the singleton CookieManager instance for this WebView implementation. The |
| 122 | * implementation must return the same instance on subsequent calls. |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 123 | * |
| 124 | * @return the singleton CookieManager instance |
Jonathan Dixon | d3101b1 | 2012-04-12 20:51:51 +0100 | [diff] [blame] | 125 | */ |
| 126 | CookieManager getCookieManager(); |
| 127 | |
| 128 | /** |
Selim Gurun | 504b81b | 2016-01-15 21:10:52 +0000 | [diff] [blame] | 129 | * Gets the TokenBindingService instance for this WebView implementation. The |
| 130 | * implementation must return the same instance on subsequent calls. |
| 131 | * |
| 132 | * @return the TokenBindingService instance |
Selim Gurun | 504b81b | 2016-01-15 21:10:52 +0000 | [diff] [blame] | 133 | */ |
| 134 | TokenBindingService getTokenBindingService(); |
| 135 | |
| 136 | /** |
Tim Volodine | c809542 | 2017-11-10 21:07:36 +0000 | [diff] [blame] | 137 | * Gets the TracingController instance for this WebView implementation. The |
| 138 | * implementation must return the same instance on subsequent calls. |
| 139 | * |
| 140 | * @return the TracingController instance |
| 141 | */ |
| 142 | TracingController getTracingController(); |
| 143 | |
| 144 | /** |
Tim Volodine | 28c8356 | 2016-01-20 19:23:03 +0000 | [diff] [blame] | 145 | * Gets the ServiceWorkerController instance for this WebView implementation. The |
| 146 | * implementation must return the same instance on subsequent calls. |
| 147 | * |
| 148 | * @return the ServiceWorkerController instance |
| 149 | */ |
| 150 | ServiceWorkerController getServiceWorkerController(); |
| 151 | |
| 152 | /** |
Jonathan Dixon | d3101b1 | 2012-04-12 20:51:51 +0100 | [diff] [blame] | 153 | * Gets the singleton WebIconDatabase instance for this WebView implementation. The |
| 154 | * implementation must return the same instance on subsequent calls. |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 155 | * |
| 156 | * @return the singleton WebIconDatabase instance |
Jonathan Dixon | d3101b1 | 2012-04-12 20:51:51 +0100 | [diff] [blame] | 157 | */ |
| 158 | WebIconDatabase getWebIconDatabase(); |
| 159 | |
| 160 | /** |
| 161 | * Gets the singleton WebStorage instance for this WebView implementation. The |
| 162 | * implementation must return the same instance on subsequent calls. |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 163 | * |
| 164 | * @return the singleton WebStorage instance |
Jonathan Dixon | d3101b1 | 2012-04-12 20:51:51 +0100 | [diff] [blame] | 165 | */ |
| 166 | WebStorage getWebStorage(); |
Ben Murdoch | 99c12e8 | 2012-04-25 15:00:17 +0100 | [diff] [blame] | 167 | |
| 168 | /** |
| 169 | * Gets the singleton WebViewDatabase instance for this WebView implementation. The |
| 170 | * implementation must return the same instance on subsequent calls. |
| 171 | * |
| 172 | * @return the singleton WebViewDatabase instance |
| 173 | */ |
| 174 | WebViewDatabase getWebViewDatabase(Context context); |
Gustav Sennton | 265afdb | 2018-01-19 11:56:55 +0000 | [diff] [blame] | 175 | |
| 176 | /** |
| 177 | * Gets the classloader used to load internal WebView implementation classes. This interface |
| 178 | * should only be used by the WebView Support Library. |
| 179 | */ |
| 180 | ClassLoader getWebViewClassLoader(); |
Jonathan Dixon | 3c90952 | 2012-02-28 18:45:06 +0000 | [diff] [blame] | 181 | } |