All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.multiplatform.webview.setting.WebSettings.kt Maven / Gradle / Ivy

There is a newer version: 1.9.40-alpha04
Show newest version
package com.multiplatform.webview.setting

import androidx.compose.ui.graphics.Color
import com.multiplatform.webview.util.KLogSeverity
import com.multiplatform.webview.util.KLogger

/**
 * Created By Kevin Zou On 2023/9/20
 */

/**
 * Web settings for different platform
 */
class WebSettings {
    /**
     * Whether the WebView should enable JavaScript execution.
     * Default is true.
     */
    var isJavaScriptEnabled = true

    /**
     * WebView's user-agent string.
     * Default is null.
     */
    var customUserAgentString: String? = null

    /**
     * Set the zoom level of the WebView.
     * Default is 1.0.
     */
    var zoomLevel: Double = 1.0

    /**
     * whether the WebView should support zooming using its on-screen zoom
     * controls and gestures. The default is {@code true}.
     *
     * @param support whether the WebView should support zoom
     */
    var supportZoom: Boolean = true

    /**
     * Whether cross-origin requests in the context of a file scheme URL should be allowed to
     * access content from other file scheme URLs. Note that some accesses such as image HTML
     * elements don't follow same-origin rules and aren't affected by this setting.
     * 

* Don't enable this setting if you open files that may be created or altered by * external sources. Enabling this setting allows malicious scripts loaded in a {@code file://} * context to access arbitrary local files including WebView cookies and app private data. *

* Loading content via {@code file://} URLs is generally discouraged. See the note in * {@link #setAllowFileAccess}. *

* * The default value is false. */ var allowFileAccessFromFileURLs: Boolean = false /** * Whether cross-origin requests in the context of a file scheme URL should be allowed to * access content from any origin. This includes access to content from other file * scheme URLs or web contexts. Note that some access such as image HTML elements doesn't * follow same-origin rules and isn't affected by this setting. *

* Don't enable this setting if you open files that may be created or altered by * external sources. Enabling this setting allows malicious scripts loaded in a {@code file://} * context to launch cross-site scripting attacks, either accessing arbitrary local files * including WebView cookies, app private data or even credentials used on arbitrary web sites. *

* Loading content via {@code file://} URLs is generally discouraged. See the note in * {@link #setAllowFileAccess}. *

* * The default value is false. */ var allowUniversalAccessFromFileURLs: Boolean = false /** * Log severity for the WebView. * Default is [KLogSeverity.Info] */ var logSeverity: KLogSeverity = KLogSeverity.Info set(value) { field = value KLogger.setMinSeverity(value) } /** * The background color of the WebView client. The default value is {@code Color.Transparent}. * Not supported on Desktop platform. */ var backgroundColor = Color.Transparent /** * Android platform specific settings */ val androidWebSettings = PlatformWebSettings.AndroidWebSettings() /** * Desktop platform specific settings */ val desktopWebSettings = PlatformWebSettings.DesktopWebSettings() /** * iOS platform specific settings */ val iOSWebSettings = PlatformWebSettings.IOSWebSettings() }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy