Closed Bug 730710 Opened 12 years ago Closed 12 years ago

GeckoEventListener implementations cannot return a value

Categories

(Firefox for Android Graveyard :: General, defect)

All
Android
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
Firefox 13

People

(Reporter: kats, Assigned: kats)

References

Details

Attachments

(1 file)

Right now there is no good way for implementations of GeckoEventListener to return a value back to the code that sent the event in browser.js, even though the event architecture supports this functionality. The only way to do it is by sticking the event handling code directly in GeckoAppShell.handleGeckoMessage which is pretty ugly.

There are many possible ways to add support for this; I picked one which reduces the impact on existing GeckoEventListener implementations.
Attachment #600795 - Flags: review?(blassey.bugs)
Comment on attachment 600795 [details] [diff] [review]
Add GeckoEventResponder to allow responding to events

Review of attachment 600795 [details] [diff] [review]:
-----------------------------------------------------------------

::: mobile/android/base/GeckoAppShell.java
@@ +1751,5 @@
> +                listener.handleMessage(type, geckoObject);
> +                if (listener instanceof GeckoEventResponder) {
> +                    String newResponse = ((GeckoEventResponder)listener).getResponse();
> +                    if (response != null && newResponse != null) {
> +                        throw new Exception("Received two responses for message of type " + type);

just log here rather than throw. It gets caught a few lines below and there's no reason to not notify any other listeners that are registered.
Attachment #600795 - Flags: review?(blassey.bugs) → review+
Landed on inbound with the suggested change.

https://hg.mozilla.org/integration/mozilla-inbound/rev/75deec1f1a7b
Target Milestone: --- → Firefox 13
https://hg.mozilla.org/mozilla-central/rev/75deec1f1a7b
Status: ASSIGNED → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: