1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -771,6 +771,9 @@ bool HandleNewTabPageLocationOverride(
Profile* profile = Profile::FromBrowserContext(browser_context);
std::string ntp_location =
profile->GetPrefs()->GetString(prefs::kNewTabPageLocationOverride);
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch("custom-ntp"))
+ ntp_location = base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII("custom-ntp");
+ if (profile->IsOffTheRecord() && ntp_location.find("chrome://") != std::string::npos) return false;
if (ntp_location.empty())
return false;
url::Component scheme;
--- a/chrome/browser/ungoogled_flag_entries.h
+++ b/chrome/browser/ungoogled_flag_entries.h
@@ -80,4 +80,8 @@
"Close Confirmation",
"Show a warning prompt when closing the browser window. ungoogled-chromium flag",
kOsDesktop, MULTI_VALUE_TYPE(kCloseConfirmation)},
+ {"custom-ntp",
+ "Custom New Tab Page",
+ "Allows setting a custom URL for the new tab page. Value can be internal (e.g. `about:blank`), external (e.g. `example.com`), or local (e.g. `file:///tmp/startpage.html`). This applies for incognito windows as well when not set to a `chrome://` internal page. ungoogled-chromium flag",
+ kOsDesktop, ORIGIN_LIST_VALUE_TYPE("custom-ntp", "")},
#endif // CHROME_BROWSER_UNGOOGLED_FLAG_ENTRIES_H_
--- a/components/flags_ui/flags_state.cc
+++ b/components/flags_ui/flags_state.cc
@@ -207,6 +207,7 @@ std::string GetCombinedOriginListValue(c
command_line.GetSwitchValueASCII(command_line_switch);
const std::string new_value =
flags_storage.GetOriginListFlag(internal_entry_name);
+ if (command_line_switch == "custom-ntp") return existing_value.empty() ? new_value : existing_value;
return CombineAndSanitizeOriginLists(existing_value, new_value);
}
@@ -395,6 +396,7 @@ void FlagsState::SetOriginListFlag(const
const std::string& value,
FlagsStorage* flags_storage) {
const std::string new_value =
+ internal_name == "custom-ntp" ? value :
CombineAndSanitizeOriginLists(std::string(), value);
flags_storage->SetOriginListFlag(internal_name, new_value);
|