1 // Copyright (c) 2014 Intel Corporation. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.xwalk.core;
7 import org.xwalk.core.internal.XWalkExtensionInternal;
10 * This class represents an extension and could be implemented by callers.
12 public abstract class XWalkExtension extends XWalkExtensionInternal {
14 * Constructor with name and javascript API.
15 * @param name the exposed namespace.
16 * @param jsApi the string of javascript API.
19 public XWalkExtension(String name, String jsApi) {
24 * Constructor with name, javascript API and entry points.
25 * @param name the exposed namespace.
26 * @param jsApi the string of javascript API.
27 * @param entryPoints Entry points are used when the extension needs to
28 * have objects outside the namespace that is
29 * implicitly created using its name.
32 public XWalkExtension(String name, String jsApi, String[] entryPoints) {
33 super(name, jsApi, entryPoints);
37 * Destroy an extension.
39 protected void destroyExtension() {
40 super.destroyExtension();
44 * Send message to an instance.
45 * @param instanceID the id of instance.
46 * @param message the message.
49 public final void postMessage(int instanceID, String message) {
50 super.postMessage(instanceID, message);
54 * Broadcast message to all extension instances.
55 * @param message the message.
58 public final void broadcastMessage(String message) {
59 super.broadcastMessage(message);
63 * Notify the extension that the async message is received.
64 * @param instanceID the id of instance.
65 * @param message the received message.
68 public abstract void onMessage(int instanceID, String message);
71 * Notify the extension that the sync message is received.
72 * @param instanceID the id of instance.
73 * @param message the received message.
76 public abstract String onSyncMessage(int instanceID, String message);