Skip to content

Commit

Permalink
Migrated code from logic in BaseWebView and added functions onBeforeO…
Browse files Browse the repository at this point in the history
…verridingUrl and onBeforeInterceptRequest
  • Loading branch information
darkryh committed Sep 16, 2024
1 parent 0ff4d48 commit 183914a
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ open class BlockerClient(
*/
val url = request?.url.toString()

/**
* Getting onInterceptingOverridingUrl to have the possibility to
* in case the they need to customize
*/
val onBeforeOverridingUrl = onBeforeOverridingUrl(view, request)
if (onBeforeOverridingUrl != null) return onBeforeOverridingUrl


/**
Expand Down Expand Up @@ -66,7 +72,7 @@ open class BlockerClient(
* return a normal resource
* if not just an empty resource
*/
return onByPassOverridingUrl(view, request) ?: !isPermitted
return !isPermitted
}

/**
Expand All @@ -86,6 +92,15 @@ open class BlockerClient(
val url = request?.url.toString()


/**
* Getting onInterceptingInterceptRequest to have the possibility to
* in case the they need to customize
*/
val onBeforeInterceptRequest = onBeforeInterceptRequest(view, request)

if (onBeforeInterceptRequest != null) return onBeforeInterceptRequest



/**
* Initializing is permitted
Expand Down Expand Up @@ -127,17 +142,18 @@ open class BlockerClient(
* return a normal resource
* if not just an empty resource
*/

return if (isPermitted) super.onPassingInterceptRequest(view, request)
else onByPassInterceptRequest(view, request) ?: emptyResource
else emptyResource
}

/**
* Used to validate, to replace shouldOverrideUrlLoading
*/
protected open fun onByPassOverridingUrl(view: WebView?, request: WebResourceRequest?) : Boolean? = null
protected open fun onBeforeOverridingUrl(view: WebView?, request: WebResourceRequest?) : Boolean? = null

/**
* Used to validate, to replace shouldInterceptRequest
*/
protected open fun onByPassInterceptRequest(view: WebView?, request: WebResourceRequest?) : WebResourceResponse? = null
protected open fun onBeforeInterceptRequest(view: WebView?, request: WebResourceRequest?) : WebResourceResponse? = null
}

0 comments on commit 183914a

Please sign in to comment.