Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 51e45ff0 authored by Derek Sollenberger's avatar Derek Sollenberger
Browse files

Cleanup how a plugin goes full-screen.

The plugin activity now fetches the plugin's existing java class from native code instead of creating a new one.
parent c3e20af0
Loading
Loading
Loading
Loading
+20 −10
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package android.webkit;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.webkit.plugin.SurfaceDrawingModel;
import android.webkit.plugin.WebkitPlugin;
@@ -28,8 +29,8 @@ import android.webkit.plugin.WebkitPlugin;
 */
public class PluginActivity extends Activity {

    /* package */ static final String INTENT_EXTRA_PACKAGE_NAME =
            "android.webkit.plugin.PACKAGE_NAME";
    private static final String LOGTAG = "PluginActivity";
    
    /* package */ static final String INTENT_EXTRA_NPP_INSTANCE =
            "android.webkit.plugin.NPP_INSTANCE";

@@ -40,24 +41,30 @@ public class PluginActivity extends Activity {

        final Intent intent = getIntent();
        if (intent == null) {
            // No intent means no class to lookup.
            Log.e(LOGTAG, "Unable to retrieve the intent responsible for this activity");
            finish();
            return;
        }
        final String pkgName = intent.getStringExtra(INTENT_EXTRA_PACKAGE_NAME);

        final int npp = intent.getIntExtra(INTENT_EXTRA_NPP_INSTANCE, -1);

        // XXX retrieve the existing object instead of creating a new one
        WebkitPlugin plugin = PluginManager.getInstance(null).getPluginInstance(pkgName, npp);
        if (npp == -1) {
            Log.e(LOGTAG, "The intent did not include the NPP pointer");
            finish();
            return;
        }

        // retrieve the plugin's existing java object instead of creating a new one
        WebkitPlugin plugin = nativeGetWebkitPlugin(npp);

        if (plugin == null) {
            //TODO log error
            Log.e(LOGTAG, "Unable to retrieve the plugin's java interface");
            finish();
            return;
        }
        SurfaceDrawingModel fullScreenSurface = plugin.getFullScreenSurface();
        if (fullScreenSurface == null) {
            //TODO log error
            Log.e(LOGTAG, "The plugin returned a null value for the full-screen interface");
            finish();
            return;
        }
@@ -67,7 +74,10 @@ public class PluginActivity extends Activity {
        } else {
            // No custom full-sreen view returned by the plugin, odd but
            // just in case, finish the activity.
            Log.e(LOGTAG, "The plugin's full-screen interface returned a null view");
            finish();
        }
    }

    native WebkitPlugin nativeGetWebkitPlugin(int npp);
}
+1 −8
Original line number Diff line number Diff line
@@ -2216,19 +2216,12 @@ final class WebViewCore {

    // called by JNI. PluginWidget function to launch an activity and overlays
    // the activity with the View provided by the plugin class.
    private void startFullScreenPluginActivity(String libName, int npp) {
    private void startFullScreenPluginActivity(int npp) {
        if (mWebView == null) {
            return;
        }

        String pkgName = PluginManager.getInstance(null).getPluginsAPKName(libName);
        if (pkgName == null) {
            Log.w(LOGTAG, "Unable to resolve " + libName + " to a plugin APK");
            return;
        }

        Intent intent = new Intent("android.intent.webkit.PLUGIN");
        intent.putExtra(PluginActivity.INTENT_EXTRA_PACKAGE_NAME, pkgName);
        intent.putExtra(PluginActivity.INTENT_EXTRA_NPP_INSTANCE, npp);
        mWebView.getContext().startActivity(intent);
    }