Be more restrictive for triggering IPFS infobar

This commit is contained in:
Brian R. Bondy
2020-12-30 20:35:55 -05:00
parent c5a05f7aab
commit e4ff9f8a51
2 changed files with 6 additions and 1 deletions
+3 -1
View File
@@ -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) {
@@ -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 {}