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 Aug 19, 2024
1 parent 7171489 commit e6396c3
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 0 deletions.
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 e6396c3

Please sign in to comment.