Backed out changeset e5ec40672f6e (bug 1258450)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Wed, 30 Mar 2016 14:02:10 +0200
changeset 290870 7f7a84327477419e181f0369cebd26678cee2e88
parent 290869 d202b268a22881704adae85f42c4473e1b82259c
child 290871 d085c3aaf69df9f799340339a4f73eb4cb8973f5
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1258450
milestone48.0a1
backs oute5ec40672f6ee91471a420e797e653e3e322bba4
Backed out changeset e5ec40672f6e (bug 1258450)
mobile/android/base/java/org/mozilla/gecko/BaseGeckoInterface.java
mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
--- a/mobile/android/base/java/org/mozilla/gecko/BaseGeckoInterface.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BaseGeckoInterface.java
@@ -156,27 +156,9 @@ public class BaseGeckoInterface implemen
     public void setUriTitle(final String uri, final String title) {
         // By default, no titles are associated with URIs.
     }
 
     @Override
     public void setAccessibilityEnabled(boolean enabled) {
         // By default, take no action when accessibility is toggled on or off.
     }
-
-    @Override
-    public boolean openUriExternal(String targetURI, String mimeType, String packageName, String className, String action, String title) {
-        // By default, never open external URIs.
-        return false;
-    }
-
-    @Override
-    public String[] getHandlersForMimeType(String mimeType, String action) {
-        // By default, offer no handlers for any MIME type.
-        return new String[] {};
-    }
-
-    @Override
-    public String[] getHandlersForURL(String url, String action) {
-        // By default, offer no handlers for any URL.
-        return new String[] {};
-    }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoApp.java
@@ -2525,26 +2525,19 @@ public abstract class GeckoApp
     public void notifyCheckUpdateResult(String result) {
         GeckoAppShell.notifyObservers("Update:CheckResult", result);
     }
 
     private void geckoConnected() {
         mLayerView.setOverScrollMode(View.OVER_SCROLL_NEVER);
     }
 
-    @Override
     public void setAccessibilityEnabled(boolean enabled) {
     }
 
-    @Override
-    public boolean openUriExternal(String targetURI, String mimeType, String packageName, String className, String action, String title) {
-        // Default to showing prompt in private browsing to be safe.
-        return IntentHelper.openUriExternal(targetURI, mimeType, packageName, className, action, title, true);
-    }
-
     public static class MainLayout extends RelativeLayout {
         private TouchEventInterceptor mTouchEventInterceptor;
         private MotionEventInterceptor mMotionEventInterceptor;
 
         public MainLayout(Context context, AttributeSet attrs) {
             super(context, attrs);
         }
 
@@ -2789,28 +2782,9 @@ public abstract class GeckoApp
         final BrowserDB db = GeckoProfile.get(context).getDB();
         ThreadUtils.postToBackgroundThread(new Runnable() {
             @Override
             public void run() {
                 GlobalHistory.getInstance().update(context.getContentResolver(), db, uri, title);
             }
         });
     }
-
-    @Override
-    public String[] getHandlersForMimeType(String mimeType, String action) {
-        Intent intent = IntentHelper.getIntentForActionString(action);
-        if (mimeType != null && mimeType.length() > 0)
-            intent.setType(mimeType);
-        return IntentHelper.getHandlersForIntent(intent);
-    }
-
-    @Override
-    public String[] getHandlersForURL(String url, String action) {
-        // May contain the whole URL or just the protocol.
-        Uri uri = url.indexOf(':') >= 0 ? Uri.parse(url) : new Uri.Builder().scheme(url).build();
-
-        Intent intent = IntentHelper.getOpenURIIntent(getApplicationContext(), uri.toString(), "",
-                TextUtils.isEmpty(action) ? Intent.ACTION_VIEW : action, "");
-
-        return IntentHelper.getHandlersForIntent(intent);
-    }
 }
--- a/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GeckoAppShell.java
@@ -15,16 +15,17 @@ import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
 import java.net.MalformedURLException;
 import java.net.Proxy;
 import java.net.URLConnection;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.StringTokenizer;
 import java.util.TreeMap;
 import java.util.concurrent.ConcurrentHashMap;
 
 import android.annotation.SuppressLint;
 import org.mozilla.gecko.annotation.JNITarget;
 import org.mozilla.gecko.annotation.RobocopTarget;
@@ -829,30 +830,31 @@ public class GeckoAppShell
                 default:
                     return 72;
             }
         }
     }
 
     @WrapForJNI(stubName = "GetHandlersForMimeTypeWrapper")
     static String[] getHandlersForMimeType(String aMimeType, String aAction) {
-        final GeckoInterface geckoInterface = getGeckoInterface();
-        if (geckoInterface == null) {
-            return new String[] {};
-        }
-        return geckoInterface.getHandlersForMimeType(aMimeType, aAction);
+        Intent intent = IntentHelper.getIntentForActionString(aAction);
+        if (aMimeType != null && aMimeType.length() > 0)
+            intent.setType(aMimeType);
+        return IntentHelper.getHandlersForIntent(intent);
     }
 
     @WrapForJNI(stubName = "GetHandlersForURLWrapper")
     static String[] getHandlersForURL(String aURL, String aAction) {
-        final GeckoInterface geckoInterface = getGeckoInterface();
-        if (geckoInterface == null) {
-            return new String[] {};
-        }
-        return geckoInterface.getHandlersForURL(aURL, aAction);
+        // aURL may contain the whole URL or just the protocol
+        Uri uri = aURL.indexOf(':') >= 0 ? Uri.parse(aURL) : new Uri.Builder().scheme(aURL).build();
+
+        Intent intent = IntentHelper.getOpenURIIntent(getApplicationContext(), uri.toString(), "",
+            TextUtils.isEmpty(aAction) ? Intent.ACTION_VIEW : aAction, "");
+
+        return IntentHelper.getHandlersForIntent(intent);
     }
 
     @WrapForJNI(stubName = "GetHWEncoderCapability")
     static boolean getHWEncoderCapability() {
       return HardwareCodecCapabilityUtils.getHWEncoderCapability();
     }
 
     @WrapForJNI(stubName = "GetHWDecoderCapability")
@@ -921,21 +923,19 @@ public class GeckoAppShell
 
     @WrapForJNI
     public static boolean openUriExternal(String targetURI,
                                           String mimeType,
                                           String packageName,
                                           String className,
                                           String action,
                                           String title) {
-        final GeckoInterface geckoInterface = getGeckoInterface();
-        if (geckoInterface == null) {
-            return false;
-        }
-        return geckoInterface.openUriExternal(targetURI, mimeType, packageName, className, action, title);
+
+        // Default to showing prompt in private browsing to be safe.
+        return IntentHelper.openUriExternal(targetURI, mimeType, packageName, className, action, title, true);
     }
 
     /**
      * Only called from GeckoApp.
      */
     public static void setNotificationClient(NotificationClient client) {
         if (notificationClient == null) {
             notificationClient = client;
@@ -1810,21 +1810,16 @@ public class GeckoAppShell
          * This method is always invoked on the Gecko thread.
          *
          * @param uri given.
          * @param title to associate with the given URI.
          */
         public void setUriTitle(final String uri, final String title);
 
         public void setAccessibilityEnabled(boolean enabled);
-
-        public boolean openUriExternal(String targetURI, String mimeType, String packageName, String className, String action, String title);
-
-        public String[] getHandlersForMimeType(String mimeType, String action);
-        public String[] getHandlersForURL(String url, String action);
     };
 
     private static GeckoInterface sGeckoInterface;
 
     public static GeckoInterface getGeckoInterface() {
         return sGeckoInterface;
     }