patches: set up initial onboarding page scaffolding

This commit is contained in:
jj
2025-04-03 15:22:06 +00:00
parent a48056ea9d
commit d5c3dfc654
4 changed files with 180 additions and 186 deletions

View File

@@ -3,3 +3,18 @@ url = https://gist.githubusercontent.com/dumbmoron/a8aeb8926c4baa8fdd0fa8e8de47e
download_filename = icons.tar.gz
sha256 = cd954c7257f126be871f79ecf8fff143425708d5d33501d0ba870fa466dafbe7
output_path = ./components/resources/default_100_percent/search_engine_choice
[onboarding]
version = e31596cca3088fed99660589867dd111f13abe1f
url = https://github.com/imputnet/helium-onboarding/archive/%(version)s.tar.gz
download_filename = onboarding-page-%(version)s.tar.gz
sha256 = eb44fde5ab8abd989ff82770e10515423f705d15f50c07faa28b03b67999bce8
output_path = ./components/helium_onboarding
strip_leading_dirs = helium-onboarding-%(version)s
[onboarding_node_modules]
version = fb4219d06c196d32847d93ccbbfdb48ded0238d2
url = https://gist.github.com/dumbmoron/26e60eb4c6908abb384ea7147c8bce32/raw/%(version)s/node_modules.tar.gz
download_filename = onboarding-node_modules-%(version)s.tar.gz
sha256 = 2fa3b8cbfc6c2da9522f625adcef39c16ed227793916393b7438138224e38409
output_path = ./components/helium_onboarding/node_modules

View File

@@ -1,185 +0,0 @@
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -1013,6 +1013,7 @@ int ChromeBrowserMainParts::PreCreateThr
if (first_run::IsChromeFirstRun()) {
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kApp) &&
!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppId)) {
+ browser_creator_->AddFirstRunTabs({GURL("chrome://ungoogled-first-run")});
browser_creator_->AddFirstRunTabs(master_prefs_->new_tabs);
}
--- a/chrome/browser/ui/webui/chrome_web_ui_configs.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_configs.cc
@@ -43,6 +43,7 @@
#include "chrome/browser/ui/webui/signin_internals_ui.h"
#include "chrome/browser/ui/webui/sync_internals/sync_internals_ui.h"
#include "chrome/browser/ui/webui/translate_internals/translate_internals_ui.h"
+#include "chrome/browser/ui/webui/ungoogled_first_run.h"
#include "chrome/browser/ui/webui/usb_internals/usb_internals_ui.h"
#include "chrome/browser/ui/webui/user_actions/user_actions_ui.h"
#include "chrome/browser/ui/webui/version/version_ui.h"
@@ -248,6 +249,7 @@ void RegisterChromeWebUIConfigs() {
map.AddWebUIConfig(std::make_unique<SiteEngagementUIConfig>());
map.AddWebUIConfig(std::make_unique<SyncInternalsUIConfig>());
map.AddWebUIConfig(std::make_unique<TranslateInternalsUIConfig>());
+ map.AddWebUIConfig(std::make_unique<UngoogledFirstRunUIConfig>());
map.AddWebUIConfig(std::make_unique<UsbInternalsUIConfig>());
map.AddWebUIConfig(std::make_unique<UserActionsUIConfig>());
map.AddWebUIConfig(std::make_unique<VersionUIConfig>());
--- /dev/null
+++ b/chrome/browser/ui/webui/ungoogled_first_run.h
@@ -0,0 +1,144 @@
+#ifndef CHROME_BROWSER_UI_WEBUI_UNGOOGLED_FIRST_RUN_H_
+#define CHROME_BROWSER_UI_WEBUI_UNGOOGLED_FIRST_RUN_H_
+
+#include "base/memory/ref_counted_memory.h"
+#include "chrome/browser/profiles/profile.h"
+#include "content/public/browser/url_data_source.h"
+#include "content/public/browser/web_ui.h"
+#include "content/public/browser/web_ui_controller.h"
+#include "content/public/browser/webui_config.h"
+#include "services/network/public/mojom/content_security_policy.mojom.h"
+
+class UFRDataSource : public content::URLDataSource {
+ public:
+ UFRDataSource() {}
+ UFRDataSource(const UFRDataSource&) = delete;
+ UFRDataSource& operator=(const UFRDataSource&) = delete;
+ std::string GetSource() { return "ungoogled-first-run"; }
+ std::string GetMimeType(const GURL& url) { return "text/html"; }
+ std::string GetContentSecurityPolicy(network::mojom::CSPDirectiveName directive) {
+ if (directive == network::mojom::CSPDirectiveName::ScriptSrc)
+ return "script-src 'unsafe-inline'";
+ return std::string();
+ }
+ void StartDataRequest(const GURL& url,
+ const content::WebContents::Getter& wc_getter,
+ GotDataCallback callback) {
+ std::string source = R"(
+<title>ungoogled-chromium first run page</title>
+<meta name="color-scheme" content="light dark">
+<style>
+ @import url(chrome://resources/css/text_defaults_md.css);
+ html{color:#202124; background:white; line-height:1.1em}
+ a{color:#1967d2}
+ h2{margin:0; padding:0.67em 1.33em}
+ p,details{border-top:.063em solid #f0f0f0; margin:0; padding:1em 2em}
+ ul,ol{padding-left:2em}
+ code{background:rgba(128 128 128 / .2); padding:0 0.5em; border-radius:0.25em}
+ summary{cursor:pointer}
+ section{width:60em; margin:4em auto; border-radius:.5em;
+ background:white; box-shadow:0 .063em .125em 0 #c4c5c6, 0 .125em .375em .125em #e2e3e3}
+ @media(prefers-color-scheme:dark){
+ html{color:#e8eaed; background:#202124}
+ a{color:#8ab4f8}
+ p,details{border-top:.063em solid #3f4042}
+ section{background:#292a2d; box-shadow:0 .063em .125em 0 #161719, 0 .125em .375em .125em #1b1c1f}
+ }
+</style>
+<base target="_blank">
+<section>
+ <h2>ungoogled-chromium</h2><p>
+ This browser was built with ungoogled-chromium patches and differs from the default Chromium experience
+ in a few ways. Look over the sections below and the
+ <a href="https://github.com/ungoogled-software/ungoogled-chromium/blob/master/docs/default_settings.md">
+ changes to the default settings</a> to see what may be important to you.<p>
+ This page can always be accessed again at <a href="chrome://ungoogled-first-run">chrome://ungoogled-first-run</a>
+</section>
+<section>
+ <h2>How-To</h2>
+ <details><summary><b>Install and update extensions</b></summary><br>
+ <a href="https://github.com/NeverDecaf">NeverDecaf</a> has created an extension to make this process easy:
+ <ol>
+ <li>Set <a href="chrome://flags/#extension-mime-request-handling">chrome://flags/#extension-mime-request-handling</a>
+ to <code>Always prompt for install</code> and relaunch.</li>
+ <li>Then click on the latest <code>Chromium.Web.Store.crx</code> link on
+ <a href="https://github.com/NeverDecaf/chromium-web-store/releases">the extension's Releases page</a>.</li>
+ </ol>
+ Please check out the <a href="https://github.com/NeverDecaf/chromium-web-store">chromium-web-store</a>
+ repo for further details and alternate installation methods for the extension.<br><br>
+ If you do not wish to install this extension, there is still a way to install other extensions albeit
+ without the ability to easily update them. In this case, please refer to the entry on the wiki for
+ <a href="https://ungoogled-software.github.io/ungoogled-chromium-wiki/faq#downloading-the-crx-file">
+ installing extensions manually</a>.</details>
+ <details><summary><b>Enable spellcheck</b></summary>
+ <ol>
+ <li>Go to <a href="https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries/+/main">
+ https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries/+/main</a></li>
+ <li>Find a bdic file for the language you want and click on it.
+ You will see a mostly empty page aside from "X-byte binary file".</li>
+ <li>On the bottom right corner, click "txt". The direct link for en-US-10-1.bdic is:
+ <a href="https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries/+/main/en-US-10-1.bdic?format=TEXT">
+ https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries/+/main/en-US-10-1.bdic?format=TEXT</a></li>
+ <li>This is a base64-encoded file that needs to be decoded. Use the button below to select the .txt file you saved
+ and save/move the resulting bdic file to your Dictionaries directory. Default locations:
+ <ul>
+ <li>Linux: <code>~/.config/chromium/Dictionaries/</code><br></li>
+ <li>Mac: <code>~/Library/Application Support/Chromium/Dictionaries/</code><br></li>
+ <li>Windows: <code>%LOCALAPPDATA%\Chromium\User Data\Dictionaries\</code><br></li>
+ </ul>
+ <input id="bdic" type="file" accept=".txt,text/plain" />
+ </li>
+ <li>Toggle spell check in <a href="chrome://settings/languages">chrome://settings/languages</a>,
+ or restart the browser for the dictionaries to take effect.</li>
+ </ol></details><p>
+ <a href="https://ungoogled-software.github.io/ungoogled-chromium-wiki/faq">Check out the FAQ on the wiki</a>
+ for information on other common topics.
+</section>
+<section>
+ <h2>Extra Features</h2><p>
+ Most features introduced by ungoogled-chromium are disabled by default and can be enabled in
+ <a href="chrome://flags">chrome://flags</a> or as command-line switches. Take a look at
+ <a href="https://github.com/ungoogled-software/ungoogled-chromium/blob/master/docs/flags.md">
+ the flags documentation</a> to see what features you may find useful to enable.
+</section>
+<section>
+ <h2>Additional Links</h2><p>
+ Privacy and security information, motivation and philosophy, rationale for changes, and more can be found in the
+ <a href="https://github.com/ungoogled-software/ungoogled-chromium/blob/master/README.md">README</a>.<p>
+ Visit our <a href="https://github.com/ungoogled-software/ungoogled-chromium/blob/master/SUPPORT.md">
+ support page</a> if you wish to report problems.<p>
+ Are you a developer? Consider
+ <a href="https://github.com/ungoogled-software/ungoogled-chromium/blob/master/docs/contributing.md">
+ contributing</a> to ungoogled-chromium!
+</section>
+<script>
+ document.getElementById("bdic").onchange = function(e){
+ var f = new FileReader;
+ f.onload = function(){
+ var a = document.createElement("a");
+ a.setAttribute("href", "data:application/octet-stream;base64, " + f.result);
+ a.setAttribute("download", e.target.files[0].name.replace(/\.[^/.]+$/, ".bdic"));
+ a.click()
+ }, f.readAsText(this.files[0])};
+</script>
+)";
+ std::move(callback).Run(base::MakeRefCounted<base::RefCountedString>(std::move(source)));
+ }
+};
+
+class UngoogledFirstRun;
+class UngoogledFirstRunUIConfig : public content::DefaultWebUIConfig<UngoogledFirstRun> {
+ public:
+ UngoogledFirstRunUIConfig() : DefaultWebUIConfig("chrome", "ungoogled-first-run") {}
+};
+
+class UngoogledFirstRun : public content::WebUIController {
+ public:
+ UngoogledFirstRun(content::WebUI* web_ui) : content::WebUIController(web_ui) {
+ content::URLDataSource::Add(Profile::FromWebUI(web_ui), std::make_unique<UFRDataSource>());
+ }
+ UngoogledFirstRun(const UngoogledFirstRun&) = delete;
+ UngoogledFirstRun& operator=(const UngoogledFirstRun&) = delete;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_UNGOOGLED_FIRST_RUN_H_
--- a/chrome/common/webui_url_constants.cc
+++ b/chrome/common/webui_url_constants.cc
@@ -71,6 +71,7 @@ bool IsSystemWebUIHost(std::string_view
// These hosts will also be suggested by BuiltinProvider.
base::span<const base::cstring_view> ChromeURLHosts() {
static constexpr auto kChromeURLHosts = std::to_array<base::cstring_view>({
+ "ungoogled-first-run",
kChromeUIAboutHost,
kChromeUIAccessibilityHost,
#if !BUILDFLAG(IS_ANDROID)

View File

@@ -0,0 +1,164 @@
--- a/tools/gritsettings/resource_ids.spec
+++ b/tools/gritsettings/resource_ids.spec
@@ -1103,6 +1103,10 @@
"META": {"sizes": {"includes": [30],}},
"includes": [7480],
},
+ "<(SHARED_INTERMEDIATE_DIR)/components/helium_onboarding/resources.grd": {
+ "META": {"sizes": {"includes": [30],}},
+ "includes": [7510],
+ },
# END components/ section.
# START ios/ section.
--- a/chrome/browser/BUILD.gn
+++ b/chrome/browser/BUILD.gn
@@ -8409,6 +8409,7 @@ static_library("browser_generated_files"
"//chrome/browser/ui/webui/user_education_internals:mojo_bindings",
"//chrome/browser/v8_compile_hints/proto",
"//chrome/browser/web_applications/mojom:mojom_web_apps_enum",
+ "//components/helium_onboarding:generated_resources",
]
if (is_android) {
public_deps += [
--- a/chrome/chrome_paks.gni
+++ b/chrome/chrome_paks.gni
@@ -435,11 +435,13 @@ template("chrome_extra_paks") {
if (!is_android && !is_chromeos_ash) {
sources += [
"$root_gen_dir/chrome/intro_resources.pak",
+ "$root_gen_dir/components/helium_onboarding/resources/helium_onboarding_generated.pak",
"$root_gen_dir/chrome/profile_picker_resources.pak",
]
deps += [
"//chrome/browser/resources/intro:resources",
"//chrome/browser/resources/signin/profile_picker:resources",
+ "//components/helium_onboarding:generated_resources",
]
}
--- a/chrome/common/webui_url_constants.cc
+++ b/chrome/common/webui_url_constants.cc
@@ -116,6 +116,7 @@ base::span<const base::cstring_view> Chr
kChromeUIPrefsInternalsHost,
kChromeUIProfileInternalsHost,
content::kChromeUIQuotaInternalsHost,
+ kHeliumSetupHost,
kChromeUISignInInternalsHost,
kChromeUISiteEngagementHost,
#if !BUILDFLAG(IS_ANDROID)
--- a/chrome/common/webui_url_constants.h
+++ b/chrome/common/webui_url_constants.h
@@ -556,6 +556,8 @@ inline constexpr char kChromeUIProfilePi
inline constexpr char kChromeUIProfilePickerStartupQuery[] = "startup";
inline constexpr char kChromeUIProfilePickerGlicQuery[] = "glic";
inline constexpr char kChromeUIProfilePickerUrl[] = "chrome://profile-picker/";
+inline constexpr char kHeliumSetupHost[] = "setup";
+inline constexpr char kHeliumSetupURL[] = "chrome://setup";
#endif
#if ((BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)) && \
--- a/chrome/browser/ui/BUILD.gn
+++ b/chrome/browser/ui/BUILD.gn
@@ -230,6 +230,8 @@ static_library("ui") {
"webui/net_internals/net_internals_ui.h",
"webui/ntp_tiles_internals_ui.cc",
"webui/ntp_tiles_internals_ui.h",
+ "webui/onboarding/onboarding_page_ui.cc",
+ "webui/onboarding/onboarding_page_ui.h",
"webui/omnibox/omnibox_page_handler.cc",
"webui/omnibox/omnibox_page_handler.h",
"webui/omnibox/omnibox_ui.cc",
--- a/chrome/browser/ui/webui/chrome_web_ui_configs.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_configs.cc
@@ -34,6 +34,7 @@
#include "chrome/browser/ui/webui/net_export_ui.h"
#include "chrome/browser/ui/webui/net_internals/net_internals_ui.h"
#include "chrome/browser/ui/webui/ntp_tiles_internals_ui.h"
+#include "chrome/browser/ui/webui/onboarding/onboarding_page_ui.h"
#include "chrome/browser/ui/webui/omnibox/omnibox_ui.h"
#include "chrome/browser/ui/webui/policy/policy_ui.h"
#include "chrome/browser/ui/webui/predictors/predictors_ui.h"
@@ -383,6 +384,7 @@ void RegisterChromeWebUIConfigs() {
#if !BUILDFLAG(IS_CHROMEOS) && !BUILDFLAG(IS_ANDROID)
map.AddWebUIConfig(std::make_unique<ManagedUserProfileNoticeUIConfig>());
map.AddWebUIConfig(std::make_unique<IntroUIConfig>());
+ map.AddWebUIConfig(std::make_unique<HeliumOnboardingPageConfig>());
map.AddWebUIConfig(std::make_unique<ProfileCustomizationUIConfig>());
map.AddWebUIConfig(std::make_unique<ProfilePickerUIConfig>());
map.AddWebUIConfig(std::make_unique<SigninErrorUIConfig>());
--- a/chrome/browser/chrome_browser_main.cc
+++ b/chrome/browser/chrome_browser_main.cc
@@ -1013,6 +1013,9 @@ int ChromeBrowserMainParts::PreCreateThr
if (first_run::IsChromeFirstRun()) {
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kApp) &&
!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppId)) {
+ // TODO: make this run for every single profile that hasn't seen it yet,
+ // OR inherit preferences from the default profile
+ browser_creator_->AddFirstRunTabs({GURL("chrome://setup")});
browser_creator_->AddFirstRunTabs(master_prefs_->new_tabs);
}
--- /dev/null
+++ b/chrome/browser/ui/webui/onboarding/onboarding_page_ui.cc
@@ -0,0 +1,27 @@
+// Copyright 2025 The Helium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/webui/onboarding/onboarding_page_ui.h"
+
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/common/webui_url_constants.h"
+#include "content/public/browser/web_ui_controller.h"
+#include "content/public/browser/web_ui_data_source.h"
+#include "components/helium_onboarding/resources/grit/helium_onboarding_generated.h"
+#include "components/helium_onboarding/resources/grit/helium_onboarding_generated_map.h"
+#include "ui/webui/webui_util.h"
+
+HeliumOnboardingPage::HeliumOnboardingPage(content::WebUI* web_ui) : WebUIController(web_ui) {
+ content::WebUIDataSource* source =
+ content::WebUIDataSource::CreateAndAdd(
+ Profile::FromWebUI(web_ui), chrome::kHeliumSetupHost
+ );
+
+ webui::SetupWebUIDataSource(
+ source, kHeliumOnboardingGenerated,
+ IDR_HELIUM_ONBOARDING_INDEX_HTML);
+
+ source->UseStringsJs();
+ source->DisableTrustedTypesCSP();
+}
--- /dev/null
+++ b/chrome/browser/ui/webui/onboarding/onboarding_page_ui.h
@@ -0,0 +1,30 @@
+// Copyright 2025 The Helium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_UI_WEBUI_ONBOARDING_ONBOARDING_PAGE_H_
+#define CHROME_BROWSER_UI_WEBUI_ONBOARDING_ONBOARDING_PAGE_H_
+
+#include "chrome/common/webui_url_constants.h"
+#include "content/public/browser/webui_config.h"
+#include "content/public/browser/web_ui_controller.h"
+
+class HeliumOnboardingPage;
+
+class HeliumOnboardingPageConfig
+ : public content::DefaultWebUIConfig<HeliumOnboardingPage> {
+ public:
+ HeliumOnboardingPageConfig()
+ : DefaultWebUIConfig(content::kChromeUIScheme,
+ chrome::kHeliumSetupHost) {}
+};
+
+class HeliumOnboardingPage : public content::WebUIController {
+public:
+ explicit HeliumOnboardingPage(content::WebUI* web_ui);
+
+ HeliumOnboardingPage(const HeliumOnboardingPage&) = delete;
+ HeliumOnboardingPage& operator=(const HeliumOnboardingPage&) = delete;
+};
+
+#endif // CHROME_BROWSER_UI_WEBUI_ONBOARDING_ONBOARDING_PAGE_H_

View File

@@ -96,7 +96,6 @@ extra/ungoogled-chromium/add-flag-for-incognito-themes.patch
extra/ungoogled-chromium/add-flags-for-referrer-customization.patch
extra/ungoogled-chromium/default-webrtc-ip-handling-policy.patch
extra/ungoogled-chromium/add-flags-for-existing-switches.patch
extra/ungoogled-chromium/first-run-page.patch
extra/ungoogled-chromium/disable-capture-all-screens.patch
extra/ungoogled-chromium/add-flag-to-reduce-system-info.patch
extra/ungoogled-chromium/add-flag-to-remove-client-hints.patch
@@ -129,6 +128,7 @@ helium/enable-tab-muting.patch
helium/disable-bookmarks-bar.patch
helium/reenable-spellcheck-downloads.patch
helium/prefer-https-by-default.patch
helium/onboarding-page.patch
helium/settings/move-search-suggest.patch
helium/settings/move-macos-settings.patch