-
Notifications
You must be signed in to change notification settings - Fork 893
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
Check if IPFS resolution is enabled before redirect URL requests. #7307
Conversation
8ebd28a
to
b782b10
Compare
0652e73
to
18e39dd
Compare
@@ -131,11 +131,12 @@ TEST_F(IpfsNavigationThrottleUnitTest, DeferUntilIpfsProcessLaunched) { | |||
"/ip4/101.101.101.101/tcp/4001/p2p/" | |||
"QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ"}; | |||
|
|||
ipfs_service(profile())->SetSkipGetConnectedPeersCallbackForTest(true); | |||
auto* service = ipfs_service(profile()); | |||
ASSERT_TRUE(service != 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.
ASSERT_TRUE(service)
browser/net/url_context.h
Outdated
@@ -78,6 +78,7 @@ struct BraveRequestInfo { | |||
bool allow_http_upgradable_resource = false; | |||
bool allow_referrers = false; | |||
bool is_webtorrent_disabled = false; | |||
bool resolve_ipfs_enabled = false; |
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.
just a random thought - it seems that after all we should just save browser_context 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.
That was actually my first thought, I prefer that way so ipfs details could be wrapped inside ipfs's helper and not in the general url_context. I'm changing it to save browser_context directly here.
@@ -71,7 +35,7 @@ IpfsServiceFactory* IpfsServiceFactory::GetInstance() { | |||
// static | |||
IpfsService* IpfsServiceFactory::GetForContext( | |||
content::BrowserContext* context) { | |||
if (!IsIpfsEnabled(context)) | |||
if (!brave::IsRegularProfile(context) || !IsIpfsEnabled(context)) |
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.
curious, why this is needed. In theory, if you don't override GetBrowserContextToUse
, default GetBrowserContextToUse
will return nullptr
for anything off-the-record and the service will not be instantiated. So removing this check and also removing GetBrowserContextToUse
should do the trick
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.
GetBrowserContextToUse
override is not needed actually, removed.
brave::IsRegularProfile(context)
checks IsGuestSession()
also and is currently used by several of our service factories, we don't want to create instance for the regular guest profile (which is created when switching to guest happens, tho only the incognito profile of it will be used for browsing).
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 wondering whether brave::IsRegularProfile
is needed at all, beacuse both Tor and Guest profiles are off-the-record. IMO we should erase it from the codebase in favor of BrowserContext::IsOffTheRecord
, 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.
This way, it seems like there is no sense in using here
browser/ipfs/ipfs_service_factory.cc
Outdated
@@ -12,6 +12,7 @@ | |||
#include "brave/components/ipfs/features.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.
pls check for unused headers
browser/net/url_context.cc
Outdated
@@ -138,6 +139,8 @@ std::shared_ptr<brave::BraveRequestInfo> BraveRequestInfo::MakeCTX( | |||
ctx->upload_data = GetUploadData(request); | |||
|
|||
#if BUILDFLAG(IPFS_ENABLED) | |||
ctx->resolve_ipfs_enabled = |
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.
mb it should be resolve_ipfs_DISabled
, to avoid negation here and in the helper
9101151
to
c49aa38
Compare
This commit makes per_profile as True for IPFS policy, so we could move IPFS checks to component utils to be used in the IPFS network delegate helper.
- Save browser context in BraveRequestInfo. - Remove GetBrowserContextToUse override in IpfsServiceFactory. - Remove unused headers.
c49aa38
to
d9d3733
Compare
iOS test failure is irrelevant, windows fail at known test-install failure, merging. |
This commit makes per_profile as True for IPFS policy, so we could move IPFS checks to component utils to be used in the IPFS network delegate helper.
Resolves brave/brave-browser#12978
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed).Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on.
Test Plan: