| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.webkit; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.annotation.SuppressLint; |
| 22 |
import android.annotation.SystemApi; |
| 23 |
import android.content.Intent; |
| 24 |
import android.content.res.Configuration; |
| 25 |
import android.graphics.Bitmap; |
| 26 |
import android.graphics.Canvas; |
| 27 |
import android.graphics.Paint; |
| 28 |
import android.graphics.Picture; |
| 29 |
import android.graphics.Rect; |
| 30 |
import android.graphics.drawable.Drawable; |
| 31 |
import android.net.Uri; |
| 32 |
import android.net.http.SslCertificate; |
| 33 |
import android.os.Bundle; |
| 34 |
import android.os.Handler; |
| 35 |
import android.os.Message; |
| 36 |
import android.print.PrintDocumentAdapter; |
| 37 |
import android.util.LongSparseArray; |
| 38 |
import android.util.SparseArray; |
| 39 |
import android.view.DragEvent; |
| 40 |
import android.view.KeyEvent; |
| 41 |
import android.view.MotionEvent; |
| 42 |
import android.view.View; |
| 43 |
import android.view.ViewGroup.LayoutParams; |
| 44 |
import android.view.WindowInsets; |
| 45 |
import android.view.accessibility.AccessibilityEvent; |
| 46 |
import android.view.accessibility.AccessibilityNodeInfo; |
| 47 |
import android.view.accessibility.AccessibilityNodeProvider; |
| 48 |
import android.view.autofill.AutofillId; |
| 49 |
import android.view.autofill.AutofillValue; |
| 50 |
import android.view.inputmethod.EditorInfo; |
| 51 |
import android.view.inputmethod.InputConnection; |
| 52 |
import android.view.textclassifier.TextClassifier; |
| 53 |
import android.view.translation.TranslationCapability; |
| 54 |
import android.view.translation.TranslationSpec.DataFormat; |
| 55 |
import android.view.translation.ViewTranslationRequest; |
| 56 |
import android.view.translation.ViewTranslationResponse; |
| 57 |
import android.webkit.WebView.HitTestResult; |
| 58 |
import android.webkit.WebView.PictureListener; |
| 59 |
import android.webkit.WebView.VisualStateCallback; |
| 60 |
|
| 61 |
|
| 62 |
import java.io.BufferedWriter; |
| 63 |
import java.io.File; |
| 64 |
import java.util.List; |
| 65 |
import java.util.Map; |
| 66 |
import java.util.concurrent.Executor; |
| 67 |
import java.util.function.Consumer; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
@SystemApi |
| 79 |
public interface WebViewProvider { |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
public void init(Map<String, Object> javaScriptInterfaces, |
| 91 |
boolean privateBrowsing); |
| 92 |
|
| 93 |
|
| 94 |
public void setHorizontalScrollbarOverlay(boolean overlay); |
| 95 |
|
| 96 |
|
| 97 |
public void setVerticalScrollbarOverlay(boolean overlay); |
| 98 |
|
| 99 |
|
| 100 |
public boolean overlayHorizontalScrollbar(); |
| 101 |
|
| 102 |
|
| 103 |
public boolean overlayVerticalScrollbar(); |
| 104 |
|
| 105 |
public int getVisibleTitleHeight(); |
| 106 |
|
| 107 |
public SslCertificate getCertificate(); |
| 108 |
|
| 109 |
public void setCertificate(SslCertificate certificate); |
| 110 |
|
| 111 |
public void savePassword(String host, String username, String password); |
| 112 |
|
| 113 |
public void setHttpAuthUsernamePassword(String host, String realm, |
| 114 |
String username, String password); |
| 115 |
|
| 116 |
public String[] getHttpAuthUsernamePassword(String host, String realm); |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
public void destroy(); |
| 125 |
|
| 126 |
public void setNetworkAvailable(boolean networkUp); |
| 127 |
|
| 128 |
public WebBackForwardList saveState(Bundle outState); |
| 129 |
|
| 130 |
public boolean savePicture(Bundle b, final File dest); |
| 131 |
|
| 132 |
public boolean restorePicture(Bundle b, File src); |
| 133 |
|
| 134 |
public WebBackForwardList restoreState(Bundle inState); |
| 135 |
|
| 136 |
public void loadUrl(String url, Map<String, String> additionalHttpHeaders); |
| 137 |
|
| 138 |
public void loadUrl(String url); |
| 139 |
|
| 140 |
public void postUrl(String url, byte[] postData); |
| 141 |
|
| 142 |
public void loadData(String data, String mimeType, String encoding); |
| 143 |
|
| 144 |
public void loadDataWithBaseURL(String baseUrl, String data, |
| 145 |
String mimeType, String encoding, String historyUrl); |
| 146 |
|
| 147 |
public void evaluateJavaScript(String script, ValueCallback<String> resultCallback); |
| 148 |
|
| 149 |
public void saveWebArchive(String filename); |
| 150 |
|
| 151 |
public void saveWebArchive(String basename, boolean autoname, ValueCallback<String> callback); |
| 152 |
|
| 153 |
public void stopLoading(); |
| 154 |
|
| 155 |
public void reload(); |
| 156 |
|
| 157 |
public boolean canGoBack(); |
| 158 |
|
| 159 |
public void goBack(); |
| 160 |
|
| 161 |
public boolean canGoForward(); |
| 162 |
|
| 163 |
public void goForward(); |
| 164 |
|
| 165 |
public boolean canGoBackOrForward(int steps); |
| 166 |
|
| 167 |
public void goBackOrForward(int steps); |
| 168 |
|
| 169 |
public boolean isPrivateBrowsingEnabled(); |
| 170 |
|
| 171 |
public boolean pageUp(boolean top); |
| 172 |
|
| 173 |
public boolean pageDown(boolean bottom); |
| 174 |
|
| 175 |
public void insertVisualStateCallback(long requestId, VisualStateCallback callback); |
| 176 |
|
| 177 |
public void clearView(); |
| 178 |
|
| 179 |
public Picture capturePicture(); |
| 180 |
|
| 181 |
public PrintDocumentAdapter createPrintDocumentAdapter(String documentName); |
| 182 |
|
| 183 |
public float getScale(); |
| 184 |
|
| 185 |
public void setInitialScale(int scaleInPercent); |
| 186 |
|
| 187 |
public void invokeZoomPicker(); |
| 188 |
|
| 189 |
public HitTestResult getHitTestResult(); |
| 190 |
|
| 191 |
public void requestFocusNodeHref(Message hrefMsg); |
| 192 |
|
| 193 |
public void requestImageRef(Message msg); |
| 194 |
|
| 195 |
public String getUrl(); |
| 196 |
|
| 197 |
public String getOriginalUrl(); |
| 198 |
|
| 199 |
public String getTitle(); |
| 200 |
|
| 201 |
public Bitmap getFavicon(); |
| 202 |
|
| 203 |
public String getTouchIconUrl(); |
| 204 |
|
| 205 |
public int getProgress(); |
| 206 |
|
| 207 |
public int getContentHeight(); |
| 208 |
|
| 209 |
public int getContentWidth(); |
| 210 |
|
| 211 |
public void pauseTimers(); |
| 212 |
|
| 213 |
public void resumeTimers(); |
| 214 |
|
| 215 |
public void onPause(); |
| 216 |
|
| 217 |
public void onResume(); |
| 218 |
|
| 219 |
public boolean isPaused(); |
| 220 |
|
| 221 |
public void freeMemory(); |
| 222 |
|
| 223 |
public void clearCache(boolean includeDiskFiles); |
| 224 |
|
| 225 |
public void clearFormData(); |
| 226 |
|
| 227 |
public void clearHistory(); |
| 228 |
|
| 229 |
public void clearSslPreferences(); |
| 230 |
|
| 231 |
public WebBackForwardList copyBackForwardList(); |
| 232 |
|
| 233 |
public void setFindListener(WebView.FindListener listener); |
| 234 |
|
| 235 |
public void findNext(boolean forward); |
| 236 |
|
| 237 |
public int findAll(String find); |
| 238 |
|
| 239 |
public void findAllAsync(String find); |
| 240 |
|
| 241 |
public boolean showFindDialog(String text, boolean showIme); |
| 242 |
|
| 243 |
public void clearMatches(); |
| 244 |
|
| 245 |
public void documentHasImages(Message response); |
| 246 |
|
| 247 |
public void setWebViewClient(WebViewClient client); |
| 248 |
|
| 249 |
public WebViewClient getWebViewClient(); |
| 250 |
|
| 251 |
@Nullable |
| 252 |
public WebViewRenderProcess getWebViewRenderProcess(); |
| 253 |
|
| 254 |
public void setWebViewRenderProcessClient( |
| 255 |
@Nullable Executor executor, |
| 256 |
@Nullable WebViewRenderProcessClient client); |
| 257 |
|
| 258 |
@Nullable |
| 259 |
public WebViewRenderProcessClient getWebViewRenderProcessClient(); |
| 260 |
|
| 261 |
public void setDownloadListener(DownloadListener listener); |
| 262 |
|
| 263 |
public void setWebChromeClient(WebChromeClient client); |
| 264 |
|
| 265 |
public WebChromeClient getWebChromeClient(); |
| 266 |
|
| 267 |
public void setPictureListener(PictureListener listener); |
| 268 |
|
| 269 |
public void addJavascriptInterface(Object obj, String interfaceName); |
| 270 |
|
| 271 |
public void removeJavascriptInterface(String interfaceName); |
| 272 |
|
| 273 |
public WebMessagePort[] createWebMessageChannel(); |
| 274 |
|
| 275 |
public void postMessageToMainFrame(WebMessage message, Uri targetOrigin); |
| 276 |
|
| 277 |
public WebSettings getSettings(); |
| 278 |
|
| 279 |
public void setMapTrackballToArrowKeys(boolean setMap); |
| 280 |
|
| 281 |
public void flingScroll(int vx, int vy); |
| 282 |
|
| 283 |
public View getZoomControls(); |
| 284 |
|
| 285 |
public boolean canZoomIn(); |
| 286 |
|
| 287 |
public boolean canZoomOut(); |
| 288 |
|
| 289 |
public boolean zoomBy(float zoomFactor); |
| 290 |
|
| 291 |
public boolean zoomIn(); |
| 292 |
|
| 293 |
public boolean zoomOut(); |
| 294 |
|
| 295 |
public void dumpViewHierarchyWithProperties(BufferedWriter out, int level); |
| 296 |
|
| 297 |
public View findHierarchyView(String className, int hashCode); |
| 298 |
|
| 299 |
public void setRendererPriorityPolicy(int rendererRequestedPriority, boolean waivedWhenNotVisible); |
| 300 |
|
| 301 |
public int getRendererRequestedPriority(); |
| 302 |
|
| 303 |
public boolean getRendererPriorityWaivedWhenNotVisible(); |
| 304 |
|
| 305 |
@SuppressWarnings("unused") |
| 306 |
public default void setTextClassifier(@Nullable TextClassifier textClassifier) {} |
| 307 |
|
| 308 |
@NonNull |
| 309 |
public default TextClassifier getTextClassifier() { return TextClassifier.NO_OP; } |
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
ViewDelegate getViewDelegate(); |
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
ScrollDelegate getScrollDelegate(); |
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
public void notifyFindDialogDismissed(); |
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
interface ViewDelegate { |
| 349 |
public boolean shouldDelayChildPressedState(); |
| 350 |
|
| 351 |
public void onProvideVirtualStructure(android.view.ViewStructure structure); |
| 352 |
|
| 353 |
default void onProvideAutofillVirtualStructure( |
| 354 |
@SuppressWarnings("unused") android.view.ViewStructure structure, |
| 355 |
@SuppressWarnings("unused") int flags) { |
| 356 |
} |
| 357 |
|
| 358 |
default void autofill(@SuppressWarnings("unused") SparseArray<AutofillValue> values) { |
| 359 |
} |
| 360 |
|
| 361 |
default boolean isVisibleToUserForAutofill(@SuppressWarnings("unused") int virtualId) { |
| 362 |
return true; |
| 363 |
} |
| 364 |
|
| 365 |
default void onProvideContentCaptureStructure( |
| 366 |
@NonNull @SuppressWarnings("unused") android.view.ViewStructure structure, |
| 367 |
@SuppressWarnings("unused") int flags) { |
| 368 |
} |
| 369 |
|
| 370 |
@SuppressLint("NullableCollection") |
| 371 |
default void onCreateVirtualViewTranslationRequests( |
| 372 |
@NonNull @SuppressWarnings("unused") long[] virtualIds, |
| 373 |
@NonNull @SuppressWarnings("unused") @DataFormat int[] supportedFormats, |
| 374 |
@NonNull @SuppressWarnings("unused") |
| 375 |
Consumer<ViewTranslationRequest> requestsCollector) { |
| 376 |
} |
| 377 |
|
| 378 |
default void onVirtualViewTranslationResponses( |
| 379 |
@NonNull @SuppressWarnings("unused") |
| 380 |
LongSparseArray<ViewTranslationResponse> response) { |
| 381 |
} |
| 382 |
|
| 383 |
default void dispatchCreateViewTranslationRequest( |
| 384 |
@NonNull @SuppressWarnings("unused") Map<AutofillId, long[]> viewIds, |
| 385 |
@NonNull @SuppressWarnings("unused") @DataFormat int[] supportedFormats, |
| 386 |
@Nullable @SuppressWarnings("unused") TranslationCapability capability, |
| 387 |
@NonNull @SuppressWarnings("unused") List<ViewTranslationRequest> requests) { |
| 388 |
|
| 389 |
} |
| 390 |
|
| 391 |
public AccessibilityNodeProvider getAccessibilityNodeProvider(); |
| 392 |
|
| 393 |
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info); |
| 394 |
|
| 395 |
public void onInitializeAccessibilityEvent(AccessibilityEvent event); |
| 396 |
|
| 397 |
public boolean performAccessibilityAction(int action, Bundle arguments); |
| 398 |
|
| 399 |
public void setOverScrollMode(int mode); |
| 400 |
|
| 401 |
public void setScrollBarStyle(int style); |
| 402 |
|
| 403 |
public void onDrawVerticalScrollBar(Canvas canvas, Drawable scrollBar, int l, int t, |
| 404 |
int r, int b); |
| 405 |
|
| 406 |
public void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY); |
| 407 |
|
| 408 |
public void onWindowVisibilityChanged(int visibility); |
| 409 |
|
| 410 |
public void onDraw(Canvas canvas); |
| 411 |
|
| 412 |
public void setLayoutParams(LayoutParams layoutParams); |
| 413 |
|
| 414 |
public boolean performLongClick(); |
| 415 |
|
| 416 |
public void onConfigurationChanged(Configuration newConfig); |
| 417 |
|
| 418 |
public InputConnection onCreateInputConnection(EditorInfo outAttrs); |
| 419 |
|
| 420 |
public boolean onDragEvent(DragEvent event); |
| 421 |
|
| 422 |
public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event); |
| 423 |
|
| 424 |
public boolean onKeyDown(int keyCode, KeyEvent event); |
| 425 |
|
| 426 |
public boolean onKeyUp(int keyCode, KeyEvent event); |
| 427 |
|
| 428 |
public void onAttachedToWindow(); |
| 429 |
|
| 430 |
public void onDetachedFromWindow(); |
| 431 |
|
| 432 |
public default void onMovedToDisplay(int displayId, Configuration config) {} |
| 433 |
|
| 434 |
public void onVisibilityChanged(View changedView, int visibility); |
| 435 |
|
| 436 |
public void onWindowFocusChanged(boolean hasWindowFocus); |
| 437 |
|
| 438 |
public void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect); |
| 439 |
|
| 440 |
public boolean setFrame(int left, int top, int right, int bottom); |
| 441 |
|
| 442 |
public void onSizeChanged(int w, int h, int ow, int oh); |
| 443 |
|
| 444 |
public void onScrollChanged(int l, int t, int oldl, int oldt); |
| 445 |
|
| 446 |
public boolean dispatchKeyEvent(KeyEvent event); |
| 447 |
|
| 448 |
public boolean onTouchEvent(MotionEvent ev); |
| 449 |
|
| 450 |
public boolean onHoverEvent(MotionEvent event); |
| 451 |
|
| 452 |
public boolean onGenericMotionEvent(MotionEvent event); |
| 453 |
|
| 454 |
public boolean onTrackballEvent(MotionEvent ev); |
| 455 |
|
| 456 |
public boolean requestFocus(int direction, Rect previouslyFocusedRect); |
| 457 |
|
| 458 |
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec); |
| 459 |
|
| 460 |
public boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate); |
| 461 |
|
| 462 |
public void setBackgroundColor(int color); |
| 463 |
|
| 464 |
public void setLayerType(int layerType, Paint paint); |
| 465 |
|
| 466 |
public void preDispatchDraw(Canvas canvas); |
| 467 |
|
| 468 |
public void onStartTemporaryDetach(); |
| 469 |
|
| 470 |
public void onFinishTemporaryDetach(); |
| 471 |
|
| 472 |
public void onActivityResult(int requestCode, int resultCode, Intent data); |
| 473 |
|
| 474 |
public Handler getHandler(Handler originalHandler); |
| 475 |
|
| 476 |
public View findFocus(View originalFocusedView); |
| 477 |
|
| 478 |
@SuppressWarnings("unused") |
| 479 |
default boolean onCheckIsTextEditor() { |
| 480 |
return false; |
| 481 |
} |
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
@SuppressWarnings("unused") |
| 495 |
@Nullable |
| 496 |
default WindowInsets onApplyWindowInsets(@Nullable WindowInsets insets) { |
| 497 |
return null; |
| 498 |
} |
| 499 |
} |
| 500 |
|
| 501 |
interface ScrollDelegate { |
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
public int computeHorizontalScrollRange(); |
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
public int computeHorizontalScrollOffset(); |
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
public int computeVerticalScrollRange(); |
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
public int computeVerticalScrollOffset(); |
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
public int computeVerticalScrollExtent(); |
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
public void computeScroll(); |
| 534 |
} |
| 535 |
} |