| 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.app.Activity; | 8 import android.app.Activity; |
| 9 import android.content.ComponentCallbacks2; | 9 import android.content.ComponentCallbacks2; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 private final int mAppTargetSdkVersion; | 217 private final int mAppTargetSdkVersion; |
| 218 private ContentViewCore mContentViewCore; | 218 private ContentViewCore mContentViewCore; |
| 219 private WindowAndroidWrapper mWindowAndroid; | 219 private WindowAndroidWrapper mWindowAndroid; |
| 220 private WebContents mWebContents; | 220 private WebContents mWebContents; |
| 221 private NavigationController mNavigationController; | 221 private NavigationController mNavigationController; |
| 222 private final AwContentsClient mContentsClient; | 222 private final AwContentsClient mContentsClient; |
| 223 private final AwContentViewClient mContentViewClient; | 223 private final AwContentViewClient mContentViewClient; |
| 224 private AwWebContentsObserver mWebContentsObserver; | 224 private AwWebContentsObserver mWebContentsObserver; |
| 225 private final AwContentsClientBridge mContentsClientBridge; | 225 private final AwContentsClientBridge mContentsClientBridge; |
| 226 private final AwWebContentsDelegateAdapter mWebContentsDelegate; | 226 private final AwWebContentsDelegateAdapter mWebContentsDelegate; |
| 227 private final AwContentsBackgroundThreadClient mBackgroundThreadClient; |
| 227 private final AwContentsIoThreadClient mIoThreadClient; | 228 private final AwContentsIoThreadClient mIoThreadClient; |
| 228 private final InterceptNavigationDelegateImpl mInterceptNavigationDelegate; | 229 private final InterceptNavigationDelegateImpl mInterceptNavigationDelegate; |
| 229 private InternalAccessDelegate mInternalAccessAdapter; | 230 private InternalAccessDelegate mInternalAccessAdapter; |
| 230 private final NativeGLDelegate mNativeGLDelegate; | 231 private final NativeGLDelegate mNativeGLDelegate; |
| 231 private final AwLayoutSizer mLayoutSizer; | 232 private final AwLayoutSizer mLayoutSizer; |
| 232 private final AwZoomControls mZoomControls; | 233 private final AwZoomControls mZoomControls; |
| 233 private final AwScrollOffsetManager mScrollOffsetManager; | 234 private final AwScrollOffsetManager mScrollOffsetManager; |
| 234 private OverScrollGlow mOverScrollGlow; | 235 private OverScrollGlow mOverScrollGlow; |
| 235 // This can be accessed on any thread after construction. See AwContentsIoTh
readClient. | 236 // This can be accessed on any thread after construction. See AwContentsIoTh
readClient. |
| 236 private final AwSettings mSettings; | 237 private final AwSettings mSettings; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 //--------------------------------------------------------------------------
------------------ | 375 //--------------------------------------------------------------------------
------------------ |
| 375 private class IoThreadClientImpl extends AwContentsIoThreadClient { | 376 private class IoThreadClientImpl extends AwContentsIoThreadClient { |
| 376 // All methods are called on the IO thread. | 377 // All methods are called on the IO thread. |
| 377 | 378 |
| 378 @Override | 379 @Override |
| 379 public int getCacheMode() { | 380 public int getCacheMode() { |
| 380 return mSettings.getCacheMode(); | 381 return mSettings.getCacheMode(); |
| 381 } | 382 } |
| 382 | 383 |
| 383 @Override | 384 @Override |
| 384 public AwWebResourceResponse shouldInterceptRequest( | 385 public AwContentsBackgroundThreadClient getBackgroundThreadClient() { |
| 385 AwContentsClient.AwWebResourceRequest request) { | 386 return mBackgroundThreadClient; |
| 386 String url = request.url; | |
| 387 AwWebResourceResponse awWebResourceResponse; | |
| 388 // Return the response directly if the url is default video poster u
rl. | |
| 389 awWebResourceResponse = mDefaultVideoPosterRequestHandler.shouldInte
rceptRequest(url); | |
| 390 if (awWebResourceResponse != null) return awWebResourceResponse; | |
| 391 | |
| 392 awWebResourceResponse = mContentsClient.shouldInterceptRequest(reque
st); | |
| 393 | |
| 394 if (awWebResourceResponse == null) { | |
| 395 mContentsClient.getCallbackHelper().postOnLoadResource(url); | |
| 396 } | |
| 397 | |
| 398 if (awWebResourceResponse != null && awWebResourceResponse.getData()
== null) { | |
| 399 // In this case the intercepted URLRequest job will simulate an
empty response | |
| 400 // which doesn't trigger the onReceivedError callback. For WebVi
ewClassic | |
| 401 // compatibility we synthesize that callback. http://crbug.com/1
80950 | |
| 402 mContentsClient.getCallbackHelper().postOnReceivedError( | |
| 403 request, | |
| 404 /* error description filled in by the glue layer */ | |
| 405 new AwContentsClient.AwWebResourceError()); | |
| 406 } | |
| 407 return awWebResourceResponse; | |
| 408 } | 387 } |
| 409 | 388 |
| 410 @Override | 389 @Override |
| 411 public boolean shouldBlockContentUrls() { | 390 public boolean shouldBlockContentUrls() { |
| 412 return !mSettings.getAllowContentAccess(); | 391 return !mSettings.getAllowContentAccess(); |
| 413 } | 392 } |
| 414 | 393 |
| 415 @Override | 394 @Override |
| 416 public boolean shouldBlockFileUrls() { | 395 public boolean shouldBlockFileUrls() { |
| 417 return !mSettings.getAllowFileAccess(); | 396 return !mSettings.getAllowFileAccess(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 } | 443 } |
| 465 } | 444 } |
| 466 | 445 |
| 467 @Override | 446 @Override |
| 468 public void onReceivedHttpError(AwContentsClient.AwWebResourceRequest re
quest, | 447 public void onReceivedHttpError(AwContentsClient.AwWebResourceRequest re
quest, |
| 469 AwWebResourceResponse response) { | 448 AwWebResourceResponse response) { |
| 470 mContentsClient.getCallbackHelper().postOnReceivedHttpError(request,
response); | 449 mContentsClient.getCallbackHelper().postOnReceivedHttpError(request,
response); |
| 471 } | 450 } |
| 472 } | 451 } |
| 473 | 452 |
| 453 private class BackgroundThreadClientImpl extends AwContentsBackgroundThreadC
lient { |
| 454 // All methods are called on the background thread. |
| 455 |
| 456 @Override |
| 457 public AwWebResourceResponse shouldInterceptRequest( |
| 458 AwContentsClient.AwWebResourceRequest request) { |
| 459 String url = request.url; |
| 460 AwWebResourceResponse awWebResourceResponse; |
| 461 // Return the response directly if the url is default video poster u
rl. |
| 462 awWebResourceResponse = mDefaultVideoPosterRequestHandler.shouldInte
rceptRequest(url); |
| 463 if (awWebResourceResponse != null) return awWebResourceResponse; |
| 464 |
| 465 awWebResourceResponse = mContentsClient.shouldInterceptRequest(reque
st); |
| 466 |
| 467 if (awWebResourceResponse == null) { |
| 468 mContentsClient.getCallbackHelper().postOnLoadResource(url); |
| 469 } |
| 470 |
| 471 if (awWebResourceResponse != null && awWebResourceResponse.getData()
== null) { |
| 472 // In this case the intercepted URLRequest job will simulate an
empty response |
| 473 // which doesn't trigger the onReceivedError callback. For WebVi
ewClassic |
| 474 // compatibility we synthesize that callback. http://crbug.com/1
80950 |
| 475 mContentsClient.getCallbackHelper().postOnReceivedError( |
| 476 request, |
| 477 /* error description filled in by the glue layer */ |
| 478 new AwContentsClient.AwWebResourceError()); |
| 479 } |
| 480 return awWebResourceResponse; |
| 481 } |
| 482 } |
| 483 |
| 474 //--------------------------------------------------------------------------
------------------ | 484 //--------------------------------------------------------------------------
------------------ |
| 475 // When the navigation is for a newly created WebView (i.e. a popup), interc
ept the navigation | 485 // When the navigation is for a newly created WebView (i.e. a popup), interc
ept the navigation |
| 476 // here for implementing shouldOverrideUrlLoading. This is to send the shoul
dOverrideUrlLoading | 486 // here for implementing shouldOverrideUrlLoading. This is to send the shoul
dOverrideUrlLoading |
| 477 // callback to the correct WebViewClient that is associated with the WebView
. | 487 // callback to the correct WebViewClient that is associated with the WebView
. |
| 478 // Otherwise, use this delegate only to post onPageStarted messages. | 488 // Otherwise, use this delegate only to post onPageStarted messages. |
| 479 // | 489 // |
| 480 // We are not using WebContentsObserver.didStartLoading because of stale URL
s, out of order | 490 // We are not using WebContentsObserver.didStartLoading because of stale URL
s, out of order |
| 481 // onPageStarted's and double onPageStarted's. | 491 // onPageStarted's and double onPageStarted's. |
| 482 // | 492 // |
| 483 private class InterceptNavigationDelegateImpl implements InterceptNavigation
Delegate { | 493 private class InterceptNavigationDelegateImpl implements InterceptNavigation
Delegate { |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 mLayoutSizer = dependencyFactory.createLayoutSizer(); | 702 mLayoutSizer = dependencyFactory.createLayoutSizer(); |
| 693 mSettings = settings; | 703 mSettings = settings; |
| 694 mDIPScale = DeviceDisplayInfo.create(mContext).getDIPScale(); | 704 mDIPScale = DeviceDisplayInfo.create(mContext).getDIPScale(); |
| 695 mLayoutSizer.setDelegate(new AwLayoutSizerDelegate()); | 705 mLayoutSizer.setDelegate(new AwLayoutSizerDelegate()); |
| 696 mLayoutSizer.setDIPScale(mDIPScale); | 706 mLayoutSizer.setDIPScale(mDIPScale); |
| 697 mWebContentsDelegate = new AwWebContentsDelegateAdapter( | 707 mWebContentsDelegate = new AwWebContentsDelegateAdapter( |
| 698 this, contentsClient, mContentViewClient, mContext, mContainerVi
ew); | 708 this, contentsClient, mContentViewClient, mContext, mContainerVi
ew); |
| 699 mContentsClientBridge = new AwContentsClientBridge(mContext, contentsCli
ent, | 709 mContentsClientBridge = new AwContentsClientBridge(mContext, contentsCli
ent, |
| 700 mBrowserContext.getKeyStore(), AwContentsStatics.getClientCertLo
okupTable()); | 710 mBrowserContext.getKeyStore(), AwContentsStatics.getClientCertLo
okupTable()); |
| 701 mZoomControls = new AwZoomControls(this); | 711 mZoomControls = new AwZoomControls(this); |
| 712 mBackgroundThreadClient = new BackgroundThreadClientImpl(); |
| 702 mIoThreadClient = new IoThreadClientImpl(); | 713 mIoThreadClient = new IoThreadClientImpl(); |
| 703 mInterceptNavigationDelegate = new InterceptNavigationDelegateImpl(); | 714 mInterceptNavigationDelegate = new InterceptNavigationDelegateImpl(); |
| 704 | 715 |
| 705 AwSettings.ZoomSupportChangeListener zoomListener = | 716 AwSettings.ZoomSupportChangeListener zoomListener = |
| 706 new AwSettings.ZoomSupportChangeListener() { | 717 new AwSettings.ZoomSupportChangeListener() { |
| 707 @Override | 718 @Override |
| 708 public void onGestureZoomSupportChanged( | 719 public void onGestureZoomSupportChanged( |
| 709 boolean supportsDoubleTapZoom, boolean supportsMulti
TouchZoom) { | 720 boolean supportsDoubleTapZoom, boolean supportsMulti
TouchZoom) { |
| 710 if (isDestroyed()) return; | 721 if (isDestroyed()) return; |
| 711 mContentViewCore.updateDoubleTapSupport(supportsDoubleTa
pZoom); | 722 mContentViewCore.updateDoubleTapSupport(supportsDoubleTa
pZoom); |
| (...skipping 2445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3157 private native void nativePreauthorizePermission(long nativeAwContents, Stri
ng origin, | 3168 private native void nativePreauthorizePermission(long nativeAwContents, Stri
ng origin, |
| 3158 long resources); | 3169 long resources); |
| 3159 | 3170 |
| 3160 private native void nativePostMessageToFrame(long nativeAwContents, String f
rameId, | 3171 private native void nativePostMessageToFrame(long nativeAwContents, String f
rameId, |
| 3161 String message, String targetOrigin, int[] msgPorts); | 3172 String message, String targetOrigin, int[] msgPorts); |
| 3162 | 3173 |
| 3163 private native void nativeCreateMessageChannel(long nativeAwContents, AwMess
agePort[] ports); | 3174 private native void nativeCreateMessageChannel(long nativeAwContents, AwMess
agePort[] ports); |
| 3164 | 3175 |
| 3165 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC
ontents); | 3176 private native void nativeGrantFileSchemeAccesstoChildProcess(long nativeAwC
ontents); |
| 3166 } | 3177 } |
| OLD | NEW |