Skip to content

Commit

Permalink
Partial CAR requests.
Browse files Browse the repository at this point in the history
Entity scope fits nicely.
Fixes #91
  • Loading branch information
John-LittleBearLabs committed Dec 20, 2023
1 parent 39cc8cb commit 8384ee8
Show file tree
Hide file tree
Showing 127 changed files with 2,201 additions and 1,875 deletions.
44 changes: 4 additions & 40 deletions .github/workflows/library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,14 @@ on:
pull_request:
release:
types: [created]
permissions:
contents: write
jobs:
test:
name: Run Tests & Publish Coverage Report
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --yes cmake ninja-build lcov binutils doxygen graphviz libc6{,-dev} valgrind
npm install -g @marp-team/marp-cli
- name: Configure
shell: bash
run: |
mkdir build
cmake \
-G Ninja \
-S . \
-B build \
-D CMAKE_BUILD_TYPE=Debug
- name: Run Tests
shell: bash
run: cmake --build build --config Debug --target run_tests
- name: Generate Coverage Report
shell: bash
run: cmake --build build --config Debug --target cov
- name: Upload coverage reports to Codecov.com
uses: codecov/codecov-action@v3
with:
files: build/library/cov.info
- name: Run Doxygen
run: |
cmake --build build --config Debug --target doc
ls -lrth build/doc/html
- name: UpDoc
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/doc/html
uses: little-bear-labs/ipfs-chromium/.github/workflows/ut.yml@car
tour:
uses: little-bear-labs/ipfs-chromium/.github/workflows/tour.yml@car
build:
name: ${{ matrix.config.name }}
needs: test
needs: [test, tour]
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: true
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/tour.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Tour de IPFS
on: push
on:
push:
workflow_call:
jobs:
tour:
name: Build clitester and exercize various ipfs_client features
Expand Down Expand Up @@ -73,6 +75,10 @@ jobs:
fi
}
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
killall python3
url_case ipns en.wikipedia-on-ipfs.org/I/HFE_Too_Slow_1.JPG.webp 8238a73ddb12e56f8f3879cc91d2739e
url_case ipfs bafybeieb33pqideyl5ncd33kho622thym5rqv6sujrmelcuhkjlf2hdpu4/Big%20Buck%20Bunny.webm 06d51286e56badb4455594ebed6daba2
killall python3 2>/dev/null || true
37 changes: 37 additions & 0 deletions .github/workflows/ut.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Unit Testing
on:
push:
workflow_call:
permissions:
contents: write
jobs:
test:
name: Run Tests & Publish Coverage Report
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --yes cmake ninja-build lcov binutils doxygen graphviz libc6{,-dev} valgrind
npm install -g @marp-team/marp-cli
- name: Configure
shell: bash
run: |
mkdir build
cmake \
-G Ninja \
-S . \
-B build \
-D CMAKE_BUILD_TYPE=Debug
- name: Run Tests
shell: bash
run: cmake --build build --config Debug --target run_tests
- name: Generate Coverage Report
shell: bash
run: cmake --build build --config Debug --target cov
- name: Upload coverage reports to Codecov.com
uses: codecov/codecov-action@v3
with:
files: build/library/cov.info
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(CHROMIUM_SOURCE_TREE "${CMAKE_CURRENT_BINARY_DIR}/chromium/src" CACHE PATH
"Path to chromium/src. If DOWNLOAD_CHROMIUM=TRUE, and it does not exist, it will be created."
)
set(CHROMIUM_PROFILE "${CMAKE_BUILD_TYPE}" CACHE STRING "The profile of the current Chromium build.")
set(CXX_VERSION "17" CACHE STRING "The numeric part (year % 100) of the version of the C++ standard to be used. Must be at least 17 (for C++17). Must be one CMake knows about.")
set(CXX_VERSION "20" CACHE STRING "The numeric part (year % 100) of the version of the C++ standard to be used. Must be at least 20 (for C++20). Must be one CMake knows about.")
if(DOWNLOAD_CHROMIUM)
set(default_dt "${CMAKE_CURRENT_BINARY_DIR}/depot_tools")
else()
Expand All @@ -28,7 +28,7 @@ set(TEST_BY_DEFAULT FALSE CACHE BOOL "Update unit tests as part of the 'all' def
set(USE_DOXYGEN TRUE CACHE BOOL "If we should attempt to use Doxygen to generate documentation.")
#End of user-configuration cache variables.

if(CXX_VERSION GREATER_EQUAL 17)
if(CXX_VERSION GREATER_EQUAL 20)
message(STATUS "Building for C++${CXX_VERSION}")
else()
message(FATAL_ERROR "Unsupported CXX_VERSION: ${CXX_VERSION}")
Expand Down
23 changes: 23 additions & 0 deletions chromium_edits/122.0.6182.0/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 0fb94c9b9b67e..df25995c80baa 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")
@@ -2596,6 +2597,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/122.0.6182.0/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 52ecc40da0226..42d45b977471e 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"
@@ -313,6 +314,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
@@ -9851,6 +9856,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,63 @@
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index a9b87ac2fcd74..987686c621664 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -377,6 +377,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"
@@ -499,6 +500,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/app_service/app_install/app_install_navigation_throttle.h"
@@ -6157,12 +6164,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) {
@@ -6304,6 +6322,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 5e02e86a700cb..1f06bded184bf 100644
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -2956,6 +2956,11 @@
"owners": [ "hanxi@chromium.org", "wychen@chromium.org" ],
"expiry_milestone": 130
},
+ {
+ "name": "enable-ipfs",
+ "owners": [ "//components/ipfs/OWNERS" ],
+ "expiry_milestone": 150
+ },
{
"name": "enable-isolated-sandboxed-iframes",
"owners": [ "wjmaclean@chromium.org", "alexmos@chromium.org", "creis@chromium.org" ],
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 d6073d3514930..f80f1330f9865 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -288,6 +288,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 4df49302f94b5..f7d3b65112d8b 100644
--- a/chrome/browser/flag_descriptions.h
+++ b/chrome/browser/flag_descriptions.h
@@ -23,6 +23,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
@@ -179,6 +180,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) {
Loading

0 comments on commit 8384ee8

Please sign in to comment.