From e4ff9f8a5182c9c4032e4a42df6d09ebb2e6037a Mon Sep 17 00:00:00 2001 From: "Brian R. Bondy" Date: Wed, 30 Dec 2020 20:33:05 -0500 Subject: [PATCH] Be more restrictive for triggering IPFS infobar --- browser/ipfs/ipfs_tab_helper.cc | 4 +++- browser/ipfs/ipfs_tab_helper_browsertest.cc | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/browser/ipfs/ipfs_tab_helper.cc b/browser/ipfs/ipfs_tab_helper.cc index 9985590b9817..0535168530d7 100644 --- a/browser/ipfs/ipfs_tab_helper.cc +++ b/browser/ipfs/ipfs_tab_helper.cc @@ -50,7 +50,9 @@ void IPFSTabHelper::DidFinishNavigation(content::NavigationHandle* handle) { pref_service_->GetInteger(kIPFSResolveMethod)); if (resolve_method == ipfs::IPFSResolveMethodTypes::IPFS_ASK && handle->GetResponseHeaders() && - handle->GetResponseHeaders()->HasHeader("x-ipfs-path")) { + handle->GetResponseHeaders()->HasHeader("x-ipfs-path") && + IsDefaultGatewayURL(handle->GetURL(), + web_contents()->GetBrowserContext())) { InfoBarService* infobar_service = InfoBarService::FromWebContents(web_contents()); if (infobar_service) { diff --git a/browser/ipfs/ipfs_tab_helper_browsertest.cc b/browser/ipfs/ipfs_tab_helper_browsertest.cc index e8b0e107bfff..0cf447378bb8 100644 --- a/browser/ipfs/ipfs_tab_helper_browsertest.cc +++ b/browser/ipfs/ipfs_tab_helper_browsertest.cc @@ -9,6 +9,7 @@ #include "brave/common/brave_paths.h" #include "brave/components/ipfs/features.h" #include "brave/components/ipfs/ipfs_constants.h" +#include "brave/components/ipfs/ipfs_gateway.h" #include "brave/components/ipfs/pref_names.h" #include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/profiles/profile.h" @@ -70,6 +71,8 @@ class IPFSTabHelperTest : public InProcessBrowserTest, embedded_test_server()->RegisterRequestHandler( base::BindRepeating(&HandleRequest)); ASSERT_TRUE(embedded_test_server()->Start()); + ipfs::SetIPFSDefaultGatewayForTest( + embedded_test_server()->GetURL("cloudflare-ipfs.com", "/")); } ~IPFSTabHelperTest() override {}