#!/bin/bash
# ============================================================
# chromium.sh — Chromium browser (Flatpak)
# ============================================================
# Installs the open-source Chromium browser via Flatpak.
# Chromium is the upstream base from which Google Chrome is
# derived.  It is useful as a reference browser for web
# development/testing and as a non-Google-branded alternative
# to Chrome.
#
# Flatpak is preferred over the official Arch chromium package
# so that the browser runs in a sandboxed environment with its
# own set of libraries, reducing the attack surface and
# avoiding dependency conflicts with the system.
# ============================================================

set -euo pipefail
# Load shared logging helpers and Flatpak utility functions
source "$(dirname "${BASH_SOURCE[0]}")/../../lib/logging.sh"

log "Installing Chromium (Flatpak)..."

# ensure_flatpak: verifies Flatpak and Flathub are set up; idempotent.
ensure_flatpak

# Install Chromium from Flathub. -y skips the confirmation prompt.
sudo flatpak install --system -y flathub org.chromium.Chromium

# apply_flatpak_theme: applies the cyberqueer GTK theme so Chromium's file
# dialogs and context menus match the rest of the desktop.
apply_flatpak_theme "org.chromium.Chromium"

log "Chromium installed."
