| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package com.android.webview.chromium; | 5 package com.android.webview.chromium; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 private AwContents mAwContents; | 95 private AwContents mAwContents; |
| 96 // Non-null if this webview is using the GL accelerated draw path. | 96 // Non-null if this webview is using the GL accelerated draw path. |
| 97 private DrawGLFunctor mGLfunctor; | 97 private DrawGLFunctor mGLfunctor; |
| 98 | 98 |
| 99 private final WebView.HitTestResult mHitTestResult; | 99 private final WebView.HitTestResult mHitTestResult; |
| 100 | 100 |
| 101 private final int mAppTargetSdkVersion; | 101 private final int mAppTargetSdkVersion; |
| 102 | 102 |
| 103 private WebViewChromiumFactoryProvider mFactory; | 103 private WebViewChromiumFactoryProvider mFactory; |
| 104 | 104 |
| 105 private final boolean mShouldDisableThreadChecking; |
| 106 |
| 105 private static boolean sRecordWholeDocumentEnabledByApi = false; | 107 private static boolean sRecordWholeDocumentEnabledByApi = false; |
| 106 static void enableSlowWholeDocumentDraw() { | 108 static void enableSlowWholeDocumentDraw() { |
| 107 sRecordWholeDocumentEnabledByApi = true; | 109 sRecordWholeDocumentEnabledByApi = true; |
| 108 } | 110 } |
| 109 | 111 |
| 110 // This does not touch any global / non-threadsafe state, but note that | 112 // This does not touch any global / non-threadsafe state, but note that |
| 111 // init is ofter called right after and is NOT threadsafe. | 113 // init is ofter called right after and is NOT threadsafe. |
| 112 public WebViewChromium(WebViewChromiumFactoryProvider factory, WebView webVi
ew, | 114 public WebViewChromium(WebViewChromiumFactoryProvider factory, WebView webVi
ew, |
| 113 WebView.PrivateAccess webViewPrivate) { | 115 WebView.PrivateAccess webViewPrivate, boolean shouldDisableThreadChe
cking) { |
| 114 mWebView = webView; | 116 mWebView = webView; |
| 115 mWebViewPrivate = webViewPrivate; | 117 mWebViewPrivate = webViewPrivate; |
| 116 mHitTestResult = new WebView.HitTestResult(); | 118 mHitTestResult = new WebView.HitTestResult(); |
| 117 mContext = ResourcesContextWrapperFactory.get(mWebView.getContext()); | 119 mContext = ResourcesContextWrapperFactory.get(mWebView.getContext()); |
| 118 mAppTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion; | 120 mAppTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion; |
| 119 mFactory = factory; | 121 mFactory = factory; |
| 122 mShouldDisableThreadChecking = shouldDisableThreadChecking; |
| 120 factory.getWebViewDelegate().addWebViewAssetPath(mWebView.getContext()); | 123 factory.getWebViewDelegate().addWebViewAssetPath(mWebView.getContext()); |
| 121 } | 124 } |
| 122 | 125 |
| 123 static void completeWindowCreation(WebView parent, WebView child) { | 126 static void completeWindowCreation(WebView parent, WebView child) { |
| 124 AwContents parentContents = ((WebViewChromium) parent.getWebViewProvider
()).mAwContents; | 127 AwContents parentContents = ((WebViewChromium) parent.getWebViewProvider
()).mAwContents; |
| 125 AwContents childContents = | 128 AwContents childContents = |
| 126 child == null ? null : ((WebViewChromium) child.getWebViewProvid
er()).mAwContents; | 129 child == null ? null : ((WebViewChromium) child.getWebViewProvid
er()).mAwContents; |
| 127 parentContents.supplyContentsForPopup(childContents); | 130 parentContents.supplyContentsForPopup(childContents); |
| 128 } | 131 } |
| 129 | 132 |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 @Override | 536 @Override |
| 534 public void run() { | 537 public void run() { |
| 535 mAwContents.loadDataWithBaseURL(baseUrl, data, mimeType, enc
oding, historyUrl); | 538 mAwContents.loadDataWithBaseURL(baseUrl, data, mimeType, enc
oding, historyUrl); |
| 536 } | 539 } |
| 537 }); | 540 }); |
| 538 return; | 541 return; |
| 539 } | 542 } |
| 540 mAwContents.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, histo
ryUrl); | 543 mAwContents.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, histo
ryUrl); |
| 541 } | 544 } |
| 542 | 545 |
| 543 public void evaluateJavaScript(String script, ValueCallback<String> resultCa
llback) { | 546 @Override |
| 544 checkThread(); | 547 public void evaluateJavaScript( |
| 545 mAwContents.evaluateJavaScript(script, resultCallback); | 548 final String script, final ValueCallback<String> resultCallback) { |
| 549 if (mShouldDisableThreadChecking && checkNeedsPost()) { |
| 550 // This is a workaround for https://crbug.com/622151. |
| 551 mFactory.addTask(new Runnable() { |
| 552 @Override |
| 553 public void run() { |
| 554 mAwContents.evaluateJavaScript(script, resultCallback); |
| 555 } |
| 556 }); |
| 557 } else { |
| 558 checkThread(); |
| 559 mAwContents.evaluateJavaScript(script, resultCallback); |
| 560 } |
| 546 } | 561 } |
| 547 | 562 |
| 548 @Override | 563 @Override |
| 549 public void saveWebArchive(String filename) { | 564 public void saveWebArchive(String filename) { |
| 550 saveWebArchive(filename, false, null); | 565 saveWebArchive(filename, false, null); |
| 551 } | 566 } |
| 552 | 567 |
| 553 @Override | 568 @Override |
| 554 public void saveWebArchive(final String basename, final boolean autoname, | 569 public void saveWebArchive(final String basename, final boolean autoname, |
| 555 final ValueCallback<String> callback) { | 570 final ValueCallback<String> callback) { |
| (...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2011 return originalHandler; | 2026 return originalHandler; |
| 2012 } | 2027 } |
| 2013 | 2028 |
| 2014 // Overrides method added to WebViewProvider.ViewDelegate interface | 2029 // Overrides method added to WebViewProvider.ViewDelegate interface |
| 2015 // (not called in M and below) | 2030 // (not called in M and below) |
| 2016 public View findFocus(View originalFocusedView) { | 2031 public View findFocus(View originalFocusedView) { |
| 2017 return originalFocusedView; | 2032 return originalFocusedView; |
| 2018 } | 2033 } |
| 2019 | 2034 |
| 2020 // Remove from superclass | 2035 // Remove from superclass |
| 2036 @Override |
| 2021 public void preDispatchDraw(Canvas canvas) { | 2037 public void preDispatchDraw(Canvas canvas) { |
| 2022 // TODO(leandrogracia): remove this method from WebViewProvider if we th
ink | 2038 // TODO(leandrogracia): remove this method from WebViewProvider if we th
ink |
| 2023 // we won't need it again. | 2039 // we won't need it again. |
| 2024 } | 2040 } |
| 2025 | 2041 |
| 2042 @Override |
| 2026 public void onStartTemporaryDetach() { | 2043 public void onStartTemporaryDetach() { |
| 2027 mAwContents.onStartTemporaryDetach(); | 2044 mAwContents.onStartTemporaryDetach(); |
| 2028 } | 2045 } |
| 2029 | 2046 |
| 2047 @Override |
| 2030 public void onFinishTemporaryDetach() { | 2048 public void onFinishTemporaryDetach() { |
| 2031 mAwContents.onFinishTemporaryDetach(); | 2049 mAwContents.onFinishTemporaryDetach(); |
| 2032 } | 2050 } |
| 2033 | 2051 |
| 2034 // WebViewProvider.ScrollDelegate implementation ---------------------------
------------------- | 2052 // WebViewProvider.ScrollDelegate implementation ---------------------------
------------------- |
| 2035 | 2053 |
| 2036 @Override | 2054 @Override |
| 2037 public int computeHorizontalScrollRange() { | 2055 public int computeHorizontalScrollRange() { |
| 2038 mFactory.startYourEngines(false); | 2056 mFactory.startYourEngines(false); |
| 2039 if (checkNeedsPost()) { | 2057 if (checkNeedsPost()) { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2227 mAwContents.extractSmartClipData(x, y, width, height); | 2245 mAwContents.extractSmartClipData(x, y, width, height); |
| 2228 } | 2246 } |
| 2229 | 2247 |
| 2230 // Implements SmartClipProvider | 2248 // Implements SmartClipProvider |
| 2231 @Override | 2249 @Override |
| 2232 public void setSmartClipResultHandler(final Handler resultHandler) { | 2250 public void setSmartClipResultHandler(final Handler resultHandler) { |
| 2233 checkThread(); | 2251 checkThread(); |
| 2234 mAwContents.setSmartClipResultHandler(resultHandler); | 2252 mAwContents.setSmartClipResultHandler(resultHandler); |
| 2235 } | 2253 } |
| 2236 } | 2254 } |
| OLD | NEW |