SecureBrowser.hpp

1. Overview

The SecureBrowser.hpp header defines the SecureBrowser utility class, a static service component responsible for launching and managing a secure embedded browser environment within BastionGuard. The class is designed as a thin abstraction layer over the Chromium Embedded Framework (CEF), enabling controlled rendering of web content in isolation from the main application process.

Functionally, SecureBrowser provides:

  • Secure opening of URLs in an embedded CEF-based browser
  • Support for standalone and window-integrated browser instances
  • Convenience overloads for simplified invocation
  • Centralized creation of the CEF application object
  • Isolation of web content from the primary GTK application workflow

2. Dependencies and Includes

#include <string>
#include <cstdint>
#include "include/cef_app.h"
  • <string> – URL handling and parameter passing
  • <cstdint> – fixed-width integer types for window identifiers
  • cef_app.h – Chromium Embedded Framework application interface

3. Class Declaration and Scope

class SecureBrowser

The class is implemented as a static utility container. All exposed methods are static, and no instance of SecureBrowser is intended to be created.


4. Public Interface

4.1 Primary Launch Method

static void open(const std::string& url, int argc, char** argv);

Launches an embedded browser instance pointing to the specified URL. The method accepts optional command-line arguments that are forwarded to the CEF runtime, enabling advanced configuration and debugging features when required.

  • url – target web address to be loaded
  • argc / argv – optional argument vector for CEF initialization

4.2 Convenience Overload

static void open(const std::string& url);

Inline helper that opens a URL using default runtime parameters. This overload simplifies invocation when no custom arguments are required.


4.3 Window-Integrated Launch

static void openInWindow(const std::string& url, uintptr_t window_id);

Requests opening of the given URL inside an existing native window, identified by window_id. This enables embedding the browser inside GTK-managed containers or external window handles (platform-dependent).

Note: In the current header, this method delegates to open() and does not directly use window_id. Platform-specific integration is expected to be handled in the implementation.


4.4 CEF Application Factory

static CefRefPtr<CefApp> createApp();

Creates and returns a reference-counted CEF application object. This object is required during CEF initialization and configures global browser behavior, handlers, and policies.


5. UI Components

This component does not define GTK user interface widgets. It operates as a backend service invoked by UI pages (e.g., banking, privacy, or cloud-related views) that require controlled web access.


6. Internal State and Data Model

No persistent state is declared in this header. All browser lifecycle state, window bindings, and CEF configuration objects are managed internally in the implementation file.


7. Usage Context

SecureBrowser is typically used in security-sensitive contexts where opening an external URL in the system browser would be undesirable. Common use cases include:

  • Secure access to online banking portals
  • Viewing cloud analysis results
  • Displaying privacy or support pages
  • Embedded authentication flows

8. Internal Logic

Although implementation details are not exposed here, a typical open() workflow includes:

  • Initialization of the CEF runtime
  • Creation of a sandboxed browser context
  • Configuration of security policies and handlers
  • Navigation to the requested URL
  • Lifecycle and shutdown management

9. Auto-Update (Scheduled Refresh)

This component does not implement timers or scheduled tasks. Browser updates and refresh behavior are delegated to the CEF engine.


10. Settings Storage

No explicit settings persistence is declared. Configuration of browser policies, cache directories, and security options is expected to be defined in the createApp() implementation or in higher-level application settings.


11. Helper Functions and Platform Integration

Integration with native window systems (X11, Wayland, Windows, macOS) is platform-dependent and handled in the implementation. The openInWindow() method provides a hook for embedding the browser into existing UI surfaces.


12. Runtime and Security Considerations

  • Sandboxing: CEF should be configured with sandboxing enabled where supported to limit the impact of compromised web content.
  • Certificate validation: TLS certificate verification must be enforced to prevent man-in-the-middle attacks.
  • Content isolation: browser contexts should be isolated from the main application filesystem and environment.
  • Navigation control: restrict navigation and pop-ups to trusted domains when used in sensitive workflows.
  • Resource cleanup: ensure proper shutdown of CEF resources to prevent orphaned processes and memory leaks.