Permalink
Browse files

Merge branch 'new-private-browsing'

  • Loading branch information...
The-Compiler committed May 16, 2017
2 parents 658abf7 + adb924a commit 086139110dc06cd3461b9b14c61a9d6f777ebe23
Showing with 593 additions and 680 deletions.
  1. +5 −1 doc/help/commands.asciidoc
  2. +30 −4 doc/help/settings.asciidoc
  3. +1 −1 qutebrowser/app.py
  4. +7 −3 qutebrowser/browser/browsertab.py
  5. +20 −10 qutebrowser/browser/commands.py
  6. +0 −3 qutebrowser/browser/history.py
  7. +6 −4 qutebrowser/browser/navigate.py
  8. +1 −1 qutebrowser/browser/qtnetworkdownloads.py
  9. +3 −1 qutebrowser/browser/shared.py
  10. +4 −3 qutebrowser/browser/webelem.py
  11. +30 −18 qutebrowser/browser/webengine/webenginesettings.py
  12. +13 −10 qutebrowser/browser/webengine/webenginetab.py
  13. +11 −5 qutebrowser/browser/webengine/webview.py
  14. +7 −136 qutebrowser/browser/webkit/cache.py
  15. +10 −26 qutebrowser/browser/webkit/network/networkmanager.py
  16. +10 −18 qutebrowser/browser/webkit/webkitsettings.py
  17. +10 −3 qutebrowser/browser/webkit/webkittab.py
  18. +2 −2 qutebrowser/browser/webkit/webpage.py
  19. +3 −2 qutebrowser/browser/webkit/webview.py
  20. +21 −4 qutebrowser/config/configdata.py
  21. +28 −17 qutebrowser/mainwindow/mainwindow.py
  22. +108 −103 qutebrowser/mainwindow/statusbar/bar.py
  23. +6 −6 qutebrowser/mainwindow/statusbar/command.py
  24. +0 −2 qutebrowser/mainwindow/statusbar/percentage.py
  25. +0 −2 qutebrowser/mainwindow/statusbar/progress.py
  26. +0 −2 qutebrowser/mainwindow/statusbar/url.py
  27. +9 −4 qutebrowser/mainwindow/tabbedbrowser.py
  28. +1 −7 qutebrowser/misc/cmdhistory.py
  29. +1 −1 qutebrowser/misc/consolewidget.py
  30. +1 −1 qutebrowser/misc/miscwidgets.py
  31. +20 −8 qutebrowser/misc/sessions.py
  32. +1 −3 scripts/dev/run_vulture.py
  33. +12 −4 tests/end2end/features/conftest.py
  34. +0 −34 tests/end2end/features/misc.feature
  35. +1 −1 tests/end2end/features/open.feature
  36. +118 −0 tests/end2end/features/private.feature
  37. +0 −13 tests/end2end/features/test_misc_bdd.py
  38. +41 −0 tests/end2end/features/test_private_bdd.py
  39. +2 −2 tests/end2end/features/urlmarks.feature
  40. +11 −7 tests/end2end/fixtures/quteprocess.py
  41. +2 −2 tests/end2end/fixtures/testprocess.py
  42. +18 −0 tests/end2end/test_invocations.py
  43. +1 −1 tests/helpers/stubs.py
  44. +5 −14 tests/unit/browser/webkit/network/test_networkmanager.py
  45. +7 −152 tests/unit/browser/webkit/test_cache.py
  46. +4 −37 tests/unit/browser/webkit/test_history.py
  47. +1 −1 tests/unit/misc/test_cmdhistory.py
  48. +1 −1 tests/unit/misc/test_miscwidgets.py
@@ -544,7 +544,8 @@ For `increment` and `decrement`, the number to change the URL by. For `up`, the
[[open]]
=== open
Syntax: +:open [*--implicit*] [*--bg*] [*--tab*] [*--window*] [*--secure*] ['url']+
Syntax: +:open [*--implicit*] [*--bg*] [*--tab*] [*--window*] [*--secure*] [*--private*]
['url']+
Open a URL in the current/[count]th tab.
@@ -560,6 +561,7 @@ If the URL contains newlines, each line gets opened in its own tab.
* +*-t*+, +*--tab*+: Open in a new tab.
* +*-w*+, +*--window*+: Open in a new window.
* +*-s*+, +*--secure*+: Force HTTPS.
* +*-p*+, +*--private*+: Open a new window in private browsing mode.
==== count
The tab index to open the URL in.
@@ -743,6 +745,7 @@ Load a session.
[[session-save]]
=== session-save
Syntax: +:session-save [*--current*] [*--quiet*] [*--force*] [*--only-active-window*]
[*--with-private*]
['name']+
Save a session.
@@ -756,6 +759,7 @@ Save a session.
* +*-q*+, +*--quiet*+: Don't show confirmation message.
* +*-f*+, +*--force*+: Force saving internal sessions (starting with an underline).
* +*-o*+, +*--only-active-window*+: Saves only tabs of the currently active window.
* +*-p*+, +*--with-private*+: Include private windows.
[[set]]
=== set
@@ -18,7 +18,7 @@
|<<general-auto-save-interval,auto-save-interval>>|How often (in milliseconds) to auto-save config/cookies/etc.
|<<general-editor,editor>>|The editor (and arguments) to use for the `open-editor` command.
|<<general-editor-encoding,editor-encoding>>|Encoding to use for editor.
|<<general-private-browsing,private-browsing>>|Do not record visited pages in the history or store web page icons.
|<<general-private-browsing,private-browsing>>|Open new windows in private browsing mode which does not record visited pages.
|<<general-developer-extras,developer-extras>>|Enable extra tools for Web developers.
|<<general-print-element-backgrounds,print-element-backgrounds>>|Whether the background color and images are also drawn when the page is printed.
|<<general-xss-auditing,xss-auditing>>|Whether load requests should be monitored for cross-site scripting attempts.
@@ -221,10 +221,14 @@
|<<colors-completion.scrollbar.bg,completion.scrollbar.bg>>|Color of the scrollbar in completion view
|<<colors-statusbar.fg,statusbar.fg>>|Foreground color of the statusbar.
|<<colors-statusbar.bg,statusbar.bg>>|Background color of the statusbar.
|<<colors-statusbar.fg.private,statusbar.fg.private>>|Foreground color of the statusbar in private browsing mode.
|<<colors-statusbar.bg.private,statusbar.bg.private>>|Background color of the statusbar in private browsing mode.
|<<colors-statusbar.fg.insert,statusbar.fg.insert>>|Foreground color of the statusbar in insert mode.
|<<colors-statusbar.bg.insert,statusbar.bg.insert>>|Background color of the statusbar in insert mode.
|<<colors-statusbar.fg.command,statusbar.fg.command>>|Foreground color of the statusbar in command mode.
|<<colors-statusbar.bg.command,statusbar.bg.command>>|Background color of the statusbar in command mode.
|<<colors-statusbar.fg.command.private,statusbar.fg.command.private>>|Foreground color of the statusbar in private browsing + command mode.
|<<colors-statusbar.bg.command.private,statusbar.bg.command.private>>|Background color of the statusbar in private browsing + command mode.
|<<colors-statusbar.fg.caret,statusbar.fg.caret>>|Foreground color of the statusbar in caret mode.
|<<colors-statusbar.bg.caret,statusbar.bg.caret>>|Background color of the statusbar in caret mode.
|<<colors-statusbar.fg.caret-selection,statusbar.fg.caret-selection>>|Foreground color of the statusbar in caret mode with a selection
@@ -395,7 +399,7 @@ Default: +pass:[utf-8]+
[[general-private-browsing]]
=== private-browsing
Do not record visited pages in the history or store web page icons.
Open new windows in private browsing mode which does not record visited pages.
Valid values:
@@ -404,8 +408,6 @@ Valid values:
Default: +pass:[false]+
This setting is only available with the QtWebKit backend.
[[general-developer-extras]]
=== developer-extras
Enable extra tools for Web developers.
@@ -1906,6 +1908,18 @@ Background color of the statusbar.
Default: +pass:[black]+
[[colors-statusbar.fg.private]]
=== statusbar.fg.private
Foreground color of the statusbar in private browsing mode.
Default: +pass:[${statusbar.fg}]+
[[colors-statusbar.bg.private]]
=== statusbar.bg.private
Background color of the statusbar in private browsing mode.
Default: +pass:[#666666]+
[[colors-statusbar.fg.insert]]
=== statusbar.fg.insert
Foreground color of the statusbar in insert mode.
@@ -1930,6 +1944,18 @@ Background color of the statusbar in command mode.
Default: +pass:[${statusbar.bg}]+
[[colors-statusbar.fg.command.private]]
=== statusbar.fg.command.private
Foreground color of the statusbar in private browsing + command mode.
Default: +pass:[${statusbar.fg.private}]+
[[colors-statusbar.bg.command.private]]
=== statusbar.bg.command.private
Background color of the statusbar in private browsing + command mode.
Default: +pass:[${statusbar.bg.private}]+
[[colors-statusbar.fg.caret]]
=== statusbar.fg.caret
Foreground color of the statusbar in caret mode.
@@ -195,7 +195,7 @@ def _process_args(args):
session_manager = objreg.get('session-manager')
if not session_manager.did_load:
log.init.debug("Initializing main window...")
window = mainwindow.MainWindow()
window = mainwindow.MainWindow(private=None)
if not args.nowindow:
window.show()
qApp.setActiveWindow(window)
@@ -35,11 +35,12 @@
tab_id_gen = itertools.count(0)
def create(win_id, parent=None):
def create(win_id, private, parent=None):
"""Get a QtWebKit/QtWebEngine tab object.
Args:
win_id: The window ID where the tab will be shown.
private: Whether the tab is a private/off the record tab.
parent: The Qt parent to set.
"""
# Importing modules here so we don't depend on QtWebEngine without the
@@ -51,7 +52,8 @@ def create(win_id, parent=None):
else:
from qutebrowser.browser.webkit import webkittab
tab_class = webkittab.WebKitTab
return tab_class(win_id=win_id, mode_manager=mode_manager, parent=parent)
return tab_class(win_id=win_id, mode_manager=mode_manager, private=private,
parent=parent)
def init():
@@ -542,6 +544,7 @@ class AbstractTab(QWidget):
Attributes:
history: The AbstractHistory for the current tab.
registry: The ObjectRegistry associated with this tab.
private: Whether private browsing is turned on for this tab.
_load_status: loading status of this page
Accessible via load_status() method.
@@ -581,7 +584,8 @@ class AbstractTab(QWidget):
fullscreen_requested = pyqtSignal(bool)
renderer_process_terminated = pyqtSignal(TerminationStatus, int)
def __init__(self, win_id, mode_manager, parent=None):
def __init__(self, *, win_id, mode_manager, private, parent=None):
self.private = private
self.win_id = win_id
self.tab_id = next(tab_id_gen)
super().__init__(parent)
@@ -67,10 +67,10 @@ def __init__(self, win_id, tabbed_browser):
def __repr__(self):
return utils.get_repr(self)
def _new_tabbed_browser(self):
def _new_tabbed_browser(self, private):
"""Get a tabbed-browser from a new window."""
from qutebrowser.mainwindow import mainwindow
new_window = mainwindow.MainWindow()
new_window = mainwindow.MainWindow(private=private)
new_window.show()
return new_window.tabbed_browser
@@ -110,20 +110,25 @@ def _current_widget(self):
return widget
def _open(self, url, tab=False, background=False, window=False,
explicit=True):
explicit=True, private=None):
"""Helper function to open a page.
Args:
url: The URL to open as QUrl.
tab: Whether to open in a new tab.
background: Whether to open in the background.
window: Whether to open in a new window
private: If opening a new window, open it in private browsing mode.
If not given, inherit the current window's mode.
"""
urlutils.raise_cmdexc_if_invalid(url)
tabbed_browser = self._tabbed_browser
cmdutils.check_exclusive((tab, background, window), 'tbw')
if window:
tabbed_browser = self._new_tabbed_browser()
cmdutils.check_exclusive((tab, background, window, private), 'tbwp')
if private is None:
private = self._tabbed_browser.private
if window or private:
tabbed_browser = self._new_tabbed_browser(private)
tabbed_browser.tabopen(url)
elif tab:
tabbed_browser.tabopen(url, background=False, explicit=explicit)
@@ -228,7 +233,8 @@ def tab_close(self, prev=False, next_=False, opposite=False, count=None):
@cmdutils.argument('url', completion=usertypes.Completion.url)
@cmdutils.argument('count', count=True)
def openurl(self, url=None, implicit=False,
bg=False, tab=False, window=False, count=None, secure=False):
bg=False, tab=False, window=False, count=None, secure=False,
private=False):
"""Open a URL in the current/[count]th tab.
If the URL contains newlines, each line gets opened in its own tab.
@@ -242,6 +248,7 @@ def openurl(self, url=None, implicit=False,
clicking on a link).
count: The tab index to open the URL in, or None.
secure: Force HTTPS.
private: Open a new window in private browsing mode.
"""
if url is None:
urls = [config.get('general', 'default-page')]
@@ -254,8 +261,10 @@ def openurl(self, url=None, implicit=False,
if not window and i > 0:
tab = False
bg = True
if tab or bg or window:
self._open(cur_url, tab, bg, window, not implicit)
if tab or bg or window or private:
self._open(cur_url, tab, bg, window, explicit=not implicit,
private=private)
else:
curtab = self._cntwidget(count)
if curtab is None:
@@ -430,7 +439,8 @@ def tab_clone(self, bg=False, window=False):
# The new tab could be in a new tabbed_browser (e.g. because of
# tabs-are-windows being set)
if window:
new_tabbed_browser = self._new_tabbed_browser()
new_tabbed_browser = self._new_tabbed_browser(
private=self._tabbed_browser.private)
else:
new_tabbed_browser = self._tabbed_browser
newtab = new_tabbed_browser.tabopen(background=bg)
@@ -27,7 +27,6 @@
from qutebrowser.commands import cmdutils
from qutebrowser.utils import (utils, objreg, standarddir, log, qtutils,
usertypes, message)
from qutebrowser.config import config
from qutebrowser.misc import lineparser, objects
@@ -280,8 +279,6 @@ def add_url(self, url, title="", *, redirect=False, atime=None):
(hidden in completion)
atime: Override the atime used to add the entry
"""
if config.get('general', 'private-browsing'):
return
if not url.isValid(): # pragma: no cover
# the no cover pragma is a WORKAROUND for this not being covered in
# old Qt versions.
@@ -127,17 +127,19 @@ def _prevnext_cb(elems):
return
qtutils.ensure_valid(url)
cur_tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=win_id)
if window:
from qutebrowser.mainwindow import mainwindow
new_window = mainwindow.MainWindow()
new_window = mainwindow.MainWindow(
private=cur_tabbed_browser.private)
new_window.show()
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=new_window.win_id)
tabbed_browser.tabopen(url, background=False)
elif tab:
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=win_id)
tabbed_browser.tabopen(url, background=background)
cur_tabbed_browser.tabopen(url, background=background)
else:
browsertab.openurl(url)
@@ -366,7 +366,7 @@ class DownloadManager(downloads.AbstractDownloadManager):
def __init__(self, win_id, parent=None):
super().__init__(parent)
self._networkmanager = networkmanager.NetworkManager(
win_id, None, self)
win_id=win_id, tab_id=None, private=False, parent=self)
@pyqtSlot('QUrl')
def get(self, url, *, user_agent=None, **kwargs):
@@ -216,8 +216,10 @@ def get_tab(win_id, target):
win_id = win_id
bg_tab = True
elif target == usertypes.ClickTarget.window:
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=win_id)
from qutebrowser.mainwindow import mainwindow
window = mainwindow.MainWindow()
window = mainwindow.MainWindow(private=tabbed_browser.private)
window.show()
win_id = window.win_id
bg_tab = False
@@ -364,15 +364,16 @@ def _click_href(self, click_target):
self._click_fake_event(click_target)
return
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=self._tab.win_id)
if click_target in [usertypes.ClickTarget.tab,
usertypes.ClickTarget.tab_bg]:
background = click_target == usertypes.ClickTarget.tab_bg
tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=self._tab.win_id)
tabbed_browser.tabopen(url, background=background)
elif click_target == usertypes.ClickTarget.window:
from qutebrowser.mainwindow import mainwindow
window = mainwindow.MainWindow()
window = mainwindow.MainWindow(private=tabbed_browser.private)
window.show()
window.tabbed_browser.tabopen(url)
else:
Oops, something went wrong.

0 comments on commit 0861391

Please sign in to comment.