am c3a30a00: Merge change 24153 into eclair
Merge commit 'c3a30a00333910268e2b93c58f14214b074aa929' into eclair-plus-aosp * commit 'c3a30a00333910268e2b93c58f14214b074aa929': adding support for webkit plugins to use the java view system
This commit is contained in:
@@ -165277,6 +165277,51 @@
|
|||||||
</parameter>
|
</parameter>
|
||||||
</method>
|
</method>
|
||||||
</class>
|
</class>
|
||||||
|
<class name="PluginStub"
|
||||||
|
extends="java.lang.Object"
|
||||||
|
abstract="true"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<constructor name="PluginStub"
|
||||||
|
type="android.webkit.PluginStub"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="npp" type="int">
|
||||||
|
</parameter>
|
||||||
|
</constructor>
|
||||||
|
<method name="getEmbeddedView"
|
||||||
|
return="android.view.View"
|
||||||
|
abstract="true"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="context" type="android.content.Context">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
|
<method name="getFullScreenView"
|
||||||
|
return="android.view.View"
|
||||||
|
abstract="true"
|
||||||
|
native="false"
|
||||||
|
synchronized="false"
|
||||||
|
static="false"
|
||||||
|
final="false"
|
||||||
|
deprecated="not deprecated"
|
||||||
|
visibility="public"
|
||||||
|
>
|
||||||
|
<parameter name="context" type="android.content.Context">
|
||||||
|
</parameter>
|
||||||
|
</method>
|
||||||
|
</class>
|
||||||
<class name="SslErrorHandler"
|
<class name="SslErrorHandler"
|
||||||
extends="android.os.Handler"
|
extends="android.os.Handler"
|
||||||
abstract="false"
|
abstract="false"
|
||||||
|
|||||||
67
core/java/android/webkit/PluginActivity.java
Normal file
67
core/java/android/webkit/PluginActivity.java
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package android.webkit;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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";
|
||||||
|
/* package */ static final String INTENT_EXTRA_CLASS_NAME =
|
||||||
|
"android.webkit.plugin.CLASS_NAME";
|
||||||
|
/* package */ static final String INTENT_EXTRA_NPP_INSTANCE =
|
||||||
|
"android.webkit.plugin.NPP_INSTANCE";
|
||||||
|
|
||||||
|
/** Called when the activity is first created. */
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
final Intent intent = getIntent();
|
||||||
|
if (intent == null) {
|
||||||
|
// No intent means no class to lookup.
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
final String packageName =
|
||||||
|
intent.getStringExtra(INTENT_EXTRA_PACKAGE_NAME);
|
||||||
|
final String className = intent.getStringExtra(INTENT_EXTRA_CLASS_NAME);
|
||||||
|
final int npp = intent.getIntExtra(INTENT_EXTRA_NPP_INSTANCE, -1);
|
||||||
|
// Retrieve the PluginStub implemented in packageName.className
|
||||||
|
PluginStub stub =
|
||||||
|
PluginUtil.getPluginStub(this, packageName, className, npp);
|
||||||
|
|
||||||
|
if (stub != null) {
|
||||||
|
View pluginView = stub.getFullScreenView(this);
|
||||||
|
if (pluginView != null) {
|
||||||
|
setContentView(pluginView);
|
||||||
|
} else {
|
||||||
|
// No custom full-sreen view returned by the plugin, odd but
|
||||||
|
// just in case, finish the activity.
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
50
core/java/android/webkit/PluginStub.java
Normal file
50
core/java/android/webkit/PluginStub.java
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package android.webkit;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This abstract class is used to implement plugins in a WebView. A plugin
|
||||||
|
* package may extend this class and implement the abstract functions to create
|
||||||
|
* embedded or fullscreeen views displayed in a WebView. The PluginStub
|
||||||
|
* implementation will be provided the same NPP instance that is created
|
||||||
|
* through the native interface.
|
||||||
|
*/
|
||||||
|
public abstract class PluginStub {
|
||||||
|
/**
|
||||||
|
* Construct a new PluginStub implementation for the given NPP instance.
|
||||||
|
* @param npp The native NPP instance.
|
||||||
|
*/
|
||||||
|
public PluginStub(int npp) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a custom embedded view to draw the plugin.
|
||||||
|
* @param context The current application's Context.
|
||||||
|
* @return A custom View that will be managed by WebView.
|
||||||
|
*/
|
||||||
|
public abstract View getEmbeddedView(Context context);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return a custom full-screen view to be displayed when the user requests
|
||||||
|
* a plugin display as full-screen. Note that the application may choose not
|
||||||
|
* to display this View as completely full-screen.
|
||||||
|
* @param context The current application's Context.
|
||||||
|
* @return A custom View that will be managed by the application.
|
||||||
|
*/
|
||||||
|
public abstract View getFullScreenView(Context context);
|
||||||
|
}
|
||||||
62
core/java/android/webkit/PluginUtil.java
Normal file
62
core/java/android/webkit/PluginUtil.java
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package android.webkit;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
class PluginUtil {
|
||||||
|
|
||||||
|
private static final String LOGTAG = "PluginUtil";
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param packageName the name of the apk where the class can be found
|
||||||
|
* @param className the fully qualified name of a subclass of PluginStub
|
||||||
|
*/
|
||||||
|
/* package */
|
||||||
|
static PluginStub getPluginStub(Context context, String packageName,
|
||||||
|
String className, int NPP) {
|
||||||
|
try {
|
||||||
|
Context pluginContext = context.createPackageContext(packageName,
|
||||||
|
Context.CONTEXT_INCLUDE_CODE |
|
||||||
|
Context.CONTEXT_IGNORE_SECURITY);
|
||||||
|
ClassLoader pluginCL = pluginContext.getClassLoader();
|
||||||
|
|
||||||
|
Class<?> stubClass =
|
||||||
|
pluginCL.loadClass(className);
|
||||||
|
Constructor<?> stubConstructor =
|
||||||
|
stubClass.getConstructor(int.class);
|
||||||
|
Object stubObject = stubConstructor.newInstance(NPP);
|
||||||
|
|
||||||
|
if (stubObject instanceof PluginStub) {
|
||||||
|
return (PluginStub) stubObject;
|
||||||
|
} else {
|
||||||
|
Log.e(LOGTAG, "The plugin class is not of type PluginStub");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Any number of things could have happened. Log the exception and
|
||||||
|
// return null. Careful not to use Log.e(LOGTAG, "String", e)
|
||||||
|
// because that reports the exception to the checkin service.
|
||||||
|
Log.e(LOGTAG, Log.getStackTraceString(e));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user