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; |
| 39 import org.chromium.components.navigation_interception.InterceptNavigationDelega
te; |
| 40 import org.chromium.components.navigation_interception.NavigationParams; |
43 import org.chromium.content.browser.ContentSettings; | 41 import org.chromium.content.browser.ContentSettings; |
44 import org.chromium.content.browser.ContentVideoView; | |
45 import org.chromium.content.browser.ContentViewClient; | 42 import org.chromium.content.browser.ContentViewClient; |
46 import org.chromium.content.browser.ContentViewCore; | 43 import org.chromium.content.browser.ContentViewCore; |
47 import org.chromium.content.browser.ContentViewStatics; | 44 import org.chromium.content.browser.ContentViewStatics; |
48 import org.chromium.content.browser.LoadUrlParams; | 45 import org.chromium.content.browser.LoadUrlParams; |
49 import org.chromium.content.browser.NavigationHistory; | 46 import org.chromium.content.browser.NavigationHistory; |
50 import org.chromium.content.browser.PageTransitionTypes; | 47 import org.chromium.content.browser.PageTransitionTypes; |
51 import org.chromium.content.common.CleanupReference; | 48 import org.chromium.content.common.CleanupReference; |
52 import org.chromium.components.navigation_interception.InterceptNavigationDelega
te; | |
53 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; | |
62 import java.util.ArrayList; | 55 import java.util.ArrayList; |
63 import java.util.List; | 56 import java.util.List; |
| 57 import java.util.concurrent.Callable; |
64 | 58 |
65 /** | 59 /** |
66 * Exposes the native AwContents class, and together these classes wrap the Cont
entViewCore | 60 * Exposes the native AwContents class, and together these classes wrap the Cont
entViewCore |
67 * and Browser components that are required to implement Android WebView API. Th
is is the | 61 * and Browser components that are required to implement Android WebView API. Th
is is the |
68 * primary entry point for the WebViewProvider implementation; it holds a 1:1 ob
ject | 62 * primary entry point for the WebViewProvider implementation; it holds a 1:1 ob
ject |
69 * relationship with application WebView instances. | 63 * relationship with application WebView instances. |
70 * (We define this class independent of the hidden WebViewProvider interfaces, t
o allow | 64 * (We define this class independent of the hidden WebViewProvider interfaces, t
o allow |
71 * continuous build & test in the open source SDK-based tree). | 65 * continuous build & test in the open source SDK-based tree). |
72 */ | 66 */ |
73 @JNINamespace("android_webview") | 67 @JNINamespace("android_webview") |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 private boolean mHasRequestedVisitedHistoryFromClient; | 159 private boolean mHasRequestedVisitedHistoryFromClient; |
166 // TODO(boliu): This should be in a global context, not per webview. | 160 // TODO(boliu): This should be in a global context, not per webview. |
167 private final double mDIPScale; | 161 private final double mDIPScale; |
168 | 162 |
169 // The base background color, i.e. not accounting for any CSS body from the
current page. | 163 // The base background color, i.e. not accounting for any CSS body from the
current page. |
170 private int mBaseBackgroundColor = Color.WHITE; | 164 private int mBaseBackgroundColor = Color.WHITE; |
171 | 165 |
172 // Must call nativeUpdateLastHitTestData first to update this before use. | 166 // Must call nativeUpdateLastHitTestData first to update this before use. |
173 private final HitTestData mPossiblyStaleHitTestData = new HitTestData(); | 167 private final HitTestData mPossiblyStaleHitTestData = new HitTestData(); |
174 | 168 |
175 private DefaultVideoPosterRequestHandler mDefaultVideoPosterRequestHandler; | 169 private final DefaultVideoPosterRequestHandler mDefaultVideoPosterRequestHan
dler; |
176 | 170 |
177 // Bound method for suppling Picture instances to the AwContentsClient. Will
be null if the | 171 // Bound method for suppling Picture instances to the AwContentsClient. Will
be null if the |
178 // picture listener API has not yet been enabled, or if it is using invalida
tion-only mode. | 172 // picture listener API has not yet been enabled, or if it is using invalida
tion-only mode. |
179 private Callable<Picture> mPictureListenerContentProvider; | 173 private Callable<Picture> mPictureListenerContentProvider; |
180 | 174 |
181 private boolean mContainerViewFocused; | 175 private boolean mContainerViewFocused; |
182 private boolean mWindowFocused; | 176 private boolean mWindowFocused; |
183 | 177 |
184 private boolean mClearViewActive; | 178 private boolean mClearViewActive; |
185 private boolean mPictureListenerEnabled; | 179 private boolean mPictureListenerEnabled; |
186 | 180 |
187 // These come from the compositor and are updated immediately (in contrast t
o the values in | 181 // These come from the compositor and are updated immediately (in contrast t
o the values in |
188 // ContentViewCore, which are updated at end of every frame). | 182 // ContentViewCore, which are updated at end of every frame). |
189 private float mPageScaleFactor = 1.0f; | 183 private float mPageScaleFactor = 1.0f; |
190 private float mContentWidthDip; | 184 private float mContentWidthDip; |
191 private float mContentHeightDip; | 185 private float mContentHeightDip; |
192 | 186 |
193 private AwAutofillManagerDelegate mAwAutofillManagerDelegate; | 187 private AwAutofillManagerDelegate mAwAutofillManagerDelegate; |
194 | 188 |
195 private ComponentCallbacks2 mComponentCallbacks; | 189 private ComponentCallbacks2 mComponentCallbacks; |
196 | 190 |
197 private static final class DestroyRunnable implements Runnable { | 191 private static final class DestroyRunnable implements Runnable { |
198 private int mNativeAwContents; | 192 private final int mNativeAwContents; |
199 private DestroyRunnable(int nativeAwContents) { | 193 private DestroyRunnable(int nativeAwContents) { |
200 mNativeAwContents = nativeAwContents; | 194 mNativeAwContents = nativeAwContents; |
201 } | 195 } |
202 @Override | 196 @Override |
203 public void run() { | 197 public void run() { |
204 // This is a no-op if not currently attached. | 198 // This is a no-op if not currently attached. |
205 nativeOnDetachedFromWindow(mNativeAwContents); | 199 nativeOnDetachedFromWindow(mNativeAwContents); |
206 nativeDestroy(mNativeAwContents); | 200 nativeDestroy(mNativeAwContents); |
207 } | 201 } |
208 } | 202 } |
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1125 * @see android.webkit.WebView#stopLoading() | 1119 * @see android.webkit.WebView#stopLoading() |
1126 */ | 1120 */ |
1127 public void stopLoading() { | 1121 public void stopLoading() { |
1128 mContentViewCore.stopLoading(); | 1122 mContentViewCore.stopLoading(); |
1129 } | 1123 } |
1130 | 1124 |
1131 /** | 1125 /** |
1132 * @see android.webkit.WebView#reload() | 1126 * @see android.webkit.WebView#reload() |
1133 */ | 1127 */ |
1134 public void reload() { | 1128 public void reload() { |
1135 mContentViewCore.reload(); | 1129 mContentViewCore.reload(true); |
1136 } | 1130 } |
1137 | 1131 |
1138 /** | 1132 /** |
1139 * @see android.webkit.WebView#canGoBack() | 1133 * @see android.webkit.WebView#canGoBack() |
1140 */ | 1134 */ |
1141 public boolean canGoBack() { | 1135 public boolean canGoBack() { |
1142 return mContentViewCore.canGoBack(); | 1136 return mContentViewCore.canGoBack(); |
1143 } | 1137 } |
1144 | 1138 |
1145 /** | 1139 /** |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2079 private native int nativeCapturePicture(int nativeAwContents, int width, int
height); | 2073 private native int nativeCapturePicture(int nativeAwContents, int width, int
height); |
2080 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e
nabled); | 2074 private native void nativeEnableOnNewPicture(int nativeAwContents, boolean e
nabled); |
2081 | 2075 |
2082 private native void nativeInvokeGeolocationCallback( | 2076 private native void nativeInvokeGeolocationCallback( |
2083 int nativeAwContents, boolean value, String requestingFrame); | 2077 int nativeAwContents, boolean value, String requestingFrame); |
2084 | 2078 |
2085 private native void nativeSetJsOnlineProperty(int nativeAwContents, boolean
networkUp); | 2079 private native void nativeSetJsOnlineProperty(int nativeAwContents, boolean
networkUp); |
2086 | 2080 |
2087 private native void nativeTrimMemory(int nativeAwContents, int level); | 2081 private native void nativeTrimMemory(int nativeAwContents, int level); |
2088 } | 2082 } |
OLD | NEW |