Skip to content

Commit

Permalink
feat(android): allow developers to provide logic for onRenderProcessG…
Browse files Browse the repository at this point in the history
…one in WebViewListener (#6946)
  • Loading branch information
carlpoole authored Oct 6, 2023
1 parent 5b43798 commit 34b724a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.graphics.Bitmap;
import android.net.Uri;
import android.webkit.RenderProcessGoneDetail;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
Expand Down Expand Up @@ -92,4 +93,19 @@ public void onReceivedHttpError(WebView view, WebResourceRequest request, WebRes
view.loadUrl(errorPath);
}
}

@Override
public boolean onRenderProcessGone(WebView view, RenderProcessGoneDetail detail) {
super.onRenderProcessGone(view, detail);
boolean result = false;

List<WebViewListener> webViewListeners = bridge.getWebViewListeners();
if (webViewListeners != null) {
for (WebViewListener listener : bridge.getWebViewListeners()) {
result = listener.onRenderProcessGone(view, detail) || result;
}
}

return result;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.getcapacitor;

import android.webkit.RenderProcessGoneDetail;
import android.webkit.WebView;

/**
Expand Down Expand Up @@ -42,4 +43,15 @@ public void onReceivedHttpError(WebView webView) {
public void onPageStarted(WebView webView) {
// Override me to add behavior to the page started event
}

/**
* Callback for render process gone event. Return true if the state is handled.
*
* @param webView The WebView that loaded
* @return returns false by default if the listener is not overridden and used
*/
public boolean onRenderProcessGone(WebView webView, RenderProcessGoneDetail detail) {
// Override me to add behavior to the web view render process gone event
return false;
}
}

0 comments on commit 34b724a

Please sign in to comment.