Add privacy local data inventory

This commit is contained in:
2026-05-09 07:22:14 -04:00
parent 91821a0fc9
commit 2b6de367b0
7 changed files with 322 additions and 3 deletions
+3 -2
View File
@@ -6,6 +6,7 @@ pub use error::CoreError;
pub use state::{
BookmarkImportSummary, BrowserCore, BrowserSnapshot, ELYBOOKMARKS_FILE_EXTENSION,
ELYBOOKMARKS_SCHEMA_VERSION, ELYSPACE_FILE_EXTENSION, ELYSPACE_SCHEMA_VERSION,
ElyBookmarksPackage, ElySpacePackage, InitialBrowserConfig, InstalledPlugin, PluginAuditAction,
PluginAuditEvent, SiteDataClearance, SpaceImportProfileMapping, TrashedSpace,
ElyBookmarksPackage, ElySpacePackage, InitialBrowserConfig, InstalledPlugin,
LocalDataInventory, PluginAuditAction, PluginAuditEvent, SiteDataClearance,
SpaceImportProfileMapping, TrashedSpace,
};
+3
View File
@@ -40,6 +40,7 @@ pub use bookmarks::{
ElyBookmarksPackage,
};
pub use plugins::{InstalledPlugin, PluginAuditAction, PluginAuditEvent};
pub use privacy::LocalDataInventory;
pub use site_data::SiteDataClearance;
pub use space_exports::{
ELYSPACE_FILE_EXTENSION, ELYSPACE_SCHEMA_VERSION, ElySpacePackage, SpaceImportProfileMapping,
@@ -97,6 +98,7 @@ pub struct BrowserSnapshot {
pub download_entries: Vec<DownloadEntry>,
pub history_entries: Vec<HistoryEntry>,
pub active_profile_history_entry_count: usize,
pub local_data_inventory: LocalDataInventory,
pub tab_groups: Vec<TabGroup>,
pub split_layouts: Vec<SplitLayout>,
pub installed_plugins: Vec<InstalledPlugin>,
@@ -385,6 +387,7 @@ impl BrowserCore {
download_entries: self.visible_downloads(),
history_entries: self.visible_history(),
active_profile_history_entry_count: self.active_profile_history_count(),
local_data_inventory: self.active_profile_local_data_inventory(),
tab_groups: self.visible_tab_groups(),
split_layouts: self.visible_split_layouts(),
installed_plugins: self.installed_plugins.clone(),
@@ -2,6 +2,79 @@ use ely_domain::{DiagnosticsReportingPolicy, HistoryRecordingPolicy};
use super::BrowserCore;
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
pub struct LocalDataInventory {
open_tabs: usize,
archived_tabs: usize,
bookmarks: usize,
notes: usize,
reading_list: usize,
history_entries: usize,
site_permissions: usize,
site_permission_audit_events: usize,
downloads: usize,
}
impl LocalDataInventory {
#[must_use]
pub fn open_tabs(self) -> usize {
self.open_tabs
}
#[must_use]
pub fn archived_tabs(self) -> usize {
self.archived_tabs
}
#[must_use]
pub fn bookmarks(self) -> usize {
self.bookmarks
}
#[must_use]
pub fn notes(self) -> usize {
self.notes
}
#[must_use]
pub fn reading_list(self) -> usize {
self.reading_list
}
#[must_use]
pub fn history_entries(self) -> usize {
self.history_entries
}
#[must_use]
pub fn site_permissions(self) -> usize {
self.site_permissions
}
#[must_use]
pub fn site_permission_audit_events(self) -> usize {
self.site_permission_audit_events
}
#[must_use]
pub fn downloads(self) -> usize {
self.downloads
}
#[must_use]
pub fn total_items(self) -> usize {
self.open_tabs
+ self.archived_tabs
+ self.bookmarks
+ self.notes
+ self.reading_list
+ self.history_entries
+ self.site_permissions
+ self.site_permission_audit_events
+ self.downloads
}
}
impl BrowserCore {
pub fn set_history_recording_policy(&mut self, policy: HistoryRecordingPolicy) {
self.history_recording_policy = policy;
@@ -25,4 +98,49 @@ impl BrowserCore {
pub fn diagnostics_reporting_policy(&self) -> DiagnosticsReportingPolicy {
self.diagnostics_reporting_policy
}
#[must_use]
pub fn active_profile_local_data_inventory(&self) -> LocalDataInventory {
let profile_id = &self.active_profile_id;
LocalDataInventory {
open_tabs: self.tabs.iter().filter(|tab| tab.profile_id() == profile_id).count(),
archived_tabs: self
.archived_tabs
.iter()
.filter(|archived| archived.tab().profile_id() == profile_id)
.count(),
bookmarks: self
.bookmarks
.iter()
.filter(|entry| entry.profile_id() == profile_id)
.count(),
notes: self.notes.iter().filter(|entry| entry.profile_id() == profile_id).count(),
reading_list: self
.reading_list
.iter()
.filter(|entry| entry.profile_id() == profile_id)
.count(),
history_entries: self
.history_entries
.iter()
.filter(|entry| entry.profile_id() == profile_id)
.count(),
site_permissions: self
.site_permissions
.iter()
.filter(|entry| entry.profile_id() == profile_id)
.count(),
site_permission_audit_events: self
.site_permission_audit_events
.iter()
.filter(|event| event.profile_id() == profile_id)
.count(),
downloads: self
.download_entries
.iter()
.filter(|entry| entry.profile_id() == profile_id)
.count(),
}
}
}