Skip to content

Commit e124d2d

Browse files
AhrotahnPF4Public
authored andcommitted
Add first run page
1 parent de90709 commit e124d2d

File tree

2 files changed

+185
-0
lines changed

2 files changed

+185
-0
lines changed
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
--- a/chrome/browser/chrome_browser_main.cc
2+
+++ b/chrome/browser/chrome_browser_main.cc
3+
@@ -989,6 +989,7 @@ int ChromeBrowserMainParts::PreCreateThr
4+
if (first_run::IsChromeFirstRun()) {
5+
if (!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kApp) &&
6+
!base::CommandLine::ForCurrentProcess()->HasSwitch(switches::kAppId)) {
7+
+ browser_creator_->AddFirstRunTabs({GURL("chrome://ungoogled-first-run")});
8+
browser_creator_->AddFirstRunTabs(master_prefs_->new_tabs);
9+
}
10+
11+
--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
12+
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
13+
@@ -66,6 +66,7 @@
14+
#include "chrome/browser/ui/webui/suggest_internals/suggest_internals_ui.h"
15+
#include "chrome/browser/ui/webui/sync_internals/sync_internals_ui.h"
16+
#include "chrome/browser/ui/webui/translate_internals/translate_internals_ui.h"
17+
+#include "chrome/browser/ui/webui/ungoogled_first_run.h"
18+
#include "chrome/browser/ui/webui/usb_internals/usb_internals_ui.h"
19+
#include "chrome/browser/ui/webui/user_actions/user_actions_ui.h"
20+
#include "chrome/browser/ui/webui/version/version_ui.h"
21+
@@ -1197,6 +1198,8 @@ WebUIFactoryFunction GetWebUIFactoryFunc
22+
}
23+
#endif
24+
25+
+ if (url.host() == "ungoogled-first-run") return &NewWebUI<UngoogledFirstRun>;
26+
+
27+
return nullptr;
28+
}
29+
30+
--- /dev/null
31+
+++ b/chrome/browser/ui/webui/ungoogled_first_run.h
32+
@@ -0,0 +1,142 @@
33+
+#ifndef CHROME_BROWSER_UI_WEBUI_UNGOOGLED_FIRST_RUN_H_
34+
+#define CHROME_BROWSER_UI_WEBUI_UNGOOGLED_FIRST_RUN_H_
35+
+
36+
+#include "base/memory/ref_counted_memory.h"
37+
+#include "chrome/browser/profiles/profile.h"
38+
+#include "content/public/browser/url_data_source.h"
39+
+#include "content/public/browser/web_ui.h"
40+
+#include "content/public/browser/web_ui_controller.h"
41+
+#include "services/network/public/mojom/content_security_policy.mojom.h"
42+
+
43+
+class UFRDataSource : public content::URLDataSource {
44+
+ public:
45+
+ UFRDataSource() {}
46+
+ UFRDataSource(const UFRDataSource&) = delete;
47+
+ UFRDataSource& operator=(const UFRDataSource&) = delete;
48+
+ std::string GetSource() { return "ungoogled-first-run"; }
49+
+ std::string GetMimeType(const GURL& url) { return "text/html"; }
50+
+ std::string GetContentSecurityPolicy(network::mojom::CSPDirectiveName directive) {
51+
+ if (directive == network::mojom::CSPDirectiveName::ScriptSrc)
52+
+ return "script-src 'unsafe-inline'";
53+
+ return std::string();
54+
+ }
55+
+ void StartDataRequest(const GURL& url,
56+
+ const content::WebContents::Getter& wc_getter,
57+
+ GotDataCallback callback) {
58+
+ std::string source = R"(
59+
+<title>ungoogled-chromium first run page</title>
60+
+<meta name="color-scheme" content="light dark">
61+
+<style>
62+
+ @import url(chrome://resources/css/text_defaults_md.css);
63+
+ html{color:#202124; background:white; line-height:1.1em}
64+
+ a{color:#1967d2}
65+
+ h2{margin:0; padding:0.67em 1.33em}
66+
+ p,details{border-top:.063em solid #f0f0f0; margin:0; padding:1em 2em}
67+
+ ul,ol{padding-left:2em}
68+
+ code{background:rgba(128 128 128 / .2); padding:0 0.5em; border-radius:0.25em}
69+
+ summary{cursor:pointer}
70+
+ section{width:60em; margin:4em auto; border-radius:.5em;
71+
+ background:white; box-shadow:0 .063em .125em 0 #c4c5c6, 0 .125em .375em .125em #e2e3e3}
72+
+ @media(prefers-color-scheme:dark){
73+
+ html{color:#e8eaed; background:#202124}
74+
+ a{color:#8ab4f8}
75+
+ p,details{border-top:.063em solid #3f4042}
76+
+ section{background:#292a2d; box-shadow:0 .063em .125em 0 #161719, 0 .125em .375em .125em #1b1c1f}
77+
+ }
78+
+</style>
79+
+<base target="_blank">
80+
+<section>
81+
+ <h2>ungoogled-chromium</h2><p>
82+
+ This browser was built with ungoogled-chromium patches and differs from the default Chromium experience
83+
+ in a few ways. Look over the sections below and the
84+
+ <a href="https://github.com/ungoogled-software/ungoogled-chromium/blob/master/docs/default_settings.md">
85+
+ changes to the default settings</a> to see what may be important to you.<p>
86+
+ This page can always be accessed again at <a href="chrome://ungoogled-first-run">chrome://ungoogled-first-run</a>
87+
+</section>
88+
+<section>
89+
+ <h2>How-To</h2>
90+
+ <details><summary><b>Install and update extensions</b></summary><br>
91+
+ <a href="https://github.com/NeverDecaf">NeverDecaf</a> has created an extension to make this process easy:
92+
+ <ol>
93+
+ <li>Set <a href="chrome://flags/#extension-mime-request-handling">chrome://flags/#extension-mime-request-handling</a>
94+
+ to <code>Always prompt for install</code> and relaunch.</li>
95+
+ <li>Then click on the latest <code>Chromium.Web.Store.crx</code> link on
96+
+ <a href="https://github.com/NeverDecaf/chromium-web-store/releases">the extension's Releases page</a>.</li>
97+
+ </ol>
98+
+ Please check out the <a href="https://github.com/NeverDecaf/chromium-web-store">chromium-web-store</a>
99+
+ repo for further details and alternate installation methods for the extension.<br><br>
100+
+ If you do not wish to install this extension, there is still a way to install other extensions albeit
101+
+ without the ability to easily update them. In this case, please refer to the entry on the wiki for
102+
+ <a href="https://ungoogled-software.github.io/ungoogled-chromium-wiki/faq#downloading-the-crx-file">
103+
+ installing extensions manually</a>.</details>
104+
+ <details><summary><b>Keep login and session data</b></summary><br>
105+
+ By default ungoogled-chromium has <code>Clear cookies and site data when you close all windows</code> enabled.<br>
106+
+ This option can be changed in
107+
+ <a href="chrome://settings/cookies?search=Clear+cookies+and+site+data+when+you+close+all+windows">
108+
+ chrome://settings/cookies</a>.</details>
109+
+ <details><summary><b>Enable spellcheck</b></summary>
110+
+ <ol>
111+
+ <li>Go to <a href="https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries/+/main">
112+
+ https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries/+/main</a></li>
113+
+ <li>Find a bdic file for the language you want and click on it.
114+
+ You will see a mostly empty page aside from "X-byte binary file".</li>
115+
+ <li>On the bottom right corner, click "txt". The direct link for en-US-10-1.bdic is:
116+
+ <a href="https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries/+/main/en-US-10-1.bdic?format=TEXT">
117+
+ https://chromium.googlesource.com/chromium/deps/hunspell_dictionaries/+/main/en-US-10-1.bdic?format=TEXT</a></li>
118+
+ <li>This is a base64-encoded file that needs to be decoded. Use the button below to select the .txt file you saved
119+
+ and save/move the resulting bdic file to your Dictionaries directory. Default locations:
120+
+ <ul>
121+
+ <li>Linux: <code>~/.config/chromium/Dictionaries/</code><br></li>
122+
+ <li>Mac: <code>~/Library/Application Support/Chromium/Dictionaries/</code><br></li>
123+
+ <li>Windows: <code>%LOCALAPPDATA%\Chromium\User Data\Dictionaries\</code><br></li>
124+
+ </ul>
125+
+ <input id="bdic" type="file" accept=".txt,text/plain" />
126+
+ </li>
127+
+ <li>Toggle spell check in <a href="chrome://settings/languages">chrome://settings/languages</a>,
128+
+ or restart the browser for the dictionaries to take effect.</li>
129+
+ </ol></details><p>
130+
+ <a href="https://ungoogled-software.github.io/ungoogled-chromium-wiki/faq">Check out the FAQ on the wiki</a>
131+
+ for information on other common topics.
132+
+</section>
133+
+<section>
134+
+ <h2>Extra Features</h2><p>
135+
+ Most features introduced by ungoogled-chromium are disabled by default and can be enabled in
136+
+ <a href="chrome://flags">chrome://flags</a> or as command-line switches. Take a look at
137+
+ <a href="https://github.com/ungoogled-software/ungoogled-chromium/blob/master/docs/flags.md">
138+
+ the flags documentation</a> to see what features you may find useful to enable.
139+
+</section>
140+
+<section>
141+
+ <h2>Additional Links</h2><p>
142+
+ Privacy and security information, motivation and philosophy, rationale for changes, and more can be found in the
143+
+ <a href="https://github.com/ungoogled-software/ungoogled-chromium/blob/master/README.md">README</a>.<p>
144+
+ Visit our <a href="https://github.com/ungoogled-software/ungoogled-chromium/blob/master/SUPPORT.md">
145+
+ support page</a> if you wish to report problems.<p>
146+
+ Are you a developer? Consider
147+
+ <a href="https://github.com/ungoogled-software/ungoogled-chromium/blob/master/docs/contributing.md">
148+
+ contributing</a> to ungoogled-chromium!
149+
+</section>
150+
+<script>
151+
+ document.getElementById("bdic").onchange = function(e){
152+
+ var f = new FileReader;
153+
+ f.onload = function(){
154+
+ var a = document.createElement("a");
155+
+ a.setAttribute("href", "data:application/octet-stream;base64, " + f.result);
156+
+ a.setAttribute("download", e.target.files[0].name.replace(/\.[^/.]+$/, ".bdic"));
157+
+ a.click()
158+
+ }, f.readAsText(this.files[0])};
159+
+</script>
160+
+)";
161+
+ std::move(callback).Run(base::MakeRefCounted<base::RefCountedString>(std::move(source)));
162+
+ }
163+
+};
164+
+
165+
+class UngoogledFirstRun : public content::WebUIController {
166+
+ public:
167+
+ UngoogledFirstRun(content::WebUI* web_ui) : content::WebUIController(web_ui) {
168+
+ content::URLDataSource::Add(Profile::FromWebUI(web_ui), std::make_unique<UFRDataSource>());
169+
+ }
170+
+ UngoogledFirstRun(const UngoogledFirstRun&) = delete;
171+
+ UngoogledFirstRun& operator=(const UngoogledFirstRun&) = delete;
172+
+};
173+
+
174+
+#endif // CHROME_BROWSER_UI_WEBUI_UNGOOGLED_FIRST_RUN_H_
175+
--- a/chrome/common/webui_url_constants.cc
176+
+++ b/chrome/common/webui_url_constants.cc
177+
@@ -669,6 +669,7 @@ const char kExtensionConfigureCommandsSu
178+
// Add hosts here to be included in chrome://chrome-urls (about:about).
179+
// These hosts will also be suggested by BuiltinProvider.
180+
const char* const kChromeHostURLs[] = {
181+
+ "ungoogled-first-run",
182+
kChromeUIAboutHost,
183+
kChromeUIAccessibilityHost,
184+
#if !BUILDFLAG(IS_ANDROID)

patches/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,4 @@ extra/ungoogled-chromium/add-flag-for-incognito-themes.patch
103103
extra/ungoogled-chromium/add-flags-for-referrer-customization.patch
104104
extra/ungoogled-chromium/default-webrtc-ip-handling-policy.patch
105105
extra/ungoogled-chromium/add-flags-for-existing-switches.patch
106+
extra/ungoogled-chromium/first-run-page.patch

0 commit comments

Comments
 (0)