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.app.runtime.extension;
7 import android.app.Activity;
8 import android.content.Context;
9 import android.content.Intent;
10 import android.util.AttributeSet;
11 import android.widget.FrameLayout;
13 import java.lang.reflect.Method;
14 import java.util.StringTokenizer;
15 import java.util.regex.Matcher;
16 import java.util.regex.Pattern;
18 import org.xwalk.app.runtime.CrossPackageWrapper;
21 * This is the extension context used by external extensions. It'll be created
24 public final class XWalkExtensionContextClient extends CrossPackageWrapper {
25 private final static String EXTENSION_CLASS_NAME =
26 "org.xwalk.core.internal.extension.XWalkExtensionContextWrapper";
27 private Object mInstance;
28 private Method mGetContext;
29 private Method mGetActivity;
32 * It's called by runtime side.
34 public XWalkExtensionContextClient(Activity activity, Object instance) {
35 super(activity, EXTENSION_CLASS_NAME, null, String.class, String.class,
39 mGetActivity = lookupMethod("getActivity");
40 mGetContext = lookupMethod("getContext");
44 * Get the current Android Activity. Used by XWalkExtensionClient.
45 * @return the current Android Activity.
47 public Activity getActivity() {
48 return (Activity) invokeMethod(mGetActivity, mInstance);
52 * Get the current Android Context. Used by XWalkExtensionClient.
53 * @return the current Android Context.
55 public Context getContext() {
56 return (Context) invokeMethod(mGetContext, mInstance);
60 * Get the object of the runtime side.
61 * @return the object of the runtime side.
63 public Object getInstance() {