Skip to content

Commit

Permalink
Register as handler
Browse files Browse the repository at this point in the history
for these schemes with desktop env.
So users click links.

Fixes #113
  • Loading branch information
John-LittleBearLabs committed Sep 4, 2024
1 parent de66c8d commit 9a0a8b0
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/tour.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ url_case ipfs bafkqacdjmrsw45djor4q ff483d1ff591898a9942916050d2ca3f 'Identity (
url_case ipfs baguqeerah2nswg7r2pvlpbnsz5y4c4pr4wsgbzixdl632w5qxvedqzryf54q 7750fd7b0928f007e1d181763c0dbdb5 'A DAG-JSON document. The block itself md5s to b92348005af4ae4795e6f312844fb359, but the response we are hashing here is an HTML preview page. This does mean this test breaks if you make the preview less ugly.'
url_case ipns en.wikipedia-on-ipfs.org/I/HFE_Too_Slow_1.JPG.webp 09c09b2654e8529740b5a7625e39e0c8 'An image fetched through DNSLink and HAMT sharded directories.' note
echo 'Skip as it takes too long.' url_case ipfs bafybeieb33pqideyl5ncd33kho622thym5rqv6sujrmelcuhkjlf2hdpu4/Big%20Buck%20Bunny.webm 06d51286e56badb4455594ebed6daba2 'A large UnixFS file - several hundred blocks.' error
url_case ipns k51qzi5uqu5dijv526o4z2z10ejylnel0bfvrtw53itcmsecffo8yf0zb4g9gi/symlinks/relative_link.txt cfe9b69523140b5b5e63874a8e4997e4 'A relative symlink resolves successfully to the file pointed to.'
url_case ipfs bafybeihmq5rnk5i4gwljixz64dns3pxt7ep2i3x7eylyfq7mkzgh4gtfh4/relative_link.txt cfe9b69523140b5b5e63874a8e4997e4 'A relative symlink resolves successfully to the file pointed to.'
echo Stop test server.
killall python3 2>/dev/null || true
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/chrome/browser/shell_integration_mac.mm b/chrome/browser/shell_integration_mac.mm
index c6bb768979453..c0d0abb9c78f3 100644
--- a/chrome/browser/shell_integration_mac.mm
+++ b/chrome/browser/shell_integration_mac.mm
@@ -79,6 +79,8 @@ bool SetAsDefaultBrowser() {
if (LSSetDefaultHandlerForURLScheme(CFSTR("https"), identifier) != noErr) {
return false;
}
+ LSSetDefaultHandlerForURLScheme(CFSTR("ipfs"), identifier);
+ LSSetDefaultHandlerForURLScheme(CFSTR("ipns"), identifier);
if (LSSetDefaultRoleHandlerForContentType(kUTTypeHTML, kLSRolesViewer,
identifier) != noErr) {
return false;
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/chrome/installer/linux/common/desktop.template b/chrome/installer/linux/common/desktop.template
index 2eb13ee1aba46..9af65726bde89 100644
--- a/chrome/installer/linux/common/desktop.template
+++ b/chrome/installer/linux/common/desktop.template
@@ -111,7 +111,7 @@ Terminal=false
Icon=@@PACKAGE@@
Type=Application
Categories=Network;WebBrowser;
-MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;
+MimeType=application/pdf;application/rdf+xml;application/rss+xml;application/xhtml+xml;application/xhtml_xml;application/xml;image/gif;image/jpeg;image/png;image/webp;text/html;text/xml;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ipfs;x-scheme-handler/ipns;
Actions=new-window;new-private-window;

[Desktop Action new-window]
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc
index 183bf96be3741..116c5b838c8c5 100644
--- a/chrome/installer/util/shell_util.cc
+++ b/chrome/installer/util/shell_util.cc
@@ -1526,11 +1526,12 @@ const wchar_t* ShellUtil::kDefaultFileAssociations[] = {
const wchar_t* ShellUtil::kPotentialFileAssociations[] = {
L".htm", L".html", L".pdf", L".shtml", L".svg",
L".xht", L".xhtml", L".webp", nullptr};
-const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = {L"http", L"https",
- nullptr};
+const wchar_t* ShellUtil::kBrowserProtocolAssociations[] = {
+ L"http", L"https", L"ipfs", L"ipns", nullptr};
const wchar_t* ShellUtil::kPotentialProtocolAssociations[] = {
L"http", L"https", L"irc", L"mailto", L"mms", L"news", L"nntp",
- L"sms", L"smsto", L"snews", L"tel", L"urn", L"webcal", nullptr};
+ L"sms", L"smsto", L"snews", L"tel", L"urn", L"webcal", L"ipfs",
+ L"ipns", nullptr};
const wchar_t* ShellUtil::kRegUrlProtocol = L"URL Protocol";
const wchar_t* ShellUtil::kRegApplication = L"\\Application";
const wchar_t* ShellUtil::kRegAppUserModelId = L"AppUserModelId";
9 changes: 9 additions & 0 deletions cmake/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,15 @@ def out_of_date(self, p):
):
verbose(p, "Still relying on absl::optional in unit tests", file_path)
return True
file_path = join(dir_path, "chrome/installer/linux/common/desktop.template.patch")
if not isfile(file_path):
verbose('No patching of', file_path)
return True
with open(file_path) as f:
lines = list(map(lambda x: x.strip(), f.readlines()))
if not any(map(lambda x: 'x-scheme-handler/ipfs' in x, lines)):
verbose(p, "No ipfs scheme in Linux installer", file_path)
return True
file_path = f"{self.pdir}/{p}.patch"
if not isfile(file_path):
return False
Expand Down
11 changes: 11 additions & 0 deletions library/src/ipfs_client/gw/gateway_request_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,14 @@ TEST_F(GatewayRequestTest, timeouts_ordinal) {
EXPECT_LT(timeout(RT::Providers), timeout(RT::Block));
EXPECT_LT(timeout(RT::Car), timeout(RT::Ipns));
}
TEST_F(GatewayRequestTest, describe_block_http) {
t_.type = RT::Block;
auto o = t_.describe_http("http://gate.way/");
ASSERT_TRUE(o.has_value());
auto& d = *o;
EXPECT_EQ(d.url, "http://gate.way/ipfs/main");
EXPECT_EQ(d.accept, "application/vnd.ipld.raw");
EXPECT_EQ(d.timeout_seconds, 32);
ASSERT_TRUE(d.max_response_size.has_value());
EXPECT_EQ(d.max_response_size.value(), 2097152);
}

0 comments on commit 9a0a8b0

Please sign in to comment.