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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 import android.webkit.WebViewProvider; | 50 import android.webkit.WebViewProvider; |
51 import android.widget.TextView; | 51 import android.widget.TextView; |
52 | 52 |
53 import org.chromium.android_webview.AwContents; | 53 import org.chromium.android_webview.AwContents; |
54 import org.chromium.android_webview.AwContentsStatics; | 54 import org.chromium.android_webview.AwContentsStatics; |
55 import org.chromium.android_webview.AwPrintDocumentAdapter; | 55 import org.chromium.android_webview.AwPrintDocumentAdapter; |
56 import org.chromium.android_webview.AwSettings; | 56 import org.chromium.android_webview.AwSettings; |
57 import org.chromium.android_webview.ResourcesContextWrapperFactory; | 57 import org.chromium.android_webview.ResourcesContextWrapperFactory; |
58 import org.chromium.base.ThreadUtils; | 58 import org.chromium.base.ThreadUtils; |
59 import org.chromium.base.annotations.SuppressFBWarnings; | 59 import org.chromium.base.annotations.SuppressFBWarnings; |
| 60 import org.chromium.components.autofill.AutofillProvider; |
60 import org.chromium.content.browser.SmartClipProvider; | 61 import org.chromium.content.browser.SmartClipProvider; |
61 import org.chromium.content_public.browser.NavigationHistory; | 62 import org.chromium.content_public.browser.NavigationHistory; |
62 | 63 |
63 import java.io.BufferedWriter; | 64 import java.io.BufferedWriter; |
64 import java.io.File; | 65 import java.io.File; |
65 import java.lang.reflect.Field; | 66 import java.lang.reflect.Field; |
66 import java.lang.reflect.Method; | 67 import java.lang.reflect.Method; |
67 import java.util.Map; | 68 import java.util.Map; |
68 import java.util.concurrent.Callable; | 69 import java.util.concurrent.Callable; |
69 | 70 |
(...skipping 24 matching lines...) Expand all Loading... |
94 private ContentSettingsAdapter mWebSettings; | 95 private ContentSettingsAdapter mWebSettings; |
95 // The WebView wrapper for ContentViewCore and required browser compontents. | 96 // The WebView wrapper for ContentViewCore and required browser compontents. |
96 AwContents mAwContents; | 97 AwContents mAwContents; |
97 // Non-null if this webview is using the GL accelerated draw path. | 98 // Non-null if this webview is using the GL accelerated draw path. |
98 private DrawGLFunctor mGLfunctor; | 99 private DrawGLFunctor mGLfunctor; |
99 | 100 |
100 private final WebView.HitTestResult mHitTestResult; | 101 private final WebView.HitTestResult mHitTestResult; |
101 | 102 |
102 private final int mAppTargetSdkVersion; | 103 private final int mAppTargetSdkVersion; |
103 | 104 |
104 private WebViewChromiumFactoryProvider mFactory; | 105 protected WebViewChromiumFactoryProvider mFactory; |
105 | 106 |
106 private final boolean mShouldDisableThreadChecking; | 107 private final boolean mShouldDisableThreadChecking; |
107 | 108 |
108 private static boolean sRecordWholeDocumentEnabledByApi; | 109 private static boolean sRecordWholeDocumentEnabledByApi; |
109 static void enableSlowWholeDocumentDraw() { | 110 static void enableSlowWholeDocumentDraw() { |
110 sRecordWholeDocumentEnabledByApi = true; | 111 sRecordWholeDocumentEnabledByApi = true; |
111 } | 112 } |
112 | 113 |
113 // This does not touch any global / non-threadsafe state, but note that | 114 // This does not touch any global / non-threadsafe state, but note that |
114 // init is ofter called right after and is NOT threadsafe. | 115 // init is ofter called right after and is NOT threadsafe. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 Log.w(TAG, "Failed to disable thread checking."); | 224 Log.w(TAG, "Failed to disable thread checking."); |
224 } | 225 } |
225 } | 226 } |
226 | 227 |
227 private void initForReal() { | 228 private void initForReal() { |
228 AwContentsStatics.setRecordFullDocument(sRecordWholeDocumentEnabledByApi | 229 AwContentsStatics.setRecordFullDocument(sRecordWholeDocumentEnabledByApi |
229 || mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP); | 230 || mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP); |
230 | 231 |
231 mAwContents = new AwContents(mFactory.getBrowserContextOnUiThread(), mWe
bView, mContext, | 232 mAwContents = new AwContents(mFactory.getBrowserContextOnUiThread(), mWe
bView, mContext, |
232 new InternalAccessAdapter(), new WebViewNativeDrawGLFunctorFacto
ry(), | 233 new InternalAccessAdapter(), new WebViewNativeDrawGLFunctorFacto
ry(), |
233 mContentsClientAdapter, mWebSettings.getAwSettings()); | 234 mContentsClientAdapter, mWebSettings.getAwSettings(), |
| 235 new AwContents.DependencyFactory() { |
| 236 @Override |
| 237 public AutofillProvider createAutofillProvider( |
| 238 Context context, ViewGroup containerView) { |
| 239 return mFactory.createAutofillProvider(context, mWebView
); |
| 240 } |
| 241 }); |
234 | 242 |
235 if (mAppTargetSdkVersion >= Build.VERSION_CODES.KITKAT) { | 243 if (mAppTargetSdkVersion >= Build.VERSION_CODES.KITKAT) { |
236 // On KK and above, favicons are automatically downloaded as the met
hod | 244 // On KK and above, favicons are automatically downloaded as the met
hod |
237 // old apps use to enable that behavior is deprecated. | 245 // old apps use to enable that behavior is deprecated. |
238 AwContents.setShouldDownloadFavicons(); | 246 AwContents.setShouldDownloadFavicons(); |
239 } | 247 } |
240 | 248 |
241 if (mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP) { | 249 if (mAppTargetSdkVersion < Build.VERSION_CODES.LOLLIPOP) { |
242 // Prior to Lollipop, JavaScript objects injected via addJavascriptI
nterface | 250 // Prior to Lollipop, JavaScript objects injected via addJavascriptI
nterface |
243 // were not inspectable. | 251 // were not inspectable. |
244 mAwContents.disableJavascriptInterfacesInspection(); | 252 mAwContents.disableJavascriptInterfacesInspection(); |
245 } | 253 } |
246 | 254 |
247 // TODO: This assumes AwContents ignores second Paint param. | 255 // TODO: This assumes AwContents ignores second Paint param. |
248 mAwContents.setLayerType(mWebView.getLayerType(), null); | 256 mAwContents.setLayerType(mWebView.getLayerType(), null); |
249 } | 257 } |
250 | 258 |
251 private RuntimeException createThreadException() { | 259 private RuntimeException createThreadException() { |
252 return new IllegalStateException( | 260 return new IllegalStateException( |
253 "Calling View methods on another thread than the UI thread."); | 261 "Calling View methods on another thread than the UI thread."); |
254 } | 262 } |
255 | 263 |
256 private boolean checkNeedsPost() { | 264 protected boolean checkNeedsPost() { |
257 boolean needsPost = !mFactory.hasStarted() || !ThreadUtils.runningOnUiTh
read(); | 265 boolean needsPost = !mFactory.hasStarted() || !ThreadUtils.runningOnUiTh
read(); |
258 if (!needsPost && mAwContents == null) { | 266 if (!needsPost && mAwContents == null) { |
259 throw new IllegalStateException("AwContents must be created if we ar
e not posting!"); | 267 throw new IllegalStateException("AwContents must be created if we ar
e not posting!"); |
260 } | 268 } |
261 return needsPost; | 269 return needsPost; |
262 } | 270 } |
263 | 271 |
264 // Intentionally not static, as no need to check thread on static methods | 272 // Intentionally not static, as no need to check thread on static methods |
265 private void checkThread() { | 273 private void checkThread() { |
266 if (!ThreadUtils.runningOnUiThread()) { | 274 if (!ThreadUtils.runningOnUiThread()) { |
(...skipping 2010 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2277 mAwContents.extractSmartClipData(x, y, width, height); | 2285 mAwContents.extractSmartClipData(x, y, width, height); |
2278 } | 2286 } |
2279 | 2287 |
2280 // Implements SmartClipProvider | 2288 // Implements SmartClipProvider |
2281 @Override | 2289 @Override |
2282 public void setSmartClipResultHandler(final Handler resultHandler) { | 2290 public void setSmartClipResultHandler(final Handler resultHandler) { |
2283 checkThread(); | 2291 checkThread(); |
2284 mAwContents.setSmartClipResultHandler(resultHandler); | 2292 mAwContents.setSmartClipResultHandler(resultHandler); |
2285 } | 2293 } |
2286 } | 2294 } |
OLD | NEW |