-
Notifications
You must be signed in to change notification settings - Fork 870
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
Add setting option for disabling tor component #4046
Conversation
0431d5a
to
cbdc72c
Compare
browser/resources/settings/brave_default_extensions_page/brave_default_extensions_page.html
Outdated
Show resolved
Hide resolved
a40dc70
to
576f1d6
Compare
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.
Changes look good and work great! As shared here, some of these blocks of settings are getting crowded and could use some organization
There was a lint problem, I just pushed a fix for. All other CI passed fine (only failure besides lint was on Publish xUnit test result report
which is fine)
@bsclifton Thanks for fixing lint error 👍 |
@rebron Can you check the this options' title and position? |
e55d35d
to
ee87251
Compare
Friendly ping to owner review @bridiver |
void GetTorDisabled(const base::ListValue* args); | ||
void OnTorDisabledChanged(); | ||
#endif | ||
void GetEnableTorOption(const base::ListValue* args); |
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.
What is this?
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.
This is used to determine whether Disable Tor
option should be enabled or not.
If tor is managed by group policy or tor is not built, this setting option should be in disabled state.
Added comment for this method.
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.
If the tor feature is not included we shouldn't be showing any UI for it at all and we can detect that with the buildflag so we don't need a method for it. For group policy it should be IsTorManaged
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.
Yes, I agree with you. UI should not be visible if tor is not built.
To do this, I tried to hide settings UI by using template with dom-if
.
However, toggle button can't get proper runtime value change if it is inside template.
I debugged this with @bsclifton but can't find solution at that time.
Maybe we need to dig more about polymer.
So, I left like this because we would not build brave w/o tor.
How about this as a f/u?
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 trying to find how to hide webui with buildflags.
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.
Moved this into tor buildflags with renamed one.
and tor settings will be hidden by adding enable_tor
defines to grit defines.
Much more clear 👍
|
||
void GetRestartNeeded(const base::ListValue* args); | ||
void SetWebTorrentEnabled(const base::ListValue* args); | ||
void SetHangoutsEnabled(const base::ListValue* args); | ||
void SetIPFSCompanionEnabled(const base::ListValue* args); | ||
void SetMediaRouterEnabled(const base::ListValue* args); | ||
void SetBraveWalletEnabled(const base::ListValue* args); | ||
#if BUILDFLAG(ENABLE_TOR) | ||
void SetTorDisabled(const base::ListValue* args); |
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.
please use Enabled
, not Disabled
. It's easier to understand and more consistent with everything else.
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.
Agreed that negative expression makes difficult to read/understand.
How about this leave as a f/u?
Just using enabled
in this class also could increase complexity because related pref name is kTorDisabled
and options name is also Disable Tor
. Also some related static methods are IsTorDisabled()
and already used by many other places.
I think it would be good to clean this up as a separate PR. WDYT?
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.
@bridiver, Changed to Enabled
as settings text is changed to enabled meaning.
@@ -23,15 +25,23 @@ class BraveDefaultExtensionsHandler : public settings::SettingsPageUIHandler { | |||
private: | |||
// SettingsPageUIHandler overrides: | |||
void RegisterMessages() override; | |||
void OnJavascriptAllowed() override; | |||
void OnJavascriptDisallowed() override; | |||
void OnJavascriptAllowed() override {} |
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.
why are you defining these as empty methods? What's the point of overriding them if we're not going to implement them?
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.
It's because they are pure virtual method in base class.
@@ -149,6 +149,8 @@ void BraveAddCommonStrings(content::WebUIDataSource* html_source, | |||
IDS_SETTINGS_IPFS_COMPANION_ENABLED_DESC}, | |||
{"mediaRouterEnabledDesc", | |||
IDS_SETTINGS_MEDIA_ROUTER_ENABLED_DESC}, | |||
{"torDisabledLabel", |
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.
same as above disabled -> enabled. It is almost always better to use the "positive" form for readability
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.
done.
ee87251
to
e07a3a9
Compare
cc: @TomL for final text. Instead of |
e07a3a9
to
695ebda
Compare
227578c
to
d127206
Compare
|
||
void BraveBrowserProcessImpl::OnTorEnabledChanged() { | ||
// Update all browsers' tor command status. | ||
for (Browser* browser : *BrowserList::GetInstance()) { |
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.
When tor option is changed, all browsers' tor commands are updated.
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.
does the utility process automatically shut down when all tor windows are closed?
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.
In nightly, tor process is gone. but not in stable version.
9b49d20
to
768f6ec
Compare
@@ -57,6 +57,10 @@ | |||
|
|||
#if BUILDFLAG(ENABLE_TOR) | |||
#include "brave/browser/extensions/brave_tor_client_updater.h" | |||
#include "brave/browser/ui/brave_browser_command_controller.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.
even though these are only used when tor is enabled, I still think it's a bad idea to put them in this guard because in the future other things may use these same header files and people may not move them out of the ENABLE_TOR block when that happens. I think only tor header files should go in 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.
Fixed.
browser/brave_browser_process_impl.h
Outdated
@@ -85,6 +89,7 @@ class BraveBrowserProcessImpl : public BrowserProcessImpl { | |||
brave_component_updater::LocalDataFilesService* local_data_files_service(); | |||
#if BUILDFLAG(ENABLE_TOR) | |||
extensions::BraveTorClientUpdater* tor_client_updater(); | |||
void OnTorEnabledChanged(); |
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.
this shouldn't be public
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.
Done.
browser/brave_browser_process_impl.h
Outdated
@@ -130,6 +135,7 @@ class BraveBrowserProcessImpl : public BrowserProcessImpl { | |||
#endif | |||
#if BUILDFLAG(ENABLE_TOR) | |||
std::unique_ptr<extensions::BraveTorClientUpdater> tor_client_updater_; | |||
PrefChangeRegistrar local_state_change_registrar_; |
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.
there is already pref_change_registrar_
in the superclass
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.
Done.
6606dae
to
93a032d
Compare
and did some code cleanup.
Tor enabling change should only affect to browser after relaunching. To cache user's change before relaunching, new kTorDisabledAtNextLaunching pref value is introduced.
To check whether tor is enabled or not, tor component registration is used instead of pref value because user can change pref via settings. With this, we don't need to another prefs to check user changed or not.
Browsr commands will be updated after changing tor option. If user turns it off, tor component will be removed at the next launching. If there is already opened tor window, it can be used. But, user can't create new tor window anymore.
93a032d
to
3e01e1f
Compare
CI on macOS has below error. |
This should also fix brave/brave-browser#4904. |
fix brave/brave-browser#6808
When tor is managed by group policy, this option is disabled. (only possible on Windows now)
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
yarn test brave_browser_tests --filter=BraveLocalStateBrowserTest*
yarn test brave_browser_tests --filter=TorDisabledPolicyBrowserTest*
yarn test brave_browser_tests --filter=TorEnabledPolicyBrowserTest*
yarn test brave_browser_tests --filter=NoTorPolicyBrowserTest*
Manual test steps
Tor
is on by defaultReviewer Checklist:
After-merge Checklist:
changes has landed on.