List of usage examples for android.webkit WebResourceRequest isForMainFrame
boolean isForMainFrame();
From source file:org.mozilla.focus.webkit.FocusWebViewClient.java
@Override public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { // Only update the user visible URL if: // 1. The purported site URL has actually been requested // 2. And it's being loaded for the main frame (and not a fake/hidden/iframe request) // Note also: shouldInterceptRequest() runs on a background thread, so we can't actually // query WebView.getURL(). // We update the URL when loading has finished too (redirects can happen after a request has been // made in which case we don't get shouldInterceptRequest with the final URL), but this // allows us to update the URL during loading. if (request.isForMainFrame()) { // WebView will always add a trailing / to the request URL, but currentPageURL may or may // not have a trailing URL (usually no trailing / when a link is entered via UrlInputFragment), // hence we do a somewhat convoluted test: final String requestURL = request.getUrl().toString(); if (UrlUtils.urlsMatchExceptForTrailingSlash(currentPageURL, requestURL)) { view.post(new Runnable() { @Override// w w w. ja v a 2 s . c o m public void run() { if (callback != null) { callback.onURLChanged(currentPageURL); } } }); } } return super.shouldInterceptRequest(view, request); }