am 51e45ff0: Cleanup how a plugin goes full-screen.

Merge commit '51e45ff0d53ce299be316e14e48cdd3e3a51d0b0' into eclair-mr2-plus-aosp

* commit '51e45ff0d53ce299be316e14e48cdd3e3a51d0b0':
  Cleanup how a plugin goes full-screen.
This commit is contained in:
Derek Sollenberger
2009-12-01 06:14:33 -08:00
committed by Android Git Automerger
2 changed files with 21 additions and 18 deletions

View File

@@ -18,18 +18,19 @@ 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;
/**
* 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
*/
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
if (fullScreenSurface == null) {
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);
}

View File

@@ -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);
}