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 17 matching lines...) Expand all Loading... | |
28 import android.view.MotionEvent; | 28 import android.view.MotionEvent; |
29 import android.view.View; | 29 import android.view.View; |
30 import android.view.ViewGroup; | 30 import android.view.ViewGroup; |
31 import android.view.accessibility.AccessibilityEvent; | 31 import android.view.accessibility.AccessibilityEvent; |
32 import android.view.accessibility.AccessibilityNodeInfo; | 32 import android.view.accessibility.AccessibilityNodeInfo; |
33 import android.view.accessibility.AccessibilityNodeProvider; | 33 import android.view.accessibility.AccessibilityNodeProvider; |
34 import android.view.inputmethod.EditorInfo; | 34 import android.view.inputmethod.EditorInfo; |
35 import android.view.inputmethod.InputConnection; | 35 import android.view.inputmethod.InputConnection; |
36 import android.webkit.GeolocationPermissions; | 36 import android.webkit.GeolocationPermissions; |
37 import android.webkit.ValueCallback; | 37 import android.webkit.ValueCallback; |
38 import android.webkit.WebResourceResponse; | |
38 import android.widget.OverScroller; | 39 import android.widget.OverScroller; |
39 | 40 |
40 import org.chromium.android_webview.permission.AwPermissionRequest; | 41 import org.chromium.android_webview.permission.AwPermissionRequest; |
41 import org.chromium.base.CalledByNative; | 42 import org.chromium.base.CalledByNative; |
42 import org.chromium.base.JNINamespace; | 43 import org.chromium.base.JNINamespace; |
43 import org.chromium.base.ThreadUtils; | 44 import org.chromium.base.ThreadUtils; |
44 import org.chromium.base.TraceEvent; | 45 import org.chromium.base.TraceEvent; |
45 import org.chromium.base.VisibleForTesting; | 46 import org.chromium.base.VisibleForTesting; |
46 import org.chromium.components.navigation_interception.InterceptNavigationDelega te; | 47 import org.chromium.components.navigation_interception.InterceptNavigationDelega te; |
47 import org.chromium.components.navigation_interception.NavigationParams; | 48 import org.chromium.components.navigation_interception.NavigationParams; |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
350 private class IoThreadClientImpl extends AwContentsIoThreadClient { | 351 private class IoThreadClientImpl extends AwContentsIoThreadClient { |
351 // All methods are called on the IO thread. | 352 // All methods are called on the IO thread. |
352 | 353 |
353 @Override | 354 @Override |
354 public int getCacheMode() { | 355 public int getCacheMode() { |
355 return mSettings.getCacheMode(); | 356 return mSettings.getCacheMode(); |
356 } | 357 } |
357 | 358 |
358 @Override | 359 @Override |
359 public AwWebResourceResponse shouldInterceptRequest( | 360 public AwWebResourceResponse shouldInterceptRequest( |
360 AwContentsClient.AwWebResourceRequest request) { | 361 AwContentsClient.WebResourceRequestImpl request) { |
361 String url = request.url; | 362 String url = request.getUrlString(); |
362 AwWebResourceResponse awWebResourceResponse; | 363 AwWebResourceResponse awWebResourceResponse; |
363 // Return the response directly if the url is default video poster u rl. | 364 // Return the response directly if the url is default video poster u rl. |
364 awWebResourceResponse = mDefaultVideoPosterRequestHandler.shouldInte rceptRequest(url); | 365 awWebResourceResponse = mDefaultVideoPosterRequestHandler.shouldInte rceptRequest(url); |
365 if (awWebResourceResponse != null) return awWebResourceResponse; | |
366 | 366 |
367 awWebResourceResponse = mContentsClient.shouldInterceptRequest(reque st); | 367 WebResourceResponse response = mContentsClient.shouldInterceptReques t(request); |
368 if (response != null) awWebResourceResponse = new AwWebResourceRespo nse(response); | |
mnaganov (inactive)
2015/03/06 09:58:43
nit: This looks a bit complex for a one-liner. Cou
| |
368 | 369 |
369 if (awWebResourceResponse == null) { | 370 if (awWebResourceResponse == null) { |
370 mContentsClient.getCallbackHelper().postOnLoadResource(url); | 371 mContentsClient.getCallbackHelper().postOnLoadResource(url); |
371 } | 372 } |
372 | 373 |
373 if (request.isMainFrame && awWebResourceResponse != null | 374 if (request.isForMainFrame() && awWebResourceResponse != null |
374 && awWebResourceResponse.getData() == null) { | 375 && awWebResourceResponse.getData() == null) { |
375 // In this case the intercepted URLRequest job will simulate an empty response | 376 // In this case the intercepted URLRequest job will simulate an empty response |
376 // which doesn't trigger the onReceivedError callback. For WebVi ewClassic | 377 // which doesn't trigger the onReceivedError callback. For WebVi ewClassic |
377 // compatibility we synthesize that callback. http://crbug.com/1 80950 | 378 // compatibility we synthesize that callback. http://crbug.com/1 80950 |
378 mContentsClient.getCallbackHelper().postOnReceivedError( | 379 mContentsClient.getCallbackHelper().postOnReceivedError( |
379 ErrorCodeConversionHelper.ERROR_UNKNOWN, | 380 ErrorCodeConversionHelper.ERROR_UNKNOWN, |
380 null /* filled in by the glue layer */, url); | 381 null /* filled in by the glue layer */, url); |
381 } | 382 } |
382 return awWebResourceResponse; | 383 return awWebResourceResponse; |
383 } | 384 } |
(...skipping 2419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2803 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo rter awPdfExporter); | 2804 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo rter awPdfExporter); |
2804 | 2805 |
2805 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin, | 2806 private native void nativePreauthorizePermission(long nativeAwContents, Stri ng origin, |
2806 long resources); | 2807 long resources); |
2807 | 2808 |
2808 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId, | 2809 private native void nativePostMessageToFrame(long nativeAwContents, String f rameId, |
2809 String message, String targetOrigin, int[] msgPorts); | 2810 String message, String targetOrigin, int[] msgPorts); |
2810 | 2811 |
2811 private native void nativeCreateMessageChannel(long nativeAwContents, Messag ePort[] ports); | 2812 private native void nativeCreateMessageChannel(long nativeAwContents, Messag ePort[] ports); |
2812 } | 2813 } |
OLD | NEW |