6184ebf8eacb1f7f450eac413e5ebb26e681bfdb
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / android / core / src / org / xwalk / core / XWalkExtension.java
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.
4
5 package org.xwalk.core;
6
7 import org.xwalk.core.internal.XWalkExtensionInternal;
8
9 /**
10  * This class represents an extension and could be implemented by callers.
11  */
12 public abstract class XWalkExtension extends XWalkExtensionInternal {
13     /**
14      * Constructor with name and javascript API.
15      * @param name  the exposed namespace.
16      * @param jsApi the string of javascript API.
17      * @since 2.1
18      */
19     public XWalkExtension(String name, String jsApi) {
20         super(name, jsApi);
21     }
22
23     /**
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.
30      * @since 2.1
31      */
32     public XWalkExtension(String name, String jsApi, String[] entryPoints) {
33         super(name, jsApi, entryPoints);
34     }
35
36     /**
37      * Destroy an extension.
38      */
39     protected void destroyExtension() {
40         super.destroyExtension();
41     }
42
43     /**
44      * Send message to an instance.
45      * @param instanceID the id of instance.
46      * @param message the message.
47      * @since 2.1
48      */
49     public final void postMessage(int instanceID, String message) {
50         super.postMessage(instanceID, message);
51     }
52
53     /**
54      * Broadcast message to all extension instances.
55      * @param message the message.
56      * @since 2.1
57      */
58     public final void broadcastMessage(String message) {
59         super.broadcastMessage(message);
60     }
61
62     /**
63      * Notify the extension that the async message is received.
64      * @param instanceID the id of instance.
65      * @param message the received message.
66      * @since 2.1
67      */
68     public abstract void onMessage(int instanceID, String message);
69
70     /**
71      * Notify the extension that the sync message is received.
72      * @param instanceID the id of instance.
73      * @param message the received message.
74      * @since 2.1
75      */
76     public abstract String onSyncMessage(int instanceID, String message);
77 }