<commit_before>// 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();
    }
}<commit_msg>[Android] Return the correct context for external extensions<commit_after>// 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 external 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() {
        // This is very tricky because for external extensions, we should
        // use Activity which contains the context for runtime client side.
        // mOriginContext.getContext() returns the context of library package,
        // e.g., the package context of runtime side.
        return mOriginContext.getActivity();
    }

    public Activity getActivity() {
        return mOriginContext.getActivity();
    }
}
{'fraction_non_alphanumeric': 0.06981818181818182, 'fraction_numerical': 0.002909090909090909, 'mean_word_length': 3.6469594594594597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7594068', 'n_tokens_mistral': 667, 'n_tokens_neox': 645, 'n_words': 226}