## Summary
- Add CommandLineConfig struct for CEF command line switches
- Use direct struct initialization with optional helper methods
- Change default to secure: only use-mock-keychain enabled on macOS debug builds
- Add comprehensive documentation with usage examples
## Usage
```rust
use bevy_cef::prelude::*;
// Default (secure, includes use-mock-keychain on macOS debug)
app.add_plugins((DefaultPlugins, CefPlugin::default()));
// Add switches while preserving defaults (recommended)
app.add_plugins((
DefaultPlugins,
CefPlugin {
command_line_config: CommandLineConfig::default()
.with_switch("disable-gpu")
.with_switch_value("remote-debugging-port", "9222"),
},
));
// Full customization with direct initialization
app.add_plugins((
DefaultPlugins,
CefPlugin {
command_line_config: CommandLineConfig {
switches: vec!["disable-gpu"],
switch_values: vec![("remote-debugging-port", "9222")],
},
},
));
```
55 lines
1.4 KiB
Rust
55 lines
1.4 KiB
Rust
#![allow(clippy::type_complexity)]
|
|
|
|
mod common;
|
|
mod cursor_icon;
|
|
mod keyboard;
|
|
mod mute;
|
|
mod navigation;
|
|
mod system_param;
|
|
mod webview;
|
|
mod zoom;
|
|
|
|
use crate::common::{LocalHostPlugin, MessageLoopPlugin, WebviewCoreComponentsPlugin};
|
|
use crate::cursor_icon::SystemCursorIconPlugin;
|
|
use crate::keyboard::KeyboardPlugin;
|
|
use crate::mute::AudioMutePlugin;
|
|
use crate::prelude::{IpcPlugin, NavigationPlugin, WebviewPlugin};
|
|
use crate::zoom::ZoomPlugin;
|
|
use bevy::prelude::*;
|
|
use bevy_cef_core::prelude::CommandLineConfig;
|
|
use bevy_remote::RemotePlugin;
|
|
|
|
pub mod prelude {
|
|
pub use crate::{CefPlugin, RunOnMainThread, common::*, navigation::*, webview::prelude::*};
|
|
pub use bevy_cef_core::prelude::CommandLineConfig;
|
|
}
|
|
|
|
pub struct RunOnMainThread;
|
|
|
|
#[derive(Debug, Default)]
|
|
pub struct CefPlugin {
|
|
pub command_line_config: CommandLineConfig,
|
|
}
|
|
|
|
impl Plugin for CefPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
app.add_plugins((
|
|
LocalHostPlugin,
|
|
MessageLoopPlugin {
|
|
config: self.command_line_config.clone(),
|
|
},
|
|
WebviewCoreComponentsPlugin,
|
|
WebviewPlugin,
|
|
IpcPlugin,
|
|
KeyboardPlugin,
|
|
SystemCursorIconPlugin,
|
|
NavigationPlugin,
|
|
ZoomPlugin,
|
|
AudioMutePlugin,
|
|
));
|
|
if !app.is_plugin_added::<RemotePlugin>() {
|
|
app.add_plugins(RemotePlugin::default());
|
|
}
|
|
}
|
|
}
|