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.content.ComponentCallbacks2; | 7 import android.content.ComponentCallbacks2; |
8 import android.content.Context; | |
9 import android.content.pm.PackageManager; | |
10 import android.content.res.Configuration; | 8 import android.content.res.Configuration; |
11 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
12 import android.graphics.Canvas; | 10 import android.graphics.Canvas; |
13 import android.graphics.Color; | 11 import android.graphics.Color; |
14 import android.graphics.Picture; | 12 import android.graphics.Picture; |
15 import android.graphics.Rect; | 13 import android.graphics.Rect; |
16 import android.graphics.drawable.Drawable; | |
17 import android.net.http.SslCertificate; | 14 import android.net.http.SslCertificate; |
18 import android.os.AsyncTask; | 15 import android.os.AsyncTask; |
19 import android.os.Build; | 16 import android.os.Build; |
20 import android.os.Bundle; | 17 import android.os.Bundle; |
21 import android.os.Message; | 18 import android.os.Message; |
22 import android.text.TextUtils; | 19 import android.text.TextUtils; |
23 import android.util.Log; | 20 import android.util.Log; |
24 import android.view.KeyEvent; | 21 import android.view.KeyEvent; |
25 import android.view.MotionEvent; | 22 import android.view.MotionEvent; |
26 import android.view.View; | 23 import android.view.View; |
27 import android.view.ViewGroup; | 24 import android.view.ViewGroup; |
28 import android.view.ViewTreeObserver; | |
29 import android.view.accessibility.AccessibilityEvent; | 25 import android.view.accessibility.AccessibilityEvent; |
30 import android.view.accessibility.AccessibilityNodeInfo; | 26 import android.view.accessibility.AccessibilityNodeInfo; |
31 import android.view.accessibility.AccessibilityNodeProvider; | 27 import android.view.accessibility.AccessibilityNodeProvider; |
32 import android.view.inputmethod.EditorInfo; | 28 import android.view.inputmethod.EditorInfo; |
33 import android.view.inputmethod.InputConnection; | 29 import android.view.inputmethod.InputConnection; |
34 import android.webkit.GeolocationPermissions; | 30 import android.webkit.GeolocationPermissions; |
35 import android.webkit.ValueCallback; | 31 import android.webkit.ValueCallback; |
36 import android.widget.OverScroller; | 32 import android.widget.OverScroller; |
37 | 33 |
38 import com.google.common.annotations.VisibleForTesting; | 34 import com.google.common.annotations.VisibleForTesting; |
39 | 35 |
40 import org.chromium.base.CalledByNative; | 36 import org.chromium.base.CalledByNative; |
41 import org.chromium.base.JNINamespace; | 37 import org.chromium.base.JNINamespace; |
42 import org.chromium.base.ThreadUtils; | 38 import org.chromium.base.ThreadUtils; |
43 import org.chromium.content.browser.ContentSettings; | 39 import org.chromium.content.browser.ContentSettings; |
44 import org.chromium.content.browser.ContentVideoView; | |
45 import org.chromium.content.browser.ContentViewClient; | 40 import org.chromium.content.browser.ContentViewClient; |
46 import org.chromium.content.browser.ContentViewCore; | 41 import org.chromium.content.browser.ContentViewCore; |
47 import org.chromium.content.browser.ContentViewStatics; | 42 import org.chromium.content.browser.ContentViewStatics; |
48 import org.chromium.content.browser.LoadUrlParams; | 43 import org.chromium.content.browser.LoadUrlParams; |
49 import org.chromium.content.browser.NavigationHistory; | 44 import org.chromium.content.browser.NavigationHistory; |
50 import org.chromium.content.browser.PageTransitionTypes; | 45 import org.chromium.content.browser.PageTransitionTypes; |
51 import org.chromium.content.common.CleanupReference; | 46 import org.chromium.content.common.CleanupReference; |
52 import org.chromium.components.navigation_interception.InterceptNavigationDelega
te; | 47 import org.chromium.components.navigation_interception.InterceptNavigationDelega
te; |
53 import org.chromium.components.navigation_interception.NavigationParams; | 48 import org.chromium.components.navigation_interception.NavigationParams; |
54 import org.chromium.net.GURLUtils; | |
55 import org.chromium.ui.gfx.DeviceDisplayInfo; | 49 import org.chromium.ui.gfx.DeviceDisplayInfo; |
56 | 50 |
57 import java.io.File; | 51 import java.io.File; |
58 import java.lang.annotation.Annotation; | 52 import java.lang.annotation.Annotation; |
59 import java.net.MalformedURLException; | 53 import java.net.MalformedURLException; |
60 import java.net.URL; | 54 import java.net.URL; |
61 import java.util.concurrent.Callable; | 55 import java.util.concurrent.Callable; |
62 import java.util.ArrayList; | 56 import java.util.ArrayList; |
63 import java.util.List; | 57 import java.util.List; |
64 | 58 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 * should fallback to the SW path. | 131 * should fallback to the SW path. |
138 */ | 132 */ |
139 boolean requestDrawGL(Canvas canvas); | 133 boolean requestDrawGL(Canvas canvas); |
140 } | 134 } |
141 | 135 |
142 private int mNativeAwContents; | 136 private int mNativeAwContents; |
143 private final AwBrowserContext mBrowserContext; | 137 private final AwBrowserContext mBrowserContext; |
144 private final ViewGroup mContainerView; | 138 private final ViewGroup mContainerView; |
145 private ContentViewCore mContentViewCore; | 139 private ContentViewCore mContentViewCore; |
146 private final AwContentsClient mContentsClient; | 140 private final AwContentsClient mContentsClient; |
| 141 private final AwContentViewClient mContentViewClient; |
147 private final AwContentsClientBridge mContentsClientBridge; | 142 private final AwContentsClientBridge mContentsClientBridge; |
148 private final AwWebContentsDelegate mWebContentsDelegate; | 143 private final AwWebContentsDelegate mWebContentsDelegate; |
149 private final AwContentsIoThreadClient mIoThreadClient; | 144 private final AwContentsIoThreadClient mIoThreadClient; |
150 private final InterceptNavigationDelegateImpl mInterceptNavigationDelegate; | 145 private final InterceptNavigationDelegateImpl mInterceptNavigationDelegate; |
151 private final InternalAccessDelegate mInternalAccessAdapter; | 146 private final InternalAccessDelegate mInternalAccessAdapter; |
152 private final AwLayoutSizer mLayoutSizer; | 147 private final AwLayoutSizer mLayoutSizer; |
153 private final AwZoomControls mZoomControls; | 148 private final AwZoomControls mZoomControls; |
154 private final AwScrollOffsetManager mScrollOffsetManager; | 149 private final AwScrollOffsetManager mScrollOffsetManager; |
155 private OverScrollGlow mOverScrollGlow; | 150 private OverScrollGlow mOverScrollGlow; |
156 // This can be accessed on any thread after construction. See AwContentsIoTh
readClient. | 151 // This can be accessed on any thread after construction. See AwContentsIoTh
readClient. |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 isAccessFromFileURLsGrantedByDefault, supportsLegacyQuir
ks)); | 519 isAccessFromFileURLsGrantedByDefault, supportsLegacyQuir
ks)); |
525 } | 520 } |
526 | 521 |
527 public AwContents(AwBrowserContext browserContext, ViewGroup containerView, | 522 public AwContents(AwBrowserContext browserContext, ViewGroup containerView, |
528 InternalAccessDelegate internalAccessAdapter, AwContentsClient conte
ntsClient, | 523 InternalAccessDelegate internalAccessAdapter, AwContentsClient conte
ntsClient, |
529 AwLayoutSizer layoutSizer, AwSettings settings) { | 524 AwLayoutSizer layoutSizer, AwSettings settings) { |
530 mBrowserContext = browserContext; | 525 mBrowserContext = browserContext; |
531 mContainerView = containerView; | 526 mContainerView = containerView; |
532 mInternalAccessAdapter = internalAccessAdapter; | 527 mInternalAccessAdapter = internalAccessAdapter; |
533 mContentsClient = contentsClient; | 528 mContentsClient = contentsClient; |
| 529 mContentViewClient = new AwContentViewClient(contentsClient, settings); |
534 mLayoutSizer = layoutSizer; | 530 mLayoutSizer = layoutSizer; |
535 mSettings = settings; | 531 mSettings = settings; |
536 mDIPScale = DeviceDisplayInfo.create(mContainerView.getContext()).getDIP
Scale(); | 532 mDIPScale = DeviceDisplayInfo.create(mContainerView.getContext()).getDIP
Scale(); |
537 mLayoutSizer.setDelegate(new AwLayoutSizerDelegate()); | 533 mLayoutSizer.setDelegate(new AwLayoutSizerDelegate()); |
538 mLayoutSizer.setDIPScale(mDIPScale); | 534 mLayoutSizer.setDIPScale(mDIPScale); |
539 mWebContentsDelegate = new AwWebContentsDelegateAdapter(contentsClient,
mContainerView); | 535 mWebContentsDelegate = new AwWebContentsDelegateAdapter(contentsClient,
mContainerView); |
540 mContentsClientBridge = new AwContentsClientBridge(contentsClient); | 536 mContentsClientBridge = new AwContentsClientBridge(contentsClient); |
541 mZoomControls = new AwZoomControls(this); | 537 mZoomControls = new AwZoomControls(this); |
542 mIoThreadClient = new IoThreadClientImpl(); | 538 mIoThreadClient = new IoThreadClientImpl(); |
543 mInterceptNavigationDelegate = new InterceptNavigationDelegateImpl(); | 539 mInterceptNavigationDelegate = new InterceptNavigationDelegateImpl(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 // each other, we should update |mBrowserContext| according to the newly
received native | 586 // each other, we should update |mBrowserContext| according to the newly
received native |
591 // WebContent's browser context. | 587 // WebContent's browser context. |
592 | 588 |
593 // The native side object has been bound to this java instance, so now i
s the time to | 589 // The native side object has been bound to this java instance, so now i
s the time to |
594 // bind all the native->java relationships. | 590 // bind all the native->java relationships. |
595 mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNati
veAwContents)); | 591 mCleanupReference = new CleanupReference(this, new DestroyRunnable(mNati
veAwContents)); |
596 | 592 |
597 int nativeWebContents = nativeGetWebContents(mNativeAwContents); | 593 int nativeWebContents = nativeGetWebContents(mNativeAwContents); |
598 mContentViewCore = createAndInitializeContentViewCore( | 594 mContentViewCore = createAndInitializeContentViewCore( |
599 mContainerView, mInternalAccessAdapter, nativeWebContents, | 595 mContainerView, mInternalAccessAdapter, nativeWebContents, |
600 new AwGestureStateListener(), mContentsClient.getContentViewClie
nt(), | 596 new AwGestureStateListener(), mContentViewClient, mZoomControls)
; |
601 mZoomControls); | |
602 nativeSetJavaPeers(mNativeAwContents, this, mWebContentsDelegate, mConte
ntsClientBridge, | 597 nativeSetJavaPeers(mNativeAwContents, this, mWebContentsDelegate, mConte
ntsClientBridge, |
603 mIoThreadClient, mInterceptNavigationDelegate); | 598 mIoThreadClient, mInterceptNavigationDelegate); |
604 mContentsClient.installWebContentsObserver(mContentViewCore); | 599 mContentsClient.installWebContentsObserver(mContentViewCore); |
605 mSettings.setWebContents(nativeWebContents); | 600 mSettings.setWebContents(nativeWebContents); |
606 nativeSetDipScale(mNativeAwContents, (float) mDIPScale); | 601 nativeSetDipScale(mNativeAwContents, (float) mDIPScale); |
607 updateGlobalVisibleRect(); | 602 updateGlobalVisibleRect(); |
608 | 603 |
609 // The only call to onShow. onHide should never be called. | 604 // The only call to onShow. onHide should never be called. |
610 mContentViewCore.onShow(); | 605 mContentViewCore.onShow(); |
611 } | 606 } |
(...skipping 1467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 private native int nativeCapturePicture(int nativeAwContents, int width, int
height); | 2074 private native int nativeCapturePicture(int nativeAwContents, int width, int
height); |
2080 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e
nabled); | 2075 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e
nabled); |
2081 | 2076 |
2082 private native void nativeInvokeGeolocationCallback( | 2077 private native void nativeInvokeGeolocationCallback( |
2083 int nativeAwContents, boolean value, String requestingFrame); | 2078 int nativeAwContents, boolean value, String requestingFrame); |
2084 | 2079 |
2085 private native void nativeSetJsOnlineProperty(int nativeAwContents, boolean
networkUp); | 2080 private native void nativeSetJsOnlineProperty(int nativeAwContents, boolean
networkUp); |
2086 | 2081 |
2087 private native void nativeTrimMemory(int nativeAwContents, int level); | 2082 private native void nativeTrimMemory(int nativeAwContents, int level); |
2088 } | 2083 } |
OLD | NEW |