public class

WebkitToCompatConverter

extends java.lang.Object

 java.lang.Object

↳androidx.webkit.internal.WebkitToCompatConverter

Gradle dependencies

compile group: 'androidx.webkit', name: 'webkit', version: '1.5.0-alpha01'

  • groupId: androidx.webkit
  • artifactId: webkit
  • version: 1.5.0-alpha01

Artifact androidx.webkit:webkit:1.5.0-alpha01 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.webkit:webkit com.android.support:webkit

Overview

A class providing functionality for converting android.webkit classes into support library classes.

Summary

Constructors
publicWebkitToCompatConverter(org.chromium.support_lib_boundary.WebkitToCompatConverterBoundaryInterface impl)

Methods
public SafeBrowsingResponseconvertSafeBrowsingResponse(java.lang.reflect.InvocationHandler safeBrowsingResponse)

Convert from an java.lang.reflect.InvocationHandler representing a SafeBrowsingResponseCompat into a .

public java.lang.reflect.InvocationHandlerconvertSafeBrowsingResponse(SafeBrowsingResponse safeBrowsingResponse)

Return an java.lang.reflect.InvocationHandler linked to the given such that calls on either of those objects affect the other object.

public ServiceWorkerWebSettingsconvertServiceWorkerSettings(java.lang.reflect.InvocationHandler serviceWorkerSettings)

Convert from an java.lang.reflect.InvocationHandler representing an ServiceWorkerWebSettingsCompat into a .

public java.lang.reflect.InvocationHandlerconvertServiceWorkerSettings(ServiceWorkerWebSettings settings)

Return a org.chromium.support_lib_boundary.ServiceWorkerWebSettingsBoundaryInterface linked to the given such that calls on either of those objects affect the other object.

public WebSettingsAdapterconvertSettings(WebSettings webSettings)

Return a WebSettingsAdapter linked to webSettings such that calls on either of those objects affect the other object.

public WebMessagePortconvertWebMessagePort(java.lang.reflect.InvocationHandler webMessagePort)

Convert from an java.lang.reflect.InvocationHandler representing a WebResourceErrorCompat into a .

public java.lang.reflect.InvocationHandlerconvertWebMessagePort(WebMessagePort webMessagePort)

Return a java.lang.reflect.InvocationHandler linked to the given such that calls on either of those objects affect the other object.

public WebResourceErrorconvertWebResourceError(java.lang.reflect.InvocationHandler webResourceError)

Convert from an java.lang.reflect.InvocationHandler representing a WebResourceErrorCompat into a .

public java.lang.reflect.InvocationHandlerconvertWebResourceError(WebResourceError webResourceError)

Return a java.lang.reflect.InvocationHandler linked to the given such that calls on either of those objects affect the other object.

public WebResourceRequestAdapterconvertWebResourceRequest(WebResourceRequest request)

Return a WebResourceRequestAdapter linked to the given so that calls on either of those objects affect the other object.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public WebkitToCompatConverter(org.chromium.support_lib_boundary.WebkitToCompatConverterBoundaryInterface impl)

Methods

public WebSettingsAdapter convertSettings(WebSettings webSettings)

Return a WebSettingsAdapter linked to webSettings such that calls on either of those objects affect the other object. That WebSettingsAdapter can be used to implement WebSettingsCompat.

public WebResourceRequestAdapter convertWebResourceRequest(WebResourceRequest request)

Return a WebResourceRequestAdapter linked to the given so that calls on either of those objects affect the other object.

public java.lang.reflect.InvocationHandler convertServiceWorkerSettings(ServiceWorkerWebSettings settings)

Return a org.chromium.support_lib_boundary.ServiceWorkerWebSettingsBoundaryInterface linked to the given such that calls on either of those objects affect the other object.

public ServiceWorkerWebSettings convertServiceWorkerSettings(java.lang.reflect.InvocationHandler serviceWorkerSettings)

Convert from an java.lang.reflect.InvocationHandler representing an ServiceWorkerWebSettingsCompat into a .

public java.lang.reflect.InvocationHandler convertWebResourceError(WebResourceError webResourceError)

Return a java.lang.reflect.InvocationHandler linked to the given such that calls on either of those objects affect the other object.

public WebResourceError convertWebResourceError(java.lang.reflect.InvocationHandler webResourceError)

Convert from an java.lang.reflect.InvocationHandler representing a WebResourceErrorCompat into a .

public java.lang.reflect.InvocationHandler convertSafeBrowsingResponse(SafeBrowsingResponse safeBrowsingResponse)

Return an java.lang.reflect.InvocationHandler linked to the given such that calls on either of those objects affect the other object.

public SafeBrowsingResponse convertSafeBrowsingResponse(java.lang.reflect.InvocationHandler safeBrowsingResponse)

Convert from an java.lang.reflect.InvocationHandler representing a SafeBrowsingResponseCompat into a .

public java.lang.reflect.InvocationHandler convertWebMessagePort(WebMessagePort webMessagePort)

Return a java.lang.reflect.InvocationHandler linked to the given such that calls on either of those objects affect the other object.

public WebMessagePort convertWebMessagePort(java.lang.reflect.InvocationHandler webMessagePort)

Convert from an java.lang.reflect.InvocationHandler representing a WebResourceErrorCompat into a .

Source

/*
 * Copyright 2018 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 androidx.webkit.internal;

import android.webkit.SafeBrowsingResponse;
import android.webkit.ServiceWorkerWebSettings;
import android.webkit.WebMessagePort;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;

import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.webkit.SafeBrowsingResponseCompat;
import androidx.webkit.WebResourceErrorCompat;

import org.chromium.support_lib_boundary.ServiceWorkerWebSettingsBoundaryInterface;
import org.chromium.support_lib_boundary.WebResourceRequestBoundaryInterface;
import org.chromium.support_lib_boundary.WebSettingsBoundaryInterface;
import org.chromium.support_lib_boundary.WebkitToCompatConverterBoundaryInterface;
import org.chromium.support_lib_boundary.util.BoundaryInterfaceReflectionUtil;

import java.lang.reflect.InvocationHandler;

/**
 * A class providing functionality for converting android.webkit classes into support library
 * classes.
 */
public class WebkitToCompatConverter {
    private final WebkitToCompatConverterBoundaryInterface mImpl;

    public WebkitToCompatConverter(@NonNull WebkitToCompatConverterBoundaryInterface impl) {
        mImpl = impl;
    }

    /**
     * Return a WebSettingsAdapter linked to webSettings such that calls on either of those
     * objects affect the other object. That WebSettingsAdapter can be used to implement
     * {@link androidx.webkit.WebSettingsCompat}.
     */
    @NonNull
    public WebSettingsAdapter convertSettings(@NonNull WebSettings webSettings) {
        return new WebSettingsAdapter(BoundaryInterfaceReflectionUtil.castToSuppLibClass(
                WebSettingsBoundaryInterface.class, mImpl.convertSettings(webSettings)));
    }

    /**
     * Return a {@link WebResourceRequestAdapter} linked to the given {@link WebResourceRequest} so
     * that calls on either of those objects affect the other object.
     */
    @NonNull
    public WebResourceRequestAdapter convertWebResourceRequest(
            @NonNull WebResourceRequest request) {
        return new WebResourceRequestAdapter(BoundaryInterfaceReflectionUtil.castToSuppLibClass(
                WebResourceRequestBoundaryInterface.class,
                mImpl.convertWebResourceRequest(request)));
    }

    /**
     * Return a {@link ServiceWorkerWebSettingsBoundaryInterface} linked to the given
     * {@link ServiceWorkerWebSettings} such that calls on either of those objects affect the other
     * object.
     */
    @NonNull
    public InvocationHandler convertServiceWorkerSettings(
            @NonNull ServiceWorkerWebSettings settings) {
        return mImpl.convertServiceWorkerSettings(settings);
    }

    /**
     * Convert from an {@link InvocationHandler} representing an
     * {@link androidx.webkit.ServiceWorkerWebSettingsCompat} into a
     * {@link ServiceWorkerWebSettings}.
     */
    @RequiresApi(24)
    @NonNull
    public ServiceWorkerWebSettings convertServiceWorkerSettings(
            @NonNull /* SupportLibServiceWorkerSettings */ InvocationHandler
            serviceWorkerSettings) {
        return (ServiceWorkerWebSettings) mImpl.convertServiceWorkerSettings(serviceWorkerSettings);
    }

    /**
     * Return a {@link InvocationHandler} linked to the given
     * {@link WebResourceError}such that calls on either of those objects affect the other
     * object.
     */
    @NonNull
    public InvocationHandler convertWebResourceError(@NonNull WebResourceError webResourceError) {
        return mImpl.convertWebResourceError(webResourceError);
    }


    /**
     * Convert from an {@link InvocationHandler} representing a {@link WebResourceErrorCompat} into
     * a {@link WebResourceError}.
     */
    @RequiresApi(23)
    @NonNull
    public WebResourceError convertWebResourceError(
            @NonNull /* SupportLibWebResourceError */ InvocationHandler webResourceError) {
        return (WebResourceError) mImpl.convertWebResourceError(webResourceError);
    }

    /**
     * Return an {@link InvocationHandler} linked to the given
     * {@link SafeBrowsingResponse} such that calls on either of those objects affect the other
     * object.
     */
    @NonNull
    public InvocationHandler convertSafeBrowsingResponse(
            @NonNull SafeBrowsingResponse safeBrowsingResponse) {
        return mImpl.convertSafeBrowsingResponse(safeBrowsingResponse);
    }


    /**
     * Convert from an {@link InvocationHandler} representing a {@link SafeBrowsingResponseCompat}
     * into a {@link SafeBrowsingResponse}.
     */
    @RequiresApi(27)
    @NonNull
    public SafeBrowsingResponse convertSafeBrowsingResponse(
            @NonNull /* SupportLibSafeBrowsingResponse */ InvocationHandler safeBrowsingResponse) {
        return (SafeBrowsingResponse) mImpl.convertSafeBrowsingResponse(safeBrowsingResponse);
    }

    /**
     * Return a {@link InvocationHandler} linked to the given
     * {@link WebResourceError} such that calls on either of those objects affect the other
     * object.
     */
    @NonNull
    public InvocationHandler convertWebMessagePort(@NonNull WebMessagePort webMessagePort) {
        return mImpl.convertWebMessagePort(webMessagePort);
    }


    /**
     * Convert from an {@link InvocationHandler} representing a {@link WebResourceErrorCompat} into
     * a {@link WebResourceError}.
     */
    @RequiresApi(23)
    @NonNull
    public WebMessagePort convertWebMessagePort(
            @NonNull /* SupportLibWebMessagePort */ InvocationHandler webMessagePort) {
        return (WebMessagePort) mImpl.convertWebMessagePort(webMessagePort);
    }
}