Skip to content

Commit

Permalink
Library use case:
Browse files Browse the repository at this point in the history
Decompose the API
needed for context
  • Loading branch information
John-LittleBearLabs committed Feb 28, 2024
1 parent 74ddc62 commit 21642e2
Show file tree
Hide file tree
Showing 252 changed files with 5,341 additions and 3,000 deletions.
2 changes: 1 addition & 1 deletion .github/tour.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -ex
echo Clone tester repo.
git clone --single-branch --branch newmain https://github.com/John-LittleBearLabs/ipfs_client_clitester.git
git clone --single-branch --branch decomposed_context https://github.com/John-LittleBearLabs/ipfs_client_clitester.git

echo Install dependencies.
sudo apt-get update
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@ jobs:
- name: Tour de IPFS
run: ./ipfs_chromium/.github/tour.sh
- name: Upload coverage reports to Codecov.com
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: build/library/cov.info
- name: Run Doxygen
run: |
cmake --build build --config Debug --target doc
ls -lrth build/doc/html
mv -v ipfs_chromium/.git .
- name: UpDoc
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: build/doc/html
repository-name: little-bear-labs/ipfs-chromium
build:
name: ${{ matrix.config.name }}
needs: [prechecks]
Expand Down Expand Up @@ -60,7 +70,7 @@ jobs:
generators: "Visual Studio 17 2022"
}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Print env
run: |
echo github.event.action: ${{ github.event.action }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ut.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: 'ipfs_chromium'
- name: Run versioned script
shell: bash
run: ./ipfs_chromium/.github/ut.sh
- name: Upload coverage reports to Codecov.com
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
files: build/library/cov.info
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ Also, slides for a BlinkOn [lightning talk](doc/slides/blinkon23.md).
[demo.webm](https://github.com/little-bear-labs/ipfs-chromium/assets/97759690/ae072a58-f5de-4270-8d48-2c858d9b17b1)

## Documentation
See the [Doxygen](https://little-bear-labs.github.io/ipfs-chromium/annotated.html) docs.

### Near-term tasks

See [doc/todo.md](doc/todo.md)
For info on how to use the library outside of Chromium, see [its readme](library/README.md).
See also the [Doxygen](https://little-bear-labs.github.io/ipfs-chromium/annotated.html) docs.

## Design

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ index 23ee785c34a30..8550b43c61f2f 100644
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(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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ index a9f0eb5ab9151..8956d3ca5519e 100644
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(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();
Expand Down
27 changes: 27 additions & 0 deletions chromium_edits/123.0.6272.0/chrome/browser/BUILD.gn.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/chrome/browser/BUILD.gn b/chrome/browser/BUILD.gn
index b68caa1566367..70c0b5afea31e 100644
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -39,6 +39,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")
@@ -2630,6 +2631,14 @@ static_library("browser") {
]
}

+ if (enable_ipfs) {
+ sources += [
+ "ipfs_extra_parts.cc",
+ "ipfs_extra_parts.h",
+ ]
+ deps += [ "//components/ipfs" ]
+ }
+
if (is_chromeos_ash) {
deps += [ "//chrome/browser/screen_ai:screen_ai_dlc_installer" ]
}
38 changes: 38 additions & 0 deletions chromium_edits/123.0.6272.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 1eccaad1240c9..fe87a844c2757 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -215,6 +215,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/ozone_buildflags.h"
@@ -311,6 +312,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
@@ -9554,6 +9559,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,78 @@
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 6267bcf055ddf..4479a47c74d8f 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -373,6 +373,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"
@@ -494,6 +495,13 @@
#include "chrome/browser/fuchsia/chrome_browser_main_parts_fuchsia.h"
#endif

+#if BUILDFLAG(ENABLE_IPFS)
+#include "chrome/browser/ipfs_extra_parts.h"
+#include "components/ipfs/interceptor.h"
+#include "components/ipfs/ipfs_features.h"
+#include "components/ipfs/url_loader_factory.h"
+#endif
+
#if !BUILDFLAG(IS_ANDROID)
#include "chrome/browser/preloading/preview/preview_navigation_throttle.h"
#endif // !BUILDFLAG(IS_ANDROID)
@@ -1663,6 +1671,11 @@ ChromeContentBrowserClient::CreateBrowserMainParts(bool is_integration_test) {
main_parts->AddParts(
std::make_unique<ChromeBrowserMainExtraPartsNaclDeprecation>());

+#if BUILDFLAG(ENABLE_IPFS)
+ if (base::FeatureList::IsEnabled(ipfs::kEnableIpfs)) {
+ main_parts->AddParts(std::make_unique<IpfsExtraParts>());
+ }
+#endif
return main_parts;
}

@@ -6007,12 +6020,25 @@ void ChromeContentBrowserClient::
const std::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();
+ auto* context = web_contents->GetBrowserContext();
+ ipfs::IpfsURLLoaderFactory::Create(
+ factories,
+ context,
+ default_factory,
+ GetSystemNetworkContext(),
+ Profile::FromBrowserContext(context)->GetPrefs()
+ );
+ }
+#endif // BUILDFLAG(ENABLE_IPFS)

#if BUILDFLAG(IS_CHROMEOS_ASH)
if (web_contents) {
@@ -6149,6 +6175,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 a0d0fb5b4e1d7..7afd2694ede8d 100644
--- a/chrome/browser/flag-metadata.json
+++ b/chrome/browser/flag-metadata.json
@@ -2984,6 +2984,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 45d78f4ea13de..bf2cce609fac4 100644
--- a/chrome/browser/flag_descriptions.cc
+++ b/chrome/browser/flag_descriptions.cc
@@ -287,6 +287,11 @@ const char kEnableBenchmarkingChoiceDefaultFeatureStates[] =
const char kEnableBenchmarkingChoiceMatchFieldTrialTestingConfig[] =
"Match Field Trial Testing Config";

+#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 31332fb557463..41e976604e6d2 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
@@ -176,6 +177,11 @@ extern const char kEnableBenchmarkingChoiceDisabled[];
extern const char kEnableBenchmarkingChoiceDefaultFeatureStates[];
extern const char kEnableBenchmarkingChoiceMatchFieldTrialTestingConfig[];

+#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[];
10 changes: 10 additions & 0 deletions chromium_edits/123.0.6272.0/chrome/browser/ipfs_extra_parts.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include "ipfs_extra_parts.h"

#include "profiles/profile.h"

#include <components/ipfs/inter_request_state.h>

void IpfsExtraParts::PostProfileInit(Profile* profile, bool /* is_initial_profile */ ) {
DCHECK(profile);
ipfs::InterRequestState::CreateForBrowserContext(profile, profile->GetPrefs());
}
10 changes: 10 additions & 0 deletions chromium_edits/123.0.6272.0/chrome/browser/ipfs_extra_parts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef IPFS_EXTRA_PART_H_
#define IPFS_EXTRA_PART_H_

#include <chrome/browser/chrome_browser_main_extra_parts.h>

class IpfsExtraParts : public ChromeBrowserMainExtraParts {
void PostProfileInit(Profile* profile, bool is_initial_profile) override;
};

#endif // IPFS_EXTRA_PART_H_
Loading

0 comments on commit 21642e2

Please sign in to comment.