Skip to content
Merged

fix lint #17496

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import android.webkit.SslErrorHandler
import android.webkit.WebResourceRequest
import android.webkit.WebResourceResponse
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.fragment.app.FragmentManager
import com.owncloud.android.authentication.AuthenticatorActivity
import com.owncloud.android.lib.common.network.AdvancedX509KeyManager
Expand All @@ -28,7 +27,7 @@ import java.security.cert.CertificateException
import java.security.cert.CertificateFactory
import java.security.cert.X509Certificate

open class NextcloudWebViewClient(val supportFragmentManager: FragmentManager) : WebViewClient() {
open class NextcloudWebViewClient(val supportFragmentManager: FragmentManager) : SafeWebViewClient() {

private val tag: String? = NextcloudWebViewClient::class.simpleName

Expand Down
32 changes: 32 additions & 0 deletions app/src/main/java/com/owncloud/android/ui/SafeWebViewClient.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Nextcloud - Android Client
*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
package com.owncloud.android.ui

import android.view.ViewGroup
import android.webkit.RenderProcessGoneDetail
import android.webkit.WebView
import android.webkit.WebViewClient
import com.owncloud.android.lib.common.utils.Log_OC

@Suppress("MissingOnRenderProcessGone")
open class SafeWebViewClient : WebViewClient() {

override fun onRenderProcessGone(view: WebView?, detail: RenderProcessGoneDetail?): Boolean {
Log_OC.e(TAG, "WebView render process gone, did crash: " + detail?.didCrash())

view?.let {
(it.parent as? ViewGroup)?.removeView(it)
it.destroy()
}

return true
}

companion object {
private val TAG = SafeWebViewClient::class.java.simpleName
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.owncloud.android.R;
import com.owncloud.android.ui.SafeWebViewClient;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand Down Expand Up @@ -51,7 +51,7 @@ public View onCreateView(@NonNull LayoutInflater inflater,
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setAllowFileAccess(false);
webView.setWebViewClient(new WebViewClient());
webView.setWebViewClient(new SafeWebViewClient());
webView.loadUrl(mWebUrl);

return v;
Expand Down
Loading