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.
5 package org.xwalk.core.internal.extension;
7 import android.app.Activity;
8 import android.content.Context;
11 * Interface for extension context
13 * It is responsible for maintaining all xwalk extensions and providing a way to
14 * post message to JavaScript side for each xwalk extension.
16 public interface XWalkExtensionContext {
18 * Register an xwalk extension into context.
20 public void registerExtension(XWalkExtension extension);
23 * Unregister an xwalk extension with the given unique name from context.
25 public void unregisterExtension(String name);
28 * Post a message to the given extension instance.
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.
35 public void postMessage(XWalkExtension extension, int instanceId, String message);
38 * Broadcast a message to all extension instances.
40 * @param extension The xwalk extension
41 * @param message The message content to be broadcasted.
43 public void broadcastMessage(XWalkExtension extension, String message);
46 * Get current Android Context.
47 * @return the current Android Context.
49 public Context getContext();
52 * Get the current Android Activity.
53 * @return the current Android Activity.
55 public Activity getActivity();