зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1570115 - Add default handler for OnLoad{Request,Error}. r=droeh
Differential Revision: https://phabricator.services.mozilla.com/D44049 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
278a0d3de7
Коммит
29e0543f01
|
@ -517,9 +517,11 @@ public class GeckoSession implements Parcelable {
|
|||
"GeckoViewNavigation", this,
|
||||
new String[]{
|
||||
"GeckoView:LocationChange",
|
||||
"GeckoView:OnNewSession"
|
||||
},
|
||||
new String[] {
|
||||
"GeckoView:OnLoadError",
|
||||
"GeckoView:OnLoadRequest",
|
||||
"GeckoView:OnNewSession"
|
||||
}
|
||||
) {
|
||||
// This needs to match nsIBrowserDOMWindow.idl
|
||||
|
@ -533,6 +535,20 @@ public class GeckoSession implements Parcelable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleDefaultMessage(final String event,
|
||||
final GeckoBundle message,
|
||||
final EventCallback callback) {
|
||||
|
||||
if ("GeckoView:OnLoadRequest".equals(event)) {
|
||||
callback.sendSuccess(false);
|
||||
} else if ("GeckoView:OnLoadError".equals(event)) {
|
||||
callback.sendSuccess(null);
|
||||
} else {
|
||||
super.handleDefaultMessage(event, message, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(final NavigationDelegate delegate,
|
||||
final String event,
|
||||
|
|
|
@ -27,10 +27,20 @@ import android.util.Log;
|
|||
/* package */ GeckoSessionHandler(final String module,
|
||||
final GeckoSession session,
|
||||
final String[] events) {
|
||||
this(module, session, events, new String[]{});
|
||||
}
|
||||
|
||||
/* package */ GeckoSessionHandler(final String module,
|
||||
final GeckoSession session,
|
||||
final String[] events,
|
||||
final String[] defaultEvents) {
|
||||
session.handlersCount++;
|
||||
|
||||
mModuleName = module;
|
||||
mEvents = events;
|
||||
|
||||
// Default events are always active
|
||||
session.getEventDispatcher().registerUiThreadListener(this, defaultEvents);
|
||||
}
|
||||
|
||||
public Delegate getDelegate() {
|
||||
|
@ -78,8 +88,8 @@ import android.util.Log;
|
|||
|
||||
if (mDelegate != null) {
|
||||
handleMessage(mDelegate, event, message, callback);
|
||||
} else if (callback != null) {
|
||||
callback.sendError("No delegate registered");
|
||||
} else {
|
||||
handleDefaultMessage(event, message, callback);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,4 +97,12 @@ import android.util.Log;
|
|||
final String event,
|
||||
final GeckoBundle message,
|
||||
final EventCallback callback);
|
||||
|
||||
protected void handleDefaultMessage(final String event,
|
||||
final GeckoBundle message,
|
||||
final EventCallback callback) {
|
||||
if (callback != null) {
|
||||
callback.sendError("No delegate registered");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче