private void initWebViewSettings()

in framework/src/org/apache/cordova/engine/SystemWebViewEngine.java [146:232]


    private void initWebViewSettings() {
        webView.setInitialScale(0);
        webView.setVerticalScrollBarEnabled(false);
        // Enable JavaScript
        final WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);

        String manufacturer = android.os.Build.MANUFACTURER;
        LOG.d(TAG, "CordovaWebView is running on device made by: " + manufacturer);

        // We don't save any form data in the application
        // @todo remove when Cordova drop API level 26 support
        settings.setSaveFormData(false);

        if (preferences.getBoolean("AndroidInsecureFileModeEnabled", false)) {
            //These settings are deprecated and loading content via file:// URLs is generally discouraged,
            //but we allow this for compatibility reasons
            LOG.d(TAG, "Enabled insecure file access");
            settings.setAllowFileAccess(true);
            settings.setAllowUniversalAccessFromFileURLs(true);
            cookieManager.setAcceptFileSchemeCookies();
        }

        settings.setMediaPlaybackRequiresUserGesture(false);

        // Enable database
        // We keep this disabled because we use or shim to get around DOM_EXCEPTION_ERROR_16
        String databasePath = webView.getContext().getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
        settings.setDatabaseEnabled(true);

        // The default is to use the module's debuggable state to decide if the WebView inspector
        // should be enabled. However, users can configure InspectableWebView preference to forcefully enable
        // or disable the WebView inspector.
        String inspectableWebview = preferences.getString("InspectableWebview", null);
        boolean shouldEnableInspector = false;
        if (inspectableWebview == null) {
            ApplicationInfo appInfo = webView.getContext().getApplicationContext().getApplicationInfo();
            shouldEnableInspector = (appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
        }
        else if ("true".equals(inspectableWebview)) {
            shouldEnableInspector = true;
        }

        if (shouldEnableInspector) {
            enableRemoteDebugging();
        }

        // @todo remove when Cordova drop API level 24 support
        settings.setGeolocationDatabasePath(databasePath);

        // Enable DOM storage
        settings.setDomStorageEnabled(true);

        // Enable built-in geolocation
        settings.setGeolocationEnabled(true);

        // Fix for CB-1405
        // Google issue 4641
        String defaultUserAgent = settings.getUserAgentString();

        // Fix for CB-3360
        String overrideUserAgent = preferences.getString("OverrideUserAgent", null);
        if (overrideUserAgent != null) {
            settings.setUserAgentString(overrideUserAgent);
        } else {
            String appendUserAgent = preferences.getString("AppendUserAgent", null);
            if (appendUserAgent != null) {
                settings.setUserAgentString(defaultUserAgent + " " + appendUserAgent);
            }
        }
        // End CB-3360

        IntentFilter intentFilter = new IntentFilter();
        intentFilter.addAction(Intent.ACTION_CONFIGURATION_CHANGED);
        if (this.receiver == null) {
            this.receiver = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    settings.getUserAgentString();
                }
            };
            webView.getContext().registerReceiver(this.receiver, intentFilter);
        }
        // end CB-1405
    }