|
1 | | -#[cfg(target_os = "linux")] |
2 | | -use std::env; |
3 | | - |
4 | 1 | use cef::rc::{Rc, RcImpl}; |
5 | 2 | use cef::sys::{_cef_app_t, cef_base_ref_counted_t}; |
6 | 3 | use cef::{BrowserProcessHandler, CefString, ImplApp, ImplCommandLine, SchemeRegistrar, WrapApp}; |
@@ -33,81 +30,71 @@ impl<H: CefEventHandler> ImplApp for BrowserProcessAppImpl<H> { |
33 | 30 |
|
34 | 31 | fn on_before_command_line_processing(&self, _process_type: Option<&cef::CefString>, command_line: Option<&mut cef::CommandLine>) { |
35 | 32 | if let Some(cmd) = command_line { |
36 | | - cmd.append_switch_with_value(Some(&CefString::from("renderer-process-limit")), Some(&CefString::from("1"))); |
37 | | - cmd.append_switch_with_value(Some(&CefString::from("password-store")), Some(&CefString::from("basic"))); |
38 | | - cmd.append_switch_with_value(Some(&CefString::from("disk-cache-size")), Some(&CefString::from("0"))); |
39 | | - cmd.append_switch(Some(&CefString::from("incognito"))); |
40 | | - cmd.append_switch(Some(&CefString::from("no-first-run"))); |
41 | | - cmd.append_switch(Some(&CefString::from("no-default-browser-check"))); |
42 | | - cmd.append_switch(Some(&CefString::from("disable-component-update"))); |
43 | | - cmd.append_switch(Some(&CefString::from("disable-geolocation"))); |
44 | | - cmd.append_switch(Some(&CefString::from("disable-notifications"))); |
45 | | - cmd.append_switch(Some(&CefString::from("disable-audio-input"))); |
46 | | - cmd.append_switch(Some(&CefString::from("disable-audio-output"))); |
47 | | - cmd.append_switch(Some(&CefString::from("disable-sync"))); |
48 | | - cmd.append_switch(Some(&CefString::from("disable-file-system"))); |
49 | | - cmd.append_switch(Some(&CefString::from("disable-local-storage"))); |
50 | | - cmd.append_switch(Some(&CefString::from("disable-background-networking"))); |
51 | | - cmd.append_switch(Some(&CefString::from("disable-default-apps"))); |
52 | | - cmd.append_switch(Some(&CefString::from("disable-breakpad"))); |
53 | | - cmd.append_switch_with_value(Some(&CefString::from("disable-blink-features")), Some(&CefString::from("WebBluetooth,WebUSB,Serial"))); |
| 33 | + cmd.append_switch_with_value(Some(&"renderer-process-limit".into()), Some(&"1".into())); |
| 34 | + cmd.append_switch_with_value(Some(&"password-store".into()), Some(&"basic".into())); |
| 35 | + cmd.append_switch_with_value(Some(&"disk-cache-size".into()), Some(&"0".into())); |
| 36 | + cmd.append_switch(Some(&"no-sandbox".into())); |
| 37 | + cmd.append_switch(Some(&"no-first-run".into())); |
| 38 | + cmd.append_switch(Some(&"noerrdialogs".into())); |
| 39 | + cmd.append_switch(Some(&"no-default-browser-check".into())); |
| 40 | + cmd.append_switch(Some(&"mute-audio".into())); |
| 41 | + cmd.append_switch(Some(&"use-fake-device-for-media-stream".into())); |
| 42 | + cmd.append_switch(Some(&"incognito".into())); |
| 43 | + cmd.append_switch(Some(&"disable-sync".into())); |
| 44 | + cmd.append_switch(Some(&"disable-file-system".into())); |
| 45 | + cmd.append_switch(Some(&"disable-component-update".into())); |
| 46 | + cmd.append_switch(Some(&"disable-geolocation".into())); |
| 47 | + cmd.append_switch(Some(&"disable-notifications".into())); |
| 48 | + cmd.append_switch(Some(&"disable-background-networking".into())); |
| 49 | + cmd.append_switch(Some(&"disable-default-apps".into())); |
| 50 | + cmd.append_switch(Some(&"disable-breakpad".into())); |
| 51 | + cmd.append_switch_with_value(Some(&"disable-blink-features".into()), Some(&"WebBluetooth,WebUSB,Serial".into())); |
54 | 52 |
|
55 | 53 | let extra_disabled_features = ["OptimizationHints", "OnDeviceModelService", "TranslateUI"]; |
56 | | - let disabled_features_switch = Some(&CefString::from("disable-features")); |
| 54 | + let disabled_features_switch = Some(&"disable-features".into()); |
57 | 55 | let disabled_features: String = CefString::from(&cmd.switch_value(disabled_features_switch)) |
58 | 56 | .to_string() |
59 | 57 | .split(',') |
60 | 58 | .chain(extra_disabled_features) |
61 | 59 | .collect::<Vec<_>>() |
62 | 60 | .join(","); |
63 | | - cmd.append_switch_with_value(disabled_features_switch, Some(&CefString::from(disabled_features.as_str()))); |
| 61 | + cmd.append_switch_with_value(disabled_features_switch, Some(&disabled_features.as_str().into())); |
64 | 62 |
|
65 | 63 | #[cfg(not(feature = "accelerated_paint"))] |
66 | 64 | { |
67 | 65 | // Disable GPU acceleration when accelerated_paint feature is not enabled |
68 | | - cmd.append_switch(Some(&CefString::from("disable-gpu"))); |
69 | | - cmd.append_switch(Some(&CefString::from("disable-gpu-compositing"))); |
| 66 | + cmd.append_switch(Some(&"disable-gpu".into())); |
| 67 | + cmd.append_switch(Some(&"disable-gpu-compositing".into())); |
70 | 68 | } |
71 | 69 |
|
72 | 70 | #[cfg(feature = "accelerated_paint")] |
73 | 71 | { |
74 | | - // Enable GPU acceleration switches for better performance |
75 | | - cmd.append_switch(Some(&CefString::from("enable-gpu-rasterization"))); |
76 | | - cmd.append_switch(Some(&CefString::from("enable-accelerated-2d-canvas"))); |
| 72 | + // cmd.append_switch(Some(&"transparent-painting-enabled".into())); |
| 73 | + cmd.append_switch(Some(&"enable-zero-copy".into())); |
| 74 | + // cmd.append_switch(Some(&"off-screen-rendering-enabled".into())); |
| 75 | + // cmd.append_switch(Some(&"use-views".into())); |
| 76 | + cmd.append_switch(Some(&"enable-gpu-rasterization".into())); |
| 77 | + cmd.append_switch(Some(&"enable-accelerated-2d-canvas".into())); |
77 | 78 | } |
78 | 79 |
|
79 | 80 | #[cfg(all(feature = "accelerated_paint", target_os = "linux"))] |
80 | 81 | { |
81 | | - // Use Vulkan for accelerated painting |
82 | | - cmd.append_switch_with_value(Some(&CefString::from("use-angle")), Some(&CefString::from("vulkan"))); |
83 | | - } |
84 | | - |
85 | | - // Tell CEF to use Wayland if available |
86 | | - #[cfg(target_os = "linux")] |
87 | | - { |
88 | | - let use_wayland = env::var("WAYLAND_DISPLAY") |
89 | | - .ok() |
90 | | - .filter(|var| !var.is_empty()) |
91 | | - .or_else(|| env::var("WAYLAND_SOCKET").ok()) |
92 | | - .filter(|var| !var.is_empty()) |
93 | | - .is_some(); |
94 | | - if use_wayland { |
95 | | - cmd.append_switch_with_value(Some(&CefString::from("ozone-platform")), Some(&CefString::from("wayland"))); |
96 | | - } |
| 82 | + cmd.append_switch_with_value(Some(&"use-angle".into()), Some(&"gl-egl".into())); |
| 83 | + cmd.append_switch_with_value(Some(&"ozone-platform".into()), Some(&"headless".into())); |
97 | 84 | } |
98 | 85 |
|
99 | 86 | #[cfg(target_os = "macos")] |
100 | 87 | { |
101 | 88 | // Hide user prompt asking for keychain access |
102 | | - cmd.append_switch(Some(&CefString::from("use-mock-keychain"))); |
| 89 | + cmd.append_switch(Some(&"use-mock-keychain".into())); |
103 | 90 | } |
104 | 91 |
|
105 | 92 | // Enable browser debugging via environment variable |
106 | 93 | if let Some(env) = std::env::var("GRAPHITE_BROWSER_DEBUG_PORT").ok() |
107 | 94 | && let Some(port) = env.parse::<u16>().ok() |
108 | 95 | { |
109 | | - cmd.append_switch_with_value(Some(&CefString::from("remote-debugging-port")), Some(&CefString::from(port.to_string().as_str()))); |
110 | | - cmd.append_switch_with_value(Some(&CefString::from("remote-allow-origins")), Some(&CefString::from("*"))); |
| 96 | + cmd.append_switch_with_value(Some(&"remote-debugging-port".into()), Some(&port.to_string().as_str().into())); |
| 97 | + cmd.append_switch_with_value(Some(&"remote-allow-origins".into()), Some(&"*".into())); |
111 | 98 | } |
112 | 99 | } |
113 | 100 | } |
|
0 commit comments