Add privacy history settings
This commit is contained in:
@@ -28,6 +28,7 @@ fn internal_page_title(url: &str) -> Option<&'static str> {
|
||||
"ely://settings/general" => Some("General Settings"),
|
||||
"ely://settings/sidebar-tabs" => Some("Sidebar & Tabs Settings"),
|
||||
"ely://settings/search" => Some("Search Settings"),
|
||||
"ely://settings/privacy-security" => Some("Privacy & Security Settings"),
|
||||
"ely://settings/spaces" => Some("Space Settings"),
|
||||
"ely://settings/shortcuts" => Some("Shortcut Settings"),
|
||||
"ely://settings/plugins" => Some("Plugin Settings"),
|
||||
@@ -164,6 +165,8 @@ fn settings_page_route(query: &str) -> Option<&'static str> {
|
||||
"search" | "search engine" | "default search" | "default search engine" => {
|
||||
Some("ely://settings/search")
|
||||
}
|
||||
"privacy" | "security" | "privacy security" | "privacy & security" | "history"
|
||||
| "history recording" => Some("ely://settings/privacy-security"),
|
||||
"space" | "spaces" | "space settings" | "spaces settings" => Some("ely://settings/spaces"),
|
||||
"shortcut" | "shortcuts" | "keyboard" | "keyboard shortcuts" => {
|
||||
Some("ely://settings/shortcuts")
|
||||
|
||||
@@ -2,9 +2,9 @@ use std::{collections::BTreeMap, time::SystemTime};
|
||||
|
||||
use ely_domain::{
|
||||
ArchivePolicy, ArchivedTab, BookmarkEntry, BrowserTab, DomainError, DownloadEntry,
|
||||
DownloadPolicy, HistoryEntry, NewTabDestination, Profile, ProfileId, ProfileKind,
|
||||
ReadingListEntry, SearchEngine, SitePermissionAuditEvent, SitePermissionEntry, Space, SpaceId,
|
||||
SplitLayout, SyncStatus, TabId, UrlText,
|
||||
DownloadPolicy, HistoryEntry, HistoryRecordingPolicy, NewTabDestination, Profile, ProfileId,
|
||||
ProfileKind, ReadingListEntry, SearchEngine, SitePermissionAuditEvent, SitePermissionEntry,
|
||||
Space, SpaceId, SplitLayout, SyncStatus, TabId, UrlText,
|
||||
};
|
||||
|
||||
use crate::{CoreError, navigation::tab_title};
|
||||
@@ -68,6 +68,7 @@ pub struct BrowserSnapshot {
|
||||
pub active_download_policy: DownloadPolicy,
|
||||
pub search_engine: SearchEngine,
|
||||
pub new_tab_destination: NewTabDestination,
|
||||
pub history_recording_policy: HistoryRecordingPolicy,
|
||||
pub command_query: String,
|
||||
}
|
||||
|
||||
@@ -94,6 +95,7 @@ pub struct BrowserCore {
|
||||
active_tabs_by_space_profile: BTreeMap<(SpaceId, ProfileId), TabId>,
|
||||
search_engine: SearchEngine,
|
||||
new_tab_destination: NewTabDestination,
|
||||
history_recording_policy: HistoryRecordingPolicy,
|
||||
command_query: String,
|
||||
}
|
||||
|
||||
@@ -128,6 +130,7 @@ impl BrowserCore {
|
||||
active_tabs_by_space_profile,
|
||||
search_engine: SearchEngine::default(),
|
||||
new_tab_destination,
|
||||
history_recording_policy: HistoryRecordingPolicy::default(),
|
||||
spaces: vec![space],
|
||||
profiles: vec![profile],
|
||||
tabs: vec![tab],
|
||||
@@ -241,6 +244,15 @@ impl BrowserCore {
|
||||
self.new_tab_destination
|
||||
}
|
||||
|
||||
pub fn set_history_recording_policy(&mut self, policy: HistoryRecordingPolicy) {
|
||||
self.history_recording_policy = policy;
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn history_recording_policy(&self) -> HistoryRecordingPolicy {
|
||||
self.history_recording_policy
|
||||
}
|
||||
|
||||
pub fn set_command_query(&mut self, query: impl Into<String>) {
|
||||
self.command_query = query.into();
|
||||
}
|
||||
@@ -279,6 +291,7 @@ impl BrowserCore {
|
||||
active_download_policy: active_profile.download_policy().clone(),
|
||||
search_engine: self.search_engine,
|
||||
new_tab_destination: self.new_tab_destination,
|
||||
history_recording_policy: self.history_recording_policy,
|
||||
command_query: self.command_query.clone(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -8,7 +8,10 @@ use super::BrowserCore;
|
||||
|
||||
impl BrowserCore {
|
||||
pub(super) fn record_history_entry(&mut self, tab: &BrowserTab) {
|
||||
if !records_history(tab.url()) || !self.profile_records_history(tab.profile_id()) {
|
||||
if !self.history_recording_policy.records_history()
|
||||
|| !records_history(tab.url())
|
||||
|| !self.profile_records_history(tab.profile_id())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::error::Error;
|
||||
|
||||
use ely_browser_core::{BrowserCore, InitialBrowserConfig};
|
||||
use ely_domain::{CommandIntent, CommandScope, ProfileKind, UrlText};
|
||||
use ely_domain::{CommandIntent, CommandScope, HistoryRecordingPolicy, ProfileKind, UrlText};
|
||||
|
||||
#[test]
|
||||
fn navigation_records_profile_and_space_history() -> Result<(), Box<dyn Error>> {
|
||||
@@ -30,6 +30,21 @@ fn internal_pages_are_omitted_from_history() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn paused_history_recording_skips_new_history_entries() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
|
||||
core.open_tab(UrlText::parse("https://example.com/recorded")?);
|
||||
core.set_history_recording_policy(HistoryRecordingPolicy::Pause);
|
||||
core.open_tab(UrlText::parse("https://example.com/private")?);
|
||||
|
||||
let snapshot = core.snapshot()?;
|
||||
assert_eq!(snapshot.history_recording_policy, HistoryRecordingPolicy::Pause);
|
||||
assert_eq!(snapshot.history_entries.len(), 1);
|
||||
assert_eq!(snapshot.history_entries[0].url().as_str(), "https://example.com/recorded");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn history_scoped_search_opens_recent_matching_entry() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
|
||||
@@ -107,3 +107,24 @@ fn settings_scoped_search_opens_search_page() -> Result<(), Box<dyn Error>> {
|
||||
assert_eq!(core.snapshot()?.command_query, "");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn settings_scoped_search_opens_privacy_security_page() -> Result<(), Box<dyn Error>> {
|
||||
let mut core = BrowserCore::new(InitialBrowserConfig::ely_defaults()?)?;
|
||||
|
||||
core.set_command_query("@settings privacy");
|
||||
let intent = core.submit_command()?;
|
||||
let active_tab = core.active_tab()?;
|
||||
|
||||
assert_eq!(
|
||||
intent,
|
||||
Some(CommandIntent::ScopedSearch {
|
||||
scope: CommandScope::Settings,
|
||||
query: "privacy".to_string(),
|
||||
})
|
||||
);
|
||||
assert_eq!(active_tab.title(), "Privacy & Security Settings");
|
||||
assert_eq!(active_tab.url().as_str(), "ely://settings/privacy-security");
|
||||
assert_eq!(core.snapshot()?.command_query, "");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user