Cleaning...

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