| Index: content/public/android/java/src/org/chromium/content/browser/MediaResourceGetter.java
|
| diff --git a/content/public/android/java/src/org/chromium/content/browser/MediaResourceGetter.java b/content/public/android/java/src/org/chromium/content/browser/MediaResourceGetter.java
|
| index 5e334820aeadc2ddb147b9039c406b963a3017c2..5da4676758bca8e8c9a7afbe1b91fb7697340115 100644
|
| --- a/content/public/android/java/src/org/chromium/content/browser/MediaResourceGetter.java
|
| +++ b/content/public/android/java/src/org/chromium/content/browser/MediaResourceGetter.java
|
| @@ -9,7 +9,6 @@ import android.content.pm.PackageManager;
|
| import android.media.MediaMetadataRetriever;
|
| import android.net.ConnectivityManager;
|
| import android.net.NetworkInfo;
|
| -import android.net.Uri;
|
| import android.text.TextUtils;
|
| import android.util.Log;
|
|
|
| @@ -21,6 +20,7 @@ import org.chromium.base.PathUtils;
|
|
|
| import java.io.File;
|
| import java.io.IOException;
|
| +import java.net.URI;
|
| import java.util.ArrayList;
|
| import java.util.HashMap;
|
| import java.util.List;
|
| @@ -188,7 +188,7 @@ class MediaResourceGetter {
|
|
|
| @VisibleForTesting
|
| boolean configure(Context context, String url, String cookies, String userAgent) {
|
| - Uri uri = Uri.parse(url);
|
| + URI uri = URI.create(url);
|
| String scheme = uri.getScheme();
|
| if (scheme == null || scheme.equals("file")) {
|
| File file = uriToFile(uri.getPath());
|
| @@ -208,7 +208,8 @@ class MediaResourceGetter {
|
| return false;
|
| }
|
| } else {
|
| - if (!isNetworkReliable(context)) {
|
| + final String host = uri.getHost();
|
| + if (!isLoopbackAddress(host) && !isNetworkReliable(context)) {
|
| Log.w(TAG, "non-file URI can't be read due to unsuitable network conditions");
|
| return false;
|
| }
|
| @@ -260,6 +261,14 @@ class MediaResourceGetter {
|
| }
|
| }
|
|
|
| + // This method covers only typcial expressions for the loopback address
|
| + // to resolve the hostname without a DNS loopup.
|
| + private boolean isLoopbackAddress(String host) {
|
| + return host != null && (host.equalsIgnoreCase("localhost") // typical hostname
|
| + || host.equals("127.0.0.1") // typical IP v4 expression
|
| + || host.equals("[::1]")); // typical IP v6 expression
|
| + }
|
| +
|
| /**
|
| * @param file the file whose path should be checked
|
| * @return true if and only if the file is in a location that we consider
|
|
|