Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e27df4dd authored by Toby Sargeant's avatar Toby Sargeant Committed by Android (Google) Code Review
Browse files

Merge "[wv] Add WebView unresponsive renderer APIs."

parents f5235d22 740b53f0
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -54253,6 +54253,8 @@ package android.webkit {
    method public static java.lang.ClassLoader getWebViewClassLoader();
    method public android.webkit.WebViewClient getWebViewClient();
    method public android.os.Looper getWebViewLooper();
    method public android.webkit.WebViewRenderer getWebViewRenderer();
    method public android.webkit.WebViewRendererClient getWebViewRendererClient();
    method public void goBack();
    method public void goBackOrForward(int);
    method public void goForward();
@@ -54302,6 +54304,8 @@ package android.webkit {
    method public void setWebChromeClient(android.webkit.WebChromeClient);
    method public static void setWebContentsDebuggingEnabled(boolean);
    method public void setWebViewClient(android.webkit.WebViewClient);
    method public void setWebViewRendererClient(java.util.concurrent.Executor, android.webkit.WebViewRendererClient);
    method public void setWebViewRendererClient(android.webkit.WebViewRendererClient);
    method public deprecated boolean shouldDelayChildPressedState();
    method public deprecated boolean showFindDialog(java.lang.String, boolean);
    method public static void startSafeBrowsing(android.content.Context, android.webkit.ValueCallback<java.lang.Boolean>);
@@ -54417,6 +54421,16 @@ package android.webkit {
    method public android.webkit.WebView getWebView();
  }
  public abstract class WebViewRenderer {
    method public abstract boolean terminate();
  }
  public abstract class WebViewRendererClient {
    ctor public WebViewRendererClient();
    method public abstract void onRendererResponsive(android.webkit.WebView, android.webkit.WebViewRenderer);
    method public abstract void onRendererUnresponsive(android.webkit.WebView, android.webkit.WebViewRenderer);
  }
}
package android.widget {
+3 −0
Original line number Diff line number Diff line
@@ -8503,6 +8503,8 @@ package android.webkit {
    method public abstract int getVisibleTitleHeight();
    method public abstract android.webkit.WebChromeClient getWebChromeClient();
    method public abstract android.webkit.WebViewClient getWebViewClient();
    method public abstract android.webkit.WebViewRenderer getWebViewRenderer();
    method public abstract android.webkit.WebViewRendererClient getWebViewRendererClient();
    method public abstract android.view.View getZoomControls();
    method public abstract void goBack();
    method public abstract void goBackOrForward(int);
@@ -8552,6 +8554,7 @@ package android.webkit {
    method public abstract void setVerticalScrollbarOverlay(boolean);
    method public abstract void setWebChromeClient(android.webkit.WebChromeClient);
    method public abstract void setWebViewClient(android.webkit.WebViewClient);
    method public abstract void setWebViewRendererClient(java.util.concurrent.Executor, android.webkit.WebViewRendererClient);
    method public abstract boolean showFindDialog(java.lang.String, boolean);
    method public abstract void stopLoading();
    method public abstract boolean zoomBy(float);
+80 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.webkit;

import android.annotation.CallbackExecutor;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -69,6 +70,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Executor;

/**
 * A View that displays web pages.
@@ -1688,6 +1690,84 @@ public class WebView extends AbsoluteLayout
        return mProvider.getWebViewClient();
    }


    /**
     * Gets the WebView renderer associated with this WebView.
     *
     * <p>In {@link android.os.Build.VERSION_CODES#O} and above, WebView may
     * run in "multiprocess" mode. In multiprocess mode, rendering of web
     * content is performed by a sandboxed renderer process separate to the
     * application process.  This renderer process may be shared with other
     * WebViews in the application, but is not shared with other application
     * processes.
     *
     * <p>If WebView is running in multiprocess mode, this method returns a
     * handle to the renderer process associated with the WebView, which can
     * be used to control the renderer process.
     *
     * @return the {@link WebViewRenderer} renderer handle associated
     *         with this {@link WebView}, or {@code null} if
     *         WebView is not runing in multiprocess mode.
     */
    @Nullable
    public WebViewRenderer getWebViewRenderer() {
        checkThread();
        return mProvider.getWebViewRenderer();
    }

    /**
     * Sets the renderer client object associated with this WebView.
     *
     * <p>The renderer client encapsulates callbacks relevant to WebView renderer
     * state. See {@link WebViewRendererClient} for details.
     *
     * <p>Although many WebView instances may share a single underlying
     * renderer, and renderers may live either in the application
     * process, or in a sandboxed process that is isolated from the
     * application process, instances of {@link WebViewRendererClient}
     * are set per-WebView.  Callbacks represent renderer events from
     * the perspective of this WebView, and may or may not be correlated
     * with renderer events affecting other WebViews.
     *
     * @param executor the Executor on which {@link WebViewRendererClient} callbacks will execute.
     * @param webViewRendererClient the {@link WebViewRendererClient} object.
     */
    public void setWebViewRendererClient(
            @NonNull @CallbackExecutor Executor executor,
            @NonNull WebViewRendererClient webViewRendererClient) {
        checkThread();
        mProvider.setWebViewRendererClient(executor, webViewRendererClient);
    }

    /**
     * Sets the renderer client object associated with this WebView.
     *
     * See {@link #setWebViewRendererClient(Executor,WebViewRendererClient)} for details.
     *
     * <p> {@link WebViewRendererClient} callbacks will run on the thread that this WebView was
     * initialized on.
     *
     * @param webViewRendererClient the {@link WebViewRendererClient} object.
     */
    public void setWebViewRendererClient(
            @Nullable WebViewRendererClient webViewRendererClient) {
        checkThread();
        mProvider.setWebViewRendererClient(null, webViewRendererClient);
    }

    /**
     * Gets the renderer client object associated with this WebView.
     *
     * @return the {@link WebViewRendererClient} object associated with this WebView, if one has
     * been set via {@link #setWebViewRendererClient(WebViewRendererClient)} or {@code null}
     * otherwise.
     */
    @Nullable
    public WebViewRendererClient getWebViewRendererClient() {
        checkThread();
        return mProvider.getWebViewRendererClient();
    }

    /**
     * Registers the interface to be used when content can not be handled by
     * the rendering engine, and should be downloaded instead. This will replace
+9 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import android.webkit.WebView.VisualStateCallback;
import java.io.BufferedWriter;
import java.io.File;
import java.util.Map;
import java.util.concurrent.Executor;

/**
 * WebView backend provider interface: this interface is the abstract backend to a WebView
@@ -237,6 +238,14 @@ public interface WebViewProvider {

    public WebViewClient getWebViewClient();

    public WebViewRenderer getWebViewRenderer();

    public void setWebViewRendererClient(
            @Nullable Executor executor,
            @Nullable WebViewRendererClient client);

    public WebViewRendererClient getWebViewRendererClient();

    public void setDownloadListener(DownloadListener listener);

    public void setWebChromeClient(WebChromeClient client);
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright 2019 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;

/**
 * WebViewRenderer provides an opaque handle to a {@link WebView} renderer.
 */
public abstract class WebViewRenderer {
    /**
     * Cause this renderer to terminate.
     *
     * <p>Calling this on a not yet started, or an already terminated renderer will have no effect.
     *
     * <p>Terminating a renderer process may have an effect on multiple {@link WebView} instances.
     *
     * <p>Renderer termination must be handled by properly overriding
     * {@link WebViewClient#onRenderProcessGone} for every WebView that shares this
     * renderer. If termination is not handled by all associated WebViews, then the application
     * process will also be terminated.
     *
     * @return {@code true} if it was possible to terminate this renderer, {@code false} otherwise.
     */
    public abstract boolean terminate();

    /**
     * This class cannot be created by applications.
     * @hide
     */
    public WebViewRenderer() {
    }
}
Loading