Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / xwalk / runtime / android / core_internal / src / org / xwalk / core / internal / extension / XWalkExtensionContext.java
1 // Copyright (c) 2013 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.internal.extension;
6
7 import android.app.Activity;
8 import android.content.Context;
9
10 /**
11  * Interface for extension context
12  *
13  * It is responsible for maintaining all xwalk extensions and providing a way to
14  * post message to JavaScript side for each xwalk extension.
15  */
16 public interface XWalkExtensionContext {
17     /**
18      * Register an xwalk extension into context.
19      */
20     public void registerExtension(XWalkExtension extension);
21
22     /**
23      * Unregister an xwalk extension with the given unique name from context.
24      */
25     public void unregisterExtension(String name);
26
27     /**
28      * Post a message to the given extension instance.
29      *
30      * @param extension The xwalk extension
31      * @param instanceId The unique id to identify the extension instance as the
32      *                   message destination.
33      * @param message The message content to be posted.
34      */
35     public void postMessage(XWalkExtension extension, int instanceId, String message);
36
37     /**
38      * Broadcast a message to all extension instances.
39      *
40      * @param extension The xwalk extension
41      * @param message The message content to be broadcasted.
42      */
43     public void broadcastMessage(XWalkExtension extension, String message);
44
45     /**
46      * Get current Android Context.
47      * @return the current Android Context.
48      */
49     public Context getContext();
50
51     /**
52      * Get the current Android Activity.
53      * @return the current Android Activity.
54      */
55     public Activity getActivity();
56 }