| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 org.chromium.android_webview; | 5 package org.chromium.android_webview; |
| 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.app.Activity; | 9 import android.app.Activity; |
| 10 import android.content.ComponentCallbacks2; | 10 import android.content.ComponentCallbacks2; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 import android.net.http.SslCertificate; | 23 import android.net.http.SslCertificate; |
| 24 import android.os.AsyncTask; | 24 import android.os.AsyncTask; |
| 25 import android.os.Build; | 25 import android.os.Build; |
| 26 import android.os.Bundle; | 26 import android.os.Bundle; |
| 27 import android.os.Handler; | 27 import android.os.Handler; |
| 28 import android.os.Message; | 28 import android.os.Message; |
| 29 import android.os.SystemClock; | 29 import android.os.SystemClock; |
| 30 import android.text.TextUtils; | 30 import android.text.TextUtils; |
| 31 import android.util.Base64; | 31 import android.util.Base64; |
| 32 import android.util.Pair; | 32 import android.util.Pair; |
| 33 import android.util.SparseArray; |
| 33 import android.view.DragEvent; | 34 import android.view.DragEvent; |
| 34 import android.view.KeyEvent; | 35 import android.view.KeyEvent; |
| 35 import android.view.MotionEvent; | 36 import android.view.MotionEvent; |
| 36 import android.view.View; | 37 import android.view.View; |
| 37 import android.view.ViewGroup; | 38 import android.view.ViewGroup; |
| 38 import android.view.ViewStructure; | 39 import android.view.ViewStructure; |
| 39 import android.view.accessibility.AccessibilityEvent; | 40 import android.view.accessibility.AccessibilityEvent; |
| 40 import android.view.accessibility.AccessibilityNodeInfo; | 41 import android.view.accessibility.AccessibilityNodeInfo; |
| 41 import android.view.accessibility.AccessibilityNodeProvider; | 42 import android.view.accessibility.AccessibilityNodeProvider; |
| 42 import android.view.animation.AnimationUtils; | 43 import android.view.animation.AnimationUtils; |
| 43 import android.view.inputmethod.EditorInfo; | 44 import android.view.inputmethod.EditorInfo; |
| 44 import android.view.inputmethod.InputConnection; | 45 import android.view.inputmethod.InputConnection; |
| 45 import android.webkit.JavascriptInterface; | 46 import android.webkit.JavascriptInterface; |
| 46 import android.webkit.ValueCallback; | 47 import android.webkit.ValueCallback; |
| 47 | 48 |
| 48 import org.chromium.android_webview.permission.AwGeolocationCallback; | 49 import org.chromium.android_webview.permission.AwGeolocationCallback; |
| 49 import org.chromium.android_webview.permission.AwPermissionRequest; | 50 import org.chromium.android_webview.permission.AwPermissionRequest; |
| 50 import org.chromium.android_webview.renderer_priority.RendererPriority; | 51 import org.chromium.android_webview.renderer_priority.RendererPriority; |
| 51 import org.chromium.base.LocaleUtils; | 52 import org.chromium.base.LocaleUtils; |
| 52 import org.chromium.base.Log; | 53 import org.chromium.base.Log; |
| 53 import org.chromium.base.ObserverList; | 54 import org.chromium.base.ObserverList; |
| 54 import org.chromium.base.ThreadUtils; | 55 import org.chromium.base.ThreadUtils; |
| 55 import org.chromium.base.TraceEvent; | 56 import org.chromium.base.TraceEvent; |
| 56 import org.chromium.base.VisibleForTesting; | 57 import org.chromium.base.VisibleForTesting; |
| 57 import org.chromium.base.annotations.CalledByNative; | 58 import org.chromium.base.annotations.CalledByNative; |
| 58 import org.chromium.base.annotations.JNINamespace; | 59 import org.chromium.base.annotations.JNINamespace; |
| 59 import org.chromium.base.annotations.SuppressFBWarnings; | 60 import org.chromium.base.annotations.SuppressFBWarnings; |
| 61 import org.chromium.components.autofill.AutofillProvider; |
| 60 import org.chromium.components.navigation_interception.InterceptNavigationDelega
te; | 62 import org.chromium.components.navigation_interception.InterceptNavigationDelega
te; |
| 61 import org.chromium.components.navigation_interception.NavigationParams; | 63 import org.chromium.components.navigation_interception.NavigationParams; |
| 62 import org.chromium.content.browser.AppWebMessagePort; | 64 import org.chromium.content.browser.AppWebMessagePort; |
| 63 import org.chromium.content.browser.ContentViewCore; | 65 import org.chromium.content.browser.ContentViewCore; |
| 64 import org.chromium.content.browser.ContentViewStatics; | 66 import org.chromium.content.browser.ContentViewStatics; |
| 65 import org.chromium.content.browser.SmartClipProvider; | 67 import org.chromium.content.browser.SmartClipProvider; |
| 66 import org.chromium.content_public.browser.GestureStateListener; | 68 import org.chromium.content_public.browser.GestureStateListener; |
| 67 import org.chromium.content_public.browser.JavaScriptCallback; | 69 import org.chromium.content_public.browser.JavaScriptCallback; |
| 68 import org.chromium.content_public.browser.LoadUrlParams; | 70 import org.chromium.content_public.browser.LoadUrlParams; |
| 69 import org.chromium.content_public.browser.MessagePort; | 71 import org.chromium.content_public.browser.MessagePort; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 */ | 240 */ |
| 239 public static class DependencyFactory { | 241 public static class DependencyFactory { |
| 240 public AwLayoutSizer createLayoutSizer() { | 242 public AwLayoutSizer createLayoutSizer() { |
| 241 return new AwLayoutSizer(); | 243 return new AwLayoutSizer(); |
| 242 } | 244 } |
| 243 | 245 |
| 244 public AwScrollOffsetManager createScrollOffsetManager( | 246 public AwScrollOffsetManager createScrollOffsetManager( |
| 245 AwScrollOffsetManager.Delegate delegate) { | 247 AwScrollOffsetManager.Delegate delegate) { |
| 246 return new AwScrollOffsetManager(delegate); | 248 return new AwScrollOffsetManager(delegate); |
| 247 } | 249 } |
| 250 |
| 251 public AutofillProvider createAutofillProvider(Context context, ViewGrou
p containerView) { |
| 252 return null; |
| 253 } |
| 248 } | 254 } |
| 249 | 255 |
| 250 /** | 256 /** |
| 251 * Visual state callback, see {@link #insertVisualStateCallback} for details
. | 257 * Visual state callback, see {@link #insertVisualStateCallback} for details
. |
| 252 * | 258 * |
| 253 */ | 259 */ |
| 254 @VisibleForTesting | 260 @VisibleForTesting |
| 255 public abstract static class VisualStateCallback { | 261 public abstract static class VisualStateCallback { |
| 256 /** | 262 /** |
| 257 * @param requestId the id passed to {@link AwContents#insertVisualState
Callback} | 263 * @param requestId the id passed to {@link AwContents#insertVisualState
Callback} |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 private Handler mHandler; | 361 private Handler mHandler; |
| 356 | 362 |
| 357 // True when this AwContents has been destroyed. | 363 // True when this AwContents has been destroyed. |
| 358 // Do not use directly, call isDestroyed() instead. | 364 // Do not use directly, call isDestroyed() instead. |
| 359 private boolean mIsDestroyed; | 365 private boolean mIsDestroyed; |
| 360 | 366 |
| 361 // True if this AwContents is in no operation state. | 367 // True if this AwContents is in no operation state. |
| 362 // Do not use directly, call isNoOperation() instead. | 368 // Do not use directly, call isNoOperation() instead. |
| 363 private boolean mIsNoOperation; | 369 private boolean mIsNoOperation; |
| 364 | 370 |
| 371 private AutofillProvider mAutofillProvider; |
| 372 |
| 365 private static String sCurrentLocales = ""; | 373 private static String sCurrentLocales = ""; |
| 366 | 374 |
| 367 private Paint mPaintForNWorkaround; | 375 private Paint mPaintForNWorkaround; |
| 368 | 376 |
| 369 private static final class AwContentsDestroyRunnable implements Runnable { | 377 private static final class AwContentsDestroyRunnable implements Runnable { |
| 370 private final long mNativeAwContents; | 378 private final long mNativeAwContents; |
| 371 // Hold onto a reference to the window (via its wrapper), so that it is
not destroyed | 379 // Hold onto a reference to the window (via its wrapper), so that it is
not destroyed |
| 372 // until we are done here. | 380 // until we are done here. |
| 373 private final WindowAndroidWrapper mWindowAndroid; | 381 private final WindowAndroidWrapper mWindowAndroid; |
| 374 | 382 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 mBrowserContext = browserContext; | 752 mBrowserContext = browserContext; |
| 745 | 753 |
| 746 // setWillNotDraw(false) is required since WebView draws it's own conten
ts using it's | 754 // setWillNotDraw(false) is required since WebView draws it's own conten
ts using it's |
| 747 // container view. If this is ever not the case we should remove this, a
s it removes | 755 // container view. If this is ever not the case we should remove this, a
s it removes |
| 748 // Android's gatherTransparentRegion optimization for the view. | 756 // Android's gatherTransparentRegion optimization for the view. |
| 749 mContainerView = containerView; | 757 mContainerView = containerView; |
| 750 mContainerView.setWillNotDraw(false); | 758 mContainerView.setWillNotDraw(false); |
| 751 | 759 |
| 752 mHandler = new Handler(); | 760 mHandler = new Handler(); |
| 753 mContext = context; | 761 mContext = context; |
| 762 mAutofillProvider = dependencyFactory.createAutofillProvider(context, mC
ontainerView); |
| 754 mAppTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion; | 763 mAppTargetSdkVersion = mContext.getApplicationInfo().targetSdkVersion; |
| 755 mInternalAccessAdapter = internalAccessAdapter; | 764 mInternalAccessAdapter = internalAccessAdapter; |
| 756 mNativeDrawGLFunctorFactory = nativeDrawGLFunctorFactory; | 765 mNativeDrawGLFunctorFactory = nativeDrawGLFunctorFactory; |
| 757 mInitialFunctor = new AwGLFunctor(mNativeDrawGLFunctorFactory, mContaine
rView); | 766 mInitialFunctor = new AwGLFunctor(mNativeDrawGLFunctorFactory, mContaine
rView); |
| 758 mCurrentFunctor = mInitialFunctor; | 767 mCurrentFunctor = mInitialFunctor; |
| 759 mContentsClient = contentsClient; | 768 mContentsClient = contentsClient; |
| 760 mContentsClient.getCallbackHelper().setCancelCallbackPoller( | 769 mContentsClient.getCallbackHelper().setCancelCallbackPoller( |
| 761 new AwContentsClientCallbackHelper.CancelCallbackPoller() { | 770 new AwContentsClientCallbackHelper.CancelCallbackPoller() { |
| 762 @Override | 771 @Override |
| 763 public boolean cancelAllCallbacks() { | 772 public boolean cancelAllCallbacks() { |
| (...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2332 if (!mWebContentsObserver.didEverCommitNavigation()) { | 2341 if (!mWebContentsObserver.didEverCommitNavigation()) { |
| 2333 // TODO(sgurun) write a test case for this condition crbug/605251 | 2342 // TODO(sgurun) write a test case for this condition crbug/605251 |
| 2334 structure.setChildCount(0); | 2343 structure.setChildCount(0); |
| 2335 return; | 2344 return; |
| 2336 } | 2345 } |
| 2337 // for webview, the platform already calculates the scroll (as it is a v
iew) in | 2346 // for webview, the platform already calculates the scroll (as it is a v
iew) in |
| 2338 // ViewStructure tree. Do not offset for it in the snapshop x,y position
calculations. | 2347 // ViewStructure tree. Do not offset for it in the snapshop x,y position
calculations. |
| 2339 mContentViewCore.onProvideVirtualStructure(structure, true); | 2348 mContentViewCore.onProvideVirtualStructure(structure, true); |
| 2340 } | 2349 } |
| 2341 | 2350 |
| 2351 public void onProvideAutoFillVirtualStructure(ViewStructure structure, int f
lags) { |
| 2352 mAutofillProvider.onProvideAutoFillVirtualStructure(structure, flags); |
| 2353 } |
| 2354 |
| 2355 public void autofill(final SparseArray<String> values) { |
| 2356 mAutofillProvider.autofill(values); |
| 2357 } |
| 2358 |
| 2342 public boolean isSelectActionModeAllowed(int actionModeItem) { | 2359 public boolean isSelectActionModeAllowed(int actionModeItem) { |
| 2343 return (mSettings.getDisabledActionModeMenuItems() & actionModeItem) !=
actionModeItem; | 2360 return (mSettings.getDisabledActionModeMenuItems() & actionModeItem) !=
actionModeItem; |
| 2344 } | 2361 } |
| 2345 | 2362 |
| 2346 //--------------------------------------------------------------------------
------------------ | 2363 //--------------------------------------------------------------------------
------------------ |
| 2347 // View and ViewGroup method implementations | 2364 // View and ViewGroup method implementations |
| 2348 //--------------------------------------------------------------------------
------------------ | 2365 //--------------------------------------------------------------------------
------------------ |
| 2349 /** | 2366 /** |
| 2350 * Calls android.view.View#startActivityForResult. A RuntimeException will | 2367 * Calls android.view.View#startActivityForResult. A RuntimeException will |
| 2351 * be thrown by Android framework if startActivityForResult is called with | 2368 * be thrown by Android framework if startActivityForResult is called with |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2885 setPageScaleFactorAndLimits(pageScaleFactor, minPageScaleFactor, maxPage
ScaleFactor); | 2902 setPageScaleFactorAndLimits(pageScaleFactor, minPageScaleFactor, maxPage
ScaleFactor); |
| 2886 } | 2903 } |
| 2887 | 2904 |
| 2888 @CalledByNative | 2905 @CalledByNative |
| 2889 private void setAwAutofillClient(AwAutofillClient client) { | 2906 private void setAwAutofillClient(AwAutofillClient client) { |
| 2890 mAwAutofillClient = client; | 2907 mAwAutofillClient = client; |
| 2891 client.init(mContentViewCore); | 2908 client.init(mContentViewCore); |
| 2892 } | 2909 } |
| 2893 | 2910 |
| 2894 @CalledByNative | 2911 @CalledByNative |
| 2912 private long getNativeAutofillAndroid() { |
| 2913 if (mAutofillProvider == null) return 0; |
| 2914 return mAutofillProvider.getNativeAutofillProviderAndroid(); |
| 2915 } |
| 2916 |
| 2917 @CalledByNative |
| 2895 private void didOverscroll(int deltaX, int deltaY, float velocityX, float ve
locityY) { | 2918 private void didOverscroll(int deltaX, int deltaY, float velocityX, float ve
locityY) { |
| 2896 mScrollOffsetManager.overScrollBy(deltaX, deltaY); | 2919 mScrollOffsetManager.overScrollBy(deltaX, deltaY); |
| 2897 | 2920 |
| 2898 if (mOverScrollGlow == null) return; | 2921 if (mOverScrollGlow == null) return; |
| 2899 | 2922 |
| 2900 mOverScrollGlow.setOverScrollDeltas(deltaX, deltaY); | 2923 mOverScrollGlow.setOverScrollDeltas(deltaX, deltaY); |
| 2901 final int oldX = mContainerView.getScrollX(); | 2924 final int oldX = mContainerView.getScrollX(); |
| 2902 final int oldY = mContainerView.getScrollY(); | 2925 final int oldY = mContainerView.getScrollY(); |
| 2903 final int x = oldX + deltaX; | 2926 final int x = oldX + deltaX; |
| 2904 final int y = oldY + deltaY; | 2927 final int y = oldY + deltaY; |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3483 | 3506 |
| 3484 private native void nativePreauthorizePermission(long nativeAwContents, Stri
ng origin, | 3507 private native void nativePreauthorizePermission(long nativeAwContents, Stri
ng origin, |
| 3485 long resources); | 3508 long resources); |
| 3486 | 3509 |
| 3487 private native void nativePostMessageToFrame(long nativeAwContents, String f
rameId, | 3510 private native void nativePostMessageToFrame(long nativeAwContents, String f
rameId, |
| 3488 String message, String targetOrigin, MessagePort[] ports); | 3511 String message, String targetOrigin, MessagePort[] ports); |
| 3489 | 3512 |
| 3490 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC
ontents); | 3513 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC
ontents); |
| 3491 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw
Contents); | 3514 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw
Contents); |
| 3492 } | 3515 } |
| OLD | NEW |