-
Notifications
You must be signed in to change notification settings - Fork 887
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
Handle onion-location HTTP header & .onion domain #6762
Conversation
bf90cac
to
8e44311
Compare
Refactoring tor into components will come up next (brave/brave-browser#1114) |
@diracdeltas could you help checking if the wording is appropriate? |
@darkdh wording looks good to me! |
@@ -130,6 +130,13 @@ | |||
disabled="[[disableTorOption_]]" | |||
on-settings-boolean-control-change="onTorEnabledChange_"> | |||
</settings-toggle-button> | |||
<settings-toggle-button |
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.
looks like bad spacing
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 in 08ec907
browser/tor/BUILD.gn
Outdated
@@ -36,12 +36,16 @@ source_set("tor") { | |||
"tor_launcher_factory.h", | |||
"tor_navigation_throttle.cc", | |||
"tor_navigation_throttle.h", | |||
"onion_location_navigation_throttle.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.
gn format
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 in 08ec907
@@ -27,6 +27,7 @@ | |||
#endif | |||
|
|||
class BraveActionViewController; | |||
class OnionLocationView; |
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.
better to keep these sorted
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 in 08ec907
namespace { | ||
|
||
bool GetOnionLocation(const net::HttpResponseHeaders* headers, | ||
std::string* onion_location) { |
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.
nit: DCHECK(onion_location)
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 in 08ec907
|
||
content::NavigationThrottle::ThrottleCheckResult | ||
OnionLocationNavigationThrottle::WillProcessResponse() { | ||
if (navigation_handle()->IsInMainFrame()) { |
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.
nit: it's easier to read when
if (!navigation_handle()->IsInMainFrame()) {
return {};
}
is placed at the beginning, and then we go on with the good case
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.
actually I think we shouldn't even create the throttle if this is not a main frame navigation. We can check this right in BraveContentBrowserClient::CreateThrottlesForNavigation
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 in 08ec907
@@ -38,6 +39,7 @@ | |||
#include "ui/views/layout/grid_layout.h" | |||
#include "ui/views/view.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.
extra diff
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 in 08ec907
#ifndef BRAVE_BROWSER_UI_VIEWS_LOCATION_BAR_ONION_LOCATION_VIEW_H_ | ||
#define BRAVE_BROWSER_UI_VIEWS_LOCATION_BAR_ONION_LOCATION_VIEW_H_ | ||
|
||
#include "chrome/browser/profiles/profile.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.
no need to include, we have the forward declaration
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 in 08ec907
@@ -135,22 +137,25 @@ void BraveActionsContainer::Init() { | |||
SetLayoutManager(std::move(vertical_container_layout)); | |||
|
|||
// children | |||
onion_location_view_ = new OnionLocationView(browser_->profile()); |
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.
shouldn't we check the tor group policy or something before adding 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.
No, BraveActionsContainer::Init()
is only called once per window creation.
And the pref toggle for tor::TorProfileService::IsTorDisabled()
doesn't need restarting browser. So if we check and user toggle the pref from off to on, the label will not be shown until next relaunch.
This view will remain invisible until it has onion location and it will be invisible again when #6762 (comment)
Besides, chromium does the same thing in PageActionIcon
like zoom, find...etc. Constructing first and then set visibility according to the condition.
explicit OnionLocationTabHelper(content::WebContents* web_contents); | ||
friend class content::WebContentsUserData<OnionLocationTabHelper>; | ||
|
||
GURL onion_location_; |
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 guess we should clean this state if a navigation happened
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 will be cleaned up if the new navigation destination doesn't have onion-location header per web_contents
https://github.com/brave/brave-core/pull/6762/files#diff-d8f2fb41afdc92a8124ec8a331c1d44dR83
profiles::SwitchToTorProfile( | ||
base::BindRepeating(&OnTorProfileCreated, GURL(onion_location))); | ||
} else { | ||
OnionLocationTabHelper::SetOnionLocation( |
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.
AFAIU there is no way to disable the newly added onion omnibox view, even if I don't want to know about onions - maybe we should consider 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 will hide OnionLocationView
when we navigate away to other website without onion-location header.
This feature will be disabled when user disable tor.
Or do you mean give users another option that they want enabling tor but don't want to see this "Open in Tor"/"Onion Available" label? If so, that sounds very weird, even in Tor browser bundle they don't provide this kind of option. cc @diracdeltas
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, I just want to understand product/UX consequences. There are two facts: (1) "Private window with Tor" pref is enabled by default (2) according to P3A, only 20% of users ever used Tor.
So by always showing this view (for certain websites) we probably will confuse 80% of users who don't care about onion domains at all, and most likely don't want to have any new buttons in the omnibox.
On the other hand, only few sites have the onion counterpart, so for now we are probably ok as is.
@@ -187,6 +190,8 @@ class BraveActionsContainer : public views::View, | |||
|
|||
std::unique_ptr<EmptyExtensionsContainer> empty_extensions_container_; | |||
|
|||
OnionLocationView* onion_location_view_ = nullptr; |
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 think onion view is not brave action.
IMO, OnionLocationView needs another parent view. 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.
@petemill do we need another parent for it? Or should we rename BraveActionContainer
to something that is designated for Brave Icons?
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.
Well, I'm leaning towards suggesting we put this in the regular PageAction
area (or simply in the LocationBar
directly and not the BraveActionsContainer
. BraveActionsContainer
is so named because it's meant to hold only almost-permanent ExtensionActions
(extensions that have popups) that are our main brand calls-to-actions. Of course it all changes if the design isn't as logical or separate as this.
But since the onion button is page-specific, I would suggest it goes in to the appropriate page actions area (or location bar) and keep BraveActionsContainer
for the more permanent items. The visual design seems to agree with that via the visual separator.
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.
addressed here 6fe10b1c7ae2599f4aca93c31279b7456c036cfa
I've built the PR - all looks good, except a minor nit: when automagical switching to .onion in Tor mode is enabled, we do not close the current tab. This way, the .onion website is opened somewhere in the end of the tabstrip, leaving a tab with "normal" URL behind - probably we should close the original tab? |
The crash was fixed in #6820 and I haven't rebase this PR |
at browser startup [8357:775:1008/110058.682124:FATAL:remote.h(97)] Check failed: is_bound(). Cannot issue Interface method calls on an unbound Remote 0 libbase.dylib 0x000000010eb7c7b9 base::debug::CollectStackTrace(void**, unsigned long) + 9 1 libbase.dylib 0x000000010ea67f43 base::debug::StackTrace::StackTrace() + 19 2 libbase.dylib 0x000000010ea8b075 logging::LogMessage::~LogMessage() + 261 3 libbase.dylib 0x000000010ea8bd5e logging::LogMessage::~LogMessage() + 14 4 libchrome_dll.dylib 0x0000000114832d6b TorLauncherFactory::OnTorControlCheckComplete() + 219 5 libchrome_dll.dylib 0x00000001148361cb base::internal::Invoker<base::internal::BindState<void (TorLauncherFactory::*)(), base::WeakPtr<TorLauncherFactory> >, void ()>::RunOnce(base::internal::BindStateBase*) + 155 6 libbase.dylib 0x000000010eb09dbb base::TaskAnnotator::RunTask(char const*, base::PendingTask*) + 411
b833afb
to
3d2ecbf
Compare
3d2ecbf
to
008196f
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.
LGTM as long as my changes LGTY!
follow up issue created |
@Merith-TK when user types in |
alright, thanks for clarifying, i was just curious if the functionality would be implemented at some point, |
Just a humble user, I think having an option like "Automatically redirect .onion sites", but only when the user is already in a TOR window would be very useful (I thought that was actually what the setting would do). Perhaps a flag to edit the option rather than two options might be preferable. |
agree with this, I agree that there should be an option |
Resolves brave/brave-browser#806
This PR makes it easier for user to interact with onion sites by
Open in Tor
/Onion Available
label when website sendsonion-location
header with its onion site url1.2. Opening tab in Tor window when user clicking on label
1.3. Add a preference for automatically opening up onion site in Tor window
.onion
domain in url bar from non-Tor windowOpen in Tor
in non-Tor windowOnion Available
in Tor windowPreference for automatically opening onion site
Clicking
Open in Tor
in non-Tor windowClicking
Onion Available
in Tor windowSubmitter Checklist:
npm run lint
,npm run gn_check
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).QA/Yes
orQA/No
) to the associated issuerelease-notes/include
orrelease-notes/exclude
) to the associated issueTest Plan:
onion-location
headerNon Tor window
https://brave.com
in regular windowOpen in Tor
on the right of url bar when page loadedhttps://brave5t5rjjg3s6k.onion
will be opened in Tor windowTor window
https://brave.com
in Tor windowOnion Available
on the right of url bar when page loadedhttps://brave5t5rjjg3s6k.onion
will be opened in new tab in the same windowTor is disabled
brave://settings/extensions
and turn off "Private window with Tor"https://brave.com
in regular windowOpen in Tor
on the right of url bar when page loadedAutomatically redirect .onion site
brave://settings/extensions
Tor window
andNon Tor window
scenarios.onion
domainNon Tor window
https://brave5t5rjjg3s6k.onion
in regular windowTor window
https://brave5t5rjjg3s6k.onion
in Tor windowTor is disabled
brave://settings/extensions
and turn off "Private window with Tor"https://brave5t5rjjg3s6k.onion
in regular windowReviewer Checklist:
After-merge Checklist:
changes has landed on.