/** Sets the current URL associated with this load. */ void setUrl(String url) { if (url != null) { if (URLUtil.isDataUrl(url)) { // Don't strip anchor as that is a valid part of the URL mUrl = url; } else { mUrl = URLUtil.stripAnchor(url); } mUri = null; if (URLUtil.isNetworkUrl(mUrl)) { try { mUri = new WebAddress(mUrl); } catch (ParseException e) { e.printStackTrace(); } } } }
/** * Guesses MIME type if one was not specified. Defaults to 'text/html'. In addition, tries to * guess the MIME type based on the extension. */ private void guessMimeType() { // Data urls must have a valid mime type or a blank string for the mime // type (implying text/plain). if (URLUtil.isDataUrl(mUrl) && mMimeType.length() != 0) { cancel(); final String text = mContext.getString(com.android.internal.R.string.httpErrorBadUrl); error(EventHandler.ERROR_BAD_URL, text); } else { // Note: This is ok because this is used only for the main content // of frames. If no content-type was specified, it is fine to // default to text/html. mMimeType = "text/html"; String newMimeType = guessMimeTypeFromExtension(); if (newMimeType != null) { mMimeType = newMimeType; } } }
/* package */ static boolean handleLocalFile(String url, LoadListener loadListener, WebSettings settings) { if (URLUtil.isAssetUrl(url)) { FileLoader.requestUrl( url, loadListener, loadListener.getContext(), true, settings.getAllowFileAccess()); return true; } else if (URLUtil.isFileUrl(url)) { FileLoader.requestUrl( url, loadListener, loadListener.getContext(), false, settings.getAllowFileAccess()); return true; } else if (URLUtil.isContentUrl(url)) { // Send the raw url to the ContentLoader because it will do a // permission check and the url has to match.. ContentLoader.requestUrl(loadListener.url(), loadListener, loadListener.getContext()); return true; } else if (URLUtil.isDataUrl(url)) { DataLoader.requestUrl(url, loadListener); return true; } else if (URLUtil.isAboutUrl(url)) { loadListener.data(mAboutBlank.getBytes(), mAboutBlank.length()); loadListener.endData(); return true; } return false; }