Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Tidy up usage of URLUtil constants
Browse files Browse the repository at this point in the history
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
  • Loading branch information
joth76 committed Mar 28, 2012
1 parent b3cbd0b commit 0fa72ef
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
13 changes: 3 additions & 10 deletions core/java/android/webkit/BrowserFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -692,13 +692,10 @@ private int getFile(String uri, byte[] buffer, int offset,
* @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) {
Expand Down Expand Up @@ -736,8 +733,6 @@ private InputStream inputStreamForAndroidResource(String url) {
Log.e(LOGTAG, "Exception: " + url);
return null;
}

// file:///android_asset
} else if (url.startsWith(ANDROID_ASSET)) {
url = url.replaceFirst(ANDROID_ASSET, "");
try {
Expand All @@ -747,8 +742,6 @@ private InputStream inputStreamForAndroidResource(String url) {
} catch (IOException e) {
return null;
}

// content://
} else if (mSettings.getAllowContentAccess() &&
url.startsWith(ANDROID_CONTENT)) {
try {
Expand Down
2 changes: 1 addition & 1 deletion core/java/android/webkit/JniUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private static synchronized String getPackageName() {
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.
Expand Down
1 change: 0 additions & 1 deletion core/java/android/webkit/MimeTypeMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package android.webkit;

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

Expand Down
3 changes: 2 additions & 1 deletion core/java/android/webkit/URLUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -253,7 +254,7 @@ public static boolean isNetworkUrl(String url) {
* @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);
}

/**
Expand Down

0 comments on commit 0fa72ef

Please sign in to comment.