| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 import org.chromium.base.VisibleForTesting; | 52 import org.chromium.base.VisibleForTesting; |
| 53 import org.chromium.base.annotations.CalledByNative; | 53 import org.chromium.base.annotations.CalledByNative; |
| 54 import org.chromium.base.annotations.JNINamespace; | 54 import org.chromium.base.annotations.JNINamespace; |
| 55 import org.chromium.base.annotations.SuppressFBWarnings; | 55 import org.chromium.base.annotations.SuppressFBWarnings; |
| 56 import org.chromium.components.navigation_interception.InterceptNavigationDelega
te; | 56 import org.chromium.components.navigation_interception.InterceptNavigationDelega
te; |
| 57 import org.chromium.components.navigation_interception.NavigationParams; | 57 import org.chromium.components.navigation_interception.NavigationParams; |
| 58 import org.chromium.content.browser.ContentViewClient; | 58 import org.chromium.content.browser.ContentViewClient; |
| 59 import org.chromium.content.browser.ContentViewCore; | 59 import org.chromium.content.browser.ContentViewCore; |
| 60 import org.chromium.content.browser.ContentViewStatics; | 60 import org.chromium.content.browser.ContentViewStatics; |
| 61 import org.chromium.content.browser.SmartClipProvider; | 61 import org.chromium.content.browser.SmartClipProvider; |
| 62 import org.chromium.content.browser.input.PopupTouchHandleDrawable; |
| 62 import org.chromium.content.common.CleanupReference; | 63 import org.chromium.content.common.CleanupReference; |
| 63 import org.chromium.content_public.browser.GestureStateListener; | 64 import org.chromium.content_public.browser.GestureStateListener; |
| 64 import org.chromium.content_public.browser.JavaScriptCallback; | 65 import org.chromium.content_public.browser.JavaScriptCallback; |
| 65 import org.chromium.content_public.browser.LoadUrlParams; | 66 import org.chromium.content_public.browser.LoadUrlParams; |
| 66 import org.chromium.content_public.browser.NavigationController; | 67 import org.chromium.content_public.browser.NavigationController; |
| 67 import org.chromium.content_public.browser.NavigationHistory; | 68 import org.chromium.content_public.browser.NavigationHistory; |
| 68 import org.chromium.content_public.browser.WebContents; | 69 import org.chromium.content_public.browser.WebContents; |
| 69 import org.chromium.content_public.browser.navigation_controller.LoadURLType; | 70 import org.chromium.content_public.browser.navigation_controller.LoadURLType; |
| 70 import org.chromium.content_public.browser.navigation_controller.UserAgentOverri
deOption; | 71 import org.chromium.content_public.browser.navigation_controller.UserAgentOverri
deOption; |
| 71 import org.chromium.content_public.common.Referrer; | 72 import org.chromium.content_public.common.Referrer; |
| 72 import org.chromium.net.NetError; | 73 import org.chromium.net.NetError; |
| 73 import org.chromium.net.NetworkChangeNotifier; | 74 import org.chromium.net.NetworkChangeNotifier; |
| 74 import org.chromium.ui.base.ActivityWindowAndroid; | 75 import org.chromium.ui.base.ActivityWindowAndroid; |
| 75 import org.chromium.ui.base.PageTransition; | 76 import org.chromium.ui.base.PageTransition; |
| 76 import org.chromium.ui.base.ViewAndroidDelegate; | 77 import org.chromium.ui.base.ViewAndroidDelegate; |
| 77 import org.chromium.ui.base.WindowAndroid; | 78 import org.chromium.ui.base.WindowAndroid; |
| 78 import org.chromium.ui.gfx.DeviceDisplayInfo; | 79 import org.chromium.ui.gfx.DeviceDisplayInfo; |
| 79 | 80 |
| 80 import java.io.File; | 81 import java.io.File; |
| 81 import java.lang.annotation.Annotation; | 82 import java.lang.annotation.Annotation; |
| 82 import java.net.MalformedURLException; | 83 import java.net.MalformedURLException; |
| 83 import java.net.URL; | 84 import java.net.URL; |
| 85 import java.util.ArrayList; |
| 84 import java.util.HashMap; | 86 import java.util.HashMap; |
| 87 import java.util.List; |
| 85 import java.util.Locale; | 88 import java.util.Locale; |
| 86 import java.util.Map; | 89 import java.util.Map; |
| 87 import java.util.Map.Entry; | 90 import java.util.Map.Entry; |
| 88 import java.util.WeakHashMap; | 91 import java.util.WeakHashMap; |
| 89 import java.util.concurrent.Callable; | 92 import java.util.concurrent.Callable; |
| 90 | 93 |
| 91 /** | 94 /** |
| 92 * Exposes the native AwContents class, and together these classes wrap the Cont
entViewCore | 95 * Exposes the native AwContents class, and together these classes wrap the Cont
entViewCore |
| 93 * and Browser components that are required to implement Android WebView API. Th
is is the | 96 * and Browser components that are required to implement Android WebView API. Th
is is the |
| 94 * primary entry point for the WebViewProvider implementation; it holds a 1:1 ob
ject | 97 * primary entry point for the WebViewProvider implementation; it holds a 1:1 ob
ject |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 private InternalAccessDelegate mInternalAccessAdapter; | 284 private InternalAccessDelegate mInternalAccessAdapter; |
| 282 private final NativeDrawGLFunctorFactory mNativeDrawGLFunctorFactory; | 285 private final NativeDrawGLFunctorFactory mNativeDrawGLFunctorFactory; |
| 283 private final AwLayoutSizer mLayoutSizer; | 286 private final AwLayoutSizer mLayoutSizer; |
| 284 private final AwZoomControls mZoomControls; | 287 private final AwZoomControls mZoomControls; |
| 285 private final AwScrollOffsetManager mScrollOffsetManager; | 288 private final AwScrollOffsetManager mScrollOffsetManager; |
| 286 private OverScrollGlow mOverScrollGlow; | 289 private OverScrollGlow mOverScrollGlow; |
| 287 // This can be accessed on any thread after construction. See AwContentsIoTh
readClient. | 290 // This can be accessed on any thread after construction. See AwContentsIoTh
readClient. |
| 288 private final AwSettings mSettings; | 291 private final AwSettings mSettings; |
| 289 private final ScrollAccessibilityHelper mScrollAccessibilityHelper; | 292 private final ScrollAccessibilityHelper mScrollAccessibilityHelper; |
| 290 | 293 |
| 294 private final List<PopupTouchHandleDrawable> mTouchHandleDrawables = new Arr
ayList<>(); |
| 295 |
| 291 private boolean mIsPaused; | 296 private boolean mIsPaused; |
| 292 private boolean mIsViewVisible; | 297 private boolean mIsViewVisible; |
| 293 private boolean mIsWindowVisible; | 298 private boolean mIsWindowVisible; |
| 294 private boolean mIsAttachedToWindow; | 299 private boolean mIsAttachedToWindow; |
| 295 // Visiblity state of |mContentViewCore|. | 300 // Visiblity state of |mContentViewCore|. |
| 296 private boolean mIsContentViewCoreVisible; | 301 private boolean mIsContentViewCoreVisible; |
| 297 private boolean mIsUpdateVisibilityTaskPending; | 302 private boolean mIsUpdateVisibilityTaskPending; |
| 298 private Runnable mUpdateVisibilityRunnable; | 303 private Runnable mUpdateVisibilityRunnable; |
| 299 | 304 |
| 300 private Bitmap mFavicon; | 305 private Bitmap mFavicon; |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 mCurrentFunctor = currentFunctor; | 932 mCurrentFunctor = currentFunctor; |
| 928 updateNativeAwGLFunctor(); | 933 updateNativeAwGLFunctor(); |
| 929 mContainerView.setWillNotDraw(false); | 934 mContainerView.setWillNotDraw(false); |
| 930 | 935 |
| 931 mViewAndroidDelegate.updateCurrentContainerView(mContainerView); | 936 mViewAndroidDelegate.updateCurrentContainerView(mContainerView); |
| 932 mContentViewCore.setContainerView(mContainerView); | 937 mContentViewCore.setContainerView(mContainerView); |
| 933 if (mAwPdfExporter != null) { | 938 if (mAwPdfExporter != null) { |
| 934 mAwPdfExporter.setContainerView(mContainerView); | 939 mAwPdfExporter.setContainerView(mContainerView); |
| 935 } | 940 } |
| 936 mWebContentsDelegate.setContainerView(mContainerView); | 941 mWebContentsDelegate.setContainerView(mContainerView); |
| 942 for (PopupTouchHandleDrawable drawable: mTouchHandleDrawables) { |
| 943 drawable.onContainerViewChanged(newContainerView); |
| 944 } |
| 937 onContainerViewChanged(); | 945 onContainerViewChanged(); |
| 938 } | 946 } |
| 939 | 947 |
| 940 /** | 948 /** |
| 941 * Reconciles the state of this AwContents object with the state of the new
container view. | 949 * Reconciles the state of this AwContents object with the state of the new
container view. |
| 942 */ | 950 */ |
| 943 @SuppressLint("NewApi") // ViewGroup#isAttachedToWindow requires API level 1
9. | 951 @SuppressLint("NewApi") // ViewGroup#isAttachedToWindow requires API level 1
9. |
| 944 private void onContainerViewChanged() { | 952 private void onContainerViewChanged() { |
| 945 // NOTE: mAwViewMethods is used by the old container view, the WebView,
so it might refer | 953 // NOTE: mAwViewMethods is used by the old container view, the WebView,
so it might refer |
| 946 // to a NullAwViewMethods when in fullscreen. To ensure that the state i
s reconciled with | 954 // to a NullAwViewMethods when in fullscreen. To ensure that the state i
s reconciled with |
| (...skipping 1727 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2674 private void onReceivedTouchIconUrl(String url, boolean precomposed) { | 2682 private void onReceivedTouchIconUrl(String url, boolean precomposed) { |
| 2675 mContentsClient.onReceivedTouchIconUrl(url, precomposed); | 2683 mContentsClient.onReceivedTouchIconUrl(url, precomposed); |
| 2676 } | 2684 } |
| 2677 | 2685 |
| 2678 @CalledByNative | 2686 @CalledByNative |
| 2679 private void onReceivedIcon(Bitmap bitmap) { | 2687 private void onReceivedIcon(Bitmap bitmap) { |
| 2680 mContentsClient.onReceivedIcon(bitmap); | 2688 mContentsClient.onReceivedIcon(bitmap); |
| 2681 mFavicon = bitmap; | 2689 mFavicon = bitmap; |
| 2682 } | 2690 } |
| 2683 | 2691 |
| 2692 @CalledByNative |
| 2693 private void onCreatedTouchHandle(PopupTouchHandleDrawable drawable) { |
| 2694 mTouchHandleDrawables.add(drawable); |
| 2695 } |
| 2696 |
| 2684 /** Callback for generateMHTML. */ | 2697 /** Callback for generateMHTML. */ |
| 2685 @CalledByNative | 2698 @CalledByNative |
| 2686 private static void generateMHTMLCallback( | 2699 private static void generateMHTMLCallback( |
| 2687 String path, long size, ValueCallback<String> callback) { | 2700 String path, long size, ValueCallback<String> callback) { |
| 2688 if (callback == null) return; | 2701 if (callback == null) return; |
| 2689 callback.onReceiveValue(size < 0 ? null : path); | 2702 callback.onReceiveValue(size < 0 ? null : path); |
| 2690 } | 2703 } |
| 2691 | 2704 |
| 2692 @CalledByNative | 2705 @CalledByNative |
| 2693 private void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, String hos
t, String realm) { | 2706 private void onReceivedHttpAuthRequest(AwHttpAuthHandler handler, String hos
t, String realm) { |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3376 long resources); | 3389 long resources); |
| 3377 | 3390 |
| 3378 private native void nativePostMessageToFrame(long nativeAwContents, String f
rameId, | 3391 private native void nativePostMessageToFrame(long nativeAwContents, String f
rameId, |
| 3379 String message, String targetOrigin, int[] msgPorts); | 3392 String message, String targetOrigin, int[] msgPorts); |
| 3380 | 3393 |
| 3381 private native void nativeCreateMessageChannel(long nativeAwContents, AwMess
agePort[] ports); | 3394 private native void nativeCreateMessageChannel(long nativeAwContents, AwMess
agePort[] ports); |
| 3382 | 3395 |
| 3383 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC
ontents); | 3396 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC
ontents); |
| 3384 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw
Contents); | 3397 private native void nativeResumeLoadingCreatedPopupWebContents(long nativeAw
Contents); |
| 3385 } | 3398 } |
| OLD | NEW |