Cleaning...

parent ad530998
......@@ -1543,6 +1543,7 @@ class ChromeUrlInterceptor(QWebEngineUrlRequestInterceptor):
# The actual handling is done by ChromeWebEnginePage
# XXX QUI
class ExtensionSchemeHandler(QWebEngineUrlSchemeHandler):
"""A custom URL scheme handler for loading extension files."""
def __init__(self, extensions_dir, parent=None):
......@@ -1565,7 +1566,8 @@ class ExtensionSchemeHandler(QWebEngineUrlSchemeHandler):
if os.path.exists(assets_file_path):
file_path = assets_file_path
try:
#try:
if True:
with open(file_path, 'rb') as f:
content = f.read()
......@@ -1582,7 +1584,8 @@ class ExtensionSchemeHandler(QWebEngineUrlSchemeHandler):
# Special handling for HTML files - inject WebChannel initialization code
if file_path.endswith(('.html', '.htm')) and mime_type in (b'text/html', b'application/xhtml+xml'):
print(f"Injecting WebChannel initialization into HTML file: {file_path}")
try:
#try:
if True:
# Decode the HTML content
html_content = content.decode('utf-8')
......@@ -1716,15 +1719,19 @@ class ExtensionSchemeHandler(QWebEngineUrlSchemeHandler):
# Convert back to bytes
content = html_content.encode('utf-8')
except Exception as e:
print(f"Error injecting WebChannel initialization: {e}")
# Continue with the original content if there's an error
#except Exception as e:
# print(f"Error injecting WebChannel initialization: {e}")
# # Continue with the original content if there's an error
# Special handling for service worker scripts
if resource_path.endswith('background.js'):
print(f"Loading background script: {file_path}")
# You might want to add special headers or processing for service workers
print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaa")
print(file_path)
print("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAaa")
buf = QBuffer(parent=self)
buf.setData(content)
buf.open(QBuffer.OpenModeFlag.ReadOnly)
......@@ -1735,9 +1742,9 @@ class ExtensionSchemeHandler(QWebEngineUrlSchemeHandler):
# Reply with the content
job.reply(mime_type, buf)
print(f"Replied with content for: {file_path}")
except FileNotFoundError:
print(f"Extension resource not found: {file_path}")
"""
except FileNotFoundError as e:
print(f"Extension resource not found: {file_path} {e}")
job.fail(QWebEngineUrlRequestJob.Error.UrlNotFound)
if job in self.jobs:
del self.jobs[job]
......@@ -1747,7 +1754,7 @@ class ExtensionSchemeHandler(QWebEngineUrlSchemeHandler):
if job in self.jobs:
del self.jobs[job]
"""
class ExtensionDialog(QDialog):
"""
Dialog for managing browser extensions.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment