Skip to content

Commit

Permalink
Merge pull request #7510 from brave/ipfs-infobar-trigger
Browse files Browse the repository at this point in the history
Be more restrictive for triggering IPFS infobar
  • Loading branch information
bbondy authored Jan 1, 2021
2 parents 8662a6b + e4ff9f8 commit 1db1b76
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion browser/ipfs/ipfs_tab_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions browser/ipfs/ipfs_tab_helper_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {}
Expand Down

0 comments on commit 1db1b76

Please sign in to comment.