зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1258450 - Delegate Intent handling from GeckoAppShell to GeckoInterface. r=snorp,mcomella
MozReview-Commit-ID: HoHqZU0Ev5D --HG-- extra : rebase_source : 602ffe212a16570a57bc4d67d728fe2ff1e51d1c extra : histedit_source : e3862782ce84ebad7aeb3838c553b4f37d9c50a4
This commit is contained in:
Родитель
abc9f12949
Коммит
46a380f51b
|
@ -161,4 +161,22 @@ public class BaseGeckoInterface implements GeckoAppShell.GeckoInterface {
|
|||
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[] {};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2530,9 +2530,16 @@ public abstract class GeckoApp
|
|||
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;
|
||||
|
@ -2787,4 +2794,23 @@ public abstract class GeckoApp
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ 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;
|
||||
|
@ -835,21 +834,20 @@ public class GeckoAppShell
|
|||
|
||||
@WrapForJNI(stubName = "GetHandlersForMimeTypeWrapper")
|
||||
static String[] getHandlersForMimeType(String aMimeType, String aAction) {
|
||||
Intent intent = IntentHelper.getIntentForActionString(aAction);
|
||||
if (aMimeType != null && aMimeType.length() > 0)
|
||||
intent.setType(aMimeType);
|
||||
return IntentHelper.getHandlersForIntent(intent);
|
||||
final GeckoInterface geckoInterface = getGeckoInterface();
|
||||
if (geckoInterface == null) {
|
||||
return new String[] {};
|
||||
}
|
||||
return geckoInterface.getHandlersForMimeType(aMimeType, aAction);
|
||||
}
|
||||
|
||||
@WrapForJNI(stubName = "GetHandlersForURLWrapper")
|
||||
static String[] getHandlersForURL(String aURL, String 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);
|
||||
final GeckoInterface geckoInterface = getGeckoInterface();
|
||||
if (geckoInterface == null) {
|
||||
return new String[] {};
|
||||
}
|
||||
return geckoInterface.getHandlersForURL(aURL, aAction);
|
||||
}
|
||||
|
||||
@WrapForJNI(stubName = "GetHWEncoderCapability")
|
||||
|
@ -928,9 +926,11 @@ public class GeckoAppShell
|
|||
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);
|
||||
final GeckoInterface geckoInterface = getGeckoInterface();
|
||||
if (geckoInterface == null) {
|
||||
return false;
|
||||
}
|
||||
return geckoInterface.openUriExternal(targetURI, mimeType, packageName, className, action, title);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1815,6 +1815,11 @@ public class GeckoAppShell
|
|||
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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче