Nacre/src/resources.rs
astar76 e8167c3f4a Nacre on Servo: first complete, reviewed, not yet built version
Everything in Rust on Servo 0.7 (trimmed: no WebXR, WebGPU, multiprocess):
tabs and windows, address bar with suggestions, history, bookmarks and
reading list, downloads with resume and external download managers,
encrypted password vault with autofill, ad blocker (adblock-rust, 22 lists),
VPN through Tor or a proxy and secure DNS via a local bridge proxy,
picture in picture, Discord Rich Presence, media player and visualizer,
spell check, site apps, user scripts and styles, import from other
browsers, gamepads, Web Bluetooth, and every setting of the original Nacre
in a plain egui interface.

Not compiled yet; docs/HANDOFF.md has the first build checklist.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-11 06:08:36 -06:00

43 lines
2 KiB
Rust

//! The files Servo asks its embedder for: data lists and the built-in pages (network error,
//! certificate error, crash). Nacre ships its own versions of the pages so their titles are known
//! to the browser (see `ERROR_TITLE` and friends) and they read like the rest of Nacre.
use std::path::PathBuf;
use servo::resources::{Resource, ResourceReaderMethods};
/// Title of the network error page; a tab showing it is treated as "failed to load".
pub const ERROR_TITLE: &str = "Couldn't open this page";
pub const BAD_CERT_TITLE: &str = "Connection not secure";
pub const CRASH_TITLE: &str = "This page crashed";
struct NacreResources;
impl ResourceReaderMethods for NacreResources {
fn read(&self, resource: Resource) -> Vec<u8> {
match resource {
Resource::BluetoothBlocklist => &include_bytes!("../assets/servo/gatt_blocklist.txt")[..],
Resource::DomainList => &include_bytes!("../assets/servo/public_domains.txt")[..],
Resource::HstsPreloadList => &include_bytes!("../assets/servo/hsts_preload.fstmap")[..],
Resource::BadCertHTML => &include_bytes!("../assets/servo/badcert.html")[..],
Resource::NetErrorHTML => &include_bytes!("../assets/servo/neterror.html")[..],
Resource::BrokenImageIcon => &include_bytes!("../assets/servo/rippy.png")[..],
Resource::CrashHTML => &include_bytes!("../assets/servo/crash.html")[..],
Resource::DirectoryListingHTML => &include_bytes!("../assets/servo/directory-listing.html")[..],
Resource::AboutMemoryHTML => &include_bytes!("../assets/servo/about-memory.html")[..],
Resource::DebuggerJS => &include_bytes!("../assets/servo/debugger.js")[..],
Resource::JsonViewerHTML => &include_bytes!("../assets/servo/json-viewer.html")[..],
}
.to_owned()
}
fn sandbox_access_files(&self) -> Vec<PathBuf> {
Vec::new()
}
fn sandbox_access_files_dirs(&self) -> Vec<PathBuf> {
Vec::new()
}
}
servo::submit_resource_reader!(&NacreResources);