diff options
| -rw-r--r-- | api/current.txt | 6 | ||||
| -rw-r--r-- | api/system-current.txt | 6 | ||||
| -rw-r--r-- | api/test-current.txt | 6 | ||||
| -rw-r--r-- | core/java/android/webkit/RenderProcessGoneDetail.java | 35 | ||||
| -rw-r--r-- | core/java/android/webkit/WebViewClient.java | 27 |
5 files changed, 80 insertions, 0 deletions
diff --git a/api/current.txt b/api/current.txt index f43ce6dc8f3f..4b0750da4066 100644 --- a/api/current.txt +++ b/api/current.txt @@ -45630,6 +45630,11 @@ package android.webkit { method public abstract android.view.View getFullScreenView(int, android.content.Context); } + public abstract class RenderProcessGoneDetail { + ctor public RenderProcessGoneDetail(); + method public abstract boolean didCrash(); + } + public class ServiceWorkerClient { ctor public ServiceWorkerClient(); method public android.webkit.WebResourceResponse shouldInterceptRequest(android.webkit.WebResourceRequest); @@ -46154,6 +46159,7 @@ package android.webkit { method public void onReceivedHttpError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceResponse); method public void onReceivedLoginRequest(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String); method public void onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError); + method public boolean onRenderProcessGone(android.webkit.WebView, android.webkit.RenderProcessGoneDetail); method public void onScaleChanged(android.webkit.WebView, float, float); method public deprecated void onTooManyRedirects(android.webkit.WebView, android.os.Message, android.os.Message); method public void onUnhandledKeyEvent(android.webkit.WebView, android.view.KeyEvent); diff --git a/api/system-current.txt b/api/system-current.txt index f8132044d2ae..dbcc74d5b35d 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -48854,6 +48854,11 @@ package android.webkit { method public abstract android.view.View getFullScreenView(int, android.content.Context); } + public abstract class RenderProcessGoneDetail { + ctor public RenderProcessGoneDetail(); + method public abstract boolean didCrash(); + } + public class ServiceWorkerClient { ctor public ServiceWorkerClient(); method public android.webkit.WebResourceResponse shouldInterceptRequest(android.webkit.WebResourceRequest); @@ -49449,6 +49454,7 @@ package android.webkit { method public void onReceivedHttpError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceResponse); method public void onReceivedLoginRequest(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String); method public void onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError); + method public boolean onRenderProcessGone(android.webkit.WebView, android.webkit.RenderProcessGoneDetail); method public void onScaleChanged(android.webkit.WebView, float, float); method public deprecated void onTooManyRedirects(android.webkit.WebView, android.os.Message, android.os.Message); method public void onUnhandledKeyEvent(android.webkit.WebView, android.view.KeyEvent); diff --git a/api/test-current.txt b/api/test-current.txt index da025ffff1fe..8a82cdfa6afe 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -45877,6 +45877,11 @@ package android.webkit { method public abstract android.view.View getFullScreenView(int, android.content.Context); } + public abstract class RenderProcessGoneDetail { + ctor public RenderProcessGoneDetail(); + method public abstract boolean didCrash(); + } + public class ServiceWorkerClient { ctor public ServiceWorkerClient(); method public android.webkit.WebResourceResponse shouldInterceptRequest(android.webkit.WebResourceRequest); @@ -46401,6 +46406,7 @@ package android.webkit { method public void onReceivedHttpError(android.webkit.WebView, android.webkit.WebResourceRequest, android.webkit.WebResourceResponse); method public void onReceivedLoginRequest(android.webkit.WebView, java.lang.String, java.lang.String, java.lang.String); method public void onReceivedSslError(android.webkit.WebView, android.webkit.SslErrorHandler, android.net.http.SslError); + method public boolean onRenderProcessGone(android.webkit.WebView, android.webkit.RenderProcessGoneDetail); method public void onScaleChanged(android.webkit.WebView, float, float); method public deprecated void onTooManyRedirects(android.webkit.WebView, android.os.Message, android.os.Message); method public void onUnhandledKeyEvent(android.webkit.WebView, android.view.KeyEvent); diff --git a/core/java/android/webkit/RenderProcessGoneDetail.java b/core/java/android/webkit/RenderProcessGoneDetail.java new file mode 100644 index 000000000000..77d85963ce2d --- /dev/null +++ b/core/java/android/webkit/RenderProcessGoneDetail.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2016 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; + +/** + * This class provides more specific information about why the render process + * exited. The application may use this to decide how to handle the situation. + **/ +public abstract class RenderProcessGoneDetail { + /** + * Indicates whether the render process was observed to crash, or whether + * it was killed by the system. + * + * If the render process was killed, this is most likely caused by the + * system being low on memory. + * + * @return True if render process crashed, otherwise it was killed by + * system. + **/ + public abstract boolean didCrash(); +} diff --git a/core/java/android/webkit/WebViewClient.java b/core/java/android/webkit/WebViewClient.java index 76d3fb15d049..8703468a74a7 100644 --- a/core/java/android/webkit/WebViewClient.java +++ b/core/java/android/webkit/WebViewClient.java @@ -466,4 +466,31 @@ public class WebViewClient { public void onReceivedLoginRequest(WebView view, String realm, String account, String args) { } + + /** + * Notify host application that the given webview's render process has exited. + * + * Multiple WebView instances may be associated with a single render process; + * onRenderProcessGone will be called for each WebView that was affected. + * The application's implementation of this callback should only attempt to + * clean up the specific WebView given as a parameter, and should not assume + * that other WebView instances are affected. + * + * The given WebView can't be used, and should be removed from the view hierarchy, + * all references to it should be cleaned up, e.g any references in the Activity + * or other classes saved using findViewById and similar calls, etc + * + * To cause an render process crash for test purpose, the application can + * call loadUrl("chrome://crash") on the WebView. Note that multiple WebView + * instances may be affected if they share a render process, not just the + * specific WebView which loaded chrome://crash. + * + * @param view The WebView which needs to be cleaned up. + * @param detail the reason why it exited. + * @return true if the host application handled the situation that process has + * exited, otherwise, application will crash. + */ + public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) { + return false; + } } |