Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ All notable changes to Tarn are documented in this file. The format is based on
GitHub or the official catalog with per-site grants (macOS, Windows, Linux, iOS, Android). On
macOS they run in WebKit and Chromium tabs alike, cross-site frames included, with a toolbar
button, badge and popup; on Windows they are the extensions Tarn can run.
- Extension store: an "Install in Tarn" link on extensions.tarnbrowser.com opens a confirmation
in Settings › Extensions built only from Tarn's verified catalog, and nothing is downloaded
until you press Install there; Settings › Extensions links the store (macOS, Windows, Linux,
iOS, Android).

### Changed

Expand Down
2 changes: 1 addition & 1 deletion PRIVACY.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Settings › Privacy › Connections Tarn makes on macOS and Windows.
| Update check | GitHub (Releases of this repository) | Your IP address and Tarn version (on Windows only your IP address: Tarn fetches the signed `windows-update.json` and, when it names a later version, downloads that installer); from the `nightly` release in place of the latest one while Settings › General › Nightly builds is on | Once a day while Settings › General › Check for updates automatically is on (the default; on Windows an hour after a check that failed), and when you choose Tarn › Check for Updates…, on macOS and Windows |
| Filter-list update | GitHub (Releases of this repository) | Your IP address. Every list is downloaded whatever you switched on, so the download does not reveal your blocking choices | Once a day, on macOS and Windows; switch off in Settings › Privacy |
| Fraudulent-website check | Apple, which relays Google Safe Browsing; done by WebKit itself, on macOS and iOS. On Android, Google directly, done by the system WebView's Safe Browsing | Shortened hashes of the addresses you visit, not the addresses | While "Block dangerous sites" is on (the default); off with that switch. On iOS and Android the web view's default, which Tarn leaves on and no switch turns off. Windows and Linux make no such check |
| Extension catalog and downloads | GitHub (the repository you name, or the official catalog in `Quavon-dev/tarn-extensions`, not offered yet because its signing key is not set) | Your IP address and which repository or extension you install or check | Only when you click Install, Check for Updates or Show Official Extensions in Settings › Extensions; switch off in Settings › Privacy (installing from a file keeps working) |
| Extension catalog and downloads | GitHub (the repository you name, or the official catalog in `Quavon-dev/tarn-extensions`, not offered yet because its signing key is not set) | Your IP address and which repository or extension you install or check | Only when you click Install, Check for Updates or Show Official Extensions in Settings › Extensions; an Install in Tarn link from extensions.tarnbrowser.com makes no request until you click Install on the confirmation it opens there; switch off in Settings › Privacy (installing from a file keeps working) |
| Theme catalog and downloads | GitHub (the repository you name, or the official catalog in `Quavon-dev/tarn-themes`, not offered yet because its signing key is not set) | Your IP address and which repository or theme you install or check | Only when you click Install, Check for Updates or Show Official Themes in Settings › Appearance, on every client; on macOS and Windows switch off with the same Settings › Privacy switch as extensions; Linux, iOS and Android have no such switch yet (themes from a file or the clipboard keep working) |
| Site icon | The site you are on, or a server it already loaded from (such as its CDN, without cookies), through the tab's web engine with your Shield rules | Same as visiting the site | After a page loads over https; never under Lockdown; cleared with history |
| Translation (builds with the `translation` feature) | Nobody: Apple's Translation framework runs on your Mac | Nothing. Only language packs you installed in System Settings › General › Language & Region › Translation Languages are used; Tarn never downloads one | Only when you click Translate on the banner; never under Lockdown |
Expand Down
1 change: 1 addition & 0 deletions crates/app/src/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1808,6 +1808,7 @@ impl Browser {
None => self.notify_offer(key, message, None),
}
}
Event::StoreInstall(id) => self.store_link(key, id, window, cx),
Event::PopupBlocked(url) => {
let message = nav_policy::popup_blocked_notice(url.as_ref());
let offer = url.filter(|u| nav_policy::decide(u, Source::Typed) == Decision::Allow).map(Offer::NewTab);
Expand Down
79 changes: 76 additions & 3 deletions crates/app/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ use ui::controls::{icon_button, tooltip};
use ui::icon::Icon;
use ui::theme::Theme;

use crate::browser::Browser;
use crate::browser::{Browser, TabKey};
use crate::ext_package;
use crate::ext_sources::{self, Net};
use crate::prefs::Pref;
use crate::shared::AppCore;
pub use browser_core::extensions::Install;
pub use browser_core::extensions::install::UNREVIEWED;
use browser_core::extensions::install::{self, CATALOG_SEEN_SETTING, Slot};
use browser_core::extensions::install::{self, CATALOG_SEEN_SETTING, Slot, StoreCatalog, StoreContext};
pub use browser_core::extensions::install::{StoreToken, UNREVIEWED};
use browser_core::extensions::{Step, Unpacked, badge, every_site, fetch_and_unpack, grew, may_use_all_sites, png_icon};

pub use browser_core::theme_fetch::DOWNLOADS_SETTING;
Expand Down Expand Up @@ -147,6 +147,8 @@ pub struct Extensions {
repin: HashSet<String>,
/// Check for Updates runs once the catalog it asked for arrives.
check_after_catalog: bool,
store_sheet: install::StoreSheet,
store_confirmed: Option<(u64, String)>,
catalog: Option<Index>,
}

Expand Down Expand Up @@ -810,7 +812,12 @@ impl Browser {
let row = u.row(slot.profile_id, &slot.install_id, extension.name(), extension.version(), permissions);
let mut ext = self.core.extensions.borrow_mut();
ext.busy = None;
let confirmed = ext.store_confirmed.take().is_some_and(|(g, id)| g == generation && install::store_confirmed(&id, &row.source));
ext.pending = Some(Pending { slot, row, extension });
drop(ext);
if confirmed {
self.confirm_extension_install(cx);
}
cx.notify();
}

Expand Down Expand Up @@ -1008,6 +1015,72 @@ impl Browser {
}
}

pub(crate) fn store_link(&mut self, key: TabKey, id: String, window: &mut Window, cx: &mut Context<Self>) {
if !self.core.admit_store_link(std::time::Instant::now()) {
return;
}
let (mut sheet, busy) = {
let ext = self.core.extensions.borrow();
(ext.store_sheet.clone(), ext.busy.is_some() || ext.pending.is_some() || ext.choice.is_some())
};
match self.store_check(key, busy, |context, catalog| sheet.offer(key, &id, context, catalog, std::time::Instant::now())) {
Ok(()) => {
self.core.extensions.borrow_mut().store_sheet = sheet;
self.open_settings_pane(crate::settings::SettingsPane::Extensions, window, cx);
}
Err(why) => self.notify_offer(key, why, None),
}
cx.notify();
}

fn store_check<R>(&self, key: TabKey, busy: bool, step: impl FnOnce(StoreContext, StoreCatalog) -> R) -> R {
let page = self.views.get(&key).and_then(|v| v.url());
let profile = self.model.profile_of(&self.core, key).filter(|p| self.current_profile_id() == Some(*p));
let allowed = self.extensions_allowed() && profile.is_some_and(|p| self.core.store_link_allowed(key.private, p, page.as_ref()));
let rows = profile.map(|p| self.core.disk.extensions(p).unwrap_or_default()).unwrap_or_default();
let (catalog, revoked) = (self.core.extensions.borrow().catalog.clone(), install::revoked(&self.core.disk));
let context = StoreContext { allowed, configured: catalog_configured(), downloads: self.extension_downloads(), busy };
step(context, StoreCatalog { index: catalog.as_ref(), now: now(), revoked: &revoked, installed: &rows })
}

pub fn store_sheet(&self) -> Option<(install::StoreToken, String, Vec<String>)> {
let ext = self.core.extensions.borrow();
let offer = ext.store_sheet.shown()?;
let (title, lines) = install::store_sheet(&offer.entry);
Some((offer.token.clone(), title, lines))
}

pub fn cancel_store_offer(&mut self, cx: &mut Context<Self>) {
self.core.extensions.borrow_mut().store_sheet.clear();
cx.notify();
}

pub fn confirm_store_offer(&mut self, token: &install::StoreToken, cx: &mut Context<Self>) {
if !self.layout_stable() {
return;
}
let Some(install::StoreOffer { tab: key, entry: offered, .. }) = self.core.extensions.borrow_mut().store_sheet.take(token, std::time::Instant::now())
else {
return;
};
let busy = {
let ext = self.core.extensions.borrow();
ext.busy.is_some() || ext.pending.is_some() || ext.choice.is_some()
};
match self.store_check(key, busy, |context, catalog| install::store_confirm(&offered, context, catalog)) {
Ok(entry) => {
let before = self.core.extensions.borrow().generation;
self.install_extension(Install::Official(*entry), None, cx);
let mut ext = self.core.extensions.borrow_mut();
if ext.generation != before {
ext.store_confirmed = Some((ext.generation, offered.id));
}
}
Err(why) => self.core.extensions.borrow_mut().notices.push(why),
}
cx.notify();
}

pub fn choose_extension_asset(&mut self, ix: usize, cx: &mut Context<Self>) {
let choice = self.core.extensions.borrow_mut().choice.take();
if let Some((input, assets)) = choice
Expand Down
34 changes: 34 additions & 0 deletions crates/app/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ struct Snapshot {
extension_busy: Option<String>,
extension_choice: Vec<String>,
consent: Option<crate::extensions::Consent>,
store_sheet: Option<(crate::extensions::StoreToken, String, Vec<String>)>,
catalog: (Vec<crate::extensions::CatalogRow>, bool),
card: Option<Card>,
/// `None` outside an app bundle, which cannot become the default browser.
Expand Down Expand Up @@ -263,6 +264,7 @@ pub struct SettingsWindow {
appearance: appearance::Pane,
_observe: Option<Subscription>,
_activation: Subscription,
_release: Subscription,
}

impl SettingsWindow {
Expand Down Expand Up @@ -324,6 +326,9 @@ impl SettingsWindow {
appearance: appearance::Pane::new(cx),
_observe: observe,
_activation: activation,
_release: cx.on_release(|this: &mut SettingsWindow, cx| {
this.main.update(cx, |b, _, cx| b.cancel_store_offer(cx)).ok();
}),
}
})
})
Expand Down Expand Up @@ -403,6 +408,7 @@ impl SettingsWindow {
.map(|(_, a)| a.iter().map(|a| crate::extensions::shown(&a.name)).collect())
.unwrap_or_default(),
consent: if self.pane == SettingsPane::Extensions { b.core.extensions.borrow().consent() } else { None },
store_sheet: if self.pane == SettingsPane::Extensions { b.store_sheet() } else { None },
catalog: if self.pane == SettingsPane::Extensions { b.catalog_rows() } else { (Vec::new(), false) },
filters: b.core.filters.borrow().clone(),
shared_data: self.pane == SettingsPane::Privacy
Expand Down Expand Up @@ -439,6 +445,9 @@ impl SettingsWindow {
}

pub(crate) fn set_pane(&mut self, pane: SettingsPane, cx: &mut Context<Self>) {
if self.pane == SettingsPane::Extensions && pane != SettingsPane::Extensions {
self.with_browser(cx, |b, _, cx| b.cancel_store_offer(cx));
}
if pane == SettingsPane::Developer {
self.with_browser(cx, |b, _, cx| b.refresh_local_servers(cx));
}
Expand Down Expand Up @@ -1759,6 +1768,24 @@ impl SettingsWindow {
),
);
}
if let Some((token, title, lines)) = s.store_sheet {
let card = group()
.child(row(true).child(text_block(title, "From Tarn's signed official catalog.")))
.children(lines.into_iter().map(|l| row(false).child(div().flex_1().child(l))))
.child(
row(false)
.child(div().flex_1())
.child(
button("store-cancel", "Cancel", true)
.on_click(cx.listener(|this, _, _, cx| this.with_browser(cx, |b, _, cx| b.cancel_store_offer(cx)))),
)
.child(button("store-install", "Install", false).on_click(cx.listener(move |this, _, _, cx| {
let token = token.clone();
this.with_browser(cx, move |b, _, cx| b.confirm_store_offer(&token, cx))
}))),
);
return page.child(section("Confirm")).child(card).into_any_element();
}
if let Some(c) = s.consent {
let list = |title: &'static str, items: &[String]| {
(!items.is_empty()).then(|| text_block(title, items.iter().map(|i| crate::extensions::shown(i)).collect::<Vec<_>>().join(", ")))
Expand Down Expand Up @@ -1925,6 +1952,13 @@ impl SettingsWindow {
.into_any_element()
}));
}
official = official.child(self.link_row(
"extension-store",
"Browse the store",
"Official extensions with screenshots and search; Install in Tarn asks here first.",
browser_core::extensions::STORE_URL,
cx,
));
page = page.child(section("Official")).child(official);
if old {
page = page.child(note("This list is more than 30 days old. Show official extensions to get the current one."));
Expand Down
2 changes: 2 additions & 0 deletions crates/browser-core/src/extensions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ use crate::github::{self, Fetch, Resolved};

pub mod install;

pub use engine::tarn_ext::{STORE_EVENT, STORE_URL, store_install};

pub const MAX_ICON_BYTES: u64 = 1 << 20;
pub const MAX_ICON_SIDE: u32 = 512;

Expand Down
Loading
Loading