<commit_before>package org.openlca.app.util;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Composite;
import org.openlca.app.App;
import org.openlca.app.preferencepages.FeatureFlag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

class BrowserFactory {

	private static Logger log = LoggerFactory.getLogger(BrowserFactory.class);

	private static boolean useXulRunner = false;
	private static boolean initialized = false;

	public static Browser create(Composite parent) {
		if (!initialized)
			initialize();
		Browser browser = null;
		if (useXulRunner) {
			log.trace("Create Mozilla browser");
			browser = createMozilla(parent);
		} else {
			log.trace("Create system browser");
			browser = new Browser(parent, SWT.NONE);
		}
		browser.setJavascriptEnabled(true);
		return browser;
	}

	private static void initialize() {
		log.trace("initialize browser factory");
		if (!FeatureFlag.USE_MOZILLA_BROWSER.isEnabled()) {
			useXulRunner = false;
			return;
		}
		try {
			String xulRunnerPath = App.getXulRunnerPath();
			if (xulRunnerPath == null) {
				log.trace("No XUL runner found, use system browser");
				useXulRunner = false;
			} else {
				log.trace("Use Mozilla browser, XUL runner found at {}",
						xulRunnerPath);
				System.setProperty("org.eclipse.swt.browser.XULRunnerPath",
						xulRunnerPath);
				useXulRunner = true;
			}
		} catch (Exception e) {
			log.error("Failed to initialize browser factory");
		} finally {
			initialized = true;
		}
	}

	private static Browser createMozilla(Composite parent) {
		try {
			return new Browser(parent, SWT.MOZILLA);
		} catch (Throwable e) {
			log.warn(
					"Failed to create Mozilla browser, fall back to system default",
					e);
			useXulRunner = false;
			return new Browser(parent, SWT.NONE);
		}
	}

}
<commit_msg>use always embedded XulRunner under Linux<commit_after>package org.openlca.app.util;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Composite;
import org.openlca.app.App;
import org.openlca.app.preferencepages.FeatureFlag;
import org.openlca.util.OS;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

class BrowserFactory {

	private static Logger log = LoggerFactory.getLogger(BrowserFactory.class);

	private static boolean useXulRunner = false;
	private static boolean initialized = false;

	public static Browser create(Composite parent) {
		if (!initialized)
			initialize();
		Browser browser = null;
		if (useXulRunner) {
			log.trace("Create Mozilla browser");
			browser = createMozilla(parent);
		} else {
			log.trace("Create system browser");
			browser = new Browser(parent, SWT.NONE);
		}
		browser.setJavascriptEnabled(true);
		return browser;
	}

	private static void initialize() {
		log.trace("initialize browser factory");
		if (!shouldUseXulRunner()) {
			useXulRunner = false;
			initialized = true;
			return;
		}
		try {
			String xulRunnerPath = App.getXulRunnerPath();
			if (xulRunnerPath == null) {
				log.trace("No XUL runner found, use system browser");
				useXulRunner = false;
			} else {
				log.trace("Use Mozilla browser, XUL runner found at {}",
						xulRunnerPath);
				System.setProperty("org.eclipse.swt.browser.XULRunnerPath",
						xulRunnerPath);
				useXulRunner = true;
			}
		} catch (Exception e) {
			log.error("Failed to initialize browser factory");
		} finally {
			initialized = true;
		}
	}

	private static boolean shouldUseXulRunner() {
		if (OS.getCurrent() == OS.Linux)
			return true;
		else
			return FeatureFlag.USE_MOZILLA_BROWSER.isEnabled();
	}

	private static Browser createMozilla(Composite parent) {
		try {
			return new Browser(parent, SWT.MOZILLA);
		} catch (Throwable e) {
			log.warn(
					"Failed to create Mozilla browser, fall back to system default",
					e);
			useXulRunner = false;
			return new Browser(parent, SWT.NONE);
		}
	}

}

{'fraction_non_alphanumeric': 0.11043256997455471, 'fraction_numerical': 0.0010178117048346056, 'mean_word_length': 3.9076154806491887, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1558610', 'n_tokens_mistral': 1459, 'n_tokens_neox': 1254, 'n_words': 311}