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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 public void run() { | 245 public void run() { |
246 nativeDestroy(mNativeAwContents); | 246 nativeDestroy(mNativeAwContents); |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 // Reference to the active mNativeAwContents pointer while it is active use | 250 // Reference to the active mNativeAwContents pointer while it is active use |
251 // (ie before it is destroyed). | 251 // (ie before it is destroyed). |
252 private CleanupReference mCleanupReference; | 252 private CleanupReference mCleanupReference; |
253 | 253 |
254 //--------------------------------------------------------------------------
------------------ | 254 //--------------------------------------------------------------------------
------------------ |
255 private class IoThreadClientImpl implements AwContentsIoThreadClient { | 255 private class IoThreadClientImpl extends AwContentsIoThreadClient { |
256 // All methods are called on the IO thread. | 256 // All methods are called on the IO thread. |
257 | 257 |
258 @Override | 258 @Override |
259 public int getCacheMode() { | 259 public int getCacheMode() { |
260 return mSettings.getCacheMode(); | 260 return mSettings.getCacheMode(); |
261 } | 261 } |
262 | 262 |
263 @Override | 263 @Override |
264 public InterceptedRequestData shouldInterceptRequest(final String url, | 264 public AwWebResourceResponse shouldInterceptRequest( |
265 boolean isMainFrame) { | 265 AwContentsClient.ShouldInterceptRequestParams params) { |
266 InterceptedRequestData interceptedRequestData; | 266 String url = params.url; |
| 267 AwWebResourceResponse awWebResourceResponse; |
267 // Return the response directly if the url is default video poster u
rl. | 268 // Return the response directly if the url is default video poster u
rl. |
268 interceptedRequestData = mDefaultVideoPosterRequestHandler.shouldInt
erceptRequest(url); | 269 awWebResourceResponse = mDefaultVideoPosterRequestHandler.shouldInte
rceptRequest(url); |
269 if (interceptedRequestData != null) return interceptedRequestData; | 270 if (awWebResourceResponse != null) return awWebResourceResponse; |
270 | 271 |
271 interceptedRequestData = mContentsClient.shouldInterceptRequest(url)
; | 272 awWebResourceResponse = mContentsClient.shouldInterceptRequest(param
s); |
272 | 273 |
273 if (interceptedRequestData == null) { | 274 if (awWebResourceResponse == null) { |
274 mContentsClient.getCallbackHelper().postOnLoadResource(url); | 275 mContentsClient.getCallbackHelper().postOnLoadResource(url); |
275 } | 276 } |
276 | 277 |
277 if (isMainFrame && interceptedRequestData != null && | 278 if (params.isMainFrame && awWebResourceResponse != null && |
278 interceptedRequestData.getData() == null) { | 279 awWebResourceResponse.getData() == null) { |
279 // In this case the intercepted URLRequest job will simulate an
empty response | 280 // In this case the intercepted URLRequest job will simulate an
empty response |
280 // which doesn't trigger the onReceivedError callback. For WebVi
ewClassic | 281 // which doesn't trigger the onReceivedError callback. For WebVi
ewClassic |
281 // compatibility we synthesize that callback. http://crbug.com/1
80950 | 282 // compatibility we synthesize that callback. http://crbug.com/1
80950 |
282 mContentsClient.getCallbackHelper().postOnReceivedError( | 283 mContentsClient.getCallbackHelper().postOnReceivedError( |
283 ErrorCodeConversionHelper.ERROR_UNKNOWN, | 284 ErrorCodeConversionHelper.ERROR_UNKNOWN, |
284 null /* filled in by the glue layer */, url); | 285 null /* filled in by the glue layer */, url); |
285 } | 286 } |
286 return interceptedRequestData; | 287 return awWebResourceResponse; |
287 } | 288 } |
288 | 289 |
289 @Override | 290 @Override |
290 public boolean shouldBlockContentUrls() { | 291 public boolean shouldBlockContentUrls() { |
291 return !mSettings.getAllowContentAccess(); | 292 return !mSettings.getAllowContentAccess(); |
292 } | 293 } |
293 | 294 |
294 @Override | 295 @Override |
295 public boolean shouldBlockFileUrls() { | 296 public boolean shouldBlockFileUrls() { |
296 return !mSettings.getAllowFileAccess(); | 297 return !mSettings.getAllowFileAccess(); |
(...skipping 1968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2265 | 2266 |
2266 private native void nativeSetJsOnlineProperty(long nativeAwContents, boolean
networkUp); | 2267 private native void nativeSetJsOnlineProperty(long nativeAwContents, boolean
networkUp); |
2267 | 2268 |
2268 private native void nativeTrimMemory(long nativeAwContents, int level, boole
an visible); | 2269 private native void nativeTrimMemory(long nativeAwContents, int level, boole
an visible); |
2269 | 2270 |
2270 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo
rter awPdfExporter); | 2271 private native void nativeCreatePdfExporter(long nativeAwContents, AwPdfExpo
rter awPdfExporter); |
2271 | 2272 |
2272 private native void nativePreauthorizePermission(long nativeAwContents, Stri
ng origin, | 2273 private native void nativePreauthorizePermission(long nativeAwContents, Stri
ng origin, |
2273 long resources); | 2274 long resources); |
2274 } | 2275 } |
OLD | NEW |