first-run-page.patch 9.1 KB

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