Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions desktop/src/cef/context/builder.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use std::path::{Path, PathBuf};

use cef::args::Args;
use cef::sys::{CEF_API_VERSION_LAST, cef_resultcode_t};
use cef::sys::{CEF_API_VERSION_LAST, cef_log_severity_t, cef_resultcode_t};
use cef::{
App, BrowserSettings, CefString, Client, DictionaryValue, ImplCommandLine, ImplRequestContext, RequestContextSettings, SchemeHandlerFactory, Settings, WindowInfo, api_hash,
App, BrowserSettings, CefString, Client, DictionaryValue, ImplCommandLine, ImplRequestContext, LogSeverity, RequestContextSettings, SchemeHandlerFactory, Settings, WindowInfo, api_hash,
browser_host_create_browser_sync, execute_process,
};

Expand Down Expand Up @@ -74,11 +74,24 @@ impl<H: CefEventHandler> CefContextBuilder<H> {
}

fn common_settings(instance_dir: &Path) -> Settings {
let log_severity = match std::env::var("GRAPHITE_BROWSER_LOG") {
Ok(level) => match level.to_lowercase().as_str() {
"debug" => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_VERBOSE),
"info" => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_INFO),
"warn" => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_WARNING),
"error" => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_ERROR),
"none" => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_DISABLE),
_ => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_FATAL),
},
Err(_) => LogSeverity::from(cef_log_severity_t::LOGSEVERITY_FATAL),
};

Settings {
windowless_rendering_enabled: 1,
root_cache_path: instance_dir.to_str().map(CefString::from).unwrap(),
cache_path: CefString::from(""),
disable_signal_handlers: 1,
log_severity,
..Default::default()
}
}
Expand Down
22 changes: 20 additions & 2 deletions desktop/src/cef/internal/browser_process_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,29 @@ impl<H: CefEventHandler> ImplApp for BrowserProcessAppImpl<H> {
cmd.append_switch_with_value(Some(&CefString::from("disk-cache-size")), Some(&CefString::from("0")));
cmd.append_switch(Some(&CefString::from("incognito")));
cmd.append_switch(Some(&CefString::from("no-first-run")));
cmd.append_switch(Some(&CefString::from("no-default-browser-check")));
cmd.append_switch(Some(&CefString::from("disable-component-update")));
cmd.append_switch(Some(&CefString::from("disable-geolocation")));
cmd.append_switch(Some(&CefString::from("disable-notifications")));
cmd.append_switch(Some(&CefString::from("disable-audio-input")));
cmd.append_switch(Some(&CefString::from("disable-audio-output")));
cmd.append_switch(Some(&CefString::from("disable-sync")));
cmd.append_switch(Some(&CefString::from("disable-file-system")));
cmd.append_switch(Some(&CefString::from("disable-local-storage")));
cmd.append_switch(Some(&CefString::from("disable-background-networking")));
cmd.append_switch(Some(&CefString::from("disable-audio-input")));
cmd.append_switch(Some(&CefString::from("disable-audio-output")));
cmd.append_switch(Some(&CefString::from("disable-default-apps")));
cmd.append_switch(Some(&CefString::from("disable-breakpad")));
cmd.append_switch_with_value(Some(&CefString::from("disable-blink-features")), Some(&CefString::from("WebBluetooth,WebUSB,Serial")));

let extra_disabled_features = ["OptimizationHints", "OnDeviceModelService", "TranslateUI"];
let disabled_features_switch = Some(&CefString::from("disable-features"));
let disabled_features: String = CefString::from(&cmd.switch_value(disabled_features_switch))
.to_string()
.split(',')
.chain(extra_disabled_features)
.collect::<Vec<_>>()
.join(",");
cmd.append_switch_with_value(disabled_features_switch, Some(&CefString::from(disabled_features.as_str())));

#[cfg(not(feature = "accelerated_paint"))]
{
Expand Down