[tbb-commits] [tor-browser/tor-browser-68.1.0esr-9.0-3] squash! Orfox: Centralized proxy applied to AbstractCommunicator and BaseResources.

gk at torproject.org gk at torproject.org
Thu Oct 17 18:48:26 UTC 2019


commit 55b6cd7f3139dd0069ba2c69ec6d08da038594ad
Author: Matthew Finkel <Matthew.Finkel at gmail.com>
Date:   Sat Oct 12 00:48:05 2019 +0000

    squash! Orfox: Centralized proxy applied to AbstractCommunicator and BaseResources.
    
    Bug 31144 - ESR68 Network Code Review
---
 .../base/java/org/mozilla/gecko/GeckoApplication.java       | 12 +++++++++---
 .../src/main/java/org/mozilla/gecko/util/BitmapUtils.java   | 13 +++----------
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java b/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
index 26e06b55ecfc..bb3cdec7c0fe 100644
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApplication.java
@@ -61,6 +61,7 @@ import org.mozilla.gecko.util.GeckoBundle;
 import org.mozilla.gecko.util.HardwareUtils;
 import org.mozilla.gecko.util.IntentUtils;
 import org.mozilla.gecko.util.PRNGFixes;
+import org.mozilla.gecko.util.ProxySelector;
 import org.mozilla.gecko.util.ShortcutUtils;
 import org.mozilla.gecko.util.ThreadUtils;
 import org.mozilla.geckoview.GeckoRuntime;
@@ -71,7 +72,7 @@ import java.io.File;
 import java.io.InputStream;
 import java.io.IOException;
 import java.lang.reflect.Method;
-import java.net.URL;
+import java.net.URI;
 import java.util.UUID;
 
 import org.torproject.android.service.util.Prefs;
@@ -866,11 +867,16 @@ public class GeckoApplication extends Application
                 byte[] buf = Base64.decode(aSrc.substring(dataStart + 1), Base64.DEFAULT);
                 image = BitmapUtils.decodeByteArray(buf);
             } else {
+                URI uri;
                 int byteRead;
                 byte[] buf = new byte[4192];
                 os = new ByteArrayOutputStream();
-                URL url = new URL(aSrc);
-                is = url.openStream();
+                try {
+                    uri = new URI(aSrc);
+                } catch (Exception e) {
+                    return;
+                }
+                is = ProxySelector.openConnectionWithProxy(uri).getInputStream();
 
                 // Cannot read from same stream twice. Also, InputStream from
                 // URL does not support reset. So converting to byte array.
diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/BitmapUtils.java b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/BitmapUtils.java
index 2a3f08de4ae7..b5e1a9664b35 100644
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/BitmapUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/BitmapUtils.java
@@ -103,16 +103,9 @@ public final class BitmapUtils {
     public static Bitmap decodeUrl(final URL url) {
         InputStream stream = null;
 
-        try {
-            if ("jar".equals(url.getProtocol())) {
-                final Context context = GeckoAppShell.getApplicationContext();
-                stream = GeckoJarReader.getStream(context, url.toString());
-            } else {
-                stream = url.openStream();
-            }
-        } catch (IOException e) {
-            Log.w(LOGTAG, "decodeUrl: IOException downloading " + url);
-            return null;
+        if ("jar".equals(url.getProtocol())) {
+            final Context context = GeckoAppShell.getApplicationContext();
+            stream = GeckoJarReader.getStream(context, url.toString());
         }
 
         if (stream == null) {



More information about the tbb-commits mailing list