FirefoxProfile constructor
FirefoxProfile({
- Directory? profileDirectory,
Creates a new FirefoxProfile.
If profileDirectory
is passed the files from this directory will be
included in the output generated by toJson.
The files prefs.js
and user.js
are loaded from the directory if they
exist and their settings are added to prefs and userPrefs.
Settings from lockedPrefs are also added to prefs and always take
precedence and can not be overridden or removed.
If profileDirectory
is null
the content returned by toJson only
consists of lockedPrefs as prefs.js
and defaultUserPrefs and the
dynamic updates made with setOption and removeOption as user.js
.
Implementation
FirefoxProfile({this.profileDirectory}) {
_userPrefs.addAll(defaultUserPrefs);
if (profileDirectory != null) {
final prefsFile =
io.File(path.join(profileDirectory!.absolute.path, 'prefs.js'));
if (prefsFile.existsSync()) {
_prefs = loadPrefsFile(prefsFile);
}
final userPrefsFile =
io.File(path.join(profileDirectory!.absolute.path, 'user.js'));
if (userPrefsFile.existsSync()) {
_userPrefs = loadPrefsFile(userPrefsFile)
.where((option) => !lockedPrefs.contains(option))
.toSet();
}
}
_prefs.addAll(lockedPrefs);
}