WebViewChromium.java revision d7bf6ab0cd8cc4005b112e4358eb797bb178a85f
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 com.android.webview.chromium; 18 19import android.content.res.Configuration; 20import android.graphics.Bitmap; 21import android.graphics.Canvas; 22import android.graphics.Paint; 23import android.graphics.Picture; 24import android.graphics.Rect; 25import android.graphics.drawable.Drawable; 26import android.net.http.SslCertificate; 27import android.os.Build; 28import android.os.Bundle; 29import android.os.Message; 30import android.util.Log; 31import android.view.HardwareCanvas; 32import android.view.KeyEvent; 33import android.view.MotionEvent; 34import android.view.View; 35import android.view.View.MeasureSpec; 36import android.view.ViewGroup; 37import android.view.accessibility.AccessibilityEvent; 38import android.view.accessibility.AccessibilityNodeInfo; 39import android.view.inputmethod.EditorInfo; 40import android.view.inputmethod.InputConnection; 41import android.webkit.DownloadListener; 42import android.webkit.JavascriptInterface; 43import android.webkit.ValueCallback; 44import android.webkit.WebBackForwardList; 45import android.webkit.WebChromeClient; 46import android.webkit.WebSettings; 47import android.webkit.WebView; 48import android.webkit.WebViewClient; 49import android.webkit.WebViewProvider; 50 51import org.chromium.android_webview.AwContents; 52import org.chromium.android_webview.AwNativeWindow; 53import org.chromium.content.browser.ContentViewCore; 54import org.chromium.content.browser.LoadUrlParams; 55import org.chromium.net.NetworkChangeNotifier; 56 57import java.io.BufferedWriter; 58import java.io.File; 59import java.lang.annotation.Annotation; 60import java.util.Map; 61 62/** 63 * This class is the delegate to which WebViewProxy forwards all API calls. 64 * 65 * Most of the actual functionality is implemented by AwContents (or ContentViewCore within 66 * it). This class also contains WebView-specific APIs that require the creation of other 67 * adapters (otherwise org.chromium.content would depend on the webview.chromium package) 68 * and a small set of no-op deprecated APIs. 69 */ 70class WebViewChromium implements WebViewProvider, 71 WebViewProvider.ScrollDelegate, WebViewProvider.ViewDelegate { 72 73 private static final String TAG = WebViewChromium.class.getSimpleName(); 74 75 // The WebView that this WebViewChromium is the provider for. 76 WebView mWebView; 77 // Lets us access protected View-derived methods on the WebView instance we're backing. 78 WebView.PrivateAccess mWebViewPrivate; 79 // The client adapter class. 80 private WebViewContentsClientAdapter mContentsClientAdapter; 81 82 // Variables for functionality provided by this adapter --------------------------------------- 83 // WebSettings adapter, lazily initialized in the getter 84 private WebSettings mWebSettings; 85 // The WebView wrapper for ContentViewCore and required browser compontents. 86 private AwContents mAwContents; 87 // Non-null if this webview is using the GL accelerated draw path. 88 private DrawGLFunctor mGLfunctor; 89 90 private final WebView.HitTestResult mHitTestResult; 91 92 public WebViewChromium(WebView webView, WebView.PrivateAccess webViewPrivate) { 93 mWebView = webView; 94 mWebViewPrivate = webViewPrivate; 95 mHitTestResult = new WebView.HitTestResult(); 96 } 97 98 static void completeWindowCreation(WebView parent, WebView child) { 99 AwContents parentContents = ((WebViewChromium) parent.getWebViewProvider()).mAwContents; 100 AwContents childContents = ((WebViewChromium) child.getWebViewProvider()).mAwContents; 101 parentContents.supplyContentsForPopup(childContents); 102 } 103 104 // WebViewProvider methods -------------------------------------------------------------------- 105 106 @Override 107 public void init(Map<String, Object> javaScriptInterfaces, boolean privateBrowsing) { 108 // TODO: BUG=6790250 javaScriptInterfaces were only ever used by DumpRenderTree and should 109 // probably be implemented as a hidden hook in WebViewClassic. 110 if (privateBrowsing) { 111 throw new IllegalArgumentException( 112 "Private browsing is not supported in this version of the WebView."); 113 } 114 115 final boolean isAccessFromFileURLsGrantedByDefault = 116 mWebView.getContext().getApplicationInfo().targetSdkVersion < 117 Build.VERSION_CODES.JELLY_BEAN; 118 mContentsClientAdapter = new WebViewContentsClientAdapter(mWebView); 119 mAwContents = new AwContents(mWebView, new InternalAccessAdapter(), mContentsClientAdapter, 120 new AwNativeWindow(mWebView.getContext()), false, 121 isAccessFromFileURLsGrantedByDefault); 122 } 123 124 @Override 125 public void setHorizontalScrollbarOverlay(boolean overlay) { 126 UnimplementedWebViewApi.invoke(); 127 } 128 129 @Override 130 public void setVerticalScrollbarOverlay(boolean overlay) { 131 UnimplementedWebViewApi.invoke(); 132 } 133 134 @Override 135 public boolean overlayHorizontalScrollbar() { 136 UnimplementedWebViewApi.invoke(); 137 return false; 138 } 139 140 @Override 141 public boolean overlayVerticalScrollbar() { 142 UnimplementedWebViewApi.invoke(); 143 return false; 144 } 145 146 @Override 147 public int getVisibleTitleHeight() { 148 // This is deprecated in WebView and should always return 0. 149 return 0; 150 } 151 152 @Override 153 public SslCertificate getCertificate() { 154 return mAwContents.getCertificate(); 155 } 156 157 @Override 158 public void setCertificate(SslCertificate certificate) { 159 UnimplementedWebViewApi.invoke(); 160 } 161 162 @Override 163 public void savePassword(String host, String username, String password) { 164 UnimplementedWebViewApi.invoke(); 165 } 166 167 @Override 168 public void setHttpAuthUsernamePassword(String host, String realm, String username, 169 String password) { 170 mAwContents.setHttpAuthUsernamePassword(host, realm, username, password); 171 } 172 173 @Override 174 public String[] getHttpAuthUsernamePassword(String host, String realm) { 175 return mAwContents.getHttpAuthUsernamePassword(host, realm); 176 } 177 178 @Override 179 public void destroy() { 180 mAwContents.destroy(); 181 if (mGLfunctor != null) { 182 mGLfunctor.destroy(); 183 mGLfunctor = null; 184 } 185 } 186 187 @Override 188 public void setNetworkAvailable(boolean networkUp) { 189 NetworkChangeNotifier.forceConnectivityState(networkUp); 190 } 191 192 @Override 193 public WebBackForwardList saveState(Bundle outState) { 194 if (outState == null) return null; 195 if (!mAwContents.saveState(outState)) return null; 196 return copyBackForwardList(); 197 } 198 199 @Override 200 public boolean savePicture(Bundle b, File dest) { 201 UnimplementedWebViewApi.invoke(); 202 return false; 203 } 204 205 @Override 206 public boolean restorePicture(Bundle b, File src) { 207 UnimplementedWebViewApi.invoke(); 208 return false; 209 } 210 211 @Override 212 public WebBackForwardList restoreState(Bundle inState) { 213 if (inState == null) return null; 214 if (!mAwContents.restoreState(inState)) return null; 215 return copyBackForwardList(); 216 } 217 218 @Override 219 public void loadUrl(String url, Map<String, String> additionalHttpHeaders) { 220 // TODO: We may actually want to do some sanity checks here (like filter about://chrome). 221 LoadUrlParams params = new LoadUrlParams(url); 222 if (additionalHttpHeaders != null) params.setExtraHeaders(additionalHttpHeaders); 223 mAwContents.loadUrl(params); 224 } 225 226 @Override 227 public void loadUrl(String url) { 228 loadUrl(url, null); 229 } 230 231 @Override 232 public void postUrl(String url, byte[] postData) { 233 mAwContents.loadUrl(LoadUrlParams.createLoadHttpPostParams( 234 url, postData)); 235 } 236 237 private static boolean isBase64Encoded(String encoding) { 238 return "base64".equals(encoding); 239 } 240 241 @Override 242 public void loadData(String data, String mimeType, String encoding) { 243 mAwContents.loadUrl(LoadUrlParams.createLoadDataParams( 244 data, mimeType, isBase64Encoded(encoding))); 245 } 246 247 @Override 248 public void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, 249 String historyUrl) { 250 if (baseUrl == null || baseUrl.length() == 0) baseUrl = "about:blank"; 251 boolean isBase64 = isBase64Encoded(encoding); 252 // For backwards compatibility with WebViewClassic, we use the value of |encoding| 253 // as the charset, as long as it's not "base64". 254 mAwContents.loadUrl(LoadUrlParams.createLoadDataParamsWithBaseUrl( 255 data, mimeType, isBase64, baseUrl, historyUrl, isBase64 ? null : encoding)); 256 } 257 258 @Override 259 public void saveWebArchive(String filename) { 260 saveWebArchive(filename, false, null); 261 } 262 263 @Override 264 public void saveWebArchive(String basename, boolean autoname, ValueCallback<String> callback) { 265 mAwContents.saveWebArchive(basename, autoname, callback); 266 } 267 268 @Override 269 public void stopLoading() { 270 mAwContents.getContentViewCore().stopLoading(); 271 } 272 273 @Override 274 public void reload() { 275 mAwContents.getContentViewCore().reload(); 276 } 277 278 @Override 279 public boolean canGoBack() { 280 return mAwContents.getContentViewCore().canGoBack(); 281 } 282 283 @Override 284 public void goBack() { 285 mAwContents.getContentViewCore().goBack(); 286 } 287 288 @Override 289 public boolean canGoForward() { 290 return mAwContents.getContentViewCore().canGoForward(); 291 } 292 293 @Override 294 public void goForward() { 295 mAwContents.getContentViewCore().goForward(); 296 } 297 298 @Override 299 public boolean canGoBackOrForward(int steps) { 300 return mAwContents.getContentViewCore().canGoToOffset(steps); 301 } 302 303 @Override 304 public void goBackOrForward(int steps) { 305 mAwContents.getContentViewCore().goToOffset(steps); 306 } 307 308 @Override 309 public boolean isPrivateBrowsingEnabled() { 310 // Not supported in this WebView implementation. 311 return false; 312 } 313 314 @Override 315 public boolean pageUp(boolean top) { 316 return mAwContents.getContentViewCore().pageUp(top); 317 } 318 319 @Override 320 public boolean pageDown(boolean bottom) { 321 return mAwContents.getContentViewCore().pageDown(bottom); 322 } 323 324 @Override 325 public void clearView() { 326 UnimplementedWebViewApi.invoke(); 327 } 328 329 @Override 330 public Picture capturePicture() { 331 UnimplementedWebViewApi.invoke(); 332 return null; 333 } 334 335 @Override 336 public float getScale() { 337 return mAwContents.getContentViewCore().getScale(); 338 } 339 340 @Override 341 public void setInitialScale(int scaleInPercent) { 342 UnimplementedWebViewApi.invoke(); 343 } 344 345 @Override 346 public void invokeZoomPicker() { 347 mAwContents.getContentViewCore().invokeZoomPicker(); 348 } 349 350 @Override 351 public WebView.HitTestResult getHitTestResult() { 352 AwContents.HitTestData data = mAwContents.getLastHitTestResult(); 353 mHitTestResult.setType(data.hitTestResultType); 354 mHitTestResult.setExtra(data.hitTestResultExtraData); 355 return mHitTestResult; 356 } 357 358 @Override 359 public void requestFocusNodeHref(Message hrefMsg) { 360 mAwContents.requestFocusNodeHref(hrefMsg); 361 } 362 363 @Override 364 public void requestImageRef(Message msg) { 365 mAwContents.requestImageRef(msg); 366 } 367 368 @Override 369 public String getUrl() { 370 String url = mAwContents.getContentViewCore().getUrl(); 371 if (url == null || url.trim().isEmpty()) return null; 372 return url; 373 } 374 375 @Override 376 public String getOriginalUrl() { 377 String url = mAwContents.getOriginalUrl(); 378 if (url == null || url.trim().isEmpty()) return null; 379 return url; 380 } 381 382 @Override 383 public String getTitle() { 384 return mAwContents.getContentViewCore().getTitle(); 385 } 386 387 @Override 388 public Bitmap getFavicon() { 389 UnimplementedWebViewApi.invoke(); 390 return null; 391 } 392 393 @Override 394 public String getTouchIconUrl() { 395 UnimplementedWebViewApi.invoke(); 396 return null; 397 } 398 399 @Override 400 public int getProgress() { 401 return mAwContents.getMostRecentProgress(); 402 } 403 404 @Override 405 public int getContentHeight() { 406 return mAwContents.getContentViewCore().getContentHeight(); 407 } 408 409 @Override 410 public int getContentWidth() { 411 return mAwContents.getContentViewCore().getContentWidth(); 412 } 413 414 @Override 415 public void pauseTimers() { 416 mAwContents.pauseTimers(); 417 } 418 419 @Override 420 public void resumeTimers() { 421 mAwContents.resumeTimers(); 422 } 423 424 @Override 425 public void onPause() { 426 mAwContents.onPause(); 427 } 428 429 @Override 430 public void onResume() { 431 mAwContents.onResume(); 432 } 433 434 @Override 435 public boolean isPaused() { 436 return mAwContents.isPaused(); 437 } 438 439 @Override 440 public void freeMemory() { 441 UnimplementedWebViewApi.invoke(); 442 } 443 444 @Override 445 public void clearCache(boolean includeDiskFiles) { 446 mAwContents.clearCache(includeDiskFiles); 447 } 448 449 @Override 450 public void clearFormData() { 451 UnimplementedWebViewApi.invoke(); 452 } 453 454 @Override 455 public void clearHistory() { 456 mAwContents.getContentViewCore().clearHistory(); 457 } 458 459 @Override 460 public void clearSslPreferences() { 461 mAwContents.getContentViewCore().clearSslPreferences(); 462 } 463 464 @Override 465 public WebBackForwardList copyBackForwardList() { 466 return new WebBackForwardListChromium( 467 mAwContents.getContentViewCore().getNavigationHistory()); 468 } 469 470 @Override 471 public void setFindListener(WebView.FindListener listener) { 472 mContentsClientAdapter.setFindListener(listener); 473 } 474 475 @Override 476 public void findNext(boolean forwards) { 477 mAwContents.findNext(forwards); 478 } 479 480 @Override 481 public int findAll(String searchString) { 482 return mAwContents.findAllSync(searchString); 483 } 484 485 @Override 486 public void findAllAsync(String searchString) { 487 mAwContents.findAllAsync(searchString); 488 } 489 490 @Override 491 public boolean showFindDialog(String text, boolean showIme) { 492 UnimplementedWebViewApi.invoke(); 493 return false; 494 } 495 496 @Override 497 public void clearMatches() { 498 mAwContents.clearMatches(); 499 } 500 501 @Override 502 public void documentHasImages(Message response) { 503 mAwContents.documentHasImages(response); 504 } 505 506 @Override 507 public void setWebViewClient(WebViewClient client) { 508 mContentsClientAdapter.setWebViewClient(client); 509 } 510 511 @Override 512 public void setDownloadListener(DownloadListener listener) { 513 mContentsClientAdapter.setDownloadListener(listener); 514 } 515 516 @Override 517 public void setWebChromeClient(WebChromeClient client) { 518 mContentsClientAdapter.setWebChromeClient(client); 519 } 520 521 @Override 522 public void setPictureListener(WebView.PictureListener listener) { 523 mContentsClientAdapter.setPictureListener(listener); 524 } 525 526 @Override 527 public void addJavascriptInterface(Object obj, String interfaceName) { 528 Class<? extends Annotation> requiredAnnotation = null; 529 if (mWebView.getContext().getApplicationInfo().targetSdkVersion >= 530 Build.VERSION_CODES.JELLY_BEAN_MR1) { 531 requiredAnnotation = JavascriptInterface.class; 532 } 533 mAwContents.getContentViewCore().addPossiblyUnsafeJavascriptInterface(obj, interfaceName, 534 requiredAnnotation); 535 } 536 537 @Override 538 public void removeJavascriptInterface(String interfaceName) { 539 mAwContents.getContentViewCore().removeJavascriptInterface(interfaceName); 540 } 541 542 @Override 543 public WebSettings getSettings() { 544 if (mWebSettings == null) { 545 mWebSettings = new ContentSettingsAdapter( 546 mAwContents.getContentViewCore().getContentSettings(), 547 mAwContents.getSettings()); 548 } 549 return mWebSettings; 550 } 551 552 @Override 553 public void setMapTrackballToArrowKeys(boolean setMap) { 554 // This is a deprecated API: intentional no-op. 555 } 556 557 @Override 558 public void flingScroll(int vx, int vy) { 559 mAwContents.getContentViewCore().flingScroll(vx, vy); 560 } 561 562 @Override 563 public View getZoomControls() { 564 // This was deprecated in 2009 and hidden in JB MR1, so just provide the minimum needed 565 // to stop very out-dated applications from crashing. 566 Log.w(TAG, "WebView doesn't support getZoomControls"); 567 return mAwContents.getContentViewCore().getContentSettings().supportZoom() ? 568 new View(mWebView.getContext()) : null; 569 } 570 571 @Override 572 public boolean canZoomIn() { 573 return mAwContents.getContentViewCore().canZoomIn(); 574 } 575 576 @Override 577 public boolean canZoomOut() { 578 return mAwContents.getContentViewCore().canZoomOut(); 579 } 580 581 @Override 582 public boolean zoomIn() { 583 return mAwContents.getContentViewCore().zoomIn(); 584 } 585 586 @Override 587 public boolean zoomOut() { 588 return mAwContents.getContentViewCore().zoomOut(); 589 } 590 591 @Override 592 public void dumpViewHierarchyWithProperties(BufferedWriter out, int level) { 593 UnimplementedWebViewApi.invoke(); 594 } 595 596 @Override 597 public View findHierarchyView(String className, int hashCode) { 598 UnimplementedWebViewApi.invoke(); 599 return null; 600 } 601 602 // WebViewProvider glue methods --------------------------------------------------------------- 603 604 @Override 605 public WebViewProvider.ViewDelegate getViewDelegate() { 606 return this; 607 } 608 609 @Override 610 public WebViewProvider.ScrollDelegate getScrollDelegate() { 611 return this; 612 } 613 614 615 // WebViewProvider.ViewDelegate implementation ------------------------------------------------ 616 617 @Override 618 public boolean shouldDelayChildPressedState() { 619 UnimplementedWebViewApi.invoke(); 620 return false; 621 } 622 623 @Override 624 public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { 625 mAwContents.getContentViewCore().onInitializeAccessibilityNodeInfo(info); 626 } 627 628 @Override 629 public void onInitializeAccessibilityEvent(AccessibilityEvent event) { 630 mAwContents.getContentViewCore().onInitializeAccessibilityEvent(event); 631 } 632 633 // TODO: Update WebView to mimic ContentView implementation for the 634 // real View#performAccessibilityAction(int, Bundle). This method has different behavior. 635 // See ContentViewCore#performAccessibilityAction(int, Bundle) for more details. 636 @Override 637 public boolean performAccessibilityAction(int action, Bundle arguments) { 638 return mAwContents.getContentViewCore().performAccessibilityAction(action, arguments); 639 } 640 641 @Override 642 public void setOverScrollMode(int mode) { 643 UnimplementedWebViewApi.invoke(); 644 } 645 646 @Override 647 public void setScrollBarStyle(int style) { 648 UnimplementedWebViewApi.invoke(); 649 } 650 651 @Override 652 public void onDrawVerticalScrollBar(Canvas canvas, Drawable scrollBar, 653 int l, int t, int r, int b) { 654 UnimplementedWebViewApi.invoke(); 655 } 656 657 @Override 658 public void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) { 659 UnimplementedWebViewApi.invoke(); 660 } 661 662 @Override 663 public void onWindowVisibilityChanged(int visibility) { 664 mAwContents.onWindowVisibilityChanged(visibility); 665 } 666 667 @Override 668 public void onDraw(Canvas canvas) { 669 if (canvas.isHardwareAccelerated() && mAwContents.onPrepareDrawGL(canvas)) { 670 if (mGLfunctor == null) { 671 mGLfunctor = new DrawGLFunctor(mAwContents.getAwDrawGLViewContext()); 672 } 673 mGLfunctor.requestDrawGL((HardwareCanvas) canvas, mWebView.getViewRootImpl()); 674 } else { 675 mAwContents.onDraw(canvas); 676 } 677 } 678 679 @Override 680 public void setLayoutParams(ViewGroup.LayoutParams layoutParams) { 681 // TODO: This is the minimum implementation for HTMLViewer 682 // bringup. Likely will need to go up to ContentViewCore for 683 // a complete implementation. 684 mWebViewPrivate.super_setLayoutParams(layoutParams); 685 } 686 687 @Override 688 public boolean performLongClick() { 689 return mWebViewPrivate.super_performLongClick(); 690 } 691 692 @Override 693 public void onConfigurationChanged(Configuration newConfig) { 694 mAwContents.onConfigurationChanged(newConfig); 695 } 696 697 @Override 698 public InputConnection onCreateInputConnection(EditorInfo outAttrs) { 699 return mAwContents.getContentViewCore().onCreateInputConnection(outAttrs); 700 } 701 702 @Override 703 public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) { 704 UnimplementedWebViewApi.invoke(); 705 return false; 706 } 707 708 @Override 709 public boolean onKeyDown(int keyCode, KeyEvent event) { 710 UnimplementedWebViewApi.invoke(); 711 return false; 712 } 713 714 @Override 715 public boolean onKeyUp(int keyCode, KeyEvent event) { 716 return mAwContents.getContentViewCore().onKeyUp(keyCode, event); 717 } 718 719 @Override 720 public void onAttachedToWindow() { 721 mAwContents.onAttachedToWindow(); 722 } 723 724 @Override 725 public void onDetachedFromWindow() { 726 mAwContents.onDetachedFromWindow(); 727 if (mGLfunctor != null) { 728 mGLfunctor.detach(); 729 } 730 } 731 732 @Override 733 public void onVisibilityChanged(View changedView, int visibility) { 734 // The AwContents will find out the container view visibility before the first draw so we 735 // can safely ignore onVisibilityChanged callbacks that happen before init(). 736 if (mAwContents != null) { 737 mAwContents.onVisibilityChanged(changedView, visibility); 738 } 739 } 740 741 @Override 742 public void onWindowFocusChanged(boolean hasWindowFocus) { 743 mAwContents.onWindowFocusChanged(hasWindowFocus); 744 } 745 746 @Override 747 public void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { 748 mAwContents.onFocusChanged(focused, direction, previouslyFocusedRect); 749 } 750 751 @Override 752 public boolean setFrame(int left, int top, int right, int bottom) { 753 // TODO(joth): This is the minimum implementation for initial 754 // bringup. Likely will need to go up to AwContents for a complete 755 // implementation, e.g. setting the compositor visible region (to 756 // avoid painting tiles that are offscreen due to the view's position). 757 return mWebViewPrivate.super_setFrame(left, top, right, bottom); 758 } 759 760 @Override 761 public void onSizeChanged(int w, int h, int ow, int oh) { 762 mAwContents.onSizeChanged(w, h, ow, oh); 763 } 764 765 @Override 766 public void onScrollChanged(int l, int t, int oldl, int oldt) { 767 } 768 769 @Override 770 public boolean dispatchKeyEvent(KeyEvent event) { 771 return mAwContents.getContentViewCore().dispatchKeyEvent(event); 772 } 773 774 @Override 775 public boolean onTouchEvent(MotionEvent ev) { 776 return mAwContents.onTouchEvent(ev); 777 } 778 779 @Override 780 public boolean onHoverEvent(MotionEvent event) { 781 return mAwContents.onHoverEvent(event); 782 } 783 784 @Override 785 public boolean onGenericMotionEvent(MotionEvent event) { 786 return mAwContents.onGenericMotionEvent(event); 787 } 788 789 @Override 790 public boolean onTrackballEvent(MotionEvent ev) { 791 // Trackball event not handled, which eventually gets converted to DPAD keyevents 792 return false; 793 } 794 795 @Override 796 public boolean requestFocus(int direction, Rect previouslyFocusedRect) { 797 mAwContents.requestFocus(); 798 return mWebViewPrivate.super_requestFocus(direction, previouslyFocusedRect); 799 } 800 801 @Override 802 public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { 803 mAwContents.onMeasure(widthMeasureSpec, heightMeasureSpec); 804 } 805 806 @Override 807 public boolean requestChildRectangleOnScreen(View child, Rect rect, boolean immediate) { 808 UnimplementedWebViewApi.invoke(); 809 return false; 810 } 811 812 @Override 813 public void setBackgroundColor(int color) { 814 UnimplementedWebViewApi.invoke(); 815 } 816 817 @Override 818 public void setLayerType(int layerType, Paint paint) { 819 UnimplementedWebViewApi.invoke(); 820 } 821 822 @Override 823 public void preDispatchDraw(Canvas canvas) { 824 // TODO(leandrogracia): remove this method from WebViewProvider if we think 825 // we won't need it again. 826 } 827 828 // WebViewProvider.ScrollDelegate implementation ---------------------------------------------- 829 830 @Override 831 public int computeHorizontalScrollRange() { 832 return mAwContents.getContentViewCore().computeHorizontalScrollRange(); 833 } 834 835 @Override 836 public int computeHorizontalScrollOffset() { 837 return mAwContents.getContentViewCore().computeHorizontalScrollOffset(); 838 } 839 840 @Override 841 public int computeVerticalScrollRange() { 842 return mAwContents.getContentViewCore().computeVerticalScrollRange(); 843 } 844 845 @Override 846 public int computeVerticalScrollOffset() { 847 return mAwContents.getContentViewCore().computeVerticalScrollOffset(); 848 } 849 850 @Override 851 public int computeVerticalScrollExtent() { 852 return mAwContents.getContentViewCore().computeVerticalScrollExtent(); 853 } 854 855 @Override 856 public void computeScroll() { 857 // BUG=http://b/6029133 858 UnimplementedWebViewApi.invoke(); 859 } 860 861 // AwContents.InternalAccessDelegate implementation -------------------------------------- 862 private class InternalAccessAdapter implements AwContents.InternalAccessDelegate { 863 @Override 864 public boolean drawChild(Canvas arg0, View arg1, long arg2) { 865 UnimplementedWebViewApi.invoke(); 866 return false; 867 } 868 869 @Override 870 public boolean super_onKeyUp(int arg0, KeyEvent arg1) { 871 UnimplementedWebViewApi.invoke(); 872 return false; 873 } 874 875 @Override 876 public boolean super_dispatchKeyEventPreIme(KeyEvent arg0) { 877 UnimplementedWebViewApi.invoke(); 878 return false; 879 } 880 881 @Override 882 public boolean super_dispatchKeyEvent(KeyEvent event) { 883 return mWebViewPrivate.super_dispatchKeyEvent(event); 884 } 885 886 @Override 887 public boolean super_onGenericMotionEvent(MotionEvent arg0) { 888 UnimplementedWebViewApi.invoke(); 889 return false; 890 } 891 892 @Override 893 public void super_onConfigurationChanged(Configuration arg0) { 894 UnimplementedWebViewApi.invoke(); 895 } 896 897 @Override 898 public void onScrollChanged(int l, int t, int oldl, int oldt) { 899 mWebViewPrivate.setScrollXRaw(l); 900 mWebViewPrivate.setScrollYRaw(t); 901 mWebViewPrivate.onScrollChanged(l, t, oldl, oldt); 902 } 903 904 @Override 905 public boolean awakenScrollBars() { 906 mWebViewPrivate.awakenScrollBars(0); 907 // TODO: modify the WebView.PrivateAccess to provide a return value. 908 return true; 909 } 910 911 @Override 912 public boolean super_awakenScrollBars(int arg0, boolean arg1) { 913 // TODO: need method on WebView.PrivateAccess? 914 UnimplementedWebViewApi.invoke(); 915 return false; 916 } 917 918 @Override 919 public void setMeasuredDimension(int measuredWidth, int measuredHeight) { 920 mWebViewPrivate.setMeasuredDimension(measuredWidth, measuredHeight); 921 } 922 } 923} 924