Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0fa72ef1 authored by Jonathan Dixon's avatar Jonathan Dixon
Browse files

Tidy up usage of URLUtil constants

Several of these are duplicated; referring to a single source makes the code
paths using them easier to track down.
(also removing a spurious import)

Bug: 6237833

Change-Id: Ibdacc124c047e37c7f0ced9ecc6f26ae3e6b4326
parent b3cbd0b4
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -692,13 +692,10 @@ class BrowserFrame extends Handler {
     * @return An InputStream to the android resource
     */
    private InputStream inputStreamForAndroidResource(String url) {
        // This list needs to be kept in sync with the list in
        // external/webkit/WebKit/android/WebCoreSupport/WebUrlLoaderClient.cpp
        final String ANDROID_ASSET = "file:///android_asset/";
        final String ANDROID_RESOURCE = "file:///android_res/";
        final String ANDROID_CONTENT = "content:";
        final String ANDROID_ASSET = URLUtil.ASSET_BASE;
        final String ANDROID_RESOURCE = URLUtil.RESOURCE_BASE;
        final String ANDROID_CONTENT = URLUtil.CONTENT_BASE;

        // file:///android_res
        if (url.startsWith(ANDROID_RESOURCE)) {
            url = url.replaceFirst(ANDROID_RESOURCE, "");
            if (url == null || url.length() == 0) {
@@ -736,8 +733,6 @@ class BrowserFrame extends Handler {
                Log.e(LOGTAG, "Exception: " + url);
                return null;
            }

        // file:///android_asset
        } else if (url.startsWith(ANDROID_ASSET)) {
            url = url.replaceFirst(ANDROID_ASSET, "");
            try {
@@ -747,8 +742,6 @@ class BrowserFrame extends Handler {
            } catch (IOException e) {
                return null;
            }

        // content://
        } else if (mSettings.getAllowContentAccess() &&
                   url.startsWith(ANDROID_CONTENT)) {
            try {
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@ class JniUtil {
        return sContext.getPackageName();
    }

    private static final String ANDROID_CONTENT = "content:";
    private static final String ANDROID_CONTENT = URLUtil.CONTENT_BASE;

    /**
     * Called by JNI. Calculates the size of an input stream by reading it.
+0 −1
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@
package android.webkit;

import android.text.TextUtils;
import java.util.HashMap;
import java.util.regex.Pattern;
import libcore.net.MimeUtils;

+2 −1
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public final class URLUtil {
    static final String RESOURCE_BASE = "file:///android_res/";
    static final String FILE_BASE = "file://";
    static final String PROXY_BASE = "file:///cookieless_proxy/";
    static final String CONTENT_BASE = "content:";

    /**
     * Cleans up (if possible) user-entered web addresses
@@ -253,7 +254,7 @@ public final class URLUtil {
     * @return True iff the url is a content: url.
     */
    public static boolean isContentUrl(String url) {
        return (null != url) && url.startsWith("content:");
        return (null != url) && url.startsWith(CONTENT_BASE);
    }

    /**