summaryrefslogtreecommitdiff
path: root/qutebrowser
diff options
context:
space:
mode:
authorJimmy <jimmy@spalge.com>2021-12-04 09:50:06 +1300
committerJimmy <jimmy@spalge.com>2021-12-04 12:13:29 +1300
commitec200c3486f6e57c084c947a2661461d709348ae (patch)
tree274b82f7e9ded79232683f87199650e40938f4d2 /qutebrowser
parentf74acc287c58ee750894b5469c6369af0e759781 (diff)
downloadqutebrowser-ec200c3486f6e57c084c947a2661461d709348ae.tar.gz
qutebrowser-ec200c3486f6e57c084c947a2661461d709348ae.zip
Let inspector know about on-the-record profiles.
The developer tools only saves preferences to disk, and reads them from disk, if the profile of the page they are drawing to isn't off-the-record. So if you want it to remember your dark mode preference the page hosting the inspector needs to be linked to an on-the-record profile. So we need to create a new page linked to a specific profile and then set that on the view. Options at this point: 1. (in `__init__()` always make a new page linked to the qute default profile and add that to the view 2. delay creating the view and page until `inspect()` is called and get a pointer to the profile of the page being inspected (1) is actually what we have done on previous Qt versions because there the inspector was started with WebEngine's default, global, profile, which used to be on-the-record. I'm not sure if there are any specific ramifications to having the inspector data persistent when the page it is attached to isn't, but there might be stuff like per-domain preferences saved in that case which would be an information leak. So I've went with (2) even though it is probably going to be more disruptive to the tests. In the future if we re-use inspectors across different tabs/windows again we can make a new page on demand if the profile of the inspected page differs form the initial one. For now I've put an assert there because I am lazy. It's a bit awkward having most of the setup in `inspect()` and not `__init__()`. `_init_inspector()` and `inspect()` are only ever called once right beside each other though (now) so we could just pass the page to `__init__()` and get rid of `inspect()`.
Diffstat (limited to 'qutebrowser')
-rw-r--r--qutebrowser/browser/webengine/webengineinspector.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/qutebrowser/browser/webengine/webengineinspector.py b/qutebrowser/browser/webengine/webengineinspector.py
index 7ad51fd7b..bb19ef153 100644
--- a/qutebrowser/browser/webengine/webengineinspector.py
+++ b/qutebrowser/browser/webengine/webengineinspector.py
@@ -62,13 +62,7 @@ class WebEngineInspector(inspector.AbstractWebInspector):
parent: QWidget = None) -> None:
super().__init__(splitter, win_id, parent)
self._check_devtools_resources()
-
- view = WebEngineInspectorView()
- self._settings = webenginesettings.WebEngineSettings(view.settings())
- self._set_widget(view)
- page = view.page()
- page.windowCloseRequested.connect( # type: ignore[attr-defined]
- self._on_window_close_requested)
+ self._settings = None
def _on_window_close_requested(self) -> None:
"""Called when the 'x' was clicked in the devtools."""
@@ -98,7 +92,21 @@ class WebEngineInspector(inspector.AbstractWebInspector):
"Fedora package.")
def inspect(self, page: QWebEnginePage) -> None: # type: ignore[override]
+ if not self._widget:
+ view = WebEngineInspectorView()
+ inspector_page = QWebEnginePage(
+ page.profile(),
+ self
+ )
+ inspector_page.windowCloseRequested.connect( # type: ignore[attr-defined]
+ self._on_window_close_requested)
+ view.setPage(inspector_page)
+ self._settings = webenginesettings.WebEngineSettings(view.settings())
+ self._set_widget(view)
+
inspector_page = self._widget.page()
+ assert inspector_page.profile() == page.profile()
+
inspector_page.setInspectedPage(page)
self._settings.update_for_url(inspector_page.requestedUrl())