Skip to content

Commit

Permalink
Simpler for use case.
Browse files Browse the repository at this point in the history
ifps::Cid
does what is needed.
  • Loading branch information
John-LittleBearLabs committed Jan 12, 2024
1 parent 4aa8c4a commit 5aec6e9
Show file tree
Hide file tree
Showing 346 changed files with 4,497 additions and 1,152 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/tour.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
done
function url_case() {
echo "url_case(" "${@}" ")"
timeout 300 ./tester_build/clitester note "${1}://${2}"
timeout 360 ./tester_build/clitester note "${1}://${2}"
n=`sed 's,[^A-Za-z0-9\.],_,g' <<< ${2}`
if cat "_${1}_${n}" | md5sum | cut -d ' ' -f 1 > actual
then
Expand All @@ -75,9 +75,4 @@ jobs:
url_case ipfs bafkqacdjmrsw45djor4q ff483d1ff591898a9942916050d2ca3f
true the block itself md5s to b92348005af4ae4795e6f312844fb359, but the response is an HTML preview page
url_case ipfs baguqeerah2nswg7r2pvlpbnsz5y4c4pr4wsgbzixdl632w5qxvedqzryf54q 7750fd7b0928f007e1d181763c0dbdb5
url_case ipns blog.ipfs.tech/2023-05-multigateway-chromium-client/
url_case ipns k51qzi5uqu5dijv526o4z2z10ejylnel0bfvrtw53itcmsecffo8yf0zb4g9gi/ipfs-blog/2023-05-multigateway-chromium-client/
echo diff _ipns_*multigateway*
diff _ipns_*multigateway*
killall python3
23 changes: 23 additions & 0 deletions chromium_edits/120.0.6099.71/chrome/browser/BUILD.gn.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index 44d3b5e543101..ece46a3db0bea 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -40,6 +40,7 @@ import("//rlz/buildflags/buildflags.gni")
import("//sandbox/features.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//third_party/blink/public/public_features.gni")
+import("//third_party/ipfs_client/args.gni")
import("//third_party/protobuf/proto_library.gni")
import("//third_party/webrtc/webrtc.gni")
import("//third_party/widevine/cdm/widevine.gni")
@@ -2660,6 +2661,10 @@ static_library("browser") {
]
}

+ if (enable_ipfs) {
+ deps += [ "//components/ipfs" ]
+ }
+
if (is_chromeos_ash) {
deps += [ "//chrome/browser/screen_ai:screen_ai_dlc_installer" ]
}
38 changes: 38 additions & 0 deletions chromium_edits/120.0.6099.71/chrome/browser/about_flags.cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index 8736a91998f6b..da556109dcbb1 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -213,6 +213,7 @@
#include "third_party/blink/public/common/features_generated.h"
#include "third_party/blink/public/common/forcedark/forcedark_switches.h"
#include "third_party/blink/public/common/switches.h"
+#include "third_party/ipfs_client/ipfs_buildflags.h"
#include "ui/accessibility/accessibility_features.h"
#include "ui/accessibility/accessibility_switches.h"
#include "ui/base/ui_base_features.h"
@@ -314,6 +315,10 @@
#include "extensions/common/switches.h"
#endif // BUILDFLAG(ENABLE_EXTENSIONS)

+#if BUILDFLAG(ENABLE_IPFS)
+#include "components/ipfs/ipfs_features.h"
+#endif
+
#if BUILDFLAG(ENABLE_PDF)
#include "pdf/pdf_features.h"
#endif
@@ -9922,6 +9927,14 @@ const FeatureEntry kFeatureEntries[] = {
flag_descriptions::kOmitCorsClientCertDescription, kOsAll,
FEATURE_VALUE_TYPE(network::features::kOmitCorsClientCert)},

+#if BUILDFLAG(ENABLE_IPFS)
+ {"enable-ipfs",
+ flag_descriptions::kEnableIpfsName,
+ flag_descriptions::kEnableIpfsDescription,
+ kOsMac | kOsWin | kOsLinux,//TODO: These are the only variants currently getting built, but that is not likely to remain the case
+ FEATURE_VALUE_TYPE(ipfs::kEnableIpfs)},
+#endif
+
{"use-idna2008-non-transitional",
flag_descriptions::kUseIDNA2008NonTransitionalName,
flag_descriptions::kUseIDNA2008NonTransitionalDescription, kOsAll,
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
diff --git a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc
index 4c88614c68c25..f8bb12a3b0c2e 100644
--- a/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc
+++ b/chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.cc
@@ -10,6 +10,8 @@
#include "chrome/browser/custom_handlers/protocol_handler_registry_factory.h"
#include "chrome/browser/external_protocol/external_protocol_handler.h"
#include "chrome/browser/profiles/profile.h"
+#include "third_party/ipfs_client/ipfs_buildflags.h"
+
#if BUILDFLAG(IS_ANDROID)
#include "chrome/browser/profiles/profile_android.h"
#endif
@@ -18,6 +20,9 @@
#include "chrome/browser/ui/android/omnibox/jni_headers/ChromeAutocompleteSchemeClassifier_jni.h"
#endif
#include "components/custom_handlers/protocol_handler_registry.h"
+#if BUILDFLAG(ENABLE_IPFS)
+#include "components/ipfs/ipfs_features.h"
+#endif
#include "content/public/common/url_constants.h"
#include "url/url_util.h"

@@ -55,12 +60,20 @@ ChromeAutocompleteSchemeClassifier::GetInputTypeForScheme(
if (scheme.empty()) {
return metrics::OmniboxInputType::EMPTY;
}
- if (base::IsStringASCII(scheme) &&
- (ProfileIOData::IsHandledProtocol(scheme) ||
- base::EqualsCaseInsensitiveASCII(scheme, content::kViewSourceScheme) ||
- base::EqualsCaseInsensitiveASCII(scheme, url::kJavaScriptScheme) ||
- base::EqualsCaseInsensitiveASCII(scheme, url::kDataScheme))) {
- return metrics::OmniboxInputType::URL;
+ if (base::IsStringASCII(scheme)) {
+ if (ProfileIOData::IsHandledProtocol(scheme) ||
+ base::EqualsCaseInsensitiveASCII(scheme, content::kViewSourceScheme) ||
+ base::EqualsCaseInsensitiveASCII(scheme, url::kJavaScriptScheme) ||
+ base::EqualsCaseInsensitiveASCII(scheme, url::kDataScheme)) {
+ return metrics::OmniboxInputType::URL;
+ }
+#if BUILDFLAG(ENABLE_IPFS)
+ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs) &&
+ (base::EqualsCaseInsensitiveASCII(scheme, "ipfs") || base::EqualsCaseInsensitiveASCII(scheme, "ipns"))
+ ) {
+ return metrics::OmniboxInputType::URL;
+ }
+#endif
}

// Also check for schemes registered via registerProtocolHandler(), which
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index d9c675c8aca73..cb360f4e7ca5b 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -228,6 +228,8 @@
#include "components/error_page/common/localized_error.h"
#include "components/error_page/content/browser/net_error_auto_reloader.h"
#include "components/google/core/common/google_switches.h"
+#include "components/ipfs/interceptor.h"
+#include "components/ipfs/url_loader_factory.h"
#include "components/keep_alive_registry/keep_alive_types.h"
#include "components/keep_alive_registry/scoped_keep_alive.h"
#include "components/language/core/browser/pref_names.h"
@@ -364,6 +366,7 @@
#include "third_party/blink/public/common/switches.h"
#include "third_party/blink/public/mojom/browsing_topics/browsing_topics.mojom.h"
#include "third_party/blink/public/public_buildflags.h"
+#include "third_party/ipfs_client/ipfs_buildflags.h"
#include "third_party/widevine/cdm/buildflags.h"
#include "ui/base/clipboard/clipboard_format_type.h"
#include "ui/base/l10n/l10n_util.h"
@@ -487,6 +490,12 @@
#include "chrome/browser/fuchsia/chrome_browser_main_parts_fuchsia.h"
#endif

+#if BUILDFLAG(ENABLE_IPFS)
+#include "components/ipfs/interceptor.h"
+#include "components/ipfs/ipfs_features.h"
+#include "components/ipfs/url_loader_factory.h"
+#endif
+
#if BUILDFLAG(IS_CHROMEOS)
#include "base/debug/leak_annotations.h"
#include "chrome/browser/apps/intent_helper/chromeos_disabled_apps_throttle.h"
@@ -6180,12 +6189,23 @@ void ChromeContentBrowserClient::
const absl::optional<url::Origin>& request_initiator_origin,
NonNetworkURLLoaderFactoryMap* factories) {
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \
- !BUILDFLAG(IS_ANDROID)
+ !BUILDFLAG(IS_ANDROID) || BUILDFLAG(ENABLE_IPFS)
content::RenderFrameHost* frame_host =
RenderFrameHost::FromID(render_process_id, render_frame_id);
WebContents* web_contents = WebContents::FromRenderFrameHost(frame_host);
#endif // BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(ENABLE_EXTENSIONS) || \
- // !BUILDFLAG(IS_ANDROID)
+ // !BUILDFLAG(IS_ANDROID) || BUILDFLAG(ENABLE_IPFS)
+#if BUILDFLAG(ENABLE_IPFS)
+ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) {
+ network::mojom::URLLoaderFactory* default_factory = g_browser_process->system_network_context_manager()->GetURLLoaderFactory();
+ ipfs::IpfsURLLoaderFactory::Create(
+ factories,
+ web_contents->GetBrowserContext(),
+ default_factory,
+ GetSystemNetworkContext()
+ );
+ }
+#endif // BUILDFLAG(ENABLE_IPFS)

#if BUILDFLAG(IS_CHROMEOS_ASH)
if (web_contents) {
@@ -6327,6 +6347,11 @@ ChromeContentBrowserClient::WillCreateURLLoaderRequestInterceptors(
scoped_refptr<base::SequencedTaskRunner> navigation_response_task_runner) {
std::vector<std::unique_ptr<content::URLLoaderRequestInterceptor>>
interceptors;
+#if BUILDFLAG(ENABLE_IPFS)
+ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) {
+ interceptors.push_back(std::make_unique<ipfs::Interceptor>(g_browser_process->system_network_context_manager()->GetURLLoaderFactory(), GetSystemNetworkContext()));
+ }
+#endif
#if BUILDFLAG(ENABLE_OFFLINE_PAGES)
interceptors.push_back(
std::make_unique<offline_pages::OfflinePageURLLoaderRequestInterceptor>(
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/chrome/browser/flag-metadata.json b/chrome/browser/flag-metadata.json
index 400505f9d64e6..320b730d894c6 100644
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -2868,6 +2868,11 @@
"owners": [ "[email protected]", "[email protected]" ],
"expiry_milestone": 130
},
+ {
+ "name": "enable-ipfs",
+ "owners": [ "//components/ipfs/OWNERS" ],
+ "expiry_milestone": 150
+ },
{
"name": "enable-isolated-sandboxed-iframes",
"owners": [ "[email protected]", "[email protected]", "[email protected]" ],
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
diff --git a/chrome/browser/flag_descriptions.cc b/chrome/browser/flag_descriptions.cc
index f92c5df0fc600..e131baa70cce2 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -248,6 +248,11 @@ const char kEnableBenchmarkingDescription[] =
"after 3 restarts. On the third restart, the flag will appear to be off "
"but the effect is still active.";

+#if BUILDFLAG(ENABLE_IPFS)
+extern const char kEnableIpfsName[] = "Enable IPFS";
+extern const char kEnableIpfsDescription[] = "Enable ipfs:// and ipns:// URLs";
+#endif
+
const char kPreloadingOnPerformancePageName[] =
"Preloading Settings on Performance Page";
const char kPreloadingOnPerformancePageDescription[] =
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
diff --git a/chrome/browser/flag_descriptions.h b/chrome/browser/flag_descriptions.h
index 71eae84724eab..a8e4b29ee3cc5 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -22,6 +22,7 @@
#include "pdf/buildflags.h"
#include "printing/buildflags/buildflags.h"
#include "third_party/blink/public/common/buildflags.h"
+#include "third_party/ipfs_client/ipfs_buildflags.h"

// This file declares strings used in chrome://flags. These messages are not
// translated, because instead of end-users they target Chromium developers and
@@ -165,6 +166,11 @@ extern const char kDownloadWarningImprovementsDescription[];
extern const char kEnableBenchmarkingName[];
extern const char kEnableBenchmarkingDescription[];

+#if BUILDFLAG(ENABLE_IPFS)
+extern const char kEnableIpfsName[];
+extern const char kEnableIpfsDescription[];
+#endif
+
#if BUILDFLAG(USE_FONTATIONS_BACKEND)
extern const char kFontationsFontBackendName[];
extern const char kFontationsFontBackendDescription[];
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/chrome/common/chrome_content_client.cc b/chrome/common/chrome_content_client.cc
index 246ec9c5c911f..5d66d133a7907 100644
--- a/chrome/common/chrome_content_client.cc
+++ b/chrome/common/chrome_content_client.cc
@@ -296,6 +296,12 @@ void ChromeContentClient::AddAdditionalSchemes(Schemes* schemes) {
#if BUILDFLAG(IS_ANDROID)
schemes->local_schemes.push_back(url::kContentScheme);
#endif
+ for ( const char* ip_s : {"ipfs", "ipns"} ) {
+ schemes->standard_schemes.push_back(ip_s);
+ schemes->cors_enabled_schemes.push_back(ip_s);
+ schemes->secure_schemes.push_back(ip_s);
+ schemes->csp_bypassing_schemes.push_back(ip_s);
+ }
}

std::u16string ChromeContentClient::GetLocalizedString(int message_id) {
44 changes: 44 additions & 0 deletions chromium_edits/120.0.6099.71/components/cbor/reader.cc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff --git a/components/cbor/reader.cc b/components/cbor/reader.cc
index 306ba52fa4944..6b13b3a679a65 100644
--- a/components/cbor/reader.cc
+++ b/components/cbor/reader.cc
@@ -22,7 +22,7 @@
namespace cbor {

namespace constants {
-const char kUnsupportedMajorType[] = "Unsupported major type.";
+const char kUnsupportedMajorType[] = "Unsupported major type operation.";
}

namespace {
@@ -156,7 +156,11 @@ absl::optional<Value> Reader::DecodeCompleteDataItem(const Config& config,
case Value::Type::FLOAT_VALUE:
// Floating point values also go here since they are also type 7.
return DecodeToSimpleValueOrFloat(*header, config);
- case Value::Type::TAG: // We explicitly don't support TAG.
+ case Value::Type::TAG:
+ if (config.parse_tags) {
+ return ReadTagContent(*header, config, max_nesting_level);
+ }
+ break;
case Value::Type::NONE:
case Value::Type::INVALID_UTF8:
break;
@@ -347,6 +351,17 @@ absl::optional<Value> Reader::ReadByteStringContent(
return Value(std::move(cbor_byte_string));
}

+absl::optional<Value> Reader::ReadTagContent(
+ const Reader::DataItemHeader& header,
+ const Config& config,
+ int max_nesting_level) {
+ auto tagged_content = DecodeCompleteDataItem(config, max_nesting_level);
+ if (tagged_content.has_value()) {
+ tagged_content.value().SetTag(header.value);
+ }
+ return tagged_content;
+}
+
absl::optional<Value> Reader::ReadArrayContent(
const Reader::DataItemHeader& header,
const Config& config,
26 changes: 26 additions & 0 deletions chromium_edits/120.0.6099.71/components/cbor/reader.h.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/components/cbor/reader.h b/components/cbor/reader.h
index f0b43a5517528..a57e277a1bc66 100644
--- a/components/cbor/reader.h
+++ b/components/cbor/reader.h
@@ -130,6 +130,11 @@ class CBOR_EXPORT Reader {
// during decoding will set raise the `UNSUPPORTED_FLOATING_POINT_VALUE`
// error.
bool allow_floating_point = false;
+
+ // If the parser encounters a TAG element, should it be parsed out and
+ // the tag value saved (true), or should the entire node and its content
+ // be discarded (false)
+ bool parse_tags = false;
};

Reader(const Reader&) = delete;
@@ -204,6 +209,9 @@ class CBOR_EXPORT Reader {
absl::optional<Value> ReadMapContent(const DataItemHeader& header,
const Config& config,
int max_nesting_level);
+ absl::optional<Value> ReadTagContent(const DataItemHeader& header,
+ const Config& config,
+ int max_nesting_level);
absl::optional<uint8_t> ReadByte();
absl::optional<base::span<const uint8_t>> ReadBytes(uint64_t num_bytes);
bool IsKeyInOrder(const Value& new_key,
Loading

0 comments on commit 5aec6e9

Please sign in to comment.