]> gitweb.stoutner.com Git - PrivacyBrowserAndroid.git/blobdiff - app/src/main/java/com/stoutner/privacybrowser/viewmodels/WebViewSource.kt
Allow View Source to connect to untrusted SSL certificates. https://redmine.stoutner...
[PrivacyBrowserAndroid.git] / app / src / main / java / com / stoutner / privacybrowser / viewmodels / WebViewSource.kt
index 6d650b0cb8f0a48069970f86d729bebd4b47296c..3251d92048038fe6cc9f90d75ad85454741dfd26 100644 (file)
@@ -19,6 +19,7 @@
 
 package com.stoutner.privacybrowser.viewmodels
 
+import android.content.ContentResolver
 import android.text.SpannableStringBuilder
 
 import androidx.lifecycle.LiveData
@@ -30,7 +31,7 @@ import com.stoutner.privacybrowser.backgroundtasks.GetSourceBackgroundTask
 import java.net.Proxy
 import java.util.concurrent.ExecutorService
 
-class WebViewSource(private val urlString: String, private val userAgent: String, private val localeString: String, private val proxy: Proxy,
+class WebViewSource(private val urlString: String, private val userAgent: String, private val localeString: String, private val proxy: Proxy, private val contentResolver: ContentResolver,
                     private val executorService: ExecutorService): ViewModel() {
     // Initialize the mutable live data variables.
     private val mutableLiveDataSourceStringArray = MutableLiveData<Array<SpannableStringBuilder>>()
@@ -42,7 +43,8 @@ class WebViewSource(private val urlString: String, private val userAgent: String
         val getSourceBackgroundTask = GetSourceBackgroundTask()
 
         // Get the source.
-        executorService.execute { mutableLiveDataSourceStringArray.postValue(getSourceBackgroundTask.acquire(urlString, userAgent, localeString, proxy, this)) }
+        executorService.execute { mutableLiveDataSourceStringArray.postValue(getSourceBackgroundTask.acquire(urlString, userAgent, localeString, proxy, contentResolver, this,
+            false)) }
     }
 
     // The source observer.
@@ -64,7 +66,7 @@ class WebViewSource(private val urlString: String, private val userAgent: String
     }
 
     // The workhorse that gets the source.
-    fun updateSource(urlString: String) {
+    fun updateSource(urlString: String, ignoreSslErrors: Boolean) {
         // Reset the mutable live data error string.  This prevents the snackbar from displaying later if the activity restarts.
         mutableLiveDataErrorString.postValue("")
 
@@ -72,6 +74,7 @@ class WebViewSource(private val urlString: String, private val userAgent: String
         val getSourceBackgroundTask = GetSourceBackgroundTask()
 
         // Get the source.
-        executorService.execute { mutableLiveDataSourceStringArray.postValue(getSourceBackgroundTask.acquire(urlString, userAgent, localeString, proxy, this)) }
+        executorService.execute { mutableLiveDataSourceStringArray.postValue(getSourceBackgroundTask.acquire(urlString, userAgent, localeString, proxy, contentResolver, this,
+            ignoreSslErrors)) }
     }
 }
\ No newline at end of file