Skip to content

Commit

Permalink
Uplift of #9355 (squashed) to beta
Browse files Browse the repository at this point in the history
  • Loading branch information
brave-browser-releases committed Jul 12, 2021
1 parent 65807fd commit 281f580
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion browser/net/ipfs_redirect_network_delegate_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <string>

#include "brave/browser/profiles/profile_util.h"
#include "brave/components/ipfs/ipfs_utils.h"
#include "chrome/common/channel_info.h"
#include "components/prefs/pref_service.h"
Expand All @@ -19,7 +20,7 @@ namespace ipfs {
int OnBeforeURLRequest_IPFSRedirectWork(
const brave::ResponseCallback& next_callback,
std::shared_ptr<brave::BraveRequestInfo> ctx) {
if (!ctx->browser_context)
if (!ctx->browser_context || !brave::IsRegularProfile(ctx->browser_context))
return net::OK;
auto* prefs = user_prefs::UserPrefs::Get(ctx->browser_context);
if (IsIpfsResolveMethodDisabled(prefs)) {
Expand Down
13 changes: 13 additions & 0 deletions browser/net/ipfs_redirect_network_delegate_helper_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,4 +204,17 @@ TEST_F(IPFSRedirectNetworkDelegateHelperTest, HeadersIPFSWorkNoRedirect) {
EXPECT_TRUE(allowed_unsafe_redirect_url.is_empty());
}

TEST_F(IPFSRedirectNetworkDelegateHelperTest, PrivateProfile) {
GURL url("ipfs://QmfM2r8seH2GiRaC4esTjeraXEachRt8ZsSeGaWTPLyMoG");
auto brave_request_info = std::make_shared<brave::BraveRequestInfo>(url);
brave_request_info->browser_context = profile()->GetPrimaryOTRProfile(true);
brave_request_info->ipfs_gateway_url = GetPublicGateway();
brave_request_info->initiator_url = ipfs::GetIPFSGatewayURL(
initiator_cid, "", ipfs::GetDefaultIPFSGateway(profile()->GetPrefs()));
int rc = ipfs::OnBeforeURLRequest_IPFSRedirectWork(brave::ResponseCallback(),
brave_request_info);
EXPECT_EQ(rc, net::OK);
EXPECT_TRUE(brave_request_info->new_url_spec.empty());
}

} // namespace ipfs

0 comments on commit 281f580

Please sign in to comment.