Vojtech Szocs has submitted this change and it was merged.
Change subject: webadmin: Cross-window communication support for UI plugins
......................................................................
webadmin: Cross-window communication support for UI plugins
This patch introduces support for cross-window (cross-origin)
communication that can be utilized by UI plugins, i.e. custom
content (contributed by UI plugin) talks back to UI plugin code
via WebAdmin (parent) window.
This enables custom content to pass arbitrary messages back to
given UI plugin(s) which might, or might not, react to them.
The implementation is based on HTML5 window.postMessage API
that triggers 'message' events on the target (i.e. WebAdmin
parent) window. WebAdmin takes care of intercepting such
messages, doing allowed source origin checks, and passing
message data to UI plugins as appropriate.
Sample UI plugin code:
<snip>
var api = parent.pluginApi('showcase');
// New function - define custom API options
api.options({
// Can be either a string (single origin)
// or a string array (multiple origins)
// "*" means "any origin", as per HTML5 spec
allowedMessageOrigins: 'http://nicedomain:8080'
});
api.register({
UiInit: function() {
// Assuming dialog content sends message via:
// parent.postMessage(message, targetOrigin)
api.showDialog(...);
},
// New event handler function
MessageReceived: function(data, sourceWindow) {
// Source origin check already passed here
window.alert('MessageReceived: ' + data);
}
});
api.ready();
</snip>
Aside from message processing, 'sourceWindow' can be used
to establish two-way communication between custom content
window and UI plugin code.
This patch also includes smaller (general) improvements.
Change-Id: I8a159bed88e0709b54a31f0959fb08b6cdf508cb
Bug-Url: https://bugzilla.redhat.com/895103
Signed-off-by: Vojtech Szocs <[email protected]>
---
M
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/SystemModule.java
M
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/Plugin.java
M
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/PluginEventHandler.java
M
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/PluginManager.java
A
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/api/ApiOptions.java
M
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/jsni/JsArrayHelper.java
M
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/plugin/jsni/JsObjectWithProperties.java
A
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/system/MessageEventData.java
A
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/system/MessageReceived.java
A
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/system/PostMessageDispatcher.java
10 files changed, 341 insertions(+), 27 deletions(-)
Approvals:
Vojtech Szocs: Verified; Looks good to me, approved
--
To view, visit http://gerrit.ovirt.org/13794
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8a159bed88e0709b54a31f0959fb08b6cdf508cb
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Vojtech Szocs <[email protected]>
Gerrit-Reviewer: Chris Morrissey <[email protected]>
Gerrit-Reviewer: Daniel Erez <[email protected]>
Gerrit-Reviewer: Einav Cohen <[email protected]>
Gerrit-Reviewer: Frank Kobzik <[email protected]>
Gerrit-Reviewer: Tomas Jelinek <[email protected]>
Gerrit-Reviewer: Vojtech Szocs <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches