Merge "WebView: Add the definition of crash API."
diff --git a/api/current.txt b/api/current.txt
index ec16f5a..952d39e 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -46136,6 +46136,11 @@
     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);
@@ -46660,6 +46665,7 @@
     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 9d356fc..dce4957 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -49402,6 +49402,11 @@
     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);
@@ -49997,6 +50002,7 @@
     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 d4fb027..be5b48c 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -46432,6 +46432,11 @@
     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);
@@ -46956,6 +46961,7 @@
     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 0000000..77d8596
--- /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 76d3fb1..8703468 100644
--- a/core/java/android/webkit/WebViewClient.java
+++ b/core/java/android/webkit/WebViewClient.java
@@ -466,4 +466,31 @@
     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;
+    }
 }