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.
This commit is contained in:
@@ -18,18 +18,19 @@ package android.webkit;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.webkit.plugin.SurfaceDrawingModel;
|
import android.webkit.plugin.SurfaceDrawingModel;
|
||||||
import android.webkit.plugin.WebkitPlugin;
|
import android.webkit.plugin.WebkitPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This activity is invoked when a plugin elects to go into full screen mode.
|
* This activity is invoked when a plugin elects to go into full screen mode.
|
||||||
* @hide
|
* @hide
|
||||||
*/
|
*/
|
||||||
public class PluginActivity extends Activity {
|
public class PluginActivity extends Activity {
|
||||||
|
|
||||||
/* package */ static final String INTENT_EXTRA_PACKAGE_NAME =
|
private static final String LOGTAG = "PluginActivity";
|
||||||
"android.webkit.plugin.PACKAGE_NAME";
|
|
||||||
/* package */ static final String INTENT_EXTRA_NPP_INSTANCE =
|
/* package */ static final String INTENT_EXTRA_NPP_INSTANCE =
|
||||||
"android.webkit.plugin.NPP_INSTANCE";
|
"android.webkit.plugin.NPP_INSTANCE";
|
||||||
|
|
||||||
@@ -40,24 +41,30 @@ public class PluginActivity extends Activity {
|
|||||||
|
|
||||||
final Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
if (intent == null) {
|
if (intent == null) {
|
||||||
// No intent means no class to lookup.
|
Log.e(LOGTAG, "Unable to retrieve the intent responsible for this activity");
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final String pkgName = intent.getStringExtra(INTENT_EXTRA_PACKAGE_NAME);
|
|
||||||
final int npp = intent.getIntExtra(INTENT_EXTRA_NPP_INSTANCE, -1);
|
final int npp = intent.getIntExtra(INTENT_EXTRA_NPP_INSTANCE, -1);
|
||||||
|
|
||||||
// XXX retrieve the existing object instead of creating a new one
|
if (npp == -1) {
|
||||||
WebkitPlugin plugin = PluginManager.getInstance(null).getPluginInstance(pkgName, npp);
|
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) {
|
if (plugin == null) {
|
||||||
//TODO log error
|
Log.e(LOGTAG, "Unable to retrieve the plugin's java interface");
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SurfaceDrawingModel fullScreenSurface = plugin.getFullScreenSurface();
|
SurfaceDrawingModel fullScreenSurface = plugin.getFullScreenSurface();
|
||||||
if(fullScreenSurface == null) {
|
if (fullScreenSurface == null) {
|
||||||
//TODO log error
|
Log.e(LOGTAG, "The plugin returned a null value for the full-screen interface");
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -67,7 +74,10 @@ public class PluginActivity extends Activity {
|
|||||||
} else {
|
} else {
|
||||||
// No custom full-sreen view returned by the plugin, odd but
|
// No custom full-sreen view returned by the plugin, odd but
|
||||||
// just in case, finish the activity.
|
// just in case, finish the activity.
|
||||||
|
Log.e(LOGTAG, "The plugin's full-screen interface returned a null view");
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
native WebkitPlugin nativeGetWebkitPlugin(int npp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2216,19 +2216,12 @@ final class WebViewCore {
|
|||||||
|
|
||||||
// called by JNI. PluginWidget function to launch an activity and overlays
|
// called by JNI. PluginWidget function to launch an activity and overlays
|
||||||
// the activity with the View provided by the plugin class.
|
// 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) {
|
if (mWebView == null) {
|
||||||
return;
|
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 intent = new Intent("android.intent.webkit.PLUGIN");
|
||||||
intent.putExtra(PluginActivity.INTENT_EXTRA_PACKAGE_NAME, pkgName);
|
|
||||||
intent.putExtra(PluginActivity.INTENT_EXTRA_NPP_INSTANCE, npp);
|
intent.putExtra(PluginActivity.INTENT_EXTRA_NPP_INSTANCE, npp);
|
||||||
mWebView.getContext().startActivity(intent);
|
mWebView.getContext().startActivity(intent);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user