Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 com.android.webview.chromium; | 5 package com.android.webview.chromium; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.ActivityNotFoundException; | 8 import android.content.ActivityNotFoundException; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 import android.webkit.DownloadListener; | 27 import android.webkit.DownloadListener; |
| 28 import android.webkit.GeolocationPermissions; | 28 import android.webkit.GeolocationPermissions; |
| 29 import android.webkit.JsDialogHelper; | 29 import android.webkit.JsDialogHelper; |
| 30 import android.webkit.JsPromptResult; | 30 import android.webkit.JsPromptResult; |
| 31 import android.webkit.JsResult; | 31 import android.webkit.JsResult; |
| 32 import android.webkit.PermissionRequest; | 32 import android.webkit.PermissionRequest; |
| 33 import android.webkit.SslErrorHandler; | 33 import android.webkit.SslErrorHandler; |
| 34 import android.webkit.ValueCallback; | 34 import android.webkit.ValueCallback; |
| 35 import android.webkit.WebChromeClient; | 35 import android.webkit.WebChromeClient; |
| 36 import android.webkit.WebChromeClient.CustomViewCallback; | 36 import android.webkit.WebChromeClient.CustomViewCallback; |
| 37 import android.webkit.WebResourceRequest; | |
| 38 import android.webkit.WebResourceResponse; | 37 import android.webkit.WebResourceResponse; |
| 39 import android.webkit.WebView; | 38 import android.webkit.WebView; |
| 40 import android.webkit.WebViewClient; | 39 import android.webkit.WebViewClient; |
| 41 | 40 |
| 42 import com.android.webview.chromium.WebViewDelegateFactory.WebViewDelegate; | 41 import com.android.webview.chromium.WebViewDelegateFactory.WebViewDelegate; |
| 43 | 42 |
| 44 import org.chromium.android_webview.AwContentsClient; | 43 import org.chromium.android_webview.AwContentsClient; |
| 45 import org.chromium.android_webview.AwContentsClientBridge; | 44 import org.chromium.android_webview.AwContentsClientBridge; |
| 46 import org.chromium.android_webview.AwHttpAuthHandler; | 45 import org.chromium.android_webview.AwHttpAuthHandler; |
| 47 import org.chromium.android_webview.AwWebResourceResponse; | |
| 48 import org.chromium.android_webview.JsPromptResultReceiver; | 46 import org.chromium.android_webview.JsPromptResultReceiver; |
| 49 import org.chromium.android_webview.JsResultReceiver; | 47 import org.chromium.android_webview.JsResultReceiver; |
| 50 import org.chromium.android_webview.permission.AwPermissionRequest; | 48 import org.chromium.android_webview.permission.AwPermissionRequest; |
| 51 import org.chromium.base.ThreadUtils; | 49 import org.chromium.base.ThreadUtils; |
| 52 import org.chromium.base.TraceEvent; | 50 import org.chromium.base.TraceEvent; |
| 53 import org.chromium.content.browser.ContentView; | 51 import org.chromium.content.browser.ContentView; |
| 54 import org.chromium.content.browser.ContentViewClient; | 52 import org.chromium.content.browser.ContentViewClient; |
| 55 import org.chromium.content.browser.ContentViewCore; | 53 import org.chromium.content.browser.ContentViewCore; |
| 56 | 54 |
| 57 import java.lang.ref.WeakReference; | 55 import java.lang.ref.WeakReference; |
| 58 import java.net.URISyntaxException; | 56 import java.net.URISyntaxException; |
| 59 import java.security.Principal; | 57 import java.security.Principal; |
| 60 import java.security.PrivateKey; | 58 import java.security.PrivateKey; |
| 61 import java.security.cert.X509Certificate; | 59 import java.security.cert.X509Certificate; |
| 62 import java.util.ArrayList; | 60 import java.util.ArrayList; |
| 63 import java.util.HashMap; | |
| 64 import java.util.Map; | |
| 65 import java.util.WeakHashMap; | 61 import java.util.WeakHashMap; |
| 66 | 62 |
| 67 /** | 63 /** |
| 68 * An adapter class that forwards the callbacks from {@link ContentViewClient} | 64 * An adapter class that forwards the callbacks from {@link ContentViewClient} |
| 69 * to the appropriate {@link WebViewClient} or {@link WebChromeClient}. | 65 * to the appropriate {@link WebViewClient} or {@link WebChromeClient}. |
| 70 * | 66 * |
| 71 * An instance of this class is associated with one {@link WebViewChromium} | 67 * An instance of this class is associated with one {@link WebViewChromium} |
| 72 * instance. A WebViewChromium is a WebView implementation provider (that is | 68 * instance. A WebViewChromium is a WebView implementation provider (that is |
| 73 * android.webkit.WebView delegates all functionality to it) and has exactly | 69 * android.webkit.WebView delegates all functionality to it) and has exactly |
| 74 * one corresponding {@link ContentView} instance. | 70 * one corresponding {@link ContentView} instance. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 TraceEvent.begin("WebViewContentsClientAdapter.onProgressChanged"); | 273 TraceEvent.begin("WebViewContentsClientAdapter.onProgressChanged"); |
| 278 if (mWebChromeClient != null) { | 274 if (mWebChromeClient != null) { |
| 279 if (TRACE) Log.d(TAG, "onProgressChanged=" + progress); | 275 if (TRACE) Log.d(TAG, "onProgressChanged=" + progress); |
| 280 mWebChromeClient.onProgressChanged(mWebView, progress); | 276 mWebChromeClient.onProgressChanged(mWebView, progress); |
| 281 } | 277 } |
| 282 } finally { | 278 } finally { |
| 283 TraceEvent.end("WebViewContentsClientAdapter.onProgressChanged"); | 279 TraceEvent.end("WebViewContentsClientAdapter.onProgressChanged"); |
| 284 } | 280 } |
| 285 } | 281 } |
| 286 | 282 |
| 287 private static class WebResourceRequestImpl implements WebResourceRequest { | |
| 288 private final AwWebResourceRequest mRequest; | |
| 289 | |
| 290 public WebResourceRequestImpl(AwWebResourceRequest request) { | |
| 291 mRequest = request; | |
| 292 } | |
| 293 | |
| 294 @Override | |
| 295 public Uri getUrl() { | |
| 296 return Uri.parse(mRequest.url); | |
| 297 } | |
| 298 | |
| 299 @Override | |
| 300 public boolean isForMainFrame() { | |
| 301 return mRequest.isMainFrame; | |
| 302 } | |
| 303 | |
| 304 @Override | |
| 305 public boolean hasGesture() { | |
| 306 return mRequest.hasUserGesture; | |
| 307 } | |
| 308 | |
| 309 @Override | |
| 310 public String getMethod() { | |
| 311 return mRequest.method; | |
| 312 } | |
| 313 | |
| 314 @Override | |
| 315 public Map<String, String> getRequestHeaders() { | |
| 316 return mRequest.requestHeaders; | |
| 317 } | |
| 318 } | |
| 319 | |
| 320 /** | 283 /** |
| 321 * @see AwContentsClient#shouldInterceptRequest(java.lang.String) | 284 * @see AwContentsClient#shouldInterceptRequest(java.lang.String) |
| 322 */ | 285 */ |
| 323 @Override | 286 @Override |
| 324 public AwWebResourceResponse shouldInterceptRequest(AwWebResourceRequest req uest) { | 287 public WebResourceResponse shouldInterceptRequest(WebResourceRequestImpl req uest) { |
|
mnaganov (inactive)
2015/03/06 12:47:40
Hmm... I'm actually not sure that we should pass a
| |
| 325 try { | 288 try { |
| 326 TraceEvent.begin("WebViewContentsClientAdapter.shouldInterceptReques t"); | 289 TraceEvent.begin("WebViewContentsClientAdapter.shouldInterceptReques t"); |
| 327 if (TRACE) Log.d(TAG, "shouldInterceptRequest=" + request.url); | 290 if (TRACE) Log.d(TAG, "shouldInterceptRequest=" + request.getUrl()); |
| 328 WebResourceResponse response = mWebViewClient.shouldInterceptRequest (mWebView, | 291 return mWebViewClient.shouldInterceptRequest(mWebView, request); |
| 329 new WebResourceRequestImpl(request)); | |
| 330 if (response == null) return null; | |
| 331 | |
| 332 // AwWebResourceResponse should support null headers. b/16332774. | |
| 333 Map<String, String> responseHeaders = response.getResponseHeaders(); | |
| 334 if (responseHeaders == null) responseHeaders = new HashMap<String, S tring>(); | |
| 335 | |
| 336 return new AwWebResourceResponse( | |
| 337 response.getMimeType(), | |
| 338 response.getEncoding(), | |
| 339 response.getData(), | |
| 340 response.getStatusCode(), | |
| 341 response.getReasonPhrase(), | |
| 342 responseHeaders); | |
| 343 } finally { | 292 } finally { |
| 344 TraceEvent.end("WebViewContentsClientAdapter.shouldInterceptRequest" ); | 293 TraceEvent.end("WebViewContentsClientAdapter.shouldInterceptRequest" ); |
| 345 } | 294 } |
| 346 } | 295 } |
| 347 | 296 |
| 348 /** | 297 /** |
| 349 * @see AwContentsClient#shouldOverrideUrlLoading(java.lang.String) | 298 * @see AwContentsClient#shouldOverrideUrlLoading(java.lang.String) |
| 350 */ | 299 */ |
| 351 @Override | 300 @Override |
| 352 public boolean shouldOverrideUrlLoading(String url) { | 301 public boolean shouldOverrideUrlLoading(String url) { |
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1246 else | 1195 else |
| 1247 mAwPermissionRequest.deny(); | 1196 mAwPermissionRequest.deny(); |
| 1248 } | 1197 } |
| 1249 | 1198 |
| 1250 @Override | 1199 @Override |
| 1251 public void deny() { | 1200 public void deny() { |
| 1252 mAwPermissionRequest.deny(); | 1201 mAwPermissionRequest.deny(); |
| 1253 } | 1202 } |
| 1254 } | 1203 } |
| 1255 } | 1204 } |
| OLD | NEW |