Skip to content

Browser Implementations

Auto Bot Solutions edited this page Apr 27, 2026 · 1 revision

This document provides detailed information about each browser implementation in the Secure Browser project, including features, use cases, and technical details.

Table of Contents

Overview

The Secure Browser project provides three distinct browser implementations, each designed for different use cases and system requirements:

  1. PyQt5 Browser: Full-featured browser with modern UI
  2. Tkinter Browser: Lightweight, security-focused browser
  3. WebView Browser: Native OS integration

PyQt5 Browser (hope.py)

Description

The PyQt5 browser is the most feature-rich implementation, offering a modern tabbed interface with advanced styling and comprehensive settings management. It uses the Chromium-based QtWebEngine for rendering, providing excellent compatibility with modern web standards.

Features

User Interface

  • Tabbed Browsing: Multiple tabs with close functionality
  • Dark Theme: Modern dark theme with advanced color scheme
  • Navigation Controls: Back, Forward, Reload, Home buttons
  • URL Bar: Auto-HTTPS prefix, URL validation
  • Settings Panel: Dialog-based configuration interface

Navigation Features

  • Tab Management: Open new tabs, close tabs, switch between tabs
  • History Management: Per-tab navigation history
  • URL Updates: Automatic URL bar updates on navigation
  • Title Updates: Tab titles update based on page titles

Settings

  • VPN Toggle: Enable/disable VPN (placeholder for future implementation)
  • JavaScript Control: Enable/disable JavaScript execution
  • Proxy Configuration: HTTP/HTTPS proxy settings

Technical Details

Dependencies

PyQt5>=5.15.0
PyQtWebEngine>=5.15.0

Architecture

  • GUI Framework: PyQt5
  • Rendering Engine: QtWebEngine (Chromium-based)
  • Window Management: QMainWindow with central widget
  • Layout Management: QVBoxLayout for main layout, QHBoxLayout for navigation

Styling

The browser uses Qt Style Sheets (QSS) for theming:

self.setStyleSheet("""
    QMainWindow {
        background-color: #2b2b2b;
        color: #ffffff;
        border: 1px solid #444444;
        border-radius: 10px;
    }
    QPushButton {
        background-color: #5865f2;
        color: #ffffff;
        border-radius: 8px;
        padding: 8px 20px;
        font: bold 12px 'Segoe UI';
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    }
    # ... additional styling
""")

Key Classes

Browser Class

  • Main browser window implementation
  • Manages tabs, navigation, and settings
  • Handles URL loading and validation

SettingsDialog Class

  • Configuration dialog
  • Manages VPN, JavaScript, and proxy settings
  • Applies settings to parent browser

Usage

Running the Browser

# Via main.py
python main.py --browser pyqt5

# Direct execution
python src/browsers/hope.py

Programmatic Usage

from src.browsers.hope import Browser
from PyQt5.QtWidgets import QApplication
import sys

app = QApplication(sys.argv)
browser = Browser()
browser.show()
sys.exit(app.exec_())

Strengths

  • Modern, polished user interface
  • Excellent web compatibility (Chromium-based)
  • Comprehensive settings management
  • Tab support for productivity
  • Dark theme for reduced eye strain

Limitations

  • Higher resource usage (memory and CPU)
  • Requires PyQt5 and PyQtWebEngine installation
  • Larger dependency footprint

Best Use Cases

  • General web browsing
  • Development and debugging
  • Users requiring modern browser features
  • Systems with sufficient resources

Tkinter Browser (secure_browser.py)

Description

The Tkinter browser is a lightweight, security-focused implementation designed for minimal resource usage and maximum security control. It uses the tkinterweb library for HTML rendering and provides extensive security features.

Features

User Interface

  • Simple Navigation: Back, Forward, Reload, Home buttons
  • Address Bar: URL input with HTTPS enforcement
  • Settings Window: Comprehensive security configuration
  • Bookmark Management: Add and access bookmarks

Security Features

  • HTTPS Enforcement: Automatic HTTPS prefix for all URLs
  • JavaScript Control: Toggle JavaScript execution
  • Website Filtering: Whitelist and blacklist for site access
  • Security Headers: CSP, X-Frame-Options, X-Content-Type-Options
  • User-Agent Customization: Privacy-focused user agent control
  • Proxy Support: HTTP and HTTPS proxy configuration

Navigation Features

  • History Management: Full navigation history with back/forward
  • Bookmark System: Save and access favorite sites
  • Search Integration: Direct web search from address bar

Technical Details

Dependencies

tkinterweb>=3.0
# tkinter is included with Python standard library

Architecture

  • GUI Framework: Tkinter (standard library)
  • Rendering Engine: tkinterweb
  • Window Management: Tk root window with frames
  • Layout Management: Pack geometry manager

Security Implementation

Security Headers

self.security_headers = {
    "X-Content-Type-Options": "nosniff",
    "X-Frame-Options": "DENY",
    "Content-Security-Policy": "default-src 'self'; script-src 'self'; object-src 'none';"
}

Website Filtering

# Whitelist check
if hasattr(self, 'whitelist') and self.whitelist:
    if all(not url.startswith(allowed) for allowed in self.whitelist):
        self.html_frame.set_html("<h1>Access Denied</h1>")
        return

# Blacklist check
if hasattr(self, 'blacklist') and self.blacklist:
    if any(url.startswith(blocked) for blocked in self.blacklist):
        self.html_frame.set_html("<h1>Blocked</h1>")
        return

Key Methods

Security Methods

  • set_user_agent(): Custom user agent configuration
  • set_proxy(): Proxy configuration via environment variables
  • toggle_javascript(): JavaScript execution control
  • set_security_settings(): Whitelist/blacklist management

Navigation Methods

  • load_url(): URL loading with security checks
  • go_back(): Back navigation with history
  • go_forward(): Forward navigation with history
  • add_bookmark(): Bookmark management

Usage

Running the Browser

# Via main.py
python main.py --browser tkinter

# Direct execution
python src/browsers/secure_browser.py

Programmatic Usage

import tkinter as tk
from src.browsers.secure_browser import SimpleBrowser

root = tk.Tk()
browser = SimpleBrowser(root)
root.mainloop()

Strengths

  • Minimal resource usage
  • Extensive security features
  • No external GUI dependencies (Tkinter is standard library)
  • Comprehensive website filtering
  • Privacy-focused design

Limitations

  • Less modern UI appearance
  • Limited web compatibility compared to Chromium
  • No tab support
  • Basic rendering capabilities

Best Use Cases

  • Security-focused browsing
  • Systems with limited resources
  • Kiosk or restricted browsing environments
  • Educational settings with content filtering
  • Privacy-conscious users

WebView Browser (modern_browser.py)

Description

The WebView browser provides native OS webview integration, offering cross-platform compatibility with modern rendering capabilities. It wraps the native webview API of each operating system.

Features

User Interface

  • Native Integration: Uses OS-native webview
  • Navigation Controls: Back, Forward, Reload, Home buttons
  • Address Bar: URL input with scheme enforcement
  • Settings Window: User-agent and proxy configuration

Cross-Platform Support

  • Windows: Uses Edge WebView2
  • macOS: Uses WKWebView
  • Linux: Uses WebKitGTK

Navigation Features

  • History Management: Full navigation history
  • Proxy Support: HTTP and HTTPS proxy configuration
  • Native Rendering: Leverages OS webview engine

Technical Details

Dependencies

pywebview>=4.0

Architecture

  • GUI Framework: Tkinter for controls, pywebview for rendering
  • Rendering Engine: Native OS webview
  • Window Management: Tk root window + native webview window
  • Layout Management: Pack geometry manager for controls

WebView Integration

def initialize_webview(self, url):
    try:
        self.load_into_webview(url)
    except Exception as e:
        print(f"Error initializing WebView: {e}")

def load_into_webview(self, url):
    try:
        if self.webview_window is None:
            self.webview_window = webview.create_window("Modern Browser", url)
            webview.start()
        else:
            webview.load_url(url)
    except Exception as e:
        print(f"Error loading URL into WebView: {e}")

Limitations

  • User-Agent: PyWebView does not currently support custom user agents
  • Single Window: Limited multi-window support

Usage

Running the Browser

# Via main.py
python main.py --browser webview

# Direct execution
python src/browsers/modern_browser.py

Programmatic Usage

import tkinter as tk
from src.browsers.modern_browser import SimpleBrowser

root = tk.Tk()
browser = SimpleBrowser(root)
root.mainloop()

Strengths

  • Native OS integration
  • Modern rendering capabilities
  • Cross-platform compatibility
  • Lightweight wrapper approach
  • Good performance

Limitations

  • Limited customization options
  • User-agent customization not supported
  • Separate window for webview content
  • Less control over rendering behavior

Best Use Cases

  • Cross-platform applications
  • Native OS integration requirements
  • Applications needing modern web rendering
  • Hybrid desktop/web applications

Comparison

Feature Comparison Matrix

Feature PyQt5 Browser Tkinter Browser WebView Browser
Tabs ✅ Yes ❌ No ❌ No
Dark Theme ✅ Yes ❌ No ⚠️ OS-dependent
JavaScript Control ✅ Yes ✅ Yes ⚠️ Limited
Proxy Support ✅ Yes ✅ Yes ✅ Yes
Whitelist/Blacklist ❌ No ✅ Yes ❌ No
User-Agent Customization ❌ No ✅ Yes ❌ No
Security Headers ❌ No ✅ Yes ❌ No
Bookmark Management ❌ No ✅ Yes ❌ No
Developer Tools ✅ Yes ❌ No ❌ No
Settings Panel ✅ Yes ✅ Yes ✅ Yes
Navigation History ✅ Yes ✅ Yes ✅ Yes
HTTPS Enforcement ✅ Yes ✅ Yes ⚠️ Partial
Resource Usage High Low Medium
Web Compatibility Excellent Good Excellent
Cross-Platform ✅ Yes ✅ Yes ✅ Yes
Dependencies PyQt5, PyQtWebEngine tkinterweb pywebview

Performance Comparison

Metric PyQt5 Browser Tkinter Browser WebView Browser
Memory Usage 150-200 MB 30-50 MB 80-120 MB
CPU Usage Medium Low Medium
Startup Time 2-3 seconds <1 second 1-2 seconds
Page Load Fast Medium Fast
Tab Switching Fast N/A N/A

Choosing a Browser

Decision Tree

Start
  │
  ├─ Need tabs and modern UI?
  │   └─ Yes → PyQt5 Browser
  │   └─ No → Continue
  │
  ├─ Maximum security and filtering required?
  │   └─ Yes → Tkinter Browser
  │   └─ No → Continue
  │
  ├─ Native OS integration needed?
  │   └─ Yes → WebView Browser
  │   └─ No → Continue
  │
  └─ Default recommendation → PyQt5 Browser

Use Case Recommendations

General Web Browsing

Recommended: PyQt5 Browser

  • Modern UI with tabs
  • Excellent web compatibility
  • Comprehensive settings

Security-Focused Browsing

Recommended: Tkinter Browser

  • Whitelist/blacklist filtering
  • Security headers
  • JavaScript control
  • Minimal attack surface

Kiosk/Restricted Environment

Recommended: Tkinter Browser

  • Website filtering
  • Resource efficiency
  • Security controls

Cross-Platform Application

Recommended: WebView Browser

  • Native OS integration
  • Consistent behavior across platforms
  • Modern rendering

Development/Debugging

Recommended: PyQt5 Browser

  • Developer tools integration
  • Tab support for testing
  • Modern debugging features

Low-Resource Systems

Recommended: Tkinter Browser

  • Minimal memory usage
  • Low CPU requirements
  • Fast startup

Performance Characteristics

PyQt5 Browser Performance

Memory Profile

  • Base: ~150 MB
  • Per tab: ~20-30 MB
  • Peak: ~200 MB with 5 tabs

CPU Profile

  • Idle: 2-5%
  • Loading: 15-30%
  • Video playback: 20-40%

Startup Time

  • Cold start: 2-3 seconds
  • Warm start: 1-2 seconds

Tkinter Browser Performance

Memory Profile

  • Base: ~30 MB
  • Peak: ~50 MB

CPU Profile

  • Idle: <1%
  • Loading: 5-15%
  • Video playback: 10-20%

Startup Time

  • Cold start: <1 second
  • Warm start: <0.5 seconds

WebView Browser Performance

Memory Profile

  • Base: ~80 MB
  • Peak: ~120 MB

CPU Profile

  • Idle: 1-3%
  • Loading: 10-25%
  • Video playback: 15-35%

Startup Time

  • Cold start: 1-2 seconds
  • Warm start: 0.5-1 seconds

Browser-Specific Configuration

PyQt5 Browser Configuration

The PyQt5 browser stores settings in the SettingsDialog:

# Access settings after dialog
browser.use_vpn = dialog.vpn_checkbox.isChecked()
browser.enable_javascript = dialog.javascript_checkbox.isChecked()
browser.proxy = dialog.proxy_input.text()

Tkinter Browser Configuration

The Tkinter browser uses environment variables for proxy:

# Set proxy
os.environ["http_proxy"] = "http://proxy.example.com:8080"
os.environ["https_proxy"] = "https://proxy.example.com:8080"

Security settings are stored as instance variables:

browser.whitelist = ["example.com", "trusted.org"]
browser.blacklist = ["malicious.com"]
browser.security_headers = {...}

WebView Browser Configuration

The WebView browser uses environment variables for proxy:

# Set proxy
os.environ["http_proxy"] = "http://proxy.example.com:8080"
os.environ["https_proxy"] = "https://proxy.example.com:8080"

Extending Browser Implementations

Adding Features to PyQt5 Browser

To add new features to the PyQt5 browser:

  1. Add UI elements to create_navigation_bar()
  2. Implement handler methods
  3. Update SettingsDialog if configuration needed
  4. Apply styles in setStyleSheet()

Example - Adding a Downloads Button:

def create_navigation_bar(self):
    # ... existing code ...
    
    self.downloads_button = QPushButton("Downloads")
    self.downloads_button.clicked.connect(self.show_downloads)
    nav_layout.addWidget(self.downloads_button)
    
    return nav_layout

def show_downloads(self):
    # Implement downloads dialog
    pass

Adding Features to Tkinter Browser

To add new features to the Tkinter browser:

  1. Add buttons to navigation frame
  2. Implement handler methods
  3. Add settings to settings window if needed

Example - Adding a History Button:

def __init__(self, root):
    # ... existing code ...
    
    self.history_button = tk.Button(nav_frame, text="History", command=self.show_history)
    self.history_button.pack(side=tk.LEFT)

def show_history(self):
    # Implement history dialog
    pass

Adding Features to WebView Browser

To add new features to the WebView browser:

  1. Add buttons to navigation frame
  2. Implement handler methods
  3. Integrate with webview API if needed

Known Issues and Limitations

PyQt5 Browser

  • VPN toggle is a placeholder (not implemented)
  • No whitelist/blacklist support
  • No bookmark management
  • Higher resource usage

Tkinter Browser

  • Limited web compatibility (older rendering engine)
  • No tab support
  • Basic UI appearance
  • JavaScript filtering is basic

WebView Browser

  • Custom user-agent not supported
  • Limited control over webview behavior
  • Separate window for content
  • No developer tools integration

Future Enhancements

Planned Features

PyQt5 Browser

  • Bookmark management
  • Download manager
  • Extension support
  • Password manager integration

Tkinter Browser

  • Tab support
  • Improved JavaScript filtering
  • Ad blocking
  • Cookie management

WebView Browser

  • Custom user-agent support
  • Developer tools integration
  • Extension API
  • Multi-window support

Browser Selection Guidelines

When to Choose PyQt5 Browser

  • You need a modern, feature-rich browser
  • System resources are not a constraint
  • You require tab support
  • Developer tools are needed
  • Web compatibility is critical

When to Choose Tkinter Browser

  • Security is the primary concern
  • System resources are limited
  • You need website filtering
  • User-agent customization is required
  • Running in a kiosk or restricted environment

When to Choose WebView Browser

  • Native OS integration is required
  • Building a cross-platform application
  • You want modern rendering with minimal code
  • Custom user-agent is not needed
  • You prefer OS-native behavior

Clone this wiki locally