-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clear browsing data on exit. #1213
Conversation
250044f
to
edd9a56
Compare
...-browser-resources-settings-clear_browsing_data_dialog-clear_browsing_data_dialog.html.patch
Outdated
Show resolved
Hide resolved
...me-browser-resources-settings-clear_browsing_data_dialog-clear_browsing_data_dialog.js.patch
Show resolved
Hide resolved
dc1098f
to
a74e5cd
Compare
browser/BUILD.gn
Outdated
@@ -11,8 +11,18 @@ source_set("browser_process") { | |||
"bookmarks/brave_bookmark_client.h", | |||
"brave_browser_main_extra_parts.cc", | |||
"brave_browser_main_extra_parts.h", | |||
"brave_browser_main_parts.cc", | |||
"brave_browser_main_parts.h", | |||
"brave_browser_main_parts_android.cc", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need all of these brave_browser_main_parts_os
files because none of them implement PreShutdown
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ChromeBrowserMainParts inherit from ChromeBrowserMainParts (except Linux and Mac which both inherit from Posix). If I just subclass ChromeBrowserMainParts I would still have to change ChromeBrowserMainParts<Win,Android,Posix> to inherit from the new subclass (see instantiation in https://cs.chromium.org/chromium/src/chrome/browser/chrome_content_browser_client.cc?l=1150).
Also, while none of them override PreShutdown now I am not sure we can depend on it staying this way or, if they do override, that they'd call the base class implementation.
|
||
int num_profiles_to_clear_ = 0; | ||
base::RunLoop run_loop_; | ||
ScopedObserver<content::BrowsingDataRemover, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused. The is a subclass of content::BrowsingDataRemover::Observer
, but also has an internal ScopedObserver
for content::BrowsingDataRemover::Observer
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am following the patter suggested in the comment here: https://cs.chromium.org/chromium/src/content/public/browser/browsing_data_remover.h?l=41 but delegating keeping track of content::BrowsingDataRemover for each profile to ScopedObserver.
a55cd20
to
3fc55a9
Compare
Please open a security review issue for this when ready, thanks. |
...ces/settings/brave_clear_browsing_data_dialog/brave_clear_browsing_data_dialog_behavior.html
Outdated
Show resolved
Hide resolved
5982a91
to
bf99490
Compare
The checkboxes in the dialog don't seem to be remembering state for me. But the save button knows that the state (with the boxes unchecked) is different to what is saved. i.e.:
|
Looks like it works on Debug builds but not Release build. Confirming... |
Just built Release, seems to be working for me. |
sorry @mkarolin false alarm on both fronts it seems. I can't replicate the issue I had with the checkboxes either 🤷♂️ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UI changes in settings are great. Thanks for looking at the minimized patching. After discussing again with @bridiver I have some improvements to make this and some other settings modifications 0-patch, but I'll do that in a follow-up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great 😄
// static | ||
void BraveClearBrowsingData::ClearOnExit() { | ||
TRACE_EVENT0("browser", "BraveClearBrowsingData::ClearOnExit"); | ||
// Do not clear browsing data when the OS is ending session (logout/reboot/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally, it would be nice to document this somewhere that's user-visible. If it's too much information for the UI, maybe a page on support.brave.com
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bsclifton, @rebron ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fmarier support.brave.com might not be the right audience for that- but we can definitely document custom trace events in our wiki. @mkarolin I created a stub page, if you wanted to add that (and describe why you'd use it):
https://github.com/brave/brave-browser/wiki/Custom-tracing-events
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bsclifton, I understood it that @fmarier was referring to the comment that we are not clearing browsing data on logout/reboot/shutdown.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkarolin ah- LOL; that makes a lot more sense 😂
cc'ing @Brave-Matt on that one - would be great to document this feature in general 😄 @Brave-Matt: this would be something we're planning for 0.63.x
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, what I was referring to was not the trace events, but the limitation that if you shutdown your computer, it won't clear your history.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a very bad limitation, which would probably surprise a lot of people who use the feature. IMO, we should back this out and fix that problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc: @rebron for the above comment by @tomlowenthal ^^
We may want to compare with Muon- it's possible Muon had that same limitation also. If the current experience is WORSE than Muon (ex: Muon works as expected), then I definitely agree that we should consider hiding this new UI until that problem is resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tomlowenthal should brave/brave-browser#3549 cover this use-case also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that issue is intended to be the new partial fix for this… someday.
} | ||
|
||
int GetRemoveMaskAll() { | ||
return ChromeBrowsingDataRemoverDelegate::DATA_TYPE_HISTORY | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should "Hosted App Data" be included here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Hosted App Data" is defined as a combination of mask = ChromeBrowsingDataRemoverDelegate::DATA_TYPE_SITE_DATA
and origin = content::BrowsingDataRemover::ORIGIN_TYPE_PROTECTED_WEB
, so it should be already accounted for.
I noticed that "Media licences" is missing from the list of things that can be cleared on shutdown, even though it's part of the Advanced tab. Is that intentional? |
@fmarier, "Media licenses" is no longer a part of the commit 3dece3d74d88a717a3a1e77eea8916e48847d8e8 Author: John Rummell Date: Thu Jan 10 00:34:57 2019 +0000 Remove "Media Licenses" from Clear Browsing Data dialog Media licenses will now be deleted when "Cookies and site data" is selected. BUG=901993 |
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/profiles/profile_manager.h" | ||
#include "chrome/common/pref_names.h" | ||
#include "components/browsing_data/core/pref_names.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to a dep for this here https://github.com/brave/brave-core/pull/1213/files#diff-84f8700538180eec90bb2f4c9dff4da4R79
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
Fixes brave/brave-browser#492 1. Adds a new "On exit" tab to chrome://settings/clearBrowserData dialog with the same options as on the "Advanced" tab and a "Save" button. By default all "On exit" options are turned off. When an option is modified from the current state the Save button becomes enabled and allows the user to save the "on exit" options. The options are saved to profile's preferences: new *OnExit preferences have been added for each option. 2. Clear browsing data on exit functionality is triggered from BraveBrowserMainParts::PreShutdown override. For each loaded profile the code checks if user selected any on exit options and if so then a BrowsingDataRemover is called. 3. Adds BraveClearDataOnExitTest and BraveClearDataOnExitTwoBrowsersTest browser tests that verify that: - the removal of the browsing data is triggered only when an "on exit" preference is set; - the removal flags are constrcuted correctly; - the removal is called only when the browser is exiting (tests with OTR/Guest/multiple profiles).
bf99490
to
02e63a9
Compare
Fixes brave/brave-browser#492
Adds a new "On exit" tab to chrome://settings/clearBrowserData dialog
with the same options as on the "Advanced" tab and a "Save" button. By
default all "On exit" options are turned off. When an option is modified
from the current state the Save button becomes enabled and allows the
user to save the "on exit" options. The options are saved to profile's
preferences: new *OnExit preferences have been added for each option.
Clear browsing data on exit functionality is triggered from
BraveBrowserMainParts::PreShutdown overrides. For each loaded profile
the code checks if user selected any on exit options and if so then a
BrowsingDataRemover is called.
Adds BraveClearDataOnExitTest and BraveClearDataOnExitTwoBrowsersTest
browser tests that verify that:
preference is set;
OTR/Guest/multiple profiles).
Submitter Checklist:
npm test brave_unit_tests && npm test brave_browser_tests
) ongit rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Automated tests:
npm run test -- brave_browser_tests --filter=BraveClearDataOnExitTest.*
npm run test -- brave_browser_tests --filter=BraveClearDataOnExitTwoBrowsersTest.*
Manual tests:
1. Verify browsing history removal.
brave://settings/clearBrowserData
, select "On exit" tab, check "Browsing History" box,brave://history/
and verify that it's empty,brave://history/
tab, reload the page and verify that an entry for the site has appeared,brave://history/
and verify that it's empty.2. Verify downloads history removal.
brave://settings/clearBrowserData
, select "On exit" tab, check "Download History" box,brave://downloads/
and verify that it's empty,Save As...
, save the page and wait for the download to complete; then close the tab,brave://downloads/
tab, reload the page and verify that an entry for the site has appeared,brave://downloads/
and verify that it's empty.3. Verify cookies removal.
brave://settings/clearBrowserData
, select "On exit" tab, check "Cookies and other site data" box,brave://settings/siteData
and verify that it's empty,brave://settings/siteData
tab, reload the page and verify that entries for the site have appeared (cookies and possibly local storage),brave://settings/siteData
and verify that it's empty. Note: on Linux, while cookies should be gone, the local storage will remain - this is not specific to clearing data on exit and behaves the same way when clearing data from the Advanced tab of Clear Browsing Data dialog.4. Verify cache removal.
brave://settings/clearBrowserData
, select "On exit" tab, check "Cached images and files" box,Alternatively, on Windows you can use NirSoft's ChromeCacheView and point it to Brave's cache, verify the cache content before exiting the browser and after.
5. Verify passwords removal.
brave://settings/clearBrowserData
, select "On exit" tab, check "Passwords and other sign-in data" box,brave://settings/passwords
and verify that the Saved Passwords list is empty,brave://settings/passwords
tab, reload the page and verify that an entry for the site has appeared in the Saved Passwords list,brave://settings/passwords
and verify that the Saved Passwords list is empty.6. Verify autofill form data removal.
brave://settings/clearBrowserData
, select "On exit" tab, check "Autofill form data" box,brave://settings/payments
and verify that the Payment methods list is empty,brave://settings/payments
and verify that the Payment methods list is empty.7. Verify content settings removal.
brave://settings/clearBrowserData
, select "On exit" tab, check "Content settings" box,brave://settings/content/javascript
and verify that the Block list is empty,brave://settings/content/javascript
and verify that the Block list is empty.Note: this will also clear out per site Brave Shields settings.
8. Test that clearing data on exit and manually produce the same results (suggested by @fmarier, thx!)
diff -Nurd original/ autocleared/
on Linux).This will allow us to:
Reviewer Checklist: