// Copyright (c) 2013 Intel Corporation. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.xwalk.runtime.extension;

import android.app.Activity;
import android.content.Context;

/**
 * This is a public class to provide context for extensions.
 * It'll be shared by all extensions.
 */
public class XWalkExtensionContextWrapper extends XWalkExtensionContext {
    private XWalkExtensionContext mOriginContext;

    public XWalkExtensionContextWrapper(XWalkExtensionContext context) {
        mOriginContext = context;
    }

    public Object registerExtension(XWalkExtension extension) {
        return mOriginContext.registerExtension(extension);
    }

    public void unregisterExtension(XWalkExtension extension) {
        mOriginContext.unregisterExtension(extension);
    }

    public void postMessage(XWalkExtension extension, String message) {
        mOriginContext.postMessage(extension, message);
    }

    public Context getContext() {
        return mOriginContext.getContext();
    }

    public Activity getActivity() {
        return mOriginContext.getActivity();
    }
}

@@ -351,16 +351,25 @@
  by all 
+external 
 extensio
@@ -1053,40 +1053,324 @@
     
-return mOriginContext.getContext
+// This is very tricky because for external extensions, we should%0A        // use Activity which contains the context for runtime client side.%0A        // mOriginContext.getContext() returns the context of library package,%0A        // e.g., the package context of runtime side.%0A        return mOriginContext.getActivity
 ();%0A

Return the correct context for external extensions