Repository navigation
Browser Implementations
This document provides detailed information about each browser implementation in the Secure Browser project, including features, use cases, and technical details.
- Overview
- PyQt5 Browser (hope.py)
- Tkinter Browser (secure_browser.py)
- WebView Browser (modern_browser.py)
- Comparison
- Choosing a Browser
- Performance Characteristics
The Secure Browser project provides three distinct browser implementations, each designed for different use cases and system requirements:
- PyQt5 Browser: Full-featured browser with modern UI
- Tkinter Browser: Lightweight, security-focused browser
- WebView Browser: Native OS integration
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.
- 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
- 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
- VPN Toggle: Enable/disable VPN (placeholder for future implementation)
- JavaScript Control: Enable/disable JavaScript execution
- Proxy Configuration: HTTP/HTTPS proxy settings
PyQt5>=5.15.0
PyQtWebEngine>=5.15.0- GUI Framework: PyQt5
- Rendering Engine: QtWebEngine (Chromium-based)
- Window Management: QMainWindow with central widget
- Layout Management: QVBoxLayout for main layout, QHBoxLayout for navigation
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
""")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
# Via main.py
python main.py --browser pyqt5
# Direct execution
python src/browsers/hope.pyfrom src.browsers.hope import Browser
from PyQt5.QtWidgets import QApplication
import sys
app = QApplication(sys.argv)
browser = Browser()
browser.show()
sys.exit(app.exec_())- Modern, polished user interface
- Excellent web compatibility (Chromium-based)
- Comprehensive settings management
- Tab support for productivity
- Dark theme for reduced eye strain
- Higher resource usage (memory and CPU)
- Requires PyQt5 and PyQtWebEngine installation
- Larger dependency footprint
- General web browsing
- Development and debugging
- Users requiring modern browser features
- Systems with sufficient resources
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.
- 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
- 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
- History Management: Full navigation history with back/forward
- Bookmark System: Save and access favorite sites
- Search Integration: Direct web search from address bar
tkinterweb>=3.0
# tkinter is included with Python standard library- GUI Framework: Tkinter (standard library)
- Rendering Engine: tkinterweb
- Window Management: Tk root window with frames
- Layout Management: Pack geometry manager
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>")
returnSecurity 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
# Via main.py
python main.py --browser tkinter
# Direct execution
python src/browsers/secure_browser.pyimport tkinter as tk
from src.browsers.secure_browser import SimpleBrowser
root = tk.Tk()
browser = SimpleBrowser(root)
root.mainloop()- Minimal resource usage
- Extensive security features
- No external GUI dependencies (Tkinter is standard library)
- Comprehensive website filtering
- Privacy-focused design
- Less modern UI appearance
- Limited web compatibility compared to Chromium
- No tab support
- Basic rendering capabilities
- Security-focused browsing
- Systems with limited resources
- Kiosk or restricted browsing environments
- Educational settings with content filtering
- Privacy-conscious users
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.
- 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
- Windows: Uses Edge WebView2
- macOS: Uses WKWebView
- Linux: Uses WebKitGTK
- History Management: Full navigation history
- Proxy Support: HTTP and HTTPS proxy configuration
- Native Rendering: Leverages OS webview engine
pywebview>=4.0- 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
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}")- User-Agent: PyWebView does not currently support custom user agents
- Single Window: Limited multi-window support
# Via main.py
python main.py --browser webview
# Direct execution
python src/browsers/modern_browser.pyimport tkinter as tk
from src.browsers.modern_browser import SimpleBrowser
root = tk.Tk()
browser = SimpleBrowser(root)
root.mainloop()- Native OS integration
- Modern rendering capabilities
- Cross-platform compatibility
- Lightweight wrapper approach
- Good performance
- Limited customization options
- User-agent customization not supported
- Separate window for webview content
- Less control over rendering behavior
- Cross-platform applications
- Native OS integration requirements
- Applications needing modern web rendering
- Hybrid desktop/web applications
| Feature | PyQt5 Browser | Tkinter Browser | WebView Browser |
|---|---|---|---|
| Tabs | ✅ Yes | ❌ No | ❌ No |
| Dark Theme | ✅ Yes | ❌ No | |
| JavaScript Control | ✅ Yes | ✅ Yes | |
| 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 | |
| Resource Usage | High | Low | Medium |
| Web Compatibility | Excellent | Good | Excellent |
| Cross-Platform | ✅ Yes | ✅ Yes | ✅ Yes |
| Dependencies | PyQt5, PyQtWebEngine | tkinterweb | pywebview |
| 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 |
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
Recommended: PyQt5 Browser
- Modern UI with tabs
- Excellent web compatibility
- Comprehensive settings
Recommended: Tkinter Browser
- Whitelist/blacklist filtering
- Security headers
- JavaScript control
- Minimal attack surface
Recommended: Tkinter Browser
- Website filtering
- Resource efficiency
- Security controls
Recommended: WebView Browser
- Native OS integration
- Consistent behavior across platforms
- Modern rendering
Recommended: PyQt5 Browser
- Developer tools integration
- Tab support for testing
- Modern debugging features
Recommended: Tkinter Browser
- Minimal memory usage
- Low CPU requirements
- Fast startup
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
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
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
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()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 = {...}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"To add new features to the PyQt5 browser:
- Add UI elements to
create_navigation_bar() - Implement handler methods
- Update
SettingsDialogif configuration needed - 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
passTo add new features to the Tkinter browser:
- Add buttons to navigation frame
- Implement handler methods
- 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
passTo add new features to the WebView browser:
- Add buttons to navigation frame
- Implement handler methods
- Integrate with webview API if needed
- VPN toggle is a placeholder (not implemented)
- No whitelist/blacklist support
- No bookmark management
- Higher resource usage
- Limited web compatibility (older rendering engine)
- No tab support
- Basic UI appearance
- JavaScript filtering is basic
- Custom user-agent not supported
- Limited control over webview behavior
- Separate window for content
- No developer tools integration
- Bookmark management
- Download manager
- Extension support
- Password manager integration
- Tab support
- Improved JavaScript filtering
- Ad blocking
- Cookie management
- Custom user-agent support
- Developer tools integration
- Extension API
- Multi-window support
- 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
- 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
- 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