FileDocCategorySizeDatePackage
WebViewDelegate.javaAPI DocAndroid 5.1 API5848Thu Mar 12 22:22:10 GMT 2015android.webkit

WebViewDelegate

public final class WebViewDelegate extends Object
Delegate used by the WebView provider implementation to access the required framework functionality needed to implement a {@link WebView}.
hide

Fields Summary
Constructors Summary
WebViewDelegate()

 
Methods Summary
public voidaddWebViewAssetPath(android.content.Context context)
Adds the WebView asset path to {@link AssetManager}.

        context.getAssets().addAssetPath(
                WebViewFactory.getLoadedPackageInfo().applicationInfo.sourceDir);
    
public voidcallDrawGlFunction(android.graphics.Canvas canvas, long nativeDrawGLFunctor)
Calls the function specified with the nativeDrawGLFunctor functor pointer. This functionality is used by the WebView for calling into their renderer from the framework display lists.

param
canvas a hardware accelerated canvas (see {@link Canvas#isHardwareAccelerated()})
param
nativeDrawGLFunctor the pointer to the native functor that implements system/core/include/utils/Functor.h
throws
IllegalArgumentException if the canvas is not hardware accelerated

        if (!(canvas instanceof HardwareCanvas)) {
            // Canvas#isHardwareAccelerated() is only true for subclasses of HardwareCanvas.
            throw new IllegalArgumentException(canvas.getClass().getName()
                    + " is not hardware accelerated");
        }
        ((HardwareCanvas) canvas).callDrawGLFunction2(nativeDrawGLFunctor);
    
public booleancanInvokeDrawGlFunctor(android.view.View containerView)
Returns true if the draw GL functor can be invoked (see {@link #invokeDrawGlFunctor}) and false otherwise.

        ViewRootImpl viewRootImpl = containerView.getViewRootImpl();
         // viewRootImpl can be null during teardown when window is leaked.
        return viewRootImpl != null;
    
public voiddetachDrawGlFunctor(android.view.View containerView, long nativeDrawGLFunctor)
Detaches the draw GL functor.

param
nativeDrawGLFunctor the pointer to the native functor that implements system/core/include/utils/Functor.h

        ViewRootImpl viewRootImpl = containerView.getViewRootImpl();
        if (nativeDrawGLFunctor != 0 && viewRootImpl != null) {
            viewRootImpl.detachFunctor(nativeDrawGLFunctor);
        }
    
public android.app.ApplicationgetApplication()
Returns the application which is embedding the WebView.

        return ActivityThread.currentApplication();
    
public java.lang.StringgetErrorString(android.content.Context context, int errorCode)
Returns the error string for the given {@code errorCode}.

        return ErrorStrings.getString(errorCode, context);
    
public intgetPackageId(android.content.res.Resources resources, java.lang.String packageName)
Returns the package id of the given {@code packageName}.

        SparseArray<String> packageIdentifiers =
                resources.getAssets().getAssignedPackageIdentifiers();
        for (int i = 0; i < packageIdentifiers.size(); i++) {
            final String name = packageIdentifiers.valueAt(i);

            if (packageName.equals(name)) {
                return packageIdentifiers.keyAt(i);
            }
        }
        throw new RuntimeException("Package not found: " + packageName);
    
public voidinvokeDrawGlFunctor(android.view.View containerView, long nativeDrawGLFunctor, boolean waitForCompletion)
Invokes the draw GL functor. If waitForCompletion is false the functor may be invoked asynchronously.

param
nativeDrawGLFunctor the pointer to the native functor that implements system/core/include/utils/Functor.h

        ViewRootImpl viewRootImpl = containerView.getViewRootImpl();
        viewRootImpl.invokeFunctor(nativeDrawGLFunctor, waitForCompletion);
    
public booleanisTraceTagEnabled()
Returns true if the WebView trace tag is enabled and false otherwise.

        return Trace.isTagEnabled(Trace.TRACE_TAG_WEBVIEW);
    
public voidsetOnTraceEnabledChangeListener(android.webkit.WebViewDelegate$OnTraceEnabledChangeListener listener)
Register a callback to be invoked when tracing for the WebView component has been enabled/disabled.

        SystemProperties.addChangeCallback(new Runnable() {
            @Override
            public void run() {
                listener.onTraceEnabledChange(isTraceTagEnabled());
            }
        });